rendered paste body<?php require('wp-config.php'); $single = 1; $siteurl = get_settings('siteurl'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/1">
<title><?php bloginfo('name'); ?><?php wp_title(); ?> Archive</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<style type="text/css" media="screen">
@import url( <?php echo get_settings('siteurl'); ?>/wp-content/themes/comicpress/style.css );
</style>
<link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/wp-content/themes/comicpress/style.css" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php //comments_popup_script(); // off by default ?>
<?php wp_head(); ?>
</head>
<body>
<div id="header">
<h1><a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?></a></h1>
<div class="description">»<?php bloginfo('description'); ?></div>
</div>
<div id="headerbar">
<div class="headerbarlinks"><a href="/">LINK1</a> | <a href="/">LINK2</a> | <a href="/">LINK3</a> | <a href="/">LINK4</a> | <a href="/">LINK5</a></div>
</div>
<div id="page">
<div id="content" class="narrowcolumn">
<br /><br />
<?php error_reporting(0); ?>
<?php
$posts_per_page = '-1';
$defaultorderby = 'post_date';
$defaultorder = 'DESC';
define('NL', "\n");
function show_year_select() {
global $wpdb, $wpdb->posts, $m;
$m = substr($m,0,4);
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) as year FROM $wpdb->posts ORDER BY year ASC");
$output .= '<option value="">All Years</option>'.NL;
foreach ($years as $year) {
$output .= '<option value="'.$year.'"';
if ($year == $m) {
$output .= ' selected="selected"';
}
$output .= '>'.$year.'</option>';
}
$output = '<select name="m">'.NL.$output.'</select>'.NL;
echo $output;
}
function show_author_select() {
global $wpdb, $wpdb->users, $author;
$users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0", ARRAY_A);
$output .= '<option value="">All Authors</option>'.NL;
foreach ($users as $user) {
$output .= '<option value="'.$user['ID'].'"';
if ($user['ID'] == $author) {
$output .= 'selected="selected"';
}
$output .= '>'.$user['user_nickname'].'</option>'.NL;
}
$output = '<select name="author">'.NL.$output.'</select>'.NL;
echo $output;
}
function show_orderby_select() {
global $orderby;
$orderby = explode(' ', $orderby);
$orderby = $orderby[0];
if ($orderby == 'date') {
$output .= '<option value="date" selected="selected">Date</option>'.NL;
} else {
$output .= '<option value="date">Date</option>'.NL;
}
if ($orderby == 'title') {
$output .= '<option value="title" selected="selected">Title</option>'.NL;
} else {
$output .= '<option value="title">Title</option>'.NL;
}
if ($orderby == 'category') {
$output .= '<option value="category" selected="selected">Category</option>'.NL;
} else {
$output .= '<option value="category">Category</option>'.NL;
}
$output = '<select name="orderby" onchange="Choose(this)">'.NL.$output.'</select>'.NL;
echo $output;
}
function show_order_select() {
global $order;
if ($order == 'ASC') {
$output .= '<option value="ASC" selected="selected">Ascending</option>'.NL;
} else {
$output .= '<option value="ASC">Ascending</option>'.NL;
}
if ($order == 'DESC') {
$output .= '<option value="DESC" selected="selected">Descending</option>'.NL;
} else {
$output .= '<option value="DESC">Descending</option>'.NL;
}
$output = '<select name="order" id="asc_desc">'.NL.$output.'</select>'.NL;
echo $output;
}
function archive_header($before='', $after='') {
global $post, $orderby, $month, $previous, $siteurl, $blogfilename, $archiveheadstart, $archiveheadend, $category_name;
$orderby = explode(' ', $orderby);
$orderby = $orderby[0];
if ('date' == $orderby || empty($orderby)) {
$thismonth = mysql2date('m', $post->post_date);
$thisyear = mysql2date('Y', $post->post_date);
$thisdate = $thisyear.$thismonth;
if ($thisdate != $previous) {
$thismonth = mysql2date('m', $post->post_date);
$output .= '<strong><br/><br/>'.$month[$thismonth].' '.$thisyear.'</strong>';
}
$previous = $thisdate;
} elseif ('title' == $orderby) {
preg_match('/[a-z0-9]{1}/i', $post->post_title, $match);
$thisletter = ucfirst($match[0]);
if ($thisletter != $previous) {
$output .= "<br/><br/>".$thisletter;
}
$previous = $thisletter;
} elseif ('category' == $orderby) {
$thiscategory = $category_name;
if ($thiscategory != $previous) {
$output .= '<br/><br/><strong>'.get_catname($thiscategory).'</strong>';
}
$previous = $thiscategory;
}
if (!empty($output)) {
$output = $before.$output.$after.NL;
echo $output;
}
}
function archive_date($format='Y-m-d H:i:s') {
global $post;
echo mysql2date($format, $post->post_date);
}
?>
<script language="javascript" type="text/javascript">
function Choose(whichSort) {
if (whichSort.selectedIndex == 2) {
document.getElementById('asc_desc').selectedIndex = 1;
} else {
document.getElementById('asc_desc').selectedIndex = 0;
}
}
</script>
<?php
//Make sure categories get parsed out, they are deprecated in wp-blog-header.php
if ($_POST["orderby"] == 'category') {
global $author, $m;
$orderby = 'category';
if ($_POST["order"] == '') $order = "DESC";
else $order = $_POST["order"];
$year = '' . intval($_POST["m"]);
$m = $year;
$author = ''.intval($_POST["author"]);
if (empty($author)) {
$whichauthor='';
} else {
$author = ''.urldecode($author).'';
$author = addslashes_gpc($author);
if (stristr($author, '-')) {
$eq = '!=';
$andor = 'AND';
$author = explode('-', $author);
$author = ''.intval($author[1]);
} else {
$eq = '=';
$andor = 'OR';
}
$author_array = explode(' ', $author);
$whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
$whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
}
$whichauthor .= ')';
}
// Author stuff for nice URIs
if ('' != $author_name) {
if (stristr($author_name,'/')) {
$author_name = explode('/',$author_name);
if ($author_name[count($author_name)-1]) {
$author_name = $author_name[count($author_name)-1];#no trailing slash
} else {
$author_name = $author_name[count($author_name)-2];#there was a trailling slash
}
}
$author_name = preg_replace('|[^a-z0-9-]|', '', strtolower($author_name));
$author = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$author_name."'");
$whichauthor .= ' AND (post_author = '.intval($author).')';
}
if (!empty($year)) $where .= ' AND YEAR(post_date)=' . $year;
if (!empty($whichauthor)) $where .= $whichauthor;
?>
<h2>Archives</h2>
<br><b>Sort By:</b>
<form action="<?php getenv('PHP_SELF') ?>" method="post">
<?php show_orderby_select() ?>
<?php show_order_select() ?>
<?php show_year_select() ?>
<input type="submit" name="submit" value="sort" />
</form>
<?php
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE 1=1 ORDER BY cat_name $order");
foreach ($dogs as $catt) {
$categories = $wpdb->get_results("SELECT * FROM $wpdb->post2cat WHERE category_id = $catt->cat_ID");
if ($categories) {
foreach ($categories as $post2category) {
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE $post2category->post_id = ID".$where);
//$category_realname = $wpdb->get_row("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = $post2category->category_id");
//print_r($category_realname);
global $category_name;
$category_name = $post2category->category_id;
if ($posts) {
foreach ($posts as $post) {
start_wp();
archive_header('<h3>', '</h3>');
archive_date('m-d-Y') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
<?php
}
}
}
}
}
}
else {
require_once ('wp-blog-header.php');
// echo $request;
?>
<h2>Archives</h2>
<hr />
<div><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><small>Sort By:</small></td></tr>
<tr><td colspan="2"><form action="<?php getenv('PHP_SELF') ?>" method="post">
<?php show_orderby_select() ?>
<?php show_order_select() ?>
<?php show_year_select() ?>
<input type="submit" name="submit" id="sortsubmit" value="Sort" />
</form></td></tr></table>
<table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><small>Search:</small></td></tr>
<tr><td><form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="47" />
<input type="submit" id="searchsubmit" value="Search" />
</form></td><td><form method="get" id="searchformclear" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" value="" />
<input type="submit" id="searchsubmitclear" value=" Clear" /></form></td></tr></table>
</div>
<hr />
<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<?php //print_r($post); ?>
<?php archive_header('<h3>', '</h3>') ?>
<?php archive_date('m-d-Y') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
<?php } }
}?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>