X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=57ca77e32a66613d94794caec488a6c089ea547a;hb=af7035c4b7477791785d350f4cd72e809583e42a;hp=5a5724fa1d3c150d37e0d43be5bcc0f8322b71b7;hpb=414570c5081d337bb6c28dcf521bd8bca02f69e7;p=mailer.git
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 5a5724fa1d..57ca77e32a 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -10,10 +10,10 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Alle MySQL-Relevanten Funktionen *
* -------------------------------------------------------------------- *
- * $Revision:: 856 $ *
- * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009) $ *
+ * $Revision:: $ *
+ * $Date:: $ *
* $Tag:: 0.2.1-FINAL $ *
- * $Author:: stelzi $ *
+ * $Author:: $ *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
@@ -362,7 +362,7 @@ function ADD_MENU ($MODE, $act, $wht) {
// is the menu action valid?
if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) {
- return getMessage('CODE_MENU_NOT_VALID');
+ return getCode('MENU_NOT_VALID');
} // END - if
// Non-admin shall not see all menus
@@ -629,10 +629,10 @@ function IS_MEMBER () {
FIX_DELETED_COOKIES(array('userid', 'u_hash'));
// Are cookies set?
- if ((!empty($GLOBALS['userid'])) && (isSessionVariableSet('u_hash'))) {
+ if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
// Cookies are set with values, but are they valid?
$result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load data from cookies
list($password, $status, $mod, $onl) = SQL_FETCHROW($result);
@@ -692,21 +692,21 @@ function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false) {
$ret = false;
// Look in all menus or only unlocked
- $ADD = "";
- if ((!IS_ADMIN()) && ($MODE != "admin")) $ADD = " AND `locked`='N'";
+ $add = "";
+ if ((!IS_ADMIN()) && ($MODE != "admin")) $add = " AND `locked`='N'";
//* DEBUG: */ echo __LINE__.":".$MODE."/".$act."/".$wht."*
\n";
if (($MODE != "admin") && ($UPDATE === true)) {
// Update guest or member menu
- $sql = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$ADD." LIMIT 1",
+ $sql = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1",
array($MODE, $act, $wht), __FUNCTION__, __LINE__, false);
} elseif (($wht != "overview") && (!empty($wht))) {
// Other actions
- $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$ADD." ORDER BY action DESC LIMIT 1",
+ $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$add." ORDER BY action DESC LIMIT 1",
array($MODE, $act, $wht), __FUNCTION__, __LINE__, false);
} else {
// Admin login overview
- $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (what='' OR `what` IS NULL)".$ADD." ORDER BY action DESC LIMIT 1",
+ $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (what='' OR `what` IS NULL)".$add." ORDER BY action DESC LIMIT 1",
array($MODE, $act), __FUNCTION__, __LINE__, false);
}
@@ -761,7 +761,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']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result_main) == 1) {
// Load hash from database
list($hashDB) = SQL_FETCHROW($result_main);
@@ -774,7 +774,7 @@ function SEND_MODE_MAILS($mod, $modes) {
if (($hash == get_session('u_hash')) || (REQUEST_POST('pass1') == REQUEST_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), __FUNCTION__, __LINE__);
+ array(getUserId(), $hashDB), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load the data
$DATA = SQL_FETCHROW($result);
@@ -818,7 +818,7 @@ function SEND_MODE_MAILS($mod, $modes) {
} // END - if
// Load template
- $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']);
+ $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, getUserId());
if (getConfig('admin_notify') == "Y") {
// The admin needs to be notified about a profile change
@@ -865,7 +865,7 @@ function SEND_MODE_MAILS($mod, $modes) {
if (empty($content)) {
if ((!empty($sub_adm)) && (!empty($msg_admin))) {
// Send admin mail
- SEND_ADMIN_NOTIFICATION($sub_adm, $msg_admin, $content, $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION($sub_adm, $msg_admin, $content, getUserId());
} elseif (getConfig('admin_notify') == "Y") {
// Cannot send mails to admin!
$content = getMessage('CANNOT_SEND_ADMIN_MAILS');
@@ -943,7 +943,7 @@ function GET_ACTION ($MODE, &$wht) {
if (isAdminRegistered()) {
// Redirect
// @TODO Why does this lead into an endless loop but we still need it???
- // Commented out LOAD_URL("admin.php");
+ // @TODO Commented out LOAD_URL("admin.php");
} // END - if
}
@@ -1017,31 +1017,33 @@ 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) {
+// Remove a receiver's ID from $receivers and add a link for him to confirm
+function REMOVE_RECEIVER (&$receivers, $key, $uid, $pool_id, $stats_id="", $bonus=false) {
+ // Default is not removed
$ret = "failed";
- if ($uid > 0)
- {
+
+ // Is the userid valid?
+ if ($uid > 0) {
// Remove entry from array
- unset($ARRAY[$key]);
+ unset($receivers[$key]);
// Is there already a line for this user available?
- if ($stats_id > 0)
- {
+ if ($stats_id > 0) {
// Only when we got a real stats ID continue searching for the entry
$type = "NORMAL"; $rowName = "stats_id";
if ($bonus) { $type = "BONUS"; $rowName = "bonus_id"; }
+
+ // Try to look the entry up
$result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_links` WHERE %s='%s' AND userid=%s AND link_type='%s' LIMIT 1",
- array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
- // No, so we add one!
+ array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+
+ // Was it *not* found?
+ if (SQL_NUMROWS($result) == 0) {
+ // So we add one!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (%s, userid, link_type) VALUES ('%s','%s','%s')",
- array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+ array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
$ret = "done";
- }
- else
- {
+ } else {
// Already found
$ret = "already";
}
@@ -1050,15 +1052,27 @@ function REMOVE_RECEIVER (&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fa
SQL_FREERESULT($result);
}
}
+
// Return status for sending routine
return $ret;
}
// Calculate sum (default) or count records of given criteria
-function GET_TOTAL_DATA ($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") {
+function GET_TOTAL_DATA ($search, $tableName, $lookFor = "id", $whereStatement = "userid", $countRows = false, $add = "") {
$ret = 0;
//* DEBUG: */ echo $search."/".$tableName."/".$lookFor."/".$whereStatement."/".$add."
\n";
- if (($onlyRows) || ($lookFor == "userid")) {
+ if (empty($search)) {
+ // Count or sum whole table?
+ if ($countRows === true) {
+ // Count whole table
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{!_MYSQL_PREFIX!}_%s`".$add,
+ array($lookFor, $tableName), __FUNCTION__, __LINE__);
+ } else {
+ // Sum whole table
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `{!_MYSQL_PREFIX!}_%s`".$add,
+ array($lookFor, $tableName), __FUNCTION__, __LINE__);
+ }
+ } elseif (($countRows === true) || ($lookFor == "userid")) {
// Count rows
//* DEBUG: */ echo "COUNT!
\n";
$result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s'".$add,
@@ -1528,6 +1542,12 @@ function ADD_OPTION_LINES ($table, $id, $name, $default="", $special="", $where=
}
// Activate exchange
function activateExchange () {
+ // Is the extension 'user' there?
+ if (!EXT_IS_ACTIVE("user")) {
+ // Silently abort here
+ return false;
+ } // END - if
+
// Check total amount of users
$totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true, " AND max_mails > 0");
@@ -1990,8 +2010,8 @@ function USER_STATS_GET_TIMESTAMP ($type, $data, $uid = 0) {
$stamp = 0;
// User id set?
- if ((isset($GLOBALS['userid'])) && ($uid == 0)) {
- $uid = $GLOBALS['userid'];
+ if ((isUserIdSet()) && ($uid == 0)) {
+ $uid = getUserId();
} // END - if
// Is the extension installed and updated?
@@ -2043,16 +2063,16 @@ function USER_STATS_INSERT_RECORD ($uid, $type, $data) {
function GET_USER_REF_POINTS ($uid, $level) {
//* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------