More stuff for mysql3->mysql switch.
[mailer.git] / inc / functions.php
index 4f37ac1a92079a5d9ae6a39ed39301fc4d8391a9..f55c9a396a70d70b13db32e2ce2794b95f016a56 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Viele Nicht-Datenbank-Funktionen                 *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
@@ -474,9 +469,9 @@ function redirectToUrl ($url, $allowSpider = TRUE) {
                sendRawRedirect(doFinalCompilation(str_replace('&', '&', $url), FALSE));
        } else {
                // Output error message
-               loadInclude('inc/header.php');
+               loadPageHeader();
                loadTemplate('redirect_url', FALSE, str_replace('&', '&', $url));
-               loadInclude('inc/footer.php');
+               loadPageFooter();
        }
 
        // Shut the mailer down here
@@ -551,7 +546,7 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') {
        if (isConfigEntrySet('file_hash')) {
                $keys .= getEncryptSeparator() . getFileHash();
        } // END - if
-       $keys .= getEncryptSeparator() . getDateFromRepository();
+
        if (isConfigEntrySet('master_salt')) {
                $keys .= getEncryptSeparator() . getMasterSalt();
        } // END - if
@@ -780,7 +775,7 @@ function generateHash ($plainText, $salt = '', $hash = TRUE) {
                $server = $_SERVER['PHP_SELF'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr();
 
                // Build key string
-               $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getDateFromRepository() . getEncryptSeparator() . getMasterSalt();
+               $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getMasterSalt();
 
                // Is the secret_key config entry set?
                if (isConfigEntrySet('secret_key')) {
@@ -1801,12 +1796,12 @@ function isExtraTitleSet () {
  *
  * @param      $baseDir                        Relative base directory to PATH to scan from
  * @param      $prefix                         Prefix for all positive matches (which files should be found)
- * @param      $fileIncludeDirs        whether to include directories in the final output array
- * @param      $addBaseDir                     whether to add $baseDir to all array entries
+ * @param      $fileIncludeDirs        Whether to include directories in the final output array
+ * @param      $addBaseDir                     Whether to add $baseDir to all array entries
  * @param      $excludeArray           Excluded files and directories, these must be full files names, e.g. 'what-' will exclude all files named 'what-' but won't exclude 'what-foo.php'
  * @param      $extension                      File extension for all positive matches
  * @param      $excludePattern         Regular expression to exclude more files (preg_match())
- * @param      $recursive                      whether to scan recursively
+ * @param      $recursive                      Whether to scan recursively
  * @param      $suffix                         Suffix for positive matches ($extension will be appended, too)
  * @param      $withPrefixSuffix       Whether to include prefix/suffix in found entries
  * @return     $foundMatches           All found positive matches for above criteria
@@ -2114,43 +2109,6 @@ function isSpider () {
        return ((isInStringIgnoreCase('spider', $userAgent)) || (isInStringIgnoreCase('slurp', $userAgent)) || (isInStringIgnoreCase('bot', $userAgent)) || (isInStringIgnoreCase('archiver', $userAgent)));
 }
 
-// Function to search for the last modified file
-function searchDirsRecursive ($dir, &$last_changed, $lookFor = 'Date') {
-       // Get dir as array
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dir=' . $dir);
-       // Does it match what we are looking for? (We skip a lot files already!)
-       // RegexPattern to exclude  ., .., .revision,  .svn, debug.log or .cache in the filenames
-       $excludePattern = '@(\.revision|\.svn|debug\.log|\.cache|config\.php)$@';
-
-       $ds = getArrayFromDirectory($dir, '', FALSE, TRUE, array(), '.php', $excludePattern);
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count(ds)='.count($ds));
-
-       // Walk through all entries
-       foreach ($ds as $d) {
-               // Generate proper FQFN
-               $FQFN = str_replace('//', '/', getPath() . $dir . '/' . $d);
-
-               // Is it a file and readable?
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dir=' . $dir . ',d=' . $d);
-               if (isFileReadable($FQFN)) {
-                       // $FQFN is a readable file so extract the requested data from it
-                       $check = extractRevisionInfoFromFile($FQFN, $lookFor);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File: ' . $d . ' found. check=' . $check);
-
-                       // Is the file more recent?
-                       if ((!isset($last_changed[$lookFor])) || ($last_changed[$lookFor] < $check)) {
-                               // This file is newer as the file before
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'NEWER!');
-                               $last_changed['path_name'] = $FQFN;
-                               $last_changed[$lookFor] = $check;
-                       } // END - if
-               } else {
-                       // Not readable
-                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File: ' . $d . ' not readable or directory.');
-               }
-       } // END - foreach
-}
-
 // Handles the braces [] of a field (e.g. value of 'name' attribute)
 function handleFieldWithBraces ($field) {
        // Are there braces [] at the end?
@@ -2937,5 +2895,31 @@ function isThemeReadable ($theme) {
        return $GLOBALS[__FUNCTION__][$theme];
 }
 
+// Checks whether a given PHP extension is loaded or can be loaded at runtime
+//
+// Supported OS: Windows, Linux, (Mac?)
+function isPhpExtensionLoaded ($extension) {
+       // Is the extension loaded?
+       if (extension_loaded($extension)) {
+               // All fine
+               return TRUE;
+       } // END - if
+
+       // Try to load the extension
+       return loadLibrary($extension);
+}
+
+// Loads given library (aka. PHP extension)
+// Credits: shaunspiller at spammenot-gmail dot com ( http://de.php.net/dl#88566 )
+function loadLibrary ($n, $f = NULL) {
+       return extension_loaded($n) or dl(((PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '') . ($f ? $f : $n) . '.' . PHP_SHLIB_SUFFIX);
+}
+
+// "Translates" given PHP extension name into a readable version
+function translatePhpExtension ($extension) {
+       // Return the language element
+       return '{--PHP_EXTENSION_' . strtoupper($extension) . '--}';
+}
+
 // [EOF]
 ?>