X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=cedb715f33342b14c6ebe456728de9474d34ae98;hp=e92f1e4d502bcefcb63320432a60acfec7680d13;hb=43f8fab36af6c030d8835e1118cab430f8585e67;hpb=fc7f4d7fd71c718503c2af305276f5a374ae24da
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index e92f1e4d50..cedb715f33 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -190,7 +190,7 @@ function CHECK_MODULE($mod) {
// Add menu description pending on given file name (without path!)
function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
- global $DEPTH, $_CONFIG;
+ global $NAV_DEPTH, $_CONFIG;
// Use only filename of the file ;)
$file = basename($file);
@@ -205,13 +205,13 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
switch ($ACC_LVL)
{
case "admin":
- $MOD_CHECK = "admin";
+ $modCheck = "admin";
break;
case "sponsor":
case "guest":
case "member":
- $MOD_CHECK = $GLOBALS['module'];
+ $modCheck = $GLOBALS['module'];
break;
}
$AND = " AND (what='' OR what IS NULL)";
@@ -223,12 +223,12 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
switch ($ACC_LVL)
{
case "admin":
- $MOD_CHECK = "admin";
+ $modCheck = "admin";
break;
case "guest":
case "member":
- $MOD_CHECK = $GLOBALS['module'];
+ $modCheck = $GLOBALS['module'];
if (!IS_ADMIN()) {
$AND = " AND visible='Y' AND locked='N'";
}
@@ -240,20 +240,20 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
// Sponsor / engine menu
$type = "what";
$search = $file;
- $MOD_CHECK = $GLOBALS['module'];
+ $modCheck = $GLOBALS['module'];
$AND = "";
} else {
// Other
$type = "menu";
$search = $file;
- $MOD_CHECK = $GLOBALS['module'];
+ $modCheck = $GLOBALS['module'];
$AND = "";
}
- if ((!isset($DEPTH)) && (!$return)) {
- $DEPTH = 0;
+ if ((!isset($NAV_DEPTH)) && (!$return)) {
+ $NAV_DEPTH = 0;
$prefix = "
".YOU_ARE_HERE."
Home";
} else {
- if (!$return) $DEPTH++;
+ if (!$return) $NAV_DEPTH++;
$prefix = "";
}
@@ -278,9 +278,9 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
if ($return) {
// Return title
return $ret;
- } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == "Y")) || ((IS_ADMIN()) && ($MOD_CHECK == "admin"))) {
+ } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == "Y")) || ((IS_ADMIN()) && ($modCheck == "admin"))) {
// Output HTML code
- $OUT = $prefix."
".$ret."\n";
+ $OUT = $prefix."
".$ret."\n";
// Can we close the you-are-here navigation?
//* DEBUG: */ echo __LINE__."*".$type."/".$GLOBALS['what']."*
\n";
@@ -297,7 +297,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
// Add line-break tag
$OUT .= "
\n";
- $DEPTH = "0";
+ $NAV_DEPTH = "0";
// Handle failed logins here if not in guest
//* DEBUG: */ print __FUNCTION__."(
".__LINE__."):type={$type},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$ACC_LVL}
\n";
@@ -839,6 +839,7 @@ function SEND_MODE_MAILS($mod, $modes)
break;
default:
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode));
$content = MEMBER_UNKNOWN_MODE.": ".$mode."\n\n";
break;
}
@@ -855,11 +856,11 @@ function SEND_MODE_MAILS($mod, $modes)
if ($_CONFIG['admin_notify'] == "Y") {
// The admin needs to be notified about a profile change
$msg_admin = "admin_mydata_notify";
- $sub_adm = ADMIN_CHANGED_DATA;
+ $sub_adm = ADMIN_CHANGED_DATA;
} else {
// No mail to admin
$msg_admin = "";
- $sub_adm = "";
+ $sub_adm = "";
}
// Set subject lines
@@ -870,6 +871,7 @@ function SEND_MODE_MAILS($mod, $modes)
break;
default:
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
$content = "
".UNKNOWN_MODULE."";
break;
}
@@ -1149,6 +1151,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
*
* Dynamic referal system, can also send mails!
*
+ * subject = Subject line, write in lower-case letters and underscore is allowed
* uid = Referal ID wich should receive...
* points = ... xxx points
* send_notify = shall I send the referal an email or not?
@@ -1157,7 +1160,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
* add_mode = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
* for default value will cause no referal will get points ever!!!)
*/
-function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
+function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
//* DEBUG: */ print "-----------------------
".__FUNCTION__." - ENTRY ------------------------
- \n";
global $DEPTH, $_CONFIG, $DATA, $cacheArray;
@@ -1171,13 +1174,21 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
return;
} // END - if
+ // Add booking record if extension is installed
+ if (EXT_IS_ACTIVE("booking")) {
+ // Add record
+ ADD_BOOKING_RECORD($subject, $uid, $points, "add");
+ } // END - if
+
// Count up referal depth
if (!isset($DEPTH)) {
// Initialialize referal system
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."): Referal system initialized!
\n";
$DEPTH = 0;
} else {
// Increase referal level
$DEPTH++;
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."): Referal level increased. DEPTH={$DEPTH}
\n";
}
// Default is "normal" points
@@ -1267,7 +1278,7 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
// Then let's credit him here...
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref},points={$points} - ADVANCE!
\n";
- ADD_POINTS_REFSYSTEM($ref, $points, $send_notify, $ref, $locked);
+ ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $DEPTH), $ref, $points, $send_notify, $ref, $locked);
} // END - if
} // END - if
} // END - if
@@ -1660,28 +1671,28 @@ WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__);
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
}
//
-function META_DESCRIPTION($mod, $wht)
-{
+function META_DESCRIPTION ($mod, $wht) {
global $_CONFIG, $DEPTH;
- if (($mod != "admin") && ($mod != "login"))
- {
- // Exclude admin and member's area
+
+ // Exclude admin and member's area
+ if (($mod != "admin") && ($mod != "login")) {
+ // Construct dynamic description
$DESCR = MAIN_TITLE." ".trim($_CONFIG['title_middle'])." ".ADD_DESCR("guest", "what-".$wht, true);
- unset($DEPTH);
- OUTPUT_HTML("");
- }
+
+ // Output it directly
+ OUTPUT_HTML("");
+ } // END - if
+
+ // Remove depth
+ unset($DEPTH);
}
//
-function ADD_JACKPOT($points)
-{
+function ADD_JACKPOT($points) {
$result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
+ if (SQL_NUMROWS($result) == 0) {
// Create line
$result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok','%s')", array($points), __FILE__, __LINE__);
- }
- else
- {
+ } else {
// Free memory
SQL_FREERESULT($result);
@@ -1691,33 +1702,28 @@ function ADD_JACKPOT($points)
}
}
//
-function SUB_JACKPOT($points)
-{
+function SUB_JACKPOT($points) {
// First failed
$ret = "-1";
// Get current points
$result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
+ if (SQL_NUMROWS($result) == 0) {
// Create line
- $result = SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__);
- }
- else
- {
- // Free memory
- SQL_FREERESULT($result);
-
+ SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__);
+ } else {
// Read points
list($jackpot) = SQL_FETCHROW($result);
- if ($jackpot >= $points)
- {
+ if ($jackpot >= $points) {
// Update points when there are enougth points in jackpot
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1",
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1",
array($points), __FILE__, __LINE__);
$ret = $jackpot - $points;
- }
+ } // END - if
}
+
+ // Free memory
+ SQL_FREERESULT($result);
}
//
function IS_DEMO() {
@@ -1759,12 +1765,12 @@ function LOAD_CONFIG($no="0") {
return $CFG_DUMMY;
}
// Gets the matching what name from module
-function GET_WHAT($MOD_CHECK) {
+function GET_WHAT($modCheck) {
global $_CONFIG;
$wht = "";
- //* DEBUG: */ echo __LINE__."!".$MOD_CHECK."!
\n";
- switch ($MOD_CHECK)
+ //* DEBUG: */ echo __LINE__."!".$modCheck."!
\n";
+ switch ($modCheck)
{
case "admin":
$wht = "overview";
@@ -1773,7 +1779,7 @@ function GET_WHAT($MOD_CHECK) {
case "login":
case "index":
$wht = "welcome";
- if (($MOD_CHECK == "index") && (!empty($_CONFIG['index_home']))) $wht = $_CONFIG['index_home'];
+ if (($modCheck == "index") && (!empty($_CONFIG['index_home']))) $wht = $_CONFIG['index_home'];
break;
default:
@@ -1785,8 +1791,7 @@ function GET_WHAT($MOD_CHECK) {
return $wht;
}
//
-function MODULE_HAS_MENU($mod, $forceDb = false)
-{
+function MODULE_HAS_MENU($mod, $forceDb = false) {
global $cacheArray, $_CONFIG;
// All is false by default
@@ -1827,18 +1832,26 @@ function MODULE_HAS_MENU($mod, $forceDb = false)
// Return status
return $ret;
}
+
// Subtract points from database and mediadata cache
-function SUB_POINTS ($uid, $points) {
+function SUB_POINTS ($subject, $uid, $points) {
// Add points to used points
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1",
array($points, bigintval($uid)), __FILE__, __LINE__);
+ // Insert booking record
+ if (EXT_IS_ACTIVE("booking")) {
+ // Add record
+ ADD_BOOKING_RECORD($subject, $uid, $points, "sub");
+ } // END - if
+
// Update mediadata as well
if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
// Update database
MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
} // END - if
}
+
// Update config entries
function UPDATE_CONFIG ($entries, $values, $updateMode="") {
// Do we have multiple entries?
@@ -1855,6 +1868,9 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
if (($values[$idx] + 0) === $values[$idx]) {
// Number detected
$all .= sprintf("%s=%s,", $entry, (float)$values[$idx]);
+ } elseif ($values[$idx] == "UNIX_TIMESTAMP()") {
+ // Function UNIX_TIMESTAMP() detected
+ $all .= sprintf("%s=%s,", $entry, $values[$idx]);
} else {
// String detected
$all .= sprintf("%s='%s',", $entry, SQL_ESCAPE($values[$idx]));
@@ -1883,6 +1899,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
// Rebuild cache
REBUILD_CACHE("config", "config");
}
+
// Creates a new task for updated extension
function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
// Check if task is not there
@@ -1897,6 +1914,7 @@ function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
// Free memory
SQL_FREERESULT($result);
}
+
// Creates a new task for newly installed extension
function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) {
// Not installed and do we have created a task for the admin?
@@ -2245,8 +2263,14 @@ ORDER BY ur.refid ASC",
// Get unconfirmed mails
$row['unconfirmed'] = GET_TOTAL_DATA($row['refid'], "user_links", "id", "userid", true);
- // Calculate clickrate
- $row['clickrate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100);
+ // Init clickrate with zero
+ $row['clickrate'] = 0;
+
+ // Is at least one mail received?
+ if ($row['emails_received'] > 0) {
+ // Calculate clickrate
+ $row['clickrate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100);
+ } // END - if
// Activity is "active" by default because if autopurge is not installed
$row['activity'] = MEMBER_ACTIVITY_ACTIVE;