Rev 12 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
12 | daniel-mar | 1 | <?php |
2 | |||
14 | daniel-mar | 3 | if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.'); |
12 | daniel-mar | 4 | |
14 | daniel-mar | 5 | if ($wb_user_type < 2) die('Keine Zugriffsberechtigung'); |
12 | daniel-mar | 6 | |
7 | function ftp_rmdir_rec($handle, $path) |
||
8 | { |
||
9 | if (!@ftp_delete($handle, $path)) |
||
10 | { |
||
11 | $list = @ftp_nlist($handle, $path); |
||
14 | daniel-mar | 12 | if(!empty($list)) { |
13 | foreach($list as $value) { |
||
12 | daniel-mar | 14 | ftp_rmdir_rec($handle, $value); |
14 | daniel-mar | 15 | } |
16 | } |
||
12 | daniel-mar | 17 | } |
18 | |||
14 | daniel-mar | 19 | if(@ftp_rmdir($handle, $path)) { |
12 | daniel-mar | 20 | return true; |
14 | daniel-mar | 21 | } else { |
12 | daniel-mar | 22 | return false; |
14 | daniel-mar | 23 | } |
12 | daniel-mar | 24 | } |
25 | |||
26 | if (($aktion == 'delete') || ($aktion == 'install')) |
||
27 | { |
||
28 | // Funktioniert FTP-Zugang? |
||
29 | |||
30 | if ($konfiguration['core_directftp']['ftp-server'] == '') { |
||
31 | $conn_id = null; |
||
32 | $login_result = false; |
||
33 | } else { |
||
34 | $conn_id = @ftp_connect($konfiguration['core_directftp']['ftp-server'], $konfiguration['core_directftp']['ftp-port']); |
||
35 | $login_result = @ftp_login ($conn_id, $konfiguration['core_directftp']['ftp-username'], $konfiguration['core_directftp']['ftp-passwort']); |
||
36 | } |
||
37 | |||
38 | $fehler = 0; |
||
39 | |||
40 | if ((!$conn_id) || (!$login_result)) |
||
41 | $fehler = 1; |
||
42 | |||
43 | if ((@ftp_size($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.'desdir.txt') == -1) || (@ftp_size($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.'moddir.txt') == -1) || (substr($konfiguration['core_directftp']['ftp-verzeichnis'], 0, 1) != '/') || (substr($konfiguration['core_directftp']['ftp-verzeichnis'], strlen($konfiguration['core_directftp']['ftp-verzeichnis'])-1, 1) != '/')) |
||
44 | $fehler = 1; |
||
45 | |||
46 | if ($fehler) |
||
47 | die($header.'<b>Fehler</b><br><br>Fehlkonfiguration im FTP-Direktzugriff-Kernmodul! FTP-Zugangsdaten oder -Verzeichnis fehlerhaft bzw. zu geringe Zugriffsrechte! Bitte <a href="'.$_SERVER['PHP_SELF'].'?modul=core_directftp&seite=konfig&vonmodul='.urlencode($modul).'">Konfigurationswerte</a> einsehen.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
48 | } |
||
49 | |||
50 | // Los gehts! |
||
51 | |||
52 | if ($aktion == 'delete') |
||
53 | { |
||
54 | // Nun Design über FTP löschen! |
||
55 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($entfernen)); |
||
56 | if ($conn_id) @ftp_quit($conn_id); |
||
57 | |||
58 | // Info: MySQL-Daten löschen sich über Autostart automatisch |
||
59 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
||
60 | } |
||
61 | |||
62 | if ($aktion == 'install') |
||
63 | { |
||
64 | // Temp-Verzeichnisnamen finden |
||
65 | $uid = 'temp_'.zufall(10); |
||
66 | |||
67 | // Datei in unser Verzeichnis kopieren, sodass wir darauf zugreifen können (für Safe-Mode) |
||
68 | if (!@ftp_put($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip', $_FILES['dfile']['tmp_name'], FTP_BINARY)) |
||
69 | { |
||
70 | if ($conn_id) @ftp_quit($conn_id); |
||
71 | die($header.'<b>Fehler</b><br><br>Konnte ZIP-Datei nicht in temporäres Verzeichnis des Modules hineinkopieren (FTP)!.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
72 | } |
||
73 | @ftp_site($conn_id, 'CHMOD 0644 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
||
74 | |||
75 | // Temporäres Verzeichnis für Extraktion erstellen |
||
76 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
77 | @ftp_mkdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
78 | @ftp_site($conn_id, 'CHMOD 0755 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
79 | |||
80 | // Entpacken zum Personal WebBase-Temp-Verzeichnis |
||
81 | if (file_exists('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php')) |
||
82 | include('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php'); |
||
83 | $zip = new dUnzip2('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
||
84 | $zip->unzipAll('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/', '', true); |
||
85 | $zip->close(); |
||
86 | |||
87 | // Temporäre Daten löschen |
||
88 | @ftp_delete($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
||
89 | |||
90 | // Wenn Verzeichnis leer ist, lässt es sich löschen. -> Fehler |
||
91 | $verzinh = @ftp_nlist($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
92 | if (count($verzinh) == 0) |
||
93 | { |
||
94 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
95 | if ($conn_id) @ftp_quit($conn_id); |
||
96 | die($header.'<b>Fehler</b><br><br>Dekompression entweder komplett misslungen oder ZIP-Datei war leer.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
97 | } |
||
98 | |||
99 | // Verzeichnis verschieben |
||
100 | if (!@ftp_rename($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/', $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($uid).'/')) |
||
101 | { |
||
102 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
103 | if ($conn_id) @ftp_quit($conn_id); |
||
104 | die($header.'<b>Fehler</b><br><br>Das Verschieben des Verzeichnisses ist misslungen!<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
105 | } |
||
106 | |||
107 | // Richtigen Dateinamen finden |
||
108 | $fn = 'design/'.wb_dir_escape($uid).'/ordnername.txt'; |
||
109 | $fp = @fopen($fn, 'r'); |
||
110 | $inhalt = @fread($fp, @filesize($fn)); |
||
111 | @fclose($fp); |
||
112 | |||
113 | // Datei ordnername.txt im Zielmodul löschen |
||
114 | @ftp_delete ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($uid).'/ordnername.txt'); |
||
115 | |||
116 | if ($inhalt != '') |
||
117 | { |
||
118 | // Schutzverletzung im Ordnernamen? |
||
119 | if (strpos($inhalt, '..')) |
||
120 | { |
||
121 | if ($conn_id) @ftp_quit($conn_id); |
||
122 | die($header.'<b>Fehler</b><br><br>Das Design konnte zwar installiert werden, jedoch gab es bei der Umbenennung des Ordners eine Schutzverletzung!'.$footer); |
||
123 | } |
||
124 | |||
125 | // Gibt es schon ein Design mit dem Titel? Dann Alternativenamen finden |
||
126 | if (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($inhalt).'/')) |
||
127 | { |
||
128 | @ftp_cdup($conn_id); |
||
129 | $zusatz = 2; |
||
130 | $problem = true; |
||
131 | while (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($inhalt).$zusatz.'/')) |
||
132 | { |
||
133 | @ftp_cdup($conn_id); |
||
134 | $zusatz++; |
||
135 | } |
||
136 | } |
||
137 | else |
||
138 | { |
||
139 | $problem = false; |
||
140 | $zusatz = ''; |
||
141 | } |
||
142 | |||
143 | // Ordner umbenennen |
||
144 | $erfolg = @ftp_rename ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($uid), $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($inhalt).$zusatz); |
||
145 | |||
146 | // FTP-Verbindung trennen |
||
147 | if ($conn_id) @ftp_quit($conn_id); |
||
148 | |||
149 | // Wurde der Ordner nicht umbenannt? (z.B. Wenn der Ordnertitel nicht für Dateisystem zulässig war) |
||
150 | if (!$erfolg) |
||
151 | die($header.'<b>Information</b><br><br>Das Design konnte zwar installiert werden, jedoch gab es bei der Umbenennung des Ordners einen Fehler!<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
152 | |||
153 | // Wurde nur der Ordner nicht korrekt umbenannt? (z.B. wenn es ein Design mit dem selben Namen noch gibt) |
||
154 | if ($problem) |
||
155 | die($header.'<b>Information</b><br><br>Es existiert bereits ein Design mit dem Namen "'.$inhalt.'". Das Design wurde trotzdem unter dem alternativen Namen "'.$inhalt.$zusatz.'" installiert.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
156 | } |
||
157 | else |
||
158 | { |
||
159 | // Kein Dateiname angegeben? |
||
160 | if ($conn_id) @ftp_quit($conn_id); |
||
161 | die($header.'<b>Information</b><br><br>Das Design wurde unter dem Namen "'.$uid.'" angelegt, da in der Designdatei keine Namensangabe vorhanden war.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
||
162 | } |
||
163 | |||
164 | // Alles OK? Dann zurück! |
||
165 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
||
166 | } |
||
167 | |||
168 | if ($aktion == 'changekonfig') |
||
169 | { |
||
170 | ib_change_config('design', $newdesign, $modul); |
||
171 | echo '<script language="JavaScript" type="text/javascript"> |
||
172 | <!-- |
||
173 | |||
174 | parent.location.href = \'index.php?prv_modul='.urlencode($vonmodul).'&prv_seite='.urlencode($vonseite).'\'; |
||
175 | |||
176 | // --> |
||
177 | </script>'; |
||
178 | |||
179 | // Funktioniert nicht für eine Designänderung: if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul=admin_konfig'); |
||
180 | } |
||
181 | |||
182 | ?> |