Файл: moduls/statush/comm.php
Строк: 85
<?php
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
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('Baxolar');
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>Statusga baxo berdingiz!</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[] = 'Xatolik!';
}
if (empty($data[1]) || $data[1] > 5) {
$err[] = 'Xatolik!';
}
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> statusingizni <b>+' . $data[1] . '</b> ga baxoladi.';
} else {
$result = ($status['rating'] - $data[1]);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> statusingizni <b>-' . $data[1] . '</b> ga baxoladi.';
}
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 class="sts">';
echo text($status['status']);
echo CLOSE_DIV;
echo DIV_AUT;
echo '<b>Ushbu statuga baxoingiz:</b><br /><br />';
$key = 1;
foreach ($array_plus AS $value) {
echo '<a href="'.HOME.'/status/'.$status['id'].'/like/?go=plus_'.$key.'" style="color:#3EA100">'.$value.' </a>';
++$key;
}
echo ' </br> ';
$key = 1;
foreach ($array_minus AS $value) {
echo '<a href="'.HOME.'/status/'.$status['id'].'/like/?go=minus_'.$key.'" style="color:#D66B53">'.$value.' </a>';
++$key;
}
echo CLOSE_DIV;
}
echo DIV_AUT . '<b>Reyting tarihi:</b>' . CLOSE_DIV;
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".STATUS_RATING." WHERE `status_id` = ?", array($status['id']));
if ($all > 0) {
$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 '<div class="lines"><b>' . vrem($post['time']) . '</b> ' . user_choice($post['user_id'], 'link') . ' '.($post['type'] == 'plus' ? '<span style="color: green">+'.$post['rating'].'</span> baxo berdi' : '<span style="color: red">+'.$post['rating'].'</span>').'</div>';
}
echo $n->navi();
} else {
echo DIV_AUT . 'Hali hech kim ovoz bermagan' . CLOSE_DIV;
}
echo DIV_LI . '- <a href="'.HOME.'/statush/'.$status['user_id'].'/">Statuslar tarihi</a>' . CLOSE_DIV;
echo DIV_LI . '- <a href="'.HOME.'/id'.$status['user_id'].'">Sahifaga qaytish</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
case 'comm':
head('Statusga sharh');
echo '<div class="sts">';
echo text($status['status']);
echo CLOSE_DIV;
if (!empty($_POST['send']) && $user['chat_post'] >= $config['limit_PhotoComm']) {
$comm = html($_POST['comm']);
if (empty($comm)) {
echo ERROR . 'Bo`sh habar' . CLOSE_DIV;
} else {
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> satatusingizga habar yozdi';
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'].'">[Jav]</a>
'.($user['user_id'] == $post['user_id'] || $ank['user_id'] == $user['id'] ? '<a href="'.HOME.'/status/'.$id.'/comm/?del='.$post['id'].'">[x]</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 . 'Sharhlar yo`q' . CLOSE_DIV;
}
echo DIV_AUT;
/* Foydalanuvchiga javob */
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 'Foydalanuvchiga javob: '.user_choice($ank2['user_id'], 'link').':<br />';
}
echo '<form action="#" method="POST">';
echo '<b>Statusga sharh:</b><br /><textarea name="comm">'.(!empty($otv) ? $otv : NULL).'</textarea><br />';
echo '<input type="submit" name="send" value="Yozish" />';
echo '</form>';
echo CLOSE_DIV;
bbsmile();
echo DIV_LI . '- <a href="'.HOME.'/statush/'.$status['user_id'].'/">Statuslar tarihi</a>' . CLOSE_DIV;
echo DIV_LI . '- <a href="'.HOME.'/id'.$status['user_id'].'">Sahifaga qaytsish</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
}
require_once('../../core/stop.php');
?>