/**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     $length_class_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("length_classes") . " mc\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $this->db->table("length_class_descriptions") . " mcd\n\t\t\t\t\t\t\t\t\t\t\t\t\tON (mc.length_class_id = mcd.length_class_id)\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE mcd.language_id = '" . (int) $this->config->get('storefront_language_id') . "'");
     foreach ($length_class_query->rows as $result) {
         $this->lengths[strtolower($result['unit'])] = array('length_class_id' => $result['length_class_id'], 'unit' => $result['unit'], 'title' => $result['title'], 'value' => $result['value']);
     }
 }
Beispiel #2
0
 /**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     $sql = "SELECT *\n\t\t\t\tFROM " . DB_PREFIX . "weight_classes wc\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "weight_class_descriptions wcd\n\t\t\t\t\tON (wc.weight_class_id = wcd.weight_class_id)\n\t\t\t\tWHERE wcd.language_id = '" . (int) $this->config->get('storefront_language_id') . "'";
     $weight_class_query = $this->db->query($sql);
     foreach ($weight_class_query->rows as $result) {
         $this->weights[strtolower($result['unit'])] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
     }
 }
Beispiel #3
0
 /**
  * @param ADB $db
  * @param string $database_name
  */
 private function create_triggers($db, $database_name)
 {
     $tables_sql = "\n\t\t\tSELECT DISTINCT TABLE_NAME \n\t\t    FROM INFORMATION_SCHEMA.COLUMNS\n\t\t    WHERE COLUMN_NAME IN ('date_added')\n\t\t    AND TABLE_SCHEMA='" . $database_name . "'";
     $query = $db->query($tables_sql);
     foreach ($query->rows as $t) {
         $table_name = $t['TABLE_NAME'];
         $triger_name = $table_name . "_date_add_trg";
         $triger_checker = $db->query("SELECT TRIGGER_NAME\n\t\t\t\t\t\t\t\tFROM information_schema.triggers\n\t\t\t\t\t\t\t\tWHERE TRIGGER_SCHEMA = '" . $database_name . "' AND TRIGGER_NAME = '{$triger_name}'");
         if (!$query->row[0]) {
             //create trigger
             $sql = "\n\t\t\t\tCREATE TRIGGER `{$triger_name}` BEFORE INSERT ON `{$table_name}` FOR EACH ROW\n\t\t\t\tBEGIN\n\t\t    \t\tSET NEW.date_added = NOW();\n\t\t\t\tEND;\n\t\t\t\t";
             $db->query($sql);
         }
     }
 }
 public static function delete($ctx)
 {
     $id = $ctx->getGet('id');
     $assid = $ctx->getGet('assid');
     ADB::deleteworklog($id);
     $ctx->redirect('/view/' . $assid);
 }
