View file modules/work/rating.php

File size: 4.02Kb
<?
if(isset($user)) {
if(isset($_GET['id']) && $db->query("SELECT * FROM `portfel` WHERE `user` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->rowCount() == 1) 
        { 
$us = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->fetch(); 
$count_rate = $db->query("SELECT * FROM `portfel_rating` WHERE `refid` = '".$us['id']."' AND `user` = '".$user['id']."'")->rowCount(); 
        } else { 
$title = 'Ошибка'; 
$locate = 'in_portfolio'; 
require_once(SYS.'/view/header.php'); 
$tpl->div('title', 'Ошибка'); 
echo '<div class="menu"><center>Нету такого портфолио</center></div>'; 
require_once(SYS.'/view/footer.php'); 
exit; 
        } 
 
if(isset($_GET['add']) && $count_rate == 0 && $us['id'] != $user['id'] && isset($user)) {
if(isset($_POST['save'])) { 
$text = substr(input($_POST['text']), 0, 200); 
$type = substr(abs(intval($_POST['type'])), 0, 2); 
if (mb_strlen($text) < 3 || mb_strlen($text) > 200) $err.= 'Недопустимая длина отзыва!'; 
if(isset($err)){$tpl->div('error', $err); } 
else { 
$db->query("INSERT INTO `portfel_rating` SET  `text` = '".$text."', `user` = '".$user['id']."', `type` = '".$type."', `time` = '".time()."', `refid` = '".$us['id']."'"); 

header('location: /work/rating?id='.$us['id'].''); 
exit; 
} 
} 

$title = 'Добавление отзыва'; 
$locate = 'in_portfolio'; 
require_once(SYS.'/view/header.php'); 
$tpl->div('title', 'Добавление отзыва'); 

echo '<div class="post"> 
                <form action="/work/rating?id='.$us['id'].'&add" method="post"> 
                 <b>Тип отзыва(<font color="green">+</font>/<font color="red">-</font>)</b>:<br /> 
                 <select name="type">
		 <option value="1">Положительный</option>
		 <option value="2">Отрицательный</option>
		 </select><br/>
                 <b>Отзыв</b>: <br/> 
                 <textarea rows="5" cols="30" name="text"></textarea><br/> 
                 <input name="save" type="submit" value="Добавить" /> 
                 </form> 
</div>'; 
$tpl->div('block', '<a href="port?id='.$us['id'].'">В портфолио '. tnick($us['id']) .'</a></div>'); 
$tpl->div('block', HICO .'<a href="/">'. $lang->word('home') .'</a></div>'); 
require_once(SYS.'/view/footer.php'); 
exit; 
                 }
                 
$title = 'Отзывыв - '.tnick($us['id']); 
$locate = 'in_portfolio'; 
require_once(SYS.'/view/header.php'); 
$tpl->div('title', 'Отзывы - '.tnick($us['id'])); 

if($count_rate == 0 && $us['id'] != $user['id'] && isset($user)) {
$tpl->div('menu', '<a href="/work/rating?id='.$us['id'].'&add">Добавить отзыв</a>'); 
}

$portfel_r = $db->query("SELECT * FROM `portfel_rating` WHERE `refid` = '".$us['id']."'")->rowCount(); 
$pages = new Paginator($portfel_r, $ames); 
if($portfel_r == 0) { 
$tpl->div('menu', '<center>Нет отзывов</center>'); 
} else { 
$komm = $db->query("SELECT * FROM `portfel_rating` WHERE `refid` = '".$us['id']."' ORDER BY `time` DESC LIMIT $start, $ames"); 
while($km = $komm->fetch()) { 
 $tpl->div('post', nick($km['user']) .' ('. rtime($km['time']) .')<br />Отзыв:
 '.($km['type'] == 1  ? '<font color="green">Положительный</font>':'<font color="red">Отрицательный</font>') .'<br />
  '.output($km['text'])); 
} 
$pages->view('/work/file?id='.$fo['id'].'&'); 
} 
$tpl->div('block', '<img src="/template/icons/album.png" alt="*" /> <a href="port?id='.$us['id'].'">Портфолио</a>'.'</div>'
.'<div class="block"><img src="/template/icons/home.png"> <a href="/">'. $lang->word('home').'</a></div>');
require_once(SYS.'/view/footer.php');

} else {
$title = 'Портфолио';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Портфолио');
$tpl->div('menu', '<center>Портфолио доступно только зарегистрированным пользователям!</center>');
$tpl->div('block',HICO .'<a href="/">'. $lang->word('home').'</a></div>');
require_once(SYS.'/view/footer.php');
}

?>