_table = 'common_searchindex'; $this->_pk = 'searchid'; parent::__construct(); } public function fetch_by_searchid_srchmod($searchid, $srchmod) { return DB::fetch_first('SELECT * FROM %t WHERE searchid=%d AND srchmod=%d', array($this->_table, $searchid, $srchmod)); } public function count_by_dateline($timestamp, $srchmod = '') { return DB::result_first('SELECT COUNT(*) FROM %t WHERE '.($srchmod ? 'srchmod='.dintval($srchmod).' AND ' : '').'dateline>%d-60', array($this->_table, $timestamp)); } public function fetch_all_search($searchctrl, $useip, $uid, $timestamp, $searchstring, $srchmod = '') { if(!$searchctrl || !$timestamp) { return null; } $timestamp = dintval($timestamp); $uid = dintval($uid); $srchmod = dintval($srchmod); $useip = daddslashes($useip); $searchctrl = dintval($searchctrl); $searchstring = daddslashes($searchstring); return DB::fetch_all("SELECT searchid, dateline, ('".$searchctrl."'<>'0' AND ".(empty($uid) ? "useip='$useip'" : "uid='$uid'")." AND $timestamp-dateline<'".$searchctrl."') AS flood, (searchstring='$searchstring' AND expiration>'$timestamp') AS indexvalid FROM ".DB::table($this->_table)." WHERE ".($srchmod ? "srchmod='$srchmod' AND " : '')."('".$searchctrl."'<>'0' AND ".(empty($uid) ? "useip='$useip'" : "uid='$uid'")." AND $timestamp-dateline<".$searchctrl.") OR (searchstring='$searchstring' AND expiration>'$timestamp') ORDER BY flood"); } } ?>