Exemple #1
0
 function basket_add()
 {
     $product = db()->query_fetch("SELECT id FROM " . db('shop_products') . " WHERE active = '1' AND " . (is_numeric($_GET["id"]) ? "id=" . intval($_GET["id"]) : "url='" . _es($_GET['id']) . "'"));
     if (!empty($product)) {
         $_GET['id'] = $product['id'];
     }
     $atts = module('shop')->_products_get_attributes($product["id"]);
     if ($_GET["id"]) {
         $_GET["id"] = intval($_GET["id"]);
         $_POST["quantity"][$_GET["id"]] = 1;
     }
     if (!empty($atts) && empty($_POST["atts"])) {
         module('shop')->_basket_is_processed = true;
         return js_redirect("./?object=shop&action=product_details&id=" . $_GET["id"]);
     }
     if (!empty($_POST["quantity"]) && !module('shop')->_basket_is_processed) {
         foreach ((array) $_POST["quantity"] as $_product_id => $_quantity) {
             $_product_id = intval($_product_id);
             $_old_quantity = (int) module('shop')->_basket_api()->get($_product_id, 'quantity');
             $_quantity = intval($_quantity) + intval($_old_quantity);
             if ($_product_id && $_quantity) {
                 module('shop')->_basket_api()->set($_product_id, ["product_id" => $_product_id, "quantity" => $_quantity, "atts" => $_POST["atts"][$_product_id]]);
             }
         }
         // Prevent double processing
         module('shop')->_basket_is_processed = true;
     }
     return js_redirect("./?object=shop");
 }
Exemple #2
0
 /**
  */
 function get_user_info()
 {
     $access_token = $this->_storage_get('access_token');
     if (!$access_token) {
         $access_token = $this->get_access_token();
         if (!$access_token) {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         }
     }
     if (!$this->_storage_get('user')) {
         $access_token_request = $this->_storage_get('access_token_request');
         $user_id = $access_token_request['result']['user_id'];
         $url = $this->url_user . '?' . http_build_query($this->url_params + ['access_token' => $access_token, 'user_id' => $user_id]);
         $result = common()->get_remote_page($url, $cache = false, $opts, $response);
         $result = $this->_decode_result($result, $response);
         if (isset($result['error']) || substr($response['http_code'], 0, 1) == '4') {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         } else {
             $this->_storage_set('user_info_request', ['result' => $result, 'response' => $response]);
             $this->_storage_set('user', $result);
         }
     }
     return $this->_storage_get('user');
 }
Exemple #3
0
 public function find($email)
 {
     $data = array('EMAIL' => rawurldecode($email));
     $return_content = http_post_data("http://itandroidbalance.miyigame.com/getbaseurl2.php", json_encode(array('email' => $email, 'platform' => 'xiaomi')));
     $return = json_decode($return_content, true);
     $baseurl = $return["baseurl"];
     $db_group_var = "db1";
     if ($baseurl == "itofdp4.miyigame.com:40002") {
         $db_group_var = "db1";
     } elseif ($baseurl == "itofdp5.miyigame.com:40003") {
         $db_group_var = "db2";
     } elseif ($baseurl == "itofdp6.miyigame.com:40004") {
         $db_group_var = "db3";
     }
     $this->session->set_tempdata('db_group', $db_group_var, 600);
     $this->load->model(array('User_data', 'Character_data', 'Skill_data', 'Treasure_data', 'Game_data', 'Item_data', 'Shop_data', 'Message_data'));
     $userRows = $this->User_data->selectUser($data);
     if (count($userRows) == 0) {
         js_alert_back('Empty no data.');
     } else {
         if (count($userRows) == 1) {
             js_redirect(site_url(array('user', 'view', $userRows[0]['USER_ID'])));
         } else {
             $data['USER_ROWS'] = $userRows;
             $this->viewer->all('user/find', $data);
         }
     }
 }
