Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
require_once 'PEAR.php';
4
require_once 'HTTP/Download.php';
5
 
6
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
7
 
8
$params = @$_GET['params'];
9
 
10
// Whatch for hackers
11
unset($params['file']);
12
unset($params['resource']);
13
unset($params['stream']);
14
unset($params['data']);
15
 
16
// Stream to test unknown-length content
17
class testStream
18
{
19
    var $_fp;
20
    function stream_open($path, $mode, $flags, &$opened)
21
    {
22
        $path = substr($path, 9);
23
        $this->_fp = fopen($path, $mode, true);
24
        return (boolean)$this->_fp;
25
    }
26
 
27
    function stream_close()
28
    {
29
        fclose($this->_fp);
30
        return true;
31
    }
32
 
33
    function stream_eof()
34
    {
35
        return feof($this->_fp);
36
    }
37
 
38
    function stream_read($count)
39
    {
40
        return fread($this->_fp, $count);
41
    }
42
 
43
    function stream_seek($offset, $whence)
44
    {
45
        return fseek($this->_fp, $offset, $whence);
46
    }
47
 
48
    function stream_stat()
49
    {
50
        return array();
51
    }
52
}
53
 
54
stream_wrapper_register('mytest', 'testStream');
55
 
56
 
57
switch ($_GET['what'])
58
{
59
    case 'file':
60
        $params['file'] = 'data.txt';
61
    break;
62
    case 'resource':
63
        $params['resource'] = fopen('data.txt', 'rb');
64
    break;
65
    case 'stream':
66
        $params['resource'] = fopen('mytest://data.txt', 'rb');
67
    break;
68
    case 'data':
69
        $params['data'] = file_get_contents('data.txt');
70
    break;
71
}
72
 
73
switch ($_GET['op'])
74
{
75
    case 'static':
76
        HTTP_Download::staticSend($params);
77
    break;
78
 
79
    case 'send':
80
        $h = &new HTTP_Download;
81
        $h->setParams($params);
82
        $h->send();
83
    break;
84
 
85
    case 'arch':
86
        HTTP_Download::sendArchive('foo.'. $_GET['type'], $_GET['what'], $_GET['type']);
87
    break;
88
}
89
 
90
?>