$AND = "";
}
if ((!isset($DEPTH)) && (!$return)) {
- $DEPTH = "0";
+ $DEPTH = 0;
$prefix = "<DIV class=\"you_are_here\">".YOU_ARE_HERE." <STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
} else {
if (!$return) $DEPTH++;
$hash = generatePassString($hashDB);
if (($hash == get_session('u_hash')) || ($_POST['pass1'] == $_POST['pass2'])) {
// Load user's data
- $result = SQL_QUERY_ESC("SELECT sex, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND password='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND password='%s' LIMIT 1",
array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load the data
// Free result
SQL_FREERESULT($result);
- // Translate salutation
- $DATA[0] = TRANSLATE_SEX($DATA[0]);
+ // Translate gender
+ $DATA[0] = TRANSLATE_GENDER($DATA[0]);
// Clear/init the content variable
$content = "";
// Default is not found
$ret = _CATEGORY_404;
- // Lookup the category
- $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) {
- // Category found... :-)
- list($ret) = SQL_FETCHROW($result);
- } // END - if
+ // Is the category id set?
+ if (!empty($cid)) {
- // Free result
- SQL_FREERESULT($result);
+ // Lookup the category
+ $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) {
+ // Category found... :-)
+ list($ret) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - if
// Return result
return $ret;
//
function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false)
{
- $ret = "0";
+ $ret = 0;
if ($onlyRows) {
// Count rows
$result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
SQL_FREERESULT($result);
if (empty($ret)) {
if (($lookFor == "counter") || ($lookFor == "id")) {
- $ret = "0";
+ $ret = 0;
} else {
$ret = "0.00000";
}
// Count up referral depth
if (empty($DEPTH)) {
// Initialialize referral system
- $DEPTH = "0";
+ $DEPTH = 0;
} else {
// Increase referral level
$DEPTH++;
// Points updated, maybe I shall send him an email?
if (($send_notify) && ($ref > 0) && (!$locked)) {
- // 0 1 2 3
- $DATA = array($per, bigintval($DEPTH), $ref_points, bigintval($ref));
- $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", "", bigintval($uid));
+ // Prepare content
+ $content = array(
+ 'percent' => $per,
+ 'level' => bigintval($DEPTH),
+ 'points' => $ref_points,
+ 'refid' => bigintval($ref)
+ );
+
+ // Load email template
+ $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", $content, bigintval($uid));
SEND_EMAIL($email, THANX_REFERRAL_ONE, $msg);
} elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == "direct") && (!defined('__POINTS_VALUE'))) {
function UPDATE_REF_COUNTER($uid)
{
global $REF_LVL, $cacheInstance;
+
// Make it sure referral level zero (member him-/herself) is at least selected
- if (empty($REF_LVL)) $REF_LVL = "0";
+ if (empty($REF_LVL)) $REF_LVL = 0;
// Update counter
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refsystem SET counter=counter+1 WHERE userid=%s AND level='%s' LIMIT 1",
if ($cacheInstance->cache_file("refsystem", true)) $cacheInstance->cache_destroy();
}
}
-//
-function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht)
-{
+// Updates/extends the online list
+function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht) {
global $_CONFIG;
// Do not update online list when extension is deactivated
if (!EXT_IS_ACTIVE("online", true)) return;
+ // Empty session?
+ if (empty($SID)) {
+ // This is invalid here!
+ print "Invalid session. Backtrace:<pre>";
+ debug_print_backtrace();
+ die("</pre>");
+ } // END - if
+
// Initialize variables
- $uid = "0"; $rid = "0"; $MEM = "N"; $ADMIN = "N";
- if (!empty($GLOBALS['userid']))
- {
- // Update member status only when userid is valid
- if (($GLOBALS['userid'] > 0) && (IS_MEMBER()))
- {
- // Is valid user
- $uid = $GLOBALS['userid'];
- $MEM = "Y";
- }
- }
- if (IS_ADMIN())
- {
+ $uid = 0; $rid = 0; $MEM = "N"; $ADMIN = "N";
+
+ // Valid userid?
+ if ((!empty($GLOBALS['userid'])) && ($GLOBALS['userid'] > 0) && (IS_MEMBER())) {
+ // Is valid user
+ $uid = bigintval($GLOBALS['userid']);
+ $MEM = "Y";
+ } // END - if
+
+ if (IS_ADMIN()) {
// Is administrator
$ADMIN = "Y";
- }
+ } // END - if
+
if (isSessionVariableSet('refid')) {
// Check cookie
- if (get_session('refid') > 0) $rid = $GLOBALS['refid'];
- }
+ if (get_session('refid') > 0) $rid = bigintval($GLOBALS['refid']);
+ } // END - if
- // Now Read data
+ // Now search for the user
$result = SQL_QUERY_ESC("SELECT timestamp FROM "._MYSQL_PREFIX."_online
WHERE sid='%s' LIMIT 1",
array($SID), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
- SQL_FREERESULT($result);
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Then update it
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET
module='%s',
action='%s',
what='%s',
is_admin='%s',
timestamp=UNIX_TIMESTAMP()
WHERE sid='%s' LIMIT 1",
- array(
- $mod,
- $act,
- $wht,
- bigintval($uid),
- bigintval($rid),
- $MEM,
- $ADMIN,
- $SID
-), __FILE__, __LINE__);
- }
- else
- {
+ array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID), __FILE__, __LINE__
+ );
+ } else {
// No entry does exists so we simply add it!
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s', '%s', '%s', %s, %s, '%s', '%s', UNIX_TIMESTAMP(), '%s', '%s')",
- array($mod, $act, $wht, bigintval($uid), bigintval($rid), $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s', '%s', '%s', %s, %s, '%s', '%s', UNIX_TIMESTAMP(), '%s', '%s')",
+ array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__
+ );
}
+ // Free result
+ SQL_FREERESULT($result);
+
// Purge old entries
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= (UNIX_TIMESTAMP() - %s)",
array($_CONFIG['online_timeout']), __FILE__, __LINE__);
// Selection from array
if (is_array($id) && is_array($name) && sizeof($id) == sizeof($name)) {
// Both are arrays
- foreach ($id as $idx=>$value) {
+ foreach ($id as $idx => $value) {
$ret .= "<OPTION value=\"".$value."\"";
if ($default == $value) $ret .= " selected checked";
$ret .= ">".$name[$idx]."</OPTION>\n";
if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
// Update database
MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
- }
+ } // END - if
// Now, when we have all his points adds them do the jackpot!
ADD_JACKPOT($points);
if ((is_array($cacheArray)) && (isset($cacheArray['config'][$no])) && (is_array($cacheArray['config'][$no]))) {
// Load config from cache
//* DEBUG: */ echo gettype($cacheArray['config'][$no])."<br />\n";
- foreach ($cacheArray['config'][$no] as $key=>$value) {
+ foreach ($cacheArray['config'][$no] as $key => $value) {
$CFG_DUMMY[$key] = $value;
} // END - foreach
// Subtract points from database and mediadata cache
function SUB_POINTS ($uid, $points) {
// Add points to used points
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1",
array($points, bigintval($uid)), __FILE__, __LINE__);
// Update mediadata as well