<?php
 define('_IN_JOHNCMS', 1);
 $headmod = 'shop';
 $textl = 'Profilni berkitish';
 require('../incfiles/core.php');
 require('../incfiles/head.php');
	if (!$user_id) {
		echo '<div class="rmenu">Faqat foydalanuvchilar uchun</div>';
		require('../incfiles/end.php');
		exit();
	}
$narx = mysql_fetch_assoc(mysql_query("SELECT `price` FROM `shop` WHERE `id` = 16"));
$narx = $narx['price'];
	switch ($act) {
	default:
		if ($datauser['closed'] == 0) {
			echo '<div class="list2">Ushbu xizmat orqali siz profilingizni berkitib olishingiz mumkin. Bunda sizni shaxsiy ma\'lumotlaringizni, rasmlaringizni faqat do\'stlaringiz ko\'rishi mumkin bo\'ladi. Shuningdek shaxsiy xabarni ham faqat do\'stlar yuborishi mumkin.</div>';
			if ($datauser['balans'] < $narx) {
			echo '<div class="list1">Hozirda bu xizmatni yoqtirish uchun yetarli ball mavjud emas. Xizmat narxi '.$narx.' ball. Saytda faol bo\'lib, ballaringizni ko\'paytirishingiz mumkin!</div>';
			require('../incfiles/end.php');
			exit();
			} else {
			echo '<div class="list1">Xizmat narxi '.$narx.' ball. Xizmatni rostdan yoqtirmoqchimisiz?<br /><form action="?act=do" method="POST"><input type="submit" value="Yoqtirish" /></form></div>';
			require('../incfiles/end.php');
			exit();
			}
		} else {
			echo '<div class="list2">Sizning profilingiz berkitilgan. Buyer orqali profilingizni ochiq holatga o\'tkazishingiz mumkin. Xizmat bepul. Lekin yana qaytadan yopish '.$narx.' ball.</div><div class="list1"><form action="?act=undo" method="POST"><input type="submit" value="Ochish" /></form></div>'; 
		}
break;

case 'do':
//oldin xatolardi tekshirvoleli akalar
	if ($datauser['closed'] == 1) {
	echo '<div class="rmenu">Xizmat oldin yoqilgan<br /><a href="index.php">Ortga</a></div>';
	require('../incfiles/end.php');
	exit(); 
	}
//oldin yopgan bosa qayta yoqomedi endi
	if ($datauser['balans'] < $narx) {
	echo '<div class="rmenu">Xizmat uchun ballingiz yetarli emas<br /><a href="index.php">Ortga</a></div>';
	require('../incfiles/end.php');
	exit(); 
	}
//puli oz bosa ololmedi
//xatolardi tekshirvoldik endi yopib qoyeli
	$yangi = $datauser['balans'] - $narx;
	mysql_query("UPDATE `users` SET `balans` = '".$yangi."', `closed` = '1' WHERE `id` = '".$user_id."'");
	echo '<div class="gmenu">Profilingiz muvaffaqqiyatli tarzda berkitildi!<br /> <a href="index.php">Ortga</a></div>';
	break;

case 'undo':
//oldin xatolardi tekshirvoleli akalar
	if ($datauser['closed'] == 0) {
	echo '<div class="rmenu">Profiliz berkitilmagan!<br /><a href="index.php">Ortga</a></div>';
	require('../incfiles/end.php');
	exit(); 
	}
//oldin yopgan bosa qayta yoqomedi endi
//xatolardi tekshirvoldik endi yopib qoyeli
	mysql_query("UPDATE `users` SET `closed` = '0' WHERE `id` = '".$user_id."'");
	echo '<div class="gmenu">Profilingiz muvaffaqqiyatli tarzda ochildi!<br /> <a href="index.php">Ortga</a></div>';
	break;
	}
 require('../incfiles/end.php');
?>
