Improvements to t3lib_div::getURL and t3lib_div::writFile
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Fri, 16 Dec 2005 15:05:49 +0000 (15:05 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Fri, 16 Dec 2005 15:05:49 +0000 (15:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@913 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php

index 4056e34..ec4e29d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+
+2005-12-13  Martin Kutschker  <martin.t.kutschker@blackbox.net>
+
+       * Support of file_get_contents() in t3lib_div::getURL()
+       * Check result of fwrite() in t3lib_div::writeFile()
+
 2005-12-15  Michael Stucki  <michael@typo3.org>
 
        * Added a deleted field to pages_language_overlay
index 3fbc8b4..e3127f6 100755 (executable)
@@ -2096,13 +2096,17 @@ class t3lib_div {
                        $content=curl_exec ($ch);
                        curl_close ($ch);
                        return $content;
+               } elseif (function_exists('file_get_contents')) {
+                       return file_get_contents($url);
                } elseif ($fd = fopen($url,'rb'))    {
                        while (!feof($fd))      {
-                               $content.=fread($fd, 5000);
+                               $content.=fread($fd, 4096);
                        }
                        fclose($fd);
                        return $content;
                }
+
+               return false;
        }
 
        /**
@@ -2117,15 +2121,20 @@ class t3lib_div {
                if (!@is_file($file))   { $changePermissions=true; }
 
                if ($fd = fopen($file,'wb'))    {
-                       fwrite($fd,$content);
+                       $res = fwrite($fd,$content);
                        fclose($fd );
 
+                       if (!$res)      {
+                               return false;
+                       }
                        if ($changePermissions) {       // Change the permissions only if the file has just been created
                                t3lib_div::fixPermissions($file);
                        }
 
                        return true;
                }
+
+               return false;
        }
 
        /**