Location: PHPKode > projects > GeBlog > v.1/mod/News/func.php
<?php
// ----------------------------------------------------------------------
// GeBlog - Weblogging system
// Copyright (C) 2003 by the GeBlog Development Team.
// https://sourceforge.net/projects/geblog/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jay Talbot
// Purpose of file: To house the functions for the blog/news module.
// ----------------------------------------------------------------------

if (eregi("func.php", $_SERVER['PHP_SELF']))
{
    die ("You can't access this file directly...");
}

function GetBlogRows()
{
    extract($GLOBALS);
    $conn->Connect($dbserver,$dbuser,$dbpass,$dbname);
    $sql = "SELECT * FROM blog";
    $rs = &$conn->Execute($sql);
    if (!$rs) print $conn->ErrorMsg();
    $GLOBALS['entries'] = $rs->RecordCount();

    if ($_GET['viewing'] != NULL)
    {
        $GLOBALS['viewing'] = $_GET['viewing'];
    }
    else
    {
        $GLOBALS['viewing'] = $GLOBALS['entries'];
    }
}

function BlogPreviousNext()
{
    GetBlogRows();
    extract($GLOBALS);
    extract($_SERVER);
    $p = array($viewing, $num_to_show);
    $previous = array_sum($p);//($viewing + $num_to_show);
    $next = ($viewing - $num_to_show);
    echo "<TR>";
    echo "<TD WIDTH=\"100%\"><FONT CLASS=\".menu-link\">";

    if ($viewing < $entries) {
        echo "<a href=\"?mod=News&viewing=".$previous."\">&lt;&lt; Previous ".$num_to_show."</a> | ";
    }
    else
    {
        echo "&lt;&lt; Previous ".$num_to_show." | ";
    }
    if ($viewing > 0 && ($viewing - $num_to_show) >= 0 && $next != 0) {
        echo "<a href=\"?mod=News&viewing=".$next."\">Next ".$num_to_show." &gt;&gt;</a><p></font></td>\n";
    }
    else
    {
        echo "Next ".$num_to_show." &gt;&gt;<p></font>";
    }
}

function PrintBlogEntries()
{
    extract($GLOBALS);
    $conn->Connect($dbserver,$dbuser,$dbpass,$dbname);
    if(!empty($viewing))
    {
        $sql = "SELECT id,DATE_FORMAT(date, '%m/%d/%Y %l:%i%p'),title,entry,mood,music FROM blog WHERE id<=".$viewing." order by id desc LIMIT $num_to_show";
    }
    else
    {
        $sql = "SELECT id,DATE_FORMAT(date, '%m/%d/%Y %l:%i%p'),title,entry,mood,music FROM blog order by id desc LIMIT $num_to_show";
    }
    $rs = $conn->Execute($sql);

    if (!$rs) die($conn->ErrorMsg());

    while (!$rs->EOF)
    {
        $entry['id']     = $rs->fields[0];
        $entry['edate']  = $rs->fields[1];
        $entry['btitle'] = $rs->fields[2];
        $entry['story']  = $rs->fields[3];
        $entry['mood']   = $rs->fields[4];
        $entry['music']  = $rs->fields[5];
        FormatBlogEntry($entry);
        //echo $format;
        $rs->MoveNext();
    }
}

function FormatBlogEntry($entry)
{
    extract($entry);
    $story = nl2br($story);
    echo "<font SIZE=\"3\" COLOR=\"#8080FF\"><b>".$btitle."</b></font><br>\n";
    echo $edate."<p>\n";
    echo $story."<p>\n";
    echo "<HR>\n";
    //echo $format;*/
//echo "<i>Mood:</i>  ".$mood."<br>";
//echo "<i>Music:</i>  ".$music."<p>";
//echo "</font>";
}

?>
Return current item: GeBlog