Файл: InstantSocial/uploud/components/present/ajax/present_form.php
Строк: 69
<?php
/*********************************************************************************************/
// //
// InstantPresent v1.0 (c) 2010 //
// http://www.instantcms.ru/, info@instantcms.ru //
// //
// written by Somebody & Александр, 2010 //
// //
/*********************************************************************************************/
session_start();
define("VALID_CMS", 1);
define('PATH', $_SERVER['DOCUMENT_ROOT']);
define('HOST', 'http://' . $_SERVER['HTTP_HOST']);
include(PATH.'/core/cms.php');
$inCore = cmsCore::getInstance();
$inCore->loadClass('page');
$inCore->loadClass('config');
$inCore->loadClass('db');
$inCore->loadClass('user');
$inDB = cmsDatabase::getInstance();
$inCore->loadLanguage('components/present');
$inCore->loadSmarty();
$smarty = new Smarty();
$inUser = cmsUser::getInstance();
$inUser->update();
$present_id = $inCore->request('present_id', 'int', 0);
$to_id = $inCore->request('user_id', 'int', 0);
$from_id = $inUser->id;
if ($present_id && $to_id && $from_id){
//Цена подарка
$sql = "SELECT price FROM cms_present WHERE id = '$present_id' AND published = 1 LIMIT 1";
$result = $inDB->query($sql);
if ($inDB->num_rows($result)){ $pres = $inDB->fetch_assoc($result); } else { echo 'error'; }
//У пользователя на счету
$sql = "SELECT rating FROM cms_users WHERE id = '$from_id' LIMIT 1";
$result = $inDB->query($sql);
if ($inDB->num_rows($result)){ $usr = $inDB->fetch_assoc($result); } else { echo 'error'; }
if ($pres['price'] > $usr['rating']){ echo 'error'; }
else {
// отдаем в шаблон
ob_start();
$smarty = $inCore->initSmarty('components', 'com_present_form_ajax.tpl');
$smarty->assign('price', $pres['price']);
$smarty->assign('present_id', $present_id);
$smarty->display('com_present_form_ajax.tpl');
$html = ob_get_clean();
echo $html;
}
} else { echo 'error'; }
return;
?>