Exemple #4
0
 function editSubmit($p)
 {
     $f = UserDataField::get($p['id']);
     $f->name = $p['name'];
     $f->label = $p['label'];
     $f->type = $p['type'];
     $f->id = $f->store();
     switch ($f->type) {
         case UserDataField::RADIO:
             for ($i = 1; $i < 6; $i++) {
                 if (!empty($p['opt_' . $i])) {
                     UserDataFieldOption::set($f->id, 'opt_' . $i, $p['opt_' . $i]);
                 }
             }
             break;
         case UserDataField::AVATAR:
             for ($i = 1; $i < 6; $i++) {
                 if (!empty($p['avatar_' . $i])) {
                     if ($p['avatar_' . $i]['error'] == UPLOAD_ERR_NO_FILE) {
                         continue;
                     }
                     $fileId = File::importImage(SITE, $p['avatar_' . $i]);
                     UserDataFieldOption::set($f->id, 'avatar_' . $i, $fileId);
                 }
             }
             break;
     }
     js_redirect('a/userdata/list');
 }
 /**
  * Cleanup variables (Delete not translated or missed vars)
  */
 function cleanup_vars()
 {
     // TODO: move out into submodule
     // Find empty translations
     db()->query("DELETE FROM " . db('locale_translate') . " WHERE value=''");
     // Delete non-changed translations
     $Q = db()->query("SELECT * FROM " . db('locale_vars') . " AS v\n\t\t\t\t, " . db('locale_translate') . " AS t \n\t\t\tWHERE t.var_id=v.id \n\t\t\t\tAND (t.value=v.value OR t.value = '')");
     while ($A = db()->fetch_assoc($Q)) {
         // Do delete found records
         db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\t\tWHERE var_id=" . intval($A["id"]) . " \n\t\t\t\t\tAND locale='" . _es($A["locale"]) . "'");
     }
     // Special for the ignore case case
     if ($this->VARS_IGNORE_CASE) {
         // Delete non-changed translations
         $Q = db()->query("SELECT * FROM " . db('locale_vars') . " AS v\n\t\t\t\t\t, " . db('locale_translate') . " AS t \n\t\t\t\tWHERE t.var_id=v.id \n\t\t\t\t\tAND LOWER(REPLACE(CONVERT(t.value USING utf8), ' ', '_')) \n\t\t\t\t\t\t= LOWER(REPLACE(CONVERT(v.value USING utf8), ' ', '_'))");
         // Delete non-changed translations
         while ($A = db()->fetch_assoc($Q)) {
             db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\t\t\tWHERE var_id=" . intval($A["id"]) . " \n\t\t\t\t\t\tAND locale='" . _es($A["locale"]) . "'");
         }
         // Delete duplicated records
         $Q = db()->query("SELECT id FROM " . db('locale_vars') . "\n\t\t\t\tGROUP BY LOWER(REPLACE(CONVERT(value USING utf8), ' ', '_')) \n\t\t\t\tHAVING COUNT(*) > 1");
         while ($A = db()->fetch_assoc($Q)) {
             db()->query("DELETE FROM " . db('locale_vars') . " WHERE id=" . intval($A["id"]));
         }
     }
     // Delete translations without parents
     db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\tWHERE var_id NOT IN( \n\t\t\t\tSELECT id FROM " . db('locale_vars') . " \n\t\t\t)");
     // Delete parents without translations
     db()->query("DELETE FROM " . db('locale_vars') . " \n\t\t\tWHERE id NOT IN( \n\t\t\t\tSELECT var_id FROM " . db('locale_translate') . " \n\t\t\t)");
     // Return user back
     return js_redirect("./?object=" . $_GET["object"] . "&action=show_vars");
 }
 /**
  */
 function get_user_info()
 {
     $access_token = $this->_storage_get('access_token');
     if (!$access_token) {
         $access_token = $this->get_access_token();
         if (!$access_token) {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         }
     }
     if (!$this->_storage_get('user')) {
         $url = $this->url_user . '?' . http_build_query(['oauth2_access_token' => $access_token]);
         $opts['custom_header'][] = 'x-li-format: json';
         $result = common()->get_remote_page($url, $cache = false, $opts, $response);
         $result = $this->_decode_result($result, $response, __FUNCTION__);
         if (isset($result['error']) || substr($response['http_code'], 0, 1) == '4') {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         } else {
             $this->_storage_set('user_info_request', ['result' => $result, 'response' => $response]);
             $this->_storage_set('user', $result);
         }
     }
     return $this->_storage_get('user');
 }
