<?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                                 */
/************************************************************************/
/********************************************************/
/* NSN News                                             */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/

global $prefix, $db, $admin_file;
include(dirname(__FILE__)."/../../News/includes/functions.php");
if(!$admin_file OR $admin_file == "") { $admin_file = "admin"; }
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".TABLE_MODULES." WHERE title='Topics'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".TABLE_AUTHORS." WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
    if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") { $auth_user = 1; }
}
$ne_config = ne_get_configs();

function TopicAdmin() {
	global $admin_file;
	$current_admin_file=$admin_file;
	if($current_admin_file==null || $current_admin_file=="") $current_admin_file="admin";

    Max_OpenTable();
    echo "<center><font class='title'><b>"._TOPICSMANAGER . "</b></font></center>";
    Max_CloseTable();
    br('1');
    Max_OpenTable();
    echo "<center>\n<table cellpadding=\"3\">\n<tr>\n";
    echo "<td align=\"center\" valign=\"top\" width=\"150\">";
    echo "<a href=\"".$current_admin_file.".php?op=topicadd\">"._ADDATOPIC."</a><br />";
    echo "</td>\n";
    echo "<td align=\"center\" valign=\"top\" width=\"150\">";
    echo "<a href=\"".$current_admin_file.".php?op=topicmodify\">"._EDITTOPIC."</a><br />";
    echo "</td>\n";
    echo "<td align=\"center\" valign=\"top\" width=\"150\">";
    echo "<a href=\"".$current_admin_file.".php?op=topicdelunused\">"._REMOVEPICTURES."</a><br />";
    echo "</td>\n";
    echo "</tr>\n";
    echo "</table>\n</center>\n";
    Max_CloseTable();
    br('1');
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {

/*********************************************************/
/* Topics Manager Functions                              */
/*********************************************************/
function topicsdefault()
{
    incoh();
    //GraphicAdmin();
    TopicAdmin();
    incof();
}

function topicsmodify() {
    global $prefix, $db, $admin_file;
    incoh();
    //GraphicAdmin();
    TopicAdmin();
    Max_OpenTable();
    echo "<center><font class=\"option\"><b>"._CURRENTTOPICS . "</b></font><br />"._CLICK2EDIT . "</font></center><br />"
        ."<table border=\"0\" width=\"100%\" align=\"center\" cellpadding=\"2\">";
    $count = 0;
    $sql = "SELECT topicid, topicname, topicimage, topictext from " . $prefix . "_topics order by topicname";
    if ( !($result = $db->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain topics admin', '', __LINE__, __FILE__, $sql);}
    while ($row = $db->sql_fetchrow($result)) {
        $topicid = $db->XMFnum($row['topicid']);
        $topicname = stripslashes($row['topicname']);
        $topicimage = stripslashes($row['topicimage']);
        $topictext = stripslashes($row['topictext']);
        echo "<td align=\"center\" width='17%' valign='top'>"
            ."<a href=\"".$admin_file.".php?op=topicedit&amp;topicid=$topicid\"><img src=\"images/topics/$topicimage\" border=\"0\" alt=\"\"></a><br />"
            ."<font class=\"content\"><b>$topictext</td>";
        $count++;
        if ($count == 6) {
            echo "</tr><tr>";
            $count = 0;
        }
    }
    echo "</table></table>";
    incof();
    Max_CloseTable();
}
function topicadd()
{
    global $prefix, $db, $admin_file;
    incoh();
    //GraphicAdmin();
	TopicAdmin();
    Max_OpenTable();
    echo "<center><font class=\"option\"><b>"._ADDATOPIC . "</b></font></center><br />"
            ."<form ENCTYPE=\"multipart/form-data\" action=\"".$admin_file.".php\" method=\"post\">"
        ."<b>"._TOPICNAME . ":</b><br /><font class=\"tiny\">"._TOPICNAME1 . "<br />"
        .""._TOPICNAME2 . "</font><br />"
        ."<input type=\"text\" name=\"topicname\" size=\"20\" maxlength=\"20\" value=\"$topicname\"><br /><br />"
        ."<b>"._TOPICTEXT . ":</b><br /><font class=\"tiny\">"._TOPICTEXT1 . "<br />"
        .""._TOPICTEXT2 . "</font><br />"
        ."<input type=\"text\" name=\"topictext\" size=\"40\" maxlength=\"40\" value=\"$topictext\"><br /><br />"
        ."<b>"._TOPICIMAGE . ":</b><br />"
        ."<select name=\"topicimage\">";
    $path1 = explode ("/", "images/topics/");
    $path = "$path1[0]/$path1[1]";
    $handle=opendir($path);
    while ($file = readdir($handle)) {
        if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "AllTopics.gif") {
            $tlist .= "$file ";
        }
    }
    closedir($handle);
    $tlist = explode(" ", $tlist);
    sort($tlist);
    for ($i=0; $i < sizeof($tlist); $i++) {
        if($tlist[$i]!="") {
            echo "<option name=\"topicimage\" value=\"$tlist[$i]\">$tlist[$i]\n";
        }
    }
    echo "</select> "._TOPICOR." <input type='file' name='topicimage_upload' size='50'><br /><br />"
        ."<input type=\"hidden\" name=\"op\" value=\"topicmake\">"
        ."<input type=\"submit\" value=\""._ADDTOPIC . "\">"
        ."</form>";
    Max_CloseTable();
    incof();
}

function topicedit($topicid) {
    global $prefix, $db, $admin_file;
    incoh();
    //GraphicAdmin();
	TopicAdmin();
    br('1');
    Max_OpenTable();
    $topicid = $db->XMFnum($topicid);
    $sql = "SELECT topicid, topicname, topicimage, topictext from ".$prefix . "_topics where topicid='$topicid'";
    if ( !($result = $db->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain topics admin', '', __LINE__, __FILE__, $sql);}
	$row = $db->sql_fetchrow($result);
        $topicid = $db->XMFnum($row['topicid']);
        $topicname = stripslashes($row['topicname']);
        $topicimage = stripslashes($row['topicimage']);
        $topictext = stripslashes($row['topictext']);
    echo "<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\" alt=\"$topictext\">"
        ."<font class=\"option\"><b>"._EDITTOPIC . ": $topictext</b></font>"
        ."<br /><br />"
        ."<form ENCTYPE=\"multipart/form-data\" action=\"".$admin_file.".php\" method=\"post\"><br />"
        ."<b>"._TOPICNAME . ":</b><br /><font class=\"tiny\">"._TOPICNAME1 . "<br />"
        .""._TOPICNAME2 . "</font><br />"
        ."<input type=\"text\" name=\"topicname\" size=\"20\" maxlength=\"20\" value=\"$topicname\"><br /><br />"
        ."<b>"._TOPICTEXT . ":</b><br /><font class=\"tiny\">"._TOPICTEXT1 . "<br />"
        .""._TOPICTEXT2 . "</font><br />"
        ."<input type=\"text\" name=\"topictext\" size=\"40\" maxlength=\"40\" value=\"$topictext\"><br /><br />"
        ."<b>"._TOPICIMAGE . ":</b><br />"
        ."<select name=\"topicimage\">";
    $path1 = explode ("/", "images/topics/");
    $path = "$path1[0]/$path1[1]";
    $handle=opendir($path);
    while ($file = readdir($handle)) {
        if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "AllTopics.gif") {
            $tlist .= "$file ";
        }
    }
    closedir($handle);
    $tlist = explode(" ", $tlist);
    sort($tlist);
    for ($i=0; $i < sizeof($tlist); $i++) {
        if($tlist[$i]!="") {
            if ($topicimage == $tlist[$i]) {
                $sel = "selected";
            } else {
                $sel = "";
            }
            echo "<option name=\"topicimage\" value=\"$tlist[$i]\" $sel>$tlist[$i]\n";
        }
    }
    echo "</select> "._TOPICOR." <input type='file' name='topicimage_upload' size='50'><br /><br />"
        ."<b>"._ADDRELATED . ":</b><br />"
        .""._SITENAME . ": <input type=\"text\" name=\"name\" size=\"30\" maxlength=\"30\"><br />"
        .""._URL . ": <input type=\"text\" name=\"url\" value=\"http://\" size=\"50\" maxlength=\"200\"><br /><br />"
        ."<b>"._ACTIVERELATEDLINKS . ":</b><br />"
        ."<table width=\"100%\" border=\"0\">";
    $sql1 = "SELECT rid, name, url from ".$prefix . "_related where tid='$topicid'";
    if ( !($res = $db->sql_query($sql1)) )
{ query_die(CORE_ERROR, 'Could not obtain related admin', '', __LINE__, __FILE__, $sql1);}
    $num = $db->sql_numrows($res);
    if ($num == 0) {
        echo "<tr><td><font class=\"tiny\">"._NORELATED . "</font></td></tr>";
    }
        while($row2 = $db->sql_fetchrow($res)) {
            $relatedid = $db->XMFnum($row2['rid']);
            $name = stripslashes($row2['name']);
            $url = stripslashes($row2['url']);
        echo "<tr><td align=\"left\"><font class=\"content\"><strong><big>&middot;</big></strong>&nbsp;&nbsp;<a href=\"$url\">$name</a></td>"
                ."<td align=\"center\"><font class=\"content\"><a href=\"$url\">$url</a></td><td align=\"right\"><font class=\"content\">[ <a href=\"".$admin_file.".php?op=relatededit&amp;tid=$topicid&amp;relatedid=$relatedid\">"._EDIT . "</a> | <a href=\"".$admin_file.".php?op=relateddelete&amp;tid=$topicid&amp;relatedid=$relatedid\">"._DELETE . "</a> ]</td></tr>";
    }
    echo "</table><br /><br />"
        ."<input type=\"hidden\" name=\"topicid\" value=\"$topicid\">"
		."<select name=\"op\">"
			."<option value=\"topicchange\" $sel>"._TOPICSAVEMODS."\n"
			."<option value=\"topicdelete\" $sel>"._TOPICDELETE."\n"
			."<option value=\"topicdeletewimg\" $sel>"._TOPICDELETEWIMG."\n"
		."</select>"
        ."<INPUT type=\"submit\" value=\""._TOPICSUBMIT . "\">"
        ."</form>";
    Max_CloseTable();
    incof();
}

function relatededit($tid, $relatedid) {
    global $prefix, $db, $admin_file;
    incoh();
    //GraphicAdmin();
	TopicAdmin();
    br('1');
    $relatedid = $db->XMFnum($relatedid);
    $tid = $db->XMFnum($tid);
    $sql = "SELECT name, url from ".$prefix . "_related where rid='$relatedid'";
    if ( !($result = $db->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain related admin', '', __LINE__, __FILE__, $sql);}
    $row = $db->sql_fetchrow($result);
        $name = stripslashes($row['name']);
        $url = stripslashes($row['url']);
    $sql2 = "SELECT topictext, topicimage from ".$prefix . "_topics where topicid='$tid'";
    if ( !($result2 = $db->sql_query($sql2)) )
{ query_die(CORE_ERROR, 'Could not obtain topics admin', '', __LINE__, __FILE__, $sql2);}
        $row2 = $db->sql_fetchrow($result2);
        $topictext = stripslashes($row2['topictext']);
        $topicimage = stripslashes($row2['topicimage']);
    Max_OpenTable();
    echo "<center>"
        ."<img src=\"images/topics/$topicimage\" border=\"0\" alt=\"$topictext\" align=\"right\">"
        ."<font class=\"option\"><b>"._EDITRELATED . "</b></font><br />"
        ."<b>"._TOPIC . ":</b> $topictext</center>"
        ."<form action=\"".$admin_file.".php\" method=\"post\">"
        .""._SITENAME . ": <input type=\"text\" name=\"name\" value=\"$name\" size=\"30\" maxlength=\"30\"><br /><br />"
        .""._URL . ": <input type=\"text\" name=\"url\" value=\"$url\" size=\"60\" maxlength=\"200\"><br /><br />"
        ."<input type=\"hidden\" name=\"op\" value=\"relatedsave\">"
        ."<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
        ."<input type=\"hidden\" name=\"relatedid\" value=\"$relatedid\">"
        ."<input type=\"submit\" value=\""._SAVECHANGES . "\"> "._GOBACK . ""
        ."</form>";
    Max_CloseTable();
    incof();
}

function relatedsave($tid, $relatedid, $name, $url) {
    global $prefix, $db, $admin_file;
    $relatedid = $db->XMFnum($relatedid);
    $tid = $db->XMFnum($tid);
    $name = stripslashes($name);
    $url = stripslashes($url);
    $db->sql_query("update ".$prefix . "_related set name='$name', url='$url' where rid='$relatedid'");
    redirect_url("".$admin_file.".php?op=topicedit&topicid=$tid");
}

function relateddelete($tid, $relatedid) {
    global $prefix, $db, $admin_file;
    $relatedid = $db->XMFnum($relatedid);
    $tid = $db->XMFnum($tid);
    $db->sql_query("delete from ".$prefix . "_related where rid='$relatedid'");
    redirect_url("".$admin_file.".php?op=topicedit&topicid=$tid");
}

function topicmake($topicname, $topicimage, $topictext) {
    global $prefix, $db, $admin_file,$_FILES;
    $topicname = stripslashes(FixQuotes($topicname));
    $topicimage = stripslashes(FixQuotes($topicimage));
    $topictext = stripslashes(FixQuotes($topictext));

	if(is_array($_FILES) && $_FILES['topicimage_upload']!=null && is_array($_FILES['topicimage_upload']) && $_FILES['topicimage_upload']['name']!=null && $_FILES['topicimage_upload']['name']!="")
	{
		$imageurl_name = $_FILES['topicimage_upload']['name'];
		$imageurl_temp = $_FILES['topicimage_upload']['tmp_name'];
		if (move_uploaded_file($imageurl_temp, "images/topics/$imageurl_name")) {
			$imgurl = "images/topics/$imageurl_name";
			chmod ("$imgurl", 0777);
			$topicimage=$imageurl_name;
		} else {
			incoh();
			title(_ADDTOPIC);
			Max_OpenTable();
			echo "<center><b>"._TOPICNOUPLOAD."</b></center><br />\n";
			echo "<center>"._TOPICGOBACK."</center>";
			Max_CloseTable();
			incof();
			die();
		}
	}

    $sqla = "INSERT INTO ".$prefix . "_topics VALUES (NULL,'$topicname','$topicimage','$topictext','0')";
    if ( !($resulta = $db->sql_query($sqla)) )
{ query_die(CORE_ERROR, 'Could not INSERT topics admin', '', __LINE__, __FILE__, $sqla);}
    redirect_url("".$admin_file.".php?op=topicsmanager");
}

function topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url) {
    global $prefix, $db, $admin_file;
    $topicname = stripslashes(FixQuotes($topicname));
    $topicimage = stripslashes(FixQuotes($topicimage));
    $topictext = stripslashes(FixQuotes($topictext));
    $name = stripslashes(FixQuotes($name));
    $url = stripslashes(FixQuotes($url));
    $topicid = intval($topicid);

	if(is_array($_FILES) && $_FILES['topicimage_upload']!=null && is_array($_FILES['topicimage_upload']) && $_FILES['topicimage_upload']['name']!=null && $_FILES['topicimage_upload']['name']!="")
	{
		$imageurl_name = $_FILES['topicimage_upload']['name'];
		$imageurl_temp = $_FILES['topicimage_upload']['tmp_name'];
		if (move_uploaded_file($imageurl_temp, "images/topics/$imageurl_name")) {
			$imgurl = "images/topics/$imageurl_name";
			chmod ("$imgurl", 0777);
			$topicimage=$imageurl_name;
		} else {
			incoh();
			title(_ADDTOPIC);
			Max_OpenTable();
			echo "<center><b>"._TOPICNOUPLOAD."</b></center><br />\n";
			echo "<center>"._TOPICGOBACK."</center>";
			Max_CloseTable();
			incof();
			die();
		}
	}

    $sqla = "update ".$prefix . "_topics set topicname='$topicname', topicimage='$topicimage', topictext='$topictext' where topicid='$topicid'";
    if ( !($resulta = $db->sql_query($sqla)) )
{ query_die(CORE_ERROR, 'Could not update topics admin', '', __LINE__, __FILE__, $sqla);}
    if (!$name) {
    } else {
        $sqlb = "insert into ".$prefix . "_related VALUES (NULL, '$topicid','$name','$url')";
	if ( !($resultb = $db->sql_query($sqlb)) )
{ query_die(CORE_ERROR, 'Could not insert related admin', '', __LINE__, __FILE__, $sqlb);}
    }
    redirect_url("".$admin_file.".php?op=topicedit&topicid=$topicid");
}

function topicdelunused($ok)
{
    global $prefix, $db, $admin_file;
    incoh();
    //GraphicAdmin();
	TopicAdmin();
    Max_OpenTable();
    $ok = $db->XMFbin($ok);
    echo "<center><font class=\"option\"><b>"._REMOVEPICTURES . "</b></font></center><br />";

    // Preparing array of pictures list
    $path1 = explode ("/", "images/topics/");
    $path = "$path1[0]/$path1[1]";
	$handle=opendir($path);
    while ($file = readdir($handle))
	{
        if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "AllTopics.gif")
			$tlist .= "$file ";
    }
    closedir($handle);
    $tlist = explode(" ", $tlist);
    sort($tlist);

	unset($tused); // reset array of used pictures

	// Scan db to fill the array of used pictures
	$sql = "SELECT topicimage from " . $prefix . "_topics order by topicname";
	if ( !($result = $db->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain topics admin', '', __LINE__, __FILE__, $sql);}
    while ($row = $db->sql_fetchrow($result))
	{
		$tused[$row['topicimage']]=true;
	}
	// Now display unsed pictures
	$toDo=false;
	$textList="<center><select size=10 >";
	foreach($tlist as $currentPicture)
	{
		if(is_array($tused) && $tused[$currentPicture]!=true && $currentPicture!="")
		{
			if($ok) unlink($path."/".$currentPicture);
			$textList.="<option>".$currentPicture."</option>";
			$toDo=true;

		}
	}
	$textList.="</select></center>";

	if($toDo==true)
	{
		echo $textList;
		if(intval($ok)==0)
		{
			echo "<center>"
				."" . _TOPICDELIMGSURE  . " ?<br />"
				."" . _TOPICDELIMGSURE1 . "<br /><br />"
				."[ <a href=\"".$admin_file.".php?op=topicsmanager\">" . _NO . "</a> | <a href=\"".$admin_file.".php?op=topicdelunused&amp;ok=1\">" . _YES . "</a> ]</center><br /><br />";
		}
		else
		{
			echo "<center>"
				."" . _TOPICDELIMGDONE. "</center><br /><br />";
		}
	}
	else
	{
			echo "<center>"
				."" . _TOPICDELIMGNOTHING. "</center><br /><br />";
	}

    Max_CloseTable();
    incof();
}
function topicdelete($topicid, $topicimg=0, $ok=0) {
    global $prefix, $db, $ne_config, $admin_file;
    $topicid = $db->XMFnum($topicid);
    $ok = $db->XMFbin($ok);
    if ($ok==1) {
		$row = $db->sql_fetchrow($db->sql_query("SELECT topicimage from " . $prefix . "_topics where topicid='$topicid'"));
		$topicimage= stripslashes($row['topicimage']);
		$row = $db->sql_fetchrow($db->sql_query("SELECT sid from ".TABLE_STORIES." where topic='$topicid'"));
        $sid = $db->XMFnum($row['sid']);
        // Copyright (c) 2000-2005 by NukeScripts Network
        if($ne_config['hometopic'] == $topicid) { ne_save_config("hometopic", "0"); }
        // Copyright (c) 2000-2005 by NukeScripts Network
        $db->sql_query("delete from ".TABLE_STORIES." where topic='$topicid'");
        $db->sql_query("delete from " . $prefix . "_topics where topicid='$topicid'");
        $db->sql_query("delete from " . $prefix . "_related where tid='$topicid'");
	    $row2 = $db->sql_fetchrow($db->sql_query("SELECT sid from " . $prefix . "_comments where sid='$sid'"));
        $sid = $db->XMFnum($row2['sid']);
        $db->sql_query("delete from " . $prefix . "_comments where sid='$sid'");
		if($db->XMFnum($topicimg)!=0) unlink("images/topics/$topicimage");
        redirect_url("".$admin_file.".php?op=topicsmanager");
    } else {
        global $topicimage;
        incoh();
        //GraphicAdmin();
		TopicAdmin();
        br('1');
    $sql3 = "SELECT topicimage, topictext from " . $prefix . "_topics where topicid='$topicid'";
    if ( !($result3 = $db->sql_query($sql3)) )
{ query_die(GENERAL_ERROR, 'Could not obtain faqcategories admin', '', __LINE__, __FILE__, $sql3);}
$row3 = $db->sql_fetchrow($result3);
        $topicimage = stripslashes($row3['topicimage']);
        $topictext = stripslashes($row3['topictext']);
        Max_OpenTable();
        echo "<center><img src=\"images/topics/$topicimage\" border=\"0\" alt=\"$topictext\"><br /><br />"
            ."<b>" . _DELETETOPIC . " $topictext</b><br /><br />"
            ."" . (intval($topicimg)!=0?_TOPICDELSUREWIMG:_TOPICDELSURE) . " <i>$topictext</i>?<br />"
            ."" . _TOPICDELSURE1 . "<br /><br />"
            ."[ <a href=\"".$admin_file.".php?op=topicmodify\">" . _NO . "</a> | <a href=\"".$admin_file.".php?op=topicdelete&amp;topicid=$topicid&amp;topicimg=".intval($topicimg)."&amp;ok=1\">" . _YES . "</a> ]</center><br /><br />";
        Max_CloseTable();
        incof();
    }
}
if($admintest && $adminsecu)  {
switch ($op) {

	case "topicadd":
	topicadd();
	break;

    case "topicmodify":
    topicsmodify();
    break;

    case "topicedit":
    topicedit($topicid);
    break;

    case "topicmake":
    topicmake($topicname, $topicimage, $topictext);
    break;

    case "topicdelete":
    topicdelete($topicid, intval($ok)==1?$topicimg:0, $ok);
    break;

    case "topicdeletewimg":
    topicdelete($topicid, 1, $ok);
    break;

    case "topicchange":
    topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url);
    break;

    case "relatedsave":
    relatedsave($tid, $relatedid, $name, $url);
    break;

    case "topicdelunused":
	topicdelunused($ok);
	break;

	case "relatededit":
    relatededit($tid, $relatedid);
    break;

    case "relateddelete":
    relateddelete($tid, $relatedid);
    break;

	default: topicsdefault(); break;

}
}
} else {
        incoh();
        //GraphicAdmin();
        Max_OpenTable();
        echo "<center><b>"._ERROR."</b><br /><br />You do not have administration permission for module \"$module_name\"</center>";
        Max_CloseTable();
        incof();
}