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

		incoh();
		if ( $wysiwyg == 'fck' ) {
   		 include_once('FCKeditor/fckeditor.php');
   		 }
		MenuMessage();
		if ($admlanguage == "") {
			$admlanguage = $language; /* This to make sure some language is pre-selected */
		}
		Max_OpenTable();
		echo "<center><font class='title'><b>" . _ADDMSG . "</b></font></center><br />";
		echo "<form action=\"".$admin_file.".php\" method=\"post\">"
		."<br /><b>" . _MESSAGETITLE . ":</b><br />"
		."<input type=\"text\" name=\"add_title\" value=\"\" size=\"50\" maxlength=\"100\"><br /><br />"
		."<b>" . _MESSAGECONTENT . ":</b><br />";

if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(add_content) ;
$oFCKeditor->InstanceName = "add_content" ;
$oFCKeditor->Create() ;
} else {
echo "<textarea name=\"add_content\" rows=\"15\" wrap=\"virtual\" cols=\"70\"></textarea>";
}
br('2');

		if ($multilingual == 1) {
			echo "<b>" . _LANGUAGE . ": </b>"
			."<select name=\"add_mlanguage\">";
			$handle=opendir('language');
			while ($file = readdir($handle)) {
				if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
					$langFound = $matches[1];
					$languageslist .= "$langFound ";
				}
			}
			closedir($handle);
			$languageslist = explode(" ", $languageslist);
			sort($languageslist);
			for ($i=0; $i < sizeof($languageslist); $i++) {
				if($languageslist[$i]!="") {
					echo "<option value=\"$languageslist[$i]\" ";
					if($languageslist[$i]==$language) echo "selected";
					echo ">".ucfirst($languageslist[$i])."</option>\n";
				}
			}
			echo "<option value=\"\">" . _ALL . "</option></select><br /><br />";
		} else {
			echo "<input type=\"hidden\" name=\"add_mlanguage\" value=\"\">";
		}
		$now = time();
echo "<b>" . _EXPIRATION . ":</b> <select name=\"add_expire\">"
	."<option value=\"86400\" >1 " . _DAY . "</option>"
	."<option value=\"172800\" >2 " . _DAYS . "</option>"
	."<option value=\"432000\" >5 " . _DAYS . "</option>"
	."<option value=\"1296000\" >15 " . _DAYS . "</option>"
	."<option value=\"2592000\" >30 " . _DAYS . "</option>"
	."<option value=\"0\" >" . _UNLIMITED . "</option>"
	."</select><br /><br />"
	."<b>"._ACTIVE."?</b> <input type=\"radio\" name=\"add_active\" value=\"1\" checked>" . _YES . " "
	."<input type=\"radio\" name=\"add_active\" value=\"0\" >" . _NO . ""
	."<br /><br /><b>" . _VIEWPRIV . "</b> <select name=\"add_view\">"
	."<option value=\"1\" >" . _MVALL . "</option>"
	."<option value=\"2\" >" . _MVANON . "</option>"
	."<option value=\"3\" >" . _MVUSERS . "</option>"
	."<option value=\"4\" >" . _MVADMIN . "</option>"
	."<option value=\"5\" >" . _SUBUSERS . "</option>"
        ."<option value=\"6\">"._MVGROUPS."</option>"
	."</select><br /><br />"
        ."<font class='tiny'>"._WHATGRDESC."</font><br /><b>"._WHATGROUPS."</b> <select name='add_groups[]' multiple size='5'>\n";
    $groupsResult = $db->sql_query("SELECT `gid`, `gname` FROM `".TABLE_NSNGR_GROUPS."`");
    while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) { echo "<option value='$gid'>$gname</option>\n"; }
    echo "</select><br /><br />\n"

		."<input type=\"hidden\" name=\"op\" value=\"addmsg\">"
		."<input type=\"hidden\" name=\"add_mdate\" value=\"$now\">"
		."<input type=\"submit\" value=\"" . _ADDMSG . "\">"
		."</form>";
		Max_CloseTable();
		incof();
}
}else {
	echo "Access Denied";
}