public function getComments($args = null) { $db = VBox::get('ConstData')->getConst('langsDb'); if (isset($args[0]) && strpos($args[0], ',') !== false) { $where = " AND c.comment_product_id IN({$args[0]}) "; } elseif (isset($args[0]) && $args[0] > 0) { $where = " AND c.comment_product_id = '{$args[0]}' "; } elseif (isset($args[1]) && strpos($args[1], ',') !== false) { $where = " AND c.comment_id IN({$args[1]}) "; } elseif (isset($args[1]) && $args[1] > 0) { $where = " AND c.comment_id = '{$args[1]}' "; } else { $where = ''; } $q = "SELECT * FROM {$db}.comments AS c WHERE c.comment_hidden = '0'{$where} ORDER BY comment_order"; DB::executeQuery($q, 'comments'); $rows = DB::fetchResults('comments'); $comments = $pages = array(); foreach ($rows as $row) { $pages = explode(',', $row['comment_pages']); if (in_array($this->pageUrl, $pages) && isset($this->pageUrl)) { $comments[] = $row; } } return $comments; }
public function buildSitemap() { if ($this->isValid) { $q = 'SELECT pg_address, pg_lang, pg_priority, UNIX_TIMESTAMP(pg_lastmodify) AS pg_lastmod FROM ' . $this->dbName . 'pages WHERE pg_indexed = 1 AND pg_hidden = 0'; DB::executeQuery($q, 'pages'); $rows = DB::fetchResults('pages'); if (!empty($rows)) { $tsize = sizeof($rows); for ($i = 0; $i < $tsize; $i++) { if (!$this->alLangs[$rows[$i]['pg_lang']]['blocked']) { $this->sitemap .= ' <url> <loc>http://' . $this->Host . $this->alLangs[$rows[$i]['pg_lang']]['prefix'] . $rows[$i]['pg_address'] . '</loc> <lastmod>' . date('Y-m-d\\Th:i:s-04:00', $rows[$i]['pg_lastmod']) . '</lastmod> <changefreq>weekly</changefreq> <priority>' . (!empty($rows[$i]['pg_priority']) ? $rows[$i]['pg_priority'] : '0.3') . '</priority> </url>'; } } if (!empty($this->sitemap)) { $this->sitemap = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . $this->sitemap . ' </urlset>'; } return TRUE; } return FALSE; } return FALSE; }
public function getOs() { $q = ' SELECT * FROM `devices_os` ORDER BY `os_order`'; DB::executeQuery($q, 'getOs'); $rows = DB::fetchResults('getOs'); return $rows; }
public function getMenuByParentId($alias = '', $parent_id = 0) { $q = 'SELECT mi.* FROM menu as m, menu_item as mi WHERE m.m_id = mi.mi_menu_id and m.m_alias = "' . $alias . '" and mi.mi_parent_id=' . $parent_id . ' and mi.mi_hidden = "0" ORDER BY mi.mi_order'; // var_dump($q); DB::executeQuery($q, 'menu' . $parent_id); $rows = DB::fetchResults('menu' . $parent_id); $result = array(); if (!empty($rows)) { $tsize = sizeof($rows); for ($i = 0; $i < $tsize; $i++) { // $mi_link_alias = explode('|',$rows[$i]['mi_link_alias']); $mi_link_alias = preg_split("/[\\s,]+/", $rows[$i]['mi_link_alias']); $page_not_view = explode(',', $rows[$i]['mi_pages_not_view']); if (!in_array($this->PageId, $page_not_view)) { $mPageAddress = ($this->mLanguage !== 'en' && strpos($rows[$i]['mi_link'], '/' . $this->mLanguage . '/') === false ? '/' . $this->mLanguage : '') . $rows[$i]['mi_link']; if ($this->mPageAddress == $mPageAddress || in_array($this->mPageAddress, $mi_link_alias)) { $selected = true; } else { $selected = false; } $LocalStrings = $this->page->getLocalStrings(); $result[] = array('name' => $LocalStrings[$rows[$i]['mi_name']], 'title' => $LocalStrings[$rows[$i]['mi_title']], 'link' => $rows[$i]['mi_link'], 'attr' => $rows[$i]['mi_attr'], 'level' => $rows[$i]['mi_level'], 'class' => $rows[$i]['mi_class'], 'selected' => $selected, 'pageadres' => $mPageAddress, 'items' => $this->getMenuByParentId($alias, $rows[$i]['mi_id'])); } } } return $result; }
public function getPlimusLinkDataByAddress($address) { $q = 'SELECT link_data FROM ' . $this->dbName . 'pa_plimus_links WHERE link_address = "' . $address . '"'; if (DB::executeQuery($q, 'link')) { return DB::fetchOne('link'); } }
public function loadConst() { $q = 'SELECT c_name, c_value FROM ' . $this->siteDb . 'const'; DB::executeQuery($q, 'const_data'); $results = DB::fetchResults('const_data'); if (!empty($results)) { foreach ($results as $row) { $this->internalData[$row['c_name']] = $row['c_value']; } } }
public function getNews($desc = "") { $db = VBox::get('ConstData')->getConst('langsDb'); $q = 'SELECT news_text, news_title FROM ' . $db . '.news_' . $this->mLanguage . ' ORDER BY news_order ' . $desc; DB::executeQuery($q, 'newsList'); $rows = DB::fetchResults('newsList'); $newsList = array(); foreach ($rows as $row) { $newsList[] = $row; } return $newsList; }
/** * function for get array banners & overlays * @version 25.11.2014 * @author italiano * @param $alias = empty or overlay, $id = id item * @return array */ public function getBanners($args = array('alias' => null, 'id' => null)) { $limit = 10; if (isset($args['alias'])) { $where = " AND b.banner_alias ='{$args['alias']}'"; } else { $where = ''; } if (isset($args['id'])) { $where .= " AND bi.bi_id = '{$args['id']}'"; } else { $where .= ''; } $q = "SELECT bi.* FROM banners as b, banners_item as bi WHERE b.banner_id = bi.bi_banner_id {$where} AND bi.bi_hidden = '0' ORDER BY bi.bi_order LIMIT 0,{$limit}"; DB::executeQuery($q, 'banners'); $rows = DB::fetchResults('banners'); $result = array(); $tsize = count($rows); $assign = null; $cookieBanners = isset($_COOKIE['banners']) ? $_COOKIE['banners'] : false; $cookieOverlays = isset($_COOKIE['overlay']) ? $_COOKIE['overlay'] : false; for ($i = 0; $i < $tsize; $i++) { $page_for_view = explode(',', $rows[$i]['bi_pages']); $assign = $rows[$i]['bi_assign']; //if not isset banner ID in cookie['banners'] if (!isset($cookieBanners[$rows[$i]['bi_id']])) { switch ($assign) { //for all pages case "0": $result[] = array('link' => $rows[$i]['bi_link'], 'type' => $rows[$i]['bi_type'], 'id' => $rows[$i]['bi_id']); break; //for select pages //for select pages case "1": if (in_array($this->PageId, $page_for_view)) { $result[] = array('link' => $rows[$i]['bi_link'], 'type' => $rows[$i]['bi_type'], 'id' => $rows[$i]['bi_id']); } break; //for no select pages //for no select pages case "2": if (!in_array($this->PageId, $page_for_view)) { $result[] = array('link' => $rows[$i]['bi_link'], 'type' => $rows[$i]['bi_type'], 'id' => $rows[$i]['bi_id']); } break; } } } return $result; }
public function authenticate($loginField, $passwdField) { if (!empty($_POST[$loginField]) && !empty($_POST[$passwdField])) { $q = 'SELECT u_passwd FROM ' . $this->_consts->getConst('adminDb') . '.users WHERE u_login = ? LIMIT 1'; DB::executeQuery($q, 'user_data', array($_POST[$loginField])); $row = DB::fetchOne('user_data'); if (!empty($row)) { if (md5($_POST[$passwdField]) == $row) { $this->_storage->setFingerprint(); $this->isValid = TRUE; } } } }
/** * function to check a user at the data table * @vars email, hash * @return bool * */ protected function checkIn($id, $hash) { $result = false; $q = 'SELECT es_email FROM ' . $this->table_name . ' WHERE es_id = ? LIMIT 1'; if (DB::executeQuery($q, 'checkIn', array($id))) { $rows = DB::fetchResults('checkIn'); if (count($rows) > 0) { $email = $rows[0]['es_email']; if ($this->check_hash($id, $email, $hash)) { $this->email = $email; $result = true; } } } //include_once('application/final.inc.php'); return $result; }
public function getCases($limit = NULL, $order = 'cs_id') { // $db = VBox::get('ConstData')->getConst('langsDb'); $q = 'SELECT cs_autor, cs_text, cs_pages_not_view, ifnull(cs_link,"") as cs_link FROM case_study WHERE cs_lang_id = ' . $this->languageId . ' and cs_hidden="0" ORDER BY ' . $order; if ($limit !== NULL) { $q .= ' LIMIT ' . $limit; } DB::executeQuery($q, 'caseList'); $rows = DB::fetchResults('caseList'); $caseList = array(); foreach ($rows as $row) { $page_not_chow = explode(',', $row['cs_pages_not_view']); if (!in_array($this->PageId, $page_not_chow)) { $caseList[] = $row; } } return $caseList; }
private function getBlocksData() { $callback = false; if (is_array($this->pageIds)) { foreach ($this->pageIds as $pageId) { $q = 'SELECT b.b_id, b.b_file, b.b_name, bf.bf_id, bf.bf_type, bf.bf_block_id, bf.bf_name, bf.bf_default, bp.bp_id, bp.bp_page_id, bp.bp_block_id, bp.bp_parent, bp.bp_order, bd.bd_id, bd.bd_value, bd.bd_bp_id, bd.bd_field_id FROM ' . $this->siteDb . 'blocks2pages AS bp LEFT JOIN ' . $this->siteDb . 'blocks_data AS bd ON bp.bp_id = bd.bd_bp_id LEFT JOIN ' . $this->siteDb . 'blocks_fields AS bf ON bf.bf_id = bd.bd_field_id LEFT JOIN ' . $this->siteDb . 'blocks AS b ON b.b_id = bp.bp_block_id WHERE bp.bp_page_id = ' . $pageId . ' ORDER BY bp.bp_order'; DB::executeQuery($q, 'blocks_data'); $result = DB::fetchResults('blocks_data'); if (!empty($result)) { $this->blocksData[$pageId] = $result; $callback = true; } } } return $callback; }
public function getCode() { $q = "SELECT COUNTRY_CODE2, COUNTRY_NAME FROM " . VBox::get('ConstData')->getConst('langsDb') . ".countries WHERE IP_FROM<=inet_aton('" . $this->IP . "') AND IP_TO>=inet_aton('" . $this->IP . "')"; DB::executeQuery($q, 'geo'); $rows = DB::fetchRow('geo'); if (count($rows) == 0) { return 'en'; } $user_country = $rows['COUNTRY_CODE2']; $user_lng = strtoupper(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); $needed_locale = 'en'; foreach ($this->available_locales as $lang => $toplng) { if (in_array($user_country, $toplng)) { $needed_locale = $lang; break; } else { if (in_array($user_lng, $toplng)) { $needed_locale = $lang; } } } return strtolower($needed_locale); }
public static function getAddressById($id) { $q = 'SELECT pg_address FROM pages WHERE pg_id = ? LIMIT 1'; DB::executeQuery($q, 'faddress', array($id)); $address = DB::fetchOne('faddress'); if (!empty($address)) { return $address; } return '/'; }
public static function deleteByEmployee($employee_id) { DB::executeQuery('DELETE FROM ' . TS_DB_HRM_TBNames::$employee_leaves . ' WHERE employee_id = :employee_id', array('employee_id' => $employee_id)); }
public function get_nearby_published($lat, $lng, $distance) { Logger::getRootLogger()->debug("Advertisement_model::get_nearby_published"); $response = new Response(); $points = Utils::distance2points($distance, $lat, $lng); $db = new DB(); $db->connect(); $cuid = Utils::getCurrentUserID(); $sql = "select advertisement.id id,advertisement.uid,advertisement.type type,publish_time,title,text_content,image,read_count," . "zan_num,address,fresh_content,fresh_coefficient,user.name user_name,lat,lng,user_collect.adv_id collected,user_focus.uid_b focused,thumb_up_for_adv.adv_id zaned from advertisement " . "inner join user on user.id = uid " . "left join user_collect on user_collect.uid = {$cuid} and advertisement.id = user_collect.adv_id " . "left join user_focus on user_focus.uid_b = advertisement.uid and user_focus.uid_a = {$cuid} " . "left join thumb_up_for_adv on thumb_up_for_adv.adv_id = advertisement.id and thumb_up_for_adv.uid = {$cuid} " . "where (lat <= {$points[0]['lat']} and lng <= {$points[0]['lng']}) " . "and (lat >= {$points[1]['lat']} and lng <= {$points[1]['lng']}) " . "and (lat >= {$points[2]['lat']} and lng >= {$points[2]['lng']}) " . "and (lat <= {$points[3]['lat']} and lng >= {$points[3]['lng']}) "; Logger::getRootLogger()->debug("sql = " . $sql); $res = $db->executeQuery($sql); if ($res instanceof Response) { return $res; } Logger::getRootLogger()->debug("res = " . Utils::var2str($res)); $unsorted = array(); while ($row = mysqli_fetch_assoc($res)) { $distance = Utils::distanceSimplify($lat, $lng, $row['lat'], $row['lng']); $row['distance'] = $distance; array_push($unsorted, $row); } /* free result set */ mysqli_free_result($res); $sorted = Utils::sort_adv_by_distance($unsorted); $adv_infor = "["; foreach ($sorted as $item) { $adv_infor = $adv_infor . "{"; $adv_infor = $adv_infor . '"id":"' . $item['id'] . '",'; $adv_infor = $adv_infor . '"uid":"' . $item['uid'] . '",'; $adv_infor = $adv_infor . '"user_name":"' . $item['user_name'] . '",'; $adv_infor = $adv_infor . '"type":"' . $item['type'] . '",'; $adv_infor = $adv_infor . '"publish_time":"' . $item['publish_time'] . '",'; $adv_infor = $adv_infor . '"title":"' . $item['title'] . '",'; $adv_infor = $adv_infor . '"text_content":"' . $item['text_content'] . '",'; $adv_infor = $adv_infor . '"fresh_content":"' . $item['fresh_content'] . '",'; $adv_infor = $adv_infor . '"fresh_coefficient":"' . $item['fresh_coefficient'] . '",'; $adv_infor = $adv_infor . '"image":"' . $item['image'] . '",'; $adv_infor = $adv_infor . '"read_count":"' . $item['read_count'] . '",'; $adv_infor = $adv_infor . '"zan_num":"' . $item['zan_num'] . '",'; $adv_infor = $adv_infor . '"addr":"' . $item['address'] . '",'; $adv_infor = $adv_infor . '"distance":"' . $item['distance'] . '",'; $adv_infor = $adv_infor . '"focused":"' . ($item['focused'] == "" ? "false" : "true") . '",'; $adv_infor = $adv_infor . '"collected":"' . ($item['collected'] == "" ? "false" : "true") . '",'; $adv_infor = $adv_infor . '"zaned":"' . ($item['zaned'] == "" ? "false" : "true") . '"'; $adv_infor = $adv_infor . "},"; } $adv_infor = substr($adv_infor, 0, -1); $adv_infor = $adv_infor . "]"; $response->status = Response::STATUS_OK; $response->message = "请求广告信息成功"; $response->response_data = $adv_infor; return $response; }
public function Validatecoupon($params) { $percent = 0; $result = array('percent' => 0, 'licenses' => array()); if (!empty($params['licenses'])) { $lics = explode(',', trim($params['licenses'])); $operator = isset($params['operator']) ? trim($params['operator']) : 0; $q = ' SELECT cup_percent, cup_validlic, cup_unvalidlic, cup_quantity, cup_opid FROM ' . $this->dbName . 'pa_coupons WHERE BINARY cup_code = ? AND cup_blocked = "N" AND cup_date >= NOW() AND ((cup_opid = ? and ? <> "0") or ( ? = "0")) LIMIT 1'; if (DB::executeQuery($q, 'coupon', array($params['coupon'], $operator, $operator, $operator))) { $row = DB::fetchRow('coupon'); $validLic = unserialize($row['cup_validlic']); $unvalidLic = unserialize($row['cup_unvalidlic']); if (is_null($validLic)) { $validLic = array(); } if (is_null($unvalidLic)) { $unvalidLic = array(); } $resinvalid = array(); $resvalid = array(); if (sizeof($unvalidLic)) { $resinvalid = array_intersect($lics, $unvalidLic); } if (sizeof($validLic)) { $resvalid = array_intersect($lics, $validLic); } $resvalid = array_diff($resvalid, $resinvalid); $tmp = array(); foreach ($resvalid as $item) { $tmp[$item] = $row['cup_percent']; } $result = array('percent' => $row['cup_percent'], 'licenses' => $tmp); } } return $result; }
public function processLicenseData() { $q = 'SELECT l_id, l_parentid, l_price, l_type, l_usernumber, l_min_usernumber, l_name, l_wiki_link, l_default, pr_curid, pr_price, oi_price_id, po_operator_id FROM ' . $this->dbName . 'pa_licenses LEFT JOIN ' . $this->dbName . 'pa_prices ON l_id = pr_lid LEFT JOIN ' . $this->dbName . 'pa_products_operators ON po_product_id = l_pid LEFT JOIN ' . $this->dbName . 'pa_operators_id ON oi_lid = l_id AND oi_curid = 12 WHERE l_pid = ' . $this->productId . ' AND l_blocked = "N" ORDER BY l_order'; if (DB::executeQuery($q, 'lic')) { $rows = DB::fetchResults('lic'); for ($i = 0; $i < sizeof($rows); $i++) { $lid = $rows[$i]['l_id']; $parentid = $rows[$i]['l_parentid']; $this->productArray['categories'][$rows[$i]['l_type']][$lid] = $lid; $this->productArray['lic'][$lid]['id'] = $lid; $this->productArray['lic'][$lid]['name'] = $rows[$i]['l_name']; $this->productArray['lic'][$lid]['parentid'] = $parentid; $this->productArray['lic'][$lid]['price'] = $rows[$i]['l_price']; $this->productArray['lic'][$lid]['price_id'] = $rows[$i]['oi_price_id']; $this->productArray['lic'][$lid]['wiki_link'] = $rows[$i]['l_wiki_link']; $this->productArray['lic'][$lid]['default'] = $rows[$i]['l_default']; $this->productArray['lic'][$lid]['htmlprice'] = str_replace('.', '.<sup>', $rows[$i]['l_price']) . '</sup>'; $this->productArray['lic'][$lid]['type'] = $rows[$i]['l_type']; $this->productArray['lic'][$lid]['usernumber'] = $rows[$i]['l_usernumber']; $this->productArray['lic'][$lid]['min_usernumber'] = $rows[$i]['l_min_usernumber']; $this->productArray['operator_id'] = $rows[$i]['po_operator_id']; $this->productArray['lic'][$lid]['save'] = 0; if (0 < $rows[$i]['l_parentid']) { $parentPrice = $this->productArray['lic'][$parentid]['price']; if (0 < $parentPrice) { $this->productArray['lic'][$lid]['save'] = 100 - round($rows[$i]['l_price'] * 100 / $parentPrice); } } $cCode = $this->currencyData[$rows[$i]['pr_curid']]['code']; if (0 < $rows[$i]['l_price']) { $this->productArray['prices'][$lid]['USD']['price'] = $rows[$i]['l_price']; $this->productArray['prices'][$lid][$cCode]['price'] = $rows[$i]['pr_price']; } } } $q = 'SELECT oi_price_id, oi_default, oi_curid, oi_operator_id, l_id FROM ' . $this->dbName . 'pa_licenses LEFT JOIN ' . $this->dbName . 'pa_operators_id ON l_id = oi_lid WHERE l_pid = ' . $this->productId . ' AND oi_blocked = "N"'; if (DB::executeQuery($q, 'lic_contracts')) { $rows = DB::fetchResults('lic_contracts'); foreach ($rows as $row) { //echo $row['oi_price_id'].'<br/>'; $cCode = $this->currencyData[$row['oi_curid']]['code']; if ($cCode == 'USD') { $this->productArray['lic'][$row['l_id']]['contractId'][$row['oi_operator_id']] = $row['oi_price_id']; $this->productArray['prices'][$row['l_id']][$row['oi_operator_id']]['contractIds']['default'] = $row['oi_price_id']; } $this->productArray['prices'][$row['l_id']][$row['oi_operator_id']]['contractIds'][$cCode] = $row['oi_price_id']; } } return $this->productArray; }
private function sendForm($ini, $subject = null) { if (!substr_count($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) { return false; } $form = new Form(); if ($form->ParseSettings($ini)) { $this->formData = $form->BuildFormFields($_POST); if (empty($this->formData['error'])) { if (isset($_POST['emails'])) { if ($mSettings = $form->getmSettings()) { foreach ($mSettings as $key => $val) { if (1 == substr_count($key, 'mail')) { $form->delmSettings($key); } } } $form->setmSettings(array('emails' => $_POST['emails'])); } $subject = isset($subject) ? $subject : 'Request'; if (!empty($_POST['product']) && is_numeric($_POST['product'])) { $products = new Products(); $product = $products->getProductById($_POST['product']); $subject .= ' [' . $product['p_title'] . ']'; } elseif (!empty($_POST['product']) && is_string($_POST['product'])) { $subject .= ' [' . $_POST['product'] . ']'; $product = null; } $subject = isset($_POST['subject']) ? $_POST['subject'] : $subject; $msg = $subject . ' from ' . $_SERVER['HTTP_REFERER'] . "\n\n" . (isset($product) ? 'Product: ' . $product['p_title'] . "\n" : '') . $form->__toString(); if (isset($this->formData['AttachFile'])) { $filePath = $this->formData['AttachFile']['filepath']; $fileName = $this->formData['AttachFile']['filename']; } else { $filePath = ''; $fileName = ''; } if (!empty($_POST['subscribe']) && !empty($_POST['email']) && !empty($_POST['product'])) { $table_name = 'discount_subscribe'; $name = isset($_POST['name']) ? $_POST['name'] : ''; $q = sprintf("INSERT IGNORE INTO %s.%s (email, product_id, name, date) values('%s',%d, '%s', '%s')", VBox::get('ConstData')->getConst('langsDb'), $table_name, $_POST['email'], $_POST['product'], $name, date('Y-m-d')); DB::executeAlter($q, 'reg'); } if (!empty($_POST['notify']) && !empty($_POST['email']) && !empty($_POST['product'])) { $table_name = 'notify_users'; $q = 'SELECT * FROM ' . VBox::get('ConstData')->getConst('langsDb') . '.' . $table_name . ' WHERE nu_product_id = ? AND nu_email = ? LIMIT 1'; if (!DB::executeQuery($q, 'selectNotifyUser', array($_POST['product'], trim($_POST['email'])))) { $q = sprintf("INSERT IGNORE INTO %s.%s (nu_email, nu_product_id, nu_name, nu_date) values('%s',%d, '%s', '%s')", VBox::get('ConstData')->getConst('langsDb'), $table_name, trim($_POST['email']), $_POST['product'], $_POST['name'], date('Y-m-d h:i:s', time())); DB::executeAlter($q, 'reg'); } } if (isset($_POST['mail_body'])) { $mail_body = nl2br($_POST['mail_body']); $reply_to = isset($_POST['reply_to']) ? $_POST['reply_to'] : '*****@*****.**'; include_once ENGINE_PATH . 'class/classEmailReporter.php'; $reporter = new EmailReporter(); $reporter->setBody($mail_body); $reporter->send($this->formData['fields']['email'], array($reply_to => 'NetSpot'), $subject); } if (!empty($_POST['notify_template_stat']) && !empty($_POST['email']) && !empty($_POST['alias'])) { $table_name = 'email_stat'; /* add information at stat table */ $q = sprintf("INSERT INTO %s.%s (es_email, es_product_id, es_date) values('%s','%s','%s')", VBox::get('ConstData')->getConst('langsDb'), $table_name, $_POST['email'], $_POST['alias'], date('Y-m-d h:i:s', time())); DB::executeAlter($q, 'notify_template_stat'); if (!empty($_POST['template'])) { $last_id = DB::getLastInsertId(); if ($last_id) { include_once ENGINE_PATH . 'class/classEmailReporter.php'; $reporter = new EmailReporter(); $_subject = isset($_POST['templateSubject']) ? $_POST['templateSubject'] : 'Thank you for subscription'; $args = array(); $args['email'] = $_POST['email']; $args['hash'] = hash_hmac('md5', $last_id . $_POST['email'], 'stat'); $args['id'] = $last_id; $args['random'] = rand(0, 10000) . chr(rand(65, 90)); if (isset($_POST['args'])) { $args = $_POST['args']; } $mail_body = $reporter->renderingTpl($_POST['template']); $reporter->setBody($mail_body, $args); $reply_to = isset($_POST['reply_to']) ? $_POST['reply_to'] : '*****@*****.**'; $reporter->send($this->formData['fields']['email'], array($reply_to => 'NetSpot Software'), $_subject); } } } if (!empty($_POST['mailchimp_u']) && !empty($_POST['mailchimp_id'])) { $mailchimp_post_url = 'http://netspotapp.us12.list-manage.com/subscribe/post'; //netspotapp.us12.list-manage.com/subscribe/post?u=49afa3dbcd460871845fac4b8&id=df296d03d7 $attributes = array('u' => $_POST['mailchimp_u'], 'id' => $_POST['mailchimp_id'], 'MERGE0' => $_POST['email'], 'MERGE1' => isset($_POST['name']) ? $_POST['name'] : '', 'MERGE2' => ''); $errno = $error = false; if ($curl = curl_init()) { curl_setopt($curl, CURLOPT_URL, $mailchimp_post_url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($attributes)); $out = curl_exec($curl); $info = curl_getinfo($curl); $errno = curl_errno($curl); $tickets_hasError = curl_error($curl); curl_close($curl); // echo $out; // var_dump($info); // var_dump($errno); //var_dump($tickets_hasError); } } if (empty($_POST['not_send'])) { $fromEmail = empty($this->formData['fields']['email']) ? '*****@*****.**' : $this->formData['fields']['email']; $fromName = empty($this->formData['fields']['name']) ? $fromEmail : $this->formData['fields']['name']; $form->SendMail($subject, $msg, $fromName, $fromName . ' <' . $fromEmail . '>', $filePath, $fileName); } } } }
public function getParentPageAddress($page_id = NULL) { $page_id = $page_id ? $page_id : $this->parentPageId; $q = 'SELECT pg_address FROM ' . $this->siteDb . 'pages WHERE pg_id = ? LIMIT 1'; DB::executeQuery($q, 'parent_page_data', array($page_id)); if ($row = DB::fetchRow('parent_page_data')) { return $row['pg_address']; } }
public function isNewIp() { // $this->userIpData=Yii::app()->db->createCommand() // ->select('*') // ->from('{{request_limits}}') // ->where('request_limits_user_ip=:_ip', array(':_ip'=>$this->getIp())) // ->queryRow(); $q = 'SELECT * FROM ' . $this->dbName . 'request_limits WHERE request_limits_user_ip = ?'; DB::executeQuery($q, 'ip', array($this->getIp())); $this->userIpData = DB::fetchRow('ip'); if (!$this->userIpData) { // $insert=Yii::app()->db->createCommand() // ->insert('{{request_limits}}',array( // 'request_limits_user_ip'=>$this->getIp(), // 'request_limits_time'=>round(microtime(true)*1000), // 'request_limits_count' => '1', // 'request_limits_status'=>self::STATUS_OPEN // )); $data = array($this->getIp(), round(microtime(true) * 1000), '1', self::STATUS_OPEN); $q = 'INSERT INTO ' . $this->dbName . 'request_limits (request_limits_user_ip,request_limits_time,request_limits_count,request_limits_status) values(?,?,?,?) '; DB::executeAlter($q, $data); return true; } else { if (!$this->isLimited()) { $this->previousRequestTime = $this->userIpData['request_limits_time']; $this->userIpData['request_limits_time'] = round(microtime(true) * 1000); $leftTime = $this->userIpData['request_limits_time'] - $this->previousRequestTime; if ($leftTime > $this->limitTime) { $this->userIpData['request_limits_count'] = 1; } else { $this->userIpData['request_limits_count'] = $this->userIpData['request_limits_count'] + 1; } // $update=Yii::app()->db->createCommand() // ->update('{{request_limits}}', // array( // 'request_limits_time' => $this->userIpData['request_limits_time'], // 'request_limits_count'=> $this->userIpData['request_limits_count'] // ), // 'request_limits_user_ip=:_ip', // array( ':_ip'=>$this->getIp() ) // ); $data = array($this->userIpData['request_limits_time'], $this->userIpData['request_limits_count'], $this->getIp()); $q = 'UPDATE ' . $this->dbName . 'request_limits SET request_limits_time = ?, request_limits_count = ? WHERE request_limits_user_ip = ?'; DB::executeAlter($q, $data); } return false; } }
protected function call_details() { $product_id = $this->getParam('p') ? urldecode($this->getParam('p')) : ''; $where = ''; if ($this->getParam('from')) { $from = $this->getParam('from'); $where .= " AND es_date >='{$from}'"; $this->smarty->assign('from', $from); } if ($this->getParam('to')) { $to = $this->getParam('to'); $where .= " AND es_date <='{$to}'"; $this->smarty->assign('to', $to); } //$join = ' LEFT JOIN '.$db_name.'.products as p on p.p_id = t.es_product_id'; $join = ''; $q = 'SELECT es_email, es_product_id as product_id, COUNT(es_email) as count_send, SUM(es_count_open) as count_open, SUM(es_count_click) as count_click, MIN(es_date) as start_date FROM ' . $this->table_name . ' as t ' . $join . ' WHERE ((es_product_id = ? AND ? <> "") OR ( ? = "" )) ' . $where . ' GROUP BY es_email ORDER BY es_product_id'; if (DB::executeQuery($q, 'details', array($product_id, $product_id, $product_id))) { $q = 'SELECT MIN(es_date) as min_date, MAX(es_date) as max_date FROM ' . $this->table_name . ' WHERE ((es_product_id = ? AND ? <> "") OR ( ? = "" ))'; if (DB::executeQuery($q, 'maccdetails', array($product_id, $product_id, $product_id))) { $dates = DB::fetchResults('maccdetails'); $this->smarty->assign('min_date', $dates[0]['min_date']); $this->smarty->assign('max_date', $dates[0]['max_date']); } $rows = DB::fetchResults('details'); if (count($rows) == 0) { $vars['alert'] = 'Empty result'; $vars['page_title'] = "Empty SQL result"; $this->smarty->assign('vars', $vars); $this->to_print(); } else { /* $result[0] = array('email' => 'Email address', 'product_name' => 'Product', 'product_sent' => 'Sum send', 'count_open'=>'Sum open', 'count_click'=>'Sum clicks', 'start_date'=>'Start date');*/ $result[0] = array('email' => 'Email address', 'product_name' => 'Product', 'product_sent' => 'Sum send', 'start_date' => 'Start date'); foreach ($rows as $row) { /* $result[] = array('email' => $row['es_email'], 'product_name' => $row['product_id'], 'product_sent' => $row['count_send'], 'count_open' => $row['count_open'], 'count_click' => $row['count_click'], 'start_date' => $row['start_date']);*/ $result[] = array('email' => $row['es_email'], 'product_name' => $row['product_id'], 'product_sent' => $row['count_send'], 'start_date' => $row['start_date']); } if ($this->getParam('getcsv')) { include_once CLASSES . 'CsvExporter.php'; $filename = 'notify-users-' . date('Y-m-d') . '.csv'; ob_end_clean(); CsvExporter::sendArrayAsCSV($result, false, $filename); } else { $vars['file'] = 'reports/details.tpl'; $vars['data'] = $result; $vars['page_title'] = "General report"; $this->smarty->assign('vars', $vars); $this->to_print(); } } } else { $vars['file'] = 'reports/details.tpl'; $vars['alert'] = '<strong>SQL error!</strong> Something happened!'; $vars['page_title'] = "SQL error"; $this->smarty->assign('vars', $vars); $this->to_print(); } }
public function add_to_user_position_list($addr, $lat, $lng) { $db = new DB(); $db->connect(); $cuid = Utils::getCurrentUserID(); $sql = "select count(*) cnt from user_postion_list where uid = {$cuid}"; Logger::getRootLogger()->debug("sql = " . $sql); $res = $db->executeQuery($sql); while ($row = mysqli_fetch_assoc($res)) { if ($row['cnt'] >= 5) { $response = new Response(); $response->status = Response::STATUS_ERROR; $response->error_code = "0030"; $response->message = "地址收藏数量达到上限"; return $response; } } $sql = "insert into user_postion_list(addr, lat,uid, lng) values('" . $addr . "', '" . $lat . "', '" . $cuid . "', '" . $lng . "')"; Logger::getRootLogger()->debug("sql = " . $sql); $response = $db->executeUpdateAndInsert($sql); if (!is_numeric($response)) { return $response; } $response = new Response(); $response->status = Response::STATUS_OK; $response->message = "恭喜您更新地址收藏列表成功"; return $response; }
public function sendPassword($email) { $pass = substr(md5(mt_rand(1, 1000000)), 0, 12); $q = 'SELECT user_id FROM ' . $this->siteDb . 'update_subscribers WHERE user_email = ? LIMIT 1'; $result = DB::executeQuery($q, 'email', array($email)); $row = DB::fetchResults('email'); if (is_array($row) && count($row) > 0) { $q = 'UPDATE ' . $this->siteDb . 'update_subscribers SET user_pass = ? WHERE user_email = ?'; DB::executeAlter($q, array($pass, $email)); $msg = "Hi there,\n\nYour new unsubscription password is: " . $pass . "\n\nThank you very much for your interest in our solutions!\nYours, Garbagecat Software Team"; $this->sendMailUp($email, $msg); return $row[0]['user_id'] + 0; } else { return 0; } }
Error::$pathToFile = LOCAL_PATH . 'logs/sitemap.log'; Error::setFileLogging(TRUE); DB::initialize('mysql', 'localhost', NULL, 'venginse_admin', 'venginse', 'YqPffTfB'); DB::executeQuery('SET NAMES utf8', 'cp_utf8'); $q = 'SELECT s_hostname, s_dbname, s_path, s_gziped FROM sites WHERE s_indexed = 1'; DB::executeQuery($q, 'sites'); $rows = DB::fetchResults('sites'); if (!empty($rows)) { $tsize = sizeof($rows); $Sitemap = new SitemapGenerator('venginse_all'); for ($i = 0; $i < $tsize; $i++) { $q = 'SELECT c_value FROM ' . $rows[$i]['s_dbname'] . '.const WHERE c_name = "siteClosed" LIMIT 1'; DB::executeQuery($q, 'close'); $row = DB::fetchOne('close'); if ($row == '0') { $Sitemap->setParams($rows[$i]); if ($Sitemap->buildSitemap()) { $Sitemap->writeSitemap(); $Sitemap->submitSitemap(); } sleep(100); } } unset($Sitemap); } Error::deInitialize(); DB::deInitialize();
public function getUserID($user_infor) { $db = new DB(); $db->connect(); $sql = "select * from user where name ='" . $user_infor["name"] . "' and password = '******'password']) . "'"; Logger::getRootLogger()->debug("sql = " . $sql); $res = $db->executeQuery($sql); if ($res->num_rows == 0) { $res->close(); $response = new Response(); $response->status = Response::STATUS_ERROR; $response->error_code = "0011"; $response->message = "密码错误"; return $response; } Logger::getRootLogger()->debug("res = " . Utils::var2str($res)); }
public function checkEmail($email = null, $table = 'blacklist_email') { $callback = array('status' => YES, 'data' => ''); /* answer if email domain no trust */ $email = trim($email); $domain = end(explode('@', $email)); if (empty($email)) { $callback['data'] = '1'; return $callback; } if (!self::checkRegEmail($email)) { $callback['data'] = '1'; return $callback; } if (isset($email)) { $time = time(); $q = 'SELECT * FROM ' . $this->db . '.' . $table . ' WHERE be_domain = ? AND be_date > ? LIMIT 1'; if (DB::executeQuery($q, 'selecttrushdomain', array($domain, $time - $this->blacklistTimeOld))) { $row = DB::fetchRow('selecttrushdomain'); if ($row['be_status']) { $callback['data'] = self::localeText('Please, try another email address', 'please_try_another_email_address'); return $callback; } else { return null; } } /* //for NameApi API if($this->connected && false) { $deaDetector = self::$service->emailServices()->disposableEmailAddressDetector(); $result = $deaDetector->isDisposable($email); $result = $result->getDisposable()->__toString(); if ($result == $callback['status']) { $q = 'insert into '.$this->db.'.'.$table.' (be_domain,be_date) values(\''.$domain.'\','.time().')'; DB::executeAlter($q, 'inserttrushdomain'); $callback['data'] = self::localeText('Please, try another email address', 'please_try_another_email_address'); return $callback; } }// end */ //for NameApi API if ($this->connected) { $result = $this->mashapeCheckEmail($email); if ($result) { $q = 'INSERT INTO ' . $this->db . '.' . $table . ' (be_domain,be_status,be_date) values(\'' . $domain . '\',' . $result['status'] . ' ,' . $time . ') ON DUPLICATE KEY UPDATE be_status = ' . $result['status'] . ' , be_date = ' . $time . ''; DB::executeAlter($q, 'inserttrushdomain'); if ($result['status']) { $callback['data'] = self::localeText('Please, try another email address', 'please_try_another_email_address'); return $callback; } } } // end } return null; }
private function includeGlobalExtensions() { $q = 'SELECT ext_id, ext_name, ext_nick FROM ' . $this->siteDb . 'extensions WHERE ext_type = "G" AND ext_blocked = 0'; DB::executeQuery($q, 'gexts_data'); $result = DB::fetchResults('gexts_data'); foreach ($result as $row) { $this->extensions[$row['ext_nick']] = $row['ext_id']; if (file_exists($this->localPath . 'application/globalExt/' . $row['ext_nick'] . '/index.php')) { include_once $this->localPath . 'application/globalExt/' . $row['ext_nick'] . '/index.php'; } } }
public function getProductByFile($file = null, $callback = true) { if (isset($file)) { $rows = array(); $q = 'SELECT p_id, p_title, p_version, p_faq_link, p_wiki_link, p_download, p_downloads FROM ' . VBox::get('ConstData')->getConst('langsDb') . '.products WHERE p_download LIKE \'%' . $file . '%\' LIMIT 1'; DB::executeQuery($q, 'prods'); $rows = DB::fetchRow('prods'); if ($rows) { if ($callback) { return $rows; } return true; } } return false; }
public function _rebuildAllCache() { $this->renameCacheDir(); $sql = 'select pg_id from pages where pg_cacheable=1 and pg_hidden=0'; DB::executeQuery($sql, 'all_pages_data'); $results = DB::fetchResults('all_pages_data'); if (!empty($results)) { foreach ($results as $row) { $this->rebuildCachePageAdress($row['pg_id']); } } //$this->flushLog(); }