Файл: moduls/avatar/index.php
Строк: 135
<?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']);
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array($id));
if (empty($ank)) {
header("Location: ".HOME);
exit();
}
if (empty($ank['photo'])) {
header("Location: ".HOME);
exit();
}
switch ($_GET['act']) {
default:
header("Location: ".HOME);
exit();
break;
case 'like':
head('Rasmga ovozlar - ' . $ank['nick']);
if (DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".PHOTO_RATING." WHERE `user_id` = ? && `friend_id` = ?", array($user['user_id'], $ank['user_id'])) == TRUE) {
echo DIV_LI . '<b>Ovoz bergansiz!</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 = ($ank['photo_rating'] + $data[1]);
$rating = ($ank['rating'] + $data[1]);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> <b>+' . $data[1] . '</b> ga <a href="'.HOME.'/avatar/like/'.$ank['user_id'].'/"><b>avataringizga</b></a> baxo berdi';
} else {
$result = ($ank['photo_rating'] - $data[1]);
$rating = ($ank['rating'] - $data[1]);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> <b>-' . $data[1] . '</b> ga <a href="'.HOME.'/avatar/like/'.$ank['user_id'].'/"><b>avataringizga</b></a> baxo berdi';
}
lenta($lenta, $ank['user_id']);
DB::$dbs->query("UPDATE ".USERS." SET `photo_rating` = ?, `rating` = ? WHERE `user_id` = ?",array($result, $rating, $ank['user_id']));
DB::$dbs->query("INSERT INTO ".PHOTO_RATING." (`user_id`, `friend_id`, `rating`, `type`, `time`) VALUES (?, ?, ?, ?, ?)", array($user['user_id'], $ank['user_id'], $data[1], $data[0], time()));
header("Location: ?");
exit();
}
}
echo DIV_AUT;
echo (empty($ank['photo']) ? '<img src="'.HOME.'/style/img/empty_photo.gif"/>' : '<a href="'.HOME.'/files/photo/'.$ank['photo'].'"><img src="'.HOME.'/files/photo/mini_'.$ank['photo'].'"/></a>');
echo '<br /><b>Baxoingiz:</b><br />';
$key = 1;
foreach ($array_plus AS $value) {
echo '<a href="'.HOME.'/avatar/like/'.$ank['user_id'].'/?go=plus_'.$key.'">'.$value.' </a>';
++$key;
}
echo ' / ';
$key = 1;
foreach ($array_minus AS $value) {
echo '<a href="'.HOME.'/avatar/like/'.$ank['user_id'].'/?go=minus_'.$key.'">'.$value.' </a>';
++$key;
}
echo CLOSE_DIV;
}
echo DIV_LI . '<b>Reyting tarihi:</b>' . CLOSE_DIV;
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".PHOTO_RATING." WHERE `friend_id` = ?", array($ank['user_id']));
if ($all > 0) {
echo DIV_AUT;
$n = new navigator($all, 10, 'act=like&id='.$id);
$sql = DB::$dbs->query("SELECT * FROM ".PHOTO_RATING." WHERE `friend_id` = ? ORDER BY `id` DESC LIMIT {$n->start()},10 ", array($ank['user_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>').' ga ' . user_choice($post['friend_id'], 'link') . ' foydalanuvchiga baxo berdi<br />';
}
echo CLOSE_DIV;
echo $n->navi();
} else {
echo DIV_AUT . 'Hali hech kim baxo bermagan' . CLOSE_DIV;
}
echo DIV_LI . '<a href="'.HOME.'/id'.$ank['user_id'].'">Sahifaga qaytish</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
case 'comm':
head('Rasmga sharh - ' . $ank['nick']);
if (!empty($_POST['send']) && $user['chat_post'] >= $config['limit_PhotoComm']) {
$comm = html($_POST['comm']);
if (empty($comm)) {
echo ERROR . 'Bo`sh sharh' . CLOSE_DIV;
} else {
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> sizning <a href="'.HOME.'/avatar/comm/'.$ank['user_id'].'/"><b>avataringizga</b></a> sharh yozdi';
lenta($lenta, $ank['user_id']);
DB::$dbs->query("INSERT INTO ".PHOTO_COMM." (`user_id`, `friend_id`, `comm`, `time`) VALUES (?, ?, ?, ?)", array($user['user_id'], $ank['user_id'], $comm, time()));
header("Location: ".HOME."/avatar/comm/".$ank['user_id']."/");
balls_operation(2);
}
}
if (!empty($_GET['del'])) {
$comm = DB::$dbs->queryFetch("SELECT * FROM ".PHOTO_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 ".PHOTO_COMM." WHERE `id` = ? ", array(num($_GET['del'])));
}
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".PHOTO_COMM." WHERE `friend_id` = ?", array($ank['user_id']));
if ($all > 0) {
$n = new navigator($all, 5, 'act=comm&id='.$id);
$sql = DB::$dbs->query("SELECT * FROM ".PHOTO_COMM." WHERE `friend_id` = ? ORDER BY `id` DESC LIMIT {$n->start()},5", array($ank['user_id']));
while($post = $sql -> fetch()) {
echo DIV_AUT . '<a href="'.HOME.'/avatar/comm/'.$ank['user_id'].'/?otv='.$post['user_id'].'">[Jav]</a>
'.($user['user_id'] == $post['user_id'] || $ank['user_id'] == $user['id'] ? '<a href="'.HOME.'/avatar/comm/'.$ank['user_id'].'/?del='.$post['id'].'">[O`chr.]</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;
/* Ответ пользователю */
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 sharh: '.user_choice($ank2['user_id'], 'link').':<br />';
}
echo '<form action="#" method="POST">';
echo '<b>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;
echo DIV_LI . '<a href="'.HOME.'/id'.$ank['user_id'].'">Sahifaga qaytish</a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
}
require_once('../../core/stop.php');
?>