public function fallback() { $parts = parse_url($this->objectId); if (!isset($parts['path'])) { return false; } $kikiFile = Core::getInstallPath() . "/htdocs/" . $parts['path']; if (file_exists($kikiFile)) { $ext = Storage::getExtension($kikiFile); switch ($ext) { case 'css': case 'gif': case 'jpg': case 'js': case 'png': $this->altContentType = Storage::getMimeType($ext); $this->template = null; $this->status = 200; $this->content = file_get_contents($kikiFile); return true; break; case 'php': Log::debug("PHP file {$kikiFile}"); $this->status = 200; $this->template = 'pages/default'; $user = Core::getUser(); $db = Core::getDb(); include_once $kikiFile; return true; break; case '': if (file_exists($kikiFile . "index.php")) { Log::debug("PHP index file {$kikiFile}" . "index.php"); $this->status = 200; $this->template = 'pages/default'; $user = Core::getUser(); $db = Core::getDb(); include_once $kikiFile . "index.php"; return true; } break; default: } Log::debug("unsupported extension {$ext} for kiki htdocs file {$kikiFile}"); } else { Log::debug("non-existing kikiFile {$kikiFile}"); } return false; }
public function exec() { list($dummy, $id, $w, $h, $dummy, $crop) = $this->objectId; $this->objectId = $id; if (!($fileName = \Kiki\Storage::localFile($this->objectId))) { return; } if (!file_exists($fileName)) { return; } $scaleFile = \Kiki\Storage::generateThumb($fileName, $w, $h, $crop); if (!file_exists($scaleFile)) { return; } $this->altContentType = \Kiki\Storage::getMimeType(\Kiki\Storage::getExtension($scaleFile)); $this->template = null; // Send content directly, without a template. $this->status = 200; $this->content = file_get_contents($scaleFile); }