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; }
if ($error) { echo "<p>Please upgrade manually.</p>\n"; echo "</li>\n"; break; } else { $db->query("update config set value='{$version}' where `key`='dbVersion'"); echo "</li>\n"; } } echo "</li>\n"; } } else { if (Config::$dbUser) { if ($db->connected()) { echo "<li>Database tables not installed.</li>\n"; $file = Core::getInstallPath() . "/db/core.sql"; echo "<li>Running install script <tt>{$file}</tt>:\n"; $error = Status::sourceSqlFile($db, $file); if ($error) { echo "<p>Please install manually.</p>\n"; } echo "</li>\n"; } else { echo "<li>Database connection failed. Please check your configuration (<tt>" . Config::configFile() . "</tt>).</li>\n"; } } else { echo "<li>Database not configured. Please create/edit <tt>" . Config::configFile() . "</tt>, see <tt>config.php-sample</tt> for an example.</li>\n"; } } echo "</ul>\n"; $this->content = ob_get_clean();
#!/usr/bin/php -q <?php /** * @file console.php * * Console front-end for the website. * * Currently hardcoded to print_r the template data for any given (GET) URL * passing through the router, for debugging purposes. Should be extended to * handle specific CLI templates for scripting output and even input * processing for specific actions to link web-actions and script-actions * closer together. * * @author Rob Kaper <http://robkaper.nl/> * @section license_sec License * Released under the terms of the MIT license. */ use Kiki\Core; $_SERVER['SERVER_NAME'] = isset($argv[1]) ? $argv[1] : die('SERVER_NAME argument missing' . PHP_EOL); $_SERVER['REQUEST_URI'] = isset($argv[2]) ? $argv[2] : die('REQUEST_URI argument missing' . PHP_EOL); $_SERVER['SCRIPT_URL'] = $_SERVER['REQUEST_URI']; require_once preg_replace('~/bin/(.*)\\.php~', '/lib/init.php', __FILE__); $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME']; $_SERVER['SERVER_PROTOCOL'] = null; include_once Core::getInstallPath() . "/htdocs/router.php";