templates/de/emails/admin/admin_support-reflink.tpl -text
templates/de/emails/admin/admin_support-unconfirmed.tpl -text
templates/de/emails/admin/admin_surfbar_url_confirmed.tpl -text
+templates/de/emails/admin/admin_surfbar_url_depleted.tpl -text
templates/de/emails/admin/admin_surfbar_url_migrate.tpl -text
templates/de/emails/admin/admin_surfbar_url_pending.tpl -text
templates/de/emails/admin/admin_surfbar_url_reg.tpl -text
templates/de/emails/member/member_support-ordr.tpl -text
templates/de/emails/member/member_support-reflink.tpl -text
templates/de/emails/member/member_support-unconfirmed.tpl -text
+templates/de/emails/member/member_surfbar_low_points.tpl -text
templates/de/emails/member/member_surfbar_url_confirmed.tpl -text
+templates/de/emails/member/member_surfbar_url_depleted.tpl -text
templates/de/emails/member/member_surfbar_url_migrate.tpl -text
templates/de/emails/member/member_surfbar_url_pending.tpl -text
templates/de/emails/member/member_surfbar_url_reg.tpl -text
define('SERVER_URL', "http://www.mxchange.org");
// This current patch level
-define('CURR_SVN_REVISION', "392");
+define('CURR_SVN_REVISION', "393");
// Take a prime number which is long (if you know a longer one please try it out!)
define('_PRIME', 591623);
`views_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`views_max` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`views_allowed` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
-`status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED') NOT NULL DEFAULT 'PENDING',
+`status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NOT NULL DEFAULT 'PENDING',
`registered` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_locked` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`lock_reason` VARCHAR(255) NOT NULL DEFAULT '',
`reject_reason` VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`),
UNIQUE KEY `userid_url` (`userid`,`url`),
+INDEX `status_userid` (`status`,`userid`),
INDEX (`payment_id`)
) TYPE=MyISAM COMMENT='Surfbar URLs'";
$SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_actions`";
$SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_surfbar_actions` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-`status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED') NOT NULL DEFAULT 'PENDING',
+`status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NOT NULL DEFAULT 'PENDING',
`action` ENUM('EDIT','DELETE','PAUSE','UNPAUSE','FRAMETEST','RETREAT','RESUBMIT','BOOKNOW') NULL DEFAULT NULL,
-`new_status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED') NULL DEFAULT NULL,
+`new_status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX (`status`)
) TYPE=MyISAM COMMENT='Surfbar Member Actions'";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('STOPPED','EDIT','PENDING')";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('STOPPED','DELETE','DELETED')";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('STOPPED','UNPAUSE','PENDING')";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('DEPLETED','EDIT','PENDING')";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('DEPLETED','DELETE','DELETED')";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('REJECTED','EDIT','PENDING')";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('REJECTED','DELETE','DELETED')";
$SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_surfbar_actions` (`status`,`action`,`new_status`) VALUES('REJECTED','FRAMETEST',NULL)";
define('ADMIN_SURFBAR_NOTIFY_URL_DELETED_SUBJECT', "[Surfbar:] URL gelöscht");
define('ADMIN_SURFBAR_NOTIFY_URL_REJECTED_SUBJECT', "[Surfbar:] URL abgelehnt");
define('ADMIN_SURFBAR_NOTIFY_URL_PENDING_SUBJECT', "[Surfbar:] URL-Buchung zugestimmt");
+define('ADMIN_SURFBAR_NOTIFY_URL_DEPLETED_SUBJECT', "[Surfbar:] URL automatisch angehalten");
define('ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT', "Problem in Surfbar-Betreff");
// Auto-generated admin subject lines
define('MEMBER_SURFBAR_NOTIFY_URL_DELETED_SUBJECT', "Löschung Ihrer URL aus der Surfbar");
define('MEMBER_SURFBAR_NOTIFY_URL_REJECTED_SUBJECT', "Ihre URL wurde für die Surfbar abgelehnt!");
define('MEMBER_SURFBAR_NOTIFY_URL_PENDING_SUBJECT', "Zustimmung zur URL-Buchung in Surfbar erhalten");
+define('MEMBER_SURFBAR_NOTIFY_URL_DEPLETED_SUBJECT', "Ihre URL wurde automatisch angehalten");
define('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT', "[Fehler:] Bitte leiten Sie diese Mail an uns weiter!");
+define('MEMBER_SURFBAR_NOTIFY_LOW_POINTS_SUBJECT', "Ihr {!POINTS!}-Stand ist sehr niedrig!");
// Auto-generated member subject lines
define('MEMBER_DEL_SURFBAR_URLS_SUBJECT', "Ihre URL wurde aus der Surfbar entfernt");
define('SURFBAR_URL_STATUS_LOCKED', "Gesperrt");
define('SURFBAR_URL_STATUS_PENDING', "Wartend");
define('SURFBAR_URL_STATUS_STOPPED', "Angehalten");
+define('SURFBAR_URL_STATUS_DEPLETED', "Views erschöpft");
define('SURFBAR_URL_STATUS_REJECTED', "Abgelehnt");
define('SURFBAR_URL_STATUS_DELETED', "Gelöscht");
define('SURFBAR_URL_STATUS_MIGRATED', "Migriert");
}
//
// -----------------------------------------------------------------------------
+// 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
+}
+//
+// -----------------------------------------------------------------------------
// Generic functions
// -----------------------------------------------------------------------------
//
// Looks up by an URL
-function SURFBAR_LOOKUP_BY_URL ($url) {
+function SURFBAR_LOOKUP_BY_URL ($url, $uid) {
// Now lookup that given URL by itself
- $urlArray = SURFBAR_GET_URL_DATA($url, "url");
+ $urlArray = SURFBAR_GET_URL_DATA($url, "url", "id", "ASC", "id", sprintf(" AND userid=%s", bigintval($uid)));
// 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") {
+function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add="") {
global $lastUrlData;
// By default nothing is found
} // END - if
// Look up the record
- $result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, status, registered, last_locked, lock_reason
+ $result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, status, registered, last_locked, lock_reason, views_max, views_allowed
FROM "._MYSQL_PREFIX."_surfbar_urls
-WHERE %s='%s'
+WHERE %s='%s'".$add."
ORDER BY %s %s
%s",
array($column, $searchTerm, $order, $sort, $limit), __FILE__, __LINE__);
return $isFull;
}
// Get total amount of URLs of given status for current user or of ACTIVE URLs by default
-function SURFBAR_GET_TOTAL_URLS ($status="ACTIVE", $excludeUserId="") {
+function SURFBAR_GET_TOTAL_URLS ($status="ACTIVE", $excludeUserId=0) {
// Determine depleted user account
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
// Is the exlude userid set?
- if ($excludeUserId !== "") {
+ if ($excludeUserId > 0) {
// Then add it
- $UIDs[] = $excludeUserId;
+ $UIDs['uid'][$excludeUserId] = $excludeUserId;
} // END - if
// Get amount from database
$result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
FROM "._MYSQL_PREFIX."_surfbar_urls
-WHERE userid NOT IN (".implode(",", $UIDs).") AND status='%s'",
+WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND status='%s'",
array($status), __FILE__, __LINE__
);
return ($cnt == 1);
}
// Determine which user hash no more points left
-function SURFBAR_DETERMINE_DEPLETED_USERIDS() {
+function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Init array
$UIDs = array();
// Do we have a current user id?
- if (IS_MEMBER()) {
+ if ((IS_MEMBER()) && ($limit == 0)) {
// Then add this as well
- $UIDs[] = $GLOBALS['userid'];
+ $UIDs['uid'][$GLOBALS['userid']] = $GLOBALS['userid'];
+ $UIDs['points'][$GLOBALS['userid']] = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $UIDs['notified'][$GLOBALS['userid']] = 0;
// Get all userid except logged in one
- $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_surfbar_urls
-WHERE userid NOT IN (%s,0) AND status='ACTIVE'
-GROUP BY userid
-ORDER BY userid ASC",
+ $result = SQL_QUERY_ESC("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+FROM "._MYSQL_PREFIX."_surfbar_urls AS u
+INNER JOIN "._MYSQL_PREFIX."_user_data AS d
+ON u.userid=d.userid
+WHERE u.userid NOT IN (%s,0) AND u.status='ACTIVE'
+GROUP BY u.userid
+ORDER BY u.userid ASC",
array($GLOBALS['userid']), __FILE__, __LINE__);
} else {
// Get all userid
- $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_surfbar_urls
-WHERE status='ACTIVE'
-GROUP BY userid
-ORDER BY userid ASC", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+FROM "._MYSQL_PREFIX."_surfbar_urls AS u
+INNER JOIN "._MYSQL_PREFIX."_user_data AS d
+ON u.userid=d.userid
+WHERE u.status='ACTIVE'
+GROUP BY u.userid
+ORDER BY u.userid ASC", __FILE__, __LINE__);
}
// Load all userid
- while (list($uid) = SQL_FETCHROW($result)) {
+ 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}");
// Shall we add this to ignore?
- if ($points <= 0) {
+ if ($points <= $limit) {
// Ignore this one!
//DEBUG_LOG(__FUNCTION__.":uid={$uid} has depleted points amount!");
- $UIDs[] = $uid;
+ $UIDs['uid'][$uid] = $uid;
+ $UIDs['points'][$uid] = $points;
+ $UIDs['notified'][$uid] = $notified;
} // END - if
} // END - while
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
// Get maximum randomness factor
- $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs, $ADD);
+ $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['uid'], $ADD);
// If more than one URL can be called generate the random number!
if ($maxRand > 1) {
// And query the database
//DEBUG_LOG(__FUNCTION__.":randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."");
- $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.reward, sbu.costs, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
+ $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
ON sbu.id=sbs.url_id
LEFT JOIN "._MYSQL_PREFIX."_surfbar_locks AS l
ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND sbu.status='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$ADD."
+WHERE sbu.userid NOT IN (".implode(",", $UIDs['uid']).") AND sbu.status='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$ADD."
GROUP BY sbu.id
ORDER BY l.last_surfed ASC, sbu.id ASC
LIMIT %s,1",
);
} else {
// Get data from specified id number
- $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.reward, sbu.costs, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
+ $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
ON sbu.id=sbs.url_id
--- /dev/null
+{--HELLO_ADMIN--},
+
+eine URL wurde soeben automatisch angehalten, da die maximalen Views verbraucht sind.
+
+Hier sind alle dazu:
+------------------------------------------
+Gebuchte URL: $content[url]
+------------------------------------------
+Email: $content[email]
+------------------------------------------
+Framekiller-Test:
+$content[frametester]
+------------------------------------------
+User-ID: $content[uid]
+------------------------------------------
+URL angemeldet: $content[registered]
+------------------------------------------
+Gesamteinblendungen: $content[views_total]
+------------------------------------------
+Maximale Einblendungen: $content[views_allowed]
+------------------------------------------
+Davon übrig: $content[views_max]
+------------------------------------------
+Vergütung/Aufruf: $content[reward] {!POINTS!}
+------------------------------------------
+Kosten/Aufruf: $content[costs] {!POINTS!}
+------------------------------------------
+ID in der Surfbar: $content[id]
+------------------------------------------
+
+{--ADMIN_THANX--}
+ {--YOUR--} {!MAIN_TITLE!} {--SCRIPT--}
+
+{!URL!}/admin.php
--- /dev/null
+Hallo $content[gender] $content[surname] $content[family],
+
+Sie haben in unserer Surfbar mindestens eine URL gebucht. Ihr {!POINTS!}-Stand ist unter dem Limit von $content[low] {!POINTS!} gefallen. Ihre gebuchte(n) URL(s) wird/werden bei einem Guthaben von 0 {!POINTS!} nicht mehr aufgerufen.
+
+Hier sind alle Daten:
+------------------------------------------
+Ihre User-ID: $content[uid]
+------------------------------------------
+Ihr aktuelles Guthaben: $content[points] {!POINTS!}
+------------------------------------------
+Warnung wird versendet ab: $content[low] {!POINTS!} und niedriger
+------------------------------------------
+Zuletzt wegen niedrigem Kontostand gewarnt: $content[notified]
+------------------------------------------
+Mindestversendeinterval dieser Mail: $content[interval]
+------------------------------------------
+
+Mit freundlichem Gruss,
+ Ihr {!MAIN_TITLE!} Team
+
+{!URL!}/login.php ({!WEBMASTER!})
--- /dev/null
+Hallo $content[gender] $content[surname] $content[family],
+
+Ihre gebuchte URL wurde soeben angehalten, da die maximalen Einblendungen verbraucht sind.
+
+Hier sind alle Daten:
+------------------------------------------
+Gebuchte URL: $content[url]
+------------------------------------------
+Ihre User-ID: $content[uid]
+------------------------------------------
+Status: $content[status]
+------------------------------------------
+Datum der Buchung: $content[registered]
+------------------------------------------
+Gesamteinblendungen: $content[views_total]
+------------------------------------------
+Maximale Einblendungen: $content[views_allowed]
+------------------------------------------
+Davon übrig: $content[views_max]
+------------------------------------------
+Kosten/Aufruf: $content[costs] {!POINTS!}
+------------------------------------------
+ID in der Surfbar: $content[id]
+------------------------------------------
+
+Wenn Sie die URL dennoch weiterlaufen wollen, so loggen Sie sich bitte im Mitgliedsbereich ein und stellen Sie erneut Einblendungen oder auf unendlich ein.
+
+Mit freundlichem Gruss,
+ Ihr {!MAIN_TITLE!} Team
+
+{!URL!}/login.php ({!WEBMASTER!})