Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<pre>
2
<?php
3
 
4
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5
 
6
/**
7
 * Net_FTP_Socket example.
8
 *
9
 * Example for the usage of Net_FTP's socket implementation of the
10
 * ext/FTP functions.'
11
 *
12
 * PHP versions 4 and 5
13
 *
14
 * LICENSE: This source file is subject to version 3.0 of the PHP license
15
 * that is available through the world-wide-web at the following URI:
16
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
17
 * the PHP License and are unable to obtain it through the web, please
18
 * send a note to license@php.net so we can mail you a copy immediately.
19
 *
20
 * @category   Networking
21
 * @package    FTP
22
 * @author     Tobias Schlitt <toby@php.net>
23
 * @copyright  1997-2005 The PHP Group
24
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
25
 * @version    CVS: $Id: socket.php,v 1.3 2005/02/23 12:12:23 toby Exp $
26
 * @link       http://pear.php.net/package/Net_FTP
27
 * @since      File available since Release 1.3.0
28
 */
29
 
30
if(isset($_GET['native'])) {
31
    @dl('ftp.so');
32
}
33
 
34
// Configuration
35
 
36
# Login info
37
$host = 'localhost';
38
$user = 'pub';
39
$pass = 'public';
40
 
41
# Passive mode on/off
42
$pasv = false;
43
 
44
# List directory
45
$dir = 'episodes/';
46
 
47
# Upload files
48
$Uasci   = basename($_SERVER['PHP_SELF']);
49
$Ubinary = 'screenshot.jpg';
50
 
51
// End of configuration
52
 
53
list($usec,$sec) = explode(' ', microtime());
54
$time = (float)$usec + (float)$sec;
55
 
56
   /**
57
* Function used by the test suit.
58
* Takes in boolean parameter and returns as string
59
*/
60
function BoolToString($bool)
61
{
62
    return $bool == true ? 'TRUE' : 'FALSE';
63
}
64
/**
65
* Function used by the test suit.
66
* Spits out test results in readable way
67
*/
68
function dump($action, $result, $msg = false)
69
{
70
    if (is_bool($result)) {
71
        $result = BoolToString($result);
72
    }
73
 
74
    if (is_array($result)) {
75
        echo '<strong>' .$action. ':</strong>' ."\n";
76
        foreach($result as $key => $value) {
77
            echo ' ' .$key. ': ' .$value. "\n";
78
        }
79
    }
80
    else {
81
        echo '<strong>' .$action. '</strong>:' ."\n";
82
        echo $result;
83
        if ($msg) {
84
            echo ' ( ' .$msg. ' )';
85
        }
86
        echo "\n";
87
    }
88
 
89
    echo '<hr style="border: 1px solid #000;"/>';# . "\n";
90
    flush();
91
}
92
 
93
/**
94
* Little test suit
95
*/
96
$stream = ftp_connect($host);
97
if (is_resource($stream)) {
98
    dump ('Logging in', $bool = ftp_login($stream, $user, $pass));
99
    if ( $bool ) {
100
        dump('PWD',             ftp_pwd    ($stream));
101
        dump('Systype',         ftp_systype($stream));
102
        dump('CHDIR "'.$dir.'"',ftp_chdir  ($stream, $dir));
103
        dump('PWD',             ftp_pwd    ($stream));
104
        dump('CDUP',            ftp_cdup   ($stream));
105
        dump('PASSIVE',         ftp_pasv   ($stream, $pasv));
106
        dump('RAWLIST "."',     ftp_rawlist($stream, '.'));
107
        dump('CHMOD',           ftp_chmod  ($stream, 0777, 'sfv3.php'));
108
        dump('ALLOCATE',        ftp_alloc  ($stream, filesize($Ubinary), $msg), $msg);
109
        dump('UPLOAD ASCII',    ftp_put    ($stream, $Uasci, $Uasci, FTP_ASCII), $Uasci);
110
        dump('UPLOAD BINARY',   ftp_put    ($stream, $Ubinary, $Ubinary, FTP_BINARY), $Ubinary);
111
        dump('RAWLIST "."',     ftp_rawlist($stream, '.'));
112
        dump('DELETE '.$Uasci,  ftp_delete ($stream, $Uasci));
113
        dump('DELETE '.$Bbinary,ftp_delete ($stream, $Ubinary));
114
        dump('RAWLIST "."',     ftp_rawlist($stream, '.'));
115
    }
116
    dump('QUIT',                ftp_quit   ($stream));
117
}
118
 
119
list($usec, $sec) = explode(' ', microtime());
120
$end = (float)$usec + (float)$sec;
121
echo $end-$time;
122
?>
123
 
124
</pre>