'.$years[year].': ');
$qm = mysql_query("SELECT distinct month(post_date) as month
FROM $tableposts
ORDER BY month asc") or die(mysql_error());
while($date = mysql_fetch_array($qm)) {
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month
FROM $tableposts
WHERE year(post_date)='$years[year]'
AND month(post_date)='$date[month]'
AND post_status='publish'
AND post_date <= NOW()
ORDER BY id desc") or die(mysql_error());
$sm = ucfirst(strftime("%b", strtotime("$date[month]/01/2001"))); // get the shortened month name; strtotime() localizes
$pd = sprintf("%02s", $date[month]); // pad the month with a zero if needed
if(mysql_num_rows($q)) { echo(''.$sm.' '); }
else {
if ($sm == "Dec") {
if ($smPrev == "Nov") { echo(''.$sm.' '); }
}
else { echo(''.$sm.' '); }
}
$smPrev=$sm;
}
echo('
');
}
echo ('
');
}
if (($format == 'both') || ($format == 'list')) { //check to see if we are supposed to display the list
$qy = mysql_query("SELECT distinct year(post_date) as year, post_status
FROM $tableposts
WHERE post_status='publish'
AND post_date <= NOW()
ORDER BY year desc");
// loop to display links to all posts, sorted by descending month and day
while($years = mysql_fetch_array($qy)) {
$qm = mysql_query("SELECT distinct month(post_date) as month FROM $tableposts ORDER BY month desc") or die(mysql_error());
while($date = mysql_fetch_array($qm)) {
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month
FROM $tableposts WHERE year(post_date)='$years[year]'
AND month(post_date)='$date[month]'
AND post_status='publish'
AND post_date <= NOW()
ORDER BY id desc") or die(mysql_error());
if(mysql_num_rows($q)) {
$lm = ucfirst(strftime("%B", strtotime("$date[month]/01/2001"))); // get the full month name; strtotime() localizes
$pd = sprintf("%02s", $date[month]); // pad the month with a zero if needed
echo('');
echo('');
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month
FROM $tableposts WHERE year(post_date)='$years[year]'
AND month(post_date)='$date[month]'
AND post_status='publish'
ORDER BY post_date desc") or die(mysql_error());
while($post = mysql_fetch_array($q)) {
if ($post[post_date_gmt] <= $now) {
$printabledate = date("m/d H:i",strtotime($post[post_date]));
if ($catID != '') { // check to see if a category id was specified in the arguments
// get the categories that are attached to the current post
$cats = $wpdb->get_col("SELECT category_id FROM $wpdb->post2cat WHERE post_id = $post[ID]");
$found=false;
foreach ($cats as $cat) { // look to see if the specified category is attached to the current post
if ($cat == $catID) $found=true;
}
if (!$found) echo('- '. $printabledate.' '.$post[post_title].'
');
}
else echo('- '. $printabledate.' '.$post[post_title].'
');
}
}
echo ('
');
}
}
}
}
}
?>