ftp-class

Gesponsorde koppelingen

PHP script bestanden

  1. ftp-class

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
// ini_set ('error_reporting', E_ALL | E_STRICT)
class FTP_Easy
{
    protected $streams = array ();
    
    public function Connect ($host, $port = '21', $timeout = 90, $StreamName = 'base')
    {

        $chk    = ftp_connect ($host, $port, $timeout);
        if ($chk)
        {

            $this->streams[$StreamName]    = $chk;
            return $chk;
        }

        return false;
    }


    public function Log_in ($username, $password, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
            return ftp_login ($this->streams[$StreamName], $username, $password);
        
        return false;
    }


    public function Close ($StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            unset ($this->streams[$StreamName]);
            return ftp_quit ($this->streams[$StreamName]);
        }

        
        return false;
    }


    public function DoPASV ($StreamName = 'base', $on = true)
    {

        $on = ($on == true) ? true : false;
        return ftp_pasv ($StreamName, $on);
    }


    public function PutFile ($rfile, $lfile, $type = FTP_ASCII, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk     = ftp_put ($this->streams[$StreamName], $rfile, $lfile, $type);
            return (file_exists ($lfile) && ($type == FTP_ASCII || $type == FTP_BINARY) && $chk) ? $chk : false;
        }

        return false;
    }


    public function GetFile ($rfile, $lfile, $type = FTP_ASCII, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk     = ftp_get ($this->streams[$StreamName], $lfile, $rfile, $type);
            return (file_exists ($lfile) && ($type == FTP_ASCII || $type == FTP_BINARY) && $chk) ? $chk : false;
        }

        return false;
    }


    public function DelFile ($file, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk     = ftp_delete ($this->streams[$StreamName], $file);
            return $chk;
        }

        return false;
    }


    public function GetFileSize ($file, $StreamName = 'base')
    {

        return ftp_size ($StreamName, $file);
    }


    public function Rename ($old, $new, $StreamName = 'base')
    {

        return ftp_rename ($StreamName, $old, $new);
    }


    public function DelDir ($dir, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk     = ftp_rmdir ($this->streams[$StreamName], $dir);
            return $chk;
        }

        return false;
    }


    public function MakeDir ($dir, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk     = ftp_mkdir ($this->streams[$StreamName], $dir);
            return $chk;
        }

        return false;
    }


    private function GetStreamStatus ($StreamName = 'base')
    {

        if (isset ($this->streams[$StreamName]))
            return true;
        
        return false;
    }


    public function ListDirFiles ($directory, $raw = false, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $func    = ($raw == false) ? 'ftp_nlist' : 'ftp_rawlist';
            $chk    = $func ($this->streams[$StreamName], $directory);
            if (is_array ($chk))
            {

                $arr    = array ();
                foreach ($chk as $key => $file)
                    $arr[] = ($raw == false) ? str_replace ($directory . '/', '', $file) : $file;

                return $arr;
            }

            return false;
        }

        return false;
    }


    public function SendRaw ($raw, $StreamName = 'base')
    {

        if ($this->GetStreamStatus ($StreamName) == true)
        {

            $chk    = ftp_exec ($this->streams[$StreamName], $raw);
            return $chk;
        }

        return false;
    }


    public function GetCurrentDir ($StreamName = 'base')
    {

        return ftp_pwd ($StreamName);
    }


    public function SwitchDir ($dir, $StreamName = 'base')
    {

        return ftp_chdir ($StreamName, $dir);
    }


    public function DoCHMOD ($path, $chmod, $StreamName = 'base')
    {

        $chk    = (ftp_chmod ($StreamName, $chmod, $path) == false) ? false : true;
        return $chk;
    }
}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.