Example #1
0
 /**
  * Вызывает обработку Ajax-запросов
  * 
  * @return void
  */
 public function user()
 {
     if (!empty($_POST['user_id'])) {
         $this->result["name"] = DB::query_result("SELECT fio FROM {users} WHERE id='%d'", $_POST['user_id']);
         $usersisert = DB::query("INSERT INTO {clock} (color) VALUES ('255,000,000')");
     } else {
         $this->result["name"] = 'ошибка';
     }
 }
Example #2
0
 /**
  * Получаем роль пользователя
  * @var int userId
  * @return int
  */
 public function _dfnGetUserRoleId($userId)
 {
     //см. таблицу {users_role}
     if ($userId) {
         PayqrLog::log("SELECT role_id FROM diafan_users WHERE id=" . $userId);
         return DB::query_result("SELECT role_id FROM {users} WHERE id=%d", $userId);
     }
     return 0;
 }
Example #3
0
 /**
  * Выводит контент модуля
  * 
  * @return void
  */
 public function show()
 {
     // DB::query("UPDATE {".$this->diafan->table."} SET color=1 WHERE id='1'");
     $userss = DB::query_result("SELECT * FROM {clock} WHERE text='часы'");
     if (!$userss["text"]) {
         $usersisert = DB::query("INSERT INTO {" . $this->diafan->table . "} (text) VALUES ('часы')");
     }
     // $users = DB::query_fetch_all("SELECT id, fio FROM {users} WHERE trash='0' ORDER BY fio ASC");
     // $usersisert= DB::query("INSERT INTO {clock} (color) VALUES ('255,000,000')");
     echo '<h2>выбор цвета часов:</h2><div style="cursor: pointer;width:50px;height:50px ;background:#ff0000;"  id="red"></div>';
     echo '<div style=" cursor: pointer;width:50px;height:50px ;background:#00ff00;"  id="green"></div>';
     echo '<div style="cursor: pointer;width:50px;height:50px ;background:#0000ff;"  id="blue"></div>';
     $this->diafan->list_row();
 }
Example #4
0
 /**
  * @return void
  */
 public function show()
 {
     $this->result = array();
     ////navigation//
     $this->diafan->_paginator->nen = DB::query_result("SELECT COUNT(id) FROM {clock} WHERE act='1' AND trash='0'");
     $this->result["paginator"] = $this->diafan->_paginator->get();
     ////navigation///
     $rows = DB::query_range_fetch_all("SELECT id, created, text FROM {clock} WHERE act='1' AND trash='0' ORDER BY created DESC, id DESC", $this->diafan->_paginator->polog, $this->diafan->_paginator->nastr);
     $row['color'] = DB::query_result("SELECT color FROM {clock} WHERE text='часы'");
     $this->result['rows'][] = $row;
     //сохранение кэша
     $this->diafan->_cache->save($this->result, $cache_meta, 'clock');
     $this->result["paginator"] = $this->diafan->_tpl->get('get', 'paginator', $this->result["paginator"]);
     $this->result['view'] = 'show';
 }
Example #5
0
 /**
  * @param $cart_summ
  * @param null $userId
  * @return bool
  */
 private function get_discount_total($cart_summ, $userId = null)
 {
     PayqrLog::log("get_discount_total");
     $discount = false;
     $order_summ = 0;
     if ($userId) {
         $order_summ = DB::query_result("SELECT SUM(summ) FROM {shop_order} WHERE user_id=%d AND (status='1' OR status='3')", $userId);
     }
     PayqrLog::log("Order sum : " . $order_summ);
     //скидка на общую сумму заказа
     $person_discount_ids = $this->diafan->_shop->price_get_person_discounts();
     PayqrLog::log("Получили скидки клиенту: ", print_r($person_discount_ids, true));
     $userRoleId = dfnUserAuth::getInstance($this->diafan)->_dfnGetUserRoleId($userId);
     PayqrLog::log("Получили роль пользователя: " . $userRoleId);
     $rows = DB::query_fetch_all("SELECT id, discount, amount, deduction, threshold, threshold_cumulative FROM" . " {shop_discount} WHERE act='1' AND trash='0' AND (threshold_cumulative>0 OR threshold>0)" . " AND role_id" . ($userRoleId ? ' IN (0, ' . $userRoleId . ')' : '=0') . " AND (person='0'" . ($person_discount_ids ? " OR id IN(" . implode(",", $person_discount_ids) . ")" : "") . ")" . " AND date_start<=%d AND (date_finish=0 OR date_finish>=%d)" . " AND (threshold_cumulative>0 AND threshold_cumulative<=%f" . " OR threshold>0 AND threshold<=%f)", time(), time(), $order_summ, $cart_summ);
     PayqrLog::log("После получения скидки: ", print_r($rows, true));
     foreach ($rows as $row) {
         $row["discount_id"] = $row["id"];
         if ($row['deduction']) {
             if ($row['deduction'] < $cart_summ) {
                 $row["discount_summ"] = $row["deduction"];
             } else {
                 $row["discount_summ"] = 0;
             }
         } else {
             $row["discount_summ"] = $cart_summ * $row["discount"] / 100;
         }
         if (empty($discount) || $discount["discount_summ"] < $row["discount_summ"]) {
             $discount = $row;
         }
     }
     return $discount;
 }
