]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Reversed and obsolete code removed (was for admin area, we don't rewrite links in...
[mailer.git] / inc / functions.php
index a3fb34dbd052fe4cebac2cd731de20cf6bdc6af2..d6c84e21874b9a6429210d85e831a3c66ef63798 100644 (file)
@@ -41,20 +41,6 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
-// Check if our config file is writeable or not
-function IS_INC_WRITEABLE ($inc) {
-       // Generate FQFN
-       $FQFN = sprintf("%sinc/%s.php", constant('PATH'), $inc);
-
-       // Abort by simple test
-       if ((FILE_READABLE($FQFN)) && (!is_writeable($FQFN))) {
-               return false;
-       } // END - if
-
-       // Test write-access on directory
-       return is_writeable(dirname($FQFN));
-}
-
 // Output HTML code directly or "render" it. You addionally switch the new-line character off
 function OUTPUT_HTML ($HTML, $newLine = true) {
        // Some global variables
@@ -2535,7 +2521,8 @@ function searchDirsRecursive ($dir, &$last_changed) {
                $FQFN = str_replace("//", "/", constant('PATH') . $dir. "/". $d);
 
                // Does it match what we are looking for? (We skip a lot files already!)
-               if (!preg_match('@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache)$@', $d)) {      // no . or  ..  or .revision or .svn in the filename
+               if (!preg_match('@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache|config\.php)$@', $d)) {          // no ., .., .revision,  .svn, debug.log or .cache in the filename
+
                        // Is it a file and readable?
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />\n";
                        if (isDirectory($FQFN)) {
@@ -2663,8 +2650,14 @@ function getAkt_vers () {
                if (isset($t[2])) $akt_vers[$search] = trim($t[2]);
        } // END - foreach
 
+       // Save the last-changed filename for debugging
+       $akt_vers['File'] = $last_changed['path_name'];
+
        // at least 3 keyword-Tags are needed for propper values
-       if ($res && $res >= 3) {
+       if ($res && $res >= 3
+               && isset($akt_vers['Revision']) && $akt_vers['Revision'] != ''
+               && isset($akt_vers['Date']) && $akt_vers['Date'] != ''
+               && isset($akt_vers['Tag']) && $akt_vers['Tag'] != '') {
                // Prepare content witch need special treadment
 
                // Prepare timestamp for date
@@ -2675,6 +2668,7 @@ function getAkt_vers () {
                if ((isset($akt_vers['Author'])) && ($akt_vers['Author'] != "quix0r")) {
                        $akt_vers['Tag'] .= '-'.strtoupper($akt_vers['Author']);
                } // END - if
+
        } else {
                // No valid Data from the last modificated file so read the Revision from the Server. Fallback-solution!! Should not be removed I think.
                $version = GET_URL("check-updates3.php");
@@ -2698,7 +2692,7 @@ function LOAD_INC ($INC) {
        $FQFN = constant('PATH') . $INC;
 
        // Is the include file there?
-       if (!FILE_READABLE($FQFN)) {
+       if (!INCLUDE_READABLE($INC)) {
                // Not there so log it
                debug_report_bug(sprintf("Include file %s not found.", $INC));
                return false;
@@ -3102,58 +3096,6 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
        } // END - if
 }
 
-// Reads a directory with PHP files in and gets only files back
-function GET_DIR_AS_ARRAY ($baseDir, $prefix, $includeDirs = false, $addBaseDir = true) {
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!");
-       // Init includes
-       $INCs = array();
-
-       // Open directory
-       $dirPointer = opendir(constant('PATH') . $baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!");
-
-       // Read all entries
-       while ($baseFile = readdir($dirPointer)) {
-               // Construct include filename and FQFN
-               $INC = $baseDir . "/" . $baseFile;
-               $FQFN = constant('PATH') . $INC;
-
-               // Is this a valid reset file?
-               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}");
-               if (((FILE_READABLE($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) || (($includeDirs) && (isDirectory($FQFN)))) {
-                       // 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
-                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " Extension entry ".$baseFile." added.");
-                               $INCs[] = $INC;
-                       } elseif ($extId == 0) {
-                               // Add non-extension files as well
-                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " Regular entry ".$baseFile." added.");
-                               if ($addBaseDir) {
-                                       $INCs[] = $INC;
-                               } else {
-                                       $INCs[] = $baseFile;
-                               }
-                       }
-               } // END - if
-       } // END - while
-
-       // Close directory
-       closedir($dirPointer);
-
-       // Sort array
-       asort($INCs);
-
-       // Return array with include files
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!");
-       return $INCs;
-}
-
 // Load more reset scripts
 function runResetIncludes () {
        // Is the reset set or old sql_patches?
@@ -3389,10 +3331,34 @@ function TRANSLATE_POOL_TYPE ($type) {
        return $translated;
 }
 
+// Determines the real remote address
+function determineRealRemoteAddress () {
+       // Is a proxy in use?
+       if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
+               // Proxy was used
+               $address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+       } elseif (isset($_SERVER['HTTP_CLIENT_IP'])){
+               // Yet, another proxy
+               $address = $_SERVER['HTTP_CLIENT_IP'];
+       } else {
+               // The regular address when no proxy was used
+               $address = $_SERVER['REMOTE_ADDR'];
+       }
+
+       // This strips out the real address from proxy output
+       if (strstr($address, ",")){
+               $addressArray = explode(",", $address);
+               $address = $addressArray[0];
+       } // END - if
+
+       // Return the result
+       return $address;
+}
+
 // "Getter" for remote IP number
 function GET_REMOTE_ADDR () {
        // Get remote ip from environment
-       $remoteAddr = getenv('REMOTE_ADDR');
+       $remoteAddr = determineRealRemoteAddress();
 
        // Is removeip installed?
        if (EXT_IS_ACTIVE("removeip")) {
@@ -3621,51 +3587,6 @@ function isDirectory ($FQFN) {
        return $isDirectory;
 }
 
-// Init INC_POOL
-function INIT_INC_POOL () {
-       $GLOBALS['inc_pool'] = array();
-}
-
-// Setter for INC_POOL
-function SET_INC_POOL ($includePool) {
-       $GLOBALS['inc_pool'] = (array) $includePool;
-}
-
-// Getter for INC_POOL
-function GET_INC_POOL () {
-       return $GLOBALS['inc_pool'];
-}
-
-// Count INC_POOL
-function COUNT_INC_POOL () {
-       return count($GLOBALS['inc_pool']);
-}
-
-// Merge INC_POOL into given
-function MERGE_INC_POOL ($includePool) {
-       SET_INC_POOL(merge_array(GET_INC_POOL(), $includePool));
-}
-
-// Add single include file to INC_POOL
-function ADD_INC_TO_POOL ($INC) {
-       $GLOBALS['inc_pool'][] = (string) $INC;
-}
-
-// Remove an include file from INC_POOL
-function REMOVE_INC_FROM_POOL ($INC) {
-       // First look it up
-       $key = array_search($INC, GET_INC_POOL());
-
-       // Is it valid?
-       if ($key !== false) {
-               // Then remove it
-               unset($GLOBALS['inc_pool'][$key]);
-
-               // And sort the list
-               asort($GLOBALS['inc_pool']);
-       } // END - if
-}
-
 // Handle message codes from URL
 function handleCodeMessage () {
        if (REQUEST_ISSET_GET(('msg'))) {