Вход Регистрация
Файл: social12/fo/search.php
Строк: 72
<?php

require '../sid.php';
require 
'../config.php';
$link = connect_db();
list(
$user, $id, $ps) = check_login($link);

whorm(0, 'fo');

include 
'../head.php';
include 
'../navigator.php';

   
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
   switch(
$do) {
   default:
    echo 
$div_title . 'Зона обмена' . $div_end . $div_left .
         
$div_menu . '
         <img src="../ico/up.gif" alt=""/> <a href="index.php?'
.$ref.'">Зона обмена</a>
         ' 
. $block . '
         <b>Поиск</b><br/>
         <a href="pop.php?'
.$ref.'">Популярные</a> |
         <a href="new.php?'
.$ref.'">Новые</a>
         ' 
. $div_end;

        if (isset(
$_GET['reload'])) {
        
// новый поиск
           
unset($_SESSION['Fsearch']);
           
header('Location: search.php?' . $ref);
        }

          if (isset(
$_REQUEST['go'])) {
            if (empty(
$_POST['Fsearch'])) $Fsearch = trim(mysql_real_escape_string(check($_POST['fo_search'])));
            if (empty(
$_SESSION['Fsearch'])) $_SESSION['Fsearch'] = $Fsearch;

            
$where = my_int($_POST['where']);
            if (
$where == 1) $_where = '`title`';
            elseif (
$where == 2) $_where = '`info`';
            else 
$_where = '`title`';

            if (empty(
$_SESSION['Fwhere'])) $_SESSION['Fwhere'] = $_where;

            if (empty(
$_SESSION['Fsearch'])) {
                
err('Поисковой запрос не введен!');
                include_once 
'../foot.php';
                exit();
            }

             
// общее число найденых файлов
              
$s = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE $_where LIKE '%$_SESSION[Fsearch]%' AND `moder` = '0'"), 0);
              
$n = new navigator($s, 10, '?go&amp;');

            
$view = mysql_query("SELECT DISTINCT `fo_pod`.*,
            (SELECT COUNT(*) FROM `fo_files` WHERE `fo_files`.
$_where LIKE '%$_SESSION[Fsearch]%' AND `fo_files`.`cat` = `fo_pod`.`id` AND `fo_files`.`rid` = `fo_pod`.`cid` AND `fo_files`.`moder` = '0') AS c FROM `fo_pod`
                                  LEFT JOIN `fo_files`
                                  ON (`fo_files`.`rid` = `fo_pod`.`cid`
                                  AND `fo_pod`.`id` = `fo_files`.`cat`)
                                  WHERE `fo_files`.`moder` = '0'
                                  AND `fo_files`.
$_where LIKE '%$_SESSION[Fsearch]%'
                                  ORDER BY `fo_files`.`id` DESC 
{$n->limit}");

              if (
$s != FALSE) {
                 
$i = 0;
                 echo 
'Вы искали: <b>' . $_SESSION['Fsearch'] . '</b>
                       <a href="search.php?reload"><img src="../ico/delete.gif" alt=""/></a>' 
. $block;

                 while(
$a = mysql_fetch_assoc($view)) {
                     echo (
$i ++ % 2) ? $div_tworazdel : $div_razdel;
                     echo 
'<img src="../ico/dir.gif" alt=""/> <a href="search.php?do=result&amp;p='.$a['id'].'">' . $a['title'] . '</a> (' . $a['c'] . ')' . $div_end;
                 }
                 echo 
$n->navi();
              } else {
                  unset(
$_SESSION['Fsearch']);
                echo 
'По запросу ' . $Fsearch . ' ничего не найдено!<br/>';
              }
          }

    echo 
'<fieldset>
          <FORM method="POST" action="search.php?'
.$ref.'">
          <label>Найти:</label><br/>
          <input type="text" name="fo_search"/>
          <br/>
          <label>Искать по:</label><br/>
          <select name="where">
          <option value="1">названию</option>
          <option value="2">описанию</option>
          </select>
          <br/>
          <input type="submit" name="go" value="Найти"/>
          </FORM>
          </fieldset>'
;

    echo 
$div_end;
break;

case 
result:
    echo 
$div_title . 'Зона обмена' . $div_end . $div_left .
         
$div_menu . '
         <img src="../ico/up.gif" alt=""/> <a href="index.php?'
.$ref.'">Зона обмена</a>
         ' 
. $block . '
         <b>Поиск</b><br/>
         <a href="pop.php?'
.$ref.'">Популярные</a> |
         <a href="new.php?'
.$ref.'">Новые</a>
         ' 
. $div_end;

       
$p = my_int($_GET['p']);
       
$empty = mysql_query("SELECT `id` FROM `fo_pod` WHERE `id` = '$p' LIMIT 1");

       if (
mysql_num_rows($empty) == FALSE) {
          
header('Location: search.php?' . $ref);
          die();
       }

             echo 
'Вы искали: <b>' . $_SESSION['Fsearch'] . '</b>
                  <a href="search.php?reload"><img src="../ico/delete.gif" alt=""/></a>' 
. $block;

         
$s = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE $_SESSION[Fwhere] LIKE '%".$_SESSION['Fsearch']."%' AND `moder` = '0' AND `cat` = '$p'"), 0);
         
$num_fil = (!empty($_SESSION['us'])) ? $user['onp_files'] : 10;
         
$n = new navigator($s, $num_fil, '?do=result&amp;');

            
$view = mysql_query("SELECT * FROM `fo_files` WHERE `moder` = '0' AND $_SESSION[Fwhere] LIKE '%".$_SESSION['Fsearch']."%' AND `cat` = '$p' ORDER BY `id` DESC {$n->limit}");

              if (
$s != FALSE) {
                 
$i = 0;
                 while(
$a = mysql_fetch_assoc($view)) {

            
$ext = strtolower(end(explode('.', $a['url'])));
            
#######################
            
if ($ext == '3gp') $format = '<img src="img/3gp.gif" alt="*"/>';
            elseif (
$ext == 'avi') $format = '<img src="img/avi.gif" alt="*"/>';
            elseif (
$ext == 'gif') $format = '<img src="img/gif.gif" alt="*"/>';
            elseif (
$ext == 'jpg') $format = '<img src="img/jpg.gif" alt="*"/>';
            elseif (
$ext == 'mp3') $format = '<img src="img/mp3.gif" alt="*"/>';
            elseif (
$ext == 'zip') $format = '<img src="img/zip.gif" alt="*"/>';
            elseif (
$ext == 'jar') $format = '<img src="img/jar.gif" alt="*"/> ';
            else 
$format = '<img src="img/unknown.gif" alt="*"/>';
            
#######################

if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp' || $ext == 'jpeg' || $ext == 'ico' || $ext == 'iso' || $ext == 'imy' || $ext == 'wbmp') $prev = '<img src="../resize.php?img=fo/'.$a['url'].'&width=40&height=0&i=0" alt="*"/><br/>';

    elseif (
$ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'mpeg' && extension_loaded('ffmpeg')) {
        
$prev = '<img src="ffmpeg.php?fid='.$a['url'].'" width="40" height="40" alt="preview"/><br/>';
    }

       elseif (
$ext == 'nth' || $ext == 'thm') {
        
$prev = '<img src="theme.php?i='.$a['id'].'" width="40" height="40" alt=""/><br/>';
     } else {
         
$prev = '';
       }

                     echo (
$i ++ % 2) ? $div_tworazdel : $div_razdel;
                     echo 
$prev . $format . ' <a href="info.php?i='.$a['id'].'">' . $a['title'] . '</a>' . $div_end;
                 }
              } else {
                      echo 
$n->navi();
                    echo 
'По запросу ' . $_SESSION['Fsearch'] . ' ничего не найдено!';
                    unset(
$_SESSION['Fwhere']);
                     unset(
$_SESSION['Fsearch']);
              }

    echo 
$div_end;
break;
}

include 
'../foot.php';
?>
Онлайн: 2
Реклама