Example #6
0
 /**
  * Проверка, есть ли пользователь с указанным id в базе
  * @param $u_id
  * @return bool
  */
 public function uloginCheckUserId($user_id = 0)
 {
     $user_id = DB::query_result("SELECT * FROM {users} WHERE trash='0' AND act='1' AND id=%d", $user_id);
     $current_user = isset($this->diafan->_users->id) ? $this->diafan->_users->id : 0;
     if ($current_user > 0 && $user_id > 0 && $current_user != $user_id) {
         throw new Exception($this->diafan->_('Данный аккаунт привязан к другому пользователю. Вы не можете использовать этот аккаунт.'));
     }
     return true;
 }
Example #7
0
 /**
  * Сохранение поля "Файл"
  * @return void
  */
 public function save_variable_file()
 {
     if ($_POST['type'] == 1) {
         if (!empty($_FILES["attachment_img"]['name'])) {
             $extension_array = array('jpg', 'jpeg', 'gif', 'png');
             $new_name = strtolower($this->diafan->translit($_FILES["attachment_img"]['name']));
             $extension = substr(strrchr($new_name, '.'), 1);
             if (!in_array($extension, $extension_array)) {
                 throw new Exception('Не удалось загрузить файл. Возможно, закрыт доступ к папке или файл превышает максимально допустимый размер');
             }
             $new_name = substr($new_name, 0, -(strlen($extension) + 1)) . '_' . $this->diafan->id . '.' . $extension;
             $file_name = DB::query_result("SELECT file FROM {bs} WHERE id=%d LIMIT 1", $this->diafan->id);
             if (!empty($file_name)) {
                 File::delete_file(USERFILES . '/' . $this->diafan->table . '/' . $file_name);
             }
             File::upload_file($_FILES["attachment_img"]['tmp_name'], USERFILES . "/pbs/" . $new_name);
             $this->diafan->set_query("file='%s'");
             $this->diafan->set_value($new_name);
             $this->diafan->set_query("html='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("width='%d'");
             $this->diafan->set_value('');
             $this->diafan->set_query("height='%d'");
             $this->diafan->set_value('');
         }
         $this->diafan->set_query("type=%d");
         $this->diafan->set_value(1);
         $this->diafan->set_query("alt" . _LANG . "='%s'");
         $this->diafan->set_value($_POST['alt']);
         $this->diafan->set_query("title" . _LANG . "='%s'");
         $this->diafan->set_value($_POST['title']);
     }
     if ($_POST['type'] == 2) {
         if (!empty($_FILES["attachment_swf"]['name'])) {
             $extension_array = array('swf');
             $new_name = strtolower($this->diafan->translit($_FILES["attachment_swf"]['name']));
             $extension = substr(strrchr($new_name, '.'), 1);
             if (!in_array($extension, $extension_array)) {
                 throw new Exception($this->diafan->_('Не удалось загрузить файл. Возможно, закрыт доступ к папке или файл превышает максимально допустимый размер'));
             }
             $new_name = substr($new_name, 0, -(strlen($extension) + 1)) . '_' . $this->diafan->id . '.' . $extension;
             $file_name = DB::query_result("SELECT file FROM {bs} WHERE id=%d LIMIT 1", $this->diafan->id);
             if (!empty($file_name)) {
                 File::delete_file(USERFILES . '/' . $this->diafan->table . '/' . $file_name);
             }
             File::upload_file($_FILES["attachment_swf"]['tmp_name'], USERFILES . "/" . $this->diafan->table . '/' . $new_name);
             $this->diafan->set_query("file='%s'");
             $this->diafan->set_value($new_name);
             $this->diafan->set_query("html='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("alt" . _LANG . "='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("title" . _LANG . "='%s'");
             $this->diafan->set_value('');
         }
         $this->diafan->set_query("type='%d'");
         $this->diafan->set_value(2);
         $this->diafan->set_query("width='%d'");
         $this->diafan->set_value($_POST['width']);
         $this->diafan->set_query("height='%d'");
         $this->diafan->set_value($_POST['height']);
     }
     if ($_POST['type'] == 3) {
         if (!empty($_POST['html'])) {
             $file_name = DB::query_result("SELECT file FROM {bs} WHERE id=%d LIMIT 1", $this->diafan->id);
             if (!empty($file_name)) {
                 File::delete_file(USERFILES . '/' . $this->diafan->table . '/' . $file_name);
             }
             $this->diafan->set_query("html='%s'");
             $this->diafan->set_value($_POST['html']);
             $this->diafan->set_query("file='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("alt" . _LANG . "='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("title" . _LANG . "='%s'");
             $this->diafan->set_value('');
             $this->diafan->set_query("width='%d'");
             $this->diafan->set_value('');
             $this->diafan->set_query("height='%d'");
             $this->diafan->set_value('');
         }
         $this->diafan->set_query("type='%d'");
         $this->diafan->set_value(3);
     }
 }
Example #8
0
 function __construct()
 {
     $DB = new DB();
     $auth_code = $DB->query_result("SELECT code FROM youtube_authorization_code ORDER by youtube_authorization_code_id DESC LIMIT 1");
     $this->authorization_code = $auth_code[0]['code'];
 }
Example #9
0
 /**
  * Проверяет правильность ввода капчи «Вопрос-Ответ»
  *
  * @return string|boolean false
  */
 private function error_qa()
 {
     if (empty($_SESSION["captcha_id"]) || empty($_POST["captcha_answer_id"])) {
         return $this->diafan->_('Выберите правильный ответ.', false);
     }
     if (!DB::query_result("SELECT COUNT(*) FROM {captcha_answers} WHERE trash='0' AND captcha_id=%d AND id=%d AND is_right='1'", $_SESSION["captcha_id"], $_POST["captcha_answer_id"])) {
         return $this->diafan->_('Ответ не верный.', false);
     }
     return false;
 }
Example #10
0
 public function cancelOrder()
 {
     PayqrLog::log("cancelOrder");
     $order_id = $this->invoice->getOrderId();
     PayqrLog::log("cancelOrder получили номер заказа: " . $order_id);
     if (!empty($order_id)) {
         //получаем статус заказа "в обработке"
         $status_id = DB::query_result("SELECT id FROM {shop_order_status} WHERE status='2' LIMIT 1");
         PayqrLog::log("cancelOrder получили статус заказа 'Отменен': " . $status_id);
         //меняем статус заказа
         DB::query("UPDATE {shop_order} set status_id=%d WHERE id=%d", $status_id, $order_id);
         PayqrLog::log("cancelOrder произвели обновление статуса заказа: ");
     }
 }
Example #11
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
include 'Library/DB.php';
print_r('<pre/>');
print_r($_REQUEST);
if (isset($_REQUEST['code'])) {
    $DB1 = new DB();
    $result = $DB1->query_result("SELECT code FROM youtube_authorization_code WHERE code = '" . $DB1->sanitize['code'] . "' ");
    print_r($result);
    if (isset($result[0]['code'])) {
        if ($result[0]['code'] == $DB1->sanitize['code']) {
            echo 'Already Set';
        } else {
            $DB2 = new DB();
            $DB2->query_no_result("INSERT INTO youtube_authorization_code (code,updated) VALUES ('" . $DB2->sanitize['code'] . "','" . date("Y-m-d H:i:s") . "')");
            print_r($DB2);
        }
    } else {
        $DB2 = new DB();
        $DB2->query_no_result("INSERT INTO youtube_authorization_code (code,updated) VALUES ('" . $DB2->sanitize['code'] . "','" . date("Y-m-d H:i:s") . "')");
        print_r($DB2);
    }
}