/** Lấy đường dẫn nhóm media */ function get_media_group_part($id = 0, $i = 1, $deepest = FALSE) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); if (!is_numeric($id)) { $tableName = DB_PREFIX . 'media_groups'; $whereArray = array('folder' => MySQL::SQLValue($id)); $hmdb->SelectRows($tableName, $whereArray); $row = $hmdb->Row(); $id = $row->id; } $bre = array(); $sub_bre = FALSE; if ($deepest == FALSE) { $deepest = $id; } $tableName = DB_PREFIX . 'media_groups'; $whereArray = array('id' => MySQL::SQLValue($id)); $hmdb->SelectRows($tableName, $whereArray); $row = $hmdb->Row(); $num_rows = $hmdb->RowCount(); if ($num_rows != 0) { $this_id = $row->id; $folder = $row->folder; $parent = $row->parent; $bre['level_' . $i] = $folder; if ($parent != '0') { $inew = $i + 1; $sub_bre = get_media_group_part($parent, $inew, $deepest); } } if (is_array($sub_bre)) { $bre = array_merge($bre, $sub_bre); } krsort($bre); $part = implode("/", $bre); if ($deepest == $id) { return $part; } else { return $bre; } }
/** Đăng nhập admin cp */ function admin_cp_login() { global $hmuser; $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('admin_cp_login'); $user_login = hm_post('login'); $password = hm_post('password'); $logmein = hm_post('log-me-in'); if (is_numeric($logmein)) { $tableName = DB_PREFIX . "users"; $whereArray = array('user_login' => MySQL::SQLValue($user_login)); $hmdb->SelectRows($tableName, $whereArray); if ($hmdb->HasRecords()) { $row = $hmdb->Row(); $salt = $row->salt; $user_pass = $row->user_pass; $password_encode = hm_encode_str(md5($password . $salt)); if ($password_encode == $user_pass) { $time = time(); $ip = hm_ip(); $cookie_array = array('time' => $time, 'ip' => $ip, 'user_login' => $user_login, 'admincp' => 'yes'); $cookie_user = hm_encode_str($cookie_array); setcookie('admin_login', $cookie_user, time() + COOKIE_EXPIRES, '/'); $_SESSION['admin_login'] = $cookie_user; return json_encode(array('status' => 'success', 'mes' => _('Đăng nhập thành công'))); } else { return json_encode(array('status' => 'error', 'mes' => _('Sai mật khẩu'))); } } else { return json_encode(array('status' => 'error', 'mes' => _('Không có tài khoản này'))); } } }
/** * returns array of all users * [userID] => 23103741 * [name] => admin * [mail] => 0 * [active] => 0 * * @param int $trash * @param array $groups list of group ids the users must be a member of * @return array * @author th */ public function get_users($trash = 0, array $groups = null) { $p = $this->kga['server_prefix']; $trash = MySQL::SQLValue($trash, MySQL::SQLVALUE_NUMBER); if (empty($groups)) { $query = "SELECT * FROM {$p}users\n WHERE trash = {$trash}\n ORDER BY name ;"; } else { $query = "SELECT DISTINCT u.* FROM {$p}users AS u\n JOIN {$p}groups_users AS g_u USING(userID)\n WHERE g_u.groupID IN (" . implode($groups, ',') . ") AND\n trash = {$trash}\n ORDER BY name ;"; } $this->conn->Query($query); $rows = $this->conn->RowArray(0, MYSQLI_ASSOC); $i = 0; $arr = array(); $this->conn->MoveFirst(); while (!$this->conn->EndOfSeek()) { $row = $this->conn->Row(); $arr[$i]['userID'] = $row->userID; $arr[$i]['name'] = $row->name; $arr[$i]['globalRoleID'] = $row->globalRoleID; $arr[$i]['mail'] = $row->mail; $arr[$i]['active'] = $row->active; $arr[$i]['trash'] = $row->trash; if ($row->password != '' && $row->password != '0') { $arr[$i]['passwordSet'] = "yes"; } else { $arr[$i]['passwordSet'] = "no"; } $i++; } return $arr; }
return FALSE; } } function get_uri_data($args) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); if (!is_array($args)) { parse_str($args, $args); } if (isset($args['uri'])) { $uri = $args['uri']; } else { $uri = FALSE; } if (isset($args['id'])) { $id_uri = $args['id']; } else { $id_uri = FALSE; } $tableName = DB_PREFIX . "request_uri"; if (is_numeric($id_uri)) { $whereArray = array('id' => MySQL::SQLValue($id_uri)); } else { $whereArray = array('uri' => MySQL::SQLValue($uri)); } $hmdb->SelectRows($tableName, $whereArray); if ($hmdb->HasRecords()) { $row = $hmdb->Row(); return $row; } else {
public function dupeCheck($name) { $db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH'); $q = $db->Query("SELECT `id` FROM `users`"); $allrecords = $db->RowCount(); $q = $db->Query("SELECT `id` FROM `users` WHERE `name` LIKE '" . $name . "';"); if ($db->RowCount() > 0) { $dupes = $db->Row()->id; } else { $dupes = 0; } return array('total' => $allrecords, 'dupe' => $dupes); }
function list_plugin($active = 1) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); $tableName = DB_PREFIX . "plugin"; $whereArray = array('active' => MySQL::SQLValue($active, MySQL::SQLVALUE_NUMBER)); $hmdb->SelectRows($tableName, $whereArray); if ($hmdb->HasRecords()) { while ($row = $hmdb->Row()) { $return[] = $row->key; } return json_encode($return); } else { return array(); } }
function chapter_show_data($id) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('chapter_show_data'); if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `status` = 'chapter' AND `parent` = '{$id}' ORDER BY id DESC")) { $hmdb->Kill(); } $array_cha = array(); while ($row = $hmdb->Row()) { $data_cha = content_data_by_id($row->id); $array_cha[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug, 'public_time' => date('d-m-Y H:i', $data_cha['field']['public_time'])); } $array['chapter'] = $array_cha; return hook_filter('chapter_show_data', json_encode($array, TRUE)); }
function request_suggest($key) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); global $hmtaxonomy; global $hmcontent; $return = ''; $input_name = hm_post('input', ''); $key = trim($key); $key = str_replace(' ', '-', $key); if ($key != '') { $tableName = DB_PREFIX . 'request_uri'; $hmdb->Query("SELECT * FROM `" . $tableName . "` WHERE `uri` LIKE '%" . $key . "%' LIMIT 10"); while ($row = $hmdb->Row()) { $id = $row->id; $object_id = $row->object_id; $object_type = $row->object_type; $uri = $row->uri; $suggest_label = ''; $object_name = ''; switch ($object_type) { case 'taxonomy': $tax_data = taxonomy_data_by_id($object_id); $tax_key = $tax_data['taxonomy']->key; $taxonomy = $hmtaxonomy->hmtaxonomy; $suggest_label = $taxonomy[$tax_key]['taxonomy_name']; $object_name = get_tax_val('name=name&id=' . $object_id); break; case 'content': $con_data = content_data_by_id($object_id); $con_key = $con_data['content']->key; $content = $hmcontent->hmcontent; $suggest_label = $content[$con_key]['content_name']; $object_name = get_con_val('name=name&id=' . $object_id); break; } $return .= '<li>'; $return .= '<p data-id="' . $id . '" data-input="' . $input_name . '" data-name="' . $object_name . '" object_id="' . $object_id . '" object_type="' . $object_type . '">'; $return .= '<span class="suggest_label">' . $suggest_label . ': </span><b>' . $object_name . '</b>'; $return .= '</p>'; $return .= '</li>'; } } return $return; }
function backupDatabase($dbName, $backupStructure = true, $backupData = true, $backupFile = null) { $columnName = 'Tables_in_' . $dbName; $this->done = false; $this->output .= "-- SQL Dump File \n"; $this->output .= "-- Generation Time: " . date('M j, Y') . " at " . date('h:i:s A') . " \n\n"; $this->output .= "-- \n"; $this->output .= "-- Database: `{$dbName}` \n"; $this->output .= "-- \n\n"; $conn = new MySQL(true, DBNAME, DBHOST, DBUSER, DBPASS, "", true); $strTables = 'SHOW TABLES'; $conn->Query($strTables); $cntTables = $conn->RowCount(); if ($cntTables) { $conn->MoveFirst(); while (!$conn->EndOfSeek()) { $rsTables = $conn->Row(); if ($backupStructure) { $this->dumpTableStructure($rsTables->{$columnName}); } if ($backupData) { $this->dumpTableData($rsTables->{$columnName}); } } } else { $this->output .= "-- \n"; $this->output .= "-- No tables in {$dbName} \n"; $this->output .= "-- \n"; } if (!is_null($backupFile)) { $this->dumpToFile($backupFile); } $this->done = true; }
// while showing the last MySQL error. if ($db->Error()) { $db->Kill(); } // Or use: if ($db->Error()) die($db->Error()); // Or: if ($db->Error()) echo $db->Error(); // Execute our query if (!$db->Query("SELECT * FROM Test")) { $db->Kill(); } // Let's show how many records were returned echo $db->RowCount() . " records returned.<br />\n<hr />\n"; // Loop through the records using the MySQL object (prefered) $db->MoveFirst(); while (!$db->EndOfSeek()) { $row = $db->Row(); echo "Row " . $db->SeekPosition() . ": "; echo $row->Color . " and " . $row->Age . "<br />\n"; } // ========================================================================= // The rest of this tutorial covers addition methods of getting to the data // and is completely optional. // ========================================================================= echo "<hr />\n"; // --------------------------------------------------------- // Loop through the records using a counter and display the values for ($index = 0; $index < $db->RowCount(); $index++) { $row = $db->Row($index); echo "Index " . $index . ": "; echo $row->Color . " and " . $row->Age . "<br />\n"; }
/** * Metodo per a creazione del file di indirizzi (indirizzi fatturazione - spedizione) */ function getIndirizzi() { /* * La richiesta � quella di gestire anche un 4� file, denominato FWINDIRIZZI, che contenga tutti gli indirizzi di spedizione. * * */ $query = "SELECT \n\t\tid_address,\n\t customer_code,\n\t\tcompany,\n\t\tfirstname,\n\t\tlastname,\n\t\tCONCAT(address1, ' ', address2) as full_address,\n\t\tpostcode,\n\t\tcity,\n\t\tstate_name,\n\t\tphone,\n\t\tphone_mobile,\n\t\tvat_number\n\t\t\n\t\tFROM ps_address \n\t\tLEFT JOIN (SELECT code as customer_code, id_customer from ps_customer) AS ps_customer_joined ON ps_customer_joined.id_customer = ps_address.id_customer\n\t\tLEFT JOIN (SELECT name as state_name, id_state from ps_state) as ps_state_joined ON ps_state_joined.id_state = ps_address.id_state\n\t\t\n\t\tWHERE ((synch = 0)AND(NOT(alias LIKE 'fatturazione')))"; $db = new MySQL(); $db->Query($query); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } foreach ($row as $anag) { /* DOC: 2.1) TABELLA FWINDIRIZZI (1) La tabella FWINDIRIZZI potr� avere un tracciato record ricavato da quello della tabella �ps_address� di Presta Shop: Campo Valori Chiave Descrizione campo ID_Address int si Numero univoco indirizzo CdCustomer char(50) no Codice del cliente, ricavato dalla tabella ps_customer Company char(64) no Ragione sociale Cognome char(32) no Cognome, da concatenare con Nome e importare in DestDiv.Des2Dest Nome char(32) no Vedi sopra Address char(128) no Indirizzo Zip char(12) no Codice Avviamento Postale City char(64) no Localit� NB. -> ripetizione. elimino => City char(64) no Localit� Prov char(5) no Sigla Provincia, ricavato da ID_State o ID_Country ? Phone char(32) no Telefono PhoneMob char(32) no Cellulare, da importare in Contatto VATnum char(32) no Partita IVA */ $stringa = null; $stringa[] = $anag->id_address; $stringa[] = $anag->customer_code; $stringa[] = !empty($anag->company) ? $anag->company : "-Senza Ragione Sociale-"; $stringa[] = !empty($anag->lastname) ? $anag->lastname : "-Senza Cognome-"; $stringa[] = !empty($anag->firstname) ? $anag->firstname : "-Senza Nome-"; $stringa[] = !empty($anag->full_address) ? $anag->full_address : "-Senza Indirizzo-"; $stringa[] = $anag->postcode; $stringa[] = $anag->city; $stringa[] = $anag->state_name; $stringa[] = $anag->phone; $stringa[] = $anag->phone_mobile; $stringa[] = !empty($anag->vat_number) ? $anag->vat_number : "-Senza Partita Iva-"; file_put_contents($this->fileFWINDIRIZZI, iconv(mb_detect_encoding(implode("§", $stringa), mb_detect_order(), true), "UTF-8", implode("§", $stringa)) . "\r\n", FILE_APPEND); $this->setAnagraficaSynchronized($anag->id_address); /* $stringa = null; $stringa[] = $this->fillCodeClientiWithZero($this -> getCodeClienti(), $anag -> id_customer); // CDute [0] $appo = null; $appo = $this -> getSIngleAnagFromId($anag -> id_customer); if (!empty($appo -> company)) { $stringa[] = $appo -> company; // DSRaso [1] } else { $stringa[] = "-Senza Ragione Sociale-"; } if (!empty($anag -> lastname)) { $stringa[] = $anag -> lastname; // DSCognome [2] } else { $stringa[] = "-Senza Cognome-"; } if (!empty($anag -> firstname)) { $stringa[] = $anag -> firstname; // DSnome [3] } else { $stringa[] = "-Senza Nome-"; } if (!empty($appo -> vat_number)) { $stringa[] = $appo -> vat_number; // DSpiva [4] } else { $stringa[] = "-Senza Partita Iva-"; } if (!empty($appo -> dni)) { $stringa[] = $appo -> dni; // DScod_fis [5] } else { $stringa[] = "-Senza Codice Fiscale-"; } $stringa[] = $appo -> address1; // DSindi [6] $stringa[] = $appo -> postcode; // DScap [7] $stringa[] = $appo -> city; // DSloca [8] $stringa[] = $this -> getStateFromId($appo -> id_state); //$stringa[] = ""; // DSprov [9] $stringa[] = $appo -> phone; // DStel [10] $stringa[] = $appo -> phone_mobile; // DScell [11] $stringa[] = ""; // DSfax [12] $stringa[] = $anag -> email; // DSemail [13] $stringa[] = ""; // null [14] $stringa[] = ""; // null [15] $stringa[] = "IT"; // DSnazione [16] $stringa[] = ""; // MMNota [17] $stringa[] = $anag -> email; // DSlogin [18] $stringa[] = ""; // DSpwd [19] * file_put_contents($this -> fileFWINDIRIZZI, iconv(mb_detect_encoding(implode("§", $stringa), mb_detect_order(), true), "UTF-8", implode("§", $stringa)) . "\r\n", FILE_APPEND); $this -> unselectSingleAnag($anag -> id_customer, $this->fillCodeClientiWithZero($this -> getCodeClienti(), $anag -> id_customer)); */ } }
function admin_cp_newpw() { global $hmuser; $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('newpw_checkkey'); $key = hm_post('key'); $password = hm_post('password'); $password2 = hm_post('password2'); if ($password == $password2) { $tableName = DB_PREFIX . "field"; $whereArray = array('name' => MySQL::SQLValue('lostpw_key'), 'object_type' => MySQL::SQLValue('user'), 'val' => MySQL::SQLValue($key)); $hmdb->SelectRows($tableName, $whereArray); $row = $hmdb->Row(); $user_id = $row->object_id; $salt = rand(100000, 999999); $password_encode = hm_encode_str(md5($password . $salt)); $tableName = DB_PREFIX . "users"; $updateArray = array('user_pass' => MySQL::SQLValue($password_encode), 'salt' => MySQL::SQLValue($salt)); $whereArray = array('id' => MySQL::SQLValue($user_id, MySQL::SQLVALUE_NUMBER)); $hmdb->UpdateRows($tableName, $updateArray, $whereArray); return json_encode(array('status' => 'success', 'mes' => _('Đã đổi mật khẩu thành công'))); } else { return json_encode(array('status' => 'error', 'mes' => _('Hai mật khẩu bạn nhập vào không khớp'))); } }
/** * Metodo utilizzato per recuperare tutti gli utenti attivi in Prestashop * * @return type */ function getEnabledCustomer() { $sql = "SELECT * FROM ps_customer WHERE active = 1"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $appoRow = $db->Row(); $row[] = $appoRow->id_customer; } } return $row; }
/** * Metodo che seleziona i gruppi dalla tabelal ps_group * @return Object Lista di strutture contenente id_group per ogni gruppo */ function getGroupId() { $db = new MySQL(); $sql = "SELECT id_group FROM ps_group"; $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } return $row; }
/** Trả về link thumbnail của file */ function thumbnail_media($id) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); if (isset($id) and is_numeric($id)) { $tableName = DB_PREFIX . "media"; $whereArray = array('id' => MySQL::SQLValue($id)); $hmdb->SelectRows($tableName, $whereArray); $rowCount = $hmdb->RowCount(); if ($rowCount != 0) { $row = $hmdb->Row(); $file_info = $row->file_info; $file_name = $row->file_name; $file_folder = $row->file_folder; if ($file_folder != '/') { $file_folder = '/' . $file_folder . '/'; } $file_info = json_decode($file_info, TRUE); if ($file_info['file_is_image'] == TRUE) { $thumbnail_src = SITE_URL . FOLDER_PATH . HM_CONTENT_DIR . '/uploads' . $file_folder . $file_info['thumbnail']; } else { $file_src_name_ext = strtolower($file_info['file_src_name_ext']); $file_ext_icon = './' . HM_CONTENT_DIR . '/icon/fileext/' . $file_src_name_ext . '.png'; if (file_exists($file_ext_icon)) { $thumbnail_src = SITE_URL . FOLDER_PATH . HM_CONTENT_DIR . '/icon/fileext/' . $file_src_name_ext . '.png'; } else { $thumbnail_src = SITE_URL . FOLDER_PATH . HM_CONTENT_DIR . '/icon/fileext/blank.png'; } } return $thumbnail_src; } } }
/** * returns expenses for specific user as multidimensional array * @TODO: needs comments * @param integer $users ID of user in table users * @param integer $start * @param integer $end * @param integer $filterCleared * @return array * @author th * @author Alexander Bauer */ public function get_expenses($start, $end, $users = null, $customers = null, $projects = null, $reverse_order = false, $filter_refundable = -1, $filterCleared = null, $startRows = 0, $limitRows = 0, $countOnly = false) { $conn = $this->conn; $kga = $this->kga; // -1 for disabled, 0 for only not cleared entries if (!is_numeric($filterCleared)) { $filterCleared = -1; if ($kga->getSettings()->isHideClearedEntries()) { $filterCleared = 0; } } $start = MySQL::SQLValue($start, MySQL::SQLVALUE_NUMBER); $end = MySQL::SQLValue($end, MySQL::SQLVALUE_NUMBER); $p = $kga['server_prefix']; $whereClauses = $this->dbLayer->timeSheet_whereClausesFromFilters($users, $customers, $projects); if (isset($kga['customer'])) { $whereClauses[] = "{$p}projects.internal = 0"; } if (!empty($start)) { $whereClauses[] = "timestamp >= {$start}"; } if (!empty($end)) { $whereClauses[] = "timestamp <= {$end}"; } if ($filterCleared > -1) { $whereClauses[] = "cleared = {$filterCleared}"; } switch ($filter_refundable) { case 0: $whereClauses[] = "refundable > 0"; break; case 1: $whereClauses[] = "refundable <= 0"; break; case -1: default: // return all expenses - refundable and non refundable } if (!empty($limitRows)) { $startRows = (int) $startRows; $limit = "LIMIT {$startRows}, {$limitRows}"; } else { $limit = ""; } $select = "SELECT expenseID, timestamp, multiplier, value, projectID, designation, userID, projectID,\n \t\t\t\t\tcustomerName, customerID, projectName, comment, refundable,\n \t\t\t\t\tcommentType, userName, cleared"; $where = empty($whereClauses) ? '' : "WHERE " . implode(" AND ", $whereClauses); $orderDirection = $reverse_order ? 'ASC' : 'DESC'; if ($countOnly) { $select = "SELECT COUNT(*) AS total"; $limit = ""; } $query = "{$select}\n \t\t\tFROM {$p}expenses\n\t \t\tJoin {$p}projects USING(projectID)\n\t \t\tJoin {$p}customers USING(customerID)\n\t \t\tJoin {$p}users USING(userID)\n\t \t\t{$where}\n\t \t\tORDER BY timestamp {$orderDirection} {$limit}"; $conn->Query($query); // return only the number of rows, ignoring LIMIT if ($countOnly) { $this->conn->MoveFirst(); $row = $this->conn->Row(); return $row->total; } $i = 0; $arr = array(); $conn->MoveFirst(); // toArray(); while (!$conn->EndOfSeek()) { $row = $conn->Row(); $arr[$i] = (array) $row; $i++; } return $arr; }
while (!$db->EndOfSeek()) { $row = $db->Row(); $dbd->Query($row->req); } $db->Query("update temprequet set stat=1 where stat=0"); // --------------------------------------------------- // Execute Remote requete on locoal server // --------------------------------------------------- global $db; $fullquery = "SELECT req,id from temprequet where stat=0 "; if (!$dbd->Query($fullquery)) { $dbd->Kill($dbd->Error()); } $nbrremotreq = $dbd->RowCount(); while (!$dbd->EndOfSeek()) { $row = $dbd->Row(); if (!$db->Query($row->req)) { $db->Kill($db->Error()); } else { $dbd->Query("update temprequet set stat=1 where id=" . $row->id); } } // --------------------------------------------------- // Insert log Last update // --------------------------------------------------- $nbrreq = $nbrlocalreq + $nbrremotreq; $lastmaj = "Insert into maj_sys(nbrreq,user)values({$nbrreq}," . $_SESSION['userid'] . ")"; if (!$db->Query($lastmaj)) { $db->Kill($lastmaj); } exit("ok");
function query_content($args = array()) { global $hmcontent; $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_filter('before_query_content', $args); hook_action('query_content'); if (!is_array($args)) { parse_str($args, $args); } /** Lọc theo content_key */ if (isset($args['content_key'])) { /** Nếu yêu cầu content key thì lấy các id có key như query yêu cầu */ $content_key = $args['content_key']; /** Nếu content key là một mảng */ if (is_array($content_key)) { $where_key = ''; $i = 0; foreach ($content_key as $key) { if ($i == 0) { $where_key .= " `key` = '" . $key . "' "; } else { $where_key .= " OR `key` = '" . $key . "' "; } $i++; } $where_content_key = "WHERE " . $where_key; } else { $where_content_key = "WHERE `key` = '" . $content_key . "'"; } } else { /** Không yêu cầu content key, kiểm tra xem có đang ở template taxonomy không */ if (is_taxonomy() == TRUE) { $taxonomy_id = get_id(); $content_key = taxonomy_get_content_key($taxonomy_id); if ($content_key != FALSE) { $where_content_key = "WHERE `key` = '" . $content_key . "'"; } } else { $where_content_key = ''; } } $hmdb->Release(); $query_content_key = "SELECT `id` FROM `" . DB_PREFIX . "content` " . $where_content_key; /** Lọc theo taxonomy */ $where_taxonomy = ''; if (isset($args['taxonomy'])) { /** Nếu yêu cầu trong một taxonomy nhất định thì lấy các object_id có relationship như query yêu cầu */ $taxonomy_id = $args['taxonomy']; /** Nếu taxonomy là một mảng */ if (is_array($taxonomy_id)) { $implode = implode($taxonomy_id, ','); if ($implode != '') { $where_taxonomy = ' WHERE `target_id` IN (' . $implode . ') '; } } else { $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id; } } else { /** Không yêu cầu taxonomy nhất định, kiểm tra xem có đang ở template taxonomy không */ if (is_taxonomy() == TRUE) { $taxonomy_id = get_id(); $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id; } } if ($where_taxonomy != '') { $hmdb->Release(); $query_in_taxonomy = "SELECT `object_id` FROM `" . DB_PREFIX . "relationship` " . $where_taxonomy . " AND `relationship` = 'contax'"; } /** Lọc theo field */ if (isset($args['field_query'])) { $field_query = $args['field_query']; } else { $field_query = array(array('field' => 'status', 'compare' => '=', 'value' => 'public'), array('field' => 'public_time', 'compare' => '<=', 'value' => time())); } $all_field_query = array(); foreach ($field_query as $item) { /** check đủ điều kiện tạo field query */ if (isset($item['field']) and isset($item['compare']) and isset($item['value'])) { $field = $item['field']; $compare = $item['compare']; $value = $item['value']; $numerically = FALSE; /** build query */ if (is_numeric($value)) { $value_query = $value; } else { $value_query = "'{$value}'"; } if ($compare == 'like%') { $all_field_query[$field] = " ( `name` = '{$field}' AND `val` LIKE '%{$value}%' )"; } else { $all_field_query[$field] = " ( `name` = '{$field}' AND `val` {$compare} {$value_query} )"; } } } /** nếu size của mảng chứa các kết quả của các field query >= 2 */ $size = sizeof($all_field_query); $query_field = "SELECT `object_id` FROM `" . DB_PREFIX . "field` WHERE"; if ($size > 1) { if (isset($args['field_query_relation'])) { $field_query_relation = $args['field_query_relation']; } else { $field_query_relation = 'and'; } switch ($field_query_relation) { case 'or': $i = 0; foreach ($all_field_query as $single_field_query) { if ($i == 0) { $query_field .= " " . $single_field_query . " "; } else { $query_field .= " OR " . $single_field_query . " "; } $i++; } break; case 'and': $i = 0; foreach ($all_field_query as $single_field_query) { if ($i == 0) { $query_field .= " " . $single_field_query . " "; } else { $query_field .= " OR " . $single_field_query . " "; } $i++; } $query_field .= " GROUP BY `object_id` HAVING COUNT(*) = {$size} "; break; } /** * Đưa ra kết quả dựa trên mối quan hệ giữa các field query ( field_query_relation ) * ( thỏa mãn tất cả các field query hay chỉ cần đáp ứng được 1 trong những field query ) */ } else { $query_field = $query_field . array_shift(array_values($all_field_query)); } /** Kiểm tra yêu cầu kết hợp kết quả từ content key, in taxonomy, field query là tất cả hay chỉ 1 */ if (isset($args['join'])) { $join = $args['join']; } else { $join = 'and'; } $query_join = ''; switch ($join) { case 'or': if ($query_content_key) { $query_join .= " AND `object_id` IN (" . $query_content_key . ") "; } if ($query_in_taxonomy) { $query_join .= " OR `object_id` IN (" . $query_in_taxonomy . ") "; } $query_join .= " OR `object_id` IN (" . $query_field . ") "; break; case 'and': if ($query_content_key) { $query_join .= " AND `object_id` IN (" . $query_content_key . ") "; } if ($query_in_taxonomy) { $query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") "; } $query_join .= " AND `object_id` IN (" . $query_field . ") "; break; default: if ($query_content_key) { $query_join .= " AND `object_id` IN (" . $query_content_key . ") "; } if ($query_in_taxonomy) { $query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") "; } $query_join .= " AND `object_id` IN (" . $query_field . ") "; } /** Kết thúc các query lấy các content id thỏa mãn yêu cầu */ /** Order theo 1 field và limit */ if (isset($args['order'])) { $order_by = $args['order']; } else { $order_by = 'public_time,desc,number'; } if (isset($args['limit'])) { $limit = $args['limit']; } else { $limit = get_option(array('section' => 'system_setting', 'key' => 'post_per_page', 'default_value' => '12')); } if (isset($args['offset']) and is_numeric($args['offset'])) { $offset = $args['offset']; } else { $offset = 0; } if (isset($args['paged'])) { $paged = $args['paged']; } else { $paged = get_current_pagination(); } $paged = $paged - 1; if ($paged < 0) { $paged = 0; } /** Tạo query ORDER */ $ex = explode(',', $order_by); $ex = array_map("trim", $ex); $order_field = $ex[0]; $order = strtoupper($ex[1]); if (isset($ex[2])) { $numerically = $ex[2]; } else { $numerically = FALSE; } if ($numerically == 'number') { $order_query = " AND `name` = '" . $order_field . "' ORDER BY CAST(val AS unsigned) " . $order . " "; } else { $order_query = " AND `name` = '" . $order_field . "' ORDER BY `val` " . $order . " "; } /** Tạo query LIMIT */ if (is_numeric($limit)) { $limit_query = " LIMIT {$limit} "; } else { $limit_query = ''; } /** Tạo query OFFSET */ if ($limit == FALSE) { $offset_query = ''; } else { $offset_query_page = $paged * $limit; $offset_query_page = $offset_query_page + $offset; $offset_query = " OFFSET {$offset_query_page} "; } /** Tạo câu lệnh select từ chuỗi các id thỏa mãn */ $result = array(); $sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " "; $hmdb->Query($sql); $total_result = $hmdb->RowCount(); $sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " " . $limit_query . " " . $offset_query . " "; $hmdb->Query($sql); $base = get_current_uri(); if ($base == '') { $base = '/'; } $hmcontent->set_val(array('key' => 'total_result', 'val' => $total_result)); $hmcontent->set_val(array('key' => 'paged', 'val' => $paged + 1)); $hmcontent->set_val(array('key' => 'perpage', 'val' => $limit)); $hmcontent->set_val(array('key' => 'base', 'val' => $base)); while ($row = $hmdb->Row()) { $result[] = $row->object_id; } return $result; }
$array = array('id' => $id, 'status' => TRUE); return json_encode($array); } function menu_select_choise($args = array()) { if (!is_array($args)) { parse_str($args, $args); } hook_action('menu_select_choise'); if (isset($args['checked'])) { $checked = $args['checked']; } else { $checked = 0; } if (isset($args['name'])) { $name = $args['name']; } else { $name = 'menu'; } $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); $tableName = DB_PREFIX . "object"; $whereArray = array('key' => MySQL::SQLValue('menu')); $hmdb->SelectRows($tableName, $whereArray); $rowCount = $hmdb->RowCount(); if (is_numeric($rowCount)) { $options[] = array('value' => '0', 'label' => 'Chọn một trình đơn'); while ($row = $hmdb->Row()) { $options[] = array('value' => $row->id, 'label' => $row->name); } $field_array['input_type'] = 'select'; $field_array['name'] = $name; $field_array['input_option'] = $options; $field_array['default_value'] = $checked; $field_array['addClass'] = 'choise_menu';
function taxonomy_checkbox_list($args = array()) { hook_action('taxonomy_checkbox_list'); hook_filter('taxonomy_checkbox_list_before', $args); global $hmtaxonomy; $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); @($key = $args['key']); @($parent = $args['parent'] ? $args['parent'] : 0); @($default_value = $args['default_value']); @($object_id = $args['object_id']); if (is_numeric($object_id)) { $tableName = DB_PREFIX . "relationship"; $whereArray = array('object_id' => MySQL::SQLValue($object_id), 'relationship' => MySQL::SQLValue('contax')); $hmdb->SelectRows($tableName, $whereArray); while ($row = $hmdb->Row()) { $default_value[] = $row->target_id; } } if (!is_array($default_value)) { $default_value = array(); } $tax = $hmtaxonomy->hmtaxonomy; if (isset($tax[$key])) { $tableName = DB_PREFIX . "taxonomy"; $whereArray = array('key' => MySQL::SQLValue($key), 'parent' => MySQL::SQLValue($parent), 'status' => MySQL::SQLValue('public')); $hmdb->SelectRows($tableName, $whereArray); if ($hmdb->HasRecords()) { if ($parent != 0) { echo '<ul class="taxonomy_tree_sub_group taxonomy_tree_sub_group_of_' . $parent . '">'; } while ($row = $hmdb->Row()) { $taxs[] = $row; } foreach ($taxs as $tax) { if (in_array($tax->id, $default_value)) { $checked = 'checked'; } else { $checked = ''; } echo '<li data-id="' . $tax->id . '" data-slug="' . $tax->slug . '" class="tax_tree_item tax_tree_item_' . $tax->id . '">'; echo '<input type="checkbox" name="taxonomy[]" value="' . $tax->id . '" ' . $checked . ' /> '; echo '<label>' . $tax->name . '</label>'; taxonomy_checkbox_list(array('key' => $key, 'parent' => $tax->id, 'default_value' => $default_value)); echo '</li>'; } if ($parent != 0) { echo '</ul>'; } } } }
<?php header("Content-type: text/xml"); $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); $sitemap = ''; $sitemap .= '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"; $sitemap .= '<?xml-stylesheet type="text/xsl" href="' . PLUGIN_URI . 'hm_seo/asset/sitemap.xsl"?>' . "\r\n"; $sitemap .= '<!-- generator="hoamaicms/1.0" -->' . "\r\n"; $sitemap .= '<!-- sitemap-generator-url="hoamaisoft.com" sitemap-generator-version="1.0" -->' . "\r\n"; $sitemap .= '<!-- generated-on="26.09.2015 12:11" -->' . "\r\n"; $sitemap .= '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n"; //loop $tableName = DB_PREFIX . "request_uri"; $hmdb->SelectRows($tableName, NULL, NULL, 'object_type', FALSE); while ($row = $hmdb->Row()) { $object_id = $row->object_id; $object_type = $row->object_type; $uri = $row->uri; $uri = urlencode($uri); switch ($object_type) { case 'content': $include_to_sitemap = get_con_val("name=include_to_sitemap&id={$object_id}"); $sitemap_change_frequency = get_con_val("name=sitemap_change_frequency&id={$object_id}"); $sitemap_priority = get_con_val("name=sitemap_priority&id={$object_id}"); $time = get_con_val("name=public_time&id={$object_id}"); $lastmod = '<lastmod>' . date('Y-m-d H:i:s', $time) . '</lastmod>'; if ($sitemap_change_frequency == 'auto') { $sitemap_change_frequency = get_option(array('section' => 'hm_seo', 'key' => 'content_sitemap_change_frequency', 'default_value' => 'daily')); } if ($sitemap_priority == 'auto') { $sitemap_priority = get_option(array('section' => 'hm_seo', 'key' => 'content_sitemap_priority', 'default_value' => '0.6'));
function getCategoryStringForLayeredTemplate() { $db = new MySQL(); $sql = "SELECT id_category FROM ps_category WHERE id_category > 1"; $result = $db->Query($sql); while (!$db->EndOfSeek()) { $row[] = $db->Row(); } $categoryArray = array(); foreach ($row as $id_category) { $categoryArray[] = $id_category->id_category; } return $categoryArray; }
function content_delete_permanently($id) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('content_delete_permanently'); if (is_numeric($id)) { /* xóa bảng content */ $tableName = DB_PREFIX . "content"; $whereArray = array('id' => MySQL::SQLValue($id)); $hmdb->DeleteRows($tableName, $whereArray); /** Tìm các sub content */ $whereArray = array('parent' => MySQL::SQLValue($id)); $hmdb->SelectRows($tableName, $whereArray); $ids = array(); while ($row = $hmdb->Row()) { $ids[] = $row->id; } foreach ($ids as $delete_id) { /** xóa các sub content */ $tableName = DB_PREFIX . "content"; $whereArray = array('id' => MySQL::SQLValue($delete_id)); $hmdb->DeleteRows($tableName, $whereArray); /** xóa các sub content field */ $tableName = DB_PREFIX . "field"; $whereArray = array('object_id' => MySQL::SQLValue($delete_id), 'object_type' => MySQL::SQLValue('content')); $hmdb->DeleteRows($tableName, $whereArray); /* xóa các relationship */ $tableName = DB_PREFIX . "relationship"; $whereArray = array('object_id' => MySQL::SQLValue($delete_id)); $hmdb->DeleteRows($tableName, $whereArray); /** xóa các sub request */ $tableName = DB_PREFIX . "request_uri"; $whereArray = array('object_id' => MySQL::SQLValue($delete_id)); $hmdb->DeleteRows($tableName, $whereArray); } /* xóa bảng field */ $tableName = DB_PREFIX . "field"; $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('content')); $hmdb->DeleteRows($tableName, $whereArray); /* xóa bảng relationship */ $tableName = DB_PREFIX . "relationship"; $whereArray = array('object_id' => MySQL::SQLValue($id)); $hmdb->DeleteRows($tableName, $whereArray); /* xóa bảng request uri */ $tableName = DB_PREFIX . "request_uri"; $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('content')); $hmdb->DeleteRows($tableName, $whereArray); } }
echo "Last ID inserted was: " . $db->GetLastInsertID() . "<br /><br />\n"; } else { $db->TransactionRollback(); echo "<p>Query Failed</p>\n"; } // --- Query and show the data -------------------------------------- // (Note: $db->Query also returns the result set) if ($db->Query("SELECT * FROM Test")) { echo $db->GetHTML(); } else { echo "<p>Query Failed</p>"; } // --- Getting the record count is easy ----------------------------- echo "\n<p>Record Count: " . $db->RowCount() . "</p>\n"; // --- Loop through the records ------------------------------------- while ($row = $db->Row()) { echo $row->Color . " - " . $row->Age . "<br />\n"; } // --- Loop through the records another way ------------------------- $db->MoveFirst(); while (!$db->EndOfSeek()) { $row = $db->Row(); echo $row->Color . " - " . $row->Age . "<br />\n"; } // --- Loop through the records with an index ----------------------- for ($index = 0; $index < $db->RowCount(); $index++) { $row = $db->Row($index); echo "Row " . $index . ":" . $row->Color . " - " . $row->Age . "<br />\n"; } // --- We can even grab array data from the last result set --------- $myArray = $db->RecordsArray();
/** * Resetta le immagini del prodotto * * @param int $id_product Id del prodotto */ function resetImages($id_product) { $sql = "SELECT id_image FROM ps_image WHERE id_product = {$id_product}"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } foreach ($row as $appoRow) { $this->reinitImageLang($appoRow->id_image); $this->reinitImageShop($appoRow->id_image); } } }
function startFillSpecificPrice() { $sql = "SELECT * FROM erp_sconti_scaglione ORDER BY priority ASC"; $db = new MySQL(); $db->Query($sql); $row = NULL; if ($db->RowCount() > 0) { while (!$db->EndOfSeek()) { $row[] = $db->Row(); } } $this->_GLOBAL_COUNTER = 0; foreach ($row as $sconto_erp) { $specific_price = new \stdClass(); $specific_price->priority = $sconto_erp->priority; if (!empty($sconto_erp->CDprodotto) and !empty($sconto_erp->CDanag)) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $cdanag = $sconto_erp->CDanag; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } else { if (!empty($sconto_erp->CDprodotto) and !empty($sconto_erp->Cdcatcli)) { foreach ($this->ERP_CATCUSTOMER[$sconto_erp->Cdcatcli] as $cdanag) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_customer != "" and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } else { if (!empty($sconto_erp->Cdcatart) and !empty($sconto_erp->CDanag)) { $arrayProductInCat = $this->getProductInsideCategory($sconto_erp->Cdcatart); if (!empty($arrayProductInCat) and count($arrayProductInCat) > 0) { foreach ($arrayProductInCat as $CdprodottoObj) { $cdprodotto = $CdprodottoObj->code; $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdanag = $sconto_erp->CDanag; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } } else { if (!empty($sconto_erp->Cdcatart) and !empty($sconto_erp->Cdcatcli)) { foreach ($this->ERP_CATCUSTOMER[$sconto_erp->Cdcatcli] as $cdanag) { $arrayProductInCat = $this->getProductInsideCategory($sconto_erp->Cdcatart); if (!empty($arrayProductInCat) and count($arrayProductInCat) > 0) { foreach ($arrayProductInCat as $CdprodottoObj) { $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $CdprodottoObj->code; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); $id_customer = $this->getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { //if (isset($this -> _GESTIONE_PREZZI[11][$cdprodotto . "-" . $cdanag])) { /* if (isset($this -> _MAPPING_ANAG_IDLISTINO[$cdanag]) and isset($this -> GROUP_LISTINI_BASE[$this -> _MAPPING_ANAG_IDLISTINO[$cdanag]][$cdprodotto] -> price)) { //$specific_price -> price = $this -> _GESTIONE_PREZZI[11][$cdprodotto . "-" . $cdanag] -> price; $specific_price -> price = $this -> GROUP_LISTINI_BASE[$this -> _MAPPING_ANAG_IDLISTINO[$cdanag]][$cdprodotto] -> price; } else { $specific_price -> price = -1; } */ if (PROPAPAGAZIONE_LISTINI_CLIENTI == 1 && isset($this->_APP1O_LIST_BASE[$cdanag])) { $appo_split = explode("_", $this->_APPO_LIST_BASE[$cdanag]); $id_listino = $appo_split[0]; $list_sconto = $appo_split[1]; $specific_price->price = $this->_GROUP_MISTO_PER_LISTINI[$id_listino][$list_sconto]['specific_price'][$cdprodotto]->price; } else { $specific_price->price = -1; } } $id_group = 0; if ($cdanag == "CCORRI") { $id_customer = null; $id_group = 1; } if ($id_product != null and $id_group == 1) { $this->checkIfExistsHighPriceRuleCCORRI($specific_price, $id_product); } if ($id_customer != null and $id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, $id_customer); } } } } } else { // sconti scaglione $infoReduction = explode(";", $this->calculateREduction(array($sconto_erp->NRsconto))); $cdprodotto = $sconto_erp->CDprodotto; $cdanag = 0; $specific_price->price = $sconto_erp->Nrprezzo; $specific_price->from_quantity = $sconto_erp->NRqtaLimite; $specific_price->reduction = $infoReduction[0]; if ($specific_price->reduction == 1) { $specific_price->reduction = 0; } $specific_price->reduction_type = "percentage"; if ($specific_price->reduction == 0) { $specific_price->reduction_type = "amount"; } $specific_price->from = $sconto_erp->Dtinizio; $specific_price->to = $sconto_erp->Dtfine; $specific_price->stringSconto = $infoReduction[1]; $specific_price->type = $sconto_erp->priority . "_" . $sconto_erp->id; $id_product = $this->getIdProductFromCode($cdprodotto); //$id_customer = $this -> getCustomerIdFromCode($cdanag); if ($sconto_erp->Nrprezzo == 0.0) { $specific_price->price = -1; } if (PROPAPAGAZIONE_LISTINI_CLIENTI == 0) { $specific_price->price = -1; } if ($id_product != null) { $this->checkIfExistsHighPriceRule($specific_price, $id_product, 0); } } } } } } }
/** bảng danh sách thành viên */ function user_show_data($user_group, $perpage) { $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('user_show_data'); $request_paged = hm_get('paged', 1); $paged = $request_paged - 1; $offset = $paged * $perpage; $limit = "LIMIT {$perpage} OFFSET {$offset}"; if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ORDER BY id DESC {$limit}")) { $hmdb->Kill(); } if ($hmdb->HasRecords()) { /* Trả về các user */ while ($row = $hmdb->Row()) { $array_use[] = array('id' => $row->id, 'user_nicename' => $row->user_nicename, 'user_role' => user_role_id_to_nicename($row->user_role)); } $array['user'] = $array_use; /* Tạo pagination */ $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' "); $total_item = $hmdb->RowCount(); $total_page = ceil($total_item / $perpage); $first = '1'; if ($request_paged > 1) { $previous = $request_paged - 1; } else { $previous = $first; } if ($request_paged < $total_page) { $next = $request_paged + 1; } else { $next = $total_page; } $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged); } else { $array['user'] = array(); $array['pagination'] = array(); } return hook_filter('user_show_data', json_encode($array, TRUE)); }