X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=9360b73c8ae581708cb69e5f1327a36f3c1fa0d0;hp=a9ba79610137c0a415f9006d98b13535aaa9573b;hb=e5dffd4249c97200cbad02f3f4eaf5c373fdb89a;hpb=7052cc3bd3ca07281078acbbce6ce595d753def1 diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index a9ba796101..9360b73c8a 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -41,30 +41,45 @@ if (!defined('__SECURITY')) { } // END - if // Register an administrator account -function addAdminAccount ($adminLogin, $passHash, $adminEmail) { +function addAdminAccount ($adminLogin, $passHash, $adminEmail, $accessLevel = 'deny') { + // Only let valid data pass + assert(in_array($accessLevel, array('allow', 'deny'))); + // Login does already exist $ret = 'already'; // Lookup the admin - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1", + $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1", array($adminLogin), __FUNCTION__, __LINE__); // Is the entry there? - if (SQL_HASZERONUMS($result)) { - // Ok, let's create the admin login - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", - array( - $adminLogin, - $passHash, - $adminEmail - ), __FUNCTION__, __LINE__); + if (ifSqlHasZeroNums($result)) { + // Is ext-admins installed and version at least 0.3.0? + if (isExtensionInstalledAndNewer('admins', '0.3.0')) { + // Ok, let's create the admin login + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`, `default_acl`) VALUES ('%s', '%s', '%s', '%s')", + array( + $adminLogin, + $passHash, + $adminEmail, + $accessLevel + ), __FUNCTION__, __LINE__); + } else { + // Ok, let's create the admin login + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", + array( + $adminLogin, + $passHash, + $adminEmail + ), __FUNCTION__, __LINE__); + } // All done $ret = 'done'; } // END - if // Free memory - SQL_FREERESULT($result); + sqlFreeResult($result); // Return result return $ret; @@ -80,7 +95,7 @@ function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) { $adminId = getAdminId($adminLogin); // Continue only with found admin ids - if ($adminId > 0) { + if (isValidId($adminId)) { // Then we need to lookup the login name by getting the admin hash $adminHash = getAdminHash($adminId); @@ -175,7 +190,7 @@ function doAdminAction () { loadTemplate('admin_main', FALSE, $content); // Check if action/what pair is valid - $result_action = SQL_QUERY_ESC("SELECT + $result_action = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` @@ -200,7 +215,7 @@ LIMIT 1", ), __FUNCTION__, __LINE__); // Is there an entry? - if (SQL_NUMROWS($result_action) == 1) { + if (sqlNumRows($result_action) == 1) { // Is valid but does the inlcude file exists? $inc = sprintf("inc/modules/admin/action-%s.php", $action); if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === TRUE)) { @@ -219,7 +234,7 @@ LIMIT 1", } // Free memory - SQL_FREERESULT($result_action); + sqlFreeResult($result_action); // Tableset footer loadTemplate('admin_main_footer', FALSE, $content); @@ -252,7 +267,7 @@ function addAdminMenu ($action, $what) { $GLOBALS['menu']['title'] = array(); // Build main menu - $result_main = SQL_QUERY("SELECT + $result_main = sqlQuery("SELECT `action` AS `main_action`, `title` AS `main_title`, `descr` AS `main_descr` @@ -265,11 +280,11 @@ ORDER BY `id` DESC", __FUNCTION__, __LINE__); // Are there entries? - if (!SQL_HASZERONUMS($result_main)) { + if (!ifSqlHasZeroNums($result_main)) { $OUT .= ''; // Free memory - SQL_FREERESULT($result_main); + sqlFreeResult($result_main); } // END - if // Return content @@ -332,7 +347,7 @@ function addAdminSubMenu ($mainContent, $action, $what) { $OUT = ''; // Check for menu entries - $result_what = SQL_QUERY_ESC("SELECT + $result_what = sqlQueryEscaped("SELECT `what` AS `sub_what`, `title` AS `sub_title`, `descr` AS `sub_descr` @@ -348,7 +363,7 @@ ORDER BY array($mainContent['main_action']), __FUNCTION__, __LINE__); // Remember the count for later checks - setAdminMenuHasEntries($mainContent['main_action'], ((!SQL_HASZERONUMS($result_what)) && (($action == $mainContent['main_action']) || (isAdminMenuJavascriptEnabled())))); + setAdminMenuHasEntries($mainContent['main_action'], ((!ifSqlHasZeroNums($result_what)) && (($action == $mainContent['main_action']) || (isAdminMenuJavascriptEnabled())))); // Start li-tag for sub menu content $OUT .= '
  • '; @@ -359,12 +374,12 @@ ORDER BY $SUB = TRUE; // Are there entries? - if (!SQL_HASZERONUMS($result_what)) { + if (!ifSqlHasZeroNums($result_what)) { // Start HTML code $OUT .= '