Beispiel #5
0
 /**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     $cache = $registry->get('cache');
     $language_id = (int) $registry->get('language')->getLanguageID();
     $cache_key = 'localization.length_classes.lang_' . $language_id;
     $cache_data = $cache->pull($cache_key);
     if ($cache_data !== false) {
         $this->lengths = $cache_data;
     } else {
         $sql = "SELECT *\n\t\t\t\t\tFROM " . $this->db->table("length_classes") . " mc\n\t\t\t\t\tLEFT JOIN " . $this->db->table("length_class_descriptions") . " mcd\n\t\t\t\t\t\tON (mc.length_class_id = mcd.length_class_id)\n\t\t\t\t\tWHERE mcd.language_id = '" . $language_id . "'";
         $length_class_query = $this->db->query($sql);
         foreach ($length_class_query->rows as $result) {
             $this->lengths[strtolower($result['unit'])] = array('length_class_id' => $result['length_class_id'], 'unit' => $result['unit'], 'title' => $result['title'], 'value' => $result['value']);
         }
         $cache->push($cache_key, $this->lengths);
     }
 }
 public static function router($ctx, $id)
 {
     //$r = ADB::get($id);
     //return print_r($r,1);
     try {
         $r = ADB::get($id);
         return print_r($r, 1);
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Beispiel #7
0
 /**
  * @return array
  */
 public function getShortList()
 {
     $output = array();
     $result = $this->db->query("SELECT UPPER(status) as status, COUNT(msg_id) as count\n\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("messages") . " \n\t\t\t\t\t\t\t\t\tWHERE viewed<'1'\n\t\t\t\t\t\t\t\t\tGROUP BY status");
     foreach ($result->rows as $row) {
         $output['count'][$row['status']] = (int) $row['count'];
         $total += (int) $row['count'];
     }
     $output['total'] = $total;
     //let last couple of messages for each type
     $result = $this->db->query("(SELECT msg_id, title, message, status, viewed, date_modified\n\t\t\t\tFROM " . $this->db->table('messages') . "\n\t\t\t\t\tWHERE UPPER(status)='E'\n\t\t\t\t\tORDER BY date_modified DESC\n\t\t\t\t\tLIMIT 0,3)\n\t\t\t\tUNION\n\t\t\t\t\t(SELECT msg_id, title, message, status, viewed, date_modified\n\t\t\t\t\tFROM " . $this->db->table('messages') . "\n\t\t\t\t\tWHERE UPPER(status)='W'\n\t\t\t\t\tORDER BY date_modified DESC\n\t\t\t\t\tLIMIT 0,3)\n\t\t\t\tUNION\n\t\t\t\t\t(SELECT msg_id, title, message, status, viewed, date_modified\n\t\t\t\t\tFROM " . $this->db->table('messages') . "\n\t\t\t\t\tWHERE UPPER(status)='N'\n\t\t\t\t\tORDER BY date_modified DESC\n\t\t\t\t\tLIMIT 0,3)");
     $output['shortlist'] = $result->rows;
     return $output;
 }
 public static function renderContacts($id)
 {
     $cts = ADB::getContacts($id);
     $vars = array();
     $vars['id'] = $id;
     $vars['list'] = '';
     foreach ($cts as $c) {
         $i = '<li>';
         $i .= $c['name'] . ' - ' . $c['number'];
         $i .= ' (' . $c['notes'] . ')';
         $i .= '</li>';
         $vars['list'] .= $i;
     }
     return Utils::at($vars, 'contacts');
 }
 /**
  * drop dataset with values and columnset
  * @internal param int $dataset_id
  * @return boolean
  */
 public function dropDataset()
 {
     if (!$this->dataset_id) {
         return false;
     }
     if ($this->columnset) {
         $this->db->query("DELETE FROM " . $this->db->table("dataset_values") . " WHERE dataset_column_id in (" . implode(", ", array_keys($this->columnset)) . ");");
         $this->db->query("DELETE FROM " . $this->db->table("dataset_column_properties") . " WHERE dataset_column_id in (" . implode(", ", array_keys($this->columnset)) . ");");
     }
     $this->db->query("DELETE FROM " . $this->db->table("dataset_properties") . " WHERE dataset_id = " . $this->dataset_id . ";");
     $this->db->query("DELETE FROM " . $this->db->table("dataset_definition") . " WHERE dataset_id = " . $this->dataset_id . ";");
     $this->db->query("DELETE FROM " . $this->db->table("datasets") . " WHERE dataset_id = " . $this->dataset_id . ";");
     $this->dataset_id = 0;
     $this->columnset = array();
     return true;
 }
Beispiel #10
0
 /**
  * Get available tax classes for country ID and zone ID
  * Storefront use only!!!
  * @param $country_id
  * @param $zone_id
  * @return mixed|null
  */
 public function getTaxes($country_id, $zone_id)
 {
     $country_id = (int) $country_id;
     $zone_id = (int) $zone_id;
     $language = $this->registry->get('language');
     $language_id = $language->getLanguageID();
     $cache_name = 'tax_class.' . $country_id . '.' . $zone_id;
     $results = $this->cache->get($cache_name, $language_id);
     if (is_null($results)) {
         //Note: Default language text is picked up if no selected language available
         $sql = "SELECT tr.tax_class_id,\n\t\t\t\t\t\t\ttr.rate AS rate, tr.rate_prefix AS rate_prefix, \n\t\t\t\t\t\t\ttr.threshold_condition AS threshold_condition, tr.threshold AS threshold,\n\t\t\t\t\t\t\tCOALESCE( td1.title,td2.title) as title,\n\t\t\t\t\t\t\tCOALESCE( NULLIF(trd1.description, ''),\n\t\t\t\t\t\t\t\t\t  NULLIF(td1.description, ''),\n\t\t\t\t\t\t\t\t\t  NULLIF(trd2.description, ''),\n\t\t\t\t\t\t\t\t\t  NULLIF(td2.description, ''),\n\t\t\t\t\t\t\t\t\t  COALESCE( td1.title,td2.title)\n\t\t\t\t\t\t\t) as description,\n\t\t\t\t\t\t\ttr.priority\t\n\t\t\t\t\tFROM " . $this->db->table("tax_rates") . " tr\n\t\t\t\t\tLEFT JOIN " . $this->db->table("tax_rate_descriptions") . " trd1 ON \n\t\t\t\t\t\t(tr.tax_rate_id = trd1.tax_rate_id AND trd1.language_id = '" . (int) $language_id . "')\n\t\t\t\t\tLEFT JOIN " . $this->db->table("tax_rate_descriptions") . " trd2 ON \n\t\t\t\t\t\t(tr.tax_rate_id = trd2.tax_rate_id AND trd2.language_id = '" . (int) $default_lang_id . "')\n\t\t\t\t\tLEFT JOIN " . $this->db->table("tax_classes") . " tc ON tc.tax_class_id = tr.tax_class_id\n\t\t\t\t\tLEFT JOIN " . $this->db->table("tax_class_descriptions") . " td1 ON \n\t\t\t\t\t\t(tc.tax_class_id = td1.tax_class_id AND td1.language_id = '" . (int) $language_id . "')\n\t\t\t\t\tLEFT JOIN " . $this->db->table("tax_class_descriptions") . " td2 ON \n\t\t\t\t\t\t(tc.tax_class_id = td2.tax_class_id AND td2.language_id = '" . (int) $default_lang_id . "')\n\t\t\t\t\tWHERE (tr.zone_id = '0' OR tr.zone_id = '" . $zone_id . "')\n\t\t\t\t\t\tAND tr.location_id in (SELECT z2l.location_id\n\t\t\t\t\t\t\t\t\t\t\t   FROM " . $this->db->table("zones_to_locations") . " z2l, " . $this->db->table("locations") . " l\n\t\t\t\t\t\t\t\t\t\t\t   WHERE z2l.location_id = l.location_id and z2l.zone_id = '" . $zone_id . "')\n\t\t\t\t\tORDER BY tr.priority ASC";
         $tax_rate_query = $this->db->query($sql);
         $results = $tax_rate_query->rows;
         $this->cache->set($cache_name, $results, $language_id);
     }
     return $results;
 }
Beispiel #11
0
 /**
  * @return bool
  */
 public function setMessageIndicator()
 {
     if (in_array($this->registry->get('request')->get['rt'], array('index/login', 'index/logout')) || !IS_ADMIN) {
         return null;
     }
     $sql = $this->db->query("SELECT status, COUNT(msg_id) as count\n\t\t\t\t\t\t\t\t\tFROM " . DB_PREFIX . "messages\n\t\t\t\t\t\t\t\t\tWHERE viewed<'1'\n\t\t\t\t\t\t\t\t\tGROUP BY status");
     if ($sql->num_rows) {
         foreach ($sql->rows as $row) {
             $this->registry->get('session')->data['new_messages'][$row['status']] = (int) $row['count'];
         }
     } else {
         $this->registry->get('session')->data['new_messages']['N'] = 0;
         $this->registry->get('session')->data['new_messages']['W'] = 0;
         $this->registry->get('session')->data['new_messages']['E'] = 0;
     }
     return true;
 }
 private static function renderList($pa)
 {
     $sts = ADB::getStatuses();
     $blk = ADB::getBlocked();
     $out = '';
     foreach ($pa as $p) {
         $row = '';
         if (count($p['contacts']) > 0) {
             $cts = array();
             foreach ($p['contacts'] as $c) {
                 $cts[] = $c['number'];
             }
             $p['contacts'] = implode(', ', $cts);
         } else {
             $p['contacts'] = '';
         }
         $p['status'] = !empty($p['status']) ? $sts[$p['status']] : '';
         $p['blocked'] = isset($p['blocked']) ? $blk[$p['blocked']] : '';
         $out .= Utils::at($p, 'prow');
     }
     return $out;
 }
 /**
  * @param string $type
  * @param array $tr_details - amount, order_id, transaction_type, description, comments, creator
  * @return bool
  */
 private function _record_transaction($type, $tr_details)
 {
     if (!$this->isLogged()) {
         return false;
     }
     if (!has_value($tr_details['transaction_type']) || !has_value($tr_details['created_by'])) {
         return false;
     }
     if ($type == 'debit') {
         $amount = 'debit = ' . (double) $tr_details['amount'];
     } else {
         if ($type == 'credit') {
             $amount = 'credit = ' . (double) $tr_details['amount'];
         } else {
             return false;
         }
     }
     $this->db->query("INSERT INTO " . $this->db->table("customer_transactions") . "\n      \t                SET customer_id \t\t= '" . (int) $this->getId() . "',\n      \t                \torder_id \t\t\t= '" . (int) $tr_details['order_id'] . "',\n      \t                    transaction_type \t= '" . $this->db->escape($tr_details['transaction_type']) . "',\n      \t                    description \t\t= '" . $this->db->escape($tr_details['description']) . "',\n      \t                    comment \t\t\t= '" . $this->db->escape($tr_details['comment']) . "',\n\t\t\t\t\t\t\t" . $amount . ",\n\t\t\t\t\t\t\tsection\t\t\t\t= '" . ((int) $tr_details['section'] ? (int) $tr_details['section'] : 0) . "',\n      \t                    created_by \t\t\t= '" . (int) $tr_details['created_by'] . "',\n      \t                    date_added = NOW()");
     $this->cache->delete('balance.' . (int) $this->getId());
     if ($this->db->getLastId()) {
         return true;
     }
     return false;
 }
Beispiel #14
0
    /**
     * @param int $layout_id
     * @return bool
     */
    private function _clear_layouts($layout_id)
    {
        $this->db->query('DELETE FROM ' . DB_PREFIX . 'layouts
			WHERE layout_id = "' . (int) $layout_id . '"');
        return true;
    }
 public function RunSQL($data)
 {
     $db = new ADB($data['db_driver'], $data['db_host'], $data['db_user'], $data['db_password'], $data['db_name']);
     $file = DIR_APP_SECTION . 'abantecart_database.sql';
     if ($sql = file($file)) {
         $query = '';
         foreach ($sql as $line) {
             $tsl = trim($line);
             if ($sql != '' && substr($tsl, 0, 2) != "--" && substr($tsl, 0, 1) != '#') {
                 $query .= $line;
                 if (preg_match('/;\\s*$/', $line)) {
                     $query = str_replace("DROP TABLE IF EXISTS `ac_", "DROP TABLE IF EXISTS `" . $data['db_prefix'], $query);
                     $query = str_replace("CREATE TABLE `ac_", "CREATE TABLE `" . $data['db_prefix'], $query);
                     $query = str_replace("INSERT INTO `ac_", "INSERT INTO `" . $data['db_prefix'], $query);
                     $query = str_replace("ON `ac_", "ON `" . $data['db_prefix'], $query);
                     $db->query($query);
                     //no silence mode! if error - will throw to exception
                     $query = '';
                 }
             }
         }
         $db->query("SET CHARACTER SET utf8;");
         $db->query("SET @@session.sql_mode = 'MYSQL40';");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "users`\n\t\t\t\tSET user_id = '1',\n\t\t\t\t\tuser_group_id = '1',\n\t\t\t\t\temail = '" . $db->escape($data['email']) . "',\n\t\t\t\t    username = '******'username']) . "',\n\t\t\t\t    password = '******'password'])) . "',\n\t\t\t\t    status = '1',\n\t\t\t\t    date_added = NOW();");
         $db->query("UPDATE `" . $data['db_prefix'] . "settings` SET value = '" . $db->escape($data['email']) . "' WHERE `key` = 'store_main_email'; ");
         $db->query("UPDATE `" . $data['db_prefix'] . "settings` SET value = '" . $db->escape(HTTP_ABANTECART) . "' WHERE `key` = 'config_url'; ");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "settings` SET `group` = 'config', `key` = 'install_date', value = NOW(); ");
         $db->query("UPDATE `" . $data['db_prefix'] . "products` SET `viewed` = '0';");
         //process triggers
         //$this->create_triggers($db, $data['db_name']);
         //run descructor and close db-connection
         unset($db);
     }
     //clear cache dir in case of reinstall
     $cache = new ACache();
     $cache->delete('*');
 }
