Файл: soc-set/moduls/statush/comm.php
Строк: 79
<?php
require_once('../../core/start.php');
check_auth();
$id = intval($_GET['id']);
$status = DB::$dbs->queryFetch("SELECT * FROM ".STATUS." WHERE `id` = ?",array($id));
if (empty($status)) {
header("Location: ".HOME);
exit();
}
switch ($_GET['act']) {
default:
header("Location: ".HOME);
exit();
break;
case 'like':
head('Голоса за фото - ' . $ank['nick']);
panel();
if (DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".STATUS_RATING." WHERE `user_id` = ? && `status_id` = ?", array($user['user_id'], $status['id'])) == TRUE) {
echo DIV_LI . '<b>Вы голосовали!</b>' . CLOSE_DIV;
} else {
$array_plus = array('+1','+2','+3','+4','+5');
$array_minus = array('-1','-2','-3','-4','-5');
if (isset($_GET['go'])) {
$type = html($_GET['go']);
$data = explode("_", $type);
$err = array();
if ($data[0] != 'plus' && $data[0] != 'minus') {
$err[] = 'Не верный параметр';
}
if (empty($data[1]) || $data[1] > 5) {
$err[] = 'Не верное значение';
}
if (!empty($err)) {
echo DIV_ERROR;
foreach ($err AS $value) {
echo $value . '<br />';
}
echo CLOSE_DIV;
} else {
if ($data[0] == 'plus') {
$result = ($status['rating'] + $data[1]);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> оценил'.(empty($user['gender']) ? 'a' : NULL).' в <b>+' . $data[1] . '</b> Ваш статус.';
} else {
$result = ($status['rating'] - $data[1]);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> оценил'.(empty($user['gender']) ? 'a' : NULL).' в <b>-' . $data[1] . '</b> Ваш статус.';
}
lenta($lenta, $status['user_id']);
DB::$dbs->query("UPDATE ".STATUS." SET `rating` = ? WHERE `id` = ?",array($result, $status['id']));
DB::$dbs->query("INSERT INTO ".STATUS_RATING." (`user_id`, `status_id`, `rating`, `type`, `time`) VALUES (?, ?, ?, ?, ?)", array($user['user_id'], $status['id'], $data[1], $data[0], time()));
header("Location: ?");
exit();
}
}
echo DIV_AUT;
echo text($status['status']);
echo '<br /><b>Ваша оценка:</b><br />';
$key = 1;
foreach ($array_plus AS $value) {
echo '<a href="'.HOME.'/status/'.$status['id'].'/like/?go=plus_'.$key.'">'.$value.' </a>';
++$key;
}
echo ' / ';
$key = 1;
foreach ($array_minus AS $value) {
echo '<a href="'.HOME.'/status/'.$status['id'].'/like/?go=minus_'.$key.'">'.$value.' </a>';
++$key;
}
echo CLOSE_DIV;
}
echo DIV_LI . '<b>История рейтинга:</b>' . CLOSE_DIV;
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".STATUS_RATING." WHERE `status_id` = ?", array($status['id']));
if ($all > 0) {
echo DIV_AUT;
$n = new navigator($all, 10, 'act=like&id='.$status['id']);
$sql = DB::$dbs->query("SELECT * FROM ".STATUS_RATING." WHERE `status_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, 10 ", array($status['id']));
while($post = $sql -> fetch()) {
echo '<b>' . vrem($post['time']) . '</b> ' . user_choice($post['user_id'], 'link') . ' поставил(а) оценку '.($post['type'] == 'plus' ? '<span style="color: green">+'.$post['rating'].'</span>' : '<span style="color: red">+'.$post['rating'].'</span>').'<br />';
}
echo CLOSE_DIV;
echo $n->navi();
} else {
echo DIV_AUT . 'Еще никто не голосовал' . CLOSE_DIV;
}
echo DIV_LI . '<a href="'.HOME.'/statush/'.$status['user_id'].'/">История статусов</a>' . CLOSE_DIV;
echo DIV_LI . '<a href="'.HOME.'/id'.$status['user_id'].'">Вернуться на страницу</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
case 'comm':
head('Комментари к статусу');
panel();
if (!empty($_POST['send']) && $user['chat_post'] >= $config['limit_PhotoComm']) {
$comm = html($_POST['comm']);
if (empty($comm)) {
echo ERROR . 'Пустой комментарий' . CLOSE_DIV;
} else {
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> написал'.(empty($user['gender']) ? 'a' : NULL).' комментарий к Вашему статусу.';
lenta($lenta, $status['user_id']);
DB::$dbs->query("INSERT INTO ".STATUS_COMM." (`user_id`, `status_id`, `comm`, `time`) VALUES (?, ?, ?, ?)", array($user['user_id'], $status['id'], $comm, time()));
header("Location: ".HOME."/status/".$status['id']."/comm/");
balls_operation(2);
}
}
if (!empty($_GET['del'])) {
$comm = DB::$dbs->queryFetch("SELECT * FROM ".STATUS_COMM." WHERE `id` = ? ORDER BY `id` DESC",array(num($_GET['del'])));
if ($user['user_id'] == $comm['user_id'] || $ank['user_id'] == $user['user_id']) {
DB::$dbs->query("DELETE FROM ".STATUS_COMM." WHERE `id` = ? ", array(num($_GET['del'])));
}
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".STATUS_COMM." WHERE `status_id` = ?", array($status['id']));
if ($all > 0) {
$n = new navigator($all, 5, 'act=comm&id='.$status['id']);
$sql = DB::$dbs->query("SELECT * FROM ".STATUS_COMM." WHERE `status_id` = ? ORDER BY `id` DESC LIMIT {$n->start()},5 ", array($status['id']));
while($post = $sql -> fetch()) {
echo DIV_AUT . '<a href="'.HOME.'/status/'.$id.'/comm/?otv='.$post['user_id'].'">[Отв]</a>
'.($user['user_id'] == $post['user_id'] || $ank['user_id'] == $user['id'] ? '<a href="'.HOME.'/status/'.$id.'/comm/?del='.$post['id'].'">[Удал.]</a>' : NULL) .
user_choice($post['user_id'], 'link') . ' <b>' . vrem($post['time']) . '</b><br />' . text($post['comm']) . CLOSE_DIV;
}
echo $n->navi();
} else {
echo DIV_LI . 'Комментарий нет' . CLOSE_DIV;
}
echo DIV_AUT;
/* Ответ пользователю */
if (!empty($_GET['otv'])) {
$ank2 = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array(num($_GET['otv'])));
if (!empty($ank2)) {
$otv = '[b]'.$ank2['nick'].'[/b], ';
}
}
if (!empty($ank2)) {
echo 'Ответ пользователю: '.user_choice($ank2['user_id'], 'link').':<br />';
}
echo '<form action="#" method="POST">';
echo '<b>Комментарий:</b><br /><textarea name="comm">'.(!empty($otv) ? $otv : NULL).'</textarea><br />';
echo '<input type="submit" name="send" value="Написать" />';
echo '</form>';
echo CLOSE_DIV;
echo DIV_LI . '<a href="'.HOME.'/statush/'.$status['user_id'].'/">История статусов</a>' . CLOSE_DIV;
echo DIV_LI . '<a href="'.HOME.'/id'.$status['user_id'].'">Вернуться на страницу</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
}
require_once('../../core/stop.php');
?>