public function testHas() { $this->assertTrue(Input::has('foo')); $this->assertTrue(Input::has('hoge')); $this->assertFalse(Input::has('foobar')); $this->assertFalse(Input::has('bar')); $this->assertFalse(Input::has('hogehoge')); }
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; }