Exemple #7
0
 function createHandler($p)
 {
     $o = new ChatRoom();
     $o->name = trim($p['name']);
     $o->id = $o->store();
     js_redirect('a/chatroom/list');
 }
 /**
  * Order step
  */
 function _order_step_do_payment($FORCE_DISPLAY_FORM = false)
 {
     $basket_contents = module('shop')->_basket_api()->get_all();
     if (module('shop')->FORCE_PAY_METHOD) {
         $_POST["pay_type"] = module('shop')->FORCE_PAY_METHOD;
     }
     // Show previous form if needed
     if (common()->_error_exists() || empty($_POST)) {
         return module('shop')->_order_step_select_payment();
     }
     $ORDER_ID = intval($_POST["order_id"] ? $_POST["order_id"] : module('shop')->_CUR_ORDER_ID);
     if (empty($ORDER_ID)) {
         _re("Missing order ID");
     }
     // Get order info
     $order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($ORDER_ID) . " AND user_id=" . intval(main()->USER_ID) . " AND status='pending'");
     if (empty($order_info["id"])) {
         _re("Missing order record");
     }
     // Payment by courier, skip next step
     if (!common()->_error_exists() && $_POST["pay_type"] == 1 or $_POST["pay_type"] == 3 or $_POST["pay_type"] == 4) {
         module('shop')->_basket_api()->clean();
         return js_redirect("./?object=shop&action=" . $_GET["action"] . "&id=finish&page=" . intval($ORDER_ID));
     }
     // Authorize.net payment type
     if ($_POST["pay_type"] == 2) {
         module('shop')->_basket_api()->clean();
         return module('shop')->_order_pay_authorize_net($order_info);
     }
 }
 /**
  */
 function get_user_info()
 {
     $access_token = $this->_storage_get('access_token');
     if (!$access_token) {
         $access_token = $this->get_access_token();
         if (!$access_token) {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         }
     }
     if (!$this->_storage_get('user')) {
         $method = 'users.getInfo';
         $sign = md5('app_id=' . $this->client_id . 'method=' . $method . 'secure=1' . 'session_key=' . $access_token . $this->client_public);
         $url = $this->url_user . '?' . http_build_query(['session_key' => $access_token, 'secure' => 1, 'app_id' => $this->client_id, 'method' => $method, 'sig' => $sign]);
         $result = common()->get_remote_page($url, $cache = false, $opts, $response);
         $result = $this->_decode_result($result, $response, __FUNCTION__);
         if (isset($result['error']) || substr($response['http_code'], 0, 1) == '4') {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         } else {
             $this->_storage_set('user_info_request', ['result' => $result, 'response' => $response]);
             $this->_storage_set('user', $result);
         }
     }
     return $this->_storage_get('user');
 }
 /**
  */
 function get_user_info()
 {
     $access_token = $this->_storage_get('access_token');
     if (!$access_token) {
         $access_token = $this->get_access_token();
         if (!$access_token) {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         }
     }
     if (!$this->_storage_get('user')) {
         $url = $this->url_user . '?' . http_build_query(['access_token' => $access_token]);
         $result = common()->get_remote_page($url, $cache = false, $opts, $response);
         $result = $this->_decode_result($result, $response, __FUNCTION__);
         if (isset($result['error']) || substr($response['http_code'], 0, 1) == '4') {
             $this->_storage_clean();
             js_redirect($this->redirect_uri, $url_rewrite = false);
             return false;
         } else {
             $this->_storage_set('user_info_request', ['result' => $result, 'response' => $response]);
             $user = $result;
             // Emails
             $url_emails = $this->url_user_emails . '?' . http_build_query(['access_token' => $access_token]);
             $result = common()->get_remote_page($url_emails, $cache = false, $opts = [], $response);
             $result = $this->_decode_result($result, $response, __FUNCTION__);
             $user['emails'] = $result;
             $this->_storage_set('user', $user);
         }
     }
     return $this->_storage_get('user');
 }
 /**
  */
 function category_mapping_delete()
 {
     $SUPPLIER_ID = module('manage_shop')->SUPPLIER_ID;
     $a = db()->get('SELECT * FROM ' . db('shop_suppliers_cat_aliases') . ' WHERE supplier_id=' . (int) $SUPPLIER_ID . ' AND cat_id=' . (int) $_GET['id']);
     if (!$a) {
         return _e('No such record');
     }
     db()->query('DELETE FROM ' . db('shop_suppliers_cat_aliases') . ' WHERE supplier_id=' . (int) $SUPPLIER_ID . ' AND cat_id=' . (int) $_GET['id'] . ' LIMIT 1');
     return js_redirect('./?object=' . main()->_get('object') . '&action=category_mapping');
 }
