Файл: modules/pc/index.php
Строк: 236
<?php
include '../../system/core.php';
include '../../system/header.php';
if(!$user['id']){
header('Location: /index.php'); exit;
}
echo '<div class="tegi"><b>Куски полезных кодов</b></div></div></div>';
include '../../modules/op/c.php';
include '../../modules/privat/c.php';
switch($_GET['m']){
case 'new':
$cop = 10;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `pc_code` where `time` > '".(time()-((60*60)*24))."'"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$new = mysql_query("select * from `pc_code` where `time` > '".(time()-((60*60)*24))."' order by `time` desc limit $start,$cop");
while($new2 = mysql_fetch_assoc($new)){
echo '<div class="post1">';
echo '<a href="/pc/code'.$new2['id'].'"><div class="men"><img src="/images/spiscod.png">'.$new2['name'].'';
echo '</div></a>';
}
echo '</div><div class="spis">Стр. ';
if($p-2>0) echo '<a href="/pc/new?p=1"><<</a> ';
if($p-1>0) echo '<a href="/pc/new?p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/pc/new?p='.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/pc/new?p='.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/pc/new?p='.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/pc/new?p='.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/pc/new?p='.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/pc/new?p='.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/pc/new?p='.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/pc/new?p='.ceil($ca/$cop).'">>></a>';
echo '</div>';
break;
#Главная
default:
if($user['status'] >1){ echo '<div class="s"> <div class="ss"><span><a href="/pc/nr">Добавить раздел</a>|
<a href="/pc/moder">Панель управления</a><span></div></div>';}
echo '<div class="post1"><img src="/images/topcod.png"/> <a href="/pc/best"> Топ кодов</a><br>
<img src="/images/newcod.png"/> <a href="/pc/new">Новые коды</a> ('.mysql_result(mysql_query('select count(`id`) from `pc_code` where `time` > "'.(time()-((60*60)*24)).'" and `status` = "0"'),0).')<br></div>';
$cop = 10;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `pc_r`"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$pc_r = mysql_query("SELECT * FROM `pc_r` ORDER BY `id` DESC LIMIT $start,$cop");
if(isset($_GET['dr'])){
$id = TextGuard($_GET['id']);
if(empty($id) or !is_numeric($id)){
header('Location: ?'); exit;
}
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = "'.$id.'"'));
if($pc_r == 0){
header('Location: /pc'); exit;
}
$pc_r_code = mysql_query('select * from `pc_code` where `r` = "'.$id.'"');
while($pc_r_code2 = mysql_fetch_array($pc_r_code)){
mysql_query("DELETE FROM `pc_code` WHERE `id` = '".$pc_r_code2['id']."'");
}
mysql_query("DELETE FROM `pc_r` WHERE `id` = '$id'");
header('Location: /pc'); exit;
}
while($pc_r2 = mysql_fetch_assoc($pc_r)){
echo ' <div class="post2"> <a href="/pc/r'.$pc_r2['id'].'"><img src="/images/razcod.png"/> <b>'.$pc_r2['name'].'</b></a> ('.mysql_result(mysql_query('select count(`id`) from `pc_code` where `r` = "'.$pc_r2['id'].'" and `status` = "0"'),0).')';
if($user['status'] >= 1) echo ' [<a href="/pc?dr&id='.$pc_r2['id'].'">уд</a>] [<a href="/pc/re'.$pc_r2['id'].'">ред</a>]';
echo '</div>';
}
echo '<div class="spis">Стр. ';
if($p-2>0) echo '<a href="/pc?p=1"><<</a> ';
if($p-1>0) echo '<a href="/pc?p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/pc?p='.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/pc?p='.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/pc?p='.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/pc?p='.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/pc?p='.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/pc?p='.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/pc?p='.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/pc?p='.ceil($ca/$cop).'">>></a>';
echo '</div>';
////////////////////////////////////////////////
if(mysql_result(mysql_query('select count(`id`) from `pc_code` where `time` > "'.(time()-((60*60)*24)).'" and `status` = "0"'),0) != 0) $codes_new = '/<font color="red"><b>+'.mysql_result(mysql_query('select count(`id`) from `pc_code` where `time` > "'.(time()-((60*60)*24)).'" and `status` = "0"'),0).'</b></font>';
echo '<div class="tegi"><font color="white"><b>Последние коды</b></font></div>';
if(mysql_result(mysql_query('select count(`id`) from `pc_code`'),0) != 0)
{
$pc_code = mysql_query('select * from `pc_code` where `status` = "0" order by `time` desc limit 3');
while($pc_code2 = mysql_fetch_array($pc_code))
{
echo '<div class="post1"><img src="/images/spiscod.png"/><a href="/pc/code'.$pc_code2['id'].'"> '.$pc_code2['name'].'</a></div>';
}
}
else
{
echo '<div class="err"><b>Еще нет....</b></div>';
}
break;
case 'r':
$id = TextGuard($_GET['id']);
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = '.$id.' limit 1'));
if(empty($id) or !is_numeric($id) or $pc_r == 0){
header('Location: /pc'); exit;
}
echo '<div class="s"><div class="ss"><span><a href="/pc/r'.$id.'/add"> Добавить код</a></span></div></div>';
$cop = 10;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `pc_code` where `r` = '".$id."' and `status` = '0'"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$pc_code = mysql_query("SELECT * FROM `pc_code` where `r` = '".$id."' and `status` = '0' ORDER BY `id` DESC LIMIT $start,$cop");
if(isset($_GET['dc'])){
$cid = TextGuard($_GET['cid']);
if(empty($cid) or !is_numeric($cid)){
header('Location: ?'); exit;
}
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = "'.$cid.'"'));
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = "'.$id.'"'));
if($pc_r == 0 or $pc_code == 0){
header('Location: /pc/r'.$id.''); exit;
}
mysql_query("DELETE FROM `pc_code` WHERE `id` = '$cid'");
header('Location: /pc/r'.$id.''); exit;
}
while($pc_code2 = mysql_fetch_assoc($pc_code)){
echo '<div class="post1"> <img src="/images/spiscod.png"/> <a href="/pc/code'.$pc_code2['id'].'">'.$pc_code2['name'].'</a>';
if($user['status'] >= 1) echo ' [<a href="/pc/r'.$id.'?dc&cid='.$pc_code2['id'].'">уд</a>] ';
echo '</div>';
}
echo '<div class="levo">Стр. ';
if($p-2>0) echo '<a href="/pc/r'.$id.'/p1"><<</a> ';
if($p-1>0) echo '<a href="/pc/r'.$id.'/p'.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/pc/r'.$id.'/p'.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/pc/r'.$id.'/p'.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/pc/r'.$id.'/p'.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/pc/r'.$id.'/p'.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/pc/r'.$id.'/p'.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/pc/r'.$id.'/p'.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/pc/r'.$id.'/p'.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/pc/r'.$id.'/p'.ceil($ca/$cop).'">>></a>';
echo '</div>';
break;
case 'add':
echo '<div class="s"><div class="ss"><span><a href="/pc/r'.$id.'"> Назад</a></span></div></div>';
$id = TextGuard($_GET['id']);
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = '.$id.' limit 1'));
if(empty($id) or !is_numeric($id) or $pc_r == 0){
header('Location: /pc'); exit;
}
if(isset($_POST['submit'])){
$name = TextGuard($_POST['name']);
if(empty($name)) $err[] = 'Вы не ввели описание...';
$code = trim(htmlspecialchars($_POST['code']));
if(empty($code)) $err[] = 'Вы не ввели код...';
if(!$err){
mysql_query("INSERT INTO `pc_code`(
`r`,
`author`,
`name`,
`code`,
`time`,
`status`
)VALUES(
'".$id."',
'".$user['id']."',
'".$name."',
'".$code."',
'".time()."',
'1'
)");
$pc_rss = mysql_query("SELECT * FROM `user` WHERE `status` > '1'");
while($pc_rss2 = mysql_fetch_assoc($pc_rss)){
mysql_query("INSERT INTO `op`(
`who`,
`ho`,
`text`,
`time`,
`read`
)VALUES(
'".$pc_rss2['id']."',
'".$user['id']."',
'добавил [url=/pc/moder]код[/url] в полезные коды!',
'".time()."',
'0'
)");
}
echo '<div class="msg"><img src="/modules/profile/images/clean.png"/> Код успешно выставлен на модерацию!</div>';
}else{
echo '<div class="err">';
foreach($err as $err_info){
echo $err_info.'<br>';
}
echo '</div>';
}
}
echo '
<div class="glav">
<form action="" method="post">
Описание:<br><input name="name"/><br>
Код:<br><textarea name="code" style="width:98%;" rows="3"></textarea><br>
<input type="submit" value="Добавить" name="submit"/>
</form></div>
';
break;
case 'nr':
echo '<div class="s"><div class="ss"><span><a href="/pc"> В кода</a></span></div></div>';
if(isset($_POST['submit'])){
$name = TextGuard($_POST['name']);
if(empty($name)) $err[] = 'Вы не ввели название...';
if(!$err){
mysql_query("INSERT INTO `pc_r`(
`name`
)VALUES(
'".$name."'
)");
header('Location: /pc'); exit;
}else{
echo '<div class="err">';
foreach($err as $err_info){
echo $err_info.'<br>';
}
echo '</div>';
}
}
echo '
<div class="glav">
<form action="" method="post">
Название:<br><input name="name"/><br>
<input type="submit" value="Добавить" name="submit"/>
</form></div>
';
break;
case 'moder':
echo '<div class="s"><div class="ss"><span><a href="/pc/">В кода</a></span></div></div>';
if($user['status'] < 1){
header('Location: /pc'); exit;
}
if(isset($_GET['ok0'])){
$id = TextGuard($id);
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = "'.$id.'"'));
if(empty($id) or $pc_code == 0){
header('Location: /pc/moder'); exit;
}
mysql_query("UPDATE `pc_code` SET `status`='0' WHERE `id`='".$id."' limit 1");
mysql_query("INSERT INTO `op`(
`who`,
`ho`,
`text`,
`time`,
`read`
)VALUES(
'".$pc_code['author']."',
'".$user['id']."',
'добавил ваш [url=/pc/code".$id."]код[/url] в куски полезных кодов!',
'".time()."',
'0'
)");
header('Location: /pc/code'.$id.''); exit;
}
if(isset($_GET['ok1'])){
$id = TextGuard($id);
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = "'.$id.'"'));
if(empty($id) or $pc_code == 0){
header('Location: /pc/moder'); exit;
}
mysql_query("DELETE FROM `pc_code` WHERE `id`='".$id."'");
header('Location: /pc/moder'); exit;
}
$cop = 10;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `pc_code` where `status` = '1'"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$pc_code = mysql_query("SELECT * FROM `pc_code` where `status` = '1' ORDER BY `id` DESC LIMIT $start,$cop");
while($pc_code2 = mysql_fetch_assoc($pc_code)){
echo '<div class="post1">'.ustatus($pc_code2['author']).' <a href="/us'.$pc_code2['author'].'">'.uname($pc_code2['author']).'</a> '.uaccess($pc_code2['author']).': '.$pc_code2['name'].' в раздел';
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = "'.$pc_code2['r'].'"'));
echo ' <a href="/pc/r'.$pc_r['id'].'">'.$pc_r['name'].'</a>';
echo '<br><div class="cit"><code>'.$pc_code2['code'].'</code></div>
<a href="/pc/moder?ok0&id='.$pc_code2['id'].'"><input type="submit" value="принять"/></a> <a href="/pc/moder?ok1&id='.$pc_code2['id'].'"><input type="submit" value="отклонить"/></a></div>';
}
echo '<div class="spis">Стр. ';
if($p-2>0) echo '<a href="/pc/moder?p=1"><<</a> ';
if($p-1>0) echo '<a href="/pc/moder?p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/pc/moder?p'.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/pc/moder?p='.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/pc/moder?p='.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/pc/moder?p='.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/pc/moder?p='.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/pc/moder?p='.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/pc/moder?p='.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/pc/moder?p='.ceil($ca/$cop).'">>></a>';
echo '</div></div>';
break;
case 'code':
$id = TextGuard($_GET['id']);
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = '.$id.' limit 1'));
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = '.$id.' limit 1'));
if(empty($id) or !is_numeric($id) or $pc_code == 0 or $pc_r == 0){
header('Location: /pc'); exit;
}
if(isset($_GET['del']) && $user['status'] >= 1){
mysql_query("DELETE FROM `pc_code` WHERE `id` = '$id'");
header('Location: /pc/c'.$id.''); exit;
}
if(isset($_GET['dc'])){
$cid = TextGuard($_GET['cid']);
if(empty($cid) or !is_numeric($cid)){
header('Location: ?'); exit;
}
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = "'.$cid.'"'));
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = "'.$id.'"'));
if($pc_r == 0 or $pc_code == 0){
header('Location: /pc/r'.$id.''); exit;
}
mysql_query("DELETE FROM `pc_code` WHERE `id` = '$cid'");
header('Location: /pc/r'.$id.''); exit;
}
/////////////////////////////////////////////////
$rek = mysql_query("SELECT * FROM `ads` WHERE `mode` = '1'");
echo '<div class="rek"><div class="rekl"><img src="/images/r.png" alt="*"> <a href="/bl?bl=rek">Купить рекламу</a></br>';
while($rek2 = mysql_fetch_array($rek))
{
echo '<img src="/images/r.png" alt="*"> <a href="'.$rek2['link'].'">'.$rek2['name'].'</a></br>';
}
echo '</div>';
echo '</div>';
include 'system/nvg.php';
if($user['id']) {
echo ' <div class="start">';
echo '<div class="s" style="border-bottom:none;">';
echo '<table style="width:100%" cellspacing="0" cellpadding="0">';
echo '<tbody><tr><td style="vertical-align:top;width:10%;">';
echo '<center>';
echo '<a href="/cab" title="Кабинет"><img class="ico" align="middle" src="/images/vcard.png" alt="*"></a></center></td>';
echo '<td style="vertical-align:top;width:10%;">';
echo '<center>';
echo '<a href="/privat/" title="Почта"><img class="ico" align="middle" src="/images/mail2.png" alt="*"></a>';
if($user['id']){
$c = mysql_result(mysql_query('select count(`id`) from `privat` where `ho` = "'.$user['id'].'" and `read` = "0"'),0);
if($c != 0) echo ' <b> (+'.$c.')</b>';
}
echo '</center></td>';
echo '<td style="vertical-align:top;width:10%;">';
echo '<center><a href="/op/" title="Оповещения"><img class="ico" align="middle" src="/images/warning.png" alt="*"></a>';
if($user['id']){
$c = mysql_result(mysql_query('select count(`id`) from `op` where `who` = "'.$user['id'].'" and `read` = "0"'),0);
if($c != 0) echo '<b> (+'.$c.')</b>';
}
echo '</center></td>';
echo '</tr></tbody></table>';
echo '</div>';
}
//////////////////////////////////////////////////////
$pc_code['code'] = str_replace("rn","<br/>",$pc_code['code']);
echo '<div class="post2">Код:</br>
<div class="cit">'.$pc_code['code'].'</div>
</div>';
echo '<div class="post1">
Добавил: '.ustatus($pc_code['author']).' <a href="/us'.$pc_code['author'].'">'.uname($pc_code['author']).'</a> '.uaccess($pc_code['author']).' ('.times($pc_code['time']).')</div>
';
//рейтинг
if(isset($_GET['v'])){
$go = TextGuard($_GET['go']);
$rate = mysql_fetch_array(mysql_query('select * from `pc_rate` where `c` = '.$id.' and `who` = "'.$user['id'].'"'));
if(empty($go) or $go != "p" && $go != "m" or $rate != 0 or $user['id'] == $pc_code['author']){
header('Location: /pc/code'.$id.''); exit;
}
if($go == "p") $status = 1; elseif($go == "m") $status = 2;
mysql_query("INSERT INTO `pc_rate`(
`c`,
`who`,
`status`,
`time`
)VALUES(
'".$id."',
'".$user['id']."',
'".$status."',
'".time()."'
)");
$pc_cc = mysql_fetch_array(mysql_query('select * from `user` where `id` = "'.$pc_code['author'].'"'));
if($pc_cc != 0){
if($status == 1){
///
mysql_query("UPDATE `user` SET `rating`='".($pc_cc['rating']+0.01)."' WHERE `id`='".$pc_cc['id']."' limit 1");
mysql_query("INSERT INTO `op`(
`who`,
`ho`,
`text`,
`time`,
`read`,
`sort`
)VALUES(
'".$pc_cc['id']."',
'".$user['id']."',
'оценил [b]положительно[/b] ваш [url=/pc/code".$id."]код[/url]!',
'".time()."',
'0',
'3'
)");
}elseif($status == 2){
mysql_query("UPDATE `user` SET `rating`='".($pc_cc['rating']-0.01)."' WHERE `id`='".$pc_cc['id']."' limit 1");
mysql_query("INSERT INTO `op`(
`who`,
`ho`,
`text`,
`time`,
`read`,
`sort`
)VALUES(
'".$pc_cc['id']."',
'".$user['id']."',
'оценил [b]отрицательно[/b] ваш [url=/pc/code".$id."]код[/url]!',
'".time()."',
'0',
'3'
)");
}
}
}
echo '<div class="post1"><a href="/pc/code'.$id.'/txt">Скопирывать код для вставки</a></div>';
echo '<div class="post1">
Рейтинг: ';
$all = mysql_result(mysql_query('select count(`id`) from `pc_rate` where `c`= "'.$id.'" and `status` = "1"'),0)-mysql_result(mysql_query('select count(`id`) from `pc_rate` where `c`= "'.$id.'" and`status` = "2"'),0);
$rate = mysql_fetch_array(mysql_query('select * from `pc_rate` where `c` = '.$id.' and `who` = "'.$user['id'].'"'));
if($rate == 0 && $user['id'] != $pc_code['author']) echo '<a href="/pc/code'.$id.'?v&go=p">+</a> | <a href="/pc/code'.$id.'?v&go=m">-</a> ';
if($all < 0) echo '<font color="red"><big><b>'.$all.'</b></big></font>';
elseif($all == 0) echo '<font color="red"><big><b>0</b></big></font>';
elseif($all > 0) echo '<font color="green"><big><b>'.$all.'</b></big></font>';
echo ' (<font color="green">'.mysql_result(mysql_query('select count(`id`) from `pc_rate` where `c`= "'.$id.'" and `status` = "1"'),0).'</font>/<font color="red">'.mysql_result(mysql_query('select count(`id`) from `pc_rate` where `c`= "'.$id.'" and`status` = "2"'),0).'</font>)</div>
<div class="post1"><a href="/pc/ccom'.$id.'">Комментарии</a> ('.mysql_result(mysql_query('select count(`id`) from `pc_ccom` where `code` = "'.$id.'"'),0).')
</div>';
break;
case 're':
$id = TextGuard($_GET['id']);
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = '.$id.' limit 1'));
if(empty($id) or !is_numeric($id) or $pc_r == 0){
header('Location: /pc'); exit;
}
if(isset($_POST['submit'])){
$text = TextGuard($_POST['text']);
if(empty($text)) $err[] = 'Название осталось пустым...';
if(!$err){
mysql_query("UPDATE `pc_r` SET `name`='".$text."' WHERE `id` = '".$id."' limit 1");
header('Location: /pc'); exit;
}else{
echo '<div class="rega">';
foreach($err as $err_info){
echo $err_info.'<br>';
}
echo '</div>';
}
}
echo '<div class="news"><div class="newss">
<form action="" method="post">
Название:<br><input name="text" value="'.$pc_r['name'].'"/><br>
<input type="submit" value="Сохранить" name="submit"/>
</form></div></div>';
break;
case 'ccom':
$id = TextGuard($id);
$pc_code = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = '.$id.' and `status` = "0"'));
$pc_r = mysql_fetch_array(mysql_query('select * from `pc_r` where `id` = '.$pc_code['r'].''));
if(empty($id) or !is_numeric($id) or $pc_r == 0 or $pc_code == 0){
header('Location: /pc'); exit;
}
echo '<div class="stat">
Код: <a href="/pc/code'.$id.'">'.$pc_code['name'].'</a>
</div><div class="tegi"><font color="white">
Комментарии:
</font> </div>';
echo '<div class="glav"><form action="" method="post">
Сообщение:<br><textarea name="text" style="width:98%;" rows="3"></textarea><br>
<input type="submit" name="submit" value="Написать"/>
</form></div>';
if(isset($_POST['submit'])){
$text = TextGuard($text);
if(empty($text)) $err[] = 'Сообщение осталось пустым...';
$ncm = mysql_query("SELECT * FROM `pc_ccom` WHERE `who`='".$user['id']."' ORDER BY `time` desc");
while($ncm2 = mysql_fetch_assoc($ncm)){
$ncm_timeout = $ncm2['time'];
if((time()-$ncm_timeout) < 5) $err[] = 'Писать можно только раз в 5 секунд...';
}
$ncm_rep = mysql_fetch_array(mysql_query('select * from `pc_ccom` where `who` = "'.$user['id'].'" and `text` = "'.$text.'"'));
if($ncm_rep != 0) $err[] = 'Вы уже писали подобное сообщение...';
if(!$err){
mysql_query("INSERT INTO `pc_ccom`(
`code`,
`who`,
`text`,
`time`
)VALUES(
'".$id."',
'".$user['id']."',
'".$text."',
'".time()."'
)");
mysql_query("INSERT INTO `op`(
`who`,
`ho`,
`text`,
`time`,
`read`
)VALUES(
'".$pc_code['author']."',
'".$user['id']."',
'написал [url=/pc/ccom".$id."]комментарий[/url] к вашему [url=/pc/code".$id."]коду[/url]!',
'".time()."',
'0'
)");
header('Location: /pc/ccom'.$id.''); exit;
}else{
echo '<div class="err"><b>';
foreach($err as $err_info){
echo $err_info.'<br>';
}
echo '</b></div>';
}
}
$cop = 10;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `pc_ccom` where `code` = '".$id."'"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p']) && $ca != 0){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
if($ca != 0){
$pc_ccom = mysql_query("SELECT * FROM `pc_ccom` where `code` = '".$id."' ORDER BY `id` DESC LIMIT $start,$cop");
while($pc_ccom2 = mysql_fetch_assoc($pc_ccom)){
echo '<div class="post1">'.ustatus($pc_ccom2['who']).' <a href="/us'.$pc_ccom2['who'].'">'.uname($pc_ccom2['who']).'</a> '.uaccess($pc_ccom2['who']).' ('.times($pc_ccom2['time']).')';
if($user['status'] >= 1) echo ' [<a href="/pc/ccom'.$id.'?p='.$p.'&dp&pid='.$pc_ccom2['id'].'">уд</a>]';
echo '<br>'.smiles(bbcode($pc_ccom2['text'])).'</div>';
}}
if(isset($_GET['dp']) && $user['status'] >= 1){
$pid = TextGuard($_GET['pid']);
$posts = mysql_fetch_array(mysql_query('select * from `pc_ccom` where `id` = "'.$pid.'" limit 1'));
if($posts == 0 or empty($pid) or !is_numeric($pid)){
header('Location: /pc/ccom'.$id.'?p='.$p.''); exit;
}
mysql_query("DELETE FROM `pc_ccom` WHERE `id`='".$pid."'");
header('Location: /pc/ccom'.$id.'?p='.$p.''); exit;
}
echo '<div class="spis">Стр. ';
if($p-2>0) echo '<a href="/pc/ccom'.$id.'?p=1"><<</a> ';
if($p-1>0) echo '<a href="/pc/ccom'.$id.'?p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/pc/ccom'.$id.'?p'.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/pc/ccom'.$id.'?p='.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/pc/ccom'.$id.'?p='.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/pc/ccom'.$id.'?p='.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/pc/ccom'.$id.'?p='.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/pc/ccom'.$id.'?p='.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/pc/ccom'.$id.'?p='.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/pc/ccom'.$id.'?p='.ceil($ca/$cop).'">>></a>';
echo '</div></div>';
break;
case 'txt':
$id = TextGuard($_GET['id']);
echo '<div class="s"><div class="ss"><span><a href="/pc/code'.$id.'"> Назад</a></span></div></div>';
if(empty($id) or !is_numeric($id))
{
header('Location: /pc'); exit;
}
$pcc_c = mysql_fetch_array(mysql_query('select * from `pc_code` where `id` = "'.$id.'"'));
if($pcc_c == 0)
{
header('Location: /pc'); exit;
}
echo '<div class="post2">
Код для вставки:<br><textarea style="width:98%" name="" rows="3">'.$pcc_c['code'].'
©Scriptwm.ru</textarea></div>';
break;
}
include '../../system/footer.php';
?>