function getModel($name) { global $db; $m = new DBModel($name, false); $m->setDb($db); $m->useCache(false); return $m; }
public static function getDB() { if (self::$dbModel == null) { self::$dbModel = new self(); } return self::$dbModel; }
function RecentRP_getRecentComments($blogid) { $context = Model_Context::getInstance(); $data = $context->getProperty('plugin.config'); $comments = array(); $limitLine = $data['repliesList'] ? $data['repliesList'] : $context->getProperty('skin.commentsOnRecent'); $pool = DBModel::getInstance(); $pool->reset('Comments'); $pool->setQualifier('blogid', 'equals', intval($context->getProperty('blog.id'))); $pool->setQualifier('isfiltered', 'equals', 0); $pool->setQualifier('entry', 'neq', 0); if ($data['repliesChk'] != 1) { $pool->setQualifier('replier', null); } $pool->setOrder('written', 'DESC'); $pool->setLimit($limitLine); $result = $pool->getAll(); foreach ($result as $comment) { if ($data['repliesChk'] == 2) { $pool->reset('Comments'); $pool->setQualifier('blogid', 'equals', $context->getProperty('blog.id')); $pool->setQualifier('parent', 'equals', $comment['id']); $row = $pool->getCount(); $comment['replier'] = $row ? "<img src=\"" . $context->getProperty("plugin.uri") . "/replier.gif\" width=\"11\" height=\"9\" align=\"top\" style=\"margin-left:2px;\" alt=\"\" />" : ""; } else { $comment['replier'] = ""; } $comment['secret'] = $comment['secret'] == 1 ? "<img src=\"" . $context->getProperty("plugin.uri") . "/secret.gif\" width=\"9\" height=\"11\" style=\"margin-left:2px;\" alt=\"\" />" : ""; array_push($comments, $comment); } return $comments; }
/** * constructor * @param \Nette\Database\Context $database * @param int $id * @return void */ public function __construct(\Nette\Database\Context $database, $config) { parent::__construct($database, $config); $this->setTable($this->config["table"]); $this->defaultValues = $this->config["default"]; return; }
public function actionGetAllNews() { $news = DBModel::getDB()->getAllNews(); $view = new View(); $view->setData($news); echo $view->render("main.php"); }
protected function __construct($group, $key, $allowed) { parent::__construct(); $this->groupID = $group; $this->keyID = $key; $this->allowed = $allowed; }
function getBlogidBySecondaryDomain($domain) { $pool = DBModel::getInstance(); $pool->init("BlogSettings"); $pool->setQualifier('name', 'eq', 'secondaryDomain', true); $pool->setQualifierSet(array("value", "eq", $domain, true), "OR", array("value", "eq", substr($domain, 0, 4) == 'www.' ? substr($domain, 4) : 'www.' . $domain, true)); return $pool->getCell("blogid"); }
function getSkinSettingForMigration($blogid, $name, $default = null) { $pool = DBModel::getInstance(); $pool->reset("SkinSettingsMig"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("name", "eq", $name, true); $value = $pool->getCell("value"); return $value === null ? $default : $value; }
private static function initialize() { global $memcache; /** After PHP 5.0.5, session write performs after object destruction. */ self::$mc = $memcache; /** To Avoid this, just copy memcache handle into Session object. */ self::$context = Model_Context::getInstance(); self::$pool = DBModel::getInstance(); }
function getBlogidByName($name) { $query = DBModel::getInstance(); $query->reset('BlogSettings'); $query->setQualifier('name', 'equals', 'name', true); $query->setQualifier('value', 'equals', $name, true); return $query->getCell('blogid'); return false; }
protected function validate($for) { parent::validate($for); if ($for == 'insert' && self::get($this->language)) { $this->language_error = t('%n is used'); throw new ValidationException($this); } }
protected function validate($for) { parent::validate($for); if (self::get($this->userID, $this->groupID)) { throw new Exception(t('User is already member of group')); } }
function printMobileEntryContent($blogid, $userid, $id) { $pool = DBModel::getInstance(); $pool->reset('Entries'); $pool->setQualifier('blogid', 'eq', $blogid); $pool->setQualifier('userid', 'eq', $userid); $pool->setQualifier('id', 'eq', $id); return $pool->getCell('content'); }
private function open_connection() { $SERVIDOR = filter_input_array(INPUT_SERVER); $PATH = $SERVIDOR['DOCUMENT_ROOT'] . "/kamarena/quiniclubs_server"; include "{$PATH}/core/adodb5/adodb.inc.php"; $bd = NewADOConnection("mysql"); $bd->Connect(self::$db_host, self::$db_user, self::$db_pass, self::$db_name); mysql_query("SET NAMES 'utf8'"); self::$conn = $bd; }
function _buildQuery() { $query = DBModel::getInstance(); $query->reset('ServiceSettings'); $query->setQualifier('name', 'equals', Utils_Unicode::lessenAsEncoding($this->name, 32), false); if (isset($this->value)) { $query->setAttribute('value', Utils_Unicode::lessenAsEncoding($this->value, 255), true); } return $query; }
protected function beforeSave() { if (parent::beforeSave()) { $this->uid = Yii::app()->user->id; $this->uname = Yii::app()->user->name; $this->acttime = time(); return true; } else { return false; } }
function FAS_Call($type, $name, $title, $url, $content) { $context = Model_Context::getInstance(); $pool = DBModel::getInstance(); $blogstr = $context->getProperty('uri.host') . $context->getProperty('uri.blog'); $DDosTimeWindowSize = 300; $rpc = new XMLRPC(); $rpc->url = 'http://antispam.textcube.org/RPC/'; if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) { // call fail // Do Local spam check with "Thief-cat algorithm" $count = 0; if ($type == 2) { $storage = "RemoteResponses"; $pool->reset($storage); $pool->setQualifier("url", "eq", $url, true); $pool->setQualifier("isfiltered", ">", 0); if ($cnt = $pool->getCount("id")) { $count += $cnt; } } else { // Comment Case $storage = "Comments"; $pool->reset($storage); $pool->setQualifier("comment", "eq", ${$content}, true); $pool->setQualifier("name", "eq", $name, true); $pool->setQualifier("homepage", "eq", $url, true); $pool->setQualifier("isfiltered", ">", 0); if ($cnt = $pool->getCount("id")) { $count += $cnt; } } // Check IP $pool->reset($storage); $pool->setQualifier("ip", "eq", $_SERVER['REMOTE_ADDR'], true); $pool->setQualifier("written", ">", Timestamp::getUNIXtime() - $DDosTimeWindowSize); if ($cnt = $pool->getCount("id")) { $count += $cnt; } if ($count >= 10) { return false; } return true; } if (!is_null($rpc->fault)) { // FAS has some problem return true; } if ($rpc->result['result'] == true) { return false; // it's spam } return true; }
static function getUserNamesOfBlog($blogid) { // TODO : Caching with global cache component. (Usually it is not changing easily.) $pool = DBModel::getInstance(); $pool->reset('Privileges'); $pool->setQualifier('blogid', 'eq', $blogid); $authorIds = $pool->getColumn('userid'); $pool->reset('Users'); $pool->setQualifier('userid', 'hasOneOf', $authorIds); return $pool->getAll('userid,name'); }
function _buildQuery() { $query = DBModel::getInstance(); $query->reset('UserSettings'); $query->setQualifier('userid', 'equals', getUserId()); $query->setQualifier('name', 'equals', $this->name, false); if (isset($this->value)) { $query->setAttribute('value', $this->value, true); } return $query; }
/** * constructor * @param \Nette\Database\Context $database * @param int $id * @return void */ public function __construct(\Nette\Database\Context $database, $config) { parent::__construct($database, $config); $this->setTable($config["table"]); if (is_array($this->config["default"])) { foreach ($this->config["default"] as $default) { $this->defaultValues = $default . "\n"; } } return; }
$list = Mail::_readFile(); array_push($list, $newmail['title']); array_push($list, $newmail['content']); Mail::_writeFile($list); } /** * Manually send an email to all addresses. * @param string mailto address * @param string mail content * @param array word replace rules * */ public static function manualsend($maillist = null, $title, $content, $attachment = null)
function load($fields = '*') { global $database; $blogid = getBlogId(); $this->reset(); $query = DBModel::getInstance(); $query->reset('BlogSettings'); if ($query->doesExist()) { $query->setQualifier('blogid', 'equals', $blogid); $blogSettings = $query->getAll('name,value'); if (isset($blogSettings)) { foreach ($blogSettings as $blogSetting) { $name = $blogSetting['name']; $value = $blogSetting['value']; switch ($name) { case 'logo': $name = 'banner'; break; case 'entriesOnPage': $name = 'postsOnPage'; break; case 'entriesOnList': $name = 'postsOnList'; break; case 'entriesOnRSS': $name = 'postsOnFeed'; break; case 'publishWholeOnRSS': $name = 'publishWholeOnFeed'; break; case 'allowWriteOnGuestbook': $name = 'acceptGuestComment'; break; case 'allowWriteDblCommentOnGuestbook': $name = 'acceptcommentOnGuestComment'; break; case 'defaultDomain': case 'useSloganOnPost': case 'useSloganOnCategory': case 'useSloganOnTag': case 'acceptGuestComment': case 'acceptcommentOnGuestComment': $value = $value ? true : false; break; } $this->{$name} = $value; } } return true; } return false; }
function getDefaultDBModelOnNotice($blogid) { $query = DBModel::getInstance(); $query->reset('Entries'); $query->setQualifier('blogid', 'equals', $blogid); $query->setQualifier('draft', 'equals', 0); if (!doesHaveOwnership()) { $query->setQualifier('visibility', 'bigger', 1); } $query->setQualifier('category', 'equals', -2); $query->setOrder('published', 'DESC'); return $query; }
function _buildQuery() { $query = DBModel::getInstance(); $query->reset('BlogStatistics'); $query->setQualifier('blogid', 'equals', getBlogId()); if (isset($this->visits)) { if (!Validator::number($this->visits, 0)) { return $this->_error('visits'); } $query->setAttribute('visits', $this->visits); } return $query; }
public function reset() { parent::reset('Lines'); $this->id = null; $this->blogid = getBlogId(); $this->category = 'public'; $this->root = 'default'; $this->author = ''; $this->content = ''; $this->permalink = ''; $this->created = null; $this->filter = array(); $this->_error = array(); }
function getEntriesByKeyword($blogid, $keyword) { $pool = DBModel::getInstance(); $pool->reset('Entries'); $pool->setQualifier('blogid', 'eq', $blogid); $pool->setQualifier('draft', 'eq', 0); if (doesHaveOwnership()) { $pool->setQualifier('visibility', 'b', 1); } $pool->setQualifier('category', 'beq', 0); $pool->setQualifierSet(array('title', 'like', $keyword, true), 'OR', array('content', 'like', $keyword, true)); $pool->setOrder('published', 'DESC'); return $pool->getRow('id,userid,title,category,comments,published'); }
function _buildQuery() { if (!Validator::directory($this->name)) { return $this->_error('name'); } $query = DBModel::getInstance(); $query->reset('Plugins'); $query->setQualifier('blogid', 'equals', getBlogId()); $query->setQualifier('name', 'equals', Utils_Unicode::lessenAsEncoding($this->name, 255), true); if (isset($this->setting)) { $query->setAttribute('settings', $this->setting, true); } return $query; }
public function activate() { if ($this->_list !== null) {return false;} list ($qs, $args) = $this->getSQLQuery(); $q = DB::prepare($qs); $q->execute($args); $this->_list = array(); $this->rewind(); foreach ($q->fetchAll() as $row) { $this->_list[] = DBModel::fetch($row, $this->_from); } return true; }
function suggestLocatives($blogid, $filter) { $pool = DBModel::getInstance(); $pool->reset("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("location", "like", $filter . '%', true); $pool->setGroup("location"); $pool->setOrder("cnt", "desc"); $pool->setLimit(10); $result = $pool->getAll("location, COUNT(*) cnt", array("filter" => "distinct")); $locatives = array(); if ($result) { foreach ($result as $locative) { $locatives[] = $locative[0]; } } return $locatives; }
function _getRecentEntries($blogid) { $query = DBModel::getInstance(); $query->reset('Entries'); $query->setQualifier('blogid', 'equals', $blogid); $query->setQualifier('draft', 'equals', 0); if (doesHaveOwnership()) { $query->setQualifier('visibility', 'bigger', 0); } $query->setQualifier('category', 'bigger or same', 0); $query->setLimit(8); $query->setOrder('published', 'desc'); $result = $query->getAll('id,title,comments'); if (!empty($result)) { return $result; } else { return array(); } }