public static function getCountryDefault($countryID) { if (!$countryID) { return false; } $sql = "SELECT *\n FROM `taxes`\n WHERE `country_id` = ?s\n AND `state_code` IS NULL"; $db = self::$_msql = SafeMySQL::getInstance(); $result = $db->getRow($sql, $countryID); if ($result) { $tax = new Tax(); $tax->fillFromArray($result); return $tax; } return false; }
function show() { $configuration = new Config(); $database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset)); $data = $database->getAll('SELECT * FROM students'); $response = new Response(); $response->setContent(json_encode($data)); $response->send(); }
public function __construct() { if (!self::$db) { self::$db = SafeMySQL::getInstance(); } parent::__construct(); }
public function beforeSave() { // make sure there isn't already a record with the same country and state code $db = self::$_msql = SafeMySQL::getInstance(); $sql = "SELECT tax_id\n FROM `taxes`\n WHERE `country_id` = ?s"; if ($this->state_code) { $sql .= " and state_code = ?s"; } else { $sql .= " and state_code is NULL"; } if ($this->tax_id) { $sql .= " and tax_id = ?i"; if ($this->state_code) { $result = $db->getOne($sql, $this->country_id, $this->state_code, $this->tax_id); } else { $result = $db->getOne($sql, $this->country_id, $this->tax_id); } } else { if ($this->state_code) { $result = $db->getOne($sql, $this->country_id, $this->state_code); } else { $result = $db->getOne($sql, $this->country_id); } } if ($result) { return false; } else { return TRUE; } }
public static function firePixelPb($model) { $db = SafeMySQL::getInstance(); if (!$model instanceof Order) { $model = Order::model()->findByPk($model); } if (!$model->order_id) { return false; } // NOTE: temp. If a payment bank in array - we don't need to fire pixel if ($model->payment && is_object($model->payment) && $model->payment->num2 && in_array($model->payment->num2, self::$_bannedBins) && in_array($model->campaign_id, self::$_bannedCampaigns)) { return false; } $fire = false; if ($model->aff_id) { $sql = 'SELECT * FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` = ?i'; $result = $db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id); $count_rows = $result->num_rows; } else { $count_rows = 0; } if (!$model->aff_id || !$count_rows) { $sql = 'SELECT * FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` IS NULL'; $result = $db->query($sql, $model->campaign_id, $model->payment->method_id); if (!$result->num_rows) { $fire = true; } else { $fire_result = $db->fetch($result); if ($fire_result['rate']) { $fire = true; } if ($model->aff_id) { $r = $fire_result['rate'] == 0 ? 0 : 1; $sql = 'INSERT IGNORE INTO `pixel_rates` (`campaign_id`, `method_id`, `aff_id`, `rate`, `total_fired`, `total_orders`) SELECT `campaign_id`, `method_id`, ?i, `rate`, ' . $r . ', 1 FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` IS NULL'; $db->query($sql, $model->aff_id, $model->campaign_id, $model->payment->method_id); } } } else { $fire_result = $db->fetch($result); if ($fire_result['rate'] != 0 && ($fire_result['total_orders'] == 0 || 100 * $fire_result['total_fired'] / ($fire_result['total_orders'] + 1) < $fire_result['rate'])) { $sql = 'UPDATE `pixel_rates` SET `total_fired` = `total_fired` + 1, `total_orders` = `total_orders` + 1 WHERE `campaign_id` = ?i AND `method_id` = ?s AND `aff_id` = ?i'; $db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id); $fire = true; } else { $sql = 'UPDATE `pixel_rates` SET `total_orders` = `total_orders` + 1 WHERE `campaign_id` = ?i AND `method_id` = ?s AND `aff_id` = ?i'; $db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id); } } if ($fire) { $sql = 'UPDATE `orders` SET `pixel_fired` = 1 WHERE `order_id` = ?i'; $db->query($sql, $model->order_id); exec('/usr/bin/php-cli /home/pinnacle/public_html/lj3/nws/pixels_pb.php ' . $model->order_id . ' > /dev/null 2>&1 &'); } }
public static function getAttachedByCampaign($campaign_id, $auto = true) { $db = SafeMySQL::getInstance(); $sql = "SELECT ca.`campattach_id`,\n\t\t\t\t\t\tca.`campaign_id`,\n ca.`campaign_attach_id`\n\t\t FROM `campaigns_attach` as ca\n WHERE ca.`campaign_id` = ?i"; if ($auto) { $sql .= " and ca.`auto_attach` = 1"; } $sql .= " ORDER BY ca.`campattach_id` ASC"; return $db->getAll($sql, $campaign_id); }
public function __construct() { if (!self::$_msql) { self::$_msql = SafeMySQL::getInstance(); } $this->setIsNewRecord(TRUE); $this->relations = $this->relations(); $this->modelName = strtolower(get_class($this)); $this->init(); }
function __construct($params) { self::$_msql = SafeMySQL::getInstance(); $modelName = get_class($this); foreach ($modelName::$vars as $k => $v) { $this->{$k} = isset($params[$k]) ? $params[$k] : $v; if ($v === FALSE && $this->{$k} === FALSE) { $this->setErrors('Undefined params ' . $k); } } }
private static function fillFromDatabase() { $cacheID = "all_currencies"; self::$_allCurrencies = AF::cache()->get($cacheID); if (!self::$_allCurrencies) { $db = self::$_msql = SafeMySQL::getInstance(); $sql = "SELECT * FROM `currency`"; self::$_allCurrencies = $db->getInd('currency_id', $sql); AF::cache()->set($cacheID, self::$_allCurrencies); } }
public function getResultsByCustomerId($id, $cc = true) { if (!$id) { return array(); } $db = self::$_msql = SafeMySQL::getInstance(); $sql = "SELECT\n\t\t\tp.`payment_id`,\n\t\t\tp.`customer_id`,\n\t\t\tp.`method_id`,\n\t\t\tp.`num1`,\n\t\t\tp.`num2`,\n\t\t\tp.`num3`,\n\t\t\tp.`num4`,\n\t\t\tp.`txt1`,\n\t\t\tp.`txt2`,\n\t\t\tp.`txt3`,\n\t\t\tp.`txt4`"; $sql .= $cc ? " , p.`note1`" : ''; $sql .= "FROM `payments` as p\n\t\t\tWHERE p.`customer_id`=?i"; $sqlParse = $db->parse($sql, $id); return $this->getSqlParse($sqlParse); }
public static function getDoubleShippingSKUArray($campaignArray, $campaignID) { self::$DoubleShippingSKUArray = array(); if (!$campaignArray) { return array(); } $db = SafeMySQL::getInstance(); $sql = "SELECT cp.`campaign_id`\n FROM `products` as p\n JOIN `campaigns_products` as cp ON p.`product_id` = cp.`product_id`\n WHERE cp.`campaign_id` IN (?a)\n AND p.`product_shipping_sku` != ''"; $result = $db->getAll($sql, $campaignArray); $resultArray = array(); foreach ($result as $item) { $resultArray[] = $item['campaign_id']; } self::$DoubleShippingSKUArray = in_array($campaignID, $resultArray) ? $resultArray : array(); }
public function getResultsById($id, $ps = null) { if (!$id) { return array(); } $db = self::$_msql = SafeMySQL::getInstance(); $sql = "SELECT\n\t\t\t\tpm.`profile_id`,\n\t\t\t\tpm.`method_id`,\n\t\t\t\tm.`method_name`,\n\t\t\t\tm.`method_ref`,\n\t\t\t\tpm.`load_balance`,\n\t\t\t\tg.`system_code`\n FROM `profiles_methods` as pm\n\t\t\t JOIN `methods` as m on m.`method_id` = pm.`method_id`\n\t\t\t JOIN `profiles_gateways` as pg on pg.`profile_id` = pm.`profile_id` and pg.`method_id` = pm.`method_id`\n\t\t\t JOIN `gateways` as g on g.`gateway_id` = pg.`gateway_id`\n WHERE pm.`profile_id` = ?i"; if ($ps && strlen($ps)) { $sql .= " AND g.`system_code` = ?s"; $sqlParse = $db->parse($sql, $id, $ps); } else { $sqlParse = $db->parse($sql, $id); } return $this->getSqlParse($sqlParse); }
function privilegeAction() { $model = new User(); $model->allFIelds = true; $id = AF::get($this->params, 'id', 0); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->setByID($id)) { throw new AFHttpException(0, 'incorrect_id'); } $access = new Access(); $access->fillFromUser($model); $userAccess = $access->getUserUpdateAccess(); ksort($userAccess); if (isset($_POST['ajax'])) { $newAcces = AF::get($_POST, 'array'); if ($newAcces) { $access->setUserAccess($newAcces); // hack to get the uesrs_access table to update instead of insert $msql = SafeMySQL::getInstance(); $sql = "SELECT * FROM ?n WHERE user_id = ?i"; $result = $msql->getRow($sql, $access->tableName(), $access->user_id); if (!empty($result)) { $access->setIsNewRecord(0); } if ($access->save()) { $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->IsNewRecord = false; $model->save(); Message::echoJsonSuccess(__('user_access_updated')); } else { Message::echoJsonError(__('user_access_not_updated')); } } else { Message::echoJsonError(__('user_access_not_updated')); } } Assets::js('jquery.form'); $this->addToPageTitle('User privilege'); $this->render('privilege', array('userAccess' => $userAccess, 'model' => $model)); }
public static function updateSites($campaignID) { $modelCampaign = Campaign::model()->with('domain')->cache()->findByPk($campaignID); if (!$modelCampaign) { return false; } $db = SafeMySQL::getInstance(); $sql = "SELECT c.`url`,\n c.`campaign_id`,\n c.`country_id`,\n c.`currency_id`\n FROM `campaigns` as c\n WHERE c.`domain_id` = ?i"; $campaigns = $db->getAll($sql, $modelCampaign->domain_id); $rArray = array(); $cIDs = array(); foreach ($campaigns as $campaign) { $cIDs[] = $campaign['campaign_id']; $rArray[$campaign['campaign_id']] = array('main' => array('path' => $campaign['url'], 'campaign_id' => $campaign['campaign_id'], 'country_id' => $campaign['country_id'], 'currency_id' => $campaign['currency_id']), 'products' => array(), 'custom_fields' => array()); $sql = "SELECT `name`, `value`\n FROM `site_variables`\n WHERE (`domain_id`=?i AND`campaign_id`=?i)\n OR (`domain_id`=?i AND `campaign_id` IS NULL)\n OR (`domain_id` IS NULL AND `campaign_id` IS NULL)"; $customFields = $db->getAll($sql, $modelCampaign->domain_id, $campaign['campaign_id'], $modelCampaign->domain_id); if ($customFields) { foreach ($customFields as $field) { $rArray[$campaign['campaign_id']]['custom_fields'][$field['name']] = $field['value']; } } } $sql = "SELECT p.`product_id`,\n p.`prodcat_id`,\n p.`product_name`,\n p.`product_price`,\n p.`product_weight`,\n p.`product_next_id`,\n p.`subscription_days`,\n cp.`campaign_id`\n FROM `products` as p\n JOIN `campaigns_products` as cp USING (`product_id`)\n WHERE cp.`campaign_id` IN (?a)\n AND cp.`enabled` = 1\n AND cp.`upsell_id` IS NULL"; $products = $db->getAll($sql, $cIDs); if ($products) { foreach ($products as $product) { $campaignID = $product['campaign_id']; unset($product['campaign_id']); array_push($rArray[$campaignID]['products'], $product); } } $siteApi = new SiteApi(); if (!$siteApi->createFile(json_encode($rArray))) { //save an error to the log file //.. return false; } $siteApi->domain = $modelCampaign->domain->url; $siteApi->update(); }
<?php require '../php/main/db_connect.php'; require 'mm/parser.php'; $arr = array(); if ($last_id && $page && $user_id) { $string_object = new SafeMySQL(); $writer = new Writer(); $y = $string_object->getRow("SELECT d_id, other_id, pioneer_id,meter FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $category, $user_id, $category, $user_id); if ($y['d_id']) { $dg = $string_object->getAll("SELECT m.text, m.date, m.mes_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND m.mes_id < ?i AND i.user_id = m.user_id ORDER BY m.mes_id DESC LIMIT 10", $y['d_id'], $last_id); $avatar = $string_object->getOne('SELECT avatar FROM users_information WHERE user_id=?i', $user_id); $avatar = file_exists('../upload_image/avatars/pre_150px/' . $avatar . '.jpg') ? $avatar : 'default'; $i = 0; foreach ($dg as $array) { $res = array('n0' => $y['d_id'], 'n1' => $array['mes_id'], 'n2' => $array['avatar'], 'n3' => $array['nickname'], 'n4' => $array['date'], 'n5' => $writer->main($array['text'], 1)); $i++; array_push($arr, $res); } unset($array); } } print json_encode($arr);
echo long2ip(2130706433); die; //time $mtime = explode(" ", microtime()); $Smtime = $mtime[1] + $mtime[0]; $start_memory_usage = memory_get_usage(); //timeend--- /** * User: Anton Antonov * Date: 6/6/14 * Time: 7:47 AM */ @(include_once 'settings/autoload.php'); $productArray['subscription_days'] = 2; $db = SafeMySQL::getInstance(); $result = array(); $result['status'] = 'upsell'; //$result['discount_next'] = 0; //$result['created'] = date("Y-m-d H:i:s"); $result['amount_product'] = 11.2; $result['amount_shipping'] = 0; $result['amount_refunded'] = 0; $result['payment_total'] = 0; //$productArray['product_price']; $result['pixel_fired'] = 0; //$result['product_id'] = 111; $result['shipping_id'] = 111; //$result['rma_code'] = 'NULL:sql'; $result['recurring'] = $productArray['subscription_days'] ? 0 : 'NULL:sql'; $result['billing_cycle'] = 0;
<body> <h2>DbTree 4.2 class demo by Kuzma Feskov</h2> [<a href="dbtree.php">Manage demo</a>] [<a href="dbtree.php?mode=map">Visual demo (Map)</a>] [<a href="dbtree.php?mode=ajar">Visual demo (Ajar)</a>] [<a href="dbtree.php?mode=branch">Visual demo (Branch)</a>] <?php require_once 'classes/safemysql.class.php'; require_once 'classes/DbTree.class.php'; require_once 'classes/DbTreeExt.class.php'; // Data base connect $dsn['user'] = '******'; $dsn['pass'] = ''; $dsn['host'] = 'localhost'; $dsn['db'] = 'test'; $dsn['charset'] = 'utf8'; $dsn['errmode'] = 'exception'; define('DEBUG_MODE', false); $db = new SafeMySQL($dsn); $sql = 'SET NAMES utf8'; $db->query($sql); $tree_params = array('table' => 'test_sections', 'id' => 'section_id', 'left' => 'section_left', 'right' => 'section_right', 'level' => 'section_level'); $dbtree = new DbTreeExt($tree_params, $db); /* ------------------------ NAVIGATOR ------------------------ */ $navigator = 'You are here: '; if (!empty($_GET['section_id'])) { $parents = $dbtree->Parents((int) $_GET['section_id'], array('section_id', 'section_name')); foreach ($parents as $item) { if (@$_GET['section_id'] != $item['section_id']) { $navigator .= '<a href="dbtree.php?mode=' . $_GET['mode'] . '§ion_id=' . $item['section_id'] . '">' . $item['section_name'] . '</a> > '; } else { $navigator .= '<strong>' . $item['section_name'] . '</strong>'; } }
public static function removeAllByCM($campaignID, $methodID) { $msql = SafeMySQL::getInstance(); $sql = "DELETE FROM `pixel_rates`\n WHERE `campaign_id` = ?i\n AND `method_id`= ?i"; $msql->query($sql, $campaignID, $methodID); }
<?php require_once '../../php/main/db_connect.php'; if ($user_id) { $r = new SafeMySQL(); date_default_timezone_set('Europe/London'); $date = date('Y-m-d H:i:s'); $r->query("UPDATE users_online SET online='offline' WHERE user_id=?i LIMIT 1", $user_id); $r->query("UPDATE users_online SET date=?s WHERE user_id=?i LIMIT 1", $date, $user_id); setcookie('RememberMe', $password, time() + 3600 * 24 * 365, '/'); setcookie('email', $email, time() + 3600 * 24 * 365, '/'); unset($_SESSION['password'], $_SESSION['email']); print 'success'; } else { print 'error'; }
public static function getAttemptNumberByOrderID($orderID) { $msql = SafeMySQL::getInstance(); $sql = "SELECT `attempt_number` FROM `attempts` WHERE `order_id`=?i ORDER BY `attempt_number` DESC LIMIT 1"; $result = $msql->getRow($sql, $orderID); return isset($result['attempt_number']) && $result['attempt_number'] ? $result['attempt_number'] + 1 : 1; }
<?php require '../../php/main/db_connect.php'; $id_other = filter_input(INPUT_POST, 'page'); $text = filter_input(INPUT_POST, 'text'); if (isset($user_id, $text, $id_other) && $id_other !== $user_id) { $string = new SafeMySQL(); date_default_timezone_set('Europe/London'); $date = date('Y-m-d H:i:s'); $x = $string->getRow("SELECT d_id FROM users_dialogs WHERE pioneer_id=?i AND other_id=?i OR other_id=?i AND pioneer_id=?i", $user_id, $id_other, $user_id, $id_other); if ($x) { $y = $string->query("INSERT INTO users_messages (d_id,user_id,text,date) VALUES (?i,?i,?s,?s)", $x['d_id'], $user_id, $text, $date); $query_dialog = $string->query('UPDATE users_dialogs SET date=?s,meter=?i WHERE d_id=?i LIMIT 1', $date, $user_id, $x['d_id']); print "success"; } else { $y = $string->query("INSERT INTO users_dialogs (other_id, pioneer_id, date) VALUES (?i, ?i, ?s)", $id_other, $user_id, $date); $k = $string->getOne('SELECT d_id FROM users_dialogs WHERE pioneer_id=?i AND other_id=?i', $user_id, $id_other); $z = $string->query("INSERT INTO users_messages (d_id,user_id,text,date) VALUES (?i,?i,?s,?s)", $k, $user_id, $text, $date); print "success"; } } else { print 'Пройдите регистрацию или авторизацию.'; }
<?php include_once '../settings/autoload.php'; $msql = SafeMySQL::getInstance(); $sql = "DELETE FROM jobs\n WHERE job_status = 'done'"; $msql->query($sql); $sql = "UPDATE `jobs` SET `job_status` = 'new'\n WHERE job_status = 'processing'\n AND (updated + INTERVAL 1 DAY) < NOW()"; $msql->query($sql);
public static function rebillNow($orderID, $productID) { //@o1 - order_id //@op1 - order_product_id //@o2 - new order_id $msql = SafeMySQL::getInstance(); $sql = "INSERT INTO `orders` (`status`, `flags`, `created`, `parent_id`, `customer_id`, `campaign_id`, `payment_id`, `gateway_id`, `shipping_id`, `amount_product`, `amount_shipping`, `aff_id`, `click_id`, `ip`, `address_id`, `billing_address_id`, `billing_cycle`)\n SELECT 'new' AS `status`, '' AS `flags`, NOW() AS `created`, ?i AS `parent_id`, `o`.`customer_id`, `o`.`campaign_id`, `o`.`payment_id`, IF(`op`.`next_gateway_id` IS NOT NULL, `op`.`next_gateway_id`, `o`.`gateway_id`) AS `gateway_id`, `s`.`shipping_id` AS `shipping_id`, ROUND(`p2`.`product_price` * (100 - IF(`op`.`discount_next` IS NULL, 0,`op`.`discount_next`)) / 100, 2) AS `amount_product`, IF(`p2`.`shippable` = 1, `s`.`amount_subscription`, 0) AS `amount_shipping`, `o`.`aff_id`, `o`.`click_id`, `o`.`ip`, `o`.`address_id`, `o`.`billing_address_id`, `o`.`billing_cycle`+1 AS `billing_cycle`\n FROM `orders` AS `o`\n JOIN `orders_products` AS `op`\n JOIN `products` AS `p` USING (`product_id`)\n JOIN `products` AS `p2` ON `p`.`product_next_id` = `p2`.`product_id`\n JOIN `shipping` AS `s` ON `op`.`shipping_id` = `s`.`shipping_id`\n WHERE `o`.`order_id` = ?i AND `op`.`order_product_id` = ?i"; $msql->query($sql, (int) $orderID, (int) $orderID, (int) $productID); $newOrderID = $msql->insertId(); $sql = 'INSERT IGNORE INTO `orders_recurring` (`order_id`, `next_order_id`) VALUES (?i, ?i)'; $msql->query($sql, (int) $orderID, (int) $newOrderID); $sql = 'INSERT IGNORE INTO `order_logs` (`order_id`, `user_id`, `action`, `create`, `notes`) VALUES (?i, 0, 26, NOW(), ?i)'; $msql->query($sql, (int) $orderID, (int) $newOrderID); $sql = "INSERT INTO `orders_products` (`order_id`, `product_id`, `flags`, `discount_next`, `shipping_id`)\n SELECT ?i AS `order_id`, `p`.`product_next_id` AS `product_id`, IF(FIND_IN_SET('stop_next_recurring', `op`.`flags`) = 0 AND `p2`.`product_next_id` IS NOT NULL, IF(FIND_IN_SET('keep_discount', `op`.`flags`) > 0, 'recurring,keep_discount', 'recurring'), '') AS `flags`, IF(FIND_IN_SET('stop_next_recurring', `op`.`flags`) = 0 AND `p2`.`product_next_id` IS NOT NULL AND FIND_IN_SET('keep_discount', `op`.`flags`) > 0, `op`.`discount_next`, NULL) AS `discount_next`, `op`.`shipping_id`\n FROM `orders_products` AS `op`\n JOIN `products` AS `p` USING (`product_id`)\n JOIN `products` AS `p2` ON `p`.`product_next_id` = `p2`.`product_id`\n WHERE `op`.`order_product_id` = ?i"; $msql->query($sql, (int) $newOrderID, (int) $productID); $sql = "UPDATE `orders_products` AS `op`\n SET `flags` = `flags` & ~pow(2, FIND_IN_SET('recurring', `flags`) - 1)\n WHERE `op`.`order_product_id` = ?i"; $msql->query($sql, (int) $productID); return $newOrderID; }
<?php require_once "lib/safemysql.class.php"; $errormsg = ""; $response = []; try { $db = new SafeMySQL(['host' => "s214.webhostingserver.nl", 'user' => "*****@*****.**", 'pass' => "tofreshdesk3", 'db' => "deb12215n7_curl3"]); $tableName = "tickets"; $sql = "SELECT * FROM {$tableName} ORDER BY dtime DESC LIMIT 1"; $values = $db->getRow($sql); $response["data"] = $values; } catch (Exception $e) { $errormsg = $e->getMessage(); } if ($errormsg == "") { $response["status"] = "ok"; } else { $response["status"] = "error"; $response["message"] = $errormsg; } echo json_encode($response);
<?php require '../php/main/SafeMySQL.php'; $string_object = new SafeMySQL(); if ($category === 'all' || !$category) { $query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10"); } else { $query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.category=?s AND i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10", $category); } $arr = array(); $i = 0; foreach ($query as $array) { $image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default'; $link = $category ? $page . '=' . $category . '&video=' . $array['v_id'] : $page . '&video=' . $array['v_id']; $res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['title'], 'n3' => $array['date'], 'n4' => $array['nickname']); if (!$i) { $res = array('head' => '<nav id="content_menu"> <a href="vo=all" class="new_local"><p>ВСЕ</p></a> <a href="vo=review" class="new_local"><p>ОБЗОРЫ</p></a> <a href="vo=letsplay" class="new_local"><p>ЛЕТСПЛЕИ</p></a> <a href="vo=vlog" class="new_local"><p>БЛОГИ</p></a> <div id="lookatme"> <div class="lookatme"></div> <div class="lookatme"></div> <div class="lookatme"></div> </div> </nav> <nav id="content_search"></nav><section id="content_block">', 'tmp' => '<a href="vo&video=%n[0]" class="new_modal"> <article class="video" id="%n[0]" style="background:#000 no-repeat center url(upload_image/videos/pre_500px/%n[1].jpg)"> <div class="video_title"> <p>%n[2]</p>
public static function getInstance() { if (self::$_instance == NULL) { self::$_instance = new SafeMySQL(); } return self::$_instance; }
private static function parserCsvFiles($downloadFilePath) { $header = NULL; $data = array(); if (($handle = fopen($downloadFilePath, 'r')) !== FALSE) { while (($row = fgetcsv($handle, 1000, ',')) !== FALSE) { if (!$header) { $header = $row; } else { $data[] = array_combine($header, $row); } } fclose($handle); } $db = SafeMySQL::getInstance(); echo '<pre>'; print_r($db->getConn()); echo '</pre>'; foreach ($data as $orderArray) { if (isset($orderArray['Tracking Number']) && isset($orderArray['Order Id'])) { /* * Old query $sql = "UPDATE `orders` SET `tracking_number`=?s, `status`='shipped' WHERE (`order_id`=?i OR `ship_with`=?i) AND `status` = 'sent'"; */ $sql = "UPDATE `packages_orders` AS `po`\n JOIN `packages` AS `p` USING (`package_id`)\n LEFT JOIN `orders` AS `o` ON `o`.`order_id` = `po`.`order_id` AND `o`.`status` IN ('ok', 'sent')\n SET `p`.`tracking_number` = ?s, `o`.`status` = 'shipped'\n WHERE `package_id` =\n (SELECT `package_id` FROM `packages_orders` AS `p1` WHERE `p1`.`order_id`=?i LIMIT 1)"; $orderID = (int) $orderArray['Order Id']; echo $sql . '<hr>'; $db->query($sql, $orderArray['Tracking Number'], $orderID); if ($db->affectedRows() > 0) { Event::setEvents($orderID, 9); OrderLog::createLog(0, $orderID, 20); } } } }
<?php require '../php/main/SafeMySQL.php'; $string_object = new SafeMySQL(); if ($category === 'all' || !$category) { $query = $string_object->getAll("SELECT u.user_id, u.avatar, u.nickname, u.category, o.online FROM users_information u, users_online o WHERE o.user_id = u.user_id ORDER BY user_id DESC LIMIT 0,10"); } else { $query = $string_object->getAll("SELECT u.user_id, u.avatar, u.nickname, u.category, o.online FROM users_information u, users_online o WHERE o.user_id = u.user_id AND u.category=?s ORDER BY user_id DESC LIMIT 0,10", $category); } $arr = array(); $i = 0; foreach ($query as $array) { $image = file_exists('../upload_image/avatars/pre_50px/' . $array['avatar'] . '.jpg') ? $array['avatar'] : 'default'; $res = array('n0' => $array['user_id'], 'n1' => $image, 'n2' => $array['nickname'], 'n3' => $array['online'], 'n4' => $array['category'], 'n5' => 'Null'); if (!$i) { $res = array('head' => '<nav id="content_menu"> <a href="pe=all" class="new_local"><p>ВСЕ</p></a> <a href="pe=user" class="new_local"><p>ПОЛЬЗОВАТЕЛИ</p></a> <a href="pe=motiondesign" class="new_local"><p>МОУШЕН-ДИЗАЙНЕРЫ</p></a> <a href="pe=review" class="new_local"><p>ОБОЗРЕВАТЕЛИ</p></a> <a href="pe=letsplay" class="new_local"><p>ЛЕТСПЛЕЕРЫ</p></a> </nav> <nav id="content_search"> <button class="content_search"> Город </button> <button class="content_search"> Пол </button> <button class="content_search"> Возраст
<?php require_once "pass.php"; require_once "lib/safemysql.class.php"; $tableName = "tickets"; echo "Log in MySQL<br>\n"; $db = new SafeMySQL(['host' => $loginData['mysql_host'], 'user' => $loginData['mysql_username'], 'pass' => $loginData['mysql_password'], 'db' => $loginData['mysql_db']]); echo "<br>List fields in table:<br>\n"; $sql = "SHOW COLUMNS FROM {$tableName}"; $fields = $db->getCol($sql); //Print table to HTML ?> <table border="1"> <thead> <tr> <? foreach($fields as $fieldname) { echo "<td>$fieldname</td>\n"; } echo "</tr></thead><tbody>"; $data=$db->getAll("SELECT * FROM $tableName ORDER BY dtime DESC LIMIT 100"); foreach($data as $row=>$cols) { echo"<tr>"; foreach($cols as $col) { echo " <td>$col</td>\n"; } echo "</tr>\n"; } echo "</tbody></table>"; ?>
<?php require '../php/main/SafeMySQL.php'; $o = new SafeMySQL(); $base = $o->getAll('SELECT id,title FROM base_games LIMIT 0,10'); $arr = array(); $i = 0; foreach ($base as $array) { $res = array('n0' => $array['id'], 'n1' => $array['title']); if (!$i) { $res = array('head' => '<nav id="content_menu"> <a href="be=games" class="new_local"><p>ИГРЫ</p></a> </nav><nav id="content_search"></nav><section id="content_block">', 'tmp' => '<article id="%n[0]" class="game"> <div class="game_img"></div> <h4>%n[1]</h4> </article>', 'footer' => '</section>') + $res; } $i++; array_push($arr, $res); } unset($array); print json_encode($arr);