public function get_archives($num = 3, $cat = 'all', $page = 1) { global $scdb; $this->archives->num = (int) is_nat($num) ? $num : 3; $this->archives->page = (int) is_nat($num) ? $page : 1; $this->archives->start = (int) ($page - 1) * $num; $this->archives->cat = $cat; $sql = "SELECT * FROM `{$scdb->news}` "; if ('all' != $cat && ($cat = is_nat($cat))) { $this->archives->cat = $cat; $sql .= "WHERE `cat` = {$cat} "; } $sql .= ' ORDER BY `ID` DESC LIMIT ' . $this->archives->start . ',' . $this->archives->num; $this->archives->data = $scdb->get_results($sql); $this->archives->last = $this->archives->data[end(array_keys($this->archives->data))]; return $this->archives->data; }
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; }
?> <meta name="description" content="our blog of sorts"/> <title>SpiffyNews!</title> </head> <?php get_sidebar(); ?> <div id="content"> <?php $page = (int) isset($_GET['page']) ? $_GET['page'] : 1; if ('page' == $_VAR && isset($_VARS[0]) && is_nat($_VARS[0])) { $page = is_nat($_VARS[0]); } foreach ($news->get_archives(5, 'all', $page) as $post) { ?> <div class="post" id="post-<?php echo $post->ID; ?> "> <div class="post-date-blog"><span class="post-month"><?php echo get_date('M', $post->time); ?> </span> <span class="post-day"><?php echo get_date('j', $post->time); ?>
if (!isset($_SERVER['HTTP_REFERER'][1])) { exit; } $URL = parse_url($_SERVER['HTTP_REFERER']); $_PATH = $URL['path']; /* if(isset($URL['query']{1})) { $_QUERY = array(); foreach(explode('&', $URL['query']) as $var) { list($q, $v) = explode('=', $var, 1); $_QUERY[$q] = $v; } } */ if (isset($_GET['form']) && $_GET['form'] == 'comment') { if (isset($_GET['p']) && is_nat($_GET['p'])) { $ID = (int) $_GET['p']; $comic->get_comic_by_permalink($ID); } elseif (preg_match('@^/(\\d+)/@', $_PATH, $ID)) { $ID = (int) (isset($ID[1]) && is_numeric($ID[1])) ? $ID[1] : 0; $comic->get_comic($ID); } elseif (preg_match('@^/(\\w+)/?(?:(\\d{1,5})/?)?@', $_PATH, $cat_ID)) { $category = safe_text(strtolower($cat_ID[1])); $cat = (int) $scdb->get_var("SELECT `ID` FROM `{$scdb->categories}` WHERE `nicename` = '{$category}' LIMIT 1"); if ($scdb->num_rows == 1) { $comic->cat = $cat; $ID = (int) (isset($cat_ID[2]) && is_numeric($cat_ID[2])) ? $cat_ID[2] : 0; $comic->get_comic($ID); } else { die; }
<?php if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) { exit(header('Location: index.php')); } if (isset($_GET['id']) && ($ID = is_nat($_GET['id']) && ($cat = get_category($ID)))) { $category = $category->category; $nicename = $category->nicename; if (isset($_POST['del']) && isset($_POST['option'])) { echo '<br /><fieldset>'; $message = ''; switch ($_POST['option']) { default: exit(header('Location: index.php?page=admin&option=cat-edit&id=' . $ID)); break; case 'cat': $scdb->query("DELETE FROM `{$scdb->categories}` WHERE `ID` = '{$ID}' LIMIT 1"); $message = '<p class="message">Removed <strong>“' . $category . '”</strong> from the categories.</p>'; break; case 'db': $scdb->query("DELETE FROM `{$scdb->categories}` WHERE `ID` = '{$ID}' LIMIT 1"); $scdb->query("DELETE FROM `{$scdb->comics}` WHERE `cat` = '{$ID}'"); $scdb->query("DELETE FROM `{$scdb->comments}` WHERE `cat` = '{$ID}'"); $message = '<p class="message">Removed anything connected to <strong>“' . $category . '”</strong> from the database.</p>'; break; case 'all': $scdb->query("DELETE FROM `{$scdb->categories}` WHERE `ID` = '{$ID}' LIMIT 1"); $scdb->query("DELETE FROM `{$scdb->comics}` WHERE `cat` = '{$ID}'"); $scdb->query("DELETE FROM `{$scdb->comments}` WHERE `cat` = '{$ID}'"); $message = '<p class="message">Removed anything connected to <strong>“' . $category . '”</strong> from the database and deleted the image files.</p>'; rm_recursive(IMG_FOLDER . $nicename . '/');
if ('' == $_ACT) { require theme() . '/index.php'; } elseif ($ID = is_nat($_ACT)) { $comic->get_comic($ID); require theme() . '/single.php'; } elseif ('archive' == $_ACT) { require theme() . '/archive.php'; } elseif ('news' == $_ACT) { require theme() . '/news.php'; } elseif ('feed' == $_ACT) { require 'feed.php'; } elseif ('comments' == $_ACT) { require 'feed-comments.php'; } elseif ($cat = is_category($_ACT)) { $comic->cat = $cat->ID; $ID = is_nat($_VAR); $comic->get_comic($ID); require theme() . '/single.php'; } elseif ($cat = is_category($_ACT) && 'random' == $_VAR) { $comic->cat = $cat->ID; $comic->random(); } elseif ('random' == $_ACT) { $comic->random(); } elseif (preg_match('@^/(\\w+\\.php)$@', $_ACT, $file)) { $allowed = array('faq.php', 'contact.php', 'hosting.php'); if (in_array($file[1], $allowed) && file_exists(theme() . '/pages/' . $file[1])) { require theme() . '/pages/' . $file[1]; } else { not_found(); } } else {
public function get_image_by_permalink($PID = false) { if (($PID === false || !is_nat($PID)) && $comic->got_comic === true) { return $this->get_image(); } $this->get_comic_by_permalink($PID); return $this->get_image(); }