<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
error_reporting( _E_VALUE );

/* vim: set expandtab tabstop=4 shiftwidth=4: */

// ***** BEGIN LICENSE BLOCK ( DO NOT REMOVE ) *****

// +----------------------------------------------------------------------+
// | MPN 189 Admin Entry Conversion For 188_8                             |
// |                                                                      |
// | -> Entry Point To MPN Administration                                 |
// +----------------------------------------------------------------------+
// | VERSION: 0.1 Alpha                                                   |
// +----------------------------------------------------------------------+
// | LICENSE: GPL 2.0 (see docs/LICENSE_GPL)                              |
// |                                                                      |
// | This file is part of MPN Admin Entry For MPN 188_8.                  |
// |                                                                      |
// | MPN Admin Entry For MPN 188_8 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.                                                       |
// |                                                                      |
// | MPN Admin Entry For MPN 188_8 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 MPN Admin Entry For MPN 188_8; if not, write to the       |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place, Suite 330                                           |
// | Boston, MA 02111-1307  USA                                           |
// +----------------------------------------------------------------------+
// | AUTHOR(s):                                                           |
// |                                                                      |
// | The Original Code is the MPN Admin Entry For MPN 188_8.              |
// | The Initial Developer of the Original Code is Eric Haddix.           |
// |                                                                      |
// | Portions created by Eric Haddix or Kiril Threndor                    |
// | <support@mpn.illearth.net> are                                       |
// | Copyright (C) 2003 Eric Haddix.  All Rights Reserved.                |
// +----------------------------------------------------------------------+
// | CONTRIBUTOR(s):                                                      |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | MODIFICATIONS:                                                       |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | NOTES:                                                               |
// +----------------------------------------------------------------------+
// | SUPPORT:                                                             |
// |   WEB:   http://myphpnuke.com/                                       |
// |   EMAIL: support@mpn.illearth.net                                    |
// +----------------------------------------------------------------------+

/**
 * MPN_188_8_Modules
 *
 * @package MPN_188_8_Administration
 * @subpackage interface
 * @version $Id: main.php,v 1.14.2.8 2004/08/15 12:58:21 kirilt Exp $
 *
 * @author Kiril Threndor <support@mpn.illearth.net>
 * @copyright Copyright (C) 2003 Eric Haddix
 * @license http://www.gnu.org/licenses/gpl.html GPL 2.0
 * @support http://myphpnuke.com/
 * @todo finish CSS & XHTML conversion
 * @todo reformat old style formatted code to new coding style
 * @todo finish and check function comments
 *
 * @tutorial
 * @filesource
 */

// ***** END LICENSE BLOCK ( DO NOT REMOVE ) *****

if ( ! _MPN_ADMIN ) { adminLoginForm(); }


// List Current Articles


if ( $GLOBALS['ainf']['super'] || $GLOBALS['ainf']['article'] )
{
    echo "<h2>" . translate( "Last" ) . " $admart " . translate( "Articles" ) . "</h2>\n";

   echo '<hr class="w80" /><br />' . "\n";

    $sql = 'SELECT sid, title, time, topic, informant
            FROM ' . $mpnTables['stories'] . '
            ORDER BY time DESC
            LIMIT 0, ' . $admart;

    @( ( $result = mysql_query( $sql ) ) && mysql_data_seek( $result, 0 ) )
      OR goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );

    echo "<div class='center'>\n";

        echo "<table class='simpleborders' summary='Recent Posted Articles'><tr>";

        echo "<th>" . translate( "Story ID" ) . "</th>\n";
        echo "<th>" . translate( "Story" ) . "</th>\n";
        echo "<th>" . translate( "Topic" ) . "</th>\n";
        echo "<th>" . translate( "Functions" ) . "</th>\n";

        echo "</tr>\n";

        while( list( $sid, $title, $time, $topic, $informant ) = mysql_fetch_row( $result ) )
        {
            $title = stripslashes( $title );
            $datetime = getDisplayTime( $time, 'forumdatestring3' );

            $sql = 'SELECT topicname
                    FROM ' . $mpnTables['topics'] . '
                    WHERE topicid = ' . $topic;

            if ( @( ( $tmp = mysql_query( $sql ) ) && mysql_data_seek( $tmp, 0 ) ) )
            {
                list( $topicname ) = mysql_fetch_row( $tmp );
                mysql_free_result( $tmp );
            }
            else
            {
                $topicname = translate( 'Database Error' );
            }

            echo "<tr>\n";

            echo "<td class='center'>\n";
                echo "<b>$sid</b>\n";
            echo "</td><td class='t-left'>\n";
                echo "<b><a href=\"article.php?sid=$sid\" title=\"" . translate( 'View Article' ) . "\">$title</a></b>\n";
            echo "</td><td class='center'>\n";
                echo "$topicname\n";
            echo "</td><td class='center'>\n";
                echo "( <a href=\"admin.php?op=EditStory&sid=$sid\">".translate("Edit")."</a>-<a href=\"admin.php?op=RemoveStory&sid=$sid\">".translate("Delete")."</a> )\n";

            echo "</td>";

            echo "</tr>";
        }

        echo "</table>\n";

    echo '</div>' . "\n";

    echo '<br />' . "\n";
}


// Show Current Poll Results

if ( $GLOBALS['ainf']['super'] || $GLOBALS['ainf']['survey'] )
{
    $sql = 'SELECT MAX(pollID) AS pollID
            FROM ' . $mpnTables['poll_desc'];

    @( ( $result = mysql_query( $sql ) ) && mysql_data_seek( $result, 0 ) )
     OR goBack( translate( 'Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );

    $tmp = mysql_fetch_row( $result );

    echo "<div class='center'>\n";

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

        $_REQUEST['op'] = 'results';
        $pollID = $tmp[0];

        @( include_once __ROOT__ . 'pollBooth.php' )
          OR goBack( translate( 'Include Error' ) );

    echo '</div>' . "\n";
}

?>