if ($GLOBALS['_config']['max_file_size'] != -1 && $GLOBALS['_content_length'] > $GLOBALS['_config']['max_file_size']) { show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'file_size')); } $GLOBALS['_response_keys']['content-length'] = 'Content-Length'; $GLOBALS['_response_headers']['content-length'][0] = $GLOBALS['_content_length']; } $GLOBALS['_response_headers'] = array_filter($GLOBALS['_response_headers']); $GLOBALS['_response_keys'] = array_filter($GLOBALS['_response_keys']); if (substr(implode('', $GLOBALS['_response_headers']['content-type']), 0, 5) == 'appli') { // oneye $path = um('getCurrentUserDir') . '/' . TMP_USER_DIR . '/'; if (!vfs('isdir', array($path))) { vfs('mkDir', array($path)); } vfs('create', array($path . $checknum . '.tmp')); $handler = vfs('open', array($path . $checknum . '.tmp', 'w')); $GLOBALS['_response_headers']['content-type'][0] = 'text/html'; $GLOBALS['_response_headers']['charset'][0] = 'utf-8'; } header(array_shift($GLOBALS['_response_keys'])); array_shift($GLOBALS['_response_headers']); foreach ($GLOBALS['_response_headers'] as $name => $array) { foreach ($array as $value) { header($GLOBALS['_response_keys'][$name] . ': ' . $value, false); } } do { $data = fread($GLOBALS['_socket'], 8192); if (isset($handler)) { // oneye fwrite($handler, $data);
/** * Append the content of the physical file $filename to the writer * writeFile($filename) must be equivalent to * writeData(file_get_contents($filename)) but can be more efficient * * @param string $filename Name of the file which content must be appended * to the writer */ function writeFile($filename) { $handle = vfs('real_open', array($filename, "r")); // oneye if (!is_resource($handle)) { return PEAR::raiseError("Unable to write to {$filename}"); } while (!feof($handle)) { $error = $this->writeData(fread($handle, 102400)); if (PEAR::isError($error)) { return $error; } } fclose($handle); }
/** * @see File_Archive_Writer::newFile() */ function newFile($filename, $stat = array(), $mime = "application/octet-stream") { $this->close(); $this->stat = $stat; $this->filename = $this->getFilename($filename); if (substr($this->filename, -1) == '/') { $error = $this->mkdirr(substr($this->filename, 0, -1)); if (PEAR::isError($error)) { return $error; } } else { $pos = strrpos($this->filename, "/"); if ($pos !== false) { $error = $this->mkdirr(substr($this->filename, 0, $pos)); if (PEAR::isError($error)) { return $error; } } $this->handle = @vfs('real_open', array($this->filename, "w")); // oneye if (!is_resource($this->handle)) { return PEAR::raiseError("Unable to write to file {$filename}"); } } }
/** * Opens the file if it was not already opened */ function _ensureFileOpened() { if ($this->handle === null) { $this->handle = @vfs('real_open', array($this->filename, "r")); // oneye if (!is_resource($this->handle)) { $this->handle = null; return PEAR::raiseError("Can't open {$this->filename} for reading"); } if ($this->handle === false) { $this->handle = null; return PEAR::raiseError("File {$this->filename} not found"); } } }