************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
require($INC);
}
+
// Add description as navigation point
ADD_DESCR("admin", basename(__FILE__));
-OPEN_TABLE("100%", "admin_content admin_content_align", "");
-
// Check if the admin has entered title and what-php file name...
-if (((empty($_POST['title'])) || (empty($_POST['menu'])) || (empty($_POST['descr']))) && (isset($_POST['ok'])))
-{
+if (((empty($_POST['title'])) || (empty($_POST['menu'])) || (empty($_POST['descr']))) && (isset($_POST['ok']))) {
unset($_POST['ok']);
}
$menus = array(); $titles = array(); $below = array();
// Get all available main menus
- $result = SQL_QUERY("SELECT action, title, sort FROM "._MYSQL_PREFIX."_admin_menu WHERE what='' ORDER BY sort", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT action, title, sort FROM "._MYSQL_PREFIX."_admin_menu WHERE (what='' OR what IS NULL) ORDER BY sort", __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0)
{
// Read menu structure
// Remove double eintries
$prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below;
- foreach ($menus as $key=>$value)
+ foreach ($menus as $key => $value)
{
if ($value == $prev)
{
}
$menus = $dmy; $titles = $dmy2; $below = $dmy3;
// Load sub menus :)
- foreach ($menus as $key_main=>$value_main)
+ foreach ($menus as $key_main => $value_main)
{
- $result = SQL_QUERY_ESC("SELECT what, title, sort FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' ORDER BY sort",
+ $result = SQL_QUERY_ESC("SELECT what, title, sort FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ORDER BY sort",
array($value_main), __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0)
{
// Remove double eintries
$prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
- foreach ($menus[$value_main] as $key=>$value)
+ foreach ($menus[$value_main] as $key => $value)
{
if ($value == $prev)
{
}
$OUT = " <SELECT class=\"admin_select\" name=\"sort\" size=\"1\">
<OPTION value=\"0\">".IS_FIRST_MENU."</OPTION>\n";
- foreach ($below as $key=>$m)
+ foreach ($below as $key => $m)
{
if (is_array($m))
{
- foreach ($m as $key2=>$m2)
+ foreach ($m as $key2 => $m2)
{
$OUT .= " <OPTION value=\"".$m2."\">".$titles[$key][$key2];
- foreach ($menus as $k=>$v)
+ foreach ($menus as $k => $v)
{
if (($v == $key) && (!is_array($v)))
{
if (!empty($_POST['menu']))
{
// Add sub menu
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort)
-VALUES('%s', '%s', '%s', '%s', '%s')",
+ $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admin_menu (`action`,`what`,`title`,`descr`,`sort`)
+VALUES('%s','%s','%s','%s','%s')",
array(
$_POST['menu'],
$_POST['name'],
addslashes($_POST['descr']),
bigintval($_POST['sort']),
), __FILE__, __LINE__);
+ CACHE_PURGE_ADMIN_MENU(0, $_POST['menu'], $_POST['name']);
}
else
{
// Add main menu
$result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, title, descr, sort)
-VALUES('%s', '%s', '%s', '%s')",
+VALUES('%s','%s','%s','%s')",
array(
$_POST['name'],
$_POST['title'],
addslashes($_POST['descr']),
bigintval($_POST['sort']),
), __FILE__, __LINE__);
+ CACHE_PURGE_ADMIN_MENU(0, $_POST['name']);
}
LOAD_TEMPLATE("admin_settings_saved", false, SAVING_DONE);
}
// Is demo login!
LOAD_TEMPLATE("admin_settings_saved", false, SETTINGS_NOT_SAVED);
}
-CLOSE_TABLE();
//
?>