Template fixes, lesser admin data will be loaded from database
authorRoland Häder <roland@mxchange.org>
Sat, 27 Sep 2008 15:05:59 +0000 (15:05 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 27 Sep 2008 15:05:59 +0000 (15:05 +0000)
21 files changed:
inc/databases.php
inc/doubler_send.php
inc/functions.php
inc/language/rallye_de.php
inc/libs/admins_functions.php
inc/libs/rallye_functions.php
inc/load_extensions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-add_points.php
inc/modules/admin/what-admins_contct.php
inc/modules/admin/what-config_admins.php
inc/modules/admin/what-unlock_sponsor.php
inc/modules/member/what-transfer.php
inc/mysql-manager.php
inc/pool-update.php
templates/de/emails/beg/beg_di_notify.tpl
templates/de/emails/beg/beg_en_notify.tpl
templates/de/emails/bonus/bonus_di_notify.tpl
templates/de/emails/bonus/bonus_en_notify.tpl
templates/de/emails/member/member_contct.tpl
templates/de/emails/member/member_rallye_notify.tpl

index 790f3a75089757f713c1d4a75f74d2fc5bbc4c15..6863d5fba90c7c2a3834e7bb6b037927de977008 100644 (file)
@@ -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);
index 782af6b03d47df7831bb768271ba951429a36918..a148c206f0c757be65c6b25842a574d8184b50f9 100644 (file)
@@ -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",
index 3cdcf706954d99018397dba1f6d6ee480f3508cd..3a8bf9c0fd2ba9fea5fbcb95a8ca53ff19e67ecf 100644 (file)
@@ -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!<br />\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."<br />
@@ -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}<br />\n";
+                               if ($test == $match) {
+                                       // Match found!
+                                       //* DEBUG: */ echo __FUNCTION__.":fuzzyFound!<br />\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}<br />\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}<br />\n";
+                               $code = str_replace($match, "\".".$match.".\"", $code);
+                               $matchesFound[$match] = 1;
+                       }
+               } // END - foreach
+       } // END - if
 
        // Return compiled code
        return $code;
index 59b58ab416cb7d12dca5df516faa9841a426dce4..b877f3a32dac19a39bb3605a4eafb9e345618678 100644 (file)
@@ -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&auml;nkungen an der Dauer der Rallye");
 define('RALLYE_REMOVE_PRICES', "Rallye-Preis(e) entfernen");
+define('RALLYE_NO_TEMPLATES_FOUND', "Keine Templates gefunden!");
+
 //
 ?>
index b77ee5259a592a2fb2d8046279659f7bae0f5ab6..65325e1a698ca1b755a5a82b27e9e2038d9be255 100644 (file)
@@ -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") {
index 50881d58eb96dee6d1b3977279978ed8f190b9db..796356caca854116dba09c067d42782580e5ed4c 100644 (file)
@@ -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))
        {
index f804ae6baf432de38bee76b823bffd488ccc387a..8d69d37d79da508a1975e1a91517c32bedacd45d 100644 (file)
@@ -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
index 2c3dffea5de11a272b5ec64479ecffef55512608..f391b42a8c16bf03071cd51cab8f69b7ebaa0276 100644 (file)
@@ -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).")<br />\n";
 
index cba19d94902ce397ab96d1ff849d26056afbfc1f..b161fd7f854f21e3c0d80a5c10513eed9445bb5b 100644 (file)
@@ -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(
index ca2e84f5301556f785f7fb2189f8d1e2cab9f3f0..f004def6c3b6fa626401292792f1382d2a9718fe 100644 (file)
@@ -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);
 }
+
 //
 ?>
index 2ab08abfae87d3bae9d2f0be2313aa796e378e73..c1bf5539c5d020a7c53d21ff90070b06b4b10fa9 100644 (file)
@@ -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;
index c919881b8363cd6570a24be503b290a93868cf41..98a72076ad5f4336ccc1ad4402fd682691a945cf 100644 (file)
@@ -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
index 8dd49ab5b81a3064672295cf4f234606a11cea90..ce4d26c8b7ad49051c01d4ee05d7cd8829c20580 100644 (file)
@@ -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']);
index 50fcf10742eb1d5cbb23471f06f910aa1e732c3f..717865cbaaec5e2767ff6afeb1b349cff605c481 100644 (file)
@@ -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 .= "<OPTION value=\"".$value."\"";
                                if ($default == $value) $ret .= " selected checked";
                                $ret .= ">".$name[$idx]."</OPTION>\n";
-                       }
-               }
+                       } // END - foreach
+               } // END - if
        } else {
                // Data from database
                $SPEC = ", ".$id;
@@ -1453,7 +1519,7 @@ function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="")
                                if ($default == $value) $ret .= " selected checked";
                                if (!empty($add)) $add = " (".$add.")";
                                $ret .= ">".$title.$add."</OPTION>\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__);
index 3c6015d66cb524dff7927666fc7c5836b1d13a12..6f1fc8f9f90a89988d918316f2dd3c3d0c574254 100644 (file)
@@ -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."*<br />";
-                                                               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;
index 673bbefed4d282606d743009d24f958ea81d4b44..84f2effe6855bbbf112ce1110ea6952d17eaed73 100644 (file)
@@ -1,4 +1,4 @@
-Hallo $content[surname] $content[family],
+Hallo $content[gender] $content[surname] $content[family],
 
 ------------------------------
 Ihre Mitglied-ID lautet: $UID
index ef0aed69a8b03aa46732ca4a5567e012758f339e..546f203f639164dab130fc141e46857df77b24a1 100644 (file)
@@ -1,4 +1,4 @@
-Hallo $content[surname] $content[family],
+Hallo $content[gender] $content[surname] $content[family],
 
 ------------------------------
 Ihre Mitglied-ID lautet: $UID
index 99ba18dfb70e579df39dc501c2c9a05572895fa1..c143dc1476ad7cd1982d79b3eb14faac72c23617 100644 (file)
@@ -1,4 +1,4 @@
-Hallo $content[surname] $content[family],
+Hallo $content[gender] $content[surname] $content[family],
 
 ------------------------------
 Ihre Mitglied-ID lautet: $UID
index fd1d6538c9a564655a003cecbc668db325f2506a..198a204d54cfde8ae7f5c82376ad578ff91e16f5 100644 (file)
@@ -1,4 +1,4 @@
-Hallo $content[surname] $content[family],
+Hallo $content[gender] $content[surname] $content[family],
 
 ------------------------------
 Ihre Mitglied-ID lautet: $UID
index bc6590d30d4580732c860a0da8b6ca2a1363013f..e560adb66a5f2ad57ced5e503175f59a7a267717 100644 (file)
@@ -1,4 +1,4 @@
-Hallo $content[surname] $content[family],
+Hallo $content[gender] $content[surname] $content[family],
 
 ------------------------------
 Ihre Mitglied-ID lautet: $content[u_id]
index 345b645a7bb746b9da516c8f9a3b74447486eff7..b399fc2ca929d001d09f59a5c46c9c9b985d8a15 100644 (file)
@@ -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
 ------------------------------