public function set($key, $value, $process = 'from_admin_interface', $app = 'system') { $datetime = get_instance()->date->datetime(); $key = strtolower($key); if ($process == 'from_install_interface') { $config = $_SESSION['db_datas']; $this->db = DB($config, TRUE); } else { if ($process == "form_admin_interface") { $this->db = get_db(); // Refreshing } } $query = $this->db->where('KEY', $key)->where('USER', '')->get('tendoo_meta'); // Convert value if (is_array($value)) { $value = json_encode($value, JSON_FORCE_OBJECT); } else { if (is_bool($value)) { $value = $value === true ? 'true' : 'false'; } } // ELSE $value keep his form // Conversion ended if (count($query->result_array()) > 0) { return $this->db->where('KEY', $key)->where('USER', '')->update('tendoo_meta', array('VALUE' => $value, 'APP' => $app, 'DATE' => $datetime)); } else { return $this->db->insert('tendoo_meta', array('KEY' => $key, 'VALUE' => $value, 'APP' => $app, 'DATE' => $datetime)); } }
function postback($VAR) { # needed for return $ret['invoice_id'] = $VAR['option1']; $ret['transaction_id'] = $VAR['order_id']; $ret['amount'] = $VAR['amount']; $ret['currency'] = DEFAULT_CURRENCY; # get the processor details: $db =& DB(); $q = "SELECT id,active,plugin_data FROM " . AGILE_DB_PREFIX . "checkout WHERE\n\t\t\t site_id \t\t= " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t checkout_plugin\t= " . $db->qstr($this->name); $rs = $db->Execute($q); while (!$rs->EOF) { $ret['checkout_id'] = $rs->fields["id"]; $do = true; $this->cfg = unserialize($rs->fields["plugin_data"]); if ($do) { include_once PATH_MODULES . 'checkout/checkout.inc.php'; $checkout = new checkout(); $checkout->postback($ret); echo '<SCRIPT LANGUAGE="JavaScript"> window.location="' . $this->success_url . $ret['invoice_id'] . '"; </script>'; return true; } $rs->MoveNext(); } echo '<SCRIPT LANGUAGE="JavaScript"> window.location="' . $this->decline_url . $ret['invoice_id'] . '"; </script>'; }
private function getLogDb() { if (empty($this->logDb)) { $this->logDb = DB('log'); } return $this->logDb; }
function update_user_feed($user_id, $username) { global $bb_cfg; $file_path = $bb_cfg['atom']['path'] . '/u/' . floor($user_id / 5000) . '/' . $user_id % 100 . '/' . $user_id . '.atom'; $sql = "\n\t\tSELECT\n\t\t\tt.topic_id, t.topic_title, t.topic_status,\n\t\t\tu1.username AS first_username,\n\t\t\tp1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,\n\t\t\tp2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,\n\t\t\ttor.size AS tor_size, tor.tor_status\n\t\tFROM " . BB_TOPICS . " t\n\t\tLEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)\n\t\tLEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)\n\t\tLEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)\n\t\tLEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)\n\t\tWHERE t.topic_poster = {$user_id}\n\t\tORDER BY t.topic_last_post_time DESC\n\t\tLIMIT 50\n\t"; $topics_tmp = DB()->fetch_rowset($sql); $topics = array(); foreach ($topics_tmp as $topic) { if (isset($topic['topic_status'])) { if ($topic['topic_status'] == TOPIC_MOVED) { continue; } } if (isset($topic['tor_status'])) { if (isset($bb_cfg['tor_frozen'][$topic['tor_status']])) { continue; } } $topics[] = $topic; } if (!count($topics)) { @unlink($file_path); return false; } if (create_atom($file_path, 'u', $user_id, wbr($username), $topics)) { return true; } else { return false; } }
private static function getLogDb() { if (!isset(self::$logDb)) { self::$logDb = DB('log'); } return self::$logDb; }
/** * AgileBill - Open Billing Software * * This body of work is free software; you can redistribute it and/or * modify it under the terms of the Open AgileBill License * License as published at http://www.agileco.com/agilebill/license1-4.txt * * For questions, help, comments, discussion, etc., please join the * Agileco community forums at http://forum.agileco.com/ * * @link http://www.agileco.com/ * @copyright 2004-2008 Agileco, LLC. * @license http://www.agileco.com/agilebill/license1-4.txt * @author Tony Landis <*****@*****.**> * @package AgileBill * @version 1.4.93 */ function CORE_database_delete($VAR, &$construct, $type) { global $C_debug, $C_translate; # set the id $id = $construct->table . '_id'; # generate the full query $q = "DELETE FROM\n\t\t\t" . AGILE_DB_PREFIX . "{$construct->table}\n\t\t\tWHERE\n\t\t\tid \t\t= '" . $db->qstr($VAR["id"], get_magic_quotes_gpc()) . "'\n\t\t\tAND\n\t\t\tsite_id = '" . DEFAULT_SITE . "'"; # execute the query $db =& DB(); $result = $db->Execute($q); # Alert $C_debug->value["id"] = $VAR[$id]; $C_debug->value["module_name"] = $C_translate->translate('menu', $construct->module, ""); $alert = $C_translate->translate('alert_delete_id', "", ""); $C_debug->alert($alert); # error reporting if ($result === false) { global $C_debug; $C_debug->error('database.inc.php', 'delete', $db->ErrorMsg()); if (isset($construct->trigger["{$type}"])) { include_once PATH_CORE . 'trigger.inc.php'; $trigger = new CORE_trigger(); $trigger->trigger($construct->trigger["{$type}"], 0, $VAR); } } else { if (isset($construct->trigger["{$type}"])) { include_once PATH_CORE . 'trigger.inc.php'; $trigger = new CORE_trigger(); $trigger->trigger($construct->trigger["{$type}"], 0, $VAR); } } }
function smarty_block_group($params, $resource, &$smarty) { if (empty($resource)) { return; } @($id = $params["id"]); $do = false; $db =& DB(); $sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND status = ' . $db->qstr('1') . ' AND id = ' . $db->qstr($id); @($result = $db->Execute($sql)); $do = false; if (@$result->RecordCount() > 0) { global $C_auth; @($arr = unserialize($result->fields['group_avail'])); for ($i = 0; $i < count($arr); $i++) { if ($do == false && $C_auth->auth_group_by_id($arr[$i])) { $do = true; } } } if ($do) { echo $resource; } else { echo @$params["msg"]; } }
/** * AgileBill - Open Billing Software * * This body of work is free software; you can redistribute it and/or * modify it under the terms of the Open AgileBill License * License as published at http://www.agileco.com/agilebill/license1-4.txt * * For questions, help, comments, discussion, etc., please join the * Agileco community forums at http://forum.agileco.com/ * * @link http://www.agileco.com/ * @copyright 2004-2008 Agileco, LLC. * @license http://www.agileco.com/agilebill/license1-4.txt * @author Tony Landis <*****@*****.**> * @package AgileBill * @version 1.4.93 */ function list_radio($input_id, $name, $table, $field, $id, $class) { global $C_translate; $db =& DB(); $sql = "SELECT id, {$field} FROM " . AGILE_DB_PREFIX . "{$table} WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY {$field}"; $result = $db->Execute($sql); if ($result === false) { global $C_debug; $C_debug->error('list.inc.php', 'radio', $db->ErrorMsg()); } if ($result->RecordCount() >= 5) { $count = 5; } else { $count = $result->RecordCount(); } if ($id == "all") { $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value=""> All <BR>'; } $i = 0; while (!$result->EOF) { if ($id == $result->fields["id"]) { $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="' . $result->fields["id"] . '" checked> ' . $result->fields["{$field}"] . '<BR>'; } else { $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="' . $result->fields["id"] . '"> ' . $result->fields["{$field}"] . '<BR>'; } $i++; $result->MoveNext(); } if ($i == 0) { $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="">' . $C_translate->translate('lists_none_defined', 'CORE', ''); } return $return; }
public function database($params = '', $return = FALSE, $active_record = NULL) { // Grab the super object $CI =& get_instance(); // Do we even need to load the database class? if (class_exists('CI_DB') and $return == FALSE and $active_record == NULL and isset($CI->db) and is_object($CI->db)) { return FALSE; } require_once BASEPATH . 'database/DB.php'; $db = DB($params, $active_record); // Load extended DB driver $custom_db_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver'; $custom_db_driver_file = APPPATH . 'core/' . $custom_db_driver . '.php'; if (file_exists($custom_db_driver_file)) { require_once $custom_db_driver_file; $db = new $custom_db_driver(get_object_vars($db)); } // Return DB instance if ($return === TRUE) { return $db; } // Initialize the db variable. Needed to prevent reference errors with some configurations $CI->db = ''; $CI->db =& $db; }
/** * Function for right load database * * @access public * @param string the DB credentials * @param bool whether to return the DB object * @param bool whether to enable active record (this allows us to override the config setting) * @return object */ function database($params = '', $return = FALSE, $query_builder = NULL) { // Do we even need to load the database class? if (class_exists('CI_DB') and $return == FALSE and $query_builder == NULL) { return FALSE; } require_once BASEPATH . 'database/DB' . '.php'; // Load the DB class $db =& DB($params, $query_builder); $my_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver'; $my_driver_file = APPPATH . 'libraries/System/' . $my_driver . '.php'; if (file_exists($my_driver_file)) { log_message('debug', 'Extended DB driver class instantiated!'); require_once $my_driver_file; $db_obj = new $my_driver(get_object_vars($db)); $db =& $db_obj; } if ($return === TRUE) { return DB($params, $query_builder); } // Grab the super object $CI =& get_instance(); // Initialize the db variable. Needed to prevent // reference errors with some configurations $CI->db = ''; $CI->db = $db; return $this; // Assign the DB object to any existing models //$this->_ci_assign_to_models(); }
public function __construct($orgcode, $enableSlaves = 'false') { $this->orgcode = $orgcode == null ? 'config' : $orgcode; $this->_current_date = date("Y-m-d H:i:s"); $this->db = DB($this->orgcode); $this->db->enableSlaves = $enableSlaves; }
function smarty_function_html_select_affiliate($params, &$smarty) { $id = $params['id']; $name = $params['name']; $default = $params['default']; $type = $params['type']; if (empty($id)) { $id = $name . "_id"; } if (!empty($default)) { $db =& DB(); $p = AGILE_DB_PREFIX; $q = "SELECT DISTINCT\n\t {$p}affiliate.id,\n\t {$p}account.first_name,\n\t {$p}account.last_name,\n\t {$p}account.username\n\t FROM \n\t {$p}account\n\t LEFT JOIN\n\t {$p}affiliate \t\n\t ON\n\t {$p}account.id = {$p}affiliate.account_id\n\t WHERE \n\t {$p}affiliate.id = '{$default}' AND\n\t {$p}affiliate.site_id = " . DEFAULT_SITE . " AND\n\t {$p}account.site_id = " . DEFAULT_SITE; $result = $db->Execute($q); if ($result != false && $result->RecordCount() > 0) { $val = $result->fields['first_name'] . ' ' . $result->fields['last_name']; } } else { $val = ''; } echo ' <input type="hidden" id="' . $id . '_hidden" name="' . $name . '" value="' . $default . '" /> <input type="text" autocomplete="off" id="' . $id . '" name="affiliate_search" size="35" value="' . $val . '" /> <div class="auto_complete" id="' . $id . '_auto_complete"></div> <script type="text/javascript">new Ajax.Autocompleter("' . $id . '", "' . $id . '_auto_complete", "ajax.php?do[]=affiliate:autoselect", { })</script> '; if (!empty($val)) { // display unselect option echo '<a href="#" OnClick="document.getElementById(\'' . $id . '\').value=\'\'; document.getElementById(\'' . $id . '_hidden\').value=\'\'"> - </a>'; } }
/** * Logs the sesson variables. * * @return void * @since Version 1.0 */ function CORE_weblog() { global $current_module, $VAR; if ($current_module == '') { $module = ''; } else { $module = $current_module; } if (!isset($VAR['_page']) || $VAR['_page'] == '') { $page = ''; } else { @($pagearr = explode(':', $VAR['_page'])); @($page = $pagearr["1"]); } ### browser type: $arr_browser = $this->get_browser(); $browser = $arr_browser["type"] . ' ' . $arr_browser["ver"]; ### product: if (isset($VAR['prid'])) { $product = $VAR['prid']; } else { $product = ''; } ### log the current hit to the database $db =& DB(); $id = $db->GenID(AGILE_DB_PREFIX . "" . 'weblog_id'); $sql = "INSERT INTO " . AGILE_DB_PREFIX . "weblog SET\n\t\t\t\tid \t= " . $db->qstr($id) . ",\n\t\t\t\tdate_orig = " . $db->qstr(time()) . ",\n\t\t\t\tsite_id\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t\t\t\tsession_id\t= " . $db->qstr(SESS) . ",\n\t\t\t\taccount_id\t= " . $db->qstr(SESS_ACCOUNT) . ",\n\t\t\t\taffiliate_id= " . $db->qstr(SESS_AFFILIATE) . ",\n\t\t\t\treseller_id\t= " . $db->qstr(SESS_RESELLER) . ",\n\t\t\t\tcampaign_id\t= " . $db->qstr(SESS_CAMPAIGN) . ",\n\t\t\t\tproduct_id\t= " . $db->qstr($product) . ",\n\t\t\t\tmodule\t\t= " . $db->qstr($module) . ",\n\t\t\t\tpage\t\t= " . $db->qstr($page) . ",\n\t\t\t\treferrer\t= " . $db->qstr($this->get_referrer()) . ",\n\t\t\t\tbrowser\t\t= " . $db->qstr($browser) . ",\n\t\t\t\tos\t\t\t= " . $db->qstr($this->get_os()); $result = $db->Execute($sql); # error reporting: if ($result === false) { global $C_debug; $C_debug->error('weblog.inc.php', 'weblog', $db->ErrorMsg()); } return; }
function database_s($params = '', $return = FALSE, $active_record = NULL) { // Do we even need to load the database class? if (class_exists('CI_DB') and $return == FALSE and $active_record == NULL and isset($CI->db) and is_object($CI->db)) { return FALSE; } require_once BASEPATH . 'database/DB' . EXT; // Load the DB class $db =& DB($params, $active_record); $my_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver'; $my_driver_file = APPPATH . 'libraries/' . $my_driver . EXT; if (file_exists($my_driver_file)) { require_once $my_driver_file; $db = new $my_driver(get_object_vars($db)); } if ($return === TRUE) { return $db; } // Grab the super object $CI =& get_instance(); // Initialize the db variable. Needed to prevent // reference errors with some configurations $CI->db = ''; // Load the DB class $CI->db = $db; if (!empty($_REQUEST['MemFlush']) && $_REQUEST['MemFlush'] == 1) { $CI->db->MemFlush = TRUE; } }
function import($VAR) { global $C_debug; if (empty($VAR['asset_pool_id'])) { $C_debug->alert("No asset pool specified"); return; } $db =& DB(); if (is_uploaded_file($_FILES['datafile']['tmp_name'])) { # Got a file to import $fp = fopen($_FILES['datafile']['tmp_name'], "r"); if ($fp) { $counter = 0; $skipped = 0; while (!feof($fp)) { $line = fgets($fp, 128); $cols = explode(",", $line); if (!empty($cols[0])) { $fields = array('date_orig' => time(), 'date_last' => time(), 'status' => 0, 'service_id' => 0, 'pool_id' => $VAR['asset_pool_id'], 'asset' => @$cols[0], 'misc' => @$cols[1]); $db->Execute(sqlInsert($db, "asset", $fields)); $counter++; } else { $skipped++; } } $C_debug->alert("Imported {$counter} new Asset(s) and skipped {$skipped} Asset(s)!"); } else { $C_debug->alert('Unable to fopen the file sent.'); } } else { $C_debug->alert('Unable to process the uploaded file.'); } }
function check($domain, $tld, $tld_array) { // check the domain validity: if (!preg_match('/^[a-zA-Z0-9\\-]{1,}$/i', $domain)) { return false; } if (preg_match('/[-]{2,}/', $domain)) { return false; } if (preg_match('/^[-]{1,}/', $domain)) { return false; } if (preg_match('/[-]{1,}$/', $domain)) { return false; } $db =& DB(); $dbm = new CORE_database(); $sql = $dbm->sql_select('service', 'id', "domain_name = ::{$domain}:: AND domain_tld = ::{$tld}::", "", $db); $rs = $db->Execute($sql); if ($rs == false || $rs->RecordCount() > 0) { return false; } else { return true; } }
function duplicate_attachment_pm($switch_attachment, $original_privmsg_id, $new_privmsg_id) { global $privmsg, $folder; if (($privmsg['privmsgs_type'] == PRIVMSGS_NEW_MAIL || $privmsg['privmsgs_type'] == PRIVMSGS_UNREAD_MAIL) && $folder == 'inbox' && intval($switch_attachment) == 1) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE privmsgs_id = ' . $original_privmsg_id; if (!($result = DB()->sql_query($sql))) { message_die(GENERAL_ERROR, 'Couldn\'t query Attachment Table', '', __LINE__, __FILE__, $sql); } if (DB()->num_rows($result) > 0) { $rows = DB()->sql_fetchrowset($result); $num_rows = DB()->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' (attach_id, post_id, privmsgs_id, user_id_1, user_id_2) VALUES ( ' . $rows[$i]['attach_id'] . ', ' . $rows[$i]['post_id'] . ', ' . $new_privmsg_id . ', ' . $rows[$i]['user_id_1'] . ', ' . $rows[$i]['user_id_2'] . ')'; if (!($result = DB()->sql_query($sql))) { message_die(GENERAL_ERROR, 'Couldn\'t store Attachment for sent Private Message', '', __LINE__, __FILE__, $sql); } } $sql = "UPDATE " . PRIVMSGS_TABLE . "\n\t\t\t\tSET privmsgs_attachment = 1\n\t\t\t\tWHERE privmsgs_id = " . $new_privmsg_id; if (!DB()->sql_query($sql)) { message_die(GENERAL_ERROR, 'Unable to update Private Message Table.', '', __LINE__, __FILE__, $sql); } } } }
function smarty_function_html_menu_product_host($params, &$smarty) { $id = $params['id']; $name = $params['name']; $default = unserialize($params['default']); $size = $params['size']; $exclude = $params['exclude']; if (empty($id)) { $id = $name; } $db =& DB(); $p = AGILE_DB_PREFIX; $q = "SELECT id,sku FROM {$p}product\n\t WHERE host = 1\n\t AND active = 1 \n\t AND price_type = 1\n\t AND id != {$exclude}\n\t AND site_id = " . DEFAULT_SITE; $result = $db->Execute($q); if ($result && $result->RecordCount() > 0) { echo "<select id=\"{$id}\" name=\"{$name}[]\" size=\"{$size}\" multiple>"; while (!$result->EOF) { $sel = ''; foreach ($default as $cur) { if ($cur == $result->fields['id']) { $sel = "selected"; } } echo "<option value=\"{$result->fields['id']}\"{$sel}>{$result->fields['sku']}</option>"; $result->MoveNext(); } echo "</select>"; } }
function _get_dbconfig($orgcode, $type = "master") { $connstr_cachekey = "ConnectionString_" . $orgcode; $connstr = Yii::$app->cache->get($connstr_cachekey); if (empty($connstr)) { $db = DB("config"); $command = $db->createCommand("select ConnectionString from myscrm_organization where UniqueName=:orgcode", [':orgcode' => $orgcode]); $connstr = $command->queryScalar(); if (empty($connstr)) { throw new Exception("租户库链接为空!", "110001"); } Yii::$app->cache->set($connstr_cachekey, $connstr); } $myconnection = array(); foreach (explode(';', $connstr) as $conn) { $connPara = explode('=', $conn); if (count($connPara) > 1) { $myconnection[$connPara[0]] = $connPara[1]; } } $connect_host = $myconnection["server"]; if ($type == 'slave') { //slave实例切换 //获取主从实例对照参数表 $m2s_instance_params = isset(\Yii::$app->params['master_slave_instance']) && is_array(\Yii::$app->params['master_slave_instance']) ? \Yii::$app->params['master_slave_instance'] : []; /** * 如果存在主从映射关系,则替换,否则主从实例为同一实例 */ if (isset($m2s_instance_params[$connect_host]) && $m2s_instance_params[$connect_host]) { $connect_host = $m2s_instance_params[$connect_host]; } } return ["host" => $connect_host, "database" => $myconnection["database"], "uid" => $myconnection["uid"], "pwd" => $myconnection["pwd"]]; }
/** * Delete a radius account */ function p_delete() { $db =& DB(); $db->Execute(sqlDelete($db, "radius", "service_id={$this->service['id']}")); $db->Execute(sqlDelete($db, "radius_service", "service_id={$this->service['id']}")); return true; }
function graph($start, $end, $constraint, $default) { global $C_translate; $db =& DB(); $sql = 'SELECT date_orig FROM ' . AGILE_DB_PREFIX . 'ticket WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND date_orig >= ' . $db->qstr($start) . ' AND date_orig <= ' . $db->qstr($end); $result = $db->Execute($sql); if ($result->RecordCount() == 0) { $arr['title'] = $C_translate->translate('search_no_results', '', ''); $arr['results'] = $default; return $arr; } $ii = 0; while (!$result->EOF) { $d = $result->fields['date_orig']; for ($i = 0; $i < count($constraint); $i++) { if ($d >= $constraint[$i]["start"] && $d < $constraint[$i]["end"]) { $default[$i]++; } $ii++; } $result->MoveNext(); } $C_translate->value['ticket_message']['count'] = $result->RecordCount(); $title = $C_translate->translate('statistics', 'ticket_message', ''); $arr['title'] = $title; $arr['results'] = $default; return $arr; }
/** * Database Loader * * @param mixed $params Database configuration options * @param bool $return Whether to return the database object * @param bool $query_builder Whether to enable Query Builder * (overrides the configuration setting) * * @return object|bool Database object if $return is set to TRUE, * FALSE on failure, CI_Loader instance in any other case */ public function database($params = '', $return = FALSE, $query_builder = NULL) { // Grab the super object $CI =& get_instance(); // Do we even need to load the database class? if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && !empty($CI->db->conn_id)) { return FALSE; } require_once BASEPATH . 'database/DB.php'; $db = DB($params, $query_builder); // Load extended DB driver $custom_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver'; $custom_driver_file = APPPATH . 'core/' . $custom_driver . '.php'; if (file_exists($custom_driver_file)) { require_once $custom_driver_file; $db = new $custom_driver(get_object_vars($db)); } if ($return === TRUE) { return $db; } // Initialize the db variable. Needed to prevent // reference errors with some configurations $CI->db = ''; $CI->db = $db; // Load the DB class // $CI->db =& DB($params, $query_builder); return $this; }
/** * Database Loader * * @access public * @param string the DB credentials * @param bool whether to return the DB object * @param bool whether to enable active record (this allows us to override the config setting) * @return object */ function database($params = '', $return = FALSE, $active_record = NULL) { /* if ( ! class_exists('CI_DB_active_record')) { @include(APPPATH.'libraries/My_DB_active_rec'.EXT); } // call the parent method to retain the CI functionality parent::database($params, $return, $active_record); */ // Do we even need to load the database class? if (class_exists('CI_DB') and $return == FALSE and $active_record == FALSE) { return FALSE; } require_once BASEPATH . 'database/DB' . EXT; // Load the DB class $db =& DB($params, $active_record); $my_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver'; $my_driver_file = APPPATH . 'libraries/' . $my_driver . EXT; if (file_exists($my_driver_file)) { require_once $my_driver_file; $db = new $my_driver(get_object_vars($db)); } if ($return === TRUE) { return $db; } // Grab the super object $CI =& get_instance(); // Initialize the db variable. Needed to prevent // reference errors with some configurations $CI->db = ''; $CI->db = $db; // Assign the DB object to any existing models $this->_ci_assign_to_models(); }
function smarty_function_html_menu($params, &$smarty) { $conditions = ''; extract($params); if (empty($field)) { $field = $name; } if (empty($id)) { $id = $field; } $db =& DB(); $rs =& $db->Execute($sql = sqlSelect($db, $assoc_table, "id," . $assoc_field, $conditions, $assoc_field)); #echo $sql; $return = '<select id="' . $id . '" name="' . $field . '">'; if ($default == "all" || $blank) { $return .= '<option value="" selected></option>'; } if ($rs && $rs->RecordCount() > 0) { while (!$rs->EOF) { $return .= '<option value="' . $rs->fields['id'] . '"'; if ($default == $rs->fields['id']) { $return .= "selected"; } $return .= '>' . $rs->fields["{$assoc_field}"] . '</option>'; $rs->MoveNext(); } } else { if ($default != "all") { $return .= '<option value=""></option>'; } } $return .= '</select>'; echo $return; }
function validate_email($email, $check_ban_and_taken = true) { global $lang, $userdata; if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) { return $lang['EMAIL_INVALID']; } if (strlen($email) > USEREMAIL_MAX_LENGTH) { return $lang['EMAIL_TOO_LONG']; } if ($check_ban_and_taken) { $banned_emails = array(); foreach (DB()->fetch_rowset("SELECT ban_email FROM " . BB_BANLIST . " ORDER BY NULL") as $row) { $banned_emails[] = str_replace('\\*', '.*?', preg_quote($row['ban_email'], '#')); } if ($banned_emails_exp = join('|', $banned_emails)) { if (preg_match("#^({$banned_emails_exp})\$#i", $email)) { return sprintf($lang['EMAIL_BANNED'], $email); } } $email_sql = DB()->escape($email); if ($row = DB()->fetch_row("SELECT `user_email` FROM " . BB_USERS . " WHERE user_email = '{$email_sql}' LIMIT 1")) { if ($row['user_email'] == $userdata['user_email']) { return false; } else { return $lang['EMAIL_TAKEN']; } } } return false; }
function getZone($zoneID) { $db = DB(); $sql = $db->get_where('tb_zone', 'zone_id =' . $zoneID); $rs = $sql->row_array(); return $rs['zone_name']; }
function download($VAR) { if (empty($VAR['id'])) { return false; } $id = $VAR['id']; // get ticket id $db =& DB(); $rs = $db->Execute(sqlSelect($db, array("ticket_attachment", "ticket"), "A.ticket_id,B.department_id,B.account_id", "A.id=::{$id}:: AND A.ticket_id=B.id")); if (!$rs || $rs->RecordCount() == 0) { return false; } // is this an admin? global $C_auth; if ($C_auth->auth_method_by_name("ticket", "view")) { // get the data & type $rs = $db->Execute(sqlSelect($db, "ticket_attachment", "*", "id=::{$id}::")); // set the header require_once PATH_CORE . 'file_extensions.inc.php'; $ft = new file_extensions(); $type = $ft->set_headers_ext($rs->fields['type'], $rs->fields['name']); if (empty($type)) { echo imap_qprint($rs->fields['content']); } elseif (preg_match("/^text/i", $type)) { echo imap_base64($rs->fields['content']); } else { echo imap_base64($rs->fields['content']); } exit; } }
/** * AgileBill - Open Billing Software * * This body of work is free software; you can redistribute it and/or * modify it under the terms of the Open AgileBill License * License as published at http://www.agileco.com/agilebill/license1-4.txt * * For questions, help, comments, discussion, etc., please join the * Agileco community forums at http://forum.agileco.com/ * * @link http://www.agileco.com/ * @copyright 2004-2008 Agileco, LLC. * @license http://www.agileco.com/agilebill/license1-4.txt * @author Tony Landis <*****@*****.**> * @package AgileBill * @version 1.4.93 */ function list_card_type_menu($default_selected, $checkout_id, $field, $class) { // define default list of accepted CC types $def_accepted_arr = array(0 => 'visa', 1 => 'mc', 2 => 'amex', 3 => 'discover', 4 => 'delta', 5 => 'solo', 6 => 'switch', 7 => 'jcb', 8 => 'diners', 9 => 'carteblanche', 10 => 'enroute'); $db =& DB(); $q = "SELECT * FROM " . AGILE_DB_PREFIX . "checkout WHERE\n\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\tid\t\t= " . $db->qstr($checkout_id); $rs = $db->Execute($q); if ($rs == false || $rs->RecordCount() == 0) { $accepted_arr = $def_accepted_arr; } @($cfg = unserialize($rs->fields["plugin_data"])); $accepted_arr = $cfg['card_type']; if (count($accepted_arr) <= 0) { $accepted_arr = $def_accepted_arr; } global $C_translate; $data = '<select id="' . $field . '" name="' . $field . '" value="' . $default . '">'; for ($i = 0; $i < count($accepted_arr); $i++) { $data .= '<option value="' . $accepted_arr[$i] . '"'; if ($default_selected == $accepted_arr[$i]) { $data .= ' selected'; } $data .= '">' . $C_translate->translate('card_type_' . $accepted_arr[$i], 'checkout', ''); '</option> '; } $data .= '</select>'; return $data; }
/** Get the plugin settings from the database */ function config() { $db =& DB(); $rs =& $db->Execute(sqlSelect($db, "voip_did_plugin", "*", "id = {$this->id}")); $this->release_minutes = $rs->fields['release_minutes']; $this->avail_countries = $rs->fields['avail_countries']; }
function smarty_function_html_select_account($params, &$smarty) { $id = $params['id']; $name = $params['name']; $default = $params['default']; $type = $params['type']; if (empty($id)) { $id = $name . "_id"; } if (!empty($default)) { $db =& DB(); $p = AGILE_DB_PREFIX; $q = "SELECT id,first_name,middle_name,last_name FROM {$p}account \n\t WHERE id = {$default} \n\t AND site_id = " . DEFAULT_SITE; $result = $db->Execute($q); if ($result->RecordCount() > 0) { $val = $result->fields['first_name'] . ' ' . $result->fields['last_name']; } if (!empty($val)) { # Get } } else { $val = ''; } if (empty($val)) { echo ' <input type="hidden" id="' . $id . '_hidden" name="' . $name . '" value="' . $default . '" /> <input type="text" autocomplete="off" id="' . $id . '" name="account_search" size="35" value="' . $val . '" /> <div class="auto_complete" id="' . $id . '_auto_complete"></div> <script type="text/javascript">new Ajax.Autocompleter("' . $id . '", "' . $id . '_auto_complete", "ajax.php?do[]=account_admin:autoselect", { })</script> '; } else { echo "<a href=\"#\" onClick=\"window.open('?_page=account_admin:view&id={$default}', 'mainFrame', '')\"><u>{$val}</u></a>"; echo "<input value=\"{$default}\" id=\"{$id}\" name=\"{$name}\" type=\"hidden\">"; } }