X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=1e4856595c3ab9a5fdb71470c18166528982673b;hb=ed9e95a268dbaea932b703fe4e8653615befcc27;hp=093ea4ee8f24d6e8bf93e80b8acaf7c2bb14b8eb;hpb=feda50ff73c05935417ed33164d30caf966ba854;p=mailer.git
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 093ea4ee8f..1e4856595c 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -65,7 +65,7 @@ function ADD_MODULE_TITLE($mod) {
// Still no luck or empty title?
if (empty($name)) {
// No name found
- $name = LANG_UNKNOWN_MODULE." (".$mod.")";
+ $name = sprintf("%s (%s)", LANG_UNKNOWN_MODULE, $mod);
if (SQL_NUMROWS($result) == 0) {
// Add module to database
$dummy = CHECK_MODULE($mod);
@@ -77,7 +77,7 @@ function ADD_MODULE_TITLE($mod) {
}
// Check validity of a given module name (no file extension)
-function CHECK_MODULE($mod) {
+function CHECK_MODULE ($mod) {
// We need them now here...
global $cacheArray, $_CONFIG, $cacheInstance;
@@ -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);
@@ -249,11 +249,11 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
$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 = "";
}
@@ -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";
@@ -794,7 +794,7 @@ function SEND_MODE_MAILS($mod, $modes)
// Load hash
$result_main = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array($GLOBALS['userid']), __FILE__, __LINE__);
if (SQL_NUMROWS($result_main) == 1) {
// Load hash from database
list($hashDB) = SQL_FETCHROW($result_main);
@@ -807,7 +807,7 @@ function SEND_MODE_MAILS($mod, $modes)
if (($hash == get_session('u_hash')) || ($_POST['pass1'] == $_POST['pass2'])) {
// Load user's data
$result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND password='%s' LIMIT 1",
- array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
+ array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load the data
$DATA = SQL_FETCHROW($result);
@@ -839,16 +839,16 @@ function SEND_MODE_MAILS($mod, $modes)
break;
default:
- DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown mode %s detected.", $mode));
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode));
$content = MEMBER_UNKNOWN_MODE.": ".$mode."\n\n";
break;
- }
+ } // END - switch
} // END - if
if (EXT_IS_ACTIVE("country")) {
// Replace code with description
$DATA[4] = COUNTRY_GENERATE_INFO($_POST['country_code']);
- }
+ } // END - if
// Load template
$msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']);
@@ -867,32 +867,32 @@ function SEND_MODE_MAILS($mod, $modes)
$sub_mem = MEMBER_CHANGED_DATA;
// Output success message
- $content = "
".MYDATA_MAIL_SENT."";
+ $content = "
".MYDATA_MAIL_SENT."";
break;
default:
- DEBUG_LOG(__FILE__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
- $content = "
".UNKNOWN_MODULE."";
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
+ $content = "
".UNKNOWN_MODULE."";
break;
- }
+ } // END - switch
} else {
// Could not load profile data
- $content = "
".MEMBER_CANNOT_LOAD_PROFILE."";
+ $content = "
".MEMBER_CANNOT_LOAD_PROFILE."";
}
} else {
// Passwords mismatch
- $content = "
".MEMBER_PASSWORD_ERROR."";
+ $content = "
".MEMBER_PASSWORD_ERROR."";
}
} else {
// Could not load profile
- $content = "
".MEMBER_CANNOT_LOAD_PROFILE."";
+ $content = "
".MEMBER_CANNOT_LOAD_PROFILE."";
}
// Send email to user if required
if ((!empty($sub_mem)) && (!empty($msg))) {
// Send member mail
SEND_EMAIL($DATA[7], $sub_mem, $msg);
- }
+ } // END - if
// Send only if no other error has occured
if (empty($content)) {
@@ -904,22 +904,20 @@ function SEND_MODE_MAILS($mod, $modes)
$content = CANNOT_SEND_ADMIN_MAILS;
} else {
// No mail to admin
- $content = "
".MYDATA_MAIL_SENT."";
+ $content = "
".MYDATA_MAIL_SENT."";
}
- }
+ } // END - if
// Load template
LOAD_TEMPLATE("admin_settings_saved", false, $content);
}
// Update module counter
-function COUNT_MODULE($mod)
-{
- if ($mod != "css")
- {
+function COUNT_MODULE($mod) {
+ if ($mod != "css") {
// Do count all other modules but not accesses on CSS file css.php!
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_mod_reg SET clicks=clicks+1 WHERE module='%s' LIMIT 1",
- array($mod), __FILE__, __LINE__);
- }
+ array($mod), __FILE__, __LINE__);
+ } // END - if
}
// Get action value from mode (admin/guest/member) and what-value
function GET_ACTION ($MODE, &$wht)
@@ -974,7 +972,8 @@ function GET_ACTION ($MODE, &$wht)
// Return action value
return $ret;
}
-//
+
+// Get category name back
function GET_CATEGORY ($cid) {
// Default is not found
$ret = _CATEGORY_404;
@@ -999,7 +998,8 @@ function GET_CATEGORY ($cid) {
// Return result
return $ret;
}
-//
+
+// Get a string of "mail title" and price back
function GET_PAYMENT ($pid, $full=false) {
// Default is not found
$ret = _PAYMENT_404;
@@ -1025,7 +1025,8 @@ function GET_PAYMENT ($pid, $full=false) {
// Return result
return $ret;
}
-//
+
+// Get (basicly) the price of given payment id
function GET_PAY_POINTS($pid, $lookFor="price")
{
$ret = "-1";
@@ -1039,8 +1040,9 @@ function GET_PAY_POINTS($pid, $lookFor="price")
}
return $ret;
}
+
// Remove a receiver's ID from $ARRAY and add a link for him to confirm
-function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false)
+function REMOVE_RECEIVER (&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false)
{
$ret = "failed";
if ($uid > 0)
@@ -1151,6 +1153,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?
@@ -1159,7 +1162,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;
@@ -1173,13 +1176,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
@@ -1269,7 +1280,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
@@ -1398,7 +1409,7 @@ WHERE sid='%s' LIMIT 1",
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= (UNIX_TIMESTAMP() - %s)",
array($_CONFIG['online_timeout']), __FILE__, __LINE__);
}
-// OBSULETE: Sends out mail to all administrators
+// OBSOLETE: Sends out mail to all administrators
function SEND_ADMIN_EMAILS ($subj, $msg) {
// Load all admin email addresses
$result = SQL_QUERY("SELECT email FROM "._MYSQL_PREFIX."_admins ORDER BY id ASC", __FILE__, __LINE__);
@@ -1662,28 +1673,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);
@@ -1693,40 +1704,35 @@ 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() {
return ((EXT_IS_ACTIVE("demo")) && (get_session('admin_login') == "demo"));
}
//
-function LOAD_CONFIG($no="0") {
+function LOAD_CONFIG ($no="0") {
global $cacheArray;
$CFG_DUMMY = array();
@@ -1787,8 +1793,7 @@ function GET_WHAT($modCheck) {
return $wht;
}
//
-function MODULE_HAS_MENU($mod, $forceDb = false)
-{
+function MODULE_HAS_MENU($mod, $forceDb = false) {
global $cacheArray, $_CONFIG;
// All is false by default
@@ -1829,18 +1834,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?
@@ -1857,6 +1870,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]));
@@ -1875,7 +1891,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
}
// Run database update
- //DEBUG_LOG(__FUNCTION__, __LINE__, "entries={$entries}");
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "entries={$entries}");
SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET ".$entries." WHERE config=0 LIMIT 1", __FILE__, __LINE__);
// Get affected rows
@@ -1885,6 +1901,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
@@ -1899,6 +1916,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?
@@ -2247,8 +2265,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;