X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=76e4a85d13b06dd44e19b14047ad4f3b392e5a02;hb=3fce27f277e3316c33a7e904ef499370c0c95dde;hp=7976506243625b366d4a6e0c9453420b302b421d;hpb=c2e17d983fcbc0c3bd1dd37908d87c678f0367df;p=mailer.git
diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php
index 7976506243..76e4a85d13 100644
--- a/inc/modules/admin/admin-inc.php
+++ b/inc/modules/admin/admin-inc.php
@@ -1,7 +1,7 @@
");
+ //* DEBUG: */ outputHtml('*' . $data['password'] . '/' . md5($password) .'/' . $ret . '*
');
if ((isset($data['password'])) && (strlen($data['password']) == 32) && ($data['password'] == md5($password))) {
// Generate new hash
$data['password'] = generateHash($password);
// Is the sql_patches not installed, than we cannot have a valid hashed password here!
+ //* DEBUG: */ outputHtml($ret . ',' . intval(isExtensionInstalledAndOlder('sql_patches', '0.3.6')) . '/' . intval(!isExtensionInstalled('sql_patches')).'
');
if (($ret == 'pass') && ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches')))) $ret = 'done';
} elseif ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches'))) {
// Old hashing way
@@ -133,8 +136,8 @@ function ifAdminLoginDataIsValid ($admin, $password) {
$salt = substr($data['password'], 0, -40);
// Check if password is same
- //* DEBUG: */ outputHtml("*".$ret.','.$data['password'].','.$password.','.$salt."*
");
- if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
+ //* DEBUG: */ outputHtml('*' . $ret . ',' . $data['password'] . ',' . $password . ',' . $salt . '*
');
+ if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == md5($password))) {
// Re-hash the plain passord with new random salt
$data['password'] = generateHash($password);
@@ -194,7 +197,7 @@ function ifAdminLoginDataIsValid ($admin, $password) {
// Try to login the admin by setting some session/cookie variables
function doAdminLogin ($adminLogin, $passHash) {
// Reset failure counter on matching admins version
- if ((isExtensionInstalledAndNewer('admins', '0.7.0')) && ((isExtensionOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches')))) {
+ if ((isExtensionInstalledAndNewer('admins', '0.7.0')) && ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches')))) {
// Reset counter on out-dated sql_patches version
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `login_failures`=0, `last_failure`='0000-00-00 00:00:00' WHERE `login`='%s' LIMIT 1",
array($adminLogin), __FUNCTION__, __LINE__);
@@ -205,13 +208,11 @@ function doAdminLogin ($adminLogin, $passHash) {
// Now set all session variables and return the result
return ((
- setSession('admin_md5', generatePassString($passHash))
+ setSession('admin_md5', generatePassString(generateHash($passHash, '', false)))
) && (
setSession('admin_login', $adminLogin)
) && (
setSession('admin_last', time())
- ) && (
- setSession('admin_to', bigintval(postRequestElement('timeout')))
));
}
@@ -228,7 +229,7 @@ function ifAdminCookiesAreValid ($admin, $password) {
//* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")
");
// Check if password matches
- if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
+ if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass))) && (isAdmin())) {
// Passwords matches!
$ret = 'done';
} // END - if
@@ -238,7 +239,10 @@ function ifAdminCookiesAreValid ($admin, $password) {
}
// Do an admin action
-function doAdminAction ($what) {
+function doAdminAction () {
+ // Get default what
+ $what = getWhat();
+
//* DEBUG: */ outputHtml(__LINE__."*".$what.'/'.getModule().'/'.getAction().'/'.getWhat()."*
");
// Remove any spaces from variable
@@ -246,14 +250,14 @@ function doAdminAction ($what) {
// Default admin action is the overview page
$what = 'overview';
} else {
- // Compile out some chars
- $what = compileCode($what, false, false, false);
+ // Secure it
+ $what = secureString($what);
}
// Get action value
$action = getModeAction(getModule(), $what);
- // Define admin login name and ID number
+ // Define admin login name and id number
$content['login'] = getSession('admin_login');
$content['id'] = getCurrentAdminId();
@@ -287,7 +291,14 @@ WHERE
)
)
)
-LIMIT 1", array($action, $what, $what), __FUNCTION__, __LINE__);
+LIMIT 1",
+ array(
+ $action,
+ $what,
+ $what
+ ), __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
if (SQL_NUMROWS($result_action) == 1) {
// Is valid but does the inlcude file exists?
$inc = sprintf("inc/modules/admin/action-%s.php", $action);
@@ -296,14 +307,14 @@ LIMIT 1", array($action, $what, $what), __FUNCTION__, __LINE__);
loadInclude($inc);
} elseif ($GLOBALS['acl_allow'] === false) {
// Access denied
- loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACCESS_DENIED'), $what));
+ loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what));
} else {
// Include file not found! :-(
- loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_404'), $action));
+ loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action));
}
} else {
// Invalid action/what pair found!
- loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action.'/'.$what));
+ loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what));
}
// Free memory
@@ -333,9 +344,11 @@ WHERE
ORDER BY
`sort` ASC,
`id` DESC", __FUNCTION__, __LINE__);
+
+ // Do we have entries?
if (SQL_NUMROWS($result_main) > 0) {
- $OUT = "
\n";
- $OUT .= "\n";
+ $OUT = '
';
+ $OUT .= '';
// @TODO Rewrite this to $content = SQL_FETCHARRAY()
while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
@@ -345,31 +358,45 @@ ORDER BY
$ACL = true;
}
+ // Filename
+ $inc = sprintf("inc/modules/admin/action-%s.php", $menu);
+
+ // Is the file readable?
+ $readable = isIncludeReadable($inc);
+
if ($ACL === true) {
if ($SUB === false) {
// Insert compiled menu title and description
$GLOBALS['menu']['title'][$menu] = $title;
$GLOBALS['menu']['description'][$menu] = $descr;
}
- $OUT .= "';
// Check for menu entries
$result_what = SQL_QUERY_ESC("SELECT
@@ -392,7 +419,7 @@ ORDER BY
if ((ifAdminMenuHasEntries($menu)) && (SQL_NUMROWS($result_what) > 0)) {
$GLOBALS['menu']['description'] = array();
$GLOBALS['menu']['title'] = array(); $SUB = true;
- $OUT .= "';
} // END - if
- $OUT .= "-
\n";
+ $OUT .= '-
';
} // END - if
} // END - while
// Free memory
SQL_FREERESULT($result_main);
- $OUT .= "
\n";
+ $OUT .= '
';
}
// Is there a cache instance again?
@@ -475,13 +502,13 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
$OUT = '';
// USe this only for adding points (e.g. adding refs really makes no sence ;-) )
- if ($add_all === true) $OUT = " \n";
- elseif ($none === true) $OUT = " \n";
+ if ($add_all === true) $OUT = ' ';
+ elseif ($none === true) $OUT = ' ';
while ($content = SQL_FETCHARRAY($result)) {
- $OUT .= " ';
} // END - while
// Free memory
@@ -496,7 +523,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
loadTemplate('admin_member_selection_box', false, $content);
} else {
// Return content in selection frame
- return "\n";
+ return '';
}
}
@@ -505,13 +532,14 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
// @DEPRECATED
function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
$what = "`what` != ''";
- if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND action !='login'";
- $result = SQL_QUERY_ESC("SELECT %s, title FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort`",
+ if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
+
+ $result = SQL_QUERY_ESC("SELECT %s, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
array($mode), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) > 0) {
// Load menu as selection
$OUT = "