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