$performed = call_user_func_array($functionName, $urlData);
} else {
// Log invalid request
- DEBUG_LOG(__FUNCTION__.": action={$formData['action']},id={$formData['id']},function={$functionName}");
+ DEBUG_LOG(__FUNCTION__, __LINE__, " action={$formData['action']},id={$formData['id']},function={$functionName}");
+ ADD_FATAL(sprintf("Invalid member action! action=%s,id=%s,function=%s", $formData['action'], $formData['id'], $functionName));
}
// Return status
// Fetch the new status if found
if ($isValid) {
+ // Load new status
list($SURFBAR_CACHE['new_status']) = SQL_FETCHROW($result);
} // END - if
// Member actions
// -----------------------------------------------------------------------------
//
-// Retreat an URL
+// Retreat a booked URL
function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
// Create the data array for next function call
$data = array(
// Simply change the status here
return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
}
+// Show edit form or do the changes
+function SURFBAR_MEMBER_EDIT_ACTION ($urlData) {
+ // Is the "execute" flag there?
+ if (isset($urlData['execute'])) {
+ // Execute the changes
+ return SURFBAR_MEMBER_EXECUTE_ACTION("edit", $urlData);
+ } // END - if
+
+ // Display form
+ return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("edit", $urlData);
+}
+// Show delete form or do the changes
+function SURFBAR_MEMBER_DELETE_ACTION ($urlData) {
+ // Is the "execute" flag there?
+ if (isset($urlData['execute'])) {
+ // Execute the changes
+ return SURFBAR_MEMBER_EXECUTE_ACTION("del", $urlData);
+ } // END - if
+
+ // Display form
+ return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("del", $urlData);
+}
+// Display selected "action form"
+function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
+ // Translate some data
+ $urlData['registered'] = MAKE_DATETIME($urlData['registered'], "2");
+ $urlData['views_total'] = TRANSLATE_COMMA($urlData['views_total']);
+
+ // Load the form and display it
+ LOAD_TEMPLATE(sprintf("member_surfbar_%s_action_form", $action), false, $urlData);
+
+ // All fine by default ... ;-)
+ return true;
+}
//
// -----------------------------------------------------------------------------
// Self-maintenance functions
if (empty($uid)) $uid = 0;
// Just run the insert query for now
- SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid,url,status,views_max,views_allowed) VALUES(%s,'%s','%s','%s','%s')",
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid,url,status,views_max,views_allowed) VALUES (%s,'%s','%s','%s','%s')",
array(
$uid,
$urlData['url'],
$subject = ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
// Prepare subject
- $eval = sprintf("\$subject = ADMIN_SURFBAR_NOTIFY_%s_SUBJECT;",
+ $subject = constant(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
strtoupper($messageType)
- );
- @eval($eval);
+ ));
// Send the notification out
return SEND_ADMIN_NOTIFICATION($subject, $templateName, $content, $content['uid']);
$subject = MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
// Prepare subject
- $eval = sprintf("\$subject = MEMBER_SURFBAR_NOTIFY_%s_SUBJECT;",
+ $subject = constant(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
strtoupper($messageType)
- );
- @eval($eval);
+ ));
// Load template
$mailText = LOAD_EMAIL_TEMPLATE($templateName, $content, $content['uid']);
// Set default translated status
$statusTranslated = "!".$constantName."!";
- // Generate eval() command
+ // Is the constant there?
if (defined($constantName)) {
- $eval = "\$statusTranslated = ".$constantName.";";
- eval($eval);
+ // Then get it's value
+ $statusTranslated = constant($constantName);
} // END - if
// Return result
// Cache static reload lock
$SURFBAR_CACHE['surf_lock'] = $_CONFIG['surfbar_static_lock'];
- //DEBUG_LOG(__FUNCTION__.":Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."", false);
// Do we have dynamic model?
if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
$total = SURFBAR_GET_TOTAL_URLS();
// Do we have some URLs in lock? Admins can always surf on own URLs!
- //DEBUG_LOG(__FUNCTION__.":userLocks=".SURFBAR_GET_DATA('user_locks').",total={$total}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "userLocks=".SURFBAR_GET_DATA('user_locks').",total={$total}", false);
$isFull = ((SURFBAR_GET_DATA('user_locks') == $total) && ($total > 0));
// Return result
if (empty($salt)) {
// Generate random hashed string
$SURFBAR_CACHE['salt'] = sha1(GEN_PASS(255));
- //DEBUG_LOG(__FUNCTION__.":newSalt=".SURFBAR_GET_SALT()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "newSalt=".SURFBAR_GET_SALT()."", false);
} else {
// Use this as salt!
$SURFBAR_CACHE['salt'] = $salt;
- //DEBUG_LOG(__FUNCTION__.":oldSalt=".SURFBAR_GET_SALT()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "oldSalt=".SURFBAR_GET_SALT()."", false);
}
// ... and now the validation code
$valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
- //DEBUG_LOG(__FUNCTION__.":valCode={$valCode}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
} // END - while
// Hash it with md5() and salt it with the random string
// Finally encrypt it PGP-like and return it
$valHashedCode = generatePassString($hashedCode);
- //DEBUG_LOG(__FUNCTION__.":finalValCode={$valHashedCode}");
+
+ // Return hashed value
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "finalValCode={$valHashedCode}", false);
return $valHashedCode;
}
// Check validation code
$code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
// Return result of checking hashes and salts
- //DEBUG_LOG(__FUNCTION__.":---".$code."|".$check."---");
- //DEBUG_LOG(__FUNCTION__.":+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "---".$code."|".$check."---", false);
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++", false);
return (($code == $check) && ($salt == SURFBAR_GET_DATA('last_salt')));
}
// Lockdown the userid/id combination (reload lock)
function SURFBAR_LOCKDOWN_ID ($urlId) {
- //* //DEBUG: */ print "LOCK!");
- ///* //DEBUG: */ return;
+ //* DEBUG: */ print "LOCK!");
+ ///* DEBUG: */ return;
// Just add it to the database
- SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_locks (userid, url_id) VALUES(%s, %s)",
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_locks (userid, url_id) VALUES (%s, %s)",
array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__);
// Remove the salt from database
// Pay points to the user and remove it from the sender
function SURFBAR_PAY_POINTS ($urlId) {
// Remove it from the URL owner
- //DEBUG_LOG(__FUNCTION__.":uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."", false);
if (SURFBAR_GET_USERID() > 0) {
- SUB_POINTS(SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
+ SUB_POINTS("surfbar", SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
} // END - if
// Book it to the user
- //DEBUG_LOG(__FUNCTION__.":uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."");
- ADD_POINTS_REFSYSTEM($GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
+ ADD_POINTS_REFSYSTEM("surfbar", $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
}
// Updates the statistics of current URL/userid
function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
// Was that update okay?
if (SQL_AFFECTEDROWS() < 1) {
// No, then insert entry
- SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_stats (userid,url_id,count) VALUES(%s,%s,1)",
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_stats (userid,url_id,count) VALUES (%s,%s,1)",
array($GLOBALS['userid'], SURFBAR_GET_ID()), __FILE__, __LINE__);
} // END - if
array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), $GLOBALS['userid']), __FILE__, __LINE__);
// Debug message
- //DEBUG_LOG(__FUNCTION__.":salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."", false);
// Was that okay?
if (SQL_AFFECTEDROWS() < 1) {
// Insert missing entry!
- SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_salts (url_id,userid,last_salt) VALUES(%s, %s, '%s')",
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_salts (url_id,userid,last_salt) VALUES (%s, %s, '%s')",
array(SURFBAR_GET_ID(), $GLOBALS['userid'], SURFBAR_GET_SALT()), __FILE__, __LINE__);
} // END - if
// Debug message
- //DEBUG_LOG(__FUNCTION__.":affectedRows=".SQL_AFFECTEDROWS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "affectedRows=".SQL_AFFECTEDROWS()."", false);
// Return if the update was okay
return (SQL_AFFECTEDROWS() == 1);
}
// Check if the reload lock is active for given id
function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
- //DEBUG_LOG(__FUNCTION__.":id={$urlId}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "id={$urlId}", false);
// Ask the database
$result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
FROM "._MYSQL_PREFIX."_surfbar_locks
SQL_FREERESULT($result);
// Return check
- //DEBUG_LOG(__FUNCTION__.":cnt={$cnt},".SURFBAR_GET_DATA('surf_lock')."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "cnt={$cnt},".SURFBAR_GET_DATA('surf_lock')."", false);
return ($cnt == 1);
}
// Determine which user hash no more points left
function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Init array
- $UIDs = array();
+ $UIDs = array(
+ 'uid' => array(),
+ 'points' => array(),
+ 'notified' => array(),
+ );
// Do we have a current user id?
if ((IS_MEMBER()) && ($limit == 0)) {
while (list($uid, $notified) = SQL_FETCHROW($result)) {
// Get total points
$points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
- //DEBUG_LOG(__FUNCTION__.":uid={$uid},points={$points}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},points={$points}", false);
// Shall we add this to ignore?
if ($points <= $limit) {
// Ignore this one!
- //DEBUG_LOG(__FUNCTION__.":uid={$uid} has depleted points amount!");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid} has depleted points amount!", false);
$UIDs['uid'][$uid] = $uid;
$UIDs['points'][$uid] = $points;
$UIDs['notified'][$uid] = $notified;
SQL_FREERESULT($result);
// Debug message
- //DEBUG_LOG(__FUNCTION__.":UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")", false);
// Return result
return $UIDs;
global $_CONFIG;
// Get URL data for status comparison if missing
- if (count($data) == 0) {
+ if ((!is_array($data)) || (count($data) == 0)) {
+ // Fetch missing URL data
$data = SURFBAR_GET_URL_DATA($urlId);
} // END - if
// Update the status now
- // ---------------------- Commented out for debugging member actions! -----------------------
+ // ---------- Comment out for debugging/developing member actions! ---------
//SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET status='%s' WHERE id=%s LIMIT 1",
// array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
- // ---------------------- Commented out for debugging member actions! -----------------------
+ // ---------- Comment out for debugging/developing member actions! ---------
// Was that fine?
if (SQL_AFFECTEDROWS() != 1) {
// Load all entries
while (list($lid, $url, $last) = SQL_FETCHROW($result)) {
// Debug message
- //DEBUG_LOG(__FUNCTION__.":next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_DATA('surf_lock')."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_DATA('surf_lock')."", false);
// Skip entries that are too old
if (($last > (time() - SURFBAR_GET_DATA('surf_lock'))) && (!in_array($url, $ignored))) {
// Debug message
- //DEBUG_LOG(__FUNCTION__.":okay - lid={$lid},url={$url},last={$last}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$lid},url={$url},last={$last}", false);
// Add only if missing or bigger
if ((!isset($IDs[$url])) || ($IDs[$url] > $last)) {
// Debug message
- //DEBUG_LOG(__FUNCTION__.":ADD - lid={$lid},url={$url},last={$last}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$lid},url={$url},last={$last}", false);
// Add this ID
$IDs[$url] = $last;
} // END - if
} else {
// Debug message
- //DEBUG_LOG(__FUNCTION__.":ignore - lid={$lid},url={$url},last={$last}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$lid},url={$url},last={$last}", false);
// Ignore these old entries!
$ignored[] = $url;
GROUP BY sbu.id", __FILE__, __LINE__);
// Log last query
- //DEBUG_LOG(__FUNCTION__.":lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
// Fetch max rand
$maxRand = SQL_NUMROWS($result);
} // END - if
// And query the database
- //DEBUG_LOG(__FUNCTION__.":randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."", false);
$result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
}
// Is there an id number?
- //DEBUG_LOG(__FUNCTION__.":lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
if (SQL_NUMROWS($result) == 1) {
// Load/cache data
- //DEBUG_LOG(__FUNCTION__.":count(".count($SURFBAR_CACHE).") - BEFORE");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - BEFORE", false);
$SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result));
- //DEBUG_LOG(__FUNCTION__.":count(".count($SURFBAR_CACHE).") - AFTER");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - AFTER", false);
// Determine waiting time
$SURFBAR_CACHE['time'] = SURFBAR_DETERMINE_WAIT_TIME();
// Is the last salt there?
if (is_null($SURFBAR_CACHE['last_salt'])) {
// Then repair it wit the static!
- //DEBUG_LOG(__FUNCTION__.":last_salt - FIXED!");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "last_salt - FIXED!", false);
$SURFBAR_CACHE['last_salt'] = "";
} // END - if
// Fix missing last_surfed
if ((!isset($SURFBAR_CACHE['last_surfed'])) || (is_null($SURFBAR_CACHE['last_surfed']))) {
// Fix it here
- //DEBUG_LOG(__FUNCTION__.":last_surfed - FIXED!");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "last_surfed - FIXED!", false);
$SURFBAR_CACHE['last_surfed'] = 0;
} // END - if
// Get base/fixed reward and costs
$SURFBAR_CACHE['reward'] = SURFBAR_DETERMINE_REWARD();
$SURFBAR_CACHE['costs'] = SURFBAR_DETERMINE_COSTS();
- //DEBUG_LOG(__FUNCTION__.":BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
// Only in dynamic model add the dynamic bonus!
if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
// Calculate dynamic reward/costs and add it
$SURFBAR_CACHE['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
$SURFBAR_CACHE['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
- //DEBUG_LOG(__FUNCTION__.":DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
} // END - if
// Now get the id
SQL_FREERESULT($result);
// Return result
- //DEBUG_LOG(__FUNCTION__.":nextId={$nextId}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "nextId={$nextId}", false);
return $nextId;
}
// -----------------------------------------------------------------------------
// Private getter for data elements
function SURFBAR_GET_DATA ($element) {
global $SURFBAR_CACHE;
- //DEBUG_LOG(__FUNCTION__.":element={$element}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "element={$element}", false);
// Default is null
$data = null;
}
// Return result
- //DEBUG_LOG(__FUNCTION__.":element[$element]={$data}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
return $data;
}
// Getter for reward from cache