Файл: moduls/harem/index.php
Строк: 132
<?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('Garem');
$all = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `harem_xoz` = ?", array($user['user_id']));
echo DIV_LI . '- <a href="'.HOME.'/harem/my/"><b>Mening garemim</b> ['.$all.']</a>' . CLOSE_DIV;
echo DIV_LI . '- <a href="'.HOME.'/harem/dorog/">Eng qimmatlar</a> [TOP: 10]' . CLOSE_DIV;
echo DIV_LI . '- <a href="'.HOME.'/harem/bogat/">Eng boylar</a> [TOP: 10]' . CLOSE_DIV;
$array = array('Garem');
nav($array);
break;
case 'my':
head('Mening garemim');
$all = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `harem_xoz` = ?", array($user['user_id']));
if ($all == 0) {
echo DIV_AUT . 'Garem bo`sh' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".USERS." WHERE `harem_xoz` = ? ORDER BY `xoz_pokup_all` DESC ", array($user['user_id']));
while($ank = $sql -> fetch()) {
echo DIV_LI . user_choice($ank['user_id'], 'link') . ' <a href="'.HOME.'/harem/otpusk/'.$ank['user_id'].'/">[Chiqarish]</a>' . CLOSE_DIV;
}
}
$array = array('Garem', 'Mening garemim');
nav($array);
break;
case 'user':
$id = abs(intval($_GET['id']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array($id));
$err = array();
if (empty($ank)) {
$err[] = 'Foydalanuvchi topilmadi';
}
if (empty($ank)) {
head('Garem topilmadi');
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/harem/">Garem</a> / <b>Xatolik!</b>' . CLOSE_DIV;
} else {
head('Mening garemim');
$all = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `harem_xoz` = ?", array($ank['user_id']));
if ($all == 0) {
echo DIV_AUT . 'Garem bo`sh' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".USERS." WHERE `harem_xoz` = ? ORDER BY `xoz_pokup_all` DESC ", array($ank['user_id']));
while($ank = $sql -> fetch()) {
echo DIV_LI . user_choice($ank['user_id'], 'link') . CLOSE_DIV;
}
}
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/harem/">Garem</a> / <b> '.$ank['nick'].' garemi</b>' . CLOSE_DIV;
}
break;
case 'kup':
head('Garemga sotib olish');
$id = abs(intval($_GET['id']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array($id));
$err = array();
if (empty($ank)) {
$err[] = 'Foydalanuvchi topilmadi';
}
if ($ank['user_id'] == $user['user_id']) {
$err[] = 'Siz o`zingizni garemga sotib ololmaysiz';
}
if ($ank['harem_xoz'] == $user['user_id']) {
$err[] = $ank['nick'] . ' sizni garemingizda bor';
}
if (!empty($err)) {
echo DIV_ERROR;
foreach ($err AS $value) {
echo $value . '<br />';
}
echo CLOSE_DIV;
} else {
$priceSumm = 50; // Boshlangich baxo
if (empty($ank['harem_pokup_all'])) {
$price = $priceSumm;
} else {
$price = ($ank['harem_pokup_all'] * $priceSumm) + $priceSumm;
}
if ($user['balls'] < $price) {
echo DIV_AUT . 'Sizda ballar yetarli emas' . CLOSE_DIV;
} else {
if (empty($ank['harem_xoz'])) {
/* Sotib olamiz (Bildirishnoma) */
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> sizni o`z <a href="'.HOME.'/harem/user/'.$user['user_id'].'/"><b>garemiga</b></a> <b>' . $price . '</b> ballga sotib oldi';
lenta($lenta, $ank['user_id']);
} else {
/* O`g`irlaymiz (Bildirishnoma) */
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> sizni o`z <a href="'.HOME.'/harem/user/'.$user['user_id'].'/"><b>garemiga</b></a> <b>' . $price . '</b> ballga sotib oldi';
lenta($lenta, $ank['user_id']);
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> sizni <a href="'.HOME.'/id'.$ank['user_id'].'"><b>' . $ank['nick'] . '</b></a> garemidan olib qochdi, <b>' . $price . '</b> ballga';
lenta($lenta, $ank['harem_xoz']);
}
DB::$dbs->query("UPDATE ".USERS." SET `harem_xoz` = ?, `harem_pokup_all` = ? WHERE `user_id` = ?", array($user['user_id'], (++$ank['harem_pokup_all']), $ank['user_id']));
DB::$dbs->query("UPDATE ".USERS." SET `balls` = ?, `xoz_pokup_all` = ? WHERE `user_id` = ?", array(($user['balls'] - $price), (++$user['xoz_pokup_all']), $user['user_id']));
echo DIV_MSG . $ank['nick'] . ' <a href="'.HOME.'/harem/my/">Garemingizga</a> muvaffaqiyatli sotib olindi' . CLOSE_DIV;
}
}
$array = array('Garem', 'Garemga sotib olish');
nav($array);
break;
case 'otpusk':
head('Garemdan chiqaramiz');
$id = abs(intval($_GET['id']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ?",array($id));
$err = array();
if (empty($ank)) {
$err[] = 'Foydalanuvchi topilmadi';
}
if ($ank['user_id'] == $user['user_id']) {
$err[] = 'Siz o`zingizni o`z garemingizdan chiqara olmaysiz';
}
if ($ank['harem_xoz'] != $user['user_id']) {
$err[] = $ank['nick'] . ' sizning garemingizdan emas';
}
if (!empty($err)) {
echo DIV_ERROR;
foreach ($err AS $value) {
echo $value . '<br />';
}
echo CLOSE_DIV;
} else {
/* Bildirishnoma qilamiz */
$lenta = '<a href="'.HOME.'/id'.$user['user_id'].'"><b>' . $user['nick'] . '</b></a> sizni <a href="'.HOME.'/harem/user/'.$user['user_id'].'/"><b>garemidan</b></a> <b>' . $price . '</b> ballga chiqardi';
lenta($lenta, $ank['user_id']);
/* */
DB::$dbs->query("UPDATE ".USERS." SET `harem_xoz` = ? WHERE `user_id` = ?", array(0, $ank['user_id']));
DB::$dbs->query("UPDATE ".USERS." SET `xoz_pokup_all` = ? WHERE `user_id` = ?", array((--$user['xoz_pokup_all']), $user['user_id']));
echo DIV_MSG . $ank['nick'] . ' <a href="'.HOME.'/harem/my/">garemingizdan</a> muvaffaqiyatli chiqarildi' . CLOSE_DIV;
}
$array = array('Garem', 'Garemdan chiqarish');
nav($array);
break;
case 'dorog':
$priceSumm = 50; // Boshlang`ich baxo
head('Eng qimmatlar');
$all = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `harem_pokup_all` > ?", array(0));
if ($all == 0) {
echo DIV_AUT . 'Ro`yhat bo`sh' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".USERS." WHERE `harem_pokup_all` > ? ORDER BY `harem_pokup_all` DESC LIMIT 10", array(0));
while($ank = $sql -> fetch()) {
if (empty($ank['harem_pokup_all'])) {
$price = $priceSumm;
} else {
$price = ($ank['harem_pokup_all'] * $priceSumm);
}
echo DIV_LI . user_choice($ank['user_id'], 'link') . ' [Baxosi: '.$price.' ball]' . CLOSE_DIV;
}
}
$array = array('Garem', 'Eng qimmatlar');
nav($array);
break;
case 'bogat':
head('Eng boylar');
$all = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `xoz_pokup_all` > ?", array(0));
if ($all == 0) {
echo DIV_AUT . 'Ro`yhat bo`sh' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".USERS." WHERE `xoz_pokup_all` > ? ORDER BY `xoz_pokup_all` DESC LIMIT 10", array(0));
while($ank = $sql -> fetch()) {
echo DIV_LI . user_choice($ank['user_id'], 'link') . ' [Garemida: '.$ank['xoz_pokup_all'].' odam]' . CLOSE_DIV;
}
}
$array = array('Garem', 'Eng boylar');
nav($array);
break;
}
require_once('../../core/stop.php');
?>