<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: article.php,v 1.26.2.4 2004/08/01 17:04:16 kirilt Exp $




/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)            */
/* http://phpnuke.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.       */
/************************************************************************/

$extStyle = 1;

if ( ! isset( $sid ) && ! isset( $tid ) ) { goBack( translate( 'Invalid Request' ) ); }

if ( isset( $op ) && $op == 'Reply' )
{
    $_SERVER['F_LIB'] -> redirectRequest( 'comments.php?op=Reply&pid=0&sid=' . $sid );
}

@mysql_query( "UPDATE ".$mpnTables['stories']." SET counter=counter+1 where sid='$sid'" );

$result = mysql_query( "SELECT catid, aid, time, title, hometext, bodytext, topic, informant, notes, counter FROM ".$mpnTables['stories']." WHERE sid='$sid'" );

list( $catid, $aid, $time, $title, $hometext, $bodytext, $topic, $informant, $notes, $counter ) = mysql_fetch_row( $result );

mysql_free_result( $result );

$counter++;

// Kiril: New Sanitizer

$sanity_ary = compact( 'title', 'time', 'hometext', 'bodytext', 'notes' );
$_SERVER['SAN'] -> slashIT( $sanity_ary );
extract( $sanity_ary );

// Adjust Formatting

if ( $_SERVER['F_LIB'] -> checkPostDate( $time ) )
{
    $slice_ary = array_slice( $sanity_ary, 2, 3 );
    $_SERVER['SAN'] -> sanitizeLegacyContent( $slice_ary );
}
else
{
    $slice_ary = array_slice( $sanity_ary, 2, 3 );
    $_SERVER['SAN'] -> adjustFormat( $slice_ary, 3, 10 );
}

extract( $slice_ary );
unset( $slice_ary, $sanity_ary );

// End New Sanitizer

$datetime = formatTimestamp( $time );

//$datetime = strftime( translate( 'emaildatestring' ) , strtotime( $time ) );

if ( $bodytext == '' )
{
    $bodytext = $hometext . '<br /><br />' . $notes;
}
else
{
    $bodytext = $hometext . '<br /><br />' . $bodytext . '<br /><br />' . $notes;
}

if ( $informant ==  '' ) { $informant = $anonymous; }

getTopics( $sid );

if ( $catid != 0 )
{
    $result = mysql_query( "SELECT title FROM ".$mpnTables['stories_cat']." WHERE catid = '$catid'" );

    list( $title1 ) = mysql_fetch_row( $result );

    mysql_free_result( $result );

    $title = "<a href=\"categories.$phpEx?op=newindex&amp;catid=$catid\">$title1</a>: $title";
}

include './header.php';

echo "<div id='article'>\n\n";

    echo "<table width='100%' summary=''><tr><td class='top'>";

        themearticle( $aid, $informant, $datetime, $title, $bodytext, $topic, $topicname, $topicimage, $topictext );

    echo "</td><td class='art-sideblk'>";

        $boxtitle = $topictext;
        $boxstuff = '';

        $result = mysql_query( "SELECT name, url FROM " . $mpnTables['related'] . " WHERE tid = '$topic'" );

        if ( mysql_num_rows( $result ) > 0 )
        {
            $boxstuff .= "<br /><div class='blocksubtitle'>" . translate("Related Links") . "</div>";

            $boxstuff .= "<hr /><br />\n";

            while( list( $name, $url ) = mysql_fetch_row( $result ) )
            {
                if ($url != '')
                {
                    $boxstuff .= "<ul><li><a href='$url'>$name</a></li></ul>";
                }
            }

            mysql_free_result( $result );
        }

        if ( $topictext != '' )
        {
            $boxstuff .= "<br /><br /><div class='blocksubtitle'>" . translate("Most read story about") . " $topictext:</div>";

            $boxstuff .= "<hr /><br />\n";

            $result = mysql_query( "SELECT sid, title FROM ".$mpnTables['stories']." WHERE topic = $topic ORDER BY counter DESC LIMIT 0,1" );

            list( $topstory, $ttitle ) = mysql_fetch_row( $result );

            mysql_free_result( $result );

            $ttitle = stripslashes( $ttitle );

            $boxstuff .= "<a href='article.php?sid=$topstory'>$ttitle</a>";

            $boxstuff .= "<br /><br /><div class='blocksubtitle'>" . translate("Recent News About") . " $topictext:</div>";

            $boxstuff .= "<hr /><br />\n";

            $result = mysql_query( "SELECT sid, title FROM " . $mpnTables['stories'] . " WHERE topic = '$topic' && title != '" . addslashes( $title ) . "' ORDER BY time DESC LIMIT 0,5" );

            while( list( $sid1, $title1 ) = mysql_fetch_row( $result ) )
            {
                $title1 = stripslashes( $title1 );

                $boxstuff .= "<ul><li><a href=\"article.$phpEx?sid=$sid1\">$title1</a></li></ul>\n";
            }

            mysql_free_result( $result );

            $boxstuff .= "<br /><br /><div class='blocksubtitle'>" . translate("Misc") . "</div><hr /><br />";

            $boxstuff .= "<ul>\n";

            $boxstuff .= "<li><a href='search.$phpEx?topic=$topic'>" . translate("More about") . "<br />$topictext</a></li>";

            $boxstuff .= "<li><a href='search.$phpEx?author=$aid'>" . translate("News by") . "<br />$aid</a></li>";

            $boxstuff .= "</ul>\n";

            $boxstuff .= "<br /><hr /><br />";

        }

        $boxstuff .= "<div class='center'>";

            if ( $anonpost == 1 || _MPN_USER || _MPN_ADMIN )
            {
                $boxstuff .= "<a class='bare' href='./comments.$phpEx&#063;op&#061;Reply&amp;pid&#061;0&amp;sid&#061;$sid'>\n";

                    $boxstuff .= "<span class='button'>\n";

                         $boxstuff .= translate( 'Post A Comment' );

                    $boxstuff .= "</span>\n";

                $boxstuff .= "</a><br /><br />\n";
            }

            $boxstuff .= "<a href='./print.php&#063;sid&#061;$sid'>\n";

                $boxstuff .= "<img src='./images/print.gif' alt='" . translate( 'Printer Friendly Page' ) . "' width='15' height='11' " . _T_NN4_BORDER . " />\n";

            $boxstuff .= "</a>&nbsp;&nbsp;\n";

            $boxstuff .= "<a href='./friend.php&#063;op&#061;FriendSend&amp;sid&#061;$sid'>\n";

                $boxstuff .= "<img src='./images/friend.gif' alt='" . translate( 'Send this Story to a Friend' ) . "' width='15' height='11' " . _T_NN4_BORDER . " />\n";

            $boxstuff .= "</a>\n";

        $boxstuff .= "</div>\n";

        $boxstuff .= "<br />";

        themesidebox( $boxtitle, $boxstuff );

    echo "</td></tr></table>";

    echo "<br /><br />\n";

    $cookie = cookiedecode();

    if (!isset( $cookie[4] ) || (isset( $cookie[4] ) && $cookie[4] != 'nocomments' ))
    {
        echo "<div id='comments'>\n";

            echo "<h2>" . translate( 'Comments' ) . "</h2>\n";
            echo "<br />\n";

            include './comments.php';

        echo "</div>\n";
    }


echo "</div>\n";

include ("footer.$phpEx");

?>
