// Check for prefix is a extension...
$modSplit = explode('_', $mod);
$extension = ''; $mod_chk = $mod;
- //* DEBUG: */ outputHtml(__LINE__."*".count($modSplit)."*/".$mod."*<br />");
+ //* DEBUG: */ print(__LINE__."*".count($modSplit)."*/".$mod."*<br />");
if (count($modSplit) == 2) {
// Okay, there is a seperator (_) in the name so is the first part a module?
- //* DEBUG: */ outputHtml(__LINE__."*".$modSplit[0]."*<br />");
+ //* DEBUG: */ print(__LINE__."*".$modSplit[0]."*<br />");
if (isExtensionActive($modSplit[0])) {
// The prefix is an extension's name, so let's set it
$extension = $modSplit[0]; $mod = $modSplit[1];
// Destroy cache here
// @TODO Rewrite this to a filter
- if (getOutputMode() == '0') rebuildCacheFile('modules', 'modules');
+ if ((getOutputMode() == 0) || (getOutputMode() == -1)) rebuildCacheFile('modules', 'modules');
// And reload data
unset($GLOBALS['module_status'][$mod]);
$OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=" . $modCheck . '&' . $type . '=' . $search.$LINK_ADD . "\">" . $ret . "</a></strong>\n";
// Can we close the you-are-here navigation?
- //* DEBUG: */ outputHtml(__LINE__."*".$type.'/'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__."*".$type.'/'.getWhat()."*<br />");
if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) {
- //* DEBUG: */ outputHtml(__LINE__.'+'.$type."+<br />");
+ //* DEBUG: */ print(__LINE__.'+'.$type."+<br />");
// Add closing div and br-tag
$OUT .= "</div><br />\n";
- $GLOBALS['nav_depth'] = '0';
+ $GLOBALS['nav_depth'] = 0;
// Run the filter chain
$ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
$result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort` ASC",
array($mode), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
if (SQL_NUMROWS($result_main) > 0) {
// There are menus available, so we simply display them... :)
$GLOBALS['rows'] = '';
while ($content = SQL_FETCHARRAY($result_main)) {
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.'/'.$content['action'].':'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].':'.getWhat()."*<br />");
// Init variables
enableBlockMode(false);
$action = $content['action'];
$OUT = '';
// Full file name for checking menu
- //* DEBUG: */ outputHtml(__LINE__.":!!!!".$content['sub_what']."!!!<br />");
+ //* DEBUG: */ print(__LINE__.":!!!!".$content['sub_what']."!!!<br />");
$inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']);
if (isIncludeReadable($inc)) {
// Mark currently selected menu - open
if (isFileReadable($INC)) {
// Load include file
if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', true, $mode);
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat()."*<br />");
loadInclude($INC);
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat()."*<br />");
if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_end', true, $mode);
}
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
}
$main_cnt++;
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
if (SQL_NUMROWS($result_main) > $main_cnt) {
// Add seperator
$GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode);
);
// Load main template
- //* DEBUG: */ outputHtml(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
loadTemplate('menu_table', false, $content);
} // END - if
}
$ret = true;
} else {
// Maybe got locked etc.
- //* DEBUG: */ outputHtml(__LINE__."!!!<br />");
+ //* DEBUG: */ print(__LINE__."!!!<br />");
destroyUserSession();
}
} else {
// Cookie data is invalid!
- //* DEBUG: */ outputHtml(__LINE__."***<br />");
+ //* DEBUG: */ print(__LINE__."***<br />");
destroyUserSession();
}
SQL_FREERESULT($result);
} else {
// Cookie data is invalid!
- //* DEBUG: */ outputHtml(__LINE__."///<br />");
+ //* DEBUG: */ print(__LINE__."///<br />");
destroyUserSession();
}
function isAdmin ($admin = '') {
// Init variables
$ret = false; $passCookie = ''; $valPass = '';
- //* DEBUG: */ outputHtml(__LINE__."ADMIN:".$admin."<br />");
+ //* DEBUG: */ print(__FUNCTION__.':'.$admin.'<br />');
// If admin login is not given take current from cookies...
if ((empty($admin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) {
$admin = getSession('admin_login');
$passCookie = getSession('admin_md5');
} // END - if
- //* DEBUG: */ outputHtml(__LINE__."ADMIN:".$admin.'/'.$passCookie."<br />");
+ //* DEBUG: */ print(__FUNCTION__.':'.$admin.'/'.$passCookie.'<br />');
- // Search in array for entry
- if (isset($GLOBALS['admin_hash'])) {
- // Use cached string
- $valPass = $GLOBALS['admin_hash'];
- } elseif ((!empty($passCookie)) && (isAdminHashSet($admin) === true) && (!empty($admin))) {
- // Login data is valid or not?
- $valPass = generatePassString(getAdminHash($admin));
+ // Do we have cache?
+ if (!isset($GLOBALS['is_admin'][$admin])) {
+ // Init it with failed
+ $GLOBALS['is_admin'][$admin] = false;
+
+ // Search in array for entry
+ if (isset($GLOBALS['admin_hash'])) {
+ // Use cached string
+ $valPass = $GLOBALS['admin_hash'];
+ } elseif ((!empty($passCookie)) && (isAdminHashSet($admin) === true) && (!empty($admin))) {
+ // Login data is valid or not?
+ $valPass = generatePassString(getAdminHash($admin));
+
+ // Cache it away
+ $GLOBALS['admin_hash'] = $valPass;
+
+ // Count cache hits
+ incrementStatsEntry('cache_hits');
+ } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) {
+ // Search for admin
+ $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
+ array($admin), __FUNCTION__, __LINE__);
- // Cache it away
- $GLOBALS['admin_hash'] = $valPass;
+ // Is he admin?
+ $passDB = '';
+ if (SQL_NUMROWS($result) == 1) {
+ // Admin login was found so let's load password from DB
+ list($passDB) = SQL_FETCHROW($result);
- // Count cache hits
- incrementStatsEntry('cache_hits');
- } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) {
- // Search for admin
- $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
- array($admin), __FUNCTION__, __LINE__);
+ // Temporary cache it
+ setAdminHash($admin, $passDB);
- // Is he admin?
- $passDB = '';
- if (SQL_NUMROWS($result) == 1) {
- // Admin login was found so let's load password from DB
- list($passDB) = SQL_FETCHROW($result);
+ // Generate password hash
+ $valPass = generatePassString($passDB);
+ } // END - if
- // Temporary cache it
- setAdminHash($admin, $passDB);
+ // Free memory
+ SQL_FREERESULT($result);
+ }
- // Generate password hash
- $valPass = generatePassString($passDB);
+ if (!empty($valPass)) {
+ // Check if password is valid
+ //* DEBUG: */ print(__FUNCTION__ . ':(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie).'<br />');
+ $GLOBALS['is_admin'][$admin] = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
-
- // Free memory
- SQL_FREERESULT($result);
- }
-
- if (!empty($valPass)) {
- // Check if password is valid
- //* DEBUG: */ print(__FUNCTION__ . ':' . $valPass . '/' . $passCookie . '<br />');
- $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
// Return result of comparision
- return $ret;
+ return $GLOBALS['is_admin'][$admin];
}
// Generates a list of "max receiveable emails per day"
$add = '';
if ((!isAdmin()) && ($mode != 'admin')) $add = " AND `locked`='N'";
- //* DEBUG: */ outputHtml(__LINE__.':'.$mode.'/'.$action.'/'.$what."*<br />");
+ //* DEBUG: */ print(__LINE__.':'.$mode.'/'.$action.'/'.$what."*<br />");
if (($mode != 'admin') && ($updateEntry === true)) {
// Update guest or member menu
$sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1",
loadTemplate('admin_settings_saved', false, $content);
}
-// Update module counter
-function countModuleHit($mod) {
- // Do count all other modules but not accesses on CSS file css.php!
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1",
- array($mod), __FUNCTION__, __LINE__);
-}
-
// Get action value from mode (admin/guest/member) and what-value
function getModeAction ($mode, $what) {
// Init status
$ret = '';
- //* DEBUG: */ outputHtml(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
+ //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
if ((empty($what)) && ($mode != 'admin')) {
$what = getConfig('index_home');
} // END - if
// Get it directly from URL
return getAction();
}
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ret=".$ret."<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ret=".$ret.'<br />');
// Does the module have a menu?
if (ifModuleHasMenu($mode)) {
$ret = getMessage('_CATEGORY_404');
// Is the category id set?
- if ($cid == '0') {
+ if ($cid == 0) {
// No category
$ret = getMessage('_CATEGORY_NONE');
} elseif ($cid > 0) {
return $ret;
}
-// Remove a receiver's ID from $receivers and add a link for him to confirm
+// Remove a receiver's id from $receivers and add a link for him to confirm
function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $bonus = false) {
// Default is not removed
$ret = 'failed';
// Is there already a line for this user available?
if ($stats_id > 0) {
- // Only when we got a real stats ID continue searching for the entry
+ // Only when we got a real stats id continue searching for the entry
$type = 'NORMAL'; $rowName = 'stats_id';
if ($bonus) { $type = 'BONUS'; $rowName = 'bonus_id'; }
// Calculate sum (default) or count records of given criteria
function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
$ret = 0;
- //* DEBUG: */ outputHtml($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'<br />');
+ //* DEBUG: */ print($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'<br />');
if ((empty($search)) && ($search != '0')) {
// Count or sum whole table?
if ($countRows === true) {
}
} elseif (($countRows === true) || ($lookFor == 'userid')) {
// Count rows
- //* DEBUG: */ outputHtml("COUNT!<br />");
+ //* DEBUG: */ print("COUNT!<br />");
$result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
} else {
// Add all rows
- //* DEBUG: */ outputHtml("SUM!<br />");
+ //* DEBUG: */ print("SUM!<br />");
$result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
}
$ret = '0.00000';
} elseif (''.$ret.'' == '') {
// Fix empty result
- $ret = '0';
+ $ret = 0;
}
// Return value
* Dynamic referal system, can also send mails!
*
* subject = Subject line, write in lower-case letters and underscore is allowed
- * userid = Referal ID wich should receive...
+ * userid = Referal id wich should receive...
* points = ... xxx points
* sendNotify = shall I send the referal an email or not?
* rid = inc/modules/guest/what-confirm.php need this
* add_mode = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct'
* for default value will cause no referal will get points ever!!!)
*/
-function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = '0', $locked = false, $add_mode = 'ref') {
- //* DEBUG: */ outputHtml("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
+function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = 0, $locked = false, $add_mode = 'ref') {
+ //* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
// Convert mode to lower-case
$add_mode = strtolower($add_mode);
// When $userid = 0 add points to jackpot
- if (($userid == '0') && (isExtensionActive('jackpot'))) {
+ if (($userid == 0) && (isExtensionActive('jackpot'))) {
// Add points to jackpot
addPointsToJackpot($points);
return;
// Count up referal depth
if (!isset($GLOBALS['ref_level'])) {
// Initialialize referal system
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />");
$GLOBALS['ref_level'] = 0;
} else {
// Increase referal level
$GLOBALS['ref_level']++;
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$GLOBALS['ref_level']}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$GLOBALS['ref_level']}<br />");
}
// Default is 'normal' points
$result_user = SQL_QUERY_ESC("SELECT `refid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
array(bigintval($userid)), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},numRows=".SQL_NUMROWS($result_user).",points={$points}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},numRows=".SQL_NUMROWS($result_user).",points={$points}<br />");
if (SQL_NUMROWS($result_user) == 1) {
// This is the user and his ref
list($ref, $email) = SQL_FETCHROW($result_user);
// Get percents
$per = getReferalLevelPercents($GLOBALS['ref_level']);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}<br />");
// Some percents found?
if ($per > 0) {
// Calculate new points
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},points={$points},per={$per},depth={$GLOBALS['ref_level']}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},points={$points},per={$per},depth={$GLOBALS['ref_level']}<br />");
$ref_points = $points * $per / 100;
// Pay refback here if level > 0 and in ref-mode
if ((isExtensionActive('refback')) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($add_mode == "ref") && (isset($GLOBALS['cache_array']['add_userid'][$userid]))) {
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!<br />");
$ref_points = addRefbackPoints($GLOBALS['cache_array']['add_userid'][$userid], $userid, $points, $ref_points);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!<br />");
} // END - if
// Update points...
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
array($data, $data, $ref_points, bigintval($userid), bigintval($GLOBALS['ref_level'])), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />");
// No entry updated?
if (SQL_AFFECTEDROWS() < 1) {
// First ref in this level! :-)
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,'%s',%s)",
array($data, bigintval($userid), bigintval($GLOBALS['ref_level']), $ref_points), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - INSERTED! (".SQL_AFFECTEDROWS().")<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - INSERTED! (".SQL_AFFECTEDROWS().")<br />");
} // END - if
// Points updated, maybe I shall send him an email?
// Maybe there's another ref?
if (($ref > 0) && ($points > 0) && ($ref != $userid) && ($add_mode == 'ref')) {
// Then let's credit him here...
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},ref={$ref},points={$points} - ADVANCE!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},ref={$ref},points={$points} - ADVANCE!<br />");
addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), $ref, $points, $sendNotify, $ref, $locked);
} // END - if
} // END - if
// Free result
SQL_FREERESULT($result_user);
- //* DEBUG: */ outputHtml("</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />");
+ //* DEBUG: */ print("</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />");
}
// Updates the referal counter
function updateReferalCounter ($userid) {
// Make it sure referal level zero (member him-/herself) is at least selected
if (empty($GLOBALS['cache_array']['ref_level'][$userid])) $GLOBALS['cache_array']['ref_level'][$userid] = 1;
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},level={$GLOBALS['cache_array']['ref_level'][$userid]}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},level={$GLOBALS['cache_array']['ref_level'][$userid]}<br />");
// Update counter
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`='%s' LIMIT 1",
array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
// When no entry was updated then we have to create it here
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):updated=".SQL_AFFECTEDROWS()."<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):updated=".SQL_AFFECTEDROWS().'<br />');
if (SQL_AFFECTEDROWS() < 1) {
// First count!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid}<br />");
} // END - if
// Check for his referal
// Free memory
SQL_FREERESULT($result);
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},ref={$ref}<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):userid={$userid},ref={$ref}<br />");
// When he has a referal...
if (($ref > 0) && ($ref != $userid)) {
// Move to next referal level and count his counter one up!
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - ADVANCE!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - ADVANCE!<br />");
$GLOBALS['cache_array']['ref_level'][$userid]++; updateReferalCounter($ref);
} elseif ((($ref == $userid) || ($ref == 0)) && (getExtensionVersion('cache') >= '0.1.2')) {
// Remove cache here
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - CACHE!<br />");
+ //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - CACHE!<br />");
rebuildCacheFile('refsystem', 'refsystem');
}
// Really simple... ;-)
}
-// Get ID number from administrator's login name
+// Get id number from administrator's login name
function getAdminId ($login) {
// By default no admin is found
$ret = '-1';
// Deletes a user account with given reason
function deleteUserAccount ($userid, $reason) {
$points = 0;
- $result = SQL_QUERY_ESC("SELECT (SUM(p.points) - d.used_points) AS points
-FROM `{?_MYSQL_PREFIX?}_user_points` AS p
-LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS d
-ON p.userid=d.userid
-WHERE p.userid=%s", array(bigintval($userid)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ (SUM(p.points) - d.used_points) AS points
+FROM
+ `{?_MYSQL_PREFIX?}_user_points` AS p
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+ON
+ p.userid=d.userid
+WHERE
+ p.userid=%s",
+ array(bigintval($userid)), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Save his points to add them to the jackpot
list($points) = SQL_FETCHROW($result);
// Default is empty
$what = '';
- //* DEBUG: */ outputHtml(__LINE__.'!'.$modCheck."!<br />");
+ //* DEBUG: */ print(__LINE__.'!'.$modCheck."!<br />");
switch ($modCheck) {
case 'admin':
$what = 'overview';
case 'login':
case 'index':
- $what = getConfig('index_home');
+ // Is ext-sql_patches installed and newer than 0.0.5?
+ if (isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
+ // Use it from config
+ $what = getConfig('index_home');
+ } else {
+ // Use default 'welcome'
+ $what = 'welcome';
+ }
break;
default:
// Generate a receiver list for given category and maximum receivers
function generateReceiverList ($cat, $receiver, $mode = '') {
// Init variables
- $CAT_TABS = "%s";
+ $CAT_TABS = '';
$CAT_WHERE = '';
$receiverList = '';
$result = false;
if ($cat > 0) {
// Select category
$CAT_TABS = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.userid=c.userid";
- $CAT_WHERE = " AND c.cat_id=%s";
+ $CAT_WHERE = sprintf(" AND c.cat_id=%s", $cat);
} // END - if
// Exclude users in holiday?
if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
// Only include HTML receivers
- $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.`html`='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, getConfig('order_select'), getConfig('order_mode'), $receiver), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.`html`='Y'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s",
+ array(
+ $receiver
+ ), __FUNCTION__, __LINE__);
} else {
// Include all
- $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, getConfig('order_select'), getConfig('order_mode'), $receiver), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s",
+ array(
+ $receiver
+ ), __FUNCTION__, __LINE__);
}
// Entries found?
// "Getter" for array for user refs and points in given level
function getUserReferalPoints ($userid, $level) {
- //* DEBUG: */ outputHtml("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
+ //* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
// Default is no refs and no nickname
$add = '';
$refs = array();
SQL_FREERESULT($result);
// Return result
- //* DEBUG: */ outputHtml("</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />");
+ //* DEBUG: */ print("</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />");
return $refs;
}