Просмотр файла c.php

Размер файла: 5.26Kb
  1. <?php
  2. error_reporting(0);
  3. session_save_path('___sess___');
  4. $_SESSION['value']=1;
  5. include 'connect.php';
  6. include 'functions.php';
  7. include 'config.php';
  8. header("Content-type: text/html; charset=utf-8");
  9. header("Cache-Control: no-cache");
  10.  
  11. $p=valid_number($p);
  12. $f=$_GET['f'];
  13. $f=valid_number($f);
  14. $res=mysql_query("SELECT *
  15. FROM `category`
  16. WHERE `id`='$p'
  17. LIMIT 1");
  18. $arr = mysql_fetch_assoc($res);
  19. $dec=urldecode($arr['array']);
  20. $dec=unserialize($dec);
  21.  
  22. if (isset($_GET['add']))
  23. {
  24. session_id(substr(str_shuffle('12345678900987654321543216789009876123456'),0,10));
  25. session_start();
  26. $_SESSION['bot']=1;
  27. $_SESSION['agent']=$_SERVER['HTTP_USER_AGENT'];
  28. $_SESSION['ip']=$_SERVER['REMOTE_ADDR'];
  29. if (is_file($_SERVER['DOCUMENT_ROOT'].$folder.'/___sess___/sess_'.trim($_GET['z'])))
  30. {$_SESSION['value']=1;}
  31. else {$_SESSION['value']=0;}
  32.  
  33.  
  34. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  35. <title>Добавить комментарий-&gt;'.basename($dec[$f]).'</title>
  36. '.$css.'
  37. </head><body>'.$logo.'<form method="post" action="c.php?p='.$p.'&amp;f='.$f.'">
  38. <div class="rekl">'.$reklama.''.$banner_top.'</div>
  39. <div class="zag" align="center">Добавить комментарий-&gt;'.basename($dec[$f]).'</div><div class="c">
  40. &#187; Ник<br/>
  41. <input type="text" name="author" maxlength="10" /><br/>
  42. &#187; Комментарий<br/>
  43. <textarea name="body" cols="30" rows="5"></textarea><br/>
  44. <input type=hidden name="rnd" value="'.session_id().'">
  45. <input type=submit value="Добавить"><br/>
  46. <a href="c.php?p='.$p.'&amp;f='.$f.'">Назад в комментарии '.basename($dec[$f]).'</a><br/>
  47. '.$banner_foot.'</div><div class="kon" align="center">
  48. '.$lnk_partner.'
  49. '.$back_link.''.$copy.'</div>
  50. </form></body></html>';
  51. exit();}
  52.  
  53. if (!empty($_POST))
  54. {
  55. session_id(trim(@$_POST['rnd']));
  56. session_start();
  57. if($_SESSION['bot']==1 and $_SESSION['agent']==$_SERVER['HTTP_USER_AGENT'] and $_SESSION['ip']==$_SERVER['REMOTE_ADDR'] and $_SESSION['value']==1)
  58. {
  59. $_SESSION['bot']=0;
  60. $_SESSION['agent']=0;
  61. $_SESSION['ip']=0;
  62. $_SESSION['value']=0;
  63. session_destroy();
  64. }
  65. else {header('Location: c.php?p='.$p.'&f='.$f.'');
  66. exit();}
  67. ///-----------------------------------------------автор----------------------------------------------------------------///
  68. $author=trim(@$_POST['author']);
  69. $a=iconv("UTF-8", "windows-1251", $author);///перекодировка в Вин-1251
  70. $a=substr($a,0,10);
  71. $author=$a;
  72. $author=iconv("windows-1251", "UTF-8", $author);///перекодировка в utf-8
  73. if ($author==''){$author='Гость';}
  74. $author=htmlspecialchars($author);
  75. $author=mysql_escape_string($author);
  76. ///--------------------------------------------Комментарий-------------------------------------------------------------///
  77. $body=trim(@$_POST['body']);
  78. $b=iconv("UTF-8", "windows-1251", $body);///перекодировка в Вин-1251
  79. $len=strlen($b);
  80. if ($len>768){$b=substr($b,0,768).'...';}
  81. else {}
  82. $body=$b;
  83. $body=iconv("windows-1251", "UTF-8", $body);///перекодировка в utf-8
  84. $body=htmlspecialchars($body);
  85. $body=mysql_escape_string($body);
  86. ///--------------------------------------------------------------------------------------------------------------------///
  87. $time=time();
  88. mysql_query("INSERT INTO `comment`
  89. (`id`, `from`, `name`, `post`, `time`) VALUES
  90. ('', '$dec[$f]', '$author', '$body', '$time');");
  91.  
  92. $inf='Сообщение успешно добавлено!<br/>';
  93. }
  94. $com_count=mysql_query("SELECT *
  95. FROM `comment`
  96. WHERE `from`='$dec[$f]'");
  97. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  98. <title>Загрузки</title>
  99. '.$css.'
  100. </head><body><div class="rekl">'.$reklama.'</div>
  101. <div class="zag" align="center">Комментарии-&gt;'.basename($dec[$f]).'</div><div class="c">'.$inf;
  102. if (!mysql_num_rows($com_count)){echo 'Нет ни одного комментария!<br/>';}
  103. else
  104. {
  105. while ($arr = mysql_fetch_assoc($com_count))
  106. {
  107. $msg=''.date('d/m H:i',$arr['time']).']'.$arr['name'].'<br/>'.$arr['post'].'<br/><br/>';
  108. $arr_msg[]=$msg;
  109. }
  110. $s=valid_number($_GET['s']);
  111. @natsort($arr_msg);
  112. $c_arr=@count($arr_msg);
  113. if ($s>($c_arr-1)){$s=0;}
  114. $total_p=@ceil($c_arr/$p_c);///количество страниц
  115. $first_record = $s;
  116. $last_record = @$first_record+$p_c;
  117.  
  118. for ($i=@$first_record;$i<@$last_record;$i++)
  119. {print_r(@$arr_msg[$i]);}
  120.  
  121.  
  122. if ($s==0 and $c_arr>$s+$p_c){echo '<a href="c.php?p='.$p.'&amp;f='.$f.'&amp;s='.($s+$p_c).'">|Далее&gt;&gt;&gt;</a>';}
  123. elseif ($c_arr>$s+$p_c){echo '<a href="c.php?p='.$p.'&amp;f='.$f.'&amp;s='.($s-$p_c).'">&lt;&lt;&lt;Назад|</a><a href="c.php?p='.$p.'&amp;f='.$f.'&amp;s='.($s+$p_c).'">|Далее&gt;&gt;&gt;</a>';}
  124. elseif (($c_arr-$p_c)<$s and $s<>0){echo '<a href="c.php?p='.$p.'&amp;f='.$f.'&amp;s='.($s-$p_c).'">&lt;&lt;&lt;Назад|</a>';}
  125. echo '<br/>';
  126. }
  127. session_id(substr(str_shuffle('12345678900987654321543216789009876123456'),0,11));
  128. session_start();
  129. echo '<a href="c.php?p='.$p.'&amp;f='.$f.'&amp;add=1&amp;z='.session_id().'">Добавить</a><br/>
  130. </div><div class="kon" align="center">
  131. <a href="'.$folder.'/?p='.$p.'&amp;f='.$f.'" style="color: #ecffff">Меню файла '.basename($dec[$f]).'</a><br/>
  132. '.$back_link.'</div>
  133. </body></html>';
  134. ?>