Вход Регистрация
Файл: muzxit.ru/stars/films.php
Строк: 133
<?php

/**
* @package     JohnCMS
* @link        http://johncms.com
* @copyright   Copyright (C) 2008-2011 JohnCMS Community
* @license     LICENSE.txt (see attached file)
* @version     VERSION.txt (see attached file)
* @author      http://johncms.com/about
*/

define('_IN_JOHNCMS', 1);

$headmod = 'stars';
require(
'../incfiles/core.php');
$lng_stars = core::load_lng('stars');
$textl = $lng_stars['search_stars'];
require(
'../incfiles/head.php');

/*
-----------------------------------------------------------------
Функция подсветки результатов запроса
-----------------------------------------------------------------
*/
function ReplaceKeywords($search, $text) {
    
$search = str_replace('*', '', $search);
    return 
mb_strlen($search) < 3 ? $text : preg_replace('|('.preg_quote($search, '/').')|siu','<span style="background-color: #FFFF33">$1</span>',$text);
}

/*
-----------------------------------------------------------------
Принимаем данные, выводим форму поиска
-----------------------------------------------------------------
*/
$search_post = isset($_POST['search']) ? trim($_POST['search']) : false;
$search_get = isset($_GET['search']) ? rawurldecode(trim($_GET['search'])) : false;
$search = $search_post ? $search_post : $search_get;
//$search = preg_replace("/[^wx7F-xFFs]/", " ", $search);
$search_n = isset($_REQUEST['n']);
echo 
'<div class="phdr"><a href="index.php"><b>' . $lng_stars['stars'] . '</b></a> | ' . $lng_stars['search_stars'] . '</div>' .
     
'<div class="topmenu">' . $lng_stars['search_info'] . '</div>' .
     
'<div class="gmenu"><form action="films.php" method="post"><p>' .
     
'<input type="text" value="' . ($search ? functions::checkout($search) : '') . '" name="search" />' .
     
'<input type="submit" value="' . $lng['search'] . '" name="submit" /><br />' .
     
'<input name="n" type="checkbox" value="1" ' . ($search_n ? 'checked="checked"' : '') . ' />&nbsp;' . $lng_stars['search_name'] .
     
'</p></form></div>';

/*
-----------------------------------------------------------------
Проверям на ошибки
-----------------------------------------------------------------
*/
$error = false;
if (
$search && (mb_strlen($search) < 2 || mb_strlen($search) > 64))
    
$error = $lng['error_search_length'];

