X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=6d414a53865611bdec27ee2af04646c29c66fff6;hb=af59daf6541b279989547829c95adc5bee8ca11d;hp=a55dda49c181db6def6913bd2a896880de657fb4;hpb=9741be1a19dd09fe6a5b4f7c92e2b2d57399bd21;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index a55dda49c1..6d414a5386 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -62,7 +62,7 @@ function IS_INC_WRITEABLE($inc) { // Output HTML code directly or "render" it. You addionally switch the new-line character off function OUTPUT_HTML ($HTML, $newLine = true) { // Some global variables - global $OUTPUT, $footer, $CSS; + global $OUTPUT; // Do we have HTML-Code here? if (!empty($HTML)) { @@ -101,7 +101,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { mxchange_die("{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); break; } - } elseif ((constant('_OB_CACHING') == "on") && ($footer == 1)) { + } elseif ((constant('_OB_CACHING') == "on") && ($GLOBALS['footer_sent'] == 1)) { // Headers already sent? if (headers_sent()) { // Log this error @@ -131,7 +131,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { header("Connection: Close"); // Extension "rewrite" installed? - if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -154,7 +154,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { OUTPUT_RAW($OUTPUT); } elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) { // Rewrite links when rewrite extension is active - if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -181,10 +181,13 @@ function OUTPUT_RAW ($HTML) { } // END - if } +// Init fatal message array +function initFatalMessages () { + $GLOBALS['fatal_messages'] = array(); +} + // Add a fatal error message to the queue array function addFatalMessage ($message, $extra="") { - global $FATAL; - if (is_array($extra)) { // Multiple extras for a message with masks $message = call_user_func_array('sprintf', $extra); @@ -193,8 +196,8 @@ function addFatalMessage ($message, $extra="") { $message = sprintf($message, $extra); } - // Add message to $FATAL - $FATAL[] = $message; + // Add message to $GLOBALS['fatal_messages'] + $GLOBALS['fatal_messages'][] = $message; // Log fatal messages away DEBUG_LOG(__FUNCTION__, __LINE__, " message={$message}"); @@ -202,15 +205,13 @@ function addFatalMessage ($message, $extra="") { // Getter for total fatal message count function getTotalFatalErrors () { - global $FATAL; - // Init coun $count = 0; // Do we have at least the first entry? - if (!empty($FATAL[0])) { + if (!empty($GLOBALS['fatal_messages'][0])) { // Get total count - $count = count($FATAL); + $count = count($GLOBALS['fatal_messages']); } // END - if // Return value @@ -703,8 +704,6 @@ function TRANSLATE_STATUS ($status) { } // function GET_LANGUAGE() { - global $cacheArray; - // Set default return value to default language from config $ret = constant('DEFAULT_LANG'); @@ -712,12 +711,12 @@ function GET_LANGUAGE() { $lang = ""; // Is the variable set - if (!empty($_GET['mx_lang'])) { + if (REQUEST_ISSET_GET(('mx_lang'))) { // Accept only first 2 chars - $lang = substr($_GET['mx_lang'], 0, 2); - } elseif (isset($cacheArray['language'])) { + $lang = substr(REQUEST_GET('mx_lang'), 0, 2); + } elseif (isset($GLOBALS['cache_array']['language'])) { // Use cached - $ret = $cacheArray['language']; + $ret = $GLOBALS['cache_array']['language']; } elseif (!empty($lang)) { // Check if main language file does exist if (FILE_READABLE(constant('PATH')."inc/language/".$lang.".php")) { @@ -733,7 +732,7 @@ function GET_LANGUAGE() { } // Cache entry - $cacheArray['language'] = $ret; + $GLOBALS['cache_array']['language'] = $ret; // Return value return $ret; @@ -748,7 +747,7 @@ function SET_LANGUAGE ($lang) { } // function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { - global $DATA, $REPLACER, $_CONFIG; + global $DATA, $_CONFIG; // Make sure all template names are lowercase! $template = strtolower($template); @@ -908,8 +907,6 @@ function MAKE_TIME($H, $M, $S, $stamp) { } // function LOAD_URL($URL, $addUrlData=true) { - global $CSS, $footer; - // Compile out URI codes $URL = compileUriCode($URL); @@ -968,17 +965,16 @@ function LOAD_CONFIGURED_URL ($configEntry) { // function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { - global $SEC_CHARS, $URL_CHARS; // Is the code a string? if (!is_string($code)) { // Silently return it return $code; } // END - if - $ARRAY = $SEC_CHARS; + $ARRAY = $GLOBALS['security_chars']; // Select smaller set of chars to replace when we e.g. want to compile URLs - if (!$full) $ARRAY = $URL_CHARS; + if (!$full) $ARRAY = $GLOBALS['url_chars']; // Compile constants if ($constants) { @@ -1309,11 +1305,11 @@ function bigintval($num, $castValue = true) { } // Insert the code in $img_code into jpeg or PNG image -function GENERATE_IMAGE ($img_code, $header=true) { +function GENERATE_IMAGE ($img_code, $headerSent=true) { if ((strlen($img_code) > 6) || (empty($img_code)) || (getConfig('code_length') == 0)) { // Stop execution of function here because of over-sized code length return; - } elseif (!$header) { + } elseif (!$headerSent) { // Return in an HTML code code return "\"Image\"\n"; } @@ -1681,7 +1677,7 @@ function ADD_EMAIL_NAV($PAGES, $offset, $show_form, $colspan, $return=false) { $NAV = ""; for ($page = 1; $page <= $PAGES; $page++) { // Is the page currently selected or shall we generate a link to it? - if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) { + if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET(('page'))) && ($page == "1"))) { // Is currently selected, so only highlight it $NAV .= "-"; } else { @@ -1689,13 +1685,13 @@ function ADD_EMAIL_NAV($PAGES, $offset, $show_form, $colspan, $return=false) { $NAV .= " 0)) $NAV .= "&u_id=".bigintval($_GET['u_id']); + if ((REQUEST_ISSET_GET(('uid'))) && (bigintval(REQUEST_GET('uid')) > 0)) $NAV .= "&uid=".bigintval(REQUEST_GET('uid')); // Close open anchor tag $NAV .= "\">"; } $NAV .= $page; - if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) { + if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET(('page'))) && ($page == "1"))) { // Is currently selected, so only highlight it $NAV .= "-"; } else { @@ -1978,7 +1974,7 @@ function MEMBER_ACTION_LINKS ($uid, $status = "") { $eval = "\$OUT = \"[ "; foreach ($TARGETS as $tar) { - $eval .= "\n"; if (($tar == "lock_user") && ($status == "LOCKED")) { // Locked accounts shall be unlocked @@ -2176,9 +2172,9 @@ function ADD_URL_DATA ($URL) { if ((!defined('__COOKIES')) || ((!__COOKIES))) { // Cookies are not accepted - if ((!empty($_GET['refid'])) && (strpos($URL, "refid=") == 0)) { + if ((REQUEST_ISSET_GET(('refid'))) && (strpos($URL, "refid=") == 0)) { // Cookie found in URL - $ADD .= $BIND."refid=".bigintval($_GET['refid']); + $ADD .= $BIND."refid=".bigintval(REQUEST_GET('refid')); } elseif ((GET_EXT_VERSION("sql_patches") != '') && (getConfig('def_refid') > 0)) { // Not found! So let's set default here $ADD .= $BIND."refid=".getConfig('def_refid'); @@ -2286,59 +2282,24 @@ function DISPLAY_PARSING_TIME_FOOTER() { LOAD_TEMPLATE("show_timings", false, $content); } -// Unset/set session variables -function set_session ($var, $value) { - global $CSS; - - // Abort in CSS mode here - if ($CSS == 1) return true; - - // Trim value and session variable - $var = trim(SQL_ESCAPE($var)); $value = trim($value); - - // Is the session variable set? - if (("".$value."" == "") && (isSessionVariableSet($var))) { - // Remove the session - //* DEBUG: */ echo "UNSET:".$var."=".get_session($var)."
\n"; - unset($_SESSION[$var]); - return session_unregister($var); - } elseif (("".$value."" != '') && (!isSessionVariableSet($var))) { - // Set session - //* DEBUG: */ echo "SET:".$var."=".$value."
\n"; - $_SESSION[$var] = $value; - return session_register($var); - } elseif (!empty($value)) { - // Update session - //* DEBUG: */ echo "UPDATE:".$var."=".$value."
\n"; - $_SESSION[$var] = $value; - return true; - } - - // Ignored (but valid) - //* DEBUG: */ echo "IGNORED:".$var."=".$value."
\n"; - return true; -} - // Check wether a boolean constant is set // Taken from user comments in PHP documentation for function constant() function isBooleanConstantAndTrue($constName) { // : Boolean - global $cacheArray; - // Failed by default $res = false; // In cache? - if (isset($cacheArray['const'][$constName])) { + if (isset($GLOBALS['cache_array']['const'][$constName])) { // Use cache //* DEBUG: */ print __FUNCTION__."(".__LINE__."): ".$constName."-CACHE!
\n"; - $res = $cacheArray['const'][$constName]; + $res = $GLOBALS['cache_array']['const'][$constName]; } else { // Check constant //* DEBUG: */ print __FUNCTION__."(".__LINE__."): ".$constName."-RESOLVE!
\n"; if (defined($constName)) $res = (constant($constName) === true); // Set cache - $cacheArray['const'][$constName] = $res; + $GLOBALS['cache_array']['const'][$constName] = $res; } //* DEBUG: */ var_dump($res); @@ -2346,569 +2307,12 @@ function isBooleanConstantAndTrue($constName) { // : Boolean return $res; } -// Check wether a session variable is set -function isSessionVariableSet ($var) { - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):var={$var}
\n"; - return (isset($_SESSION[$var])); -} -// Returns wether the value of the session variable or NULL if not set -function get_session ($var) { - global $cacheArray; - - // Default is not found! ;-) - $value = null; - - // Is the variable there or cached values? - if (isset($cacheArray['session'][$var])) { - // Get cached value (skips a lot SQL_ESCAPE() calles! - //* DEBUG: */ print __FUNCTION__."(".__LINE__."): ".$var."-CACHE!
\n"; - $value = $cacheArray['session'][$var]; - } elseif (isSessionVariableSet($var)) { - // Then get it secured! - //* DEBUG: */ print __FUNCTION__."(".__LINE__."): ".$var."-RESOLVE!
\n"; - $value = SQL_ESCAPE($_SESSION[$var]); - - // Cache the value - $cacheArray['session'][$var] = $value; - } // END - if - - // Return the value - return $value; -} - -// Send notification to admin -function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid="0") { - if (GET_EXT_VERSION("admins") >= "0.4.1") { - // Send new way - SEND_ADMIN_EMAILS_PRO($subject, $templateName, $content, $uid); - } else { - // Send outdated way - $msg = LOAD_EMAIL_TEMPLATE($templateName, $content, $uid); - SEND_ADMIN_EMAILS($subject, $msg); - } -} - -// Destroy user session -function destroy_user_session () { - // Reset userid - $GLOBALS['userid'] = 0; - - // Remove all user data from session - return ((set_session('userid', "")) && (set_session('u_hash', ""))); -} - -// Merges an array together but only if both are arrays -function merge_array ($array1, $array2) { - // Are both an array? - if ((is_array($array1)) && (is_array($array2))) { - // Merge all together - return array_merge($array1, $array2); - } elseif (is_array($array1)) { - // Return left array - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2))); - return $array1; - } elseif (is_array($array2)) { - // Return right array - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1))); - return $array2; - } - - // Both are not arrays - debug_report_bug(__FUNCTION__.": No arrays provided!"); -} - -// Debug message logger -function DEBUG_LOG ($funcFile, $line, $message, $force=true) { - // Is debug mode enabled? - if ((isBooleanConstantAndTrue('DEBUG_MODE')) || ($force === true)) { - // Log this message away - $fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or mxchange_die("Cannot write logfile debug.log!"); - fwrite($fp, date("d.m.Y|H:i:s", time())."|".basename($funcFile)."|".$line."|".strip_tags($message)."\n"); - fclose($fp); - } // END - if -} - -// Reads a directory with PHP files in and gets only files back -function GET_DIR_AS_ARRAY ($baseDir, $prefix) { - $INCs = array(); - - // Open directory - $dirPointer = opendir($baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!"); - - // Read all entries - while ($baseFile = readdir($dirPointer)) { - // Load file only if extension is active - // Make full path - $FQFN = $baseDir.$baseFile; - - // Is this a valid reset file? - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}
\n"; - if ((FILE_READABLE($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { - // Remove both for extension name - $extName = substr($baseFile, strlen($prefix), -4); - - // Try to find it - $extId = GET_EXT_ID($extName); - - // Is the extension valid and active? - if (($extId > 0) && (EXT_IS_ACTIVE($extName))) { - // Then add this file - $INCs[] = $FQFN; - } elseif ($extId == 0) { - // Add non-extension files as well - $INCs[] = $FQFN; - } - } // END - if - } // END - while - - // Close directory - closedir($dirPointer); - - // Sort array - asort($INCs); - - // Return array with include files - return $INCs; -} -// Load more reset scripts -function RESET_ADD_INCLUDES () { - // Is the reset set or old sql_patches? - if ((!defined('__DAILY_RESET')) || (EXT_VERSION_IS_OLDER("sql_patches", "0.4.5"))) { - // Then abort here - return array(); - } // END - if - - // Get more daily reset scripts - $INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/reset/", "reset_"); - - // Update database - if (!defined('DEBUG_RESET')) UPDATE_CONFIG("last_update", time()); - - // Create current week mark - $currWeek = date("W", time()); - - // Has it changed? - if (getConfig('last_week') != $currWeek) { - // Include weekly reset scripts - $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/weekly/", "weekly_")); - - // Update config - if (!defined('DEBUG_WEEKLY')) UPDATE_CONFIG("last_week", $currWeek); - } // END - if - - // Create current month mark - $currMonth = date("m", time()); - - // Has it changed? - if (getConfig('last_month') != $currMonth) { - // Include monthly reset scripts - $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/monthly/", "monthly_")); - - // Update config - if (!defined('DEBUG_MONTHLY')) UPDATE_CONFIG("last_month", $currMonth); - } // END - if - - // Return array - return $INC_POOL; -} -// Handle extra values -function HANDLE_EXTRA_VALUES ($filterFunction, $value, $extraValue) { - // Default is the value itself - $ret = $value; - - // Do we have a special filter function? - if (!empty($filterFunction)) { - // Does the filter function exist? - if (function_exists($filterFunction)) { - // Do we have extra parameters here? - if (!empty($extraValue)) { - // Put both parameters in one new array by default - $args = array($value, $extraValue); - - // If we have an array simply use it and pre-extend it with our value - if (is_array($extraValue)) { - // Make the new args array - $args = merge_array(array($value), $extraValue); - } // END - if - - // Call the multi-parameter call-back - $ret = call_user_func_array($filterFunction, $args); - } else { - // One parameter call - $ret = call_user_func($filterFunction, $value); - } - } // END - if - } // END - if - - // Return the value - return $ret; -} -// Check if given FQFN is a readable file -function FILE_READABLE($fqfn) { - // Check all... - return ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))); -} -// Converts timestamp selections into a timestamp -function CONVERT_SELECTIONS_TO_TIMESTAMP(&$POST, &$DATA, &$id, &$skip) { - // Init test variable - $test2 = ""; - - // Get last three chars - $test = substr($id, -3); - - // Improved way of checking! :-) - if (in_array($test, array("_ye", "_mo", "_we", "_da", "_ho", "_mi", "_se"))) { - // Found a multi-selection for timings? - $test = substr($id, 0, -3); - if ((isset($POST[$test."_ye"])) && (isset($POST[$test."_mo"])) && (isset($POST[$test."_we"])) && (isset($POST[$test."_da"])) && (isset($POST[$test."_ho"])) && (isset($POST[$test."_mi"])) && (isset($POST[$test."_se"])) && ($test != $test2)) { - // Generate timestamp - $POST[$test] = CREATE_TIMESTAMP_FROM_SELECTIONS($test, $POST); - $DATA[] = sprintf("%s='%s'", $test, $POST[$test]); - - // Remove data from array - foreach (array("ye", "mo", "we", "da", "ho", "mi", "se") as $rem) { - unset($POST[$test."_".$rem]); - } // END - foreach - - // Skip adding - unset($id); $skip = true; $test2 = $test; - } // END - if - } else { - // Process this entry - $skip = false; $test2 = ""; - } -} -// Reverts the german decimal comma into Computer decimal dot -function REVERT_COMMA ($str) { - // Default float is not a float... ;-) - $float = false; - - // Which language is selected? - switch (GET_LANGUAGE()) { - case "de": // German language - // Remove german thousand dots first - $str = str_replace(".", "", $str); - - // Replace german commata with decimal dot and cast it - $float = (float)str_replace(",", ".", $str); - break; - - default: // US and so on - // Remove thousand dots first and cast - $float = (float)str_replace(",", "", $str); - break; - } - - // Return float - return $float; -} - -// Handle menu-depending failed logins and return the rendered content -function HANDLE_LOGIN_FAILTURES ($accessLevel) { - // Default output is empty ;-) - $OUT = ""; - - // Is the session data set? - if ((isSessionVariableSet('mxchange_'.$accessLevel.'_failures')) && (isSessionVariableSet('mxchange_'.$accessLevel.'_last_fail'))) { - // Ignore zero values - if (get_session('mxchange_'.$accessLevel.'_failures') > 0) { - // Non-guest has login failures found, get both data and prepare it for template - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):accessLevel={$accessLevel}
\n"; - $content = array( - 'login_failures' => get_session('mxchange_'.$accessLevel.'_failures'), - 'last_failure' => MAKE_DATETIME(get_session('mxchange_'.$accessLevel.'_last_fail'), "2") - ); - - // Load template - $OUT = LOAD_TEMPLATE("login_failures", true, $content); - } // END - if - - // Reset session data - set_session('mxchange_'.$accessLevel.'_failures', ""); - set_session('mxchange_'.$accessLevel.'_last_fail', ""); - } // END - if - - // Return rendered content - return $OUT; -} - -// Rebuild cache -function REBUILD_CACHE ($cache, $inc="") { - global $cacheInstance, $CSS; - - // Shall I remove the cache file? - if ((EXT_IS_ACTIVE("cache")) && (is_object($cacheInstance))) { - // Rebuild cache - if ($cacheInstance->loadCacheFile($cache)) { - // Destroy it - $cacheInstance->destroyCacheFile(); - } // END - if - - // Include file given? - if (!empty($inc)) { - // Construct FQFN - $INC = sprintf("inc/loader/load_cache-%s.php", $inc); - - // Is the include there? - if (INCLUDE_READABLE($INC)) { - // And rebuild it from scratch - //* DEBUG: */ print __FUNCTION__."(".__LINE__."): inc={$inc} - LOADED!
\n"; - LOAD_INC($INC); - } else { - // Include not found! - DEBUG_LOG(__FUNCTION__, __LINE__, "Include {$inc} not found. cache={$cache}"); - } - } // END - if - } // END - if -} - -// Purge admin menu cache -function CACHE_PURGE_ADMIN_MENU ($id=0, $action="", $what="", $str="") { - global $cacheInstance; - - // Is the cache extension enabled or no cache instance or admin menu cache disabled? - if (!EXT_IS_ACTIVE("cache")) { - // Cache extension not active - return false; - } elseif (!is_object($cacheInstance)) { - // No cache instance! - DEBUG_LOG(__FUNCTION__, __LINE__, " No cache instance found."); - return false; - } elseif ((!isConfigEntrySet('cache_admin_menu')) || (getConfig('cache_admin_menu') != "Y")) { - // Caching disabled (currently experiemental!) - return false; - } - - // Experiemental feature! - debug_report_bug("Experimental feature: You have to delete the admin_*.cache files by yourself at this point."); -} - -// Translates the "pool type" into human-readable -function TRANSLATE_POOL_TYPE ($type) { - // Default type is unknown - $translated = sprintf(getMessage('POOL_TYPE_UNKNOWN'), $type); - - // Generate constant - $constName = sprintf("POOL_TYPE_%s", $type); - - // Does it exist? - if (defined($constName)) { - // Then use it - $translated = getMessage($constName); - } // END - if - - // Return "translation" - return $translated; -} - -// "Getter" for remote IP number -function GET_REMOTE_ADDR () { - // Get remote ip from environment - $remoteAddr = getenv('REMOTE_ADDR'); - - // Is removeip installed? - if (EXT_IS_ACTIVE("removeip")) { - // Then anonymize it - $remoteAddr = GET_ANONYMOUS_REMOTE_ADDR($remoteAddr); - } // END - if - - // Return it - return $remoteAddr; -} -// "Getter" for remote hostname -function GET_REMOTE_HOST () { - // Get remote ip from environment - $remoteHost = getenv('REMOTE_HOST'); - - // Is removeip installed? - if (EXT_IS_ACTIVE("removeip")) { - // Then anonymize it - $remoteHost = GET_ANONYMOUS_REMOTE_HOST($remoteHost); - } // END - if - - // Return it - return $remoteHost; -} -// "Getter" for user agent -function GET_USER_AGENT () { - // Get remote ip from environment - $userAgent = getenv('HTTP_USER_AGENT'); - - // Is removeip installed? - if (EXT_IS_ACTIVE("removeip")) { - // Then anonymize it - $userAgent = GET_ANONYMOUS_USER_AGENT($userAgent); - } // END - if - - // Return it - return $userAgent; -} -// "Getter" for referer -function GET_REFERER () { - // Get remote ip from environment - $referer = getenv('HTTP_REFERER'); - - // Is removeip installed? - if (EXT_IS_ACTIVE("removeip")) { - // Then anonymize it - $referer = GET_ANONYMOUS_REFERER($referer); - } // END - if - - // Return it - return $referer; -} - -// Adds a bonus mail to the queue -// This is a high-level function! -function ADD_NEW_BONUS_MAIL ($data, $mode="", $output=true) { - // Use mode from data if not set and availble ;-) - if ((empty($mode)) && (isset($data['mode']))) $mode = $data['mode']; - - // Generate receiver list - $RECEIVER = GENERATE_RECEIVER_LIST($data['cat'], $data['receiver'], $mode); - - // Receivers added? - if (!empty($RECEIVER)) { - // Add bonus mail to queue - ADD_BONUS_MAIL_TO_QUEUE( - $data['subject'], - $data['text'], - $RECEIVER, - $data['points'], - $data['seconds'], - $data['url'], - $data['cat'], - $mode, - $data['receiver'] - ); - - // Mail inserted into bonus pool - if ($output) LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_BONUS_SEND')); - } elseif ($output) { - // More entered than can be reached! - LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_MORE_SELECTED')); - } else { - // Debug log - DEBUG_LOG(__FUNCTION__, __LINE__, " cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!"); - } -} - -// Determines referal id and sets it -function DETERMINE_REFID () { - global $CLICK, $_SERVER; - - // Check if refid is set - if ((!empty($_GET['user'])) && ($CLICK == 1) && (basename($_SERVER['PHP_SELF']) == "click.php")) { - // The variable user comes from the click-counter script click.php and we only accept this here - $GLOBALS['refid'] = bigintval($_GET['user']); - } elseif (!empty($_POST['refid'])) { - // Get referal id from variable refid (so I hope this makes my script more compatible to other scripts) - $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_POST['refid'])); - } elseif (!empty($_GET['refid'])) { - // Get referal id from variable refid (so I hope this makes my script more compatible to other scripts) - $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_GET['refid'])); - } elseif (!empty($_GET['ref'])) { - // Set refid=ref (the referal link uses such variable) - $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_GET['ref'])); - } elseif ((isSessionVariableSet('refid')) && (get_session('refid') != 0)) { - // Set session refid als global - $GLOBALS['refid'] = bigintval(get_session('refid')); - } elseif ((GET_EXT_VERSION("sql_patches") != "") && (getConfig('def_refid') > 0)) { - // Set default refid as refid in URL - $GLOBALS['refid'] = bigintval(getConfig('def_refid')); - } elseif ((GET_EXT_VERSION("user") >= "0.3.4") && (getConfig('select_user_zero_refid')) == "Y") { - // Select a random user which has confirmed enougth mails - $GLOBALS['refid'] = SELECT_RANDOM_REFID(); - } else { - // No default ID when sql_patches is not installed or none set - $GLOBALS['refid'] = 0; - } - - // Set cookie when default refid > 0 - if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((get_session('refid') == "0") && (getConfig('def_refid') > 0))) { - // Set cookie - set_session('refid', $GLOBALS['refid']); - } // END - if - - // Return determined refid - return $GLOBALS['refid']; -} - -// Destroys the admin session -function destroyAdminSession ($destroy = true) { - // Kill maybe existing session variables including array elements - set_session('admin_login', ""); - set_session('admin_md5' , ""); - set_session('admin_last' , ""); - set_session('admin_to' , ""); - - // Destroy session and return status - if ($destroy) { - return session_destroy(); - } // END - if - - // All fine if we shall not really destroy the session - return true; -} - // Checks if a given apache module is loaded function IF_APACHE_MODULE_LOADED ($apacheModule) { // Check it and return result return (((function_exists('apache_get_modules')) && (in_array($apacheModule, apache_get_modules()))) || (!function_exists('apache_get_modules'))); } -// Merges $_CONFIG with data in given array -function mergeConfig ($newConfig) { - global $_CONFIG; - $_CONFIG = merge_array($_CONFIG, $newConfig); -} - -// Getter for $_CONFIG entries -function getConfig ($entry) { - global $_CONFIG; - - // Default value - $value = null; - - // Is the entry there? - if (isConfigEntrySet($entry)) { - // Then use it - $value = $_CONFIG[$entry]; - } // END - if - - // Return it - return $value; -} - -// Setter for $_CONFIG entries -function setConfigEntry ($entry, $value) { - global $_CONFIG; - - // Secure the entry name - $entry = SQL_ESCAPE($entry); - - // And set it - $_CONFIG[$entry] = $value; -} - -// Checks wether the given config entry is set -function isConfigEntrySet ($entry) { - global $_CONFIG; - return (isset($_CONFIG[$entry])); -} - -// Increment or init with given value or 1 as default the given config entry -function incrementConfigEntry ($configEntry, $value=1) { - global $_CONFIG; - - // Increment it if set or init it with 1 - if (getConfig($configEntry) > 0) { - $_CONFIG[$configEntry] += $value; - } else { - $_CONFIG[$configEntry] = $value; - } -} - // "Getter" for language strings // @TODO Rewrite all language constants to this function. function getMessage ($messageId) { @@ -2936,7 +2340,7 @@ function getMessage ($messageId) { // Get current theme name function GET_CURR_THEME() { - global $INC_POOL, $CSS, $cacheArray; + global $INC_POOL; // The default theme is 'default'... ;-) $ret = "default"; @@ -2948,7 +2352,7 @@ function GET_CURR_THEME() { // Set default theme set_session('mxchange_theme', $ret); } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) { - //die("
".print_r($cacheArray['themes'], true)."
"); + //die("
".print_r($GLOBALS['cache_array']['themes'], true)."
"); // Get theme from cookie $ret = get_session('mxchange_theme'); @@ -2957,17 +2361,17 @@ function GET_CURR_THEME() { // Fix it to default $ret = "default"; } // END - if - } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) { + } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET(('theme'))) || (REQUEST_ISSET_POST(('theme'))))) { // Prepare FQFN for checking - $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE($_GET['theme'])); + $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE(REQUEST_GET('theme'))); // Installation mode active - if ((!empty($_GET['theme'])) && (FILE_READABLE($theme))) { + if ((REQUEST_ISSET_GET(('theme'))) && (FILE_READABLE($theme))) { // Set cookie from URL data - set_session('mxchange_theme', SQL_ESCAPE($_GET['theme'])); - } elseif (FILE_READABLE(sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE($_POST['theme'])))) { + set_session('mxchange_theme', SQL_ESCAPE(REQUEST_GET('theme'))); + } elseif (FILE_READABLE(sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE(REQUEST_POST('theme'))))) { // Set cookie from posted data - set_session('mxchange_theme', SQL_ESCAPE($_POST['theme'])); + set_session('mxchange_theme', SQL_ESCAPE(REQUEST_POST('theme'))); } // Set return value @@ -2989,8 +2393,6 @@ function GET_CURR_THEME() { // Get id from theme function THEME_GET_ID ($name) { - global $cacheArray; - // Is the extension "theme" installed? if (!EXT_IS_ACTIVE("theme")) { // Then abort here @@ -3001,9 +2403,9 @@ function THEME_GET_ID ($name) { $id = 0; // Is the cache entry there? - if (isset($cacheArray['themes']['id'][$name])) { + if (isset($GLOBALS['cache_array']['themes']['id'][$name])) { // Get the version from cache - $id = $cacheArray['themes']['id'][$name]; + $id = $GLOBALS['cache_array']['themes']['id'][$name]; // Count up incrementConfigEntry('cache_hits'); @@ -3051,7 +2453,7 @@ function READ_FILE ($FQFN, $sqlPrepare = false) { // Writes content to a file function WRITE_FILE ($FQFN, $content) { // Is the file writeable? - if (((FILE_READABLE($FQFN)) && (!is_writeable($FQFN))) && (!chmod($FQFN, 0644)) { + if ((FILE_READABLE($FQFN)) && (!is_writeable($FQFN)) && (!chmod($FQFN, 0644))) { // Not writeable! DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN))); @@ -3183,15 +2585,13 @@ function LOAD_INC ($INC) { // Loads an include file once function LOAD_INC_ONCE ($INC) { - global $cacheArray; - // Is it not loaded? - if (!isset($cacheArray['load_once'][$INC])) { + if (!isset($GLOBALS['cache_array']['load_once'][$INC])) { // Then try to load it LOAD_INC($INC); // And mark it as loaded - $cacheArray['load_once'][$INC] = true; + $GLOBALS['cache_array']['load_once'][$INC] = true; } // END - if } @@ -3268,8 +2668,8 @@ function convertCodeToMessage ($code) { break; case constant('CODE_EXTENSION_PROBLEM'): - if (isset($_GET['ext'])) { - $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), SQL_ESCAPE($_GET['ext'])); + if (REQUEST_ISSET_GET(('ext'))) { + $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), SQL_ESCAPE(REQUEST_GET('ext'))); } else { $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT'); }