require($INC);
}
-// Admin has added an URL with given user id
+// -----------------------------------------------------------------------------
+// Admin functions
+// -----------------------------------------------------------------------------
+
+// Admin has added an URL with given user id and so on
function SURFBAR_ADMIN_ADD_URL ($url, $uid, $reward, $costs, $paymentId) {
// Do some pre-checks
if (!IS_ADMIN()) {
// Register the new URL
return SURFBAR_REGISTER_URL($url, $uid, $reward, $costs, $paymentId, "CONFIRMED", "unlock");
}
+// Admin function for unlocking URLs
+function SURFBAR_ADMIN_UNLOCK_URL_IDS ($IDs) {
+ // Is this an admin or invalid array?
+ if (!IS_ADMIN()) {
+ // Not admin or invalid IDs array
+ return false;
+ } elseif (!is_array($IDs)) {
+ // No array
+ return false;
+ } elseif (count($IDs) == 0) {
+ // Empty array
+ return false;
+ }
+
+ // Set to true to make AND expression valid if first URL got unlocked
+ $done = true;
+
+ // Update the status for all ids
+ foreach ($IDs as $id => $dummy) {
+ // Test all ids through (ignores failed)
+ $done = (($done) && (SURFBAR_CHANGE_STATUS($id, "PENDING", "CONFIRMED")));
+ } // END - if
+
+ // Return total status
+ return $done;
+}
+
+// -----------------------------------------------------------------------------
+// Member functions
+// -----------------------------------------------------------------------------
+
// Member has added an URL
function SURFBAR_MEMBER_ADD_URL ($url) {
global $_CONFIG;
// Register the new URL
return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], $reward, $costs);
}
+// -----------------------------------------------------------------------------
+// Generic functions
+// -----------------------------------------------------------------------------
+
// Looks up by an URL
function SURFBAR_LOOKUP_BY_URL ($url) {
// Now lookup that given URL by itself
$searchTerm = bigintval($searchTerm);
} // END - if
+ // If the column is "id" there can be only one entry
+ $limit = "";
+ if ($column == "id") {
+ $limit = "LIMIT 1";
+ } // END - if
+
// Look up the record
$result = SQL_QUERY_ESC("SELECT id, userid, url, reward, costs, views_total, status, registered, last_locked, lock_reason
FROM "._MYSQL_PREFIX."_surfbar_urls
WHERE %s='%s'
-ORDER BY %s %s",
- array($column, $searchTerm, $order, $sort), __FILE__, __LINE__);
+ORDER BY %s %s
+%s",
+ array($column, $searchTerm, $order, $sort, $limit), __FILE__, __LINE__);
// Is there at least one record?
if (SQL_NUMROWS($result) > 0) {
// Return result
return $cnt;
}
-// Determine next id for surfbar view, always call this before you call other
+// Changes the status of an URL from given to other
+function SURFBAR_CHANGE_STATUS ($id, $prevStatus, $newStatus) {
+ // Get URL data for status comparison
+ $data = SURFBAR_GET_URL_DATA($id);
+
+ // Is the status like prevStatus is saying?
+ if ($data[$id]['status'] != $prevStatus) {
+ // No, then abort here
+ return false;
+ } // END - if
+
+ // Update the status now
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET status='%s' WHERE id=%s LIMIT 1",
+ array($newStatus, bigintval($id)), __FILE__, __LINE__);
+
+ // Was that fine?
+ if (SQL_AFFECTEDROWS() != 1) {
+ // No, something went wrong
+ return false;
+ } // END - if
+
+ // Prepare content for notification routines
+ $data[$id]['uid'] = $data[$id]['userid'];
+ $data[$id]['frametester'] = FRAMETESTER($data[$id]['url']);
+ $data[$id]['reward'] = TRANSLATE_COMMA($data[$id]['reward']);
+ $data[$id]['costs'] = TRANSLATE_COMMA($data[$id]['costs']);
+ $data[$id]['status'] = SURFBAR_TRANSLATE_STATUS($newStatus);
+ $data[$id]['registered'] = MAKE_DATETIME($data[$id]['registered'], "2");
+ $newStatus = strtolower($newStatus);
+
+ // Send admin notification
+ SURFBAR_NOTIFY_ADMIN("url_{$newStatus}", $data[$id]);
+
+ // Send user notification
+ SURFBAR_NOTIFY_USER("url_{$newStatus}", $data[$id]);
+
+ // All done!
+ return true;
+}
+// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
-function SURFBAR_GET_NEXT_ID ($id = 0) {
+function SURFBAR_DETERMINE_NEXT_ID ($id = 0) {
global $SURFBAR_CACHE, $_CONFIG;
// Default is no id!
//DEBUG_LOG(__FUNCTION__.":nextId={$nextId}");
return $nextId;
}
-// ----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
// PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE ELSE THEY "WRAP" THE
// $SURFBAR_CACHE ARRAY!
-// ----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
// Private getter for data elements
function SURFBAR_GET_DATA ($element) {
global $SURFBAR_CACHE;