Example #1
0
 /**
  * Вывод страницы /gift/ "Подарок".
  */
 public function giftAction()
 {
     include $_SERVER['DOCUMENT_ROOT'] . '/404.php';
     exit;
     /*
      * @deprecated Все что ниже пока не используется
      */
     front::og('tpl')->page = 'gift';
     self::isBlockMoney();
     /**
      * Подключаем AJAX для страницы.
      */
     require_once $_SERVER['DOCUMENT_ROOT'] . '/xajax/bill.common.php';
     front::og('tpl')->script = '/scripts/bill2.js';
     front::og('tpl')->xajax = $xajax;
     front::og('tpl')->mnth = 1;
     // Месяцев оплаты по умолчанию
     $val = $this->uri[0];
     switch ($val) {
         case 'pro':
             // Вывод подстраницы "Аккаунт «PRO»"
             /*
              * Обработка события "Подарить"
              */
             if ($_POST['act']) {
                 $mnth = intval(trim($_POST['mnth']));
                 // месяцев
                 $login = trim(strip_tags($_POST['login']));
                 // логин пользователя
                 $msg = change_q_x(__paramInit('string', null, 'msg', null, 300));
                 $usertype = trim(strip_tags($_POST['usertype']));
                 /**
                  * Подключаем класс для оплаты подарка.
                  */
                 require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/payed.php';
                 $prof = new payed();
                 $tr_id = $_REQUEST['transaction_id'];
                 if (!$tr_id) {
                     $this->account->view_error('Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.');
                 }
                 front::og('tpl')->tr_id = $tr_id;
                 front::og('tpl')->login = $login;
                 front::og('tpl')->msg = $msg;
                 front::og('tpl')->mnth = $mnth;
                 /*
                  * Если нет ошибок выводим
                  */
                 if ($mnth > 0 && $login) {
                     // Класс для работы с пользователем
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
                     $user = new users();
                     $gid = $user->GetUid($error, $login);
                     $user->GetUser($login);
                     if (!$gid) {
                         $alert['login'] = '******';
                     }
                     if ($gid == get_uid()) {
                         $alert['login'] = '******';
                     }
                     if (defined('SPEC_USER') && get_uid() == SPEC_USER) {
                         $alert['login'] = '******';
                     }
                     if (!$alert) {
                         $role = $user->GetRole($login, $error);
                         /*
                          * Высчитываем тариф для обработки. Тариф зависит от количества месяцев (Действуют специальные скидки)
                          */
                         if (substr($role, 0, 1) != '0') {
                             $tarif = 16;
                         } else {
                             $tarif = 52;
                             if ($mnth == 3) {
                                 $tarif = 66;
                             }
                             if ($mnth == 6) {
                                 $tarif = 67;
                             }
                             if ($mnth == 12) {
                                 $tarif = 68;
                             }
                         }
                         $ok = $prof->GiftOrderedTarif($bill_id, $gift_id, $gid, get_uid(), $tr_id, $mnth, $msg, $tarif);
                         // Оплата подарка
                         if ($ok) {
                             // Посылаем уведомление о подарке и переносим на страницу успешной оплаты
                             $sm = new smail();
                             $sm->NewGift($_SESSION['login'], $login, $msg, $gift_id);
                             $_SESSION['success_aid'] = $bill_id;
                             header("Location: /{$this->name_page}/success/");
                             exit;
                         }
                         unset($msg);
                     }
                 } else {
                     $alert['login'] = '******';
                 }
                 front::og('tpl')->error = $alert;
             }
             front::og('tpl')->display('bill/bill_gift_pro.tpl');
             break;
         case 'main':
             // Вывод подстраницы "Платное размещение в разделе"
             front::og('tpl')->type = 1;
             // Типа размещения = неделя
             /*
              * Обработка события "Подарить" - при нажатии кнопки подарить
              */
             if ($_POST['act']) {
                 $type = intval(trim($_POST['type']));
                 // Сколько недель
                 $login = trim(strip_tags($_POST['login']));
                 $msg = change_q_x(__paramInit('string', null, 'msg', null, 300));
                 /**
                  * Класс для обработки оплаты и взаимодействия механизма вывода.
                  */
                 require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/firstpage.php';
                 $prof = new firstpage();
                 $tr_id = $_REQUEST['transaction_id'];
                 if (!$tr_id) {
                     $this->account->view_error('Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.');
                 }
                 front::og('tpl')->tr_id = $tr_id;
                 front::og('tpl')->login = $login;
                 front::og('tpl')->msg = $msg;
                 front::og('tpl')->type = $type;
                 if (!$type) {
                     $alert['type'] = 'Не выбрано количество недель.';
                 } else {
                     $d_time = "{$type} неделя";
                     $intv = "{$type} weeks";
                     if ($login) {
                         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
                         $user = new users();
                         $gid = $user->GetUid($error, $login);
                         $user->GetUser($login);
                         if (!$gid) {
                             $alert['login'] = '******';
                         }
                         if (is_emp($user->role)) {
                             $alert['login'] = '******';
                         }
                         if ($gid == get_uid()) {
                             $alert['login'] = '******';
                         }
                         if (defined('SPEC_USER') && get_uid() == SPEC_USER) {
                             $alert['login'] = '******';
                         }
                         if (!$alert) {
                             $order_id = $prof->Gift($bill_id, $gift_id, $gid, get_uid(), $tr_id, $intv, 17, $msg, $type);
                             if (!$order_id) {
                                 header('Location: /bill/fail/');
                                 // Если оплата не прошла
                                 exit;
                             } else {
                                 // Уведомление на почту
                                 $sm = new smail();
                                 $sm->NewGift($_SESSION['login'], $login, $msg, $gift_id);
                                 $_SESSION['success_aid'] = $bill_id;
                                 header("Location: /{$this->name_page}/success/");
                                 // Если все прошло успешно переносим на страницу - Успешно
                                 exit;
                             }
                         }
                     } else {
                         $alert['login'] = '******';
                     }
                 }
                 front::og('tpl')->error = $alert;
             }
             front::og('tpl')->display('bill/bill_gift_main.tpl');
             break;
         case 'fronttop':
             // Обработка подстраницы "Платные места наверху главной страницы"
             // Событие нажатия кнопки "Подарить"
             if ($_POST['act']) {
                 $login = trim(strip_tags($_POST['login']));
                 // Логин
                 $msg = change_q_x(__paramInit('string', null, 'msg', null, 300));
                 $tr_id = $_REQUEST['transaction_id'];
                 if (!$tr_id) {
                     $this->account->view_error('Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.');
                 }
                 front::og('tpl')->tr_id = $tr_id;
                 front::og('tpl')->login = $login;
                 front::og('tpl')->msg = $msg;
                 if ($login) {
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
                     $user = new users();
                     $gid = $user->GetUid($error, $login);
                     $user->GetUser($login);
                     if (is_emp($user->role)) {
                         $alert['login'] = '******';
                     }
                     if ($gid == get_uid()) {
                         $alert['login'] = '******';
                     }
                     if (defined('SPEC_USER') && get_uid() == SPEC_USER) {
                         $alert['login'] = '******';
                     }
                     if (!$gid) {
                         $alert['login'] = '******';
                     }
                     if (!$alert) {
                         /**
                          * Класс для работы с оплатой подарка.
                          */
                         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/pay_place.php';
                         $place = new pay_place();
                         $tarif = 69;
                         $profs = $place->gift($bill_id, $gift_id, $tr_id, $gid, get_uid(), $msg, $tarif);
                         // Оплачиваем подарок
                         if ($profs) {
                             $_SESSION['success_aid'] = $bill_id;
                             header("Location: /{$this->name_page}/success/");
                             // Все прошло успешно
                             exit;
                         }
                     }
                 } else {
                     $alert['login'] = '******';
                 }
                 front::og('tpl')->error = @$alert;
                 // Переменная ошибок
             }
             front::og('tpl')->display('bill/bill_gift_fronttop.tpl');
             break;
         case 'cattop':
             // Обработка подстраницы "Платные места наверху каталога"
             // Событие нажатия кнопки "Подарить"
             if ($_POST['act']) {
                 $login = trim(strip_tags($_POST['login']));
                 // Логин
                 $msg = change_q_x(__paramInit('string', null, 'msg', null, 300));
                 $tr_id = $_REQUEST['transaction_id'];
                 if (!$tr_id) {
                     $this->account->view_error('Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.');
                 }
                 front::og('tpl')->tr_id = $tr_id;
                 front::og('tpl')->login = $login;
                 front::og('tpl')->msg = $msg;
                 if ($login) {
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
                     $user = new users();
                     $gid = $user->GetUid($error, $login);
                     $user->GetUser($login);
                     if (!$gid) {
                         $alert['login'] = '******';
                     }
                     if (is_emp($user->role)) {
                         $alert['login'] = '******';
                     }
                     if ($gid == get_uid()) {
                         $alert['login'] = '******';
                     }
                     if (defined('SPEC_USER') && get_uid() == SPEC_USER) {
                         $alert['login'] = '******';
                     }
                     if (!$alert) {
                         /**
                          * Класс для работы с оплатой подарка.
                          */
                         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/pay_place.php';
                         $place = new pay_place(1);
                         $tarif = 83;
                         $profs = $place->gift($bill_id, $gift_id, $tr_id, $gid, get_uid(), $msg, $tarif);
                         // Оплачиваем подарок
                         if ($profs) {
                             $_SESSION['success_aid'] = $bill_id;
                             header("Location: /{$this->name_page}/success/");
                             // Все прошло успешно
                             exit;
                         }
                     }
                 } else {
                     $alert['login'] = '******';
                 }
                 front::og('tpl')->error = @$alert;
                 // Переменная ошибок
             }
             front::og('tpl')->display('bill/bill_gift_cattop.tpl');
             break;
         case 'catalog':
             // Обработка подстраницы "Платные места в каталоге в подарок"
             // Событие нажатия кнопки "Подарить"
             front::og('tpl')->filter_categories = professions::GetAllGroupsLite(true);
             front::og('tpl')->filter_subcategories = professions::GetAllProfessions(1);
             $x = new op_codes();
             $x->GetRow(84);
             $top_p = $x->sum;
             $x->GetRow(85);
             $inside_p = $x->sum;
             front::og('tpl')->price_top = $top_p;
             front::og('tpl')->price_inside = $inside_p;
             if ($_POST['act']) {
                 $login = trim(strip_tags($_POST['login']));
                 // Логин
                 $msg = change_q_x(__paramInit('string', null, 'msg', null, 300));
                 $pf_category = __paramInit('int', null, 'pf_category', 0);
                 $pf_subcategory = __paramInit('int', null, 'pf_subcategory', 0);
                 //echo '<pre>'; print_r($_POST); exit('</pre>');
                 $tr_id = $_REQUEST['transaction_id'];
                 if (!$tr_id) {
                     $this->account->view_error('Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.');
                 }
                 front::og('tpl')->tr_id = $tr_id;
                 front::og('tpl')->login = $login;
                 front::og('tpl')->msg = $msg;
                 front::og('tpl')->pf_category = $pf_category;
                 front::og('tpl')->pf_subcategory = $pf_subcategory;
                 if ($login) {
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
                     $user = new users();
                     $gid = $user->GetUid($error, $login);
                     $user->GetUser($login);
                     if (!$gid) {
                         $alert['login'] = '******';
                     }
                     if (is_emp($user->role)) {
                         $alert['login'] = '******';
                     }
                     if ($gid == get_uid()) {
                         $alert['login'] = '******';
                     }
                     if (defined('SPEC_USER') && get_uid() == SPEC_USER) {
                         $alert['login'] = '******';
                     }
                     $weeks = (int) $_POST['weeks'];
                     if (!$weeks) {
                         $alert['week'] = 'Данное поле является обязательным';
                     }
                     if (!$alert) {
                         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/firstpage.php';
                         $prof = new firstpage();
                         $pf_category = (int) $_POST['pf_category'];
                         $pf_subcategory = (int) $_POST['pf_subcategory'];
                         $page = !$pf_subcategory ? 0 : $pf_subcategory;
                         $place_info = array($page => $weeks);
                         $op_code = $page ? 85 : 84;
                         //                                                                               require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/account.php");
                         //                                                                                $account = new account();
                         //                                                                                $account ->/ view_error("Невозможно завершить транзакцию. Попробуйте повторить операцию с самого начала.");
                         $account = new account();
                         if ($prof->GiftOrderedCat($bill_id, $gift_id, $gid, get_uid(), $tr_id, $page, (int) $weeks, $op_code, $msg)) {
                             $_SESSION['success_aid'] = $bill_id;
                             header("Location: /{$this->name_page}/success/");
                             // Все прошло успешно
                             exit;
                         }
                     }
                 } else {
                     $alert['login'] = '******';
                 }
                 front::og('tpl')->error = @$alert;
                 // Переменная ошибок
             }
             front::og('tpl')->display('bill/bill_gift_catalog.tpl');
             break;
         default:
             /*
              * По умолчанию выводим главную страницу раздела "Подарки"
              */
             front::og('tpl')->display('bill/bill_gift.tpl');
             break;
     }
 }