Rev 4 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | <?php |
2 | |||
3 | daniel-mar | 3 | if (!defined('IBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.'); |
2 | daniel-mar | 4 | |
5 | if ($ib_user_type < 2) die('Keine Zugriffsberechtigung'); |
||
6 | |||
7 | function ftp_rmdir_rec($handle, $path) |
||
8 | { |
||
9 | if (!@ftp_delete($handle, $path)) |
||
10 | { |
||
11 | $list = @ftp_nlist($handle, $path); |
||
12 | if(!empty($list)) |
||
13 | foreach($list as $value) |
||
14 | ftp_rmdir_rec($handle, $value); |
||
15 | } |
||
16 | |||
17 | if(@ftp_rmdir($handle, $path)) |
||
18 | return true; |
||
19 | else |
||
20 | return false; |
||
21 | } |
||
22 | |||
23 | if (($aktion == 'delete') || ($aktion == 'install')) |
||
24 | { |
||
25 | // Funktioniert FTP-Zugang? |
||
26 | |||
3 | daniel-mar | 27 | if ($konfiguration['core_directftp']['ftp-server'] == '') { |
28 | $conn_id = null; |
||
29 | $login_result = false; |
||
30 | } else { |
||
31 | $conn_id = @ftp_connect($konfiguration['core_directftp']['ftp-server'], $konfiguration['core_directftp']['ftp-port']); |
||
32 | $login_result = @ftp_login ($conn_id, $konfiguration['core_directftp']['ftp-username'], $konfiguration['core_directftp']['ftp-passwort']); |
||
33 | } |
||
2 | daniel-mar | 34 | |
35 | $fehler = 0; |
||
36 | |||
37 | if ((!$conn_id) || (!$login_result)) |
||
38 | $fehler = 1; |
||
39 | |||
40 | 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) != '/')) |
||
41 | $fehler = 1; |
||
42 | |||
43 | if ($fehler) |
||
8 | daniel-mar | 44 | 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); |
2 | daniel-mar | 45 | } |
46 | |||
47 | // Los gehts! |
||
48 | |||
49 | if ($aktion == 'delete') |
||
50 | { |
||
51 | // Nun Design über FTP löschen! |
||
8 | daniel-mar | 52 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($entfernen)); |
3 | daniel-mar | 53 | if ($conn_id) @ftp_quit($conn_id); |
2 | daniel-mar | 54 | |
55 | // Info: MySQL-Daten löschen sich über Autostart automatisch |
||
8 | daniel-mar | 56 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
2 | daniel-mar | 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) |
||
8 | daniel-mar | 65 | 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)) |
2 | daniel-mar | 66 | { |
3 | daniel-mar | 67 | if ($conn_id) @ftp_quit($conn_id); |
8 | daniel-mar | 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=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
2 | daniel-mar | 69 | } |
8 | daniel-mar | 70 | @ftp_site($conn_id, 'CHMOD 0644 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
2 | daniel-mar | 71 | |
72 | // Temporäres Verzeichnis für Extraktion erstellen |
||
8 | daniel-mar | 73 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
74 | @ftp_mkdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
75 | @ftp_site($conn_id, 'CHMOD 0755 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
||
2 | daniel-mar | 76 | |
3 | daniel-mar | 77 | // Entpacken zum Personal WebBase-Temp-Verzeichnis |
8 | daniel-mar | 78 | if (file_exists('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php')) |
79 | include('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php'); |
||
80 | $zip = new dUnzip2('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
||
81 | $zip->unzipAll('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/', '', true); |
||
2 | daniel-mar | 82 | $zip->close(); |
83 | |||
84 | // Temporäre Daten löschen |
||
8 | daniel-mar | 85 | @ftp_delete($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
2 | daniel-mar | 86 | |
87 | // Wenn Verzeichnis leer ist, lässt es sich löschen. -> Fehler |
||
8 | daniel-mar | 88 | $verzinh = @ftp_nlist($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
2 | daniel-mar | 89 | if (count($verzinh) == 0) |
90 | { |
||
8 | daniel-mar | 91 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
3 | daniel-mar | 92 | if ($conn_id) @ftp_quit($conn_id); |
8 | daniel-mar | 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=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
2 | daniel-mar | 94 | } |
95 | |||
96 | // Verzeichnis verschieben |
||
8 | daniel-mar | 97 | 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).'/')) |
2 | daniel-mar | 98 | { |
8 | daniel-mar | 99 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
3 | daniel-mar | 100 | if ($conn_id) @ftp_quit($conn_id); |
8 | daniel-mar | 101 | 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); |
2 | daniel-mar | 102 | } |
103 | |||
104 | // Richtigen Dateinamen finden |
||
8 | daniel-mar | 105 | $fn = 'design/'.wb_dir_escape($uid).'/ordnername.txt'; |
2 | daniel-mar | 106 | $fp = @fopen($fn, 'r'); |
107 | $inhalt = @fread($fp, @filesize($fn)); |
||
108 | @fclose($fp); |
||
109 | |||
110 | // Datei ordnername.txt im Zielmodul löschen |
||
8 | daniel-mar | 111 | @ftp_delete ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($uid).'/ordnername.txt'); |
2 | daniel-mar | 112 | |
113 | if ($inhalt != '') |
||
114 | { |
||
115 | // Schutzverletzung im Ordnernamen? |
||
116 | if (strpos($inhalt, '..')) |
||
117 | { |
||
3 | daniel-mar | 118 | if ($conn_id) @ftp_quit($conn_id); |
2 | daniel-mar | 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 |
||
8 | daniel-mar | 123 | if (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($inhalt).'/')) |
2 | daniel-mar | 124 | { |
125 | @ftp_cdup($conn_id); |
||
126 | $zusatz = 2; |
||
127 | $problem = true; |
||
8 | daniel-mar | 128 | while (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'design/'.wb_dir_escape($inhalt).$zusatz.'/')) |
2 | daniel-mar | 129 | { |
130 | @ftp_cdup($conn_id); |
||
131 | $zusatz++; |
||
132 | } |
||
133 | } |
||
134 | else |
||
135 | { |
||
136 | $problem = false; |
||
137 | $zusatz = ''; |
||
138 | } |
||
139 | |||
140 | // Ordner umbenennen |
||
8 | daniel-mar | 141 | $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); |
2 | daniel-mar | 142 | |
143 | // FTP-Verbindung trennen |
||
3 | daniel-mar | 144 | if ($conn_id) @ftp_quit($conn_id); |
2 | daniel-mar | 145 | |
146 | // Wurde der Ordner nicht umbenannt? (z.B. Wenn der Ordnertitel nicht für Dateisystem zulässig war) |
||
147 | if (!$erfolg) |
||
8 | daniel-mar | 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=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
2 | daniel-mar | 149 | |
150 | // Wurde nur der Ordner nicht korrekt umbenannt? (z.B. wenn es ein Design mit dem selben Namen noch gibt) |
||
151 | if ($problem) |
||
8 | daniel-mar | 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=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
2 | daniel-mar | 153 | } |
154 | else |
||
155 | { |
||
156 | // Kein Dateiname angegeben? |
||
3 | daniel-mar | 157 | if ($conn_id) @ftp_quit($conn_id); |
8 | daniel-mar | 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=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
2 | daniel-mar | 159 | } |
160 | |||
161 | // Alles OK? Dann zurück! |
||
8 | daniel-mar | 162 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
2 | daniel-mar | 163 | } |
164 | |||
165 | if ($aktion == 'changekonfig') |
||
166 | { |
||
167 | ib_change_config('design', $newdesign, $modul); |
||
168 | echo '<script language="JavaScript" type="text/javascript"> |
||
169 | <!-- |
||
170 | |||
8 | daniel-mar | 171 | parent.location.href = \'index.php?prv_modul='.urlencode($vonmodul).'&prv_seite='.urlencode($vonseite).'\'; |
2 | daniel-mar | 172 | |
173 | // --> |
||
174 | </script>'; |
||
175 | |||
176 | // Funktioniert nicht für eine Designänderung: if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul=admin_konfig'); |
||
177 | } |
||
178 | |||
3 | daniel-mar | 179 | ?> |