Example #1
0
 public function get_categories($type = OBJECT)
 {
     global $scdb;
     $categories = get_cached_var('news-categories');
     if ($categories === false) {
         $categories = $scdb->get_results("SELECT * FROM `{$scdb->news_categories}` ORDER BY `default` DESC, `ID` ASC", $type);
         cache_var('news-categories', $categories);
     }
     return $categories;
 }
Example #2
0
 public function get_archives($num = 10, $page = 1)
 {
     global $scdb, $comic;
     $num = (int) is_nat($num) ? $num : 10;
     $page = (int) is_nat($page) ? $page : 1;
     $start = (int) (intval($page - 1) * $num);
     // we already grabbed the results, just return them again
     if ($this->archives->data !== false && $this->archives->cat == $this->archives_cat && $this->archives->num >= $num && $this->archives->page === $page && $this->archives->start === $start) {
         if ($this->archives->num > $num) {
             return array_slice($this->archives->data, 0, $num);
         }
         return $this->archives->data;
     }
     $this->archives->cat = $this->archives_cat;
     $this->archives->page = $page;
     $this->archives->num = $num;
     $this->archives->start = $start + 1;
     $this->archives->end = $start + $num;
     // check if we've cached them, and return that if we have, return those
     if ($archives = get_cached_var('recent-comments')) {
         if ($archives->cat == $this->archives->cat && $archives->num >= $this->archives->num && $archives->page == $this->archives->page && $archives->start == $this->archives->start) {
             $this->archives = $archives;
             return array_slice($this->archives->data, 0, $num);
         }
     }
     $sql = "SELECT * FROM `{$scdb->comments}`";
     if ($this->archives->cat > 0) {
         $sql .= " WHERE `cat` = '" . $this->archives->cat . "'";
     }
     $sql .= " ORDER BY `time` DESC LIMIT " . $start . ", " . $num;
     $i = 0;
     foreach ($scdb->get_results($sql) as $row) {
         $rows[$i] = $row;
         $rows[$i]->url = DOMAIN . $comic->cat_info($row->cat)->nicename . '/' . $row->comicID . '#comment-' . $row->ID;
         $rows[$i]->title = $scdb->get_var("SELECT `title` FROM `{$scdb->comics}` WHERE `PID` = '{$row->comicPID}' LIMIT 1");
         ++$i;
     }
     if ($i === 0) {
         return false;
     }
     $this->archives->data = $rows;
     // if we've made it this far we should cache the results
     cache_var('recent-comments', $this->archives);
     return $rows;
 }
Example #3
0
 public function get_users($type = OBJECT)
 {
     global $scdb;
     $users = get_cached_var('users', 0);
     if ($users === false) {
         $users = $scdb->get_results("SELECT login, pass, name, nicename, level, ID FROM `{$scdb->users}` ORDER BY `ID` DESC", $type);
         cache_var('users', $users);
     }
     return $users;
 }