public function get() { $full_file_name = $this->getFileName(); $file = new File($full_file_name, 'image/' . pathinfo($full_file_name, PATHINFO_EXTENSION)); if ($file->validateFileExtension() && $file->exists()) { $file->doDownload(); exit; } else { header('HTTP/1.0 404 not found'); exit; } }
protected function embedImages(File &$file) { $loop_breaker = 0; $contents = $file->getContents(); $image_pos = strpos($contents, 'image://'); while ($image_pos !== false) { $loop_breaker++; if ($loop_breaker > 200) { break; } $image_end = strpos($contents, ')', $image_pos); $file_name = trim(substr($contents, $image_pos + 8, $image_end - ($image_pos + 8))); $full_file_name = $this->getImageFullFileName($file_name); $image_data = ''; if (file_exists($full_file_name)) { $image_data = base64_encode(file_get_contents($full_file_name)); } $contents = substr($contents, 0, $image_pos) . 'data:image/png;base64,' . $image_data . substr($contents, $image_end); $image_pos = strpos($contents, 'image://'); } $file->tempSetContents($contents); }
public function get() { $full_file_name = $this->getFileName(); $file = new File($full_file_name, 'text/javascript'); if ($file->validateFileExtension(array('.js', '.javascript', '.css'), '.js') && $file->exists()) { if ($this->request->getRequestParam('tokenized')) { $file->replaceLanguageAndPHPTokens($this->request->language); } if (pathinfo($full_file_name, PATHINFO_EXTENSION) == 'css') { $file->setContentType('text/css'); } $file->doDownload(); exit; } else { header('HTTP/1.0 404 not found'); } }