Location: PHPKode > projects > Buzzword > buzzword-0.8.12/blog/sidebar.inc
<?php

/*
 * buzzword
 * Copyright (c) 2003 Jon Tai
 *
 * $Id: sidebar.inc 267 2004-03-31 03:14:55Z bradt $
 *
 * This file is part of buzzword.
 *
 * buzzword is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * buzzword is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with buzzword; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

function get_sidebar_blog_months() {
    $archive = '';

    $sql = 'SELECT DISTINCT MONTH(created) AS month, YEAR(created) AS year ';
    $sql .= 'FROM '.DB_PREFIX.'blog_entries ';
    if (!defined('ADMIN_LOGGED_IN')) {
        $sql .= "WHERE is_private = 'N' ";
        $sql .= "AND is_hidden = 'N' ";
    }
    $sql .= 'ORDER BY created DESC';
    $result = mysql_query($sql);

    while ($row = mysql_fetch_assoc($result)) {
        $month = mktime(0, 0, 0, $row['month'], 1, $row['year']);
        $archive .= '<a href="archive.php?d='.$month.'">'.date('F Y', $month)."</a><br>\n";
    }

    return ($archive == '') ? "archives not available<br>\n" : $archive;
}

?>
Return current item: Buzzword