Beispiel #16
0
 /**
  * @param array $data
  * @return bool
  */
 protected function _is_definition_in_db($data)
 {
     $sql = "SELECT *\n                     FROM " . DB_PREFIX . "language_definitions\n                     WHERE language_id = '" . $data['language_id'] . "'\n                           AND  block = '" . $data['block'] . "'\n                           AND section =  '" . $data['section'] . "'\n                           AND language_key =  '" . $data['language_key'] . "'\n                           AND language_value =  '" . $data['language_value'] . "'";
     $exist = $this->db->query($sql);
     return $exist->num_rows ? true : false;
 }
require_once 'init.php';
//Check if cart is already installed
if (file_exists(DIR_SYSTEM . 'config.php')) {
    require_once DIR_SYSTEM . 'config.php';
}
if (isset($_SESSION['SALT']) && strlen($_SESSION['SALT']) == 4) {
    define('SALT', $_SESSION['SALT']);
}
//generate salt
if (!defined('SALT')) {
    DEFINE('SALT', randomWord(4));
    $_SESSION['SALT'] = SALT;
}
$data_exist = false;
if (defined('DB_HOSTNAME') && DB_HOSTNAME) {
    $db = new ADB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
    $r = $db->query("SELECT product_id FROM " . DB_PREFIX . "products");
    $data_exist = $r->num_rows;
} else {
    unset($session->data['finish']);
}
if ($data_exist && empty($session->data['finish'])) {
    header('Location: ../');
}
if (!empty($session->data['finish']) && $session->data['finish'] == 'true') {
    $request->get['rt'] = 'finish';
}
try {
    // Document
    $document = new ADocument();
    $document->setBase(HTTP_SERVER);
 /**
  * @param int $layout_id
  * @return bool
  */
 private function _clear_layouts($layout_id)
 {
     $this->db->query("DELETE FROM " . $this->db->table("layouts") . " \n\t\t\tWHERE layout_id = '" . (int) $layout_id . "'");
     return true;
 }
 public function test($ctx)
 {
     return print_r(self::renderFields(ADB::getFields()));
 }