Ejemplo n.º 1
0
    $INPUT = new Input();
}
// BEGIN main
$mimetypes = getMimeTypes();
//get input
$MEDIA = stripctl(getID('media', false));
// no cleaning except control chars - maybe external
$CACHE = calc_cache($INPUT->str('cache'));
$WIDTH = $INPUT->int('w');
$HEIGHT = $INPUT->int('h');
$REV =& $INPUT->ref('rev');
//sanitize revision
$REV = preg_replace('/[^0-9]/', '', $REV);
list($EXT, $MIME, $DL) = mimetype($MEDIA, false);
// get dl parameter from input
$DL = $INPUT->bool('dl');
if ($EXT === false) {
    $EXT = 'unknown';
    $MIME = 'application/octet-stream';
    $DL = true;
}
// check for permissions, preconditions and cache external files
list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE, $REV, $WIDTH, $HEIGHT);
// prepare data for plugin events
$data = array('media' => $MEDIA, 'file' => $FILE, 'orig' => $FILE, 'mime' => $MIME, 'download' => $DL, 'cache' => $CACHE, 'ext' => $EXT, 'width' => $WIDTH, 'height' => $HEIGHT, 'status' => $STATUS, 'statusmessage' => $STATUSMESSAGE, 'ispublic' => media_ispublic($MEDIA));
// handle the file status
$evt = new Doku_Event('FETCH_MEDIA_STATUS', $data);
if ($evt->advise_before()) {
    // redirects
    if ($data['status'] > 300 && $data['status'] <= 304) {
        if (defined('SIMPLE_TEST')) {
Ejemplo n.º 2
0
 public function test_bool()
 {
     $_REQUEST = $this->data;
     $_POST = $this->data;
     $_GET = $this->data;
     $_GET['get'] = '1';
     $_POST['post'] = '1';
     $INPUT = new Input();
     $this->assertSame(true, $INPUT->bool('one'));
     $this->assertSame(false, $INPUT->bool('zero'));
     $this->assertSame(false, $INPUT->bool('get'));
     $this->assertSame(false, $INPUT->bool('post'));
     $this->assertSame(true, $INPUT->post->bool('one'));
     $this->assertSame(false, $INPUT->post->bool('zero'));
     $this->assertSame(false, $INPUT->post->bool('get'));
     $this->assertSame(true, $INPUT->post->bool('post'));
     $this->assertSame(false, $INPUT->bool('zero', -1));
     $this->assertSame(-1, $INPUT->bool('empty', -1));
     $this->assertSame(-1, $INPUT->bool('zero', -1, true));
     $this->assertSame(-1, $INPUT->bool('empty', -1, true));
 }