} // END - if
// Check if that URL does not exist
- if (SURFBAR_LOOKUP_URL($url, $uid)) {
+ if (SURFBAR_LOOKUP_BY_URL($url, $uid)) {
// Already found!
return false;
} // END - if
// Register the new URL
- return SURFBAR_REGISTER_URL($url, $uid, $reward, "CONFIRMED");
+ return SURFBAR_REGISTER_URL($url, $uid, $reward, "CONFIRMED", "unlock");
+}
+// Looks up by an URL
+function SURFBAR_LOOKUP_BY_URL ($url) {
+ // Now lookup that given URL by itself
+ $urlArray = SURFBAR_GET_URL_DATA($url, "url");
+
+ // Was it found?
+ return (count($urlArray) > 0);
+}
+// Load URL data by given search term and column
+function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id") {
+ global $lastUrlData;
+
+ // By default nothing is found
+ $lastUrlData = array();
+
+ // Is the column an id number?
+ if (($column == "id") || ($column == "userid")) {
+ // Extra secure input
+ $searchTerm = bigintval($searchTerm);
+ } // END - if
+
+ // Look up the record
+ $result = SQL_QUERY_ESC("SELECT id, userid, url, reward, 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__);
+
+ // Is there at least one record?
+ if (SQL_NUMROWS($result) > 0) {
+ // Then load all!
+ while ($dataRow = SQL_FETCHARRAY($result)) {
+ // Shall we group these results?
+ if ($group == "id") {
+ // Add the row by id as index
+ $lastUrlData[$dataRow['id']] = $dataRow;
+ } else {
+ // Group entries
+ $lastUrlData[$dataRow[$group]][$dataRow['id']] = $dataRow;
+ }
+ } // END - while
+ } // END - if
+
+ // Free the result
+ SQL_FREERESULT($result);
+
+ // Return the result
+ return $lastUrlData;
+}
+// Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
+function SURFBAR_REGISTER_URL ($url, $uid, $reward, $status="PENDING", $addMode="reg") {
+ global $_CONFIG;
+
+ // Make sure by the user registered URLs are always pending
+ if ($addMode == "reg") $status = "PENDING";
+
+ // Prepare content
+ $content = array(
+ 'url' => $url,
+ 'frametester' => FRAMETESTER($url),
+ 'uid' => $uid,
+ 'reward' => $reward,
+ 'status' => $status
+ );
+
+ // Insert the URL into database
+ $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
+
+ // If in reg-mode we notify admin
+ if ($addMode == "reg") {
+ // Notify admin of newly added URL in surfbar
+ SURFBAR_NOTIFY_ADMIN("url_reg", $content);
+ } elseif ($_CONFIG['surfbar_notify_admin_unlock'] == "Y") {
+ // Notify admin even when he as unlocked an email
+ SURFBAR_NOTIFY_ADMIN("url_unlock", $content);
+ }
+
+ // Send mail to user
+ SURFBAR_NOTIFY_USER("url_{$addMode}", $content);
+
+ // Return the insert id
+ return $content['insert_id'];
+}
+// Inserts an url by given data array and return the insert id
+function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
+ // Just run the insert query for now
+ /*
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid, url, reward, status) VALUES(%s, '%s', %s, '%s')",
+ array(
+ bigintval($urlData['userid']),
+ bigintval($urlData['url']),
+ (float)$urlData['reward'],
+ $urlData['status']
+ ), __FILE__, __LINE__
+ );
+ */
+
+ // Return insert id
+ return SQL_INSERTID();
+}
+// Notify admin(s) with a selected message and content
+function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
+ // Prepare template name
+ $template = sprintf("admin_surfbar_%s", $messageType);
}
//
?>