Rev 12 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12 | Rev 14 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | if (!defined('IBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.'); |
3 | if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.'); |
4 | 4 | ||
5 | function ftp_rmdir_rec($handle, $path) |
5 | function ftp_rmdir_rec($handle, $path) |
6 | { |
6 | { |
7 | if (!@ftp_delete($handle, $path)) |
7 | if (!@ftp_delete($handle, $path)) |
8 | { |
8 | { |
9 | $list = @ftp_nlist($handle, $path); |
9 | $list = @ftp_nlist($handle, $path); |
10 | if(!empty($list)) |
10 | if(!empty($list)) |
11 | foreach($list as $value) |
11 | foreach($list as $value) |
12 | ftp_rmdir_rec($handle, $value); |
12 | ftp_rmdir_rec($handle, $value); |
13 | } |
13 | } |
14 | 14 | ||
15 | if(@ftp_rmdir($handle, $path)) |
15 | if(@ftp_rmdir($handle, $path)) |
16 | return true; |
16 | return true; |
17 | else |
17 | else |
18 | return false; |
18 | return false; |
19 | } |
19 | } |
20 | 20 | ||
21 | // Funktioniert FTP-Zugang? |
21 | // Funktioniert FTP-Zugang? |
22 | 22 | ||
23 | if ($konfiguration['core_directftp']['ftp-server'] == '') { |
23 | if ($konfiguration['core_directftp']['ftp-server'] == '') { |
24 | $conn_id = null; |
24 | $conn_id = null; |
25 | $login_result = false; |
25 | $login_result = false; |
26 | } else { |
26 | } else { |
27 | $conn_id = @ftp_connect($konfiguration['core_directftp']['ftp-server'], $konfiguration['core_directftp']['ftp-port']); |
27 | $conn_id = @ftp_connect($konfiguration['core_directftp']['ftp-server'], $konfiguration['core_directftp']['ftp-port']); |
28 | $login_result = @ftp_login ($conn_id, $konfiguration['core_directftp']['ftp-username'], $konfiguration['core_directftp']['ftp-passwort']); |
28 | $login_result = @ftp_login ($conn_id, $konfiguration['core_directftp']['ftp-username'], $konfiguration['core_directftp']['ftp-passwort']); |
29 | } |
29 | } |
30 | 30 | ||
31 | $fehler = 0; |
31 | $fehler = 0; |
32 | 32 | ||
33 | if ((!$conn_id) || (!$login_result)) |
33 | if ((!$conn_id) || (!$login_result)) |
34 | $fehler = 1; |
34 | $fehler = 1; |
35 | 35 | ||
36 | if ((@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) != '/')) |
36 | if ((@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) != '/')) |
37 | $fehler = 1; |
37 | $fehler = 1; |
38 | 38 | ||
39 | if ($fehler) |
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=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); |
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=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); |
41 | 41 | ||
42 | // Los gehts! |
42 | // Los gehts! |
43 | 43 | ||
44 | if ($aktion == 'delete') |
44 | if ($aktion == 'delete') |
45 | { |
45 | { |
46 | // Nun Modul über FTP löschen! |
46 | // Nun Modul über FTP löschen! |
47 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($entfernen)); |
47 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($entfernen)); |
48 | if ($conn_id) @ftp_quit($conn_id); |
48 | if ($conn_id) @ftp_quit($conn_id); |
49 | 49 | ||
50 | // Info: MySQL-Daten löschen sich über Autostart automatisch |
50 | // Info: MySQL-Daten löschen sich über Autostart automatisch |
51 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
51 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
52 | } |
52 | } |
53 | 53 | ||
54 | if ($aktion == 'install') |
54 | if ($aktion == 'install') |
55 | { |
55 | { |
56 | // Temp-Verzeichnisnamen finden |
56 | // Temp-Verzeichnisnamen finden |
57 | $uid = 'temp_'.zufall(10); |
57 | $uid = 'temp_'.zufall(10); |
58 | 58 | ||
59 | // Datei in unser Verzeichnis kopieren, sodass wir darauf zugreifen können (für Safe-Mode) |
59 | // Datei in unser Verzeichnis kopieren, sodass wir darauf zugreifen können (für Safe-Mode) |
60 | 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)) |
60 | 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)) |
61 | { |
61 | { |
62 | if ($conn_id) @ftp_quit($conn_id); |
62 | if ($conn_id) @ftp_quit($conn_id); |
63 | 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); |
63 | 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); |
64 | } |
64 | } |
65 | @ftp_site($conn_id, 'CHMOD 0644 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
65 | @ftp_site($conn_id, 'CHMOD 0644 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
66 | 66 | ||
67 | // Temporäres Verzeichnis für Extraktion erstellen |
67 | // Temporäres Verzeichnis für Extraktion erstellen |
68 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
68 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
69 | @ftp_mkdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
69 | @ftp_mkdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
70 | @ftp_site($conn_id, 'CHMOD 0755 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
70 | @ftp_site($conn_id, 'CHMOD 0755 '.$konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
71 | 71 | ||
72 | // Entpacken zum Personal WebBase-Temp-Verzeichnis |
72 | // Entpacken zum Personal WebBase-Temp-Verzeichnis |
73 | if (file_exists('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php')) |
73 | if (file_exists('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php')) |
74 | include('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php'); |
74 | include('modules/'.wb_dir_escape($modul).'/dUnzip2.inc.php'); |
75 | $zip = new dUnzip2('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
75 | $zip = new dUnzip2('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
76 | $zip->unzipAll('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/', '', true); |
76 | $zip->unzipAll('modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/', '', true); |
77 | $zip->close(); |
77 | $zip->close(); |
78 | 78 | ||
79 | // Temporäre Daten löschen |
79 | // Temporäre Daten löschen |
80 | @ftp_delete($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
80 | @ftp_delete($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'.zip'); |
81 | 81 | ||
82 | // Wenn Verzeichnis leer ist, lässt es sich löschen. -> Fehler |
82 | // Wenn Verzeichnis leer ist, lässt es sich löschen. -> Fehler |
83 | $verzinh = @ftp_nlist($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
83 | $verzinh = @ftp_nlist($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
84 | if (count($verzinh) == 0) |
84 | if (count($verzinh) == 0) |
85 | { |
85 | { |
86 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
86 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
87 | if ($conn_id) @ftp_quit($conn_id); |
87 | if ($conn_id) @ftp_quit($conn_id); |
88 | 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); |
88 | 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); |
89 | } |
89 | } |
90 | 90 | ||
91 | // Verzeichnis verschieben |
91 | // Verzeichnis verschieben |
92 | 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'].'modules/'.wb_dir_escape($uid).'/')) |
92 | 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'].'modules/'.wb_dir_escape($uid).'/')) |
93 | { |
93 | { |
94 | @ftp_rmdir_rec($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($modul).'/temp/'.wb_dir_escape($uid).'/'); |
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); |
95 | if ($conn_id) @ftp_quit($conn_id); |
96 | 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); |
96 | 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); |
97 | } |
97 | } |
98 | 98 | ||
99 | // Richtigen Dateinamen finden |
99 | // Richtigen Dateinamen finden |
100 | $fn = 'modules/'.wb_dir_escape($uid).'/ordnername.txt'; |
100 | $fn = 'modules/'.wb_dir_escape($uid).'/ordnername.txt'; |
101 | $fp = @fopen($fn, 'r'); |
101 | $fp = @fopen($fn, 'r'); |
102 | $inhalt = @fread($fp, @filesize($fn)); |
102 | $inhalt = @fread($fp, @filesize($fn)); |
103 | @fclose($fp); |
103 | @fclose($fp); |
104 | 104 | ||
105 | // Datei ordnername.txt im Zielmodul löschen |
105 | // Datei ordnername.txt im Zielmodul löschen |
106 | @ftp_delete ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($uid).'/ordnername.txt'); |
106 | @ftp_delete ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($uid).'/ordnername.txt'); |
107 | 107 | ||
108 | if ($inhalt != '') |
108 | if ($inhalt != '') |
109 | { |
109 | { |
110 | // Schutzverletzung im Ordnernamen? |
110 | // Schutzverletzung im Ordnernamen? |
111 | if (strpos($inhalt, '..')) |
111 | if (strpos($inhalt, '..')) |
112 | { |
112 | { |
113 | if ($conn_id) @ftp_quit($conn_id); |
113 | if ($conn_id) @ftp_quit($conn_id); |
114 | die($header.'<b>Fehler</b><br><br>Das Modul konnte zwar installiert werden, jedoch gab es bei der Umbenennung des Ordners eine Schutzverletzung!<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
114 | die($header.'<b>Fehler</b><br><br>Das Modul konnte zwar installiert werden, jedoch gab es bei der Umbenennung des Ordners eine Schutzverletzung!<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
115 | } |
115 | } |
116 | 116 | ||
117 | // Gibt es schon ein Modul mit dem Titel? Dann Alternativenamen finden |
117 | // Gibt es schon ein Modul mit dem Titel? Dann Alternativenamen finden |
118 | if (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).'/')) |
118 | if (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).'/')) |
119 | { |
119 | { |
120 | @ftp_cdup($conn_id); |
120 | @ftp_cdup($conn_id); |
121 | $zusatz = 2; |
121 | $zusatz = 2; |
122 | $problem = true; |
122 | $problem = true; |
123 | while (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).$zusatz.'/')) |
123 | while (@ftp_chdir($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).$zusatz.'/')) |
124 | { |
124 | { |
125 | @ftp_cdup($conn_id); |
125 | @ftp_cdup($conn_id); |
126 | $zusatz++; |
126 | $zusatz++; |
127 | } |
127 | } |
128 | } |
128 | } |
129 | else |
129 | else |
130 | { |
130 | { |
131 | $problem = false; |
131 | $problem = false; |
132 | $zusatz = ''; |
132 | $zusatz = ''; |
133 | } |
133 | } |
134 | 134 | ||
135 | // Ordner umbenennen |
135 | // Ordner umbenennen |
136 | $erfolg = @ftp_rename ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($uid), $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).$zusatz); |
136 | $erfolg = @ftp_rename ($conn_id, $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($uid), $konfiguration['core_directftp']['ftp-verzeichnis'].'modules/'.wb_dir_escape($inhalt).$zusatz); |
137 | 137 | ||
138 | // FTP-Verbindung trennen |
138 | // FTP-Verbindung trennen |
139 | if ($conn_id) @ftp_quit($conn_id); |
139 | if ($conn_id) @ftp_quit($conn_id); |
140 | 140 | ||
141 | // Wurde der Ordner nicht umbenannt? (z.B. Wenn der Ordnertitel nicht für Dateisystem zulässig war) |
141 | // Wurde der Ordner nicht umbenannt? (z.B. Wenn der Ordnertitel nicht für Dateisystem zulässig war) |
142 | if (!$erfolg) |
142 | if (!$erfolg) |
143 | die($header.'<b>Information</b><br><br>Das Modul 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); |
143 | die($header.'<b>Information</b><br><br>Das Modul 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); |
144 | 144 | ||
145 | // Wurde nur der Ordner nicht korrekt umbenannt? (z.B. wenn es ein Modul mit dem selben Namen noch gibt) |
145 | // Wurde nur der Ordner nicht korrekt umbenannt? (z.B. wenn es ein Modul mit dem selben Namen noch gibt) |
146 | if ($problem) |
146 | if ($problem) |
147 | die($header.'<b>Information</b><br><br>Es existiert bereits ein Modul mit dem Namen "'.$inhalt.'". Das Modul 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); |
147 | die($header.'<b>Information</b><br><br>Es existiert bereits ein Modul mit dem Namen "'.$inhalt.'". Das Modul 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); |
148 | } |
148 | } |
149 | else |
149 | else |
150 | { |
150 | { |
151 | // Kein Dateiname angegeben? |
151 | // Kein Dateiname angegeben? |
152 | if ($conn_id) @ftp_quit($conn_id); |
152 | if ($conn_id) @ftp_quit($conn_id); |
153 | die($header.'<b>Information</b><br><br>Das Modul wurde unter dem Namen "'.$uid.'" angelegt, da in der Moduldatei keine Namensangabe vorhanden war.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
153 | die($header.'<b>Information</b><br><br>Das Modul wurde unter dem Namen "'.$uid.'" angelegt, da in der Moduldatei keine Namensangabe vorhanden war.<br><br><a href="'.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul).'">Zurück</a>'.$footer); |
154 | } |
154 | } |
155 | 155 | ||
156 | // Alles OK? Dann zurück! |
156 | // Alles OK? Dann zurück! |
157 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
157 | if (!headers_sent()) header('location: '.$_SERVER['PHP_SELF'].'?seite=inhalt&modul='.urlencode($modul)); |
158 | } |
158 | } |
159 | 159 | ||
160 | ?> |
160 | ?> |
161 | 161 |