View file cat.php

File size: 8.62Kb
<?php
define( 'WBCAT', 1 );
$loc = 'cat';
require_once ('inc/head.php');

$req = mysql_query("SELECT * FROM `cat` WHERE `id` = '$id' LIMIT 1");
$res = mysql_fetch_assoc($req);

$mod = isset($_GET['mod']) ? $_GET['mod'] : '';
switch($mod) {


# Информация о сайте #

case 'view' :
        $view = mysql_fetch_array(mysql_query("SELECT * FROM `sites` WHERE id='" .$site. "' AND `id_cat`='".$id."' LIMIT 1;"));

        // Счетчик прочтений
        if ($_SESSION['co'] != $site) {
            $_SESSION['co'] = $site;
            mysql_query("UPDATE `sites` SET  `count` = `count`+1 WHERE `id` = '" . $site . "'");
        }

        echo '<div class="zag">'.$view['name'].'</div>';
        echo '<div class="title">';
		if($settings['cat_bb']){$view['about']=tags($view['about']);	}
		if($settings['cat_smile']){	$view['about']=  smileys($view['about']);	}
        echo '<p><b>Сайт</b>: <a href="http://'.$view['url'].'">'.$view['name'].'</a> [id '.$view['id'].']<br/>
            <b>Описание</b> : '.nl2br($view['about']).'</p>
            <p><b>Информация:</b><br/>
            <small>
            <u>Категория</u> : <a href="'.$home.'/cat-'.$res['id'].'.html">'.$res['title'].'</a><br/>
            <u>Url</u> : <a href="http://'.$view['url'].'">http://'.$view['url'].'</a><br/>
            <u>Добавлен</u> '.date('d.m.y/H:i',$view['date']).'<br/>
            <u>Просмотров</u> '.$view['count'].'<br/>
            </small></p>';
        
        if ($settings['rate'] || $settings['review'])
        echo '<p><b>Статистика:</b><br/>';
        
        // Система рейтинга сайта
        if ($settings['rate'] == true) {
            echo '<u>Рейтинг сайта:</u> <b><font color="'.($view['rate'] >= 0 ? 'green' : 'red').'">'.($view['rate'] > 0 ? '+'.$view['rate'] : $view['rate']).'</font></b><br/>';
            if (isset($_POST['submit']))  {
                if (!$_SESSION['rate'.$site]) {
                  $rate = intval($_POST['rate']);
                  $sql = '';
                  if ($rate > 0) {
                      $sql = "`rate` = (`rate` + 1)";
                      $log = '+1';
                  }else{ 
                      $sql = '`rate` = (`rate` - 1)';
                      $log = '-1';
                  }
                  mysql_query("UPDATE `sites` SET $sql WHERE `id` = '$site'") or die(mysql_error());
                  $_SESSION['rate'.$site] = 1;
                  header("Location: {$home}/cat-{$view['id_cat']}/site-$site.html");
                  
                if ($settings['rate_log_status']) {
                    mysql_query("INSERT INTO `logs` SET 
                            `id_site` = '$site',
                            `time` = '$time',
                            `ip` = '".mysql_real_escape_string(ip2int(getip()))."',
                            `ua` = '".mysql_real_escape_string(ua())."',
                            `type` = '0',
                            `data` = '$log'") 
                            or die(mysql_error());
                }
                  
                  
                } 
                
            }
            if (!$_SESSION['rate'.$site]) {
                echo '<form action="'.$home.'/cat-'.$view['id_cat'].'/site-'.$site.'.html" method="POST">';
                echo '<small>Полезный сайт ?</small><br/>';
                echo '<input type="radio" name="rate" value="1" checked="checked"/> Да<br/>';
                echo '<input type="radio" name="rate" value="0"/> Нет<br/>';
                echo '<input type="submit" name="submit" value="Голосовать"/>';
                echo '</form>';
            }
        }
        if ($settings['review'] == true) {
            $count_re = mysql_result(mysql_query("SELECT COUNT(*) FROM `komm` WHERE id_site='".$site."';"), 0);
            echo '<a href="'.$home.'/review-'.$site.'.html">Отзывы</a> ['.$count_re.']';
            }
        echo '</p>';	
        echo '<p><b>Сервисы:</b><br/><a href="'.$home.'/seo-'.$site.'.html">Seo-анализ сайта</a></p>';
		echo '<p><b>Скриншот сайта:</b><br/><img src="http://api.webthumbnail.org/?width=200&height=300&format=png&screen=1024&url=http://'.$view['url'].'" alt="site '.$view['url'].' screen proved by click-cat.tk"/></p>';
//<img src="http://api.webthumbnail.org/?width=200&height=300&format=png&screen=1024&url=http://wmrclub.org" alt="site wmrclub.org screen"/>       
	   echo '</div>';	
		
        echo '<div class="main"><a href="'.$home.'/cat-'.$view['id_cat'].'.html">В категорию</a></div>';
        if ($allow) {
            if (!empty($view['ip'])) {
                echo '<div class="func"><small>Информация</small> :<br/><u>IP</u> : <i>'.int2ip($view['ip']).'</i><br/>
                <u>USER AGENT</u> : <i>'.$view['browser'].'</i></div>';
            }
            echo '<div class="func"><small>Управление сайтом :<br/></small>';
            echo '<a href="'.$home.'/adm/edit_site.php?id='.$site.'">Редактировать</a><br/><a href="'.$home.'/adm/del_site.php?id='.$site.'">Удалить</a><br/>';
            echo '<a href="'.$home.'/adm/ban_site.php?id='.$site.'">Бан Url</a><br/><a href="'.$home.'/adm/logs.php?mod=site&amp;id='.$site.'">Логи рейтинга</a><br/>';
            echo '<a href="'.$home.'/adm">Админ-панель</a></div>';
        }
    break;
default :
    echo '<div class="zag">'.$res['title'].'</div>';

    ############Сортировка сайтов################
    $sort = '`id` DESC';

    if (isset($_POST['submit'])) {
        if (!empty($_POST['sort1'])) {
            if ($_POST['sort1'] == 0) {
                $_SESSION['sort1'] = 0;
            }elseif ($_POST['sort1'] == 1) {
                $_SESSION['sort1'] = 1;
            } else {
                $_SESSION['sort1'] = 2;
            }
        }
        $_SESSION['sort2'] = $_POST['sort2'] ? 1 : 0;
        header("Location: $home/cat-$id.html");
    }
    
    
    if ($_SESSION['sort1'] == 0) {
        $sort = "`id`";
    }elseif ($_SESSION['sort1'] == 1) {
        $sort = "`count`";
    } else {
        $sort = "`rate`";
    }
    $sort .= $_SESSION['sort2'] ? ' ASC' : ' DESC';
    ##############################################

        // Вывод меню сортировки
    echo '<div class="main"><form action="'.$home.'/cat-' . $id . '.html" method="post">
        <b>Сортировка: </b>
        <select name="sort1">
            <option value="0"' . (!$_SESSION['sort1'] ? ' selected="selected"' : '') . '>Дата добавления</option>
            <option value="1"' . ($_SESSION['sort1'] == 1? ' selected="selected"' : '') . '>Просмотры</option>
            <option value="2"' . ($_SESSION['sort1'] == 2? ' selected="selected"' : '') . '>Рейтинг</option>
        </select>
        &amp; 
        <select name="sort2">
            <option value="0"' . (!$_SESSION['sort2'] ? ' selected="selected"' : '') . '>По убыванию</option>
            <option value="1"' . ($_SESSION['sort2'] ? ' selected="selected"' : '') . '>По возростанию</option>
        </select>
        <input type="submit" value="&gt;&gt;" name="submit"/></form></div>';
    
    // Формируем вывод сообщений + постраничная навигация
    $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sites` WHERE `id_cat` = '$id' AND `type` = '1'"),0);
    $pager = new pager($count,10,$home.'/cat-'.$id.'.html/page-');
    $result = mysql_query('SELECT * FROM `sites` WHERE `id_cat` ="'.$id.'" AND type = "1" ORDER BY '.$sort.' LIMIT '.$pager->get_start().', '.$pager->on_page.'');
    if ($count >0) {
        while ($m = mysql_fetch_array($result)) {
            echo '<div class="title"><a href="'.$home.'/cat-'.$id.'/site-'.$m['id'].'.html">'.$m['name'].'</a><br/>';
            echo '<b>Описание</b>:<br/>'.$m['about'].'</div>';
        }
        echo $pager->print_nav();
    } else {
        echo '<div class="title">Сайтов нет</div>';
    }


    if ($allow) {
        echo '<div class="func"><small>Управление разделом :<br/></small>';
        echo '<a href="'.$home.'/adm/edit.php?id='.$id.'">Редактировать</a>|<a href="'.$home.'/adm/del.php?id='.$id.'">Удалить</a><br/>';
        echo '<a href="'.$home.'/adm">Админ-панель</a></div>';
    }
}
echo '<div class="main"><a href="'.$home.'">На главную</a></div>';
require_once ('inc/foot.php');
?>