Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2011-03-12 00:04:42 +0300
committerrobocoder <anthon.pang@gmail.com>2011-03-12 00:04:42 +0300
commit585d25914ae8d8780c55946fd2bf0bfd0d4e6404 (patch)
tree10f6a501face24a1069fdabfa225880f91a0a757 /libs/upgradephp
parent617c37937ca867562f8309521665c47c8ee6f169 (diff)
fixes #2177
git-svn-id: http://dev.piwik.org/svn/trunk@4067 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/upgradephp')
-rw-r--r--libs/upgradephp/upgrade.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/libs/upgradephp/upgrade.php b/libs/upgradephp/upgrade.php
index 5246fc33e7..a2d2988234 100644
--- a/libs/upgradephp/upgrade.php
+++ b/libs/upgradephp/upgrade.php
@@ -944,3 +944,37 @@ function safe_unserialize( $str )
}
return $out;
}
+
+/**
+ * readfile() replacement.
+ * Behaves similar to readfile($filename);
+ *
+ * @author anthon (dot) pang (at) gmail (dot) com
+ *
+ * @param string $filename
+ * @param bool $useIncludePath
+ * @param resource $context
+ * @return int the number of bytes read from the file, or false if an error occurs
+ */
+function _readfile($filename, $useIncludePath, $context)
+{
+ $count = @filesize($filename);
+
+ // built-in function has a 2 MB limit when using mmap
+ if (function_exists('readfile') && $count <= (2 * 1024 * 1024)) {
+ return @readfile($filename, $useIncludePath, $context);
+ }
+
+ // when in doubt (or when readfile() function is disabled)
+ $handle = @fopen($filename, Piwik_Common::isWindows() ? "rb" : "r");
+ if ($handle) {
+ while(!feof($handle)) {
+ echo fread($handle, 8192);
+ ob_flush();
+ flush();
+ }
+
+ fclose($handle);
+ return $count;
+ }
+}