Code:
<?php
if(!defined('MOZG'))
die('You never have to spend Embush');
if($ajax == 'yes')
NoAjaxQuery();
if($logged){
$act = $_GET['act'];
$user_id = $user_info['user_id'];
$metatags['title'] = 'Хочу общаться';
$price = 10; // Устанавливаем цену
$row = $db->super_query("SELECT user_id, user_username, user_search_pref, user_real, user_comm, user_country_city_name, user_birthday, user_xfields, user_xfields_all, user_balance, user_city, user_country, user_group, user_photo, user_friends_num, user_notes_num, user_subscriptions_num, user_wall_num, user_albums_num, user_last_visit, user_videos_num, user_status, user_privacy, user_sp, user_sex, user_gifts, user_public_num, user_audio, user_delet, user_ban_date, xfields, user_doc_num FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
switch($act){
//################### Добавляемся ###################//
case "add":
if($owner['user_balance'] < $price){
msgbox('', 'На вашем счете недостаточно голосов, пожалуйста, пополните баланс!', 'info_2');
}else{
$db->query("UPDATE `".PREFIX."_users` SET user_balance = user_balance-10 , user_comm = 1 WHERE user_id = '{$user_id}'");
header('Location: /radar');
}
break;
default:
//################### Страница "Радар" ###################//
$owner = $db->super_query("SELECT user_balance FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
$tpl->load_template('radar/main.tpl');
if($owner['user_balance'] < $price OR $row['user_comm'] = 1){
$tpl->set('[noo]', '');
$tpl->set('[/noo]', '');
} else
$tpl->set_block("'\\[noo\\](.*?)\\[/noo\\]'si","");
if($row['user_comm'] == 1){
$tpl->set('[comm_yes]', '');
$tpl->set('[/comm_yes]', '');
} else
$tpl->set_block("'\\[comm_yes\\](.*?)\\[/comm_yes\\]'si","");
if($row['user_comm'] != 1){
$tpl->set('[comm_no]', '');
$tpl->set('[/comm_no]', '');
} else
$tpl->set_block("'\\[comm_no\\](.*?)\\[/comm_no\\]'si","");
if($owner['user_balance'] >= $price){
$tpl->set('{ubm}', 'У Вас '.$owner['user_balance'].' голосов.');
$ost = $owner['user_balance'] - $price;
$tpl->set('{ost}', '(останется '.$ost.' голосов.)');
}else{
$tpl->set('{ubm}', 'У Вас недостаточно голосов');
$tpl->set('{ost}', '');
}
$tpl->set('{price}', $price);
$tpl->compile('content');
}
$tpl->clear();
$db->free();
} else {
$user_speedbar = $lang['no_infooo'];
msgbox('', $lang['not_logged'], 'info');
}
?>