require($INC);
}
-//
-function ADD_MODULE_TITLE($mod) {
+// Returns the title for given module
+function ADD_MODULE_TITLE ($mod) {
global $cacheArray;
- $name = ""; $result = false;
+
+ // Init variables
+ $name = "";
+ $result = false;
// Is the script installed?
if (isBooleanConstantAndTrue('mxchange_installed')) {
// Still no luck or empty title?
if (empty($name)) {
// No name found
- $name = sprintf("%s (%s)", LANG_UNKNOWN_MODULE, $mod);
+ $name = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $mod);
if (SQL_NUMROWS($result) == 0) {
// Add module to database
$dummy = CHECK_MODULE($mod);
}
// Is the module found?
- if ($found) {
+ if ($found === true) {
// Check returned values against current access permissions
//
// Admin access ----- Guest access ----- --- Guest or member? ---
// Add menu description pending on given file name (without path!)
function ADD_DESCR ($ACC_LVL, $file, $return = false, $output = true) {
global $NAV_DEPTH;
+
// Use only filename of the file ;)
$file = basename($file);
return $OUT;
}
}
+
//
function ADD_MENU ($MODE, $act, $wht) {
// Init some variables
OUTPUT_HTML("</table>");
}
}
+
// This patched function will reduce many SELECT queries for the specified or current admin login
function IS_ADMIN ($admin="") {
global $cacheArray;
// Use cached string
$valPass = $cacheArray['admin_hash'];
} elseif ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) {
- // Count cache hits
- incrementConfigEntry('cache_hits');
-
// Login data is valid or not?
$valPass = generatePassString($cacheArray['admins']['password'][$admin]);
// Cache it away
$cacheArray['admin_hash'] = $valPass;
+
+ // Count cache hits
+ incrementConfigEntry('cache_hits');
} elseif ((!empty($admin)) && ((!EXT_IS_ACTIVE("cache"))) || (!isset($cacheArray['admins']['password'][$admin]))) {
// Search for admin
$result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1",
//* DEBUG: */ if (!$ret) echo __LINE__."OK!<br />";
return $ret;
}
-//
-function ADD_MAX_RECEIVE_LIST($MODE, $default="", $return=false)
-{
+
+// Generates a list of "max receiveable emails per day"
+function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) {
global $_POST;
$OUT = "";
- switch ($MODE)
- {
+ switch ($MODE) {
case "guest":
// Guests (in the registration form) are not allowed to select 0 mails per day.
$result = SQL_QUERY("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value > 0 ORDER BY value", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0)
- {
+ if (SQL_NUMROWS($result) > 0) {
$OUT = "";
- while (list($value, $comment) = SQL_FETCHROW($result))
- {
+ while (list($value, $comment) = SQL_FETCHROW($result)) {
$OUT .= " <option value=\"".$value."\"";
if ($_POST['max_mails'] == $value) $OUT .= " selected=\"selected\"";
$OUT .= ">".$value." ".PER_DAY;
// Free memory
SQL_FREERESULT($result);
$OUT = LOAD_TEMPLATE("guest_receive_table", true);
- }
- else
- {
+ } else {
// Maybe the admin has to setup some maximum values?
+ debug_report_bug("Nothing is being done here?");
}
break;
case "member":
// Members are allowed to set to zero mails per day (we will change this soon!)
$result = SQL_QUERY("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` ORDER BY value", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0)
- {
+ if (SQL_NUMROWS($result) > 0) {
$OUT = "";
- while (list($value, $comment) = SQL_FETCHROW($result))
- {
+ while (list($value, $comment) = SQL_FETCHROW($result)) {
$OUT .= " <option value=\"".$value."\"";
if ($default == $value) $OUT .= " selected=\"selected\"";
$OUT .= ">".$value." ".PER_DAY;
define('__MAX_RECEIVE_OPTIONS', $OUT);
SQL_FREERESULT($result);
$OUT = LOAD_TEMPLATE("member_receive_table", true);
- }
- else
- {
+ } else {
// Maybe the admin has to setup some maximum values?
$OUT = LOAD_TEMPLATE("admin_settings_saved", true, NO_MAX_VALUES);
}
break;
}
- if ($return)
- {
+
+ if ($return) {
// Return generated HTML code
return $OUT;
- }
- else
- {
+ } else {
// Output directly (default)
OUTPUT_HTML($OUT);
}
}
-//
-function SEARCH_EMAIL_USERTAB($email)
-{
- $ret = false;
- $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE email LIKE '{PER}%s{PER}' LIMIT 1", array($email), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) $ret = true;
+
+// Checks wether the given email address is used.
+function SEARCH_EMAIL_USERTAB ($email) {
+ // Query the database
+ $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE email LIKE '{PER}%s{PER}' LIMIT 1",
+ array($email), __FILE__, __LINE__);
+
+ // Is the email there?
+ $ret = (SQL_NUMROWS($result) == 1);
+
+ // Free the result
SQL_FREERESULT($result);
+
+ // Return result
return $ret;
}
-//
-function WHAT_IS_VALID($act, $wht, $type="guest")
-{
- if (IS_ADMIN())
- {
+
+// Checks wether 'what' is valid
+// @TODO This cache can be flushed to hard drive
+function WHAT_IS_VALID ($act, $wht, $type="guest") {
+ global $cacheArray;
+
+ // Is admin or cache entry is there?
+ if (IS_ADMIN()) {
// Everything is valid to the admin :-)
- return true;
- }
- else
- {
+ $ret = true;
+ } elseif (isset($cacheArray['what_valid'][$type][$act][$what])) {
+ // Use the cache
+ $ret = $cacheArray['what_valid'][$type][$act][$what];
+
+ // Count the cache hit
+ incrementConfigEntry('cache_hits');
+ } else {
+ // By default is nothing valid
$ret = false;
+
+ // Look in database
$result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE action='%s' AND what='%s' AND `locked`='N' LIMIT 1", array($type, $act, $wht), __FILE__, __LINE__);
+
// Is "what" valid?
- if (SQL_NUMROWS($result) == 1) $ret = true;
+ $ret = (SQL_NUMROWS($result) == 1);
+
+ // Free the result
SQL_FREERESULT($result);
- return $ret;
}
+
+ // Cache the entry
+ $cacheArray['what_valid'][$type][$act][$what] = $ret;
+
+ // Return the result
+ return $ret;
}
-//
+
+// Checks wether the current user is a member
function IS_MEMBER () {
global $status, $LAST, $cacheArray;
if (!is_array($LAST)) $LAST = array();
// Return status
return $ret;
}
-//
-function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false)
-{
+
+// Validate the given menu action
+function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false) {
+ // By default nothing is valid
$ret = false;
+
+ // Look in all menus or only unlocked
$ADD = "";
if ((!IS_ADMIN()) && ($MODE != "admin")) $ADD = " AND `locked`='N'";
+
//* DEBUG: */ echo __LINE__.":".$MODE."/".$act."/".$wht."*<br />\n";
if (($MODE != "admin") && ($UPDATE)) {
// Update guest or member menu