X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=bf54a9f45b5b4dff9450c065025295a88bdff584;hp=186b1d43e1c678457ef27ae9e0f24ac82e7a75c6;hb=40e18f1f10e4c7b3e63cf728567459a2cc0dcbd5;hpb=dfaa8c1675da4071ea451406a6f6fedd4c568416
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 186b1d43e1..bf54a9f45b 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -50,7 +50,7 @@ function ADD_MODULE_TITLE($mod) {
$name = $cacheArray['modules']['title'][$mod];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} else {
// Load from database
$result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__);
@@ -115,7 +115,7 @@ function CHECK_MODULE($mod) {
$mem = $cacheArray['modules']['mem_only'][$mod_chk];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
$found = true;
} else {
// No, then we have to update it!
@@ -191,7 +191,12 @@ 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;
+ // Use only filename of the file ;)
+ $file = basename($file);
+
+ // Init variables
$LINK_ADD = ""; $OUT = ""; $AND = "";
+
// First we have to do some analysis...
if (ereg("action-", $file)) {
// This is an action file!
@@ -282,8 +287,17 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
//* DEBUG: */ die("
".print_r($_CONFIG, true)."
");
if (($type == "what") || (($type == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview")))) {
//* DEBUG: */ echo __LINE__."+".$type."+
\n";
- $OUT .= "
\n";
- $DEPTH="0";
+ $OUT .= "\n";
+
+ // Extension removeip activated?
+ if ((EXT_IS_ACTIVE("removeip")) && (isset($_CONFIG['removeip_'.strtolower($ACC_LVL).'_show'])) && ($_CONFIG['removeip_'.strtolower($ACC_LVL).'_show'] == "Y")) {
+ // Add anoymity/privacy infos
+ $OUT .= REMOVEIP_ADD_INFOS();
+ } // END - if
+
+ // Add line-break tag
+ $OUT .= "
\n";
+ $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";
@@ -445,7 +459,7 @@ function IS_ADMIN($admin="")
$valPass = $cacheArray['admin_hash'];
} elseif ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) {
// Count cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
// Login data is valid or not?
$valPass = generatePassString($cacheArray['admins']['password'][$admin]);
@@ -629,6 +643,7 @@ function IS_MEMBER()
} else {
// Cookie data is invalid!
//* DEBUG: */ echo __LINE__."***
";
+ destroy_user_session();
// Reset userid
$GLOBALS['userid'] = 0;
@@ -689,8 +704,8 @@ function UPDATE_LOGIN_DATA () {
} // END - if
// Update last module / online time
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_module='%s', last_online=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1",
- array($GLOBALS['what'], $GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_module='%s', last_online=UNIX_TIMESTAMP(), REMOTE_ADDR='%s' WHERE userid=%s LIMIT 1",
+ array($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FILE__, __LINE__);
}
} else {
// Destroy session, we cannot update!
@@ -1060,16 +1075,16 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal
return $ret;
}
//
-function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false) {
+function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") {
$ret = 0;
if ($onlyRows) {
// Count rows
- $result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
- array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'%s",
+ array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__);
} else {
// Add all rows
- $result = SQL_QUERY_ESC("SELECT SUM(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
- array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT SUM(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'%s",
+ array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__);
}
// Load row
@@ -1102,7 +1117,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
$per = $cacheArray['ref_depths']['percents'][$key];
// Count cache hit
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
}
} else {
// Get referal data
@@ -1124,15 +1139,15 @@ function GET_REF_LEVEL_PERCENTS ($level) {
}
/**
*
- * Dynamic referral system, can also send mails!
+ * Dynamic referal system, can also send mails!
*
- * uid = Referral ID wich should receive...
+ * uid = Referal ID wich should receive...
* points = ... xxx points
- * send_notify = shall I send the referral an email or not?
+ * send_notify = shall I send the referal an email or not?
* rid = inc/modules/guest/what-confirm.php need this (DEPRECATED???)
* locked = Shall I pay it to normal (false) or locked (true) points ammount?
* add_mode = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
- * for default value will cause no referral will get points ever!!!)
+ * 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") {
//* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------- \n";
@@ -1148,12 +1163,12 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
return;
} // END - if
- // Count up referral depth
+ // Count up referal depth
if (!isset($DEPTH)) {
- // Initialialize referral system
+ // Initialialize referal system
$DEPTH = 0;
} else {
- // Increase referral level
+ // Increase referal level
$DEPTH++;
}
@@ -1219,7 +1234,7 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
);
// Load email template
- $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", $content, bigintval($uid));
+ $msg = LOAD_EMAIL_TEMPLATE("confirm-referal", $content, bigintval($uid));
SEND_EMAIL($email, THANX_REFERRAL_ONE, $msg);
} elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == "direct") && (!defined('__POINTS_VALUE'))) {
@@ -1257,7 +1272,7 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
function UPDATE_REF_COUNTER ($uid) {
global $cacheArray, $cacheInstance;
- // Make it sure referral level zero (member him-/herself) is at least selected
+ // Make it sure referal level zero (member him-/herself) is at least selected
if (empty($cacheArray['ref_level'][$uid])) $cacheArray['ref_level'][$uid] = 1;
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level={$cacheArray['ref_level'][$uid]}
\n";
@@ -1274,7 +1289,7 @@ function UPDATE_REF_COUNTER ($uid) {
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid}
\n";
} // END - if
- // Check for his referral
+ // Check for his referal
$result = SQL_QUERY_ESC("SELECT refid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
array(bigintval($uid)), __FILE__, __LINE__);
@@ -1285,15 +1300,15 @@ function UPDATE_REF_COUNTER ($uid) {
SQL_FREERESULT($result);
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref}
\n";
- // When he has a referral...
+ // When he has a referal...
if (($ref > 0) && ($ref != $uid)) {
- // Move to next referral level and count his counter one up!
+ // Move to next referal level and count his counter one up!
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):ref={$ref} - ADVANCE!
\n";
$cacheArray['ref_level'][$uid]++; UPDATE_REF_COUNTER($ref);
} elseif ((($ref == $uid) || ($ref == 0)) && (GET_EXT_VERSION("cache") >= "0.1.2")) {
// Remove cache here
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):ref={$ref} - CACHE!
\n";
- if ($cacheInstance->cache_file("refsystem", true)) $cacheInstance->cache_destroy();
+ REBUILD_CACHE("refsystem", "refsystem");
}
// "Walk" back here
@@ -1362,7 +1377,7 @@ WHERE sid='%s' LIMIT 1",
} else {
// No entry does exists so we simply add it!
SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')",
- array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__
+ array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID, GET_REMOTE_ADDR()), __FILE__, __LINE__
);
}
@@ -1396,7 +1411,7 @@ function GET_ADMIN_ID($login) {
$ret = $cacheArray['admins']['aid'][$login];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} elseif (!EXT_IS_ACTIVE("cache")) {
// Load from database
$result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
@@ -1421,7 +1436,7 @@ function GET_ADMIN_HASH($login)
$ret = $cacheArray['admins']['password'][$login];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} elseif (!EXT_IS_ACTIVE("cache")) {
// Load from database
$result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
@@ -1448,7 +1463,7 @@ function GET_ADMIN_LOGIN ($aid) {
$ret = $cacheArray['admins']['login'][$aid];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} elseif (!EXT_IS_ACTIVE("cache")) {
// Load from database
$result = SQL_QUERY_ESC("SELECT login FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1",
@@ -1476,7 +1491,7 @@ function GET_ADMIN_EMAIL ($aid) {
$ret = $cacheArray['admins']['email'][$aid];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} elseif (!EXT_IS_ACTIVE("cache")) {
// Load from database
$result_aid = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1",
@@ -1506,7 +1521,7 @@ function GET_ADMIN_DEFAULT_ACL ($aid) {
$ret = $cacheArray['admins']['def_acl'][$aid];
// Update cache hits
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} else {
// Load from database
$result_aid = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1",
@@ -1774,11 +1789,11 @@ function MODULE_HAS_MENU($mod, $forceDb = false)
if (isset($cacheArray['modules']['has_menu'][$mod])) {
// Check module cache and count hit
$ret = ($cacheArray['modules']['has_menu'][$mod] == "Y");
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
} elseif (isset($cacheArray['extensions']['ext_menu'][$mod])) {
// Check cache and count hit
$ret = ($cacheArray['extensions']['ext_menu'][$mod] == "Y");
- $_CONFIG['cache_hits']++;
+ if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
}
} elseif ((GET_EXT_VERSION("sql_patches") >= "0.3.6") && ((!EXT_IS_ACTIVE("cache")) || ($forceDb === true))) {
// Check database for entry
@@ -1843,7 +1858,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
$entries = substr($all, 0, -1);
} elseif (!empty($updateMode)) {
// Update mode set
- $entries .= sprintf("=%s%s%s", $entries, $updateMode, (float)$value);
+ $entries .= sprintf("=%s%s%s", $entries, $updateMode, (float)$values);
} else {
// Regular entry to update
$entries .= sprintf("='%s'", SQL_ESCAPE($values));
@@ -1910,5 +1925,227 @@ VALUES (%s,0,'NEW','EXTENSION','%s','%s',UNIX_TIMESTAMP())",
// Free memory
SQL_FREERESULT($result);
}
+
+// Prepares an SQL statement part for HTML mail and/or holiday depency
+function PREPARE_SQL_HTML_HOLIDAY ($mode) {
+ // Exclude no users by default
+ $MORE = "";
+
+ // HTML mail?
+ if ($mode == "html") $MORE = " AND html='Y'";
+ if (GET_EXT_VERSION("holiday") >= "0.1.3") {
+ // Add something for the holiday extension
+ $MORE .= " AND holiday_active='N'";
+ } // END - if
+
+ // Return result
+ return $MORE;
+}
+
+// "Getter" for total available receivers
+function GET_TOTAL_RECEIVERS ($mode="normal") {
+ // Query database
+ $result_all = SQL_QUERY("SELECT userid
+FROM "._MYSQL_PREFIX."_user_data
+WHERE status='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode),
+ __FILE__, __LINE__);
+
+ // Get num rows
+ $numRows = SQL_NUMROWS($result_all);
+
+ // Free result
+ SQL_FREERESULT($result_all);
+
+ // Return value
+ return $numRows;
+}
+
+// Returns HTML code with an "\n";
+ }
+ } else {
+ // No cateogries are defined yet
+ $OUT = "\n";
+ }
+
+ // Return HTML code
+ return $OUT;
+}
+
+// Add bonus mail to queue
+function ADD_BONUS_MAIL_TO_QUEUE ($subject, $text, $receiverList, $points, $seconds, $url, $cat, $mode="normal", $receiver=0) {
+ // Is admin or bonus extension there?
+ if (!IS_ADMIN()) {
+ // Abort here
+ return false;
+ } elseif (!EXT_IS_ACTIVE("bonus")) {
+ // Abort here
+ return false;
+ }
+
+ // Calculcate target sent
+ $target = SELECTION_COUNT(explode(";", $receiverList));
+
+ // Receiver is zero?
+ if ($receiver == 0) {
+ // Then auto-fix it
+ $receiver = $target;
+ } // END - if
+
+ // HTML extension active?
+ if (EXT_IS_ACTIVE("html")) {
+ // No HTML by default
+ $HTML = "N";
+
+ // HTML mode?
+ if ($mode == "html") $HTML = "Y";
+
+ // Add HTML mail
+ $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
+(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, html_msg)
+VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s')",
+ array(
+ $subject,
+ addslashes($text),
+ $receiverList,
+ $points,
+ $seconds,
+ $url,
+ $cat,
+ $target,
+ bigintval($receiver),
+ $HTML
+), __FILE__, __LINE__);
+ } else {
+ // Add regular mail
+ $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
+(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent)
+VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s')",
+ array(
+ $subject,
+ addslashes($text),
+ $receiverList,
+ $points,
+ $seconds,
+ $url,
+ $cat,
+ $target,
+ bigintval($receiver),
+), __FILE__, __LINE__);
+ }
+}
+
+// Generate a receiver list for given category and maximum receivers
+function GENERATE_RECEIVER_LIST ($cat, $receiver, $mode="") {
+ global $_CONFIG;
+
+ // Init variables
+ $CAT_TABS = "%s";
+ $CAT_WHERE = "";
+ $receiverList = "";
+
+ // Secure data
+ $cat = bigintval($cat);
+ $receiver = bigintval($receiver);
+
+ // Is the receiver zero and mode set?
+ if (($receiver == 0) && (!empty($mode))) {
+ // Auto-fix receiver maximum
+ $receiver = GET_TOTAL_RECEIVERS($mode);
+ } // END - if
+
+ // Category given?
+ if ($cat > 0) {
+ // Select category
+ $CAT_TABS = "LEFT JOIN "._MYSQL_PREFIX."_user_cats AS c ON d.userid=c.userid";
+ $CAT_WHERE = " AND c.cat_id=%s";
+ } // END - if
+
+ // Exclude users in holiday?
+ if (GET_EXT_VERSION("holiday") >= "0.1.3") {
+ // Add something for the holiday extension
+ $CAT_WHERE .= " AND d.holiday_active='N'";
+ } // END - if
+
+ if ((EXT_IS_ACTIVE("html_mail")) && ($mode == "html")) {
+ // Only include HTML receivers
+ $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED' AND d.html='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
+ array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], $receiver), __FILE__, __LINE__);
+ } else {
+ // Include all
+ $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
+ array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], $receiver), __FILE__, __LINE__);
+ }
+
+ // Entries found?
+ if ((SQL_NUMROWS($result) >= $receiver) && ($receiver > 0)) {
+ // Load all entries
+ while (list($REC) = SQL_FETCHROW($result)) {
+ // Add receiver when not empty
+ if (!empty($REC)) $receiverList .= $REC.";";
+ } // END - while
+
+ // Free memory
+ SQL_FREERESULT($result);
+
+ // Remove trailing semicolon
+ $receiverList = substr($receiverList, 0, -1);
+ } // END - if
+
+ // Return list
+ return $receiverList;
+}
+
//
?>