// Register an administrator account
function REGISTER_ADMIN ($user, $md5, $email) {
// Login does already exist
- $ret = "already";
+ $ret = 'already';
// Lookup the admin
$result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1",
- array($user), __FUNCTION__, __LINE__);
+ array($user), __FUNCTION__, __LINE__);
// Is the entry there?
if (SQL_NUMROWS($result) == 0) {
$add = runFilterChain('sql_admin_extra_data');
// Get password from DB
- $result = SQL_QUERY_ESC("SELECT password".$add." FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
- array($aid), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `password`" . $add . " FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
+ array($aid), __FUNCTION__, __LINE__);
// Entry found?
if (SQL_NUMROWS($result) == 1) {
SQL_FREERESULT($result);
}
- //* DEBUG: */ echo "*".$data['password'].'/'.md5($password).'/'.$ret."<br />";
+ //* DEBUG: */ OUTPUT_HTML("*".$data['password'].'/'.md5($password).'/'.$ret."<br />");
if ((isset($data['password'])) && (strlen($data['password']) == 32) && ($data['password'] == md5($password))) {
// Generate new hash
$data['password'] = generateHash($password);
$salt = __SALT;
// Check if password is same
- //* DEBUG: */ echo "*".$ret.','.$data['password'].','.$password.','.$salt."*<br >\n";
+ //* DEBUG: */ OUTPUT_HTML("*".$ret.','.$data['password'].','.$password.','.$salt."*<br />");
if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
// Re-hash the plain passord with new random salt
$data['password'] = generateHash($password);
if ((GET_EXT_VERSION('admins') >= '0.7.0') && ((EXT_VERSION_IS_OLDER('sql_patches', '0.3.6')) || (GET_EXT_VERSION('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__);
+ array($adminLogin), __FUNCTION__, __LINE__);
// Rebuild cache
rebuildCacheFiles('admins', 'admin');
} // END - if
// Now set all session variables and return the result
- return (
- (
- setSession('admin_md5', generatePassString($passHash))
+ return ((
+ setSession('admin_md5', generatePassString($passHash))
) && (
- setSession('admin_login', $adminLogin)
+ setSession('admin_login', $adminLogin)
) && (
- setSession('admin_last', time())
+ setSession('admin_last', time())
) && (
- setSession('admin_to', bigintval(REQUEST_POST('timeout')))
- )
- );
+ setSession('admin_to', bigintval(REQUEST_POST('timeout')))
+ ));
}
// Only be executed on cookie checking
function CHECK_ADMIN_COOKIES ($admin_login, $password) {
// By default no admin cookies are found
- $ret = '404'; $pass = '';
+ $ret = '404';
+ $pass = '';
// Get hash
$pass = GET_ADMIN_HASH(GET_ADMIN_ID($admin_login));
if ($pass != '-1') $ret = 'pass';
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")<br />");
// Check if password matches
if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
// Passwords matches!
$ret = 'done';
- }
+ } // END - if
// Return result
return $ret;
//
function ADMIN_DO_ACTION ($wht) {
global $DATA;
- //* DEBUG: */ echo __LINE__."*".$wht.'/'.getModule().'/'.getAction().'/'.getWhat()."*<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__LINE__."*".$wht.'/'.getModule().'/'.getAction().'/'.getWhat()."*<br />");
// Remove any spaces from variable
if (empty($wht)) {
$GLOBALS['menu']['description'][$menu] = $descr;
}
$OUT .= "<li class=\"admin_menu\">
- <div class=\"nobr\"><strong>·</strong> ";
+<div class=\"nobr\"><strong>·</strong> ";
if (($menu == $act) && (empty($wht))) {
$OUT .= "<strong>";
}
// Creates a user-profile link for the admin. This function can also be used for many other purposes
-function generateUserProfileLink ($uid, $title = '', $wht="list_user") {
+function generateUserProfileLink ($uid, $title = '', $wht = 'list_user') {
if (($title == '') && ($title != '0')) {
// Set userid as title
$title = $uid;
} // END - if
- if (($title == '0') && ($wht == "list_refs")) {
+ if (($title == '0') && ($wht == 'list_refs')) {
// Return title again
return $title;
} // END - if
- //* DEBUG: */ echo "a:".$title."<br />";
// Return link
+ //* DEBUG: */ OUTPUT_HTML("a:".$title."<br />");
return "<a href=\"{!URL!}/modules.php?module=admin&what=".$wht."&uid=".$uid."\" title=\"{--ADMIN_USER_PROFILE_TITLE--}\">".$title."</a>";
}
// "Walk" through all entries
foreach ($IDs as $id => $sel) {
// Construct SQL query
- $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET",
- SQL_ESCAPE($table)
- );
+ $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET", SQL_ESCAPE($table));
// Load data of entry
$result = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_%s` WHERE %s=%s LIMIT 1",
- array($table, $idColumn, $id), __FUNCTION__, __LINE__);
+ array($table, $idColumn, $id), __FUNCTION__, __LINE__);
// Fetch the data
$content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
// Add all status entries (e.g. status column last_updated or so)
- $newStatus = "UNKNOWN";
- $oldStatus = "UNKNOWN";
- $statusColumn = "unknown";
+ $newStatus = 'UNKNOWN';
+ $oldStatus = 'UNKNOWN';
+ $statusColumn = 'unknown';
foreach ($statusArray as $column => $statusInfo) {
// Does the entry exist?
if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
$sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
// Remember status
- if ($statusColumn == "unknown") {
+ if ($statusColumn == 'unknown') {
// Always (!!!) change status column first!
$oldStatus = $content[$column];
$newStatus = $statusInfo[$oldStatus];