Просмотр файла forum/search.php

Размер файла: 6.81Kb
  1. <?php
  2. require_once ("../includes/start.php");
  3. require_once ("../includes/functions.php");
  4. require_once ("../includes/header.php");
  5. include_once ("../themes/".$config['themes']."/index.php");
  6. include_once ("../includes/db.php");
  7.  
  8.  
  9. if ($_REQUEST['chto'] != NULL || $_REQUEST['who'] !=NULL || $_REQUEST['wh'] != NULL){
  10. if (isset($_GET['start'])){$start = (int)$_GET['start'];} else {$start = 0;}
  11. $total = 0;
  12.  
  13.  
  14. function pages($start, $total, $onpage, $home){
  15. if ($start != 0)
  16. echo '<a href="'.$home.'/forum/search.php?start='.($start - $onpage).'">&lt;-Назад</a> ';
  17. else echo '&lt;-Назад';
  18. echo ' | ';
  19. if ($total > $start + $onpage)
  20. echo ' <a href="'.$home.'/forum/search.php?start='.($start + $onpage).'">Далее-&gt;</a>';
  21. else echo 'Далее-&gt;';
  22. if ($total > 0) {
  23. $ba = ceil($total / $onpage);
  24. $ba2 = $ba * $onpage - $onpage;
  25. echo '<br/>Страницы:';
  26. $asd = $start - ($onpage * 3);
  27. $asd2 = $start + ($onpage * 4);
  28. if ($asd < $total && $asd > 0)
  29. echo ' <a href="'.$home.'/forum/search.php?start=0">1</a> ... ';
  30. for($i = $asd; $i < $asd2;) {
  31. if ($i < $total && $i >= 0) {
  32. $ii = floor(1 + $i / $onpage);
  33. if ($start == $i) echo ' <b>[' . $ii . ']</b>';
  34. else echo ' <a href="'.$home.'/forum/search.php?start='.$i.'&amp;'.SID.'">' . $ii . '</a>';}
  35. $i = $i + $onpage;}
  36. if ($asd2 < $total) echo ' ... <a href="'.$home.'/forum/?act=themes&amp;id='.$id.'&amp;start='.$ba2.'&amp;'.SID.'">' . $ba . '</a>';}}
  37.  
  38.  
  39.  
  40. $chto = check($_REQUEST['chto']);
  41. $whos = check($_REQUEST['who']);
  42. $wh = (int)$_REQUEST['wh'];}
  43. $who = substr($whos, 2);
  44. $substrw = $whos{0};
  45.  
  46. if (strlen($chto) < '3'){echo '<br><div><img src="'.$config['home'].'/forum/img/err.gif" alt=""> <small>Слишком маленький запрос!</small></div><br><hr><div>';
  47. echo ': <a href="'.$config['home'].'/forum/index.php?act=search&amp;'.SID.'">Поиск</a><br>';
  48. echo ':: <a href="'.$config['home'].'/forum/index.php?'.SID.'">В форум</a><br>';
  49. echo '::: <a href="'.$config['home'].'/index.php?'.SID.'">На главную</a>';
  50. echo '</div><div style="margin: 0px 0px -5px 0px"><img src="'.$config['home'].'/forum/img/byforum.gif" alt=""></div>';
  51. include_once ("../themes/".$config['themes']."/foot.php"); exit;}
  52.  
  53. if (strlen($chto) > '32'){echo '<br><div><img src="'.$config['home'].'/forum/img/err.gif" alt=""> <small>Слишком большой запрос!</small></div><br><hr><div>';
  54. echo ': <a href="'.$config['home'].'/forum/index.php?act=search&amp;'.SID.'">Поиск</a><br>';
  55. echo ':: <a href="'.$config['home'].'/forum/index.php?'.SID.'">В форум</a><br>';
  56. echo '::: <a href="'.$config['home'].'/index.php?'.SID.'">На главную</a>';
  57. echo '</div><div style="margin: 0px 0px -5px 0px"><img src="'.$config['home'].'/forum/img/byforum.gif" alt=""></div>';
  58. include_once ("../themes/".$config['themes']."/foot.php"); exit;}
  59.  
  60. echo '<div class="b"> Поиск по форуму</div>';
  61.  
  62.  
  63. if ($wh == '0'){
  64.  
  65. if ($who !='0'){
  66. if ($substrw =='f'){
  67. $sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `forums` LIKE '".$who."' LIMIT $start, 10";
  68. }else{
  69. $sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `under` LIKE '".$who."' LIMIT $start, 10";}
  70. }else{$sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' LIMIT $start, 10";}
  71.  
  72.  
  73. $sar = mysql_query($sqlresult);
  74. if (mysql_num_rows($sar)) {
  75.  
  76.  
  77. if ($who !='0'){
  78. $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `under` LIKE '%".$who."%'"),0);
  79. }else{
  80. $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `name` LIKE '%".$chto."%' "),0);}
  81. $start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
  82. if ($start > $total) $start = 0;
  83. if ($total < $start + 10) $end = $total;
  84. else $end = $start + 10;
  85.  
  86.  
  87. while ($src = mysql_fetch_array($sar)) {
  88. echo '<div><img src="'.$config['home'].'/forum/img/t.gif" alt=""> ';
  89. echo '<a href="'.$config['home'].'/forum/posts/'.$src['id'].'"><b>'.$src['name'].'</b></a><br>';
  90.  
  91. echo '<small>Создал: '.nickname($src['author']).' <br>';
  92. if($src['description']){echo 'Кратко: '.$src['description'].' <br>';}
  93. echo 'Последний: '.nickname($src['last']).' <br>';
  94. echo '</small><hr></div>';}
  95. }else{ echo '<br><div><img src="'.$config['home'].'/forum/img/err.gif" alt=""> <small>По вашему запросу ничего не найдено!</small></div><br><hr>';}}
  96.  
  97. elseif ($wh=='1'){
  98.  
  99. if ($who != '0'){
  100.  
  101. if ($substrw =='f'){
  102. $sqlresult = "SELECT * FROM `posts` WHERE `forums` = '".$who."' AND `msg` LIKE '%".$chto."%' LIMIT $start, 10";
  103. }else{
  104. $sqlresult = "SELECT * FROM `posts` WHERE `under` = '".$who."' AND `msg` LIKE '%".$chto."%' LIMIT $start, 10";}
  105.  
  106.  
  107. }else{$sqlresult = "SELECT * FROM `posts` WHERE `msg` LIKE '%".$chto."%' LIMIT $start, 10";}
  108.  
  109. $sar = mysql_query($sqlresult);
  110. if (mysql_num_rows($sar)) {
  111.  
  112.  
  113. if ($who !='0'){
  114. $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `msg` LIKE '%".$chto."%' AND `under` LIKE '%".$who."%'"),0);
  115. }else{
  116. $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `msg` LIKE '%".$chto."%' "),0);}
  117.  
  118. $start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
  119. if ($start > $total) $start = 0;
  120. if ($total < $start + 10) $end = $total;
  121. else $end = $start + 10;
  122.  
  123.  
  124. while ($src = mysql_fetch_array($sar)) {
  125. $thms = mysql_query("SELECT * FROM `theme` WHERE `id` = '".$src['theme']."' ");
  126. $thm = mysql_fetch_array($thms);
  127. echo '<div><img src="'.$config['home'].'/forum/img/t.gif" alt=""> ';
  128. echo '<a href="'.$config['home'].'/forum/?act=posts&amp;id='.$thm['id'].'"><b>'.$thm['name'].'</b></a><br>';
  129.  
  130.  
  131.  
  132. if (strlen($src['msg']) > '1000') {
  133. echo 'Сообщение: '.antimat(bb_code(check(utf_substr($src['msg'])))).' <br>';
  134. echo '<a href="'.$config['home'].'/forum/?act=poste&amp;id='.$src['theme'].'&amp;pid='.$src['id'].'">Читать все >></a><br>';
  135. }else{
  136. echo 'Сообщение: '.antimat(bb_code(check($src['msg']))).' <br>';
  137. }
  138.  
  139. echo '<small>Написал: ';
  140. if (!empty($post['author_n'])){
  141. echo '<b>'.$src['author_n'].'</b>';
  142. }else{
  143. echo '<b>'.$src['author'].'</b>';}
  144. echo ' ('.date_fixed($src['time']).')</small><hr></div>';}
  145. }else{ echo '<br><div><img src="'.$config['home'].'/forum/img/err.gif" alt=""> <small>По вашему запросу ничего не найдено!</small></div><br>';}}
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. echo '<div>';
  153. if ($total > '10'){ pages($start, $total, 10, $config['home']); echo '<hr>';}
  154.  
  155. echo ': <a href="'.$config['home'].'/forum/index.php?act=search&amp;'.SID.'">Поиск</a><br>';
  156. echo ':: <a href="'.$config['home'].'/forum/index.php?'.SID.'">В форум</a><br>';
  157. echo '::: <a href="'.$config['home'].'/index.php?'.SID.'">На главную</a></div>';
  158.  
  159. echo '<a href="http://7je.ru">ByForum 1.5 DEMO</a>';
  160.  
  161. include_once ("../themes/".$config['themes']."/foot.php");
  162. ?>