- 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) {
- // Default is not found!
- $return = "!".$messageId."!";
-
- // Is the language string found?
- if (isset($GLOBALS['msg'][strtolower($messageId)])) {
- // Language array element found in small_letters
- $return = $GLOBALS['msg'][$messageId];
- } elseif (isset($GLOBALS['msg'][strtoupper($messageId)])) {
- // @DEPRECATED Language array element found in BIG_LETTERS
- $return = $GLOBALS['msg'][$messageId];
- } elseif (defined($messageId)) {
- // @DEPRECATED Deprecated constant found
- $return = constant($messageId);
- } else {
- // Missing language constant
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Missing message string %s detected.", $messageId));
- }
-
- // Return the string
- return $return;
-}
-
-// Get current theme name
-function GET_CURR_THEME() {
- global $INC_POOL;
-
- // The default theme is 'default'... ;-)
- $ret = "default";
-
- // Load default theme if not empty from configuration
- if (getConfig('default_theme') != "") $ret = getConfig('default_theme');
-
- if (!isSessionVariableSet('mxchange_theme')) {
- // Set default theme
- set_session('mxchange_theme', $ret);
- } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) {
- //die("<pre>".print_r($GLOBALS['cache_array']['themes'], true)."</pre>");
- // Get theme from cookie
- $ret = get_session('mxchange_theme');
-
- // Is it valid?
- if (THEME_GET_ID($ret) == 0) {
- // Fix it to default
- $ret = "default";
- } // END - if
- } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($GLOBALS['output_mode'] == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) {
- // Prepare FQFN for checking
- $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE($_GET['theme']));
-
- // Installation mode active
- if ((!empty($_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 cookie from posted data
- set_session('mxchange_theme', SQL_ESCAPE($_POST['theme']));
- }
-
- // Set return value
- $ret = get_session('mxchange_theme');
- } else {
- // Invalid design, reset cookie
- set_session('mxchange_theme', $ret);
- }
-
- // Add (maybe) found theme.php file to inclusion list
- $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE($ret));
-
- // Try to load the requested include file
- if (FILE_READABLE($theme)) $INC_POOL[] = $theme;
-
- // Return theme value
- return $ret;
-}
-
-// Get id from theme
-function THEME_GET_ID ($name) {
- // Is the extension "theme" installed?
- if (!EXT_IS_ACTIVE("theme")) {
- // Then abort here
- return 0;
- } // END - if
-
- // Default id
- $id = 0;
-
- // Is the cache entry there?
- if (isset($GLOBALS['cache_array']['themes']['id'][$name])) {
- // Get the version from cache
- $id = $GLOBALS['cache_array']['themes']['id'][$name];
-
- // Count up
- incrementConfigEntry('cache_hits');
- } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
- // Check if current theme is already imported or not
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_themes` WHERE theme_path='%s' LIMIT 1",
- array($name), __FILE__, __LINE__);
-
- // Entry found?
- if (SQL_NUMROWS($result) == 1) {
- // Fetch data
- list($id) = SQL_FETCHROW($result);
- } // END - if
-
- // Free result
- SQL_FREERESULT($result);
- }
-
- // Return id
- return $id;