]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/libs/cache_functions.php
win32 to unix line delimiters changed
[mailer.git] / 0.2.1 / inc / libs / cache_functions.php
index 87c25188f842cef8cfd5ab861a689a3249b77c1c..be3b0cee40bb54339bb6cafe55c83ac7eb48c808 100644 (file)
-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1                                    Start: 10/11/2003 *\r
- * ===============                              Last change: 10/11/2003 *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * File              : admins_functions.php                             *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Functions for the admins extension               *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung  : Funktionen fuer die admins-Erweiterung           *\r
- * -------------------------------------------------------------------- *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
- * For more information visit: http://www.mxchange.org                  *\r
- *                                                                      *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or    *\r
- * (at your option) any later version.                                  *\r
- *                                                                      *\r
- * This program is distributed in the hope that it will be useful,      *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
- * GNU General Public License for more details.                         *\r
- *                                                                      *\r
- * You should have received a copy of the GNU General Public License    *\r
- * along with this program; if not, write to the Free Software          *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
- * MA  02110-1301  USA                                                  *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\r
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))\r
-{\r
-        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";\r
-        require($INC);\r
-}\r
-// Caching class\r
-class mxchange_cache\r
-{\r
-        // Define variables\r
-        var $update_interval = 0;\r
-        var $ret = "init";\r
-        var $cache_path = "";\r
-        var $cache_inc = "";\r
-        var $cache_ctime = 0;\r
-        var $cache_pointer = false;\r
-\r
-        // Constructor\r
-        function mxchange_cache($interval, $path, $tested)\r
-        {\r
-                // Remember interval in class\r
-                $this->update_interval=$interval;\r
-\r
-                // Remeber path\r
-                $this->cache_path=$path;\r
-\r
-                // Check if path exists\r
-                if ((file_exists($path)) && (is_dir($path)) && (!$tested))\r
-                {\r
-                        // Check if we can create a file inside the path\r
-                        @touch($path."dummy.tmp", 'w');\r
-                        if (file_exists($path."dummy.tmp"))\r
-                        {\r
-                                // Yes, we can do. So let's remove it\r
-                                unlink($path."dummy.tmp");\r
-\r
-                                // Is there a .htaccess file?\r
-                                if (file_exists($path.".htaccess"))\r
-                                {\r
-                                        // Update database that we have tested it\r
-                                        $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET cache_tested='1' WHERE config='0' LIMIT 1", __FILE__, __LINE__);\r
-                                        $this->ret="done";\r
-\r
-                                        // All done!\r
-                                        return "done";\r
-                                }\r
-                                 else\r
-                                {\r
-                                        // Stop! Set a .htaccess file first\r
-                                        $this->ret="htaccess";\r
-                                        return "htaccess";\r
-                                }\r
-                        }\r
-                }\r
-                 elseif ($tested)\r
-                {\r
-                        // System already tested\r
-                        $this->ret="done";\r
-                        return "done";\r
-                }\r
-\r
-                // Something goes wrong here!\r
-                $this->ret="failed";\r
-                return "failed";\r
-        }\r
-\r
-        function cache_file($file, $ignore_ctime=false)\r
-        {\r
-                global $INC;\r
-                // Construct FQFN (full qualified file name)\r
-                $inc = $this->cache_path.$file.".cache";\r
-\r
-                // Rember it + filename in class\r
-                $this->cache_inc = $inc;\r
-\r
-                // Check if file exists\r
-                $status = (file_exists($inc) && (is_readable($inc)) && (is_writeable($inc)));\r
-                if ($status)\r
-                {\r
-                        // Yes, it does. So let's get it's last changed date/time\r
-                        $ctime = filectime($inc);\r
-                }\r
-                 else\r
-                {\r
-                        // No, it doesn't. Zero date/time\r
-                        $ctime = "0";\r
-                }\r
-\r
-                // Remember change date/time in class\r
-                $this->cache_ctime = $ctime;\r
-\r
-                // Is the cache file outdated?\r
-                if (((time() - $ctime) >= $this->update_interval) && (!$ignore_ctime))\r
-                {\r
-                        // Ok, we need an update!\r
-                        $status = false;\r
-                }\r
-                return $status;\r
-        }\r
-\r
-        function cache_init($array)\r
-        {\r
-                // This will destory an existing cache file!\r
-                if ($this->ret == "done")\r
-                {\r
-                        // Create file\r
-                        if (file_exists($this->cache_inc)) @chmod($this->cache_inc, 0666);\r
-                        $fp = @fopen($this->cache_inc, 'w') or mxchange_die("Cannot write to cache ".$this->cache_inc." !");\r
-\r
-                        // Begin of cache file\r
-                        fwrite($fp, "\$ARRAY = \"".$array."\";\n\n");\r
-\r
-                        // Remember file pointer\r
-                        $this->cache_pointer = $fp;\r
-                }\r
-                 else\r
-                {\r
-                        // Cannot create file\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);\r
-                }\r
-        }\r
-\r
-        function add_row($data)\r
-        {\r
-                if ($this->cache_pointer)\r
-                {\r
-                        // Write every array element to cache file\r
-                        foreach ($data as $k=>$v)\r
-                        {\r
-                                @fwrite($this->cache_pointer, "\$CACHE['".$k."'][] = \"".$v."\";\n");\r
-                        }\r
-                }\r
-                 else\r
-                {\r
-                        // Cannot create file\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);\r
-                }\r
-        }\r
-\r
-        function cache_close()\r
-        {\r
-                // Quit function when no pointer is set\r
-                if (empty($this->cache_pointer)) return;\r
-                if ($this->cache_pointer)\r
-                {\r
-                        // Close file add destroy handler\r
-                        @fclose($this->cache_pointer);\r
-\r
-                        // Set rights\r
-                        if (file_exists($this->cache_inc)) @chmod($this->cache_inc, 0666);\r
-\r
-                        // Remove pointer\r
-                        unset($this->cache_pointer);\r
-                }\r
-                 else\r
-                {\r
-                        // Cannot create file\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);\r
-                }\r
-        }\r
-\r
-        function cache_load()\r
-        {\r
-                if ((file_exists($this->cache_inc)) && (is_readable($this->cache_inc)))\r
-                {\r
-                        // Prepare temporay array\r
-                        $CACHE = array();\r
-                        // Load cache file\r
-                        $cache = implode("", file($this->cache_inc));\r
-                        // Execute cache file\r
-                        eval($cache);\r
-                        if (is_array($CACHE))\r
-                        {\r
-                                return $CACHE;\r
-                        }\r
-                         else\r
-                        {\r
-                                // Cache problem detected!\r
-                                $this->cache_destroy();\r
-                        }\r
-                }\r
-                 else\r
-                {\r
-                        // Cache file not found or not readable\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->cache_inc.CACHE_CANNOT_LOAD_2);\r
-                }\r
-        }\r
-\r
-        function cache_destroy()\r
-        {\r
-                if (file_exists($this->cache_inc))\r
-                {\r
-                        // Remove cache file from system\r
-                        @unlink($this->cache_inc);\r
-                        if (!file_exists($this->cache_inc))\r
-                        {\r
-                                // Close cache automatically (we don't need it anymore!)\r
-                                $this->cache_close();\r
-                        }\r
-                         else\r
-                        {\r
-                                // Not removed!\r
-                                ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);\r
-                        }\r
-                }\r
-                 else\r
-                {\r
-                        // Does not exist!\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);\r
-                }\r
-        }\r
-\r
-        function cache_remove($search, $data, $array)\r
-        {\r
-                global $ARRAY;\r
-                if ((file_exists($this->cache_inc)) && (is_writeable($this->cache_inc)))\r
-                {\r
-                        // Load cache into dummy array\r
-                        $DUMMY = $this->cache_load();\r
-\r
-                        // Search for key in array\r
-                        $key = array_search($data, $DUMMY[$search]);\r
-                        if (!empty($key))\r
-                        {\r
-                                // Key (hopefully) found?\r
-                                foreach ($array as $a)\r
-                                {\r
-                                        // So we can remove all elements as requested\r
-                                        unset($DUMMY[$a][$key]);\r
-                                }\r
-\r
-                                // Flush array to cache file\r
-                                $fp = fopen($this->cache_inc, 'w');\r
-                                fwrite($fp, "\$ARRAY = \"".$ARRAY."\";\n");\r
-                                foreach ($DUMMY as $k=>$v)\r
-                                {\r
-                                        if (is_array($v))\r
-                                        {\r
-                                                // Multi line(s) found\r
-                                                $LINE = "";\r
-                                                foreach($v as $k2=>$v2)\r
-                                                {\r
-                                                        // Put every array element in a row...\r
-                                                        $LINE .= "\$CACHE['".$k."'][] = \"".$v2."\";\n";\r
-                                                }\r
-                                        }\r
-                                         else\r
-                                        {\r
-                                                // Single line found\r
-                                                $LINE = "\$CACHE['".$k."'] = \"".$v."\";\n";\r
-                                        }\r
-\r
-                                        // Write line(s)\r
-                                        fwrite($fp, $LINE);\r
-                                }\r
-\r
-                                // Close cache file\r
-                                fclose($fp);\r
-                        }\r
-                }\r
-                 else\r
-                {\r
-                        // Cannot write to cache!\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);\r
-                }\r
-        }\r
-\r
-        function cache_replace($search, $replace, $search_key, $array)\r
-        {\r
-                global $ARRAY;\r
-                if ((file_exists($this->cache_inc)) && (is_writeable($this->cache_inc)))\r
-                {\r
-                        // Load cache into dummy array\r
-                        $DUMMY = $this->cache_load();\r
-\r
-                        // Check if $DUMMY is valid (prevents some errors)\r
-                        if ((is_array($DUMMY)) && (is_array($DUMMY[$search])))\r
-                        {\r
-                                // Search for key in array\r
-                                $key_found = array_key_exists($search_key, $DUMMY[$search]);\r
-                                if ($key_found == true)\r
-                                {\r
-                                        $key = $search_key;\r
-                                        // Key (hopefully) found?\r
-                                        foreach ($DUMMY as $a=>$v)\r
-                                        {\r
-                                                // So we can update all entries\r
-                                                if ($a == $search)\r
-                                                {\r
-                                                        // Update now...\r
-                                                        $DUMMY[$a][$search_key] = $replace;\r
-                                                }\r
-                                        }\r
-\r
-                                        // Flush array to cache file\r
-                                        $fp = fopen($this->cache_inc, 'w');\r
-                                        fwrite($fp, "\$DUMMY = \"".$ARRAY."\";\n");\r
-                                        foreach ($DUMMY as $k=>$v)\r
-                                        {\r
-                                                if (is_array($v))\r
-                                                {\r
-                                                        // Multi line(s) found\r
-                                                        $LINE = "";\r
-                                                        foreach($v as $k2=>$v2)\r
-                                                        {\r
-                                                                // Put every array element in a row...\r
-                                                                $LINE .= "\$CACHE['".$k."'][] = \"".$v2."\";\n";\r
-                                                        }\r
-                                                }\r
-                                                 else\r
-                                                {\r
-                                                        // Single line found\r
-                                                        $LINE = "\$CACHE['".$k."'] = \"".$v."\";\n";\r
-                                                }\r
-\r
-                                                // Write line(s)\r
-                                                fwrite($fp, $LINE);\r
-                                        }\r
-\r
-                                        // Close cache file\r
-                                        fclose($fp);\r
-                                }\r
-                        }\r
-                }\r
-                 else\r
-                {\r
-                        // Cannot write to cache!\r
-                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);\r
-                }\r
-        }\r
-}\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 10/11/2003 *
+ * ===============                              Last change: 10/11/2003 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : admins_functions.php                             *
+ * -------------------------------------------------------------------- *
+ * Short description : Functions for the admins extension               *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Funktionen fuer die admins-Erweiterung           *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
+{
+        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+        require($INC);
+}
+// Caching class
+class mxchange_cache
+{
+        // Define variables
+        var $update_interval = 0;
+        var $ret = "init";
+        var $cache_path = "";
+        var $cache_inc = "";
+        var $cache_ctime = 0;
+        var $cache_pointer = false;
+
+        // Constructor
+        function mxchange_cache($interval, $path, $tested)
+        {
+                // Remember interval in class
+                $this->update_interval=$interval;
+
+                // Remeber path
+                $this->cache_path=$path;
+
+                // Check if path exists
+                if ((file_exists($path)) && (is_dir($path)) && (!$tested))
+                {
+                        // Check if we can create a file inside the path
+                        @touch($path."dummy.tmp", 'w');
+                        if (file_exists($path."dummy.tmp"))
+                        {
+                                // Yes, we can do. So let's remove it
+                                unlink($path."dummy.tmp");
+
+                                // Is there a .htaccess file?
+                                if (file_exists($path.".htaccess"))
+                                {
+                                        // Update database that we have tested it
+                                        $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET cache_tested='1' WHERE config='0' LIMIT 1", __FILE__, __LINE__);
+                                        $this->ret="done";
+
+                                        // All done!
+                                        return "done";
+                                }
+                                 else
+                                {
+                                        // Stop! Set a .htaccess file first
+                                        $this->ret="htaccess";
+                                        return "htaccess";
+                                }
+                        }
+                }
+                 elseif ($tested)
+                {
+                        // System already tested
+                        $this->ret="done";
+                        return "done";
+                }
+
+                // Something goes wrong here!
+                $this->ret="failed";
+                return "failed";
+        }
+
+        function cache_file($file, $ignore_ctime=false)
+        {
+                global $INC;
+                // Construct FQFN (full qualified file name)
+                $inc = $this->cache_path.$file.".cache";
+
+                // Rember it + filename in class
+                $this->cache_inc = $inc;
+
+                // Check if file exists
+                $status = (file_exists($inc) && (is_readable($inc)) && (is_writeable($inc)));
+                if ($status)
+                {
+                        // Yes, it does. So let's get it's last changed date/time
+                        $ctime = filectime($inc);
+                }
+                 else
+                {
+                        // No, it doesn't. Zero date/time
+                        $ctime = "0";
+                }
+
+                // Remember change date/time in class
+                $this->cache_ctime = $ctime;
+
+                // Is the cache file outdated?
+                if (((time() - $ctime) >= $this->update_interval) && (!$ignore_ctime))
+                {
+                        // Ok, we need an update!
+                        $status = false;
+                }
+                return $status;
+        }
+
+        function cache_init($array)
+        {
+                // This will destory an existing cache file!
+                if ($this->ret == "done")
+                {
+                        // Create file
+                        if (file_exists($this->cache_inc)) @chmod($this->cache_inc, 0666);
+                        $fp = @fopen($this->cache_inc, 'w') or mxchange_die("Cannot write to cache ".$this->cache_inc." !");
+
+                        // Begin of cache file
+                        fwrite($fp, "\$ARRAY = \"".$array."\";\n\n");
+
+                        // Remember file pointer
+                        $this->cache_pointer = $fp;
+                }
+                 else
+                {
+                        // Cannot create file
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+                }
+        }
+
+        function add_row($data)
+        {
+                if ($this->cache_pointer)
+                {
+                        // Write every array element to cache file
+                        foreach ($data as $k=>$v)
+                        {
+                                @fwrite($this->cache_pointer, "\$CACHE['".$k."'][] = \"".$v."\";\n");
+                        }
+                }
+                 else
+                {
+                        // Cannot create file
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+                }
+        }
+
+        function cache_close()
+        {
+                // Quit function when no pointer is set
+                if (empty($this->cache_pointer)) return;
+                if ($this->cache_pointer)
+                {
+                        // Close file add destroy handler
+                        @fclose($this->cache_pointer);
+
+                        // Set rights
+                        if (file_exists($this->cache_inc)) @chmod($this->cache_inc, 0666);
+
+                        // Remove pointer
+                        unset($this->cache_pointer);
+                }
+                 else
+                {
+                        // Cannot create file
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+                }
+        }
+
+        function cache_load()
+        {
+                if ((file_exists($this->cache_inc)) && (is_readable($this->cache_inc)))
+                {
+                        // Prepare temporay array
+                        $CACHE = array();
+                        // Load cache file
+                        $cache = implode("", file($this->cache_inc));
+                        // Execute cache file
+                        eval($cache);
+                        if (is_array($CACHE))
+                        {
+                                return $CACHE;
+                        }
+                         else
+                        {
+                                // Cache problem detected!
+                                $this->cache_destroy();
+                        }
+                }
+                 else
+                {
+                        // Cache file not found or not readable
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->cache_inc.CACHE_CANNOT_LOAD_2);
+                }
+        }
+
+        function cache_destroy()
+        {
+                if (file_exists($this->cache_inc))
+                {
+                        // Remove cache file from system
+                        @unlink($this->cache_inc);
+                        if (!file_exists($this->cache_inc))
+                        {
+                                // Close cache automatically (we don't need it anymore!)
+                                $this->cache_close();
+                        }
+                         else
+                        {
+                                // Not removed!
+                                ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);
+                        }
+                }
+                 else
+                {
+                        // Does not exist!
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);
+                }
+        }
+
+        function cache_remove($search, $data, $array)
+        {
+                global $ARRAY;
+                if ((file_exists($this->cache_inc)) && (is_writeable($this->cache_inc)))
+                {
+                        // Load cache into dummy array
+                        $DUMMY = $this->cache_load();
+
+                        // Search for key in array
+                        $key = array_search($data, $DUMMY[$search]);
+                        if (!empty($key))
+                        {
+                                // Key (hopefully) found?
+                                foreach ($array as $a)
+                                {
+                                        // So we can remove all elements as requested
+                                        unset($DUMMY[$a][$key]);
+                                }
+
+                                // Flush array to cache file
+                                $fp = fopen($this->cache_inc, 'w');
+                                fwrite($fp, "\$ARRAY = \"".$ARRAY."\";\n");
+                                foreach ($DUMMY as $k=>$v)
+                                {
+                                        if (is_array($v))
+                                        {
+                                                // Multi line(s) found
+                                                $LINE = "";
+                                                foreach($v as $k2=>$v2)
+                                                {
+                                                        // Put every array element in a row...
+                                                        $LINE .= "\$CACHE['".$k."'][] = \"".$v2."\";\n";
+                                                }
+                                        }
+                                         else
+                                        {
+                                                // Single line found
+                                                $LINE = "\$CACHE['".$k."'] = \"".$v."\";\n";
+                                        }
+
+                                        // Write line(s)
+                                        fwrite($fp, $LINE);
+                                }
+
+                                // Close cache file
+                                fclose($fp);
+                        }
+                }
+                 else
+                {
+                        // Cannot write to cache!
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+                }
+        }
+
+        function cache_replace($search, $replace, $search_key, $array)
+        {
+                global $ARRAY;
+                if ((file_exists($this->cache_inc)) && (is_writeable($this->cache_inc)))
+                {
+                        // Load cache into dummy array
+                        $DUMMY = $this->cache_load();
+
+                        // Check if $DUMMY is valid (prevents some errors)
+                        if ((is_array($DUMMY)) && (is_array($DUMMY[$search])))
+                        {
+                                // Search for key in array
+                                $key_found = array_key_exists($search_key, $DUMMY[$search]);
+                                if ($key_found == true)
+                                {
+                                        $key = $search_key;
+                                        // Key (hopefully) found?
+                                        foreach ($DUMMY as $a=>$v)
+                                        {
+                                                // So we can update all entries
+                                                if ($a == $search)
+                                                {
+                                                        // Update now...
+                                                        $DUMMY[$a][$search_key] = $replace;
+                                                }
+                                        }
+
+                                        // Flush array to cache file
+                                        $fp = fopen($this->cache_inc, 'w');
+                                        fwrite($fp, "\$DUMMY = \"".$ARRAY."\";\n");
+                                        foreach ($DUMMY as $k=>$v)
+                                        {
+                                                if (is_array($v))
+                                                {
+                                                        // Multi line(s) found
+                                                        $LINE = "";
+                                                        foreach($v as $k2=>$v2)
+                                                        {
+                                                                // Put every array element in a row...
+                                                                $LINE .= "\$CACHE['".$k."'][] = \"".$v2."\";\n";
+                                                        }
+                                                }
+                                                 else
+                                                {
+                                                        // Single line found
+                                                        $LINE = "\$CACHE['".$k."'] = \"".$v."\";\n";
+                                                }
+
+                                                // Write line(s)
+                                                fwrite($fp, $LINE);
+                                        }
+
+                                        // Close cache file
+                                        fclose($fp);
+                                }
+                        }
+                }
+                 else
+                {
+                        // Cannot write to cache!
+                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+                }
+        }
+}
+//
+?>