X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fmysql-manager.php;h=bd453fac30a4aa7c3b1f44fd84a53c971608df86;hb=a28637f0eb7975f2240c42d349e5f08a9722d9bb;hp=6d8b3c821ec58092dc016eb9376f0d9a6bc67819;hpb=039203d5428c9c6a3bed61fb3a9a16958c6fd44c;p=mailer.git
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 6d8b3c821e..bd453fac30 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -326,7 +326,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false) {
if (isAdmin()) $ADD = '';
$dummy = substr($search, 0, -4);
- $ADD .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
+ $ADD .= " AND `action`='".getActionFromModuleWhat($accessLevel, $dummy)."'";
} elseif (($accessLevel == 'sponsor') || ($accessLevel == 'engine')) {
// Sponsor / engine menu
$type = 'what';
@@ -695,7 +695,9 @@ function fetchUserData ($userid, $column = 'userid') {
// This patched function will reduce many SELECT queries for the specified or current admin login
function isAdmin ($admin = '') {
// Init variables
- $ret = false; $passCookie = ''; $valPass = '';
+ $ret = false;
+ $passCookie = '';
+ $valPass = '';
//* DEBUG: */ print(__FUNCTION__.':'.$admin.'
');
// If admin login is not given take current from cookies...
@@ -724,9 +726,12 @@ function isAdmin ($admin = '') {
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) {
+ } elseif ((!empty($admin)) && ((!isExtensionActive('cache')) || (isAdminHashSet($admin) === false))) {
// Get admin hash and hash it
$valPass = generatePassString(getAdminHash($admin));
+
+ // Cache it away
+ $GLOBALS['admin_hash'] = $valPass;
}
if (!empty($valPass)) {
@@ -768,7 +773,7 @@ function addMaxReceiveList ($mode, $default = '', $return = false) {
$OUT = '';
while ($content = SQL_FETCHARRAY($result)) {
$OUT .= ' ");
+ //* DEBUG: */ print(__LINE__.'='.$module.'/'.$what.'/'.getAction()."=
");
if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
// sql_patches is missing so choose depending on mode
if (isWhatSet()) {
// Use setted what
$what = getWhat();
- } elseif ($mode == 'admin') {
+ } elseif ($module == 'admin') {
// Admin area
$what = 'overview';
} else {
// Everywhere else
$what = 'welcome';
}
- } elseif ((empty($what)) && ($mode != 'admin')) {
+ } elseif ((empty($what)) && ($module != 'admin')) {
// Use configured 'home'
$what = getConfig('index_home');
} // END - if
- if ($mode == 'admin') {
+ if ($module == 'admin') {
// Action value for admin area
- if (isGetRequestElementSet('action')) {
+ if (isGetRequestParameterSet('action')) {
// Use from request!
- return getRequestElement('action');
+ return getRequestParameter('action');
} elseif (isActionSet()) {
// Get it directly from URL
return getAction();
@@ -903,19 +908,19 @@ function getModeAction ($mode, $what) {
// Get it directly from URL
return getAction();
}
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."): ret=".$data['action'].'
');
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__ . '): ret=' . $data['action'] . '
');
// Does the module have a menu?
- if (ifModuleHasMenu($mode)) {
+ if (ifModuleHasMenu($module)) {
// Rewriting modules to menu
- $mode = mapModuleToTable($mode);
+ $module = mapModuleToTable($module);
// Guest and member menu is 'main' as the default
if (empty($data['action'])) $data['action'] = 'main';
// Load from database
$result = SQL_QUERY_ESC("SELECT `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what`='%s' LIMIT 1",
- array($mode, $what), __FUNCTION__, __LINE__);
+ array($module, $what), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load action value and pray that this one is the right you want... ;-)
$data = SQL_FETCHARRAY($result);
@@ -923,7 +928,7 @@ function getModeAction ($mode, $what) {
// Free memory
SQL_FREERESULT($result);
- } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) {
+ } elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) {
// No sql_patches installed, but maybe we need to register an admin?
if (isAdminRegistered()) {
// Redirect to admin area
@@ -1176,12 +1181,12 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
// Count up referal depth
if (!isset($GLOBALS['ref_level'])) {
// Initialialize referal system
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."): Referal system initialized!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."): Referal system initialized!
");
$GLOBALS['ref_level'] = '0';
} else {
// Increase referal level
$GLOBALS['ref_level']++;
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."): Referal level increased. DEPTH={$GLOBALS['ref_level']}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."): Referal level increased. DEPTH={$GLOBALS['ref_level']}
");
}
// Default is 'normal' points
@@ -1191,39 +1196,39 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
if ($locked === true) $data = 'locked_points';
// Check user account
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},points={$points}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},points={$points}
");
if (fetchUserData($userid)) {
// This is the user and his ref
$GLOBALS['cache_array']['add_userid'][getUserData('refid')] = $userid;
// Get percents
$per = getReferalLevelPercents($GLOBALS['ref_level']);
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}
");
// Some percents found?
if ($per > 0) {
// Calculate new points
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},points={$points},per={$per},depth={$GLOBALS['ref_level']}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},points={$points},per={$per},depth={$GLOBALS['ref_level']}
");
$ref_points = $points * $per / 100;
// Pay refback here if level > 0 and in ref-mode
if ((isExtensionActive('refback')) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($add_mode == "ref") && (isset($GLOBALS['cache_array']['add_userid'][$userid]))) {
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!
");
$ref_points = addRefbackPoints($GLOBALS['cache_array']['add_userid'][$userid], $userid, $points, $ref_points);
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},data={$GLOBALS['cache_array']['add_userid'][$userid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!
");
} // END - if
// Update points...
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
array($data, $data, $ref_points, bigintval($userid), bigintval($GLOBALS['ref_level'])), __FUNCTION__, __LINE__);
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")
");
// No entry updated?
if (SQL_AFFECTEDROWS() < 1) {
// First ref in this level! :-)
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,'%s',%s)",
array($data, bigintval($userid), bigintval($GLOBALS['ref_level']), $ref_points), __FUNCTION__, __LINE__);
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - INSERTED! (".SQL_AFFECTEDROWS().")
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):data={$data},ref_points={$ref_points},userid={$userid},depth={$GLOBALS['ref_level']},mode={$add_mode} - INSERTED! (".SQL_AFFECTEDROWS().")
");
} // END - if
// Points updated, maybe I shall send him an email?
@@ -1253,13 +1258,13 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
// And sent it away
sendEmail($userid, getMessage('SUBJECT_DIRECT_PAYMENT'), $message);
- if (!isGetRequestElementSet('mid')) loadTemplate('admin_settings_saved', false, getMessage('ADMIN_POINTS_ADDED'));
+ if (!isGetRequestParameterSet('mid')) loadTemplate('admin_settings_saved', false, getMessage('ADMIN_POINTS_ADDED'));
}
// Maybe there's another ref?
if ((getUserData('refid') > 0) && ($points > 0) && (getUserData('refid') != $userid) && ($add_mode == 'ref')) {
// Then let's credit him here...
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},ref=".getUserData('refid').",points={$points} - ADVANCE!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},ref=".getUserData('refid').",points={$points} - ADVANCE!
");
addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid'), $locked);
} // END - if
} // END - if
@@ -1272,19 +1277,19 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
function updateReferalCounter ($userid) {
// Make it sure referal level zero (member him-/herself) is at least selected
if (empty($GLOBALS['cache_array']['ref_level'][$userid])) $GLOBALS['cache_array']['ref_level'][$userid] = 1;
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},level={$GLOBALS['cache_array']['ref_level'][$userid]}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},level={$GLOBALS['cache_array']['ref_level'][$userid]}
");
// Update counter
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`='%s' LIMIT 1",
array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
// When no entry was updated then we have to create it here
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):updated=".SQL_AFFECTEDROWS().'
');
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):updated=".SQL_AFFECTEDROWS().'
');
if (SQL_AFFECTEDROWS() < 1) {
// First count!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid}
");
} // END - if
// Init referal id
@@ -1296,17 +1301,17 @@ function updateReferalCounter ($userid) {
$ref = getUserData('refid');
} // END - if
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},ref={$ref}
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},ref={$ref}
");
// When he has a referal...
if (($ref > 0) && ($ref != $userid)) {
// Move to next referal level and count his counter one up!
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):ref={$ref} - ADVANCE!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):ref={$ref} - ADVANCE!
");
$GLOBALS['cache_array']['ref_level'][$userid]++;
updateReferalCounter($ref);
} elseif ((($ref == $userid) || ($ref == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) {
// Remove cache here
- //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):ref={$ref} - CACHE!
");
+ //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):ref={$ref} - CACHE!
");
rebuildCacheFile('refsystem', 'refsystem');
}
@@ -1397,7 +1402,7 @@ function getAdminHash ($admin) {
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
array($admin), __FUNCTION__, __LINE__);
// Do we have an entry?
@@ -1519,7 +1524,7 @@ function getAdminDefaultAcl ($adminId) {
}
// Generates an option list from various parameters
-function generateOptionList ($table, $id, $name, $default='', $special='', $where='') {
+function generateOptionList ($table, $id, $name, $default='', $special='', $where='', $disabled=array()) {
$ret = '';
if ($table == '/ARRAY/') {
// Selection from array
@@ -1527,7 +1532,13 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher
// Both are arrays
foreach ($id as $idx => $value) {
$ret .= '