Exemple #12
0
 public function checkLevelRedirect($level)
 {
     if (!$this->CI->session->userdata('LEVEL')) {
         js_redirect(site_url(array('manager', 'login')));
     } else {
         if ($this->CI->session->userdata('LEVEL') < $level) {
             js_alert_back('Permission error!');
         }
     }
 }
Exemple #13
0
 function editHandler($p)
 {
     $session = SessionHandler::getInstance();
     $o = FaqItem::get($p['id']);
     $o->question = $p['q'];
     $o->answer = $p['a'];
     $o->creator = $session->id;
     $o->time_created = sql_datetime(time());
     $o->store();
     js_redirect('a/faq');
 }
Exemple #14
0
 /**
  */
 function add()
 {
     $a = [];
     $a['back_link'] = url('/@object');
     !$a['locale'] && ($a['locale'] = conf('language'));
     $_this = $this;
     return form((array) $_POST + (array) $a)->validate(['__before__' => 'trim', 'name' => 'required', 'text' => 'required', 'locale' => 'required'])->insert_if_ok(self::table, ['name', 'text', 'active', 'locale'])->on_after_update(function () use($_this) {
         $id = db()->insert_id();
         module_safe('manage_revisions')->add($_this::table, $id, 'add');
         js_redirect(url('/@object/edit/' . $id));
     })->text('name')->textarea('text', ['id' => 'text', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->locale_box('locale')->active_box()->save_and_back();
 }
Exemple #15
0
 function createHandler($p)
 {
     $session = SessionHandler::getInstance();
     $o = new BlogEntry();
     $o->owner = $session->id;
     $o->subject = trim($p['subject']);
     $o->body = trim($p['body']);
     $o->time_created = sql_datetime(time());
     $o->time_published = sql_datetime(time());
     $o->id = $o->store();
     js_redirect('a/blogs/overview');
 }
Exemple #16
0
function fbHandler($p)
{
    $session = SessionHandler::getInstance();
    $o = new Feedback();
    $o->type = USER;
    $o->subject = $p['subj'];
    $o->body = $p['body'];
    $o->from = $session->id;
    $o->time_created = sql_datetime(time());
    $o->store();
    js_redirect('');
    // jump to start page
}
Exemple #17
0
 /**
  */
 function change_debug()
 {
     if (!DEBUG_MODE) {
         return;
     }
     if (is_post()) {
         $_SESSION['debug_console_light'] = intval((bool) $_POST['debug_console_light']);
         $_SESSION['locale_vars_edit'] = intval((bool) $_POST['locale_edit']);
         #			$_SESSION['stpls_inline_edit']		= intval((bool)$_POST['stpl_edit']);
         return js_redirect($_SERVER['HTTP_REFERER'], 0);
     }
     $a = $_POST + $_SESSION;
     return form($a)->active_box('debug_console_light', ['selected' => $_SESSION['debug_console_light']])->active_box('locale_edit', ['selected' => $_SESSION['locale_vars_edit']])->save();
 }
 /**
  * Clean basket contents
  */
 function basket_clean()
 {
     $add_sql = "url='" . _es($_GET['id']);
     $sql = "SELECT * FROM " . db('shop_products') . " WHERE active='1' AND " . $add_sql . "'";
     $product_info = db()->query_fetch($sql);
     $_GET["id"] = $product_info["id"];
     if ($_GET["id"] && isset($basket[$_GET["id"]])) {
         module('shop')->_basket_api()->del($_GET["id"]);
     }
     if (!$_GET["id"] && isset($basket)) {
         module('shop')->_basket_api()->clean();
     }
     return js_redirect($_SERVER["HTTP_REFERER"], false);
 }
 /**
  * Automatic translator via Google translate
  */
 function autotranslate()
 {
     if ($_POST['translate'] && $_POST['locale']) {
         set_time_limit(1800);
         $LOCALE_RES = $_POST['locale'];
         $base_url = 'http://ajax.googleapis.com/ajax/services/language/translate' . '?v=1.0';
         $vars = db()->query_fetch_all("SELECT id,value FROM " . db('locale_vars') . " WHERE id NOT IN( \n\t\t\t\t\tSELECT var_id FROM " . db('locale_translate') . " \n\t\t\t\t\tWHERE locale = '" . $LOCALE_RES . "' AND value != '' \n\t\t\t\t)");
         $_info = [];
         $max_threads = 4;
         $buffer = [];
         $translated = [];
         _debug_log("LOCALE_NUM_VARS: " . count($vars));
         foreach ((array) $vars as $A) {
             $translated = [];
             $url = $base_url . "&q=" . urlencode(str_replace("_", " ", $A["value"])) . "&langpair=en%7C" . $LOCALE_RES;
             $_temp[$url] = $A["id"];
             if (count($buffer) < $max_threads) {
                 $buffer[$url] = $url;
                 continue;
             }
             foreach ((array) common()->multi_request($buffer) as $url => $response) {
                 $response_array = json_decode($response);
                 $response_text = trim($response_array->responseData->translatedText);
                 $ID = $_temp[$url];
                 $source = str_replace("_", " ", $vars[$ID]["value"]);
                 _debug_log("LOCALE: " . ++$j . " ## " . $ID . " ## " . $source . " ## " . $response_text . " ## " . $url);
                 if (_strlen($response_text) && $response_text != $source) {
                     $translated[$ID] = $response_text;
                 }
             }
             if ($translated) {
                 $Q = db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\t\t\t\tWHERE locale = '" . _es($LOCALE_RES) . "' \n\t\t\t\t\t\t\tAND var_id IN(" . implode(",", array_keys($translated)) . ")");
             }
             foreach ((array) $translated as $_id => $_value) {
                 db()->REPLACE('locale_translate', ['var_id' => intval($_id), 'value' => _es($_value), 'locale' => _es($LOCALE_RES)]);
             }
             $buffer = [];
             $_temp = [];
         }
         cache_del('locale_translate_' . $LOCALE_RES);
         return js_redirect('./?object=' . $_GET['object']);
     }
     $Q = db()->query('SELECT * FROM ' . db('locale_langs') . ' ORDER BY name');
     while ($A = db()->fetch_assoc($Q)) {
         $locales[$A['locale']] = $A['name'];
     }
     $replace = ['locale_box' => common()->select_box('locale', $locales), 'locale_editor_url' => './?object=locale_editor', 'form_action' => './?object=' . $_GET['object'] . '&action=' . $_GET['action']];
     return tpl()->parse($_GET['object'] . '/autotranslate', $replace);
 }
Exemple #20
0
 public function find($keyword)
 {
     $data = array('NICKNAME' => rawurldecode($keyword));
     $userRows = $this->User_data->selectUser($data);
     if (count($userRows) == 0) {
         js_alert_back('Empty no data.');
     } else {
         if (count($userRows) == 1) {
             js_redirect(site_url(array('user', 'view', $userRows[0]['USER_ID'])));
         } else {
             $data['USER_ROWS'] = $userRows;
             $this->viewer->all('user/find', $data);
         }
     }
 }
Exemple #21
0
 /**
  */
 function filter_save()
 {
     $filter_name = $_GET['object'] . '__view';
     if ($_GET['page'] == 'clear') {
         $_SESSION[$filter_name] = [];
     } else {
         $_SESSION[$filter_name] = $_POST;
         foreach (explode('|', 'clear_url|form_id|submit') as $f) {
             if (isset($_SESSION[$filter_name][$f])) {
                 unset($_SESSION[$filter_name][$f]);
             }
         }
     }
     return js_redirect('./?object=' . $_GET['object'] . '&action=' . str_replace($_GET['object'] . '__', '', $filter_name));
 }
Exemple #22
0
 function order()
 {
     $_avail_steps = ["start", "delivery", "select_payment", "do_payment", "finish"];
     $step = $_GET["id"];
     if (!$step || !in_array($step, $_avail_steps)) {
         $step = "start";
     }
     // Prevent ordering with empty shopping basket
     $basket_contents = module('shop')->_basket_api()->get_all();
     if (empty($basket_contents) && in_array($step, ["start", "delivery", "select_payment"])) {
         return js_redirect("./?object=shop");
     }
     $func = "_order_step_" . $step;
     return module("shop")->{$func}();
 }
Exemple #23
0
 /**
  */
 function active()
 {
     $_GET['id'] = intval($_GET['id']);
     if (!empty($_GET['id'])) {
         $a = db()->query_fetch('SELECT * FROM ' . db('comments') . ' WHERE id=' . intval($_GET['id']));
     }
     if (!empty($a)) {
         db()->update('comments', ['active' => (int) (!$a['active'])], 'id=' . intval($_GET['id']));
     }
     if (is_ajax()) {
         main()->NO_GRAPHICS = true;
         echo $a['active'] ? 0 : 1;
     } else {
         return js_redirect('./?object=' . $_GET['object']);
     }
 }
Exemple #24
0
 /**
  * Change current user language
  */
 function change_lang()
 {
     if (!$this->_parent->ALLOW_LANG_CHANGE) {
         return _e('Changing language not allowed!');
     }
     $new_lang = _prepare_html($_REQUEST['lang_id']);
     if (!empty($new_lang) && conf('languages::' . $new_lang . '::active')) {
         $_SESSION['user_lang'] = $new_lang;
         $old_location = './?object=account';
         if (!empty($_POST['back_url'])) {
             $old_location = str_replace(WEB_PATH, './', $_POST['back_url']);
         }
         return js_redirect($old_location);
     }
     return js_redirect($_SERVER['HTTP_REFERER']);
 }
 function filter_save()
 {
     $filter_name = $_GET['object'];
     if ($_GET['page'] == 'clear') {
         $_SESSION[$filter_name] = [];
     } else {
         $_SESSION[$filter_name] = $_POST;
         foreach (explode('|', 'clear_url|form_id|submit') as $f) {
             if (isset($_SESSION[$filter_name][$f])) {
                 unset($_SESSION[$filter_name][$f]);
             }
         }
     }
     $redirect_url = "./?object=" . $_GET['object'];
     return js_redirect($redirect_url);
 }
Exemple #26
0
 /**
  * view orders
  */
 function _order_view()
 {
     if ($_POST["order_id"]) {
         $_GET["id"] = intval($_POST["order_id"]);
     } else {
         $_GET["id"] = intval($_GET["id"]);
     }
     if ($_GET["id"]) {
         $order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($_GET["id"]));
     }
     if (empty($order_info)) {
         return _e("No such order");
     }
     if (!empty($_POST["status"])) {
         db()->UPDATE(db('shop_orders'), ["status" => _es($_POST["status"])], "id=" . intval($_GET["id"]));
         return js_redirect("./?object=shop&action=orders");
     }
     $products_ids = [];
     $Q = db()->query("SELECT * FROM " . db('shop_order_items') . " WHERE `order_id`=" . intval($order_info["id"]));
     while ($_info = db()->fetch_assoc($Q)) {
         if ($_info["product_id"]) {
             $products_ids[$_info["product_id"]] = $_info["product_id"];
         }
         $order_items[$_info["product_id"]] = $_info;
     }
     if (!empty($products_ids)) {
         $products_infos = db()->query_fetch_all("SELECT * FROM " . db('shop_products') . " WHERE id IN(" . implode(",", $products_ids) . ") AND active='1'");
         $products_atts = module('shop')->_products_get_attributes($products_ids);
     }
     foreach ((array) $order_items as $_info) {
         $_product = $products_infos[$_info["product_id"]];
         $dynamic_atts = [];
         if (strlen($_info["attributes"]) > 3) {
             foreach ((array) unserialize($_info["attributes"]) as $_attr_id) {
                 $_attr_info = $products_atts[$_info["product_id"]][$_attr_id];
                 $dynamic_atts[$_attr_id] = "- " . $_attr_info["name"] . " " . $_attr_info["value"];
                 $price += $_attr_info["price"];
             }
         }
         $products[$_info["product_id"]] = ["name" => _prepare_html($_product["name"]), "price" => module('shop')->_format_price($_info["sum"]), "currency" => _prepare_html(module('shop')->CURRENCY), "quantity" => intval($_info["quantity"]), "details_link" => process_url("./?object=shop&action=view&id=" . $_product["id"]), "dynamic_atts" => !empty($dynamic_atts) ? implode("\n<br />", $dynamic_atts) : ""];
         $total_price += $_info["price"] * $quantity;
     }
     $total_price = $order_info["total_sum"];
     $replace = my_array_merge($replace, _prepare_html($order_info));
     $replace = my_array_merge($replace, ["form_action" => "./?object=shop&action=" . $_GET["action"] . "&id=" . $_GET["id"], "order_id" => $order_info["id"], "total_sum" => module('shop')->_format_price($order_info["total_sum"]), "user_link" => _profile_link($order_info["user_id"]), "user_name" => _display_name(user($order_info["user_id"])), "error_message" => _e(), "products" => (array) $products, "total_price" => module('shop')->_format_price($total_price), "ship_type" => module('shop')->_ship_type[$order_info["ship_type"]], "pay_type" => module('shop')->_pay_types[$order_info["pay_type"]], "date" => _format_date($order_info["date"], "long"), "status_box" => module('shop')->_statuses[$order_info["status"]], "back_url" => "./?object=shop&action=orders"]);
     return tpl()->parse("shop/order_view", $replace);
 }
Exemple #27
0
 public function balance($options)
 {
     if (empty(main()->USER_ID)) {
         js_redirect('/login_form', false, 'User id empty');
     }
     $payment_api = _class('payment_api');
     list($account_id, $account) = $payment_api->get_account();
     list($currency_id, $currency) = $payment_api->get_currency__by_id($account);
     list($operation, $count) = $payment_api->operation($account);
     $page_per = $payment_api->OPERATION_LIMIT;
     $pages = ceil($count / $page_per);
     // limit
     $balance_limit_lower = $payment_api->BALANCE_LIMIT_LOWER;
     $payout_limit_min = @$payment_api->PAYOUT_LIMIT_MIN ?: 1;
     // provider
     $providers = $payment_api->provider(['all' => true]);
     $payment_api->provider_options($providers, ['IS_DEPOSITION', 'IS_PAYMENT', 'method_allow', 'fee', 'currency_allow', 'description']);
     $provider_user = $payment_api->provider();
     $provider = [];
     foreach ($provider_user as &$item) {
         $provider_id = (int) $item['provider_id'];
         $_provider =& $providers[$provider_id];
         $_provider['_IS_DEPOSITION'] && ($provider['payin'][] = $provider_id);
         $_provider['_IS_PAYMENT'] && ($provider['payout'][] = $provider_id);
     }
     // user
     $user = user(main()->USER_ID);
     // misc
     $status = $payment_api->status();
     $currencies = $payment_api->currencies;
     $currency_rate = $payment_api->currency_rates__buy();
     $payout_currency_allow = $payment_api->payout_currency_allow;
     // transition
     $payment_module = $this->payment_module;
     $payment_module->t($currency, 'currency');
     $payment_module->t($currencies, 'currency');
     $payment_module->t($operation);
     $payment_module->t($providers);
     $payment_module->t($status);
     // tpl
     $replace = ['user' => $user, 'payment' => json_encode(['balance_limit_lower' => $balance_limit_lower, 'payout_limit_min' => $payout_limit_min, 'user' => $user, 'account' => $account, 'currency' => $currency, 'currencies' => $currencies, 'currency_rate' => $currency_rate, 'payout_currency_allow' => $payout_currency_allow, 'operation' => $operation, 'provider' => $provider, 'providers' => $providers, 'status' => $status, 'operation_pagination' => ['count' => $count, 'page_per' => $page_per, 'pages' => $pages, 'page' => 1]])];
     // tpl
     $result = '';
     $result .= tpl()->parse('payment/user/balance_ctrl', $replace);
     $result .= tpl()->parse('payment/user/balance_form', $replace);
     return $result;
 }
 /**
  */
 function unit_delete()
 {
     $_GET['id'] = intval($_GET['id']);
     if (!empty($_GET['id'])) {
         $info = db()->query_fetch('SELECT * FROM ' . db('shop_product_units') . ' WHERE id=' . intval($_GET['id']));
     }
     if (!empty($info['id'])) {
         db()->query('DELETE FROM ' . db('shop_product_units') . ' WHERE id=' . intval($_GET['id']) . ' LIMIT 1');
         common()->admin_wall_add(['shop product unit deleted: ' . $info['name'], $_GET['id']]);
     }
     if ($_POST['ajax_mode']) {
         main()->NO_GRAPHICS = true;
         echo $_GET['id'];
     } else {
         return js_redirect('./?object=' . main()->_get('object') . '&action=units');
     }
 }
Exemple #29
0
 /**
  */
 function active()
 {
     $id = intval($_GET['id']);
     if (!empty($id)) {
         $a = db()->from('admin')->whereid($id)->get();
     }
     if (!empty($a['id']) && $id != 1 && $id != main()->ADMIN_ID) {
         db()->update_safe('admin', ['active' => (int) (!$a['active'])], $id);
         common()->admin_wall_add(['admin account ' . ($a['active'] ? 'inactivated' : 'activated'), $id]);
     }
     if (is_ajax()) {
         no_graphics(true);
         echo (int) (!$a['active']);
     } else {
         return js_redirect(url('/@object'));
     }
 }
Exemple #30
0
 /**
  */
 function active()
 {
     $_GET['id'] = intval($_GET['id']);
     if (!empty($_GET['id'])) {
         $group_info = db()->query_fetch('SELECT * FROM ' . db('user_groups') . ' WHERE id=' . intval($_GET['id']));
     }
     if (!empty($group_info)) {
         db()->UPDATE('user_groups', ['active' => intval(!$group_info['active'])], 'id=' . intval($_GET['id']));
         common()->admin_wall_add(['user group: ' . $group_info['name'] . ' ' . ($group_info['active'] ? 'inactivated' : 'activated'), $group_info['id']]);
     }
     cache_del(['user_groups', 'user_groups_details']);
     if (is_ajax()) {
         no_graphics(true);
         echo $group_info['active'] ? 0 : 1;
     } else {
         return js_redirect(url('/@object'));
     }
 }