define('ADMIN_SURFBAR_EDIT_URLS_TITLE', "Surfbar - URLs editieren");
define('ADMIN_SURFBAR_LOCK_URLS_TITLE', "Surfbar - URLs sperren/entsperren");
+// Member titles
+define('MEMBER_SURFBAR_LIST_TITLE', "Ihre URLs in der Surfbar verwalten");
+
// General member text
define('MEMBER_SURFBAR_URL_ADDED', "URL hinzugefügt und wartet auf Freischaltung.");
define('MEMBER_SURFBAR_URL_NOT_ADDED', "URL konnte nicht hinzugefügt werden, da ein Fehler vorliegt.");
define('MEMBER_SURFBAR_ADD_URL', "URL in Surfbar buchen");
define('MEMBER_SURFBAR_NO_MORE_ALLOWED', "Sie können leider nicht mehr URLs in der Surfbar buchen, da Sie das Maximum erreicht haben.");
define('MEMBER_SURFBAR_NO_URLS_FOUND', "Sie haben noch keine URLs für die Surfbar gebucht.");
+define('MEMBER_SURFBAR_VIEWS_TOTAL', "Views");
+define('MEMBER_SURFBAR_STATUS', "Anmeldestatus");
+define('MEMBER_SURFBAR_REGISTERED', "Angemeldet");
+define('MEMBER_SURFBAR_LAST_LOCKED', "Letzte Sperre");
+define('MEMBER_SURFBAR_LOCK_REASON', "Sperrgrund");
+define('MEMBER_SURFBAR_ACTIONS', "Aktionen");
+define('MEMBER_SURFBAR_TEST_URL', "URL anzeigen");
+define('MEMBER_SURFBAR_LIST_NOTE', "Bitte beachten Sie, dass Editieren und erneutes Aktivieren von gestoppten URLs eine Freischaltung durch unsere Administratoren nötig ist.");
+define('MEMBER_SURFBAR_ACTION_DONE', "Ausgew&aumml;hlte Aktion ausgeführt.");
+define('MEMBER_SURFBAR_ACTION_FAILED', "Ausgewählte Aktion konnte nicht vollständig ausgeführt werden!");
// Subject lines for admins
define('ADMIN_SURFBAR_NOTIFY_URL_UNLOCK_SUBJECT', "URL in Surfbar gebucht");
define('MEMBER_SURFBAR_ACTION_RETREAT_SUBMIT', "Zurücknehmen");
define('MEMBER_SURFBAR_ACTION_FRAMETEST_SUBMIT', "Framkiller-Test");
+// Member actions - button titles
+define('MEMBER_SURFBAR_ACTION_RETREAT_TITLE', "Nehmen Sie hiermit Ihre Buchung wieder zurück, falls Sie diese doch nicht bewerben wollten.");
+define('MEMBER_SURFBAR_ACTION_FRAMETEST_TITLE', "Testen Sie die Seite auf Framekiller hin, diese sind in unserer Surfbar grundsätzlich nicht gestattet.");
+
//
?>
// -----------------------------------------------------------------------------
// Admin functions
// -----------------------------------------------------------------------------
-
+//
// Admin has added an URL with given user id and so on
function SURFBAR_ADMIN_ADD_URL ($url) {
// Do some pre-checks
// 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);
}
+// Create list of actions depending on status for the user
+function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
+ // Load all actions in an array for given status
+ $actionArray = SURFBAR_GET_ACTION_ARRAY($status);
+
+ // Init HTML code
+ $OUT = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">
+<tr>\n";
+
+ // Calculate width
+ $width = round(100 / count($actionArray));
+
+ // "Walk" through all actions and create forms
+ foreach ($actionArray as $actionId=>$action) {
+ // Add form for this action
+ $OUT .= sprintf(" <td align=\"center\" width=\"%d%%\">
+ <form action=\"".URL."/modules.php?module=login&what=surfbar_list\" method=\"post\" style=\"padding-bottom:0px\">
+ <input type=\"hidden\" name=\"id\" value=\"%s\" />
+ <input type=\"hidden\" name=\"action\" value=\"%s\" />
+ <input type=\"submit\" class=\"member_submit\" name=\"ok\" title=\"{--MEMBER_SURFBAR_ACTION_%s_TITLE--}\" value=\"{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}\" />
+ </form>
+ </td>\n",
+ $width,
+ bigintval($urlId),
+ strtolower($action),
+ strtoupper($action),
+ strtoupper($action)
+ );
+ } // END - foreach
+
+ // Close table
+ $OUT .= "</tr>
+</table>\n";
+
+ // Return code
+ return $OUT;
+}
+// Do the member form request
+function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
+ // Is this a member?
+ if (!IS_MEMBER()) {
+ // No member!
+ return false;
+ } // END - if
+
+ /* DEBUG: */ die("<pre>".print_r($formData, true)."</pre><pre>".print_r($URLs, true)."</pre>");
+}
+//
// -----------------------------------------------------------------------------
// Generic functions
// -----------------------------------------------------------------------------
-
+//
// Looks up by an URL
function SURFBAR_LOOKUP_BY_URL ($url) {
// Now lookup that given URL by itself
return $cnt;
}
// Generate a validation code for the given id number
-function SURFBAR_GENERATE_VALIDATION_CODE ($id, $salt="") {
+function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") {
global $_CONFIG, $SURFBAR_CACHE;
// @TODO Invalid salt should be refused
}
// ... and now the validation code
- $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$id), $GLOBALS['userid']);
+ $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
//DEBUG_LOG(__FUNCTION__.":valCode={$valCode}");
} // END - while
return $valHashedCode;
}
// Check validation code
-function SURFBAR_CHECK_VALIDATION_CODE ($id, $check, $salt) {
+function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
global $SURFBAR_CACHE;
// Secure id number
- $id = bigintval($id);
+ $urlId = bigintval($urlId);
// Now generate the code again
- $code = SURFBAR_GENERATE_VALIDATION_CODE($id, $salt);
+ $code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
// Return result of checking hashes and salts
//DEBUG_LOG(__FUNCTION__.":---".$code."|".$check."---");
return (($code == $check) && ($salt == SURFBAR_GET_DATA('last_salt')));
}
// Lockdown the userid/id combination (reload lock)
-function SURFBAR_LOCKDOWN_ID ($id) {
+function SURFBAR_LOCKDOWN_ID ($urlId) {
//* //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)",
- array($GLOBALS['userid'], bigintval($id)), __FILE__, __LINE__);
+ array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__);
// Remove the salt from database
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_surfbar_salts WHERE url_id=%s AND userid=%s LIMIT 1",
- array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval($urlId), $GLOBALS['userid']), __FILE__, __LINE__);
}
// Pay points to the user and remove it from the sender
-function SURFBAR_PAY_POINTS ($id) {
+function SURFBAR_PAY_POINTS ($urlId) {
// Remove it from the URL owner
//DEBUG_LOG(__FUNCTION__.":uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."");
if (SURFBAR_GET_USERID() > 0) {
return (SQL_AFFECTEDROWS() == 1);
}
// Check if the reload lock is active for given id
-function SURFBAR_CHECK_RELOAD_LOCK ($id) {
- //DEBUG_LOG(__FUNCTION__.":id={$id}");
+function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
+ //DEBUG_LOG(__FUNCTION__.":id={$urlId}");
// Ask the database
$result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
FROM "._MYSQL_PREFIX."_surfbar_locks
WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") < UNIX_TIMESTAMP(last_surfed)
ORDER BY last_surfed ASC
LIMIT 1",
- array($GLOBALS['userid'], bigintval($id)), __FILE__, __LINE__
+ array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
);
// Fetch counter
return $time;
}
// Changes the status of an URL from given to other
-function SURFBAR_CHANGE_STATUS ($id, $prevStatus, $newStatus) {
+function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus) {
// Get URL data for status comparison
- $data = SURFBAR_GET_URL_DATA($id);
+ $data = SURFBAR_GET_URL_DATA($urlId);
// Is the status like prevStatus is saying?
- if ($data[$id]['status'] != $prevStatus) {
+ if ($data[$urlId]['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__);
+ array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
// Was that fine?
if (SQL_AFFECTEDROWS() != 1) {
} // 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");
+ $data[$urlId]['uid'] = $data[$urlId]['userid'];
+ $data[$urlId]['frametester'] = FRAMETESTER($data[$urlId]['url']);
+ $data[$urlId]['reward'] = TRANSLATE_COMMA($data[$urlId]['reward']);
+ $data[$urlId]['costs'] = TRANSLATE_COMMA($data[$urlId]['costs']);
+ $data[$urlId]['status'] = SURFBAR_TRANSLATE_STATUS($newStatus);
+ $data[$urlId]['registered'] = MAKE_DATETIME($data[$urlId]['registered'], "2");
$newStatus = strtolower($newStatus);
// Send admin notification
- SURFBAR_NOTIFY_ADMIN("url_{$newStatus}", $data[$id]);
+ SURFBAR_NOTIFY_ADMIN("url_{$newStatus}", $data[$urlId]);
// Send user notification
- SURFBAR_NOTIFY_USER("url_{$newStatus}", $data[$id]);
+ SURFBAR_NOTIFY_USER("url_{$newStatus}", $data[$urlId]);
// All done!
return true;
// Return result
return $returnArray;
}
-// Create list of actions depending on status for the user
-function SURFBAR_MEMBER_ACTIONS ($id, $status) {
- // Load all actions in an array for given status
- $actionArray = SURFBAR_GET_ACTION_ARRAY($status);
-
- // Init HTML code
- $OUT = "";
-
- // "Walk" through all actions and create forms
- foreach ($actionArray as $action) {
- // Add form for this action
- $OUT .= sprintf("<form action=\"".URL."/modules.php?module=login&what=surfbar_list\" method=\"post\" style=\"padding-bottom:0px\">
-<input type=\"submit\" name=\"%s\" value=\"{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}\" />
-</form>",
- $action,
- strtoupper($action)
- );
- } // END - if
-
- // Return code
- return $OUT;
-}
// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
-function SURFBAR_DETERMINE_NEXT_ID ($id = 0) {
+function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
global $SURFBAR_CACHE, $_CONFIG;
// Default is no id and no random number
$randNum = 0;
// Is the ID set?
- if ($id == 0) {
+ if ($urlId == 0) {
// Get array with lock ids
$USE = SURFBAR_GET_LOCK_IDS();
ON sbu.id=l.url_id
WHERE sbu.userid != %s AND sbu.status='CONFIRMED' AND sbu.id=%s
LIMIT 1",
- array($GLOBALS['userid'], bigintval($id)), __FILE__, __LINE__
+ array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
);
}