<?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                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
if ($acces == 1) {
if($admintest && $adminsecu)  {


$pagetitle = _DAZIBAO;
  incoh();
  $page = $GLOBALS['db']->XMFnum($page);

  Max_OpenTable();
echo "<table><tr><td width=\"20%'\"></td><td width=\"80%\">"
    ."<font size=\"2\"><img src=\"images/arrow.png\" alt=\"\" /> "._DAZIBAO1." <img src=\"images/edit.gif\" alt=\""._EDIT."\" title=\""._EDIT."\" /><br />"
    ."<img src=\"images/arrow.png\" alt=\"\" /> "._DAZIBAO2." <img src=\"images/trashmini.png\" alt=\""._DELETE."\" title=\""._DELETE."\" /><br />"
    ."<img src=\"images/arrow.png\" alt=\"\" /> "._DAZIBAO3."<br />"
    ."<img src=\"images/arrow.png\" alt=\"\" /> "._DAZIBAO4."<br />"
    ."</font></td></tr></table>";
  Max_CloseTable();
br('1');
  // pagination
 $ipp = 15;
$sql = "SELECT `id` from `".TABLE_MAXDAZIBAO."` ";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _maxdazibao', '', __LINE__, __FILE__, $sql);}
  $total =  $GLOBALS['db']->sql_numrows($result);
// nd de post
  if ($total>$ipp) {
        $pages=ceil($total/$ipp);
        if ($page > $pages) { $page = $pages; }
        if (!$page) { $page=1; }
        $offset=($page-1)*$ipp;
    } else {
        $offset=0;
        $pages=1;
        $page=1;
    }
// fin pagination

       Max_OpenTable();
echo "<form action=\"".$admin_file.".php\" method=\"post\" >"
    ."<b>"._MESSAGE."</b>";
br('1');
echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"5\" name=\"titre\" style=\"font-size: 14 pt; font-family: Arial; color: #0000FF\"></textarea>";
br('2');
echo "<input type=\"hidden\" name=\"op\" value=\"EnvoyerDazibao\" />
    <input type=\"submit\" value=\""._DAZIBAO_SAVE."\" />
    </form>";
    Max_CloseTable();
br('1');
    Max_OpenTable();

echo    "<table border=\"0\" width=\"100% \" cellpadding=\"4\" cellspacing=\"2\" >"
 	."<tr>"
 	."<td bgcolor=\"$bgcolor2\" align=\"left\" width=\"10%\"><b>"._BY."</b></td>"
 	."<td bgcolor=\"$bgcolor2\" align=\"left\" width=\"60%\"><b> "._MESSAGE." </b></td>"
 	."<td bgcolor=\"$bgcolor2\" align=\"center\" width=\"15%\"><b>"._DATE."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align=\"center\" width=\"5%\"><b>"._ACTION."</b></td></tr>";

$a = 0;
$sql2 = "SELECT `id`, `pseudo`, `titre`, `date` FROM `".TABLE_MAXDAZIBAO."` ORDER BY `date` DESC limit $offset,$ipp";
if ( !($result2 = $GLOBALS['db']->sql_query($sql2)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _maxdazibao', '', __LINE__, __FILE__, $sql2);}
         while ($row2 = $GLOBALS['db']->sql_fetchrow($result2)) {
	$id= $GLOBALS['db']->XMFnum($row2['id']);
	$pseudo = stripslashes(check_html($row2['pseudo'], "nohtml"));
	$titre  = nl2br(stripslashes($row2['titre']));
        $date   = stripslashes($row2['date']);
        $year   = substr($date,0,4);
        $month  = substr($date,5,2);
        $day    = substr($date,8,2);
        $hour   = substr($date,11,2);
        $minute = substr($date,14,2);
        $second = substr($date,17,2);
        $date   = date("d-m-Y H:i:s",mktime ($hour,$minute,$second,$month,$day,$year));

$a++;
if ($a >= 2) { $a=0; $color = "white"; } else { $color= "$bgcolor3"; }

echo "<tr><td bgcolor=\"$color\" align=\"left\" width=\"10%\" valign=\"top\" ><a href='modules.php?name=Your_Account&amp;op=userinfo&amp;username=$pseudo'><font size=\"3\"><b>$pseudo</b></font></a>";
if (is_god($admin)) {
echo "<br /><a href=\"".$admin_file.".php?op=DelDazibao&amp;id=$id\"><i>"._DELETE."</i></a>";
}
echo "</td><td bgcolor=\"$color\" align=\"left\" width=\"60%\" valign=\"top\"><font size=\"2\">$titre</font></td>"
	."<td bgcolor=\"$color\" align=\"center\" width=\"15%\" valign=\"top\"><font size='1'>$date</font></td>"
	."<td bgcolor=\"$color\" align=\"center\" width=\"5%\" valign=\"top\">";

if ( ($cookie[1] == $pseudo) OR (is_god($admin)) ) {
image_dyn( "images/edit_x.gif", "images/edit.gif", "".$admin_file.".php?op=ModDazibao&amp;did=$id&amp;envoi=$pseudo", ""._EDIT."", "Edit" ) ;
image_dyn( "images/trashmini_x.png", "images/trashmini.png", "".$admin_file.".php?op=DelDazibao&amp;id=$id&amp;envoi=$pseudo", ""._DELETE."", "Delete" ) ;
}
echo "</td></tr>";
    }
echo "</table>";

 // pagination bas de bage
   if ($pages > 1) {
        $pcnt=1;


echo "<table align='right'><tr> ";
 if ($page > 1) {
echo "<td align='center'><a href=\"".$admin_file.".php?op=Dazibao&amp;page=" . ($page-1) . "\"><b>"._DAZIBAO_PREVIOUS."</b></a></td>";
        }
while($pcnt < $page) {
echo "<td align='center'><b>[ <a href=\"".$admin_file.".php?op=Dazibao&amp;page=$pcnt\">$pcnt</a> ]</b></td>";
            $pcnt++;
        }
echo "<td align='center'><b>[ $page ]</td>";
        $pcnt++;
        while($pcnt <= $pages) {
echo "<td align='center'><b>[ <a href=\"".$admin_file.".php?op=Dazibao&amp;page=$pcnt\">$pcnt</a> ]</b></td>";
            $pcnt++;
        }
        if ($page < $pages) {
echo "<td align='center'><a href=\"".$admin_file.".php?op=Dazibao&amp;page=" . ($page+1) . "\"><b>"._DAZIBAO_NEXT."</b></a></td>\n";
        }
        echo "</tr></table>";
	}

 $GLOBALS['db']->sql_freeresult($result);
   Max_CloseTable();
   incof();

}
}else {
	echo "Access Denied";
}