<?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)  {

    OpenHeader(_BLOCKMGR);
	Max_OpenTable();
	echo "<center><font class=\"option\"><b>"._ADDNEWBLOCK."</b></font></center><br /><br />"
	."<form action=\"".$admin_file.".php\" method=\"post\">"
	."<table border=\"0\" width=\"100%\">"
	."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"30\" maxlength=\"60\"></td></tr>"
	."<tr><td>"._RSSFILE.":</td><td><input type=\"text\" name=\"url\" size=\"30\" maxlength=\"200\">&nbsp;&nbsp;"
	."<select name=\"headline\">"
	."<option name=\"headline\" value=\"0\" selected>"._CUSTOM."</option>";
	$res3 = $db->sql_query("select hid, sitename from ".$prefix."_headlines");
	while ($row_res3 = $db->sql_fetchrow($res3)) {
		$hid = $db->XMFnum($row_res3['hid']);
		$htitle = stripslashes($row_res3['sitename']);
		echo "<option name=\"headline\" value=\"$hid\">$htitle</option>";
		}
	echo "</select>&nbsp;[ <a href=\"".$admin_file.".php?op=HeadlinesAdmin\">Setup</a> ]<br /><font class=\"tiny\">";
	echo ""._SETUPHEADLINES."</font></td></tr>"
	."<tr><td>"._FILENAME.":</td><td>"
	."<select name=\"blockfile\">"
	."<option name=\"blockfile\" value=\"\" selected>"._NONE."</option>";
	$blocksdir = dir("blocks");
	while($func=$blocksdir->read()) {
		if(substr($func, 0, 6) == "block-") {
			$blockslist .= "$func ";
		}
	}
	closedir($blocksdir->handle);
	$blockslist = explode(" ", $blockslist);
	sort($blockslist);
	for ($i=0; $i < sizeof($blockslist); $i++) {
		if($blockslist[$i]!="") {
			$bl = ereg_replace("block-","",$blockslist[$i]);
			$bl = ereg_replace(".php","",$bl);
			$bl = ereg_replace("_"," ",$bl);
			$result2 = $db->sql_query("select * from ".TABLE_BLOCKS." where blockfile='$blockslist[$i]'");
			$numrows = $db->sql_numrows($result2);
			if ($numrows == 0) {
			echo "<option value=\"$blockslist[$i]\">$bl</option>\n";
				}
			}
		}
	echo "</select>&nbsp;&nbsp;<font class=\"tiny\">"._FILEINCLUDE."</font></td></tr>"
	."<tr><td>"._CONTENT.":</td><td><textarea name=\"content\" cols=\"70\" rows=\"15\"></textarea><br /><font class=\"tiny\">"._IFRSSWARNING."</font></td></tr>";

	if ($multilingual == 1) {
		echo "<tr><td>"._LANGUAGE.":</td><td>"
		."<select name=\"blanguage\">";
		$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]==$currentlang) echo "selected";
				echo ">".ucfirst($languageslist[$i])."</option>\n";
			}
		}
		echo "<option value=\"\">"._ALL."</option></select></td></tr>";
	} else {
		echo "<input type=\"hidden\" name=\"blanguage\" value=\"\">";
	}
	echo "<tr><td>"._ACTIVATE2."</td><td><input type=\"radio\" name=\"active\" value=\"1\" checked>"._YES." &nbsp;&nbsp;"
	."<input type=\"radio\" name=\"active\" value=\"0\">"._NO."</td></tr>"
	."<tr><td>"._EXPIRATION.":</td><td><input type=\"text\" name=\"expire\" size=\"4\" maxlength=\"3\" value=\"0\"> "._DAYS."</td></tr>"
	."<tr><td>"._AFTEREXPIRATION.":</td><td><select name=\"action\">"
	."<option name=\"action\" value=\"d\">"._DEACTIVATE."</option>"
	."<option name=\"action\" value=\"r\">"._DELETE."</option></select></td></tr>"
	."<tr><td>"._REFRESHTIME.":</td><td><select name=\"refresh\">"
	."<option name=\"refresh\" value=\"1800\">1/2 "._HOUR."</option>"
	."<option name=\"refresh\" value=\"3600\" selected>1 "._HOUR."</option>"
	."<option name=\"refresh\" value=\"18000\">5 "._HOURS."</option>"
	."<option name=\"refresh\" value=\"36000\">10 "._HOURS."</option>"
	."<option name=\"refresh\" value=\"86400\">24 "._HOURS."</option></select>&nbsp;<font class=\"tiny\">"._ONLYHEADLINES."</font></td></tr>"
	."<tr><td>"._VIEWPRIV."</td><td><select name=\"view\">"
	."<option value=\"0\" >"._MVALL."</option>"
	."<option value=\"1\" >"._MVUSERS."</option>"
	."<option value=\"2\" >"._MVADMIN."</option>"
	."<option value=\"3\" >"._MVANON."</option>"
	    ."<option value=\"4\">"._MVGROUPS."</option>"
	    ."</select></td></tr><tr><td nowrap>"
	    ."<b>"._WHATGROUPS."</b></td><td><font class='tiny'>"._WHATGRDESC."</font><br /><select name='groups[]' multiple size='5'>\n";
        $groupsResult = $db->sql_query("select gid, gname from ".TABLE_NSNGR_GROUPS."");
        while($raw = $db->sql_fetchrow($groupsResult)) {
	$gid = $db->XMFnum($raw['gid']);
	$gname = stripslashes($raw['gname']);
	echo "<OPTION VALUE='$gid'>$gname</option>\n"; }
	    echo "</select></td></tr><tr><td nowrap>\n"
	    .""._SUBVISIBLE."</td><td><input type=\"radio\" name=\"subscription\" value=\"0\" checked>"._YES." &nbsp;&nbsp;<input type=\"radio\" name=\"subscription\" value=\"1\">"._NO.""

		."</td></tr></table><br /><br />"
		."<input type=\"hidden\" name=\"op\" value=\"BlocksAdd\">"
		."<input type=\"submit\" value=\""._CREATEBLOCK."\"></form>";
		Max_CloseTable();
		CloseFooter();

}
}else {
	echo "Access Denied";
}