Beispiel #1
0
 public function testGet()
 {
     $this->assertEquals('bar', Input::get('foo'));
     $this->assertEquals('hogehoge', Input::get('hoge'));
     $this->assertNull(Input::get('foobar'));
     $this->assertEquals('pyo', Input::get('foobar', 'pyo'));
 }
Beispiel #2
0
 public function view()
 {
     $page = new Page(Input::get('p', Config::get('index')), 'name');
     $name = urlencode($page->getName() . '.md');
     header('Content-Type: text/x-markdown; charset="UTF-8"');
     header("Content-Disposition: inline; filename=\"{$name}\"");
     echo $page->getHead()->getData();
     return false;
 }
Beispiel #3
0
 public function file()
 {
     $this->_enforceExists();
     if (!Input::has('f')) {
         throw new ForbiddenException();
     }
     $name = Input::get('f');
     $id = $this->page->getId() . '_' . sha1($name);
     $path = dirname(dirname(dirname(__FILE__))) . '/file/' . $id;
     if (!file_exists($path)) {
         throw new NotFoundException("A file \"{$name}\" is not found");
     }
     $json = $path . '.json';
     if (!file_exists($json)) {
         throw new NotFoundException("Informations of the file \"{$name}\" are not found");
     }
     $file = json_decode(file_get_contents($json), true);
     header('Content-Type: ' . $file['type']);
     header('Content-Length: ' . $file['size']);
     header('Content-Disposition: inline; filename="' . str_replace('"', '?', $file['name']) . '"');
     echo file_get_contents($path);
     return false;
 }
Beispiel #4
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use ukatama\Mew\Config;
use ukatama\Mew\Input;
use ukatama\Mew\PageController;
use ukatama\Mew\Registry;
ini_set('display_errors', Config::get('debug'));
try {
    Registry::controller(Input::get('c', 'page'))->dispatch(Input::get('a', 'view'));
} catch (Exception $e) {
    $ctr = Registry::controller('error');
    $ctr->error = $e;
    $ctr->dispatch('error');
}