Вход Регистрация
Файл: 4mast/profmas.ru/forums/search.php
Строк: 51
<?php
require_once('../includes/Headers.php');
require_once(
'../includes/PDO_func.php');

if(
$us['id'] == false){
header('location: /login/auth');
exit;
 } 

('Поиск по форуму''Поиск по форуму');

    if (isset (
$_GET['thems'])) {
    
        
$_SESSION['thema'] = htmlspecialchars (addslashes (trim ($_SESSION['thema'])));
    
        echo 
'<div class="list1">';
        echo 
'<form action="/forums/search.php?thems&get" method="post">';
        echo 
'<input name="name" value="' $_SESSION['thema'] . '"/><br/>';
        echo 
'<input type="submit" value="Поиск"/>';
        echo 
'</form>';
        echo 
'</div>';

        if (isset (
$_GET['get'])) {
                
$_POST['name'] = htmlspecialchars (addslashes (trim ($_POST['name'])));
                if (!empty (
$_POST['name'])) {
                        
$_SESSION['thema'] = $_POST['name'];
                }
                
                if (isset (
$_SESSION['thema'])) {
                
                        
$items DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_t` WHERE (`name` LIKE '%" $_SESSION['thema'] . "%') AND (`type`!='2')");

                        
$items_per_page 10;
                        
$pages ceil $items $items_per_page );

                        if (
$page 1)
                            
$page 1;

                        if (
$page $pages)
                            
$page $pages;
                            
                        
$start $page $items_per_page $items_per_page;


                        if (
$items==0) {
                                echo 
'<div class="error">По вашему запросу ничего не найдено!</div>';
                        }
                        else {

                                
$query DB :: $dbs -> query ("SELECT * FROM `forum_t` WHERE (`name` LIKE '%" $_SESSION['thema'] . "%') AND (`type`!='2') ORDER BY `id` DESC LIMIT $start$items_per_page");
                                while (
$t $query -> fetch()) {
                                        
                                        
$c_p DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`id_r`='" $r['id'] . "') AND (`id_pr`='" $pr['id'] . "') AND (`id_t`='" $t['id'] . "') " . ($us['level'] > '':'AND (`del`='0')'));
                                        
                                        echo 
'<div class="list1">';
                                        echo 
'<img src="/images/' . ($t['top'] != 'prikrep' : ($t['type'] == 'closed':'the')) . '.png" alt=""/> <a href="/forums/thema' $t['id'] . '">' $t['name'] . '</a> (' $c_p .') <a href="/forums/thema' $t['id'] . '/page' ceil ($c_p 10) . '">&gt;</a><br/>';

                                        
$c_f DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_f` WHERE (`id_t`= '" $t['id'] . "')");
                                        if (
$c_f != 0) {
                                                echo 
'<img src="/images/page_white_get.png" alt="" align="middle"/> Файлов: <a href="/forums/files' $t['id'] . '">' $c_f '</a><br/>';
                                        }
                                        
                                        echo 
Nick ($t['us']) . '/' Nick ($t['last']) . ' (' datef ($t['time'])  .')';
                                        echo 
'</div>';
                                        
                                }
                                
                                if (
$pages>1) {
                                        echo 
'' page ('/fsearch/thems') . '';
                                }
                
                        }
                        
                }
        
        }


}
elseif (isset (
$_GET['posts'])) {

        
$_SESSION['post'] = htmlspecialchars (addslashes (trim ($_SESSION['post'])));
        
        echo 
'<div class="list1">';
        echo 
'<form action="/forums/search.php?posts&get" method="post">';
        echo 
'<input name="text"/><br/>';
        echo 
'<input type="submit" value="Поиск"/>';
        echo 
'</form>';
        echo 
'</div>';
        
        if (isset (
$_GET['get'])) {
                
$_POST['text'] = htmlspecialchars (trim ($_POST['text']));
                if (!empty (
$_POST['text'])) {
                        
$_SESSION['post'] = $_POST['text'];
                }
                
                if (isset (
$_SESSION['post'])) {
                
                        
$items DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`text` LIKE '%" $_SESSION['post'] . "%') AND (`del`='0')");

                        
$items_per_page 10;
                        
$pages ceil $items $items_per_page );

                        if (
$page 1)
                            
$page 1;

                        if (
$page $pages)
                            
$page $pages;
                            
                        
$start $page $items_per_page $items_per_page;


                        if (
$items==0) {
                                echo 
'<div class="error">По вашему запросу ничего не найдено!</div>';
                        }
                        else {

                                
$query DB :: $dbs -> query ("SELECT * FROM `forum_p` WHERE (`text` LIKE '%" $_SESSION['post'] . "%') AND (`del`='0') ORDER BY `id` DESC LIMIT $start$items_per_page");
                                while (
$p $query -> fetch()) {





                                        
$t DB :: $dbs -> queryFetch ("SELECT * FROM `forum_t` WHERE (`id`='" $p['id_t'] . "')");
                                    
                                        echo 
'<div class="list1">';
                                        echo 
'<img src="/design/' . ($t['top']==1'prikrep' : ($t['type']=='closed' 'the')) . '.png" alt=""/> Тема: <a href="/forums/thema' $t['id'] . '">' $t['name'] . '</a><br/>';
                                        echo 
Nick ($p['us']) . ' (' datef ($p['time']) . ')';
                                            
                                        
$za     DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`id_p`='" $p['id'] . "') AND (`vot`='za')");
                                        
$protiv DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`id_p`='" $p['id'] . "') AND (`vot`='protiv')");
                                          
                                        
// display post votes
                                        
echo ' (<span style="color:green;">' $za '</span>/<span style="color:red;">' $protiv '</span>)<br/>';
                                        
                                        
// if post have quote
                                        
if ($p['cit'] != 0) {
                                            
                                                echo 
'Цитата:';
                                                echo 
'<div class="cit">';
                                                
                                                
$q DB :: $dbs -> query ("SELECT * FROM `forum_p` WHERE (`id`='" $p['cit'] . "')");                
                                                if (
$q -> rowCount () == 0) {
                                                        echo 
'<b>Сообщение удалено!</b>';
                                                }
                                                else {
                                                        
                                                        
// 
                                                        
$cit $q -> fetch ();
                                                        if (
$cit['del'] !=) {
                                                                echo 
'<b>Сообщение удалено!</b>';
                                                        }
                                                        else {
                                                            
                                                                
$citu DB :: $dbs -> queryFetch ("SELECT * FROM `us` WHERE (`id`='" $cit['us'] . "')");
                                                                echo 
'<b style="color:red;">' $citu['nick'] . '</b>: ' tag ($cit['text']);
                                                        
                                                        }
                                                
                                                }
                                                
                                                echo 
'</div>';
                                        
                                        }
                                        
                                        
$p['text'] = tag ($p['text']);
                                        
                                        echo 
$p['text'] . '<br/>';

                                        
                                        
// if post have attachment files
                                        
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_f` WHERE (`id_p`='" $p['id'] . "')") != 0) {
                                        
                                            echo 
'<b>Прикрепленные файлы:</b><br/>';
                                            
                                            
$q DB :: $dbs -> query ("SELECT * FROM `forum_f` WHERE (`id_p`='" $p['id'] . "') ORDER BY `id`");
                                            while (
$f $q -> fetch ()) {
                                                echo 
'<a href="/files/forum/' $f['name'] . '">' $f['name'] . '</a> (' sizef ($f['size']) . ')<br/>';
                                            }
                                        }

                                        
                                        
$q DB :: $dbs -> query ("SELECT * FROM `forum_reds` WHERE (`id_p`='" $p['id'] . "')");
                                        if (
$q -> rowCount () != 0) {
                                                
$redk DB :: $dbs -> queryFetch ("SELECT * FROM `forum_reds` WHERE (`id_p`='" $p['id'] . "') ORDER BY `id` DESC LIMIT 1");
                                                echo 
'
                                                ________<br/>
                                                <small>Пост изменён <a href="/forums/reds.php?id=' 
$p['id'] . '">' $q -> rowCount () . ' раз.</a> Посл. ред. ' uNick ($redk['us']) . ' (' datef ($redk['time']) . ')</small>
                                                '
;
                                        }
                                        
                                        echo 
'</div>';




                                        
                                }
                                
                                if (
$pages>1) {
                                        echo 
'' page ('/search/posts') . '';
                                }
                
                        }
                        
                }
        
        }
        
}
else {
        echo 
'<div class="block"><img src="'.$img.'" alt="*"/> <a href="/forums/search.php?thems">По названию тем</a></div>';
        echo 
'<div class="block"><img src="'.$img.'" alt="*"/> <a href="/forums/search.php?posts">По сообщениям</a></div>';
}


require_once(
'../includes/Footers.php');


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