/** Class constructor @public **/ function __construct() { $this->_db =& Factory::getDBO(); if ($args = func_get_args()) { $table_key = $args[0]; $table_name = $args[1]; $this->__initTable($table_key, $table_name); } }
private function getWeblogId() { fb('ssss', FirePHP::TRACE); $ob = Factory::getDBO()->SimpleSelect('wb_weblogs', 'id', array("site_id" => ResponseRegistery::getInstance()->site_id))->fetch(); fb($ob, 'admin'); if ($ob) { return intval($ob->id); } else { return 0; } }
private function getSiteId($sub) { $db = Factory::getDBO(); $sql = "SELECT\n\t\t\t\t\tsite.id as id,\n\t\t\t\t\tsite.active\n\t\t\t\tFROM ge_sites as site\n\t\t\t\tJOIN ge_subdomains as subdomain\n\t\t\t\t\tON(site.id=subdomain.site_id)\n\t\t\t\t\t\n\t\t\t\tWHERE\n\t\t\t\t\tsub_domain=" . $db->valueQuote($db->getEscaped($sub)); $res = $db->query($sql)->fetch(); if ($res->active == 0) { throw new InActiveException(); } if ($res) { return $res->id; } else { return false; } }
public function saveCode() { Factory::getUser()->authorise("template", ResponseRegistery::getInstance()->site_id); $db = Factory::getDBO(); $data->main = $this->input->getString('main'); $data->id = $this->getWebLogTemplateId(); $db->StoreObject("ge_templates", $data); //Messages::getInstance()->logSuccess('قالب با موفقیت ذخیره و اعمال شد'); $msg = Messages::getInstance(); $msg->logSuccess('قالب با موفقیت ذخیره شد'); if ($this->compile($data->main, $data->id)) { $msg->logSuccess('قالب با موفقیت اعمال شد'); } else { $msg->logError('در ساختار قالب خطا وجود دارد لطفا قبل از نمایش وبلاگ این خطاها را بررسی کنید'); } $this->reponse->redirect(ResponseRegistery::getInstance()->baseURL . "/dashboard/template/show"); }
public function findWeblogAddress() { $db = Factory::getDBO(); $sql = 'SELECT site.id, sub_domain FROM ge_subdomains sub JOIN ge_sites as site ON(sub.site_id=site.id) JOIN ge_users_sites as us ON(site.id=us.site_id) WHERE us.user_id=' . intval(Factory::getUser()->id); fb(Factory::getUser()->id, 'user_id'); $sub = $db->query($sql)->fetch(); if ($sub) { ResponseRegistery::getInstance()->site_id = $sub->id; return $sub->sub_domain; } return false; }
private function getItemPerPage($id) { return 50; return Factory::getDBO()->SimpleSelect('wb_weblogs', 'post_in_page', 'id=' . $id)->fetch()->post_in_page; }
public function disban() { Factory::getUser()->authorise("admin", ResponseRegistery::getInstance()->site_id); $site_id = $this->input->getInt('id'); $tmp->id = $site_id; $tmp->active = 1; Factory::getDBO()->StoreObject("ge_sites", $tmp); Messages::getInstance()->logSuccess('سایت مورد نظر با موفقیت فعال شد'); $this->reponse->redirect(ResponseRegistery::getInstance()->baseURL . "/admin/blog/show"); }
/** Load module by module id @private **/ private static function _loadById($id) { $db = Factory::getDBO(); $sql = "SELECT *" . "\n FROM {TABLE_PREFIX}_modules" . "\n WHERE `id` = " . $db->Quote($id) . "\n AND `published` = '1'" . "\n ORDER BY `ordering`"; $db->query($sql); return $db->fetch_object(); }
/** Constructor @abstract **/ function __construct() { // init db $this->__db =& Factory::getDBO(); }
public function __construct() { $this->db = Factory::getDBO(); $this->input = Request::getInstance(); $this->reponse = Response::getInstance(); }
/** Simple XSS fix @param $var string @param $convert_to_html boolean @public **/ function cleanVar($var, $convert_to_html = true) { // init db $db =& Factory::getDBO(); if (get_magic_quotes_gpc()) { $var = stripslashes($var); } // utilize mysql string escape function $config =& Factory::getConfig(); if (strpos($config->dsn, 'mysql') !== false) { $var = @mysql_real_escape_string($var); } if ($convert_to_html) { $var = htmlentities($var); } return $var; }
/** Save redirection uri to table @param $oldurl string @param $newurl string @private **/ private static function saveRedirection($oldurl, $newurl) { $db = Factory::getDBO(); // check if exists // pass 1 $query = "SELECT `newurl`" . "\n FROM {TABLE_PREFIX}_redirection" . "\n WHERE `oldurl` = " . $db->Quote($oldurl); $db->query($query); $result = $db->result(); if (!empty($result)) { // update on recent change if ($result != $newurl) { $query = "UPDATE {TABLE_PREFIX}_redirection" . "\n SET `newurl` = " . $db->Quote($newurl) . "\n WHERE `oldurl` = " . $db->Quote($oldurl); $db->query($query); $result = $newurl; } return $result; } // pass 2 $query = "SELECT count(*)" . "\n FROM {TABLE_PREFIX}_redirection" . "\n WHERE `newurl` = " . $db->Quote($newurl); $db->query($query); $found = (int) $db->result(); // increment if ($found) { $newurl = $newurl . "-{$found}"; } /**/ // 11/09/2012 $values = array($db->Quote($newurl), $db->Quote($oldurl)); $query = "INSERT IGNORE INTO {TABLE_PREFIX}_redirection(`newurl`,`oldurl`)" . "\n VALUES(" . implode(',', $values) . ")"; $db->query($query); if ($found) { return $newurl; } return false; }
public function __construct() { $this->db = Factory::getDBO(); }
/** Check if selected language is active @return boolean @private **/ private static function _isActive($lang_id) { $db =& Factory::getDBO(); $sql = "SELECT `published`" . "\n FROM {TABLE_PREFIX}_languages" . "\n WHERE `lang_code` = " . $db->Quote($lang_id); $db->query($sql); return (int) $db->result(); }
/** Class constructor @public **/ function __construct() { $this->__dbo =& Factory::getDBO(); $this->_build(); }
public function __construct($task) { $this->db = Factory::getDBO(); $this->task = $task; }
/** Attempt to log credentials @param $username string @param $password string @private **/ private function _attemptLogin($username, $password) { $db =& Factory::getDBO(); $sql = "SELECT *" . "\n FROM {TABLE_PREFIX}_users" . "\n WHERE md5(`username`) = " . $db->Quote($username) . "\n AND `blocked` = 0"; $db->query($sql); $row = $db->fetch_object(); if (!$row) { return false; } if ($password != $row->password) { return false; } // update last login date if ($this->_in_session($username, $password)) { $now = date('Y-m-d H:i:s'); $sql = "UPDATE {TABLE_PREFIX}_users" . "\n SET `lastvisit` = " . $db->Quote($now) . "\n WHERE `id` = " . $db->Quote($row->id); $db->query($sql); } $this->id = $row->id; $this->username = $row->username; $this->level = $row->level; $this->parent = $row->parent; $this->blocked = $row->blocked; $this->_storeSessionData($username, $password); $this->_loggedIn = true; return true; }