if (
$search && !$error) {
    
/*
    -----------------------------------------------------------------
    Выводим результаты запроса
    -----------------------------------------------------------------
    */
    
$array = explode(' ', $search);
    
$count = count($array);
    
$query = mysql_real_escape_string($search);
    
$total = mysql_result(mysql_query("
        SELECT COUNT(*) FROM `stars`
        WHERE MATCH (" 
. ($search_n ? '`name`' : '`films`') . ") AGAINST ('$query' IN BOOLEAN MODE)
        AND `type` = '1'
    "
), 0);
    echo 
'<div class="phdr">' . $lng['search_results'] . '</div>';
    if (
$total > $kmess)
        echo 
'<div class="topmenu">' . functions::display_pagination('films.php?' . ($search_n ? 'n=1&amp;' : '') . 'search=' . urlencode($search) . '&amp;', $start, $total, $kmess) . '</div>';
    if (
$total) {
        
$req = mysql_query("
            SELECT *
            FROM `stars`
            WHERE MATCH (" 
. ($search_n ? '`name`' : '`films`') . ") AGAINST ('$query' IN BOOLEAN MODE)
            AND `type` = '1'
            LIMIT 
$start, $kmess
        "
);
        
$i = 0;
        
$razm = $agent_web == 'web' ? '64' : '32';
        while ((
$res = mysql_fetch_assoc($req)) !== false) {
            echo 
$i % 2 ? '<div class="list2">' : '<div class="list1">';
            echo 
'<table cellpadding="0" cellspacing="0"><tr><td>';
            if (!
$search_n) {
                
// Поиск только в фильмах
                
$req_t = mysql_query("SELECT * FROM `stars` WHERE `id` = '" . $res['id'] . "'");
                
$res_t = mysql_fetch_assoc($req_t);
                if(
file_exists('photo/' . $res['id'] . '.jpg'))
                    echo 
'<img src="photo/' . $res['id'] . '.jpg" alt="' . $res_t['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res['id'] . '.jpeg'))
                    echo 
'<img src="photo/' . $res['id'] . '.jpeg" alt="' . $res_t['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res['id'] . '.bmp'))
                    echo 
'<img src="photo/' . $res['id'] . '.bmp" alt="' . $res_t['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res['id'] . '.png'))
                    echo 
'<img src="photo/' . $res['id'] . '.png" alt="' . $res_t['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res['id'] . '.gif'))
                    echo 
'<img src="photo/' . $res['id'] . '.gif" alt="' . $res_t['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                echo (
$agent_web == 'web' ? '<br/>' : '') . '<a href="index.php?id=' . $res['id'] . '"><b>' . $res_t['name'] . '</b></a><br />';
            } else {
                
// Поиск в именах
                
$req_p = mysql_query("SELECT * FROM `stars` WHERE `id` = '" . $res['id'] . "'");
                
$res_p = mysql_fetch_assoc($req_p);
                foreach(
$array as $val){
                    
$res['name'] = ReplaceKeywords($val, $res['name']);
                }
                if(
file_exists('photo/' . $res_p['id'] . '.jpg'))
                    echo 
'<img src="photo/' . $res_p['id'] . '.jpg" alt="' . $res_p['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res_p['id'] . '.jpeg'))
                    echo 
'<img src="photo/' . $res_p['id'] . '.jpeg" alt="' . $res_p['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res_p['id'] . '.bmp'))
                    echo 
'<img src="photo/' . $res_p['id'] . '.bmp" alt="' . $res_p['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res_p['id'] . '.png'))
                    echo 
'<img src="photo/' . $res_p['id'] . '.png" alt="' . $res_p['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                elseif(
file_exists('photo/' . $res_p['id'] . '.gif'))
                    echo 
'<img src="photo/' . $res_p['id'] . '.gif" alt="' . $res_p['name'] . '" width="' . $razm . '" height="' . $razm . '" />&#160;</td><td>';
                echo (
$agent_web == 'web' ? '<br/>' : '') . '<a href="index.php?id=' . $res_p['id'] . '"><b>' . $res_p['name'] . '</b></a><br />';
            }
            
$text = null;
            if(
$search_n)
            {
                
$films = explode(';', $res_p['films']);
                foreach(
$films as $key)
                {
                    
$key = trim($key);
                    
$text .= '<a href="films.php?search=' . rawurlencode($key) . '">' . $key . '</a>, ';
                }
            }
            else
            {
                
$films = explode(';', $res['films']);
                foreach(
$films as $key)
                {
                    
$key = trim($key);
                    
$text .= '<a href="films.php?search=' . rawurlencode($key) . '">' . $key . '</a>, ';
                }
            }
            
//$text = $search_n ? $res_p['films'] : $res['name'];
            
foreach ($array as $srch) if (($pos = mb_strpos(strtolower($res['name']), strtolower(str_replace('*', '', $srch)))) !== false) break;
            if(!isset(
$pos) || $pos < 100) $pos = 100;
            
//$text = preg_replace('#[c](.*?)[/c]#si', '<div class="quote">1</div>', $text);
            //$text = functions::checkout(mb_substr($text, ($pos - 100), 400), 1);
            
if (!$search_t) {
                foreach(
$array as $val){
                    
$text = ReplaceKeywords($val, $text);
                }
            }
            if(!empty(
$res['films']))
            {
            
$text2 = explode(',', $text);
            unset(
$text2[end($text2)]);
               unset(
$text2[count($text2)-1]);
               
               
$texts = array();
            
//$text2 = implode(',', $text2);
            
foreach($text2 as $keys)
            {
                if(
$keys != end($text2))
                    
$pref = ',';
                   else
                       
$pref = '';
                   
$texts[] = $keys.$pref;
            }
            echo  
$lng_stars['films'] . ': <span class="phpcode">' . implode('', $texts) . '</span>';
            }
            echo 
'</td></tr></table></div>';
            ++
$i;
        }
    } else {
        echo 
'<div class="rmenu"><p>' . $lng['search_results_empty'] . '</p></div>';
    }
    echo 
'<div class="phdr">' . $lng['total'] . ': ' . $total . '</div>';
    if (
$total > $kmess) {
        echo 
'<div class="topmenu">' . functions::display_pagination('films.php?' . ($search_t ? 't=1&amp;' : '') . 'search=' . urlencode($search) . '&amp;', $start, $total, $kmess) . '</div>' .
            
'<p><form action="films.php?' . ($search_t ? 't=1&amp;' : '') . 'search=' . urlencode($search) . '" method="post">' .
            
'<input type="text" name="page" size="2"/>' .
            
'<input type="submit" value="' . $lng['to_page'] . ' &gt;&gt;"/>' .
            
'</form></p>';
    }
} else {
    if (
$error) echo functions::display_error($error);
    echo 
'<div class="phdr"><small>' . $lng_stars['search_help'] . '</small></div>';
}
echo 
'<p>' . ($search ? '<a href="films.php">' . $lng['search_new'] . '</a><br />' : '') . '<a href="index.php">' . $lng_stars['stars'] . '</a></p>';

require(
'../incfiles/end.php');

?>
Онлайн: 3
Реклама