From: Roland Häder Date: Sat, 27 Sep 2008 15:05:59 +0000 (+0000) Subject: Template fixes, lesser admin data will be loaded from database X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=811c2a74188a97591fb05ed1dd3d1929b8bc23aa Template fixes, lesser admin data will be loaded from database --- diff --git a/inc/databases.php b/inc/databases.php index 790f3a7508..6863d5fba9 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -113,7 +113,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // This current patch level -define('CURR_SVN_REVISION', "393"); +define('CURR_SVN_REVISION', "394"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/doubler_send.php b/inc/doubler_send.php index 782af6b03d..a148c206f0 100644 --- a/inc/doubler_send.php +++ b/inc/doubler_send.php @@ -107,19 +107,10 @@ if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) } // Exclude webmaster from doubling... - if ($uid != $_CONFIG['doubler_uid']) - { + if ($uid != $_CONFIG['doubler_uid']) { // Add points - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($points, bigintval($uid)), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - MEDIA_UPDATE_ENTRY(array("total_points"), "add", $points); - } - } + ADD_POINTS_REFSYSTEM($uid, $points, false, "0", false, "direct"); + } // END - if // Set entry as "payed" $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_doubler SET completed='Y' WHERE id=%s LIMIT 1", diff --git a/inc/functions.php b/inc/functions.php index 3cdcf70695..3a8bf9c0fd 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -131,6 +131,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { $OUTPUT = ob_get_contents(); // Clear output buffer for later output + die(); ob_end_clean(); // Extension "rewrite" installed? @@ -704,13 +705,13 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { $REMOTE_ADDR = getenv('REMOTE_ADDR'); $HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); + // Default admin $ADMIN = MAIN_TITLE; - if (isSessionVariableSet('admin_login')) { + + // Is the admin logged in? + if (IS_ADMIN()) { // Load Admin data - $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array(get_session('admin_login')), __FILE__, __LINE__); - list($ADMIN) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $ADMIN = GET_ADMIN_EMAIL(get_session('admin_login')); } // END - if // Neutral email address is default @@ -744,7 +745,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { array(bigintval($UID)), __FILE__, __LINE__); } else { //* DEBUG: */ echo __FUNCTION__.":NO-NICK!
\n"; - // Load normal data + /// Load normal data $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($UID)), __FILE__, __LINE__); } @@ -811,7 +812,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { // Run code $tmpl_file = "\$newContent=html_entity_decode(\"".COMPILE_CODE($tmpl_file)."\");"; - eval($tmpl_file); + @eval($tmpl_file); } elseif (!empty($template)) { // Template file not found! $newContent = TEMPLATE_404.": ".$template."
@@ -831,7 +832,8 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { // Is there some content? if (empty($newContent)) { // Compiling failed - $newContent = "Compiler error for template {$template}!"; + $newContent = "Compiler error for template {$template}!\nUncompiled content:\n".$tmpl_file; + if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx."; } // END - if // Return compiled content @@ -911,13 +913,13 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { // BEFORE 0.2.1 : Not used // WITH 0.2.1+ : Data constants $code = str_replace('{!','".', str_replace("!}", '."', $code)); - } + } // END - if // Compile QUOT and other non-HTML codes foreach ($ARRAY['to'] as $k => $to) { // Do the reversed thing as in inc/libs/security_functions.php $code = str_replace($to, $ARRAY['from'][$k], $code); - } + } // END - foreach // But shall I keep simple quotes for later use? if ($simple) $code = str_replace("\'", '{QUOT}', $code); @@ -930,22 +932,43 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { // Replace all matches $matchesFound = array(); foreach ($matches[0] as $key => $match) { - // Avoid replacing matches multiple times - if (!isset($matchesFound[$match])) { - // Not yet replaced! - $code = str_replace($match, "\".".$match.".\"", $code); - $matchesFound[$match] = 1; - } // END - if + // Fuzzy look has failed by default + $fuzzyFound = false; + + // Fuzzy look on match if already found + foreach ($matchesFound as $found => $set) { + // Get test part + $test = substr($found, 0, strlen($match)); + + // Does this entry exist? + //* DEBUG: */ echo __FUNCTION__.":found={$found},match={$match},set={$set}
\n"; + if ($test == $match) { + // Match found! + //* DEBUG: */ echo __FUNCTION__.":fuzzyFound!
\n"; + $fuzzyFound = true; + break; + } // END - if + } // END - foreach + + // Skip this entry? + if ($fuzzyFound) continue; // Take all string elements - if ((is_string($matches[4][$key])) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) { + if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) { // Replace it in the code + //* DEBUG: */ echo __FUNCTION__.":key={$key},match={$match}
\n"; $newMatch = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $match); - $code = str_replace($match, $newMatch, $code); + $code = str_replace($match, "\".".$newMatch.".\"", $code); $matchesFound[$key."_".$matches[4][$key]] = 1; - } // END - if - } - } + $matchesFound[$match] = 1; + } elseif (!isset($matchesFound[$match])) { + // Not yet replaced! + //* DEBUG: */ echo __FUNCTION__.":match={$match}
\n"; + $code = str_replace($match, "\".".$match.".\"", $code); + $matchesFound[$match] = 1; + } + } // END - foreach + } // END - if // Return compiled code return $code; diff --git a/inc/language/rallye_de.php b/inc/language/rallye_de.php index 59b58ab416..b877f3a32d 100644 --- a/inc/language/rallye_de.php +++ b/inc/language/rallye_de.php @@ -144,5 +144,7 @@ define('RALLYE_END_PRICES_1', "Die Rallye endet, sobald mindestens"); define('RALLYE_END_PRICES_2', "Plaetze belegt sind!"); define('RALLYE_LIMITATIONS', "Einschränkungen an der Dauer der Rallye"); define('RALLYE_REMOVE_PRICES', "Rallye-Preis(e) entfernen"); +define('RALLYE_NO_TEMPLATES_FOUND', "Keine Templates gefunden!"); + // ?> diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index b77ee5259a..65325e1a69 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -56,10 +56,7 @@ function ADMINS_CHECK_ACL($act, $wht) { $_CONFIG['cache_hits']++; } elseif (!is_object($cacheInstance)) { // Load from database - $result = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array(get_session('admin_login')), __FILE__, __LINE__); - list($default) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $default = GET_ADMIN_DEFAULT_ACL(get_session('admin_login')); } // Get admin's ID @@ -212,16 +209,10 @@ function ADMINS_CHANGE_ADMIN_ACCOUNT($POST) { // Update password cookie set_session("admin_md5", $hash); } - - } + } // END - if // Get default ACL from admin to check if we can allow him to change the default ACL - $result = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array(get_session('admin_login')), __FILE__, __LINE__); - list($default) = SQL_FETCHROW($result); - - // Free result - SQL_FREERESULT($result); + $default = GET_ADMIN_DEFAULT_ACL(get_session('admin_login')); // Update admin account if ($default == "allow") { diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 50881d58eb..796356caca 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -63,23 +63,18 @@ function RALLYE_AUTOSTART_RALLYES($result) $DATA['title'] = $title; $DATA['id'] = $id; // ID for the rallye details link - if ($min_users == 0) - { + if ($min_users == 0) { // Rallye ends without user limitation $DATA['min_users'] = RALLYE_END_NO_USER_LIMITATION; - } - else - { + } else { // Rallye ends when X members are totally in your exchange $DATA['min_users'] = RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2; } - if ($min_prices == 0) - { + + if ($min_prices == 0) { // Rallye ends without user limitation $DATA['min_prices'] = RALLYE_END_NO_PRICE_LIMITATION; - } - else - { + } else { // Rallye ends when X members are totally in your exchange $DATA['min_prices'] = RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2; } @@ -88,8 +83,7 @@ function RALLYE_AUTOSTART_RALLYES($result) $prices = RALLYE_ADD_PRICES($id); // Let's begin with the userids... - while (list($uid) = SQL_FETCHROW($result_user)) - { + while (list($uid) = SQL_FETCHROW($result_user)) { $un = false; // Get refs by userid @@ -99,8 +93,7 @@ function RALLYE_AUTOSTART_RALLYES($result) // Check if line is already included... $result_ref = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s AND userid=%s LIMIT 1", array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result_ref) == 0) - { + if (SQL_NUMROWS($result_ref) == 0) { // Free memory SQL_FREERESULT($result_ref); @@ -118,22 +111,21 @@ WHERE d.status='CONFIRMED' AND d.max_mails > 0 AND d.mails_confirmed >= %s AND p // Add info line $result_ref = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_users (rallye_id, userid, refs, curr_points) -VALUES ('%s', '%s', '%s', '%s')", +VALUES ('%s','%s','%s','%s')", array(bigintval($id), bigintval($uid), bigintval($cnt), $cpoints), __FILE__, __LINE__); $un = true; - } + } // END - if // Ignored but for the template required refs (made before start of rallye) $DATA['refs'] = $cnt; // Shall I notify this member? - if (($notify == "Y") && ($un)) - { + if (($notify == "Y") && ($un)) { // Load email template and send it to the user - $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", $prices, $uid); + $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); SEND_EMAIL($uid, RALLYE_MEMBER_NOTIFY.$title, $msg); - } - } + } // END - if + } // END - while // Choose the right admin template $templ = "admin_rallye_no_notify"; @@ -303,7 +295,7 @@ function RALLYE_AUTOADD_USER($uid) { // Add userid and his ref count to table $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_users (rallye_id, userid, refs) -VALUES ('%s', '%s', '0')", +VALUES ('%s','%s','0')", array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); } else @@ -326,7 +318,7 @@ VALUES ('%s', '%s', '0')", $prices = RALLYE_ADD_PRICES($id); // Send notification to member - $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", $prices, $uid); + $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); SEND_EMAIL($uid, RALLYE_MEMBER_NOTIFY.$title, $msg); } } @@ -402,48 +394,30 @@ LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__); $DATA['info'] = $prices['info'][$key]; $DATA['ref'] = $prices['ref'][$key]; - if ($DATA['points'] > 0) - { + if ($DATA['points'] > 0) { // Add points directly to user's account - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($DATA['points'], bigintval($uid)), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - MEDIA_UPDATE_ENTRY(array("total_points"), "add", $DATA['points']); - } + ADD_POINTS_REFSYSTEM($uid, $DATA['points'], false, "0", false, "direct"); } - if ($notify == "Y") - { + if ($notify == "Y") { // Prepare infos for the mail template - if (!empty($DATA['info'])) - { + if (!empty($DATA['info'])) { // Take direct infos $DATA['infos'] = $DATA['info']; - } - else - { + } else { // Take points $DATA['infos'] = $DATA['points']." ".POINTS; } // Add suffix to template name $template = "member_rallye_expired"; - if ($DATA['level'] == 1) - { + if ($DATA['level'] == 1) { // The winner! $template .= "_gold"; - } - elseif ($DATA['level'] == 2) - { + } elseif ($DATA['level'] == 2) { // The vice winner! $template .= "_silver"; - } - elseif ($DATA['level'] == 3) - { + } elseif ($DATA['level'] == 3) { // The bronce winner $template .= "_bronce"; } @@ -451,7 +425,7 @@ LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__); // Load template $msg = LOAD_EMAIL_TEMPLATE($template, $DATA, $uid); SEND_EMAIL($uid, RALLYE_MEMBER_EXPIRED.": ".$DATA['level']." "._RALLYE_PRICE, $msg); - } + } // END - if // Count userid $cnt++; @@ -461,12 +435,9 @@ LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__); } // Select template depending on notfication is switch on / off - if ($notify == "Y") - { + if ($notify == "Y") { $templ = "admin_rallye_expired"; - } - elseif (is_array($users['uid'])) - { + } elseif (is_array($users['uid'])) { $templ = "admin_rallye_expired_no"; $cnt = RALLYE_LOAD_USER_DATA($users); } @@ -476,7 +447,7 @@ LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__); // Add task $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (status, task_type, subject, text, task_created) -VALUES ('NEW', 'RALLYE_EXPIRED', '".RALLYE_ADMIN_EXPIRED.": %s', '".RALLYE_ADMIN_EXPIRED_TEXT."', UNIX_TIMESTAMP())", +VALUES ('NEW','RALLYE_EXPIRED','".RALLYE_ADMIN_EXPIRED.": %s','".RALLYE_ADMIN_EXPIRED_TEXT."',UNIX_TIMESTAMP())", array($title), __FILE__, __LINE__); // All work done here... @@ -695,7 +666,7 @@ WHERE end_time <= (UNIX_TIMESTAMP() - %s) AND expired='Y'", // Add task $result_task = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (status, task_type, subject, text, task_created) -VALUES ('NEW', 'RALLYE_PURGED', '".RALLYE_ADMIN_PURGED.": %s', '".RALLYE_ADMIN_PURGED_TEXT."', UNIX_TIMESTAMP())", +VALUES ('NEW','RALLYE_PURGED','".RALLYE_ADMIN_PURGED.": %s','".RALLYE_ADMIN_PURGED_TEXT."',UNIX_TIMESTAMP())", array($title), __FILE__, __LINE__); } @@ -707,7 +678,7 @@ function RALLYE_TEMPLATE_SELECTION($name="template", $default="") { // Check templates directory $OUT = ""; $ral = array(); - $BASE = sprintf("%stemplates/%s/html", PATH, GET_LANGUAGE()); + $BASE = sprintf("%stemplates/%s/html/rallye/", PATH, GET_LANGUAGE()); $dir = opendir($BASE); while ($read = readdir($dir)) { diff --git a/inc/load_extensions.php b/inc/load_extensions.php index f804ae6baf..8d69d37d79 100644 --- a/inc/load_extensions.php +++ b/inc/load_extensions.php @@ -70,15 +70,15 @@ if (EXT_IS_ACTIVE("cache")) { // Do not recreate cache file when it's switched off! if (($cacheMode == "init") && ($_CONFIG['cache_exts'] == "N")) $cacheMode = "skip"; - - // Load language - if ($cacheMode == "load") include(PATH."inc/language/cache_".GET_LANGUAGE().".php"); } else { // Cache extension not active $cacheMode = "no"; } if ($cacheMode == "load") { + // Init include array + $EXT_POOL = array(); + // Re-initialize handler $cacheInstance->cache_file("extensions", true); @@ -96,7 +96,10 @@ if ($cacheMode == "load") { // Load Language file if ($EXT_DUMMY['ext_lang'][$k] == "Y") { $INC = sprintf("%sinc/language/%s_%s.php", PATH, $name, GET_LANGUAGE()); - if (FILE_READABLE($INC)) require_once($INC); + if (FILE_READABLE($INC)) { + // Add it + $EXT_POOL[] = $INC; + } } // END - if // Load CSS file @@ -104,7 +107,7 @@ if ($cacheMode == "load") { // Load extension file itself if (($EXT_DUMMY['ext_active'][$k] == "Y") || ($EXT_DUMMY['ext_keep'][$k] == "Y") || (IS_ADMIN())) { - require_once(PATH."inc/extensions/ext-".$name.".php"); + $EXT_POOL[] = sprintf("%sinc/extensions/ext-%s.php", PATH, $name); } // END - if // Version number @@ -154,6 +157,14 @@ if ($cacheMode == "load") { // Load more cache files (like admins) require_once(PATH."inc/load_cache.php"); + + // Load all extension files + foreach ($EXT_POOL as $inc) { + require_once($inc); + } // END - foreach + + // Remove array + unset($EXT_POOL); } else { // If current user is not admin load only activated extensions // The admin shall use every available extension for testing purposes diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 2c3dffea5d..f391b42a8c 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -211,26 +211,10 @@ function LOGIN_ADMIN ($adminLogin, $passHash) { function CHECK_ADMIN_COOKIES ($admin_login, $password) { global $cacheArray, $_CONFIG; $ret = "404"; $pass = ""; - if (!empty($cacheArray['admins']['aid'][$admin_login])) { - // Get password from cache - $pass = $cacheArray['admins']['password'][$admin_login]; - $ret = "pass"; - $_CONFIG['cache_hits']++; - } elseif (GET_EXT_VERSION("cache") == "") { - // Get password from DB - $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array($admin_login), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { - // Entry found - $ret = "pass"; - - // Fetch password - list($pass) = SQL_FETCHROW($result); - } - // Free result - SQL_FREERESULT($result); - } + // Get hash + $pass = GET_ADMIN_HASH($admin_login); + if ($pass != "-1") $ret = "pass"; //* DEBUG: */ echo __FUNCTION__.":".generatePassString($pass)."(".strlen($pass).")/".$password."(".strlen($password).")
\n"; diff --git a/inc/modules/admin/what-add_points.php b/inc/modules/admin/what-add_points.php index cba19d9490..b161fd7f85 100644 --- a/inc/modules/admin/what-add_points.php +++ b/inc/modules/admin/what-add_points.php @@ -59,14 +59,7 @@ if ($_GET['u_id'] == "all") { if ((isset($_POST['ok'])) && (!empty($_POST['points']))) { // Ok, add points and send an email to him... - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+(%s) WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($_POST['points'], bigintval($uid)), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") { - // Update database - MEDIA_UPDATE_ENTRY(array("total_points"), "add", $_POST['points']); - } + ADD_POINTS_REFSYSTEM($uid, bigintval($_POST['points']), false, "0", false, "direct"); // Prepare content $content = array( @@ -101,8 +94,7 @@ if ($_GET['u_id'] == "all") { if ((isset($_POST['ok'])) && (!empty($_POST['points']))) { // Ok, add points and send an email to him... - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+(%s) WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($_POST['points'], bigintval($_GET['u_id'])), __FILE__, __LINE__); + ADD_POINTS_REFSYSTEM(bigintval($_GET['u_id']), bigintval($_POST['points']), false, "0", false, "direct"); // Prepare content $content = array( diff --git a/inc/modules/admin/what-admins_contct.php b/inc/modules/admin/what-admins_contct.php index ca2e84f530..f004def6c3 100644 --- a/inc/modules/admin/what-admins_contct.php +++ b/inc/modules/admin/what-admins_contct.php @@ -40,50 +40,38 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) { // Add description as navigation point ADD_DESCR("admin", basename(__FILE__)); -if ((isset($_POST['ok'])) && (!empty($_GET['admin']))) -{ +if ((isset($_POST['ok'])) && (!empty($_GET['admin']))) { // Send mail or message - if ((EXT_IS_ACTIVE("msg")) && ($_POST['type'] == "msg")) - { + if ((EXT_IS_ACTIVE("msg")) && ($_POST['type'] == "msg")) { // Add message $msg = LOAD_EMAIL_TEMPLATE("admins_msg_contct_admin", $_POST['text'], "0"); SEND_ADMIN_MESSAGE($_GET['admin'], ADMINS_MSG_FROM_ADMIN, $msg); - } - else - { + } else { // Load admin's email address - $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", - array(bigintval($_GET['admin'])), __FILE__, __LINE__); - list($email) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $email = GET_ADMIN_EMAIL(GET_ADMIN_LOGIN(bigintval($_GET['admin']))); // Load email template and send the mail to the admin $msg = LOAD_EMAIL_TEMPLATE("admins_mail_contct_admin", $_POST['text'], "0"); SEND_EMAIL($email, ADMINS_MSG_FROM_ADMIN, $msg); } + // Mail / message dropped LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_ADMIN_CONTACTED); -} - elseif (!empty($_GET['admin'])) -{ +} elseif (!empty($_GET['admin'])) { // Load contact form template define('__ADMIN', $_GET['admin']); - if (EXT_IS_ACTIVE("msg")) - { + if (EXT_IS_ACTIVE("msg")) { // Add option to select between mail and message define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_select", true)); - } - else - { + } else { // Outout hidden input define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_default", true)); } LOAD_TEMPLATE("admin_admins_contct_form"); -} - else -{ +} else { // Please select an admin! LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_SELECT_ADMIN); } + // ?> diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index 2ab08abfae..c1bf5539c5 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -160,10 +160,7 @@ if ((isset($_POST['edit'])) && ($SEL > 0)) { LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ADMINS_ENTRIES_DELETED); } elseif (isset($_POST['add'])) { // Check if everything is fine... - $result = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", - array(bigintval($_POST['admin_id'])), __FILE__, __LINE__); - list($mode) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $mode = GET_ADMIN_DEFAULT_ACL(GET_ADMIN_LOGIN(bigintval($_POST['admin_id']))); // Default ACL is false $ACL = false; diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php index c919881b83..98a72076ad 100644 --- a/inc/modules/admin/what-unlock_sponsor.php +++ b/inc/modules/admin/what-unlock_sponsor.php @@ -66,13 +66,7 @@ ORDER BY sp.pay_name", $aid = SPONSOR_NO_ADMIN; } else { // Load admin's email address for contact - $result_aid = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id='%s' LIMIT 1", - array(bigintval($aid)), __FILE__, __LINE__); - list($aid) = SQL_FETCHROW($result_aid); - SQL_FREERESULT($result_aid); - - // Check if admin login is still in db - if (empty($aid)) $aid = ADMIN_NOT_FOUND; + $aid = GET_ADMIN_EMAIL(GET_ADMIN_LOGIN(($aid)); } // Transfer data to array diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index 8dd49ab5b8..ce4d26c8b7 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -201,8 +201,7 @@ case "new": // Start new transfer __FILE__, __LINE__); // Add points to account *directly* ... - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s WHERE userid=%s AND ref_depth=0 LIMIT 1", - array(bigintval($_POST['points']), bigintval($_POST['to_uid'])), __FILE__, __LINE__); + ADD_POINTS_REFSYSTEM(bigintval($_POST['to_uid']), bigintval($_POST['points']), false, "0", false, "direct"); // ... and add it to current user's used points SUB_POINTS($GLOBALS['userid'], $_POST['points']); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 50fcf10742..717865cbaa 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1353,13 +1353,15 @@ function SEND_ADMIN_EMAILS($subj, $msg) { } // Get ID number from administrator's login name function GET_ADMIN_ID($login) { - global $cacheArray; + global $cacheArray, $_CONFIG; $ret = "-1"; if (!empty($cacheArray['admins']['aid'][$login])) { // Check cache $ret = $cacheArray['admins']['aid'][$login]; - if (empty($ret)) $ret = "-1"; - } else { + + // Update cache hits + $_CONFIG['cache_hits']++; + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", array($login), __FILE__, __LINE__); @@ -1376,54 +1378,118 @@ function GET_ADMIN_ID($login) { // Get password hash from administrator's login name function GET_ADMIN_HASH($login) { - global $cacheArray; + global $cacheArray, $_CONFIG; $ret = "-1"; - if (!empty($cacheArray['admins']['password'][$login])) - { + if (!empty($cacheArray['admins']['password'][$login])) { // Check cache $ret = $cacheArray['admins']['password'][$login]; - if (empty($ret)) $ret = "-1"; - } - else - { + + // Update cache hits + $_CONFIG['cache_hits']++; + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", array($login), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { + // Fetch data list($ret) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + + // Set cache + $cacheArray['admins']['password'][$login] = $ret; } + + // Free result + SQL_FREERESULT($result); } return $ret; } // function GET_ADMIN_LOGIN ($aid) { - global $cacheArray; + global $cacheArray, $_CONFIG; $ret = "***"; - if (!empty($cacheArray['admins']['login'])) { - // Check cache - if (!empty($cacheArray['admins']['login'][$aid])) { - $ret = $cacheArray['admins']['login'][$aid]; - } // END - if - if (empty($ret)) $ret = "***"; - } else { + if (!empty($cacheArray['admins']['login'][$aid])) { + // Get cache + $ret = $cacheArray['admins']['login'][$aid]; + + // Update cache hits + $_CONFIG['cache_hits']++; + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT login FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", - array(bigintval($aid)), __FILE__, __LINE__); + array(bigintval($aid)), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Fetch data list($ret) = SQL_FETCHROW($result); // Set cache $cacheArray['admins']['login'][$aid] = $ret; - } + } // END - if // Free memory SQL_FREERESULT($result); } return $ret; } +// Get email address of admin id +function GET_ADMIN_EMAIL ($aid) { + global $cacheArray, $_CONFIG; + + $ret = "***"; + if (!empty($cacheArray['admins']['email'])) { + // Get cache + $ret = $cacheArray['admins']['email'][$aid]; + + // Update cache hits + $_CONFIG['cache_hits']++; + } elseif (!EXT_IS_ACTIVE("cache")) { + // Load from database + $result_aid = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array(bigintval($ret)), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Get data + list($ret) = SQL_FETCHROW($result_aid); + + // Set cache + $cacheArray['admins']['email'][$aid] = $ret; + } // END - if + + // Free result + SQL_FREERESULT($result_aid); + } + + // Return email + return $ret; +} +// Get default ACL of admin id +function GET_ADMIN_DEFAULT_ACL ($aid) { + global $cacheArray, $_CONFIG; + + $ret = "***"; + if (!empty($cacheArray['admins']['def_acl'])) { + // Use cache + $ret = $cacheArray['admins']['def_acl'][$aid]; + + // Update cache hits + $_CONFIG['cache_hits']++; + } else { + // Load from database + $result_aid = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array(bigintval($ret)), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Fetch data + list($ret) = SQL_FETCHROW($result_aid); + + // Set cache + $cacheArray['admins']['def_acl'][$aid] = $ret; + } + + // Free result + SQL_FREERESULT($result_aid); + } + + // Return email + return $ret; +} // function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") { $ret = ""; @@ -1435,8 +1501,8 @@ function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") $ret .= "\n"; - } + } // END - while // Free memory SQL_FREERESULT($result); @@ -1466,7 +1532,7 @@ function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") // Return - hopefully - the requested data return $ret; } -// Aiut +// Activate exchange (DEPERECATED???) function activateExchange() { global $_CONFIG; $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__); diff --git a/inc/pool-update.php b/inc/pool-update.php index 3c6015d66c..6f1fc8f9f9 100644 --- a/inc/pool-update.php +++ b/inc/pool-update.php @@ -275,16 +275,7 @@ if (SQL_NUMROWS($result_main) > 0) { // User does not exists, pay points back $points = GET_PAY_POINTS($DATA[5]); - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($points, bigintval($DATA[1])), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - //* DEBUG: */ echo "*MEDIA/L:".__LINE__."/".$points."*
"; - MEDIA_UPDATE_ENTRY(array("total_points"), "add", $points); - } + ADD_POINTS_REFSYSTEM($DATA[1], $points, false, "0", false, "direct"); // Add points together and remove user $points_BACK[$DATA[1]] += $points; diff --git a/templates/de/emails/beg/beg_di_notify.tpl b/templates/de/emails/beg/beg_di_notify.tpl index 673bbefed4..84f2effe68 100644 --- a/templates/de/emails/beg/beg_di_notify.tpl +++ b/templates/de/emails/beg/beg_di_notify.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $UID diff --git a/templates/de/emails/beg/beg_en_notify.tpl b/templates/de/emails/beg/beg_en_notify.tpl index ef0aed69a8..546f203f63 100644 --- a/templates/de/emails/beg/beg_en_notify.tpl +++ b/templates/de/emails/beg/beg_en_notify.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $UID diff --git a/templates/de/emails/bonus/bonus_di_notify.tpl b/templates/de/emails/bonus/bonus_di_notify.tpl index 99ba18dfb7..c143dc1476 100644 --- a/templates/de/emails/bonus/bonus_di_notify.tpl +++ b/templates/de/emails/bonus/bonus_di_notify.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $UID diff --git a/templates/de/emails/bonus/bonus_en_notify.tpl b/templates/de/emails/bonus/bonus_en_notify.tpl index fd1d6538c9..198a204d54 100644 --- a/templates/de/emails/bonus/bonus_en_notify.tpl +++ b/templates/de/emails/bonus/bonus_en_notify.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $UID diff --git a/templates/de/emails/member/member_contct.tpl b/templates/de/emails/member/member_contct.tpl index bc6590d30d..e560adb66a 100644 --- a/templates/de/emails/member/member_contct.tpl +++ b/templates/de/emails/member/member_contct.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $content[u_id] diff --git a/templates/de/emails/member/member_rallye_notify.tpl b/templates/de/emails/member/member_rallye_notify.tpl index 345b645a7b..b399fc2ca9 100644 --- a/templates/de/emails/member/member_rallye_notify.tpl +++ b/templates/de/emails/member/member_rallye_notify.tpl @@ -1,4 +1,4 @@ -Hallo $content[surname] $content[family], +Hallo $content[gender] $content[surname] $content[family], ------------------------------ Ihre Mitglied-ID lautet: $UID @@ -14,7 +14,7 @@ Beginn der Rallye: $DATA[start] Uhr Ende der Rallye: $DATA[end] Uhr Server-Zeit: $DATA[now_t] Uhr ------------------------------ -$content +$content[prices] Ihr Werbelink zum Werben neuer Mitglieder: {!URL!}/ref.php?refid=$UID ------------------------------