<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied big story MAXIMUS directly...');


if ( $content = opencacheb ( 'BigStory', 'html' , "".CACHE_BL_BIG_STORY."", '1' ) ) {
} else {

global $cookie, $multilingual, $currentlang;

$multilingual = addslashes( $multilingual ) ;
$currentlang  = addslashes( $currentlang ) ;

if ($multilingual == 1) {
    $querylang = "AND (`alanguage`='$currentlang' OR `alanguage`='')"; /* the OR is needed to display stories who are posted to ALL languages */
} else {
    $querylang = "";
}

$today = getdate();
$day = $today["mday"];
if ($day < 10) {
    $day = "0$day";
}
$month = $today["mon"];
if ($month < 10) {
    $month = "0$month";
}
$year = $today["year"];
$tdate = "$year-$month-$day";
$tdate = addslashes( $tdate ) ;
$sql = "SELECT `sid`, `title` FROM `".TABLE_STORIES."` WHERE (`time` LIKE '%$tdate%') $querylang ORDER BY `counter` DESC LIMIT 0,1";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories', '', __LINE__, __FILE__, $sql);}
$row     = $GLOBALS['db']->sql_fetchrow($result);
$fsid    = $GLOBALS['db']->XMFnum($row['sid']);
$ftitle  = stripslashes($row['title']);
$content = "<font class=\"content\">";
if ((!$fsid) AND (!$ftitle)) {
    $content .= ""._NOBIGSTORY."</font>";
} else {
    $content .= ""._BIGSTORY."<br /><br />";
    $r_options = "";
    if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }
    if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }
    if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; }
    $content .= "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$fsid$r_options\">$ftitle</a></font>";
}

closecacheb ( "".$content."", 'BigStory', 'html' , "".CACHE_BL_BIG_STORY."", '1' );
}