/** * Reverse IP filter */ function fn_settings_actions_addons_access_restrictions_admin_reverse_ip_access(&$new_value, $old_value) { $ip = fn_get_ip(true); if ($new_value == 'Y') { $ip_data = db_get_row("SELECT item_id, status FROM ?:access_restriction WHERE ip_from = ?i AND ip_to = ?i AND type IN ('aas', 'aab', 'aar')", $ip['host'], $ip['host']); if (empty($ip_data) || empty($ip_data['item_id'])) { // Add IP $restrict_ip = array('ip_from' => $ip['host'], 'ip_to' => $ip['host'], 'type' => 'aas', 'timestamp' => TIME, 'expires' => '0', 'status' => 'A'); $__data = array(); $__data['item_id'] = db_query("REPLACE INTO ?:access_restriction ?e", $restrict_ip); $__data['type'] = 'aas'; foreach (fn_get_translation_languages() as $__data['lang_code'] => $_v) { $__data['reason'] = __('store_admin', '', $__data['lang_code']); db_query("REPLACE INTO ?:access_restriction_reason_descriptions ?e", $__data); } fn_set_notification('W', __('warning'), __('your_ip_added', array('[ip]' => long2ip($ip['host'])))); } elseif (empty($ip_data['status']) || $ip_data['status'] != 'A') { // Change IP status to available db_query("UPDATE ?:access_restriction SET ?u WHERE item_id = ?i", array('status' => 'A'), $ip_data['item_id']); fn_set_notification('W', __('warning'), __('your_ip_enabled', array('[ip]' => long2ip($ip['host'])))); } } else { // Delete IP $ips_data = db_get_array("SELECT item_id, type FROM ?:access_restriction WHERE ip_from <= ?i AND ip_to >= ?i AND type IN ('aas', 'aab', 'aar')", $ip['host'], $ip['host']); if (!empty($ips_data)) { foreach ($ips_data as $ip_data) { db_query("DELETE FROM ?:access_restriction WHERE item_id = ?i", $ip_data['item_id']); db_query("DELETE FROM ?:access_restriction_reason_descriptions WHERE item_id = ?i AND type = ?s", $ip_data['item_id'], $ip_data['type']); } fn_set_notification('W', __('warning'), __('your_ip_removed', array('[ip]' => long2ip($ip['host'])))); } } return true; }
public static function init($reinit = false, $config = array()) { self::$active_debug_mode = false; self::$allow_backtrace_sql = isset($_REQUEST['sql_backtrace']); self::$debugger_cookie = !empty($_COOKIE['debugger']) ? $_COOKIE['debugger'] : ''; if ($reinit) { Registry::registerCache('debugger', SESSION_ALIVE_TIME, Registry::cacheLevel('time'), true); self::$actives = fn_get_storage_data('debugger_active'); self::$actives = !empty(self::$actives) ? unserialize(self::$actives) : array(); $active_in_registry = !empty(self::$actives[self::$debugger_cookie]) && time() - self::$actives[self::$debugger_cookie] < 0 ? true : false; } $debugger_token = !empty($config) ? $config['debugger_token'] : Registry::get('config.debugger_token'); switch (true) { case defined('AJAX_REQUEST') && substr($_REQUEST['dispatch'], 0, 8) !== 'debugger': break; case defined('DEBUG_MODE') && DEBUG_MODE == true: case !$reinit && (!empty(self::$debugger_cookie) || isset($_REQUEST[$debugger_token])): self::$active_debug_mode = true; break; case !$reinit: break; // next if reinit // next if reinit case !empty(self::$debugger_cookie) && !empty($active_in_registry): self::$active_debug_mode = true; break; case isset($_REQUEST[$debugger_token]): $salt = ''; if ($_SESSION['auth']['user_type'] == 'A' && $_SESSION['auth']['is_root'] == 'Y') { $user_admin = db_get_row('SELECT email, password FROM ?:users WHERE user_id = ?i', $_SESSION['auth']['user_id']); $salt = $user_admin['email'] . $user_admin['password']; } if ($debugger_token != self::DEFAULT_TOKEN || !empty($salt)) { // for non-default token allow full access self::$debugger_cookie = substr(md5(SESSION::getId() . $salt), 0, 8); $active_in_registry = true; self::$active_debug_mode = true; } if (AREA == 'C' && !empty($_REQUEST[$debugger_token])) { if (!empty(self::$actives[$_REQUEST[$debugger_token]]) && time() - self::$actives[$_REQUEST[$debugger_token]] < 0) { $active_in_registry = true; self::$debugger_cookie = $_REQUEST[$debugger_token]; self::$active_debug_mode = true; } } fn_set_cookie('debugger', self::$debugger_cookie, SESSION_ALIVE_TIME); break; } if ($reinit && self::$active_debug_mode && !empty(self::$debugger_cookie)) { self::$actives[self::$debugger_cookie] = time() + self::EXPIRE_DEBUGGER; fn_set_storage_data('debugger_active', serialize(self::$actives)); $active_in_registry = true; } if ($reinit && !empty(self::$debugger_cookie) && empty($active_in_registry)) { fn_set_cookie('debugger', '', 0); unset(self::$actives[self::$debugger_cookie]); fn_set_storage_data('debugger_active', serialize(self::$actives)); } return self::$active_debug_mode; }
function fn_reward_points_get_cart_product_data($product_id, &$_pdata, $product) { $_pdata = fn_array_merge($_pdata, db_get_row("SELECT is_pbp, is_oper, is_op FROM ?:products WHERE product_id = ?i", $product_id)); if (isset($product['extra']['configuration'])) { $_pdata['extra']['configuration'] = $product['extra']['configuration']; } }
function fn_api_auth_routines($request, $auth) { $status = true; $user_login = !empty($request['user_login']) ? trim($request['user_login']) : ''; $password = !empty($request['password']) ? $request['password'] : ''; $field = 'email'; $condition = ''; if (fn_allowed_for('ULTIMATE')) { if (Registry::get('settings.Stores.share_users') == 'N' && AREA != 'A') { $condition = fn_get_company_condition('?:users.company_id'); } } $user_data = db_get_row("SELECT * FROM ?:users WHERE {$field} = ?s" . $condition, $user_login); if (empty($user_data)) { $user_data = db_get_row("SELECT * FROM ?:users WHERE {$field} = ?s AND user_type IN ('A', 'V', 'P')", $user_login); } if (!empty($user_data)) { $user_data['usergroups'] = fn_get_user_usergroups($user_data['user_id']); } if (!empty($user_data['status']) && $user_data['status'] == 'D') { fn_set_notification('E', __('error'), __('error_account_disabled')); $status = false; } $salt = isset($user_data['salt']) ? $user_data['salt'] : ''; return array($status, $user_data, $user_login, $password, $salt); }
function execute($requests) { $u = $GLOBALS['AUTH']->uid(); $sessid = session_id(); $sql = 'SELECT c_member_id, nickname FROM c_member WHERE c_member_id <> ?'; $params = array($u); $members = db_get_all($sql, $params); $sql = 'SELECT c_member_id, nickname FROM c_member WHERE c_member_id = ?'; $params = array($u); $my_info = db_get_row($sql, $params); array_unshift($members, $my_info); $id = $requests['target_id']; $group = biz_getGroupData($id); if ($u != $group['admin_id']) { die('アクセスできません。'); } foreach ($members as $key => $value) { if (biz_isGroupMember($value['c_member_id'], $id)) { $members[$key]['joined'] = true; } else { $members[$key]['joined'] = false; } } $this->set('inc_navi', fetch_inc_navi('h')); $this->set("c_invite_list", $members); $this->set("group", $group); $this->set("c_member_id", $u); return 'success'; }
function fn_age_verification_category_check($category_id) { if (!empty($_SESSION['auth']['age'])) { $age = $_SESSION['auth']['age']; } else { $age = 0; } while ($category_id) { $data = db_get_row("SELECT category_id, parent_id, age_verification, age_limit FROM ?:categories WHERE category_id = ?i", $category_id); if (empty($data)) { return array(false, 0); } if ($data['age_verification'] == 'Y') { if (!$age) { return array('form', $data['category_id']); } else { if ($age < $data['age_limit']) { return array('deny', $data['category_id']); } } } $category_id = $data['parent_id']; } return array(false, 0); }
function db_get_field($sql, $field) { $row = db_get_row($sql); if (count($row) > 0) { return $row[0][$field]; } return ""; }
function fn_exim_get_user_info($email) { if (!empty($email)) { $user = db_get_row("SELECT company_id, is_root FROM ?:users WHERE email = ?s", $email); } else { $user = false; } return $user; }
function getProductImage($product_id) { $image_path = db_get_row("SELECT image_path FROM cscart_images WHERE image_id = (SELECT detailed_id FROM cscart_images_links WHERE object_type='product' AND type='M' AND object_id='{$product_id}')"); //return Storage::instance('images')->getAbsolutePath($image_path['image_path']); if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/images/detailed/0/' . $image_path['image_path'])) { return 'http://' . $_SERVER['SERVER_NAME'] . '/images/detailed/0/' . $image_path['image_path']; } return 'http://' . $_SERVER['SERVER_NAME'] . '/images/detailed/1/' . $image_path['image_path']; }
function fn_get_banner_data($banner_id, $lang_code = CART_LANGUAGE) { $status_condition = AREA == 'A' ? '' : " AND ?:banners.status IN ('A', 'H') "; $banner = db_get_row("SELECT ?:banners.banner_id, ?:banners.status, ?:banners.url, ?:banner_descriptions.banner, ?:banners.type, ?:banners.target, ?:banners.localization, ?:banners.timestamp, ?:banner_descriptions.description FROM ?:banners LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s WHERE ?:banners.banner_id = ?i ?p", $lang_code, $banner_id, $status_condition); if (!empty($banner)) { $banner['main_pair'] = fn_get_image_pairs($banner['banner_id'], 'banner', 'M', true, false, $lang_code); } return $banner; }
function fn_get_postcode_location($postcode_location_id, $lang_code = CART_LANGUAGE) { $fields = array('?:postcode_locations.*', '?:postcode_location_descriptions.*', '?:country_descriptions.country as country_title'); $join = db_quote(" LEFT JOIN ?:postcode_location_descriptions ON ?:postcode_locations.postcode_location_id = ?:postcode_location_descriptions.postcode_location_id AND ?:postcode_location_descriptions.lang_code = ?s", $lang_code); $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:postcode_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code); $condition = db_quote(" ?:postcode_locations.postcode_location_id = ?i ", $postcode_location_id); $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:postcode_locations.localization') : ''; $postcode_location = db_get_row('SELECT ?p FROM ?:postcode_locations ?p WHERE ?p', implode(', ', $fields), $join, $condition); return $postcode_location; }
protected function _processProfileFields() { $fields = array('profile_show', 'checkout_show', 'partner_show'); $billing = db_get_row("SELECT " . implode(', ', $fields) . " FROM ?:profile_fields WHERE field_name = 'email' AND section = 'B'"); $shipping = array(); foreach ($fields as $field) { $shipping[$field] = $billing[$field] == 'Y' ? 'N' : 'Y'; } return db_query("UPDATE ?:profile_fields SET ?u WHERE field_name = 'email' AND section = 'S'", $shipping); }
/** * 認証後のみ表示されるバナーかどうかをバナーIDから確認 * * @param int $c_banner_id * @return bool */ function db_banner_is_after_auth_banner($c_banner_id) { $sql = 'SELECT is_hidden_before, is_hidden_after FROM c_banner WHERE c_banner_id = ?'; $params = array($c_banner_id); $c_banner = db_get_row($sql, $params); if ($c_banner['is_hidden_before'] && !$c_banner['is_hidden_after']) { return true; } else { return false; } }
function getProductImage($product_id) { $image_path = db_get_row("SELECT image_path FROM cscart_images WHERE image_id = (SELECT detailed_id FROM cscart_images_links WHERE object_type='product' AND type='M' AND object_id='{$product_id}')"); if (!$image_path['image_path']) { return $this->http . '/images/no_image.gif'; } if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/images/detailed/0/' . $image_path['image_path'])) { return $this->http . '/images/detailed/0/' . $image_path['image_path']; } return $this->http . '/images/detailed/1/' . $image_path['image_path']; }
function fn_get_store_location($store_location_id, $lang_code = CART_LANGUAGE) { $fields = array('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title'); $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", $lang_code); $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code); $condition = db_quote(" ?:store_locations.store_location_id = ?i ", $store_location_id); $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:store_locations.localization') : ''; $store_location = db_get_row('SELECT ?p FROM ?:store_locations ?p WHERE ?p', implode(', ', $fields), $join, $condition); $store_location["image_pairs"] = fn_get_image_pairs($store_location_id, 'store_locations', 'M', true, true, $lang_code); $store_location["additional_image_pairs"] = fn_get_image_pairs($store_location_id, 'store_locations', 'A', true, true, $lang_code); return $store_location; }
public function getDefault($theme_name = '') { $condition = ''; if (empty($theme_name)) { $theme_name = Settings::instance()->getValue('theme_name', ''); } if (fn_allowed_for('ULTIMATE')) { $condition = $this->getCompanyCondition('?:bm_layouts.company_id'); } $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name); $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition); return $layout; }
function rollback() { $id = $_GET['id']; $sql = "select vhost.name,backup.filename from backup join vhost on backup.pid=vhost.id where backup.id={$id}"; $backup = db_get_row($sql); $name = $backup['name']; $filename = $backup['filename']; system("tar xvf {$filename} -C /www/backup/"); //解压备份文件 system("cp -rf /www/backup/{$name} /var/www"); //拷贝到部署目录 system("rm -rf /www/backup/{$name}"); }
function fn_get_found_locations($postcode) { if (!empty($postcode)) { $data = db_get_row("SELECT * FROM ?:restricted_location_descriptions WHERE description = ?i", $postcode); $result = "" . $data['name'] . ", " . $data['city'] . ""; if (!empty($data)) { return "2"; } else { return "1"; } } return false; }
function fn_check_order_existence(&$primary_object_id, &$object, &$pattern, &$options, &$processed_data, &$processing_groups, &$skip_record) { $result = false; if ($object['order_id']) { $order_data = db_get_row("SELECT order_id, company_id FROM ?:orders WHERE order_id = ?i", $object['order_id']); if (!empty($order_data) && (Registry::get('runtime.simple_ultimate') || !Registry::get('runtime.simple_ultimate') && (Registry::get('runtime.company_id') == $order_data['company_id'] || Registry::get('runtime.company_id') === 0))) { $result = true; } } if (!$result) { $skip_record = true; $processed_data['S']++; } }
/** * Read session data * * @param string $sess_id session ID * * @return mixed session data if exist, false otherwise */ public function read($sess_id) { $session = db_get_row('SELECT * FROM ?:sessions WHERE session_id = ?s', $sess_id); if (!empty($session)) { if ($session['expiry'] > TIME) { return $session['data']; } else { // the session did not have time to get in "stored_sessions" and got out of date, it is necessary to return only settings db_query('DELETE FROM ?:sessions WHERE session_id = ?s', $sess_id); $session = Session::decode($session['data']); return Session::encode(array('settings' => !empty($session['settings']) ? $session['settings'] : array())); } } return false; }
/** * generate CheckOut from Planning Orders * * @param int order_id * @return int count of CheckOuts generated */ function JKY_generate_checkout($the_id) { $db = Zend_Registry::get('db'); $sql = 'SELECT *' . ' FROM Orders' . ' WHERE id = ' . $the_id; $my_order = $db->fetchRow($sql); $sql = 'SELECT *' . ' FROM OrdThreads' . ' WHERE parent_id = ' . $the_id; $my_rows = $db->fetchAll($sql); /* $my_needed_at = $my_order['needed_at']; if ($my_needed_at == null) { $my_needed_at = get_time(); } */ $my_checkout_id = get_next_id('CheckOuts'); $sql = 'INSERT CheckOuts' . ' SET id =' . $my_checkout_id . ', updated_by =' . get_session('user_id') . ', updated_at ="' . get_time() . '"' . ', number =' . $my_checkout_id . ', requested_at ="' . get_time() . '"' . ', requested_weight =' . $my_order['ordered_weight']; if ($my_order['machine_id']) { $sql .= ', machine_id=' . $my_order['machine_id']; } if ($my_order['partner_id']) { $sql .= ', partner_id=' . $my_order['partner_id']; } log_sql('CheckOuts', 'INSERT', $sql); $db->query($sql); insert_changes($db, 'CheckOuts', $my_checkout_id); $my_count = 0; foreach ($my_rows as $my_row) { $my_ord_thread_id = $my_row['id']; $my_batch = db_get_row('Batches', 'id=' . $my_row['batchin_id']); $my_ordered_weight = $my_row['ordered_weight']; $my_ordered_boxes = ceil((double) $my_ordered_weight / (double) $my_batch['average_weight']); $my_batchout_id = get_next_id('BatchOuts'); $sql = 'INSERT BatchOuts' . ' SET id =' . $my_batchout_id . ', updated_by =' . get_session('user_id') . ', updated_at ="' . get_time() . '"' . ', checkout_id =' . $my_checkout_id . ', thread_id =' . $my_row['thread_id'] . ', batchin_id =' . $my_row['batchin_id'] . ', order_thread_id =' . $my_ord_thread_id . ', batch ="' . $my_batch['batch'] . '"' . ', unit_price =' . $my_batch['unit_price'] . ', average_weight =' . $my_batch['average_weight'] . ', requested_weight =' . $my_ordered_weight . ', requested_boxes =' . $my_ordered_boxes; log_sql('BatchOuts', 'INSERT', $sql); $db->query($sql); insert_changes($db, 'BatchOuts', $my_batchout_id); $sql = 'UPDATE OrdThreads' . ' SET batchout_id = ' . $my_batchout_id . ' WHERE id = ' . $my_ord_thread_id; log_sql('OrdThreads', 'UPDATE', $sql); $db->query($sql); insert_changes($db, 'OrdThreads', $my_ord_thread_id); $my_count++; } $sql = 'UPDATE Orders' . ' SET status = "Active"' . ' WHERE id = ' . $the_id; log_sql('Orders', 'UPDATE', $sql); $db->query($sql); insert_changes($db, 'Orders', $the_id); return $my_count; }
static function get($name, $cache_level = NULL) { $fname = $name . '.' . $cache_level; Registry::set('runtime.database.skip_cache', true); $expiry_condition = $cache_level == CACHE_LEVEL_TIME ? db_quote(" AND expiry > ?i", TIME) : ''; $res = db_get_row("SELECT data, expiry FROM ?:cache WHERE name = ?s ?p", $fname, $expiry_condition); Registry::set('runtime.database.skip_cache', false); if (!empty($name) && !empty($res)) { $_cache_data = !empty($res['data']) ? @unserialize($res['data']) : false; if ($_cache_data !== false) { return array($_cache_data); } // clean up the cache db_query("DELETE FROM ?:cache WHERE name = ?s", $fname); } return false; }
/** * Gets grid data by id * @static * @param int $grid_id Grid identifier * @param string $lang_code 2 letter language code * @return array Grid data */ public static function getById($grid_id, $lang_code = CART_LANGUAGE) { /** * Prepares params for SQL query before getting grid * @param int $grid_id Grid identifier * @param string $lang_code 2 letter language code */ fn_set_hook('get_grid_pre', $grid_id, $lang_code); $grid = db_get_row('SELECT * FROM ?:bm_grids WHERE grid_id = ?i ORDER BY ?:bm_grids.order', $grid_id); /** * Processes grid data after getting it * @param array $grid Array of grid data * @param string $lang_code 2 letter language code */ fn_set_hook('get_grid_post', $grid, $lang_code); return $grid; }
public static final function updateIconsByApiData($image, $object_id = 0, $object_type = 'product', $lang_code = CART_LANGUAGE) { if (!empty($image['deleted']) && $image['deleted'] == 'Y') { // delete image $image_info = db_get_row("SELECT image_id, pair_id\n FROM ?:images_links\n WHERE object_id = ?i\n AND object_type=?s AND type = 'M'", $object_id, $object_type); if (!empty($image_info)) { fn_delete_image($image_info['image_id'], $image_info['pair_id'], $object_type); } return true; } $icon_list = array(); if ($icon = self::fn_twg_get_image_by_api_data($image)) { $icon_list[] = $icon; } $detailed_alt = db_get_field("SELECT a.description\n FROM ?:common_descriptions as a, ?:images_links as b\n WHERE a.object_holder = ?s\n AND a.lang_code = ?s\n AND a.object_id = b.detailed_id\n AND b.object_id = ?i\n AND b.object_type = ?s\n AND b.type = ?s", 'images', $lang_code, $object_id, $object_type, 'M'); $icon_data = array('type' => 'M', 'image_alt' => !empty($image['alt']) ? $image['alt'] : '', 'detailed_alt' => $detailed_alt); return fn_update_image_pairs($icon_list, array(), array($icon_data), $object_id, $object_type, array(), '', 0, true, $lang_code); }
function fn_get_banners_detailed_stats($params) { $condition = ''; $params['page'] = empty($params['page']) ? 1 : $params['page']; list($params['time_from'], $params['time_to']) = fn_create_periods($params); $constraints = db_get_row("SELECT MIN(timestamp) as min, MAX(timestamp) as max FROM ?:stat_banners_log WHERE banner_id = ?i", $params['banner_id']); if (!empty($params['time_from'])) { $condition .= db_quote(" AND timestamp >= ?i", $params['time_from']); } else { $params['time_from'] = $constraints['min']; } if (!empty($params['time_to'])) { $condition .= db_quote(" AND timestamp <= ?i", $params['time_to']); } else { $params['time_to'] = $constraints['max']; } if ($params['time_to'] - $params['time_from'] > 60 * 60 * 24 * 365) { // split by year $field = "YEAR(FROM_UNIXTIME(timestamp))"; $period = 'year'; } elseif ($params['time_to'] - $params['time_from'] > 60 * 60 * 24 * 30) { // split by month $field = "CONCAT(YEAR(FROM_UNIXTIME(timestamp)),'/',MONTH(FROM_UNIXTIME(timestamp)))"; $period = 'month'; } elseif ($params['time_to'] - $params['time_from'] > 60 * 60 * 24) { // split by day $field = "CONCAT(YEAR(FROM_UNIXTIME(timestamp)),'/',MONTH(FROM_UNIXTIME(timestamp)),'/',DAY(FROM_UNIXTIME(timestamp)))"; $period = 'day'; } else { // split per hour $field = "CONCAT(YEAR(FROM_UNIXTIME(timestamp)),'/',MONTH(FROM_UNIXTIME(timestamp)),'/',DAY(FROM_UNIXTIME(timestamp)),' ',HOUR(FROM_UNIXTIME(timestamp)),':00')"; $period = 'hour'; } $log = db_get_hash_multi_array("SELECT type, COUNT(type) as number, banner_id, unix_timestamp({$field}) as date FROM ?:stat_banners_log WHERE banner_id = ?i ?p GROUP BY type, date ORDER BY date DESC", array('date', 'type'), $params['banner_id'], $condition); foreach ($log as $k => $v) { if (!empty($v['C']['number']) && !empty($v['V']['number'])) { $log[$k]['conversion'] = sprintf('%.2f', $v['C']['number'] / $v['V']['number'] * 100); if (floatval($log[$k]['conversion']) == intval($log[$k]['conversion'])) { $log[$k]['conversion'] = intval($log[$k]['conversion']); } } } return array($log, $period); }
/** * return Box from Boxes Return * * $.ajax({ method:'return', table:'Boxes', barcode:9...9}; * * @return string '' */ function JKY_return_box($the_data) { $db = Zend_Registry::get('db'); $my_barcode = get_data($the_data, 'barcode'); $my_number_of_cones = get_data($the_data, 'number_of_cones'); $my_real_weight = get_data($the_data, 'real_weight'); $sql = 'UPDATE Boxes' . ' SET ' . get_updated() . ', status="Return"' . ', returned_by=' . get_session('user_id') . ', returned_at="' . get_time() . '"' . ', number_of_cones =' . $my_number_of_cones . ', real_weight =' . $my_real_weight . ' WHERE id=' . $my_barcode; log_sql('Boxes', 'update', $sql); $db->query($sql); insert_changes($db, 'Boxes', $my_barcode); $my_box = db_get_row('Boxes', 'id=' . $my_barcode); $my_average_weight = $my_box['average_weight']; $my_real_weight = $my_box['real_weight']; $my_weight = $my_real_weight == 0 ? $my_average_weight : $my_real_weight; $sql = 'UPDATE Batches' . ' SET returned_boxes = returned_boxes + 1' . ' , returned_weight = returned_weight + ' . $my_weight . ' WHERE id = ' . $my_box['batch_id']; log_sql('Batches', 'update', $sql); $db->query($sql); insert_changes($db, 'Batches', $my_box['batch_id']); return ''; }
function execute($requests) { $u = $GLOBALS['AUTH']->uid(); $sessid = session_id(); $sql = 'SELECT c_member_id, nickname FROM c_member WHERE c_member_id <> ?'; $params = array(intval($u)); $members = db_get_all($sql, $params); $sql = 'SELECT c_member_id, nickname FROM c_member WHERE c_member_id = ?'; $params = array(intval($u)); $my_info = db_get_row($sql, $params); array_unshift($members, $my_info); $this->set('inc_navi', fetch_inc_navi('h')); $this->set("c_invite_list", $members); $this->set("c_member_id", $u); $member_list = unserialize($requests['memberlist']); $this->set("name", $requests['name']); $this->set("info", $requests['info']); $this->set("member_list", $member_list); return 'success'; }
public function getDefault($theme_name = '') { $condition = ''; if (empty($theme_name)) { $theme_name = Settings::instance()->getValue('theme_name', ''); } if (fn_allowed_for('ULTIMATE')) { $condition = $this->getCompanyCondition('?:bm_layouts.company_id'); } $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name); /** * Modifies the way to get default layout * * @param object $this Layout object * @param string $theme_name theme name * @param string $condition part of SQL condition */ fn_set_hook('layout_get_default', $this, $theme_name, $condition); $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition); return $layout; }
/** * Read session data * * @param string $sess_id session ID * * @return mixed session data if exist, false otherwise */ public function read($sess_id) { $session = db_get_row('SELECT * FROM ?:sessions WHERE session_id = ?s', $sess_id); if (empty($session) || $session['expiry'] < TIME) { if (!empty($session)) { // the session did not have time to get in "stored_sessions" and got out of date, it is necessary to return only settings db_query('DELETE FROM ?:sessions WHERE session_id = ?s', $sess_id); $session = Session::decode($session['data']); return Session::encode(array('settings' => !empty($session['settings']) ? $session['settings'] : array())); } $stored_data = db_get_field('SELECT data FROM ?:stored_sessions WHERE session_id = ?s', $sess_id); if (!empty($stored_data)) { db_query('DELETE FROM ?:stored_sessions WHERE session_id = ?s', $sess_id); $current = array(); $_stored = Session::decode($stored_data); $_current['settings'] = !empty($_stored['settings']) ? $_stored['settings'] : array(); return Session::encode($_current); } } else { return $session['data']; } return false; }
function fn_statistics_livehelp_get_group_data($group_name, &$result) { if ($group_name == 'visitors' && !empty($result)) { foreach ($result as $k => $v) { if (!empty($v['ip'])) { $sess_id = db_get_field("SELECT MAX(sess_id) FROM ?:stat_sessions WHERE host_ip = ?i", $v['ip']); $sess_data = db_get_row("SELECT CONCAT(?:stat_browsers.browser, ', ', ?:stat_browsers.version) AS browser, ?:stat_sessions.os, ?:stat_sessions.referrer, CONCAT(?:stat_ips.country_code, '|', ?:country_descriptions.country) AS country FROM ?:stat_sessions LEFT JOIN ?:stat_browsers ON ?:stat_sessions.browser_id = ?:stat_browsers.browser_id LEFT JOIN ?:stat_ips ON ?:stat_sessions.ip_id = ?:stat_ips.ip_id LEFT JOIN ?:country_descriptions ON ?:stat_ips.country_code = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s WHERE sess_id = ?i", CART_LANGUAGE, $sess_id); if (!empty($sess_data)) { $result[$k]['browser'] = htmlentities($sess_data['browser']); $result[$k]['os'] = htmlentities($sess_data['os']); $result[$k]['referer'] = htmlentities($sess_data['referrer']); $result[$k]['country'] = htmlentities($sess_data['country']); } $req_id = db_get_field("SELECT MAX(req_id) FROM ?:stat_requests WHERE sess_id = ?i", $sess_id); $req_data = db_get_row("SELECT url, title FROM ?:stat_requests WHERE req_id = ?i", $req_id); if (!empty($req_data)) { $result[$k]['href'] = htmlentities($req_data['url']); $result[$k]['title'] = htmlentities($req_data['title']); } } } } }