Файл: moduls/dey/index.php
Строк: 42
<?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();
switch ($_GET['act']) {
default:
head('Menga amal bajarganlar');
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".DEY." WHERE `friend_id` = ?", array($user['user_id']));
if ($all == 0) {
echo DIV_AUT . 'Ro`yhat bo`sh' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".DEY." WHERE `friend_id` = ? ORDER BY `id` DESC ", array($user['user_id']));
while($post = $sql -> fetch()) {
if ($post['status'] == 1) {
echo DIV_LI . '<b>' . $post['msg'] . '</b>' . CLOSE_DIV;
DB::$dbs->query("UPDATE ".DEY." SET `status` = ? WHERE `id` = ?", array(0, $post['id']));
} else {
echo DIV_LI . $post['msg'] . CLOSE_DIV;
}
}
}
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <b>Amallar</b>' . CLOSE_DIV;
break;
case 'go':
head('Qiziqish bildirish');
$id = abs(intval($_GET['id']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array($id));
$array = array(
array('Ko`z qisish', 'Sizga ko`z qisdi', 'Sizga ko`z qisdi', 50),
array('O`pib olish', 'Sizni o`pdi', 'Sizni o`pdi', 50),
array('Jilmayish', 'Sizga jilmaydi', 'Sizga jilmaydi', 50),
array('Quchoqlash', 'Sizni quchoqladi', 'Sizni quchoqladi', 50),
array('Salomlashish', 'Siz bilan salomlashdi', 'Siz bilan salomlashdi', 50),
array('Sevgi izhor qilish', 'Sizga sevgi izhor qildi', 'Sizga sevgi izhor qildi', 100),
array('Tishlab olish', 'Sizni tishlab oldi', 'Sizni tishlab oldi', 80),
array('So`kish', 'Sani so`kdi', 'Sani so`kdi', 150)
);
$err = array();
if (empty($ank)) {
$err[] = 'Foydalanuvchi ma`lumotlar bazasida topilmadi';
}
if ($ank['user_id'] == $user['user_id']) {
$err[] = 'Siz o`zingizga amal jo`nata olmaysiz';
}
if (!empty($err)) {
echo DIV_ERROR;
foreach ($err AS $value) {
echo $value . '<br />';
}
echo CLOSE_DIV;
} else {
if (isset($_GET['dey'])) {
$dey = abs(num($_GET['dey']));
$err = array();
if (empty($array[$dey])) {
$err[] = 'Harakatlar topilmadi';
}
if ($array[$dey][3] > $user['balls']) {
$err[] = 'Sizda yetarlicha ballar yo`q';
}
if (!empty($err)) {
echo DIV_ERROR;
foreach ($err AS $value) {
echo $value . '<br />';
}
echo CLOSE_DIV;
} else {
/* Формируем текст */
if ($user['gender'] == 1) {
$msg = '<a href="'.HOME.'/id'.$user['user_id'].'">' . $user['nick'] . '</a> ' . $array[$dey][1];
} else {
$msg = '<a href="'.HOME.'/id'.$user['user_id'].'">' . $user['nick'] . '</a> ' . $array[$dey][2];
}
lenta($msg, $ank['user_id']);
DB::$dbs->query("UPDATE ".USERS." SET `balls` = ? WHERE `user_id` = ?", array(($user['balls'] - $array[$dey][3]), $user['user_id']));
DB::$dbs->query("INSERT INTO ".DEY." (`user_id`, `friend_id`, `time`, `msg`, `status`) VALUES (?, ?, ?, ?, ?)", array($user['user_id'], $ank['user_id'], time(), $msg, 1));
echo DIV_MSG . 'Siz foydalanuvchi ' . user_choice($ank['user_id'], 'link') . ' ustidan muvaffaqiyatli harakat jo`natdingiz' . CLOSE_DIV;
}
}
foreach ($array AS $key => $value) {
echo DIV_LI . ' <a href="?dey='.$key.'">'.$value[0].'</a> ['.$value[3].' ball]' . CLOSE_DIV;
}
}
echo DIV_LI . '- <a href="'.HOME.'/id'.$ank['user_id'].'"><b>Sahifaga qaytish</b></a>' . CLOSE_DIV;
$array = array();
nav($array);
break;
}
require_once('../../core/stop.php');
?>