+// Book an URL now (from migration)
+function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
+ // Create the data array for next function call
+ $data = array(
+ $urlData['id'] => $urlData
+ );
+
+ // Simply change the status here
+ return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
+}
+//
+// -----------------------------------------------------------------------------
+// Self-maintenance functions
+// -----------------------------------------------------------------------------
+//
+// Main function
+function SURFBAR_HANDLE_SELF_MAINTENANCE () {
+ // Handle URLs which limit has depleted so we can stop them
+ SURFBAR_HANDLE_DEPLETED_VIEWS();
+
+ // Handle low-points amounts
+ SURFBAR_HANDLE_LOW_POINTS();
+}
+// Handle URLs which limit has depleted
+function SURFBAR_HANDLE_DEPLETED_VIEWS () {
+ // Get all URLs
+ $urlArray = SURFBAR_GET_URL_DATA("0", "views_max", "id", "ASC", "id", " AND views_allowed>0 AND status='ACTIVE'");
+
+ // Do we have some entries?
+ if (count($urlArray) > 0) {
+ // Then handle all!
+ foreach ($urlArray as $id => $urlData) {
+ // Backup data
+ $data = $urlData;
+
+ // Rewrite array for next call
+ $urlData[$id] = $data;
+
+ // Handle the status
+ SURFBAR_CHANGE_STATUS($id, "ACTIVE", "DEPLETED", $urlData);
+ } // END - foreach
+ } // END - if
+}
+// Alert users which have URLs booked and are low on points amount
+function SURFBAR_HANDLE_LOW_POINTS () {
+ global $_CONFIG;
+
+ // Get all userids
+ $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS($_CONFIG['surfbar_warn_low_points']);
+
+ // "Walk" through all URLs
+ foreach ($UIDs['uid'] as $uid => $dummy) {
+ // Is the last notification far enougth away to notify again?
+ if ((time() - $UIDs['notified'][$uid]) >= $_CONFIG['surfbar_low_interval']) {
+ // Prepare content
+ $content = array(
+ 'uid' => $uid,
+ 'low' => TRANSLATE_COMMA($_CONFIG['surfbar_warn_low_points']),
+ 'points' => TRANSLATE_COMMA($UIDs['points'][$uid]),
+ 'notified' => MAKE_DATETIME($UIDs['notified'][$uid]),
+ 'interval' => CREATE_FANCY_TIME($_CONFIG['surfbar_low_interval'])
+ );
+
+ // Notify this user
+ SURFBAR_NOTIFY_USER("low_points", $content);
+
+ // Update last notified
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
+ array($uid), __FILE__, __LINE__);
+ } // END - if
+ } // END - foreach
+}