Merge pull request #635 from owncloud/ob_end

provide a safe way to end output buffering
This commit is contained in:
Thomas Müller 2012-11-29 13:50:49 -08:00
commit 9b709fa95d
6 changed files with 17 additions and 8 deletions

View File

@ -27,7 +27,7 @@ $RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging');
OC_App::loadApps($RUNTIME_APPTYPES);
ob_end_clean();
OC_Util::obEnd();
// Backends
$authBackend = new OC_Connector_Sabre_Auth();

View File

@ -44,5 +44,5 @@ header('Content-Disposition: attachment; filename="'.basename($filename).'"');
OCP\Response::disableCaching();
header('Content-Length: '.OC_Filesystem::filesize($filename));
@ob_end_clean();
OC_Util::obEnd();
OC_Filesystem::readfile( $filename );

View File

@ -32,7 +32,7 @@ class OC_EventSource{
private $fallBackId=0;
public function __construct() {
@ob_end_clean();
OC_Util::obEnd();
header('Cache-Control: no-cache');
$this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true';
if($this->fallback) {

View File

@ -195,7 +195,7 @@ class OC_Files {
$zip=false;
$filename=$dir.'/'.$files;
}
@ob_end_clean();
OC_Util::obEnd();
if($zip or OC_Filesystem::is_readable($filename)) {
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');

View File

@ -195,7 +195,7 @@ class OC_FilesystemView {
return $this->basicOperation('filesize', $path);
}
public function readfile($path) {
@ob_end_clean();
OC_Util::obEnd();
$handle=$this->fopen($path, 'rb');
if ($handle) {
$chunkSize = 8192;// 8 MB chunks

View File

@ -594,22 +594,31 @@ class OC_Util {
$connected = @fsockopen("www.owncloud.org", 80);
if ($connected) {
fclose($connected);
return true;
return true;
}else{
// second try in case one server is down
$connected = @fsockopen("apps.owncloud.com", 80);
if ($connected) {
fclose($connected);
return true;
return true;
}else{
return false;
return false;
}
}
}
/**
* clear all levels of output buffering
*/
public static function obEnd(){
while (ob_get_level()) {
ob_end_clean();
}
}
/**
* @brief Generates a cryptographical secure pseudorandom string