************************************************************************/
// Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+if (!defined('__SECURITY')) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
require($INC);
}
// Is the script installed?
if (isBooleanConstantAndTrue('mxchange_installed')) {
- if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod]))) {
+ // Check if cache is valid
+ if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (in_array($mod, $cacheArray['modules']['module']))) {
// Load from cache
$name = $cacheArray['modules']['title'][$mod];
list($name) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
}
- }
+ } // END - if
// Trim name
$name = trim($name);
if (SQL_NUMROWS($result) == 0) {
// Add module to database
$dummy = CHECK_MODULE($mod);
- }
- }
+ } // END - if
+ } // END - if
+
+ // Return name
return $name;
}
// Load menu header template
LOAD_TEMPLATE($MODE."_menu_title", false, $content);
- $result_sub = SQL_QUERY_ESC("SELECT title, what FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what != '' ".$AND." ORDER BY sort",
+ $result_sub = SQL_QUERY_ESC("SELECT title, what FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ".$AND." ORDER BY sort",
array($MODE, $main_action), __FILE__, __LINE__);
$ctl = SQL_NUMROWS($result_sub);
if ($ctl > 0) {
//* DEBUG: */ echo __LINE__."ADMIN:".$admin."/".$passCookie."<br />";
// Search in array for entry
- if ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) {
+ if (isset($cacheArray['admin_hash'])) {
+ // Use cached string
+ $valPass = $cacheArray['admin_hash'];
+ } elseif ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) {
// Count cache hits
$_CONFIG['cache_hits']++;
// Login data is valid or not?
$valPass = generatePassString($cacheArray['admins']['password'][$admin]);
+
+ // Cache it away
+ $cacheArray['admin_hash'] = $valPass;
} elseif (!empty($admin)) {
// Search for admin
$result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
// Admin login was found so let's load password from DB
list($passDB) = SQL_FETCHROW($result);
+ // Temporary cache it
+ $cacheArray['admins']['password'][$admin] = $passDB;
+
// Generate password hash
$valPass = generatePassString($passDB);
- }
+ } // END - if
// Free memory
SQL_FREERESULT($result);
// Free memory
SQL_FREERESULT($result);
- }
- else
- {
+ } else {
// Cookie data is invalid!
//* DEBUG: */ echo __LINE__."///<br />";
destroy_user_session();
// Remove array elements to prevent errors
unset($GLOBALS['userid']);
}
+
+ // Return status
return $ret;
}
//
function GET_ACTION ($MODE, &$wht)
{
global $ret, $_CONFIG;
- // DEPRECATED: Init status
+ // @DEPRECATED Init status
$ret = "";
//* DEBUG: */ echo __LINE__."=".$MODE."/".$wht."/".$GLOBALS['action']."=<br />";
} elseif (!empty($GLOBALS['action'])) {
// Get it directly from URL
return $GLOBALS['action'];
- } else {
- // Everything else will be touched after checking the module has a menu assigned
}
//* DEBUG: */ echo __LINE__."*".$ret."*<br />\n";
- if (MODULE_HAS_MENU($MODE))
- {
+ if (MODULE_HAS_MENU($MODE)) {
// Rewriting modules to menu
- switch ($MODE)
- {
+ switch ($MODE) {
case "index": $MODE = "guest"; break;
case "login": $MODE = "member"; break;
- break;
- }
+ } // END - switch
// Guest and member menu is "main" as the default
if (empty($ret)) $ret = "main";
if (SQL_NUMROWS($result) == 1) {
// Load action value and pray that this one is the right you want... ;-)
list($ret) = SQL_FETCHROW($result);
- }
+ } // END - if
// Free memory
SQL_FREERESULT($result);
- }
+ } // END - if
// Return action value
return $ret;
$ret = _CATEGORY_404;
// Is the category id set?
- if (!empty($cid)) {
-
- // Lookup the category
+ if ($cid == "0") {
+ // No category
+ $ret = _CATEGORY_NONE;
+ } elseif ($cid > 0) {
+ // Lookup the category in database
$result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%s LIMIT 1",
array(bigintval($cid)), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
* rid = inc/modules/guest/what-confirm.php need this
* locked = Shall I pay it to normal (false) or locked (true) points ammount?
* add_mode = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
- * will cause no referral will get points ever!!!)
+ * for default value will cause no referral will get points ever!!!)
*/
function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref")
{
$percents = "percents"; if (isset($_CONFIG['db_percents'])) $percents = $_CONFIG['db_percents'];
$table = "refdepths"; if (isset($_CONFIG['db_table'])) $table = $_CONFIG['db_table'];
+ // Default is "normal" points
+ $data = "points";
+
// Which points, locked or normal?
- $data = "points"; if ($locked) $data = "locked_points";
+ if ($locked) $data = "locked_points";
// Check user account
$result_user = SQL_QUERY_ESC("SELECT refid, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
// Direct payment shall be notified about
define('__POINTS_VALUE', $ref_points);
+ // Prepare content
+ $content = array(
+ 'text' => REASON_DIRECT_PAYMENT,
+ 'points' => TRANSLATE_COMMA($ref_points)
+ );
+
// Load message
- $msg = LOAD_EMAIL_TEMPLATE("add-points", REASON_DIRECT_PAYMENT, $uid);
+ $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, $uid);
// And sent it away
SEND_EMAIL($email, SUBJECT_DIRECT_PAYMENT, $msg);
}
// Now a mail to the user and that's all...
- $msg = LOAD_EMAIL_TEMPLATE("del-user", $reason, $uid);
+ $msg = LOAD_EMAIL_TEMPLATE("del-user", array('text' => $reason), $uid);
SEND_EMAIL($uid, ADMIN_DEL_ACCOUNT, $msg);
// Ok, delete the account!