Файл: modules/phpcodes/code.php
Строк: 32
<?php
$title = 'Полезные PHP коды | Просмотр кода';
include_once($_SERVER["DOCUMENT_ROOT"].'/style/head.php');
$_GET['id'] = abs(intval($_GET['id']));
if($db->query("SELECT `id` FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->num_rows==0){
error('Кода не существует');
}
$db->query("UPDATE `phpcodes_codes` SET `views`=`views`+1 WHERE `id`='".$_GET['id']."'");
if(isset($user['id'])){
if($db->query("SELECT `id` FROM `phpcodes_views` WHERE `id_us`='".$user['id']."' AND `id_code`='".$_GET['id']."'")->num_rows==0){
$db->query("UPDATE `phpcodes_codes` SET `unique_views`=`unique_views`+1 WHERE `id`='".$_GET['id']."'");
$db->query("INSERT INTO `phpcodes_views` SET `id_us`='".$user['id']."', `id_code`='".$_GET['id']."'");
}
}
$code = $db->query("SELECT * FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->fetch_assoc();
$folder = $db->query("SELECT * FROM `phpcodes_folders` WHERE `id`='".$code['folder']."'")->fetch_assoc();
?>
<div class="title"><a href="/phpcodes">Полезные PHP коды</a> | <a href="/phpcodes/folder/<?=$folder['id']?>"><?=htmlspecialchars($folder['name'])?></a> | <?=htmlspecialchars($code['name'])?></div>
<?
if($code['moderation']==0 AND $user['level']<1){
error('Код находиться на модерации.');
}
if($code['moderation']==2){
error('Код отклонён.');
}
?>
<div class="text">
<?
if($user['level']>=1 or $code['id_us']==$user['id']){
?>
<a href="/phpcodes/code/<?=$_GET['id']?>/edit">Редактировать</a>
<?
if($user['level']>=1){
?>
<a href="/phpcodes/code/<?=$_GET['id']?>/del">Удалить</a>
<?
}
?>
<br/>
<?
}
?>
<b>Название:</b> <?=htmlspecialchars($code['name'])?><br/>
<b>Описание:</b><br/>
<?=output($code['description'])?><br/>
<b>Код:</b><br/>
<?=highlight_string($code['code'], true)?><br/>
</div>
<div class="section1">
<b>Добавил:</b> <?=nick($code['id_us'])?>(<?=times($code['time'])?>)<br/>
<b>Просмотров:</b> <?=$code['views']?><br/>
<b>Уникальных просмотров:</b> <?=$code['unique_views']?><br/>
<b>Рейтинг:</b> <font color="green"><?=$code['plus']?></font>/<font color="red"><?=$code['minus']?></font> [<a href="/phpcodes/history_rating/<?=$_GET['id']?>">История изменения рейтинга</a>]
<?
if(isset($user['id']) AND $db->query("SELECT `id` FROM `phpcodes_rating` WHERE `id_us`='".$user['id']."' AND `id_code`='".$_GET['id']."'")->num_rows==0 AND $user['id']!=$code['id_us']){
?>
<a href="/phpcodes/plus/<?=$_GET['id']?>">+</a> | <a href="/phpcodes/minus/<?=$_GET['id']?>">-</a>
<?
}
?>
</div>
<div class="section"><a href="/phpcodes/comm/<?=$_GET['id']?>">Комментарии [<?=$db->query("SELECT `id` FROM `phpcodes_comm` WHERE `code`='".$_GET['id']."'")->num_rows?>]</a></div>
<?
include_once($_SERVER["DOCUMENT_ROOT"].'/style/foot.php');
?>