Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
 
5
/**
6
 * Net_FTP general example.
7
 *
8
 * General example file for the usage of Net_FTP.
9
 *
10
 * PHP versions 4 and 5
11
 *
12
 * LICENSE: This source file is subject to version 3.0 of the PHP license
13
 * that is available through the world-wide-web at the following URI:
14
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
15
 * the PHP License and are unable to obtain it through the web, please
16
 * send a note to license@php.net so we can mail you a copy immediately.
17
 *
18
 * @category   Networking
19
 * @package    FTP
20
 * @author     Tobias Schlitt <toby@php.net>
21
 * @copyright  1997-2005 The PHP Group
22
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
23
 * @version    CVS: $Id: index.php,v 1.4 2005/02/23 12:12:23 toby Exp $
24
 * @link       http://pear.php.net/package/Net_FTP
25
 * @since      File available since Release 0.0.1
26
 */
27
 
28
require_once 'Net/FTP.php';
29
require_once 'Var_Dump.php';
30
 
31
/**
32
 * Setting up test variables. The following variables have to be set
33
 * up, to suite the needs of your environment.
34
 */
35
 
36
$host           = '';
37
$port           = 21;
38
$user           = '';
39
$pass           = '';
40
 
41
// The local base directory for FTP operations.
42
$baseDir        = './test/';
43
// The directory to upload to the FTP server for testing.
44
$testUpDir      = 'test_up/';
45
// The directory to download to for testing.
46
$testDownDir    = 'test_down/';
47
// The file for single file up- and download testing.
48
$singleTestFile = 'test.zip';
49
 
50
// Initializing Var_Var_Dump::display
51
if (isset($_SERVER)) {
52
    // Setup for displaying XHTML output.
53
    Var_Dump::displayInit(array(
54
        'display_mode'=>'XHTML_Text'
55
    ), array(
56
        'mode'=>'normal',
57
        'offset'=>4
58
    ));
59
    // Headline function for XHTML output.
60
    function head ( $text ) {
61
        echo '<br /><b>'.$text.'</b><br />';
62
    }
63
} else {
64
    // Setup for displaying console output.
65
    Var_Dump::displayInit(array('display_mode'=>'Text'));
66
    // Headline function for XHTML output.
67
    function head ( $text ) {
68
        echo "\n--- ".$text." ---\n";
69
    }
70
}
71
 
72
head("\$ftp = new Net_FTP();");
73
$ftp = new Net_FTP();
74
 
75
head("\$ftp->setHostname($host)");
76
Var_Dump::display($ftp->setHostname($host));
77
 
78
head("\$ftp->setPort($port)");
79
Var_Dump::display($ftp->setPort($port));
80
 
81
head("\$ftp->connect($host, $port)");
82
Var_Dump::display($ftp->connect());
83
 
84
head("\$ftp->setUsername($user)");
85
Var_Dump::display($ftp->setUsername($user));
86
 
87
head("\$ftp->setPassword(xxx)");
88
Var_Dump::display($ftp->setPassword($pass));
89
 
90
head("\$ftp->login($user, xxx)");
91
Var_Dump::display($ftp->login($user, $pass));
92
 
93
head("\$ftp->pwd()");
94
Var_Dump::display($ftp->pwd());
95
 
96
head("\$ftp->ls(null, NET_FTP_DIRS_FILES)");
97
Var_Dump::display($ftp->ls(null, NET_FTP_DIRS_FILES));
98
 
99
head("\$ftp->mkdir($baseDir)");
100
Var_Dump::display($ftp->mkdir($baseDir));
101
 
102
head("\$ftp->cd($baseDir)");
103
Var_Dump::display($ftp->cd($baseDir));
104
 
105
head("\$ftp->ls(null, NET_FTP_RAWLIST)");
106
Var_Dump::display($ftp->ls(null, NET_FTP_RAWLIST));
107
 
108
head("\$ftp->put($baseDir$singleTestFile, $singleTestFile)");
109
Var_Dump::display($ftp->put($baseDir.$singleTestFile, $singleTestFile));
110
 
111
head("\$ftp->ls(null, NET_FTP_FILES_ONLY)");
112
Var_Dump::display($ftp->ls(null, NET_FTP_FILES_ONLY));
113
 
114
head("\$ftp->put($baseDir$singleTestFile, $singleTestFile, true)");
115
Var_Dump::display($ftp->put($baseDir.$singleTestFile, $singleTestFile, true));
116
 
117
head("\$ftp->ls(null, NET_FTP_FILES_ONLY)");
118
Var_Dump::display($ftp->ls(null, NET_FTP_FILES_ONLY));
119
 
120
head("\$ftp->mdtm($singleTestFile, 'd.m.Y H:i:s')");
121
Var_Dump::display($ftp->mdtm($singleTestFile, 'd.m.Y'));
122
 
123
head("\$ftp->size($singleTestFile)");
124
Var_Dump::display($ftp->size($singleTestFile));
125
 
126
head("\$ftp->get($singleTestFile, $baseDir$singleTestFile, true)");
127
Var_Dump::display($ftp->get($singleTestFile, $baseDir.$singleTestFile, true));
128
 
129
head("\$ftp->chmod($singleTestFile, 700)");
130
Var_Dump::display($ftp->chmod($singleTestFile, 700));
131
 
132
head("\$ftp->ls(null, NET_FTP_FILES_ONLY)");
133
Var_Dump::display($ftp->ls(null, NET_FTP_FILES_ONLY));
134
 
135
head("\$ftp->cd('../')");
136
Var_Dump::display($ftp->cd('../'));
137
 
138
head("\$ftp->chmodRecursive($baseDir, 777)");
139
Var_Dump::display($ftp->chmodRecursive($baseDir, 777));
140
 
141
head("\$ftp->ls(null, NET_FTP_DIRS_ONLY)");
142
Var_Dump::display($ftp->ls(null, NET_FTP_DIRS_ONLY));
143
 
144
head("\$ftp->putRecursive($baseDir$testUpDir, $baseDir$testUpDir)");
145
Var_Dump::display($ftp->putRecursive($baseDir.$testUpDir, $baseDir.$testUpDir));
146
 
147
head("\$ftp->putRecursive($baseDir$testUpDir, $baseDir$testUpDir)");
148
Var_Dump::display($ftp->putRecursive($baseDir.$testUpDir, $baseDir.$testUpDir, true));
149
 
150
head("\$ftp->cd($baseDir:$testUpDir)");
151
Var_Dump::display($ftp->cd($baseDir.$testUpDir));
152
 
153
head("\$ftp->ls(null, NET_FTP_DIRS_FILES)");
154
Var_Dump::display($ftp->ls(null, NET_FTP_DIRS_FILES));
155
 
156
head("\$ftp->cd(../../)");
157
Var_Dump::display($ftp->cd('../../'));
158
 
159
head("\$ftp->getRecursive($baseDir$testUpDir, $baseDir$testDownDir)");
160
Var_Dump::display($ftp->getRecursive($baseDir.$testUpDir, $baseDir.$testDownDir, true));
161
 
162
head("\$ftp->rm($baseDir, true)");
163
Var_Dump::display($ftp->rm($baseDir, true));
164
 
165
head("\$ftp->ls(null, NET_FTP_DIRS_ONLY)");
166
Var_Dump::display($ftp->ls(null, NET_FTP_DIRS_ONLY));
167
 
168
head("\$ftp->disconnect()");
169
Var_Dump::display($ftp->disconnect());
170
?>