X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=2f2d9bb0fc3bb9b1f4de3e7aea4385ae4aab0017;hp=0d06e5fbfde55875e011fd4fd359fced8c054b84;hb=0e269568bd666186509e98594e83bac199ac26da;hpb=7fabfadce30a7bea7ce3ad1f1e2e7e5e616f2669
diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php
index 0d06e5fbfd..2f2d9bb0fc 100644
--- a/inc/modules/admin/admin-inc.php
+++ b/inc/modules/admin/admin-inc.php
@@ -51,10 +51,16 @@ function addAdminAccount ($user, $md5, $email) {
array($user), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 0) {
+ if (SQL_NUMROWS($result) == '0') {
// Ok, let's create the admin login
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (login, password, email) VALUES ('%s', '%s', '%s')",
- array($user, $md5, $email), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')",
+ array(
+ $user,
+ $md5,
+ $email
+ ), __FUNCTION__, __LINE__);
+
+ // All done
$ret = 'done';
} // END - if
@@ -175,15 +181,15 @@ function ifAdminLoginDataIsValid ($admin, $password) {
// Count login failure if admins extension version is 0.7.0+
if (($ret == 'pass') && (getExtensionVersion('admins') >= '0.7.0')) {
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET login_failures=login_failures+1,last_failure=NOW() WHERE `id`=%s LIMIT 1",
- array($adminId), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `id`=%s LIMIT 1",
+ array($adminId), __FUNCTION__, __LINE__);
// Rebuild cache
rebuildCacheFile('admin', 'admin');
} // END - if
// Return the result
- //* DEBUG: */ die("RETURN=".$ret);
+ //* DEBUG: */ die('RETURN=' . $ret);
return $ret;
}
@@ -206,8 +212,6 @@ function doAdminLogin ($adminLogin, $passHash) {
setSession('admin_login', $adminLogin)
) && (
setSession('admin_last', time())
- ) && (
- setSession('admin_to', bigintval(postRequestElement('timeout')))
));
}
@@ -224,7 +228,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
@@ -234,7 +238,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
@@ -242,14 +249,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();
@@ -283,7 +290,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);
@@ -329,6 +343,8 @@ WHERE
ORDER BY
`sort` ASC,
`id` DESC", __FUNCTION__, __LINE__);
+
+ // Do we have entries?
if (SQL_NUMROWS($result_main) > 0) {
$OUT = "