· 10 years ago · Oct 21, 2015, 09:18 PM
1<?
2//a:9:{s:4:"lang";s:2:"en";s:9:"auth_pass";s:32:"48ab3ebf67e8e919491bf6499a110e1a";s:8:"quota_mb";i:0;s:17:"upload_ext_filter";a:0:{}s:19:"download_ext_filter";a:0:{}s:15:"error_reporting";s:0:"";s:7:"fm_root";s:0:"";s:17:"cookie_cache_time";i:1096733048;s:7:"version";s:5:"0.9.3";}
3/*--------------------------------------------------
4 | PHP FILE MANAGER
5 +--------------------------------------------------
6 | phpFileManager 0.9.3
7 | By FabrÃcio Seger Kolling
8 | Copyright (c) 2004 FabrÃcio Seger Kolling
9 | E-mail: dulldusk@nho.com.br
10 | URL: http://phpfm.sf.net
11 | Last Changed: 2004-09-02
12 +--------------------------------------------------
13 | OPEN SOURCE CONTRIBUTIONS
14 +--------------------------------------------------
15 | TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.0
16 | By Devin Doucette
17 | Copyright (c) 2004 Devin Doucette
18 | E-mail: darksnoopy@shaw.ca
19 | URL: http://www.phpclasses.org
20 +--------------------------------------------------
21 | It is the AUTHOR'S REQUEST that you keep intact the above header information
22 | and notify him if you conceive BUGFIXES or any IMPROVEMENTS to this program.
23 +--------------------------------------------------
24 | LICENCE - GPL [ GNU General Public License ]
25 +--------------------------------------------------
26 | This program is FREE SOFTWARE; you can REDISTRIBUTE it and/or MODIFY
27 | it under the terms of the GNU General Public License as published by
28 | the Free Software Foundation; either version 2 of the License, or
29 | (at your option) any later version.
30 | This program is distributed in the hope that it will be useful,
31 | but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | GNU General Public License for more details.
34 | You should have gotten a copy of the GPL license with this program.
35 | If not, it can found at http://www.gnu.org/copyleft/gpl.html
36 +--------------------------------------------------
37 | CONFIGURATION AND INSTALATION NOTES
38 +--------------------------------------------------
39 | This program does not include any instalation or configuration
40 | notes because it simply does not require them.
41 | Just throw this file anywhere in your webserver and enjoy !!
42 +--------------------------------------------------
43*/
44// +--------------------------------------------------
45// | Header and Globals
46// +--------------------------------------------------
47 header("Pragma: no-cache");
48 header("Cache-Control: no-store");
49 foreach ($_GET as $key => $val) $$key=htmldecode($val);
50 foreach ($_POST as $key => $val) $$key=htmldecode($val);
51 foreach ($_COOKIE as $key => $val) $$key=htmldecode($val);
52 if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) $ip = $_SERVER["REMOTE_ADDR"]; //nao usa proxy
53 else $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; //usa proxy
54 $islinux = !(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
55 $url_info = parse_url($_SERVER["HTTP_REFERER"]);
56 $doc_root = ($islinux) ? $_SERVER["DOCUMENT_ROOT"] : ucfirst($_SERVER["DOCUMENT_ROOT"]);
57 $script_filename = $doc_root.$_SERVER["PHP_SELF"];
58 $path_info = pathinfo($script_filename);
59// +--------------------------------------------------
60// | Config
61// +--------------------------------------------------
62 $cfg = new config();
63 $cfg->load();
64 ini_set("display_errors",1);
65 ini_set("error_reporting",$error_reporting);
66 if (!isset($dir_atual)){
67 $dir_atual = $path_info["dirname"]."/";
68 if (!$islinux) $dir_atual = ucfirst($dir_atual);
69 @chmod($dir_atual,0777);
70 } else $dir_atual = formatpath($dir_atual);
71 $is_reachable = (stristr($dir_atual,$doc_root)!==false);
72 // Auto Expand Local Path
73 if (!isset($expanded_dir_list)){
74 $expanded_dir_list = "";
75 $mat = explode("/",$path_info["dirname"]);
76 for ($x=0;$x<count($mat);$x++) $expanded_dir_list .= ":".$mat[$x];
77 setcookie("expanded_dir_list", $expanded_dir_list, 0, "/");
78 }
79 if (!isset($fm_root_atual)){
80 if (strlen($fm_root)) $fm_root_atual = $fm_root;
81 else {
82 if (!$islinux) $fm_root_atual = ucfirst($path_info["dirname"]."/");
83 else $fm_root_atual = $doc_root."/";
84 }
85 setcookie("fm_root_atual", $fm_root_atual, 0, "/");
86 } elseif (isset($set_fm_root_atual)) {
87 if (!$islinux) $fm_root_atual = ucfirst($set_fm_root_atual);
88 setcookie("fm_root_atual", $fm_root_atual, 0, "/");
89 }
90 if (!isset($resolveIDs)){
91 setcookie("resolveIDs", 0, $cookie_cache_time, "/");
92 } elseif (isset($set_resolveIDs)){
93 $resolveIDs=($resolveIDs)?0:1;
94 setcookie("resolveIDs", $resolveIDs, $cookie_cache_time, "/");
95 }
96 if ($resolveIDs){
97 exec("cat /etc/passwd",$mat_passwd);
98 exec("cat /etc/group",$mat_group);
99 }
100 $fm_color['Bg'] = "EEEEEE";
101 $fm_color['Text'] = "000000";
102 $fm_color['Link'] = "992929";
103 $fm_color['Mark'] = "A7D2E4";
104 $fm_color['Dir'] = "CCCCCC";
105 $fm_color['File'] = "EEEEEE";
106 $fm_color['FileFirstCell'] = "FFFFFF";
107 foreach($fm_color as $tag=>$color){
108 $fm_color[$tag]=strtolower($color);
109 }
110// +--------------------------------------------------
111// | File Manager Actions
112// +--------------------------------------------------
113if ($loggedon==$auth_pass){
114 switch ($frame){
115 case 1: break; // Empty Frame
116 case 2: frame2(); break;
117 case 3: frame3(); break;
118 default:
119 switch($action){
120 case 1: logout(); break;
121 case 2: config_form(); break;
122 case 3: download(); break;
123 case 4: view(); break;
124 case 5: server_info(); break;
125 case 6: execute(); break;
126 case 7: edit_file_form(); break;
127 case 8: chmod_form(); break;
128 case 9: shell_form(); break;
129 case 10: upload_form(); break;
130 default: frameset();
131 }
132 }
133} else {
134 if (isset($senha)) login();
135 else form_login();
136}
137// +--------------------------------------------------
138// | Config Class
139// +--------------------------------------------------
140class config {
141 var $data;
142 var $filename;
143 function config(){
144 global $script_filename;
145 $this->data = array(
146 'lang'=>'en',
147 'auth_pass'=>md5(''),
148 'quota_mb'=>0,
149 'upload_ext_filter'=>array(),
150 'download_ext_filter'=>array(),
151 'error_reporting'=>'',
152 'fm_root'=>'',
153 'cookie_cache_time'=>time()+60*60*24*30, // 30 Dias
154 'version'=>'0.9.3'
155 );
156 $data = false;
157 $this->filename = $script_filename;
158 if (file_exists($this->filename)){
159 $mat = file($this->filename);
160 $objdata = trim(substr($mat[1],2));
161 if (strlen($objdata)) $data = unserialize($objdata);
162 }
163 if (is_array($data)&&count($data)==count($this->data)) $this->data = $data;
164 else $this->save();
165 }
166 function save(){
167 $objdata = "<?".chr(13).chr(10)."//".serialize($this->data).chr(13).chr(10);
168 if (strlen($objdata)){
169 if (file_exists($this->filename)){
170 $mat = file($this->filename);
171 if ($fh = @fopen($this->filename, "w")){
172 @fputs($fh,$objdata,strlen($objdata));
173 for ($x=2;$x<count($mat);$x++) @fputs($fh,$mat[$x],strlen($mat[$x]));
174 @fclose($fh);
175 }
176 }
177 }
178 }
179 function load(){
180 foreach ($this->data as $key => $val) $GLOBALS[$key] = $val;
181 }
182}
183// +--------------------------------------------------
184// | Internationalization
185// +--------------------------------------------------
186function et($tag){
187 global $lang;
188 // English
189 $en['Version'] = 'Version';
190 $en['DocRoot'] = 'Document Root';
191 $en['FLRoot'] = 'File Manager Root';
192 $en['Name'] = 'Name';
193 $en['And'] = 'and';
194 $en['Enter'] = 'Enter';
195 $en['Send'] = 'Send';
196 $en['Refresh'] = 'Refresh';
197 $en['SaveConfig'] = 'Save Configurations';
198 $en['SavePass'] = 'Save Password';
199 $en['SaveFile'] = 'Save File';
200 $en['Save'] = 'Save';
201 $en['Leave'] = 'Leave';
202 $en['Edit'] = 'Edit';
203 $en['View'] = 'View';
204 $en['Config'] = 'Config';
205 $en['Ren'] = 'Rename';
206 $en['Rem'] = 'Delete';
207 $en['Compress'] = 'Compress';
208 $en['Decompress'] = 'Decompress';
209 $en['ResolveIDs'] = 'Resolve IDs';
210 $en['Move'] = 'Move';
211 $en['Copy'] = 'Copy';
212 $en['ServerInfo'] = 'Server Info';
213 $en['CreateDir'] = 'Create Directory';
214 $en['CreateArq'] = 'Create File';
215 $en['ExecCmd'] = 'Execute Command';
216 $en['Upload'] = 'Upload';
217 $en['UploadEnd'] = 'Upload Finished';
218 $en['Perms'] = 'Permissions';
219 $en['Owner'] = 'Owner';
220 $en['Group'] = 'Group';
221 $en['Other'] = 'Other';
222 $en['Size'] = 'Size';
223 $en['Date'] = 'Date';
224 $en['Type'] = 'Type';
225 $en['Free'] = 'free';
226 $en['Shell'] = 'Shell';
227 $en['Read'] = 'Read';
228 $en['Write'] = 'Write';
229 $en['Exec'] = 'Execute';
230 $en['Apply'] = 'Apply';
231 $en['StickyBit'] = 'Sticky Bit';
232 $en['Pass'] = 'Password';
233 $en['Lang'] = 'Language';
234 $en['File'] = 'File';
235 $en['File_s'] = 'file(s)';
236 $en['Dir_s'] = 'directory(s)';
237 $en['To'] = 'to';
238 $en['Destination'] = 'Destination';
239 $en['Configurations'] = 'Configurations';
240 $en['JSError'] = 'JavaScript Error';
241 $en['NoSel'] = 'There are no selected itens';
242 $en['SelDir'] = 'Select the destination directory on the left tree';
243 $en['TypeDir'] = 'Enter the directory name';
244 $en['TypeArq'] = 'Enter the file name';
245 $en['TypeCmd'] = 'Enter the command';
246 $en['TypeArqComp'] = 'Enter the file name.\\nThe extension will define the compression type.\\nEx:\\nnome.zip\\nnome.tar\\nnome.bzip\\nnome.gzip';
247 $en['RemSel'] = 'DELETE selected itens';
248 $en['NoDestDir'] = 'There is no selected destination directory';
249 $en['DestEqOrig'] = 'Origin and destination directories are equal';
250 $en['InvalidDest'] = 'Destination directory is invalid';
251 $en['NoNewPerm'] = 'New permission not set';
252 $en['CopyTo'] = 'COPY to';
253 $en['MoveTo'] = 'MOVE to';
254 $en['AlterPermTo'] = 'CHANGE PERMISSIONS to';
255 $en['ConfExec'] = 'Confirm EXECUTE';
256 $en['ConfRem'] = 'Confirm DELETE';
257 $en['EmptyDir'] = 'Empty directory';
258 $en['IOError'] = 'I/O Error';
259 $en['FileMan'] = 'PHP File Manager';
260 $en['TypePass'] = 'Enter the password';
261 $en['InvPass'] = 'Invalid Password';
262 $en['ReadDenied'] = 'Read Access Denied';
263 $en['FileNotFound'] = 'File not found';
264 $en['AutoClose'] = 'Close on Complete';
265 $en['OutDocRoot'] = 'File beyond DOCUMENT_ROOT';
266 $en['NoCmd'] = 'Error: Command not informed';
267 $en['ConfTrySave'] = 'File without write permisson.\\nTry to save anyway';
268 $en['ConfSaved'] = 'Configurations saved';
269 $en['PassSaved'] = 'Password saved';
270 $en['FileDirExists'] = 'File or directory already exists';
271 $en['NoPhpinfo'] = 'Function phpinfo disabled';
272 $en['NoReturn'] = 'no return';
273 $en['FileSent'] = 'File sent';
274 $en['SpaceLimReached'] = 'Space limit reached';
275 $en['InvExt'] = 'Invalid extension';
276 $en['FileNoOverw'] = 'File could not be overwritten';
277 $en['FileOverw'] = 'File overwritten';
278 $en['FileIgnored'] = 'File ignored';
279 $en['ChkVer'] = 'Check sf.net for new version';
280 $en['ChkVerAvailable'] = 'New version, click here to begin download!!';
281 $en['ChkVerNotAvailable'] = 'No new version available. :(';
282 $en['ChkVerError'] = 'Connection Error.';
283 $en['Website'] = 'Website';
284 $en['SendingForm'] = 'Sending files, please wait';
285 $en['NoFileSel'] = 'No file selected';
286 $en['SelAll'] = 'All';
287 $en['SelNone'] = 'None';
288 $en['SelInverse'] = 'Inverse';
289 $en['Selected_s'] = 'selected';
290 $en['Total'] = 'total';
291 $en['Partition'] = 'Partition';
292 $en['RenderTime'] = 'Time to render this page';
293 $en['Seconds'] = 'sec';
294 $en['ErrorReport'] = 'Error Reporting';
295
296 // Portuguese
297 $pt['Version'] = 'Versão';
298 $pt['DocRoot'] = 'Document Root';
299 $pt['FLRoot'] = 'File Manager Root';
300 $pt['Name'] = 'Nome';
301 $pt['And'] = 'e';
302 $pt['Enter'] = 'Entrar';
303 $pt['Send'] = 'Enviar';
304 $pt['Refresh'] = 'Atualizar';
305 $pt['SaveConfig'] = 'Salvar Configurações';
306 $pt['SavePass'] = 'Salvar Senha';
307 $pt['SaveFile'] = 'Salvar Arquivo';
308 $pt['Save'] = 'Salvar';
309 $pt['Leave'] = 'Sair';
310 $pt['Edit'] = 'Editar';
311 $pt['View'] = 'Visualizar';
312 $pt['Config'] = 'Config';
313 $pt['Ren'] = 'Renomear';
314 $pt['Rem'] = 'Apagar';
315 $pt['Compress'] = 'Compactar';
316 $pt['Decompress'] = 'Descompactar';
317 $pt['ResolveIDs'] = 'Resolver IDs';
318 $pt['Move'] = 'Mover';
319 $pt['Copy'] = 'Copiar';
320 $pt['ServerInfo'] = 'Server Info';
321 $pt['CreateDir'] = 'Criar Diretório';
322 $pt['CreateArq'] = 'Criar Arquivo';
323 $pt['ExecCmd'] = 'Executar Comando';
324 $pt['Upload'] = 'Upload';
325 $pt['UploadEnd'] = 'Upload Terminado';
326 $pt['Perms'] = 'Permissões';
327 $pt['Owner'] = 'Dono';
328 $pt['Group'] = 'Grupo';
329 $pt['Other'] = 'Outros';
330 $pt['Size'] = 'Tamanho';
331 $pt['Date'] = 'Data';
332 $pt['Type'] = 'Tipo';
333 $pt['Free'] = 'livre';
334 $pt['Shell'] = 'Shell';
335 $pt['Read'] = 'Ler';
336 $pt['Write'] = 'Escrever';
337 $pt['Exec'] = 'Executar';
338 $pt['Apply'] = 'Aplicar';
339 $pt['StickyBit'] = 'Sticky Bit';
340 $pt['Pass'] = 'Senha';
341 $pt['Lang'] = 'Idioma';
342 $pt['File'] = 'Arquivo';
343 $pt['File_s'] = 'arquivo(s)';
344 $pt['Dir_s'] = 'diretorio(s)';
345 $pt['To'] = 'para';
346 $pt['Destination'] = 'Destino';
347 $pt['Configurations'] = 'Configurações';
348 $pt['JSError'] = 'Erro de JavaScript';
349 $pt['NoSel'] = 'Não há itens selecionados';
350 $pt['SelDir'] = 'Selecione o diretório de destino na árvore a esquerda';
351 $pt['TypeDir'] = 'Digite o nome do diretório';
352 $pt['TypeArq'] = 'Digite o nome do arquivo';
353 $pt['TypeCmd'] = 'Digite o commando';
354 $pt['TypeArqComp'] = 'Digite o nome do arquivo.\\nA extensão determina o tipo de compactação.\\nEx:\\nnome.zip\\nnome.tar\\nnome.bzip\\nnome.gzip';
355 $pt['RemSel'] = 'APAGAR itens selecionados';
356 $pt['NoDestDir'] = 'Não há um diretório de destino selecionado';
357 $pt['DestEqOrig'] = 'Diretório de origem e destino iguais';
358 $pt['InvalidDest'] = 'Diretório de destino inválido';
359 $pt['NoNewPerm'] = 'Nova permissão não foi setada';
360 $pt['CopyTo'] = 'COPIAR para';
361 $pt['MoveTo'] = 'MOVER para';
362 $pt['AlterPermTo'] = 'ALTERAR PERMISSÕES para';
363 $pt['ConfExec'] = 'Confirma EXECUTAR';
364 $pt['ConfRem'] = 'Confirma APAGAR';
365 $pt['EmptyDir'] = 'Diretório vazio';
366 $pt['IOError'] = 'Erro de E/S';
367 $pt['FileMan'] = 'PHP File Manager';
368 $pt['TypePass'] = 'Digite a senha';
369 $pt['InvPass'] = 'Senha Inválida';
370 $pt['ReadDenied'] = 'Acesso de leitura negado';
371 $pt['FileNotFound'] = 'Arquivo não encontrado';
372 $pt['AutoClose'] = 'Fechar Automaticamente';
373 $pt['OutDocRoot'] = 'Arquivo fora do DOCUMENT_ROOT';
374 $pt['NoCmd'] = 'Erro: Comando não informado';
375 $pt['ConfTrySave'] = 'Arquivo sem permissão de escrita.\\nTentar salvar assim mesmo';
376 $pt['ConfSaved'] = 'Configurações salvas';
377 $pt['PassSaved'] = 'Senha salva';
378 $pt['FileDirExists'] = 'Arquivo ou diretório já existe';
379 $pt['NoPhpinfo'] = 'Função phpinfo desabilitada';
380 $pt['NoReturn'] = 'sem retorno';
381 $pt['FileSent'] = 'Arquivo enviado';
382 $pt['SpaceLimReached'] = 'Limite de espaço alcançado';
383 $pt['InvExt'] = 'Extensão inválida';
384 $pt['FileNoOverw'] = 'Arquivo não pode ser sobreescrito';
385 $pt['FileOverw'] = 'Arquivo sobreescrito';
386 $pt['FileIgnored'] = 'Arquivo omitido';
387 $pt['ChkVer'] = 'Verificar sf.net por nova versão';
388 $pt['ChkVerAvailable'] = 'Nova versão, clique aqui para iniciar download!!';
389 $pt['ChkVerNotAvailable'] = 'Não há nova versão disponÃvel :(';
390 $pt['ChkVerError'] = 'Erro de conexão.';
391 $pt['Website'] = 'Website';
392 $pt['SendingForm'] = 'Enviando arquivos, aguarde';
393 $pt['NoFileSel'] = 'Nenhum arquivo selecionado';
394 $pt['SelAll'] = 'Tudo';
395 $pt['SelNone'] = 'Nada';
396 $pt['SelInverse'] = 'Inverso';
397 $pt['Selected_s'] = 'selecionado(s)';
398 $pt['Total'] = 'total';
399 $pt['Partition'] = 'Partição';
400 $pt['RenderTime'] = 'Tempo para gerar esta página';
401 $pt['Seconds'] = 'seg';
402 $pt['ErrorReport'] = 'Error Reporting';
403
404 $lang_ = $$lang;
405 if (isset($lang_[$tag])) return htmlencode($lang_[$tag]);
406 else return "undefined";
407}
408// +--------------------------------------------------
409// | File System
410// +--------------------------------------------------
411function total_size($arg) {
412 $total = 0;
413 if (file_exists($arg)) {
414 if (is_dir($arg)) {
415 $handle = opendir($arg);
416 while($aux = readdir($handle)) {
417 if ($aux != "." && $aux != "..") $total += total_size($arg."/".$aux);
418 }
419 closedir($handle);
420 } else $total = filesize($arg);
421 }
422 return $total;
423}
424function total_delete($arg) {
425 if (file_exists($arg)) {
426 chmod($arg,0777);
427 if (is_dir($arg)) {
428 $handle = opendir($arg);
429 while($aux = readdir($handle)) {
430 if ($aux != "." && $aux != "..") total_delete($arg."/".$aux);
431 }
432 closedir($handle);
433 rmdir($arg);
434 } else unlink($arg);
435 }
436}
437function total_copy($orig,$dest) {
438 $ok = true;
439 if (file_exists($orig)) {
440 if (is_dir($orig)) {
441 mkdir($dest,0777);
442 $handle = opendir($orig);
443 while(($aux = readdir($handle))&&($ok)) {
444 if ($aux != "." && $aux != "..") $ok = total_copy($orig."/".$aux,$dest."/".$aux);
445 }
446 closedir($handle);
447 } else $ok = copy((string)$orig,(string)$dest);
448 }
449 return $ok;
450}
451function total_move($orig,$dest) {
452 // Just why doesn't it has a MOVE alias?!
453 return rename((string)$orig,(string)$dest);
454}
455function download(){
456 global $dir_atual,$filename;
457 $file = $dir_atual.$filename;
458 if(file_exists($file)){
459 $is_proibido = false;
460 foreach($download_ext_filter as $key=>$ext){
461 if (eregi($ext,$filename)){
462 $is_proibido = true;
463 break;
464 }
465 }
466 if (!$is_proibido){
467 $size = filesize($file);
468 header("Content-Type: application/save");
469 header("Content-Length: $size");
470 header("Content-Disposition: attachment; filename=\"$filename\"");
471 header("Content-Transfer-Encoding: binary");
472 if ($fh = fopen("$file", "rb")){
473 fpassthru($fh);
474 fclose($fh);
475 } else alert(et('ReadDenied').": ".$file);
476 } else alert(et('ReadDenied').": ".$file);
477 } else alert(et('FileNotFound').": ".$file);
478}
479function execute(){
480 global $cmd;
481 header("Content-type: text/plain");
482 if (strlen($cmd)){
483 echo "# ".$cmd."\n";
484 exec($cmd,$mat);
485 if (count($mat)) echo trim(implode("\n",$mat));
486 else echo "exec(\"$cmd\") ".et('NoReturn')."...";
487 } else echo et('NoCmd');
488}
489function save_upload($temp_file,$filename,$dir_dest) {
490 global $upload_ext_filter;
491 $filename = remove_acentos($filename);
492 $file = $dir_dest.$filename;
493 $filesize = filesize($temp_file);
494 $is_proibido = false;
495 foreach($upload_ext_filter as $key=>$ext){
496 if (eregi($ext,$filename)){
497 $is_proibido = true;
498 break;
499 }
500 }
501 if (!$is_proibido){
502 if (!limite($filesize)){
503 if (file_exists($file)){
504 if (unlink($file)){
505 if (copy($temp_file,$file)){
506 chmod($file,0777);
507 $out = 6;
508 } else $out = 2;
509 } else $out = 5;
510 } else {
511 if (copy($temp_file,$file)){
512 chmod($file,0777);
513 $out = 1;
514 } else $out = 2;
515 }
516 } else $out = 3;
517 } else $out = 4;
518 return $out;
519}
520function zip_extract(){
521 global $cmd_arg,$dir_atual,$islinux;
522 $zip = zip_open($dir_atual.$cmd_arg);
523 if ($zip) {
524 while ($zip_entry = zip_read($zip)) {
525 if (zip_entry_filesize($zip_entry)) {
526 $complete_path = $path.dirname(zip_entry_name($zip_entry));
527 $complete_name = $path.zip_entry_name($zip_entry);
528 if(!file_exists($complete_path)) {
529 $tmp = '';
530 foreach(explode('/',$complete_path) AS $k) {
531 $tmp .= $k.'/';
532 if(!file_exists($tmp)) {
533 @mkdir($dir_atual.$tmp, 0777);
534 }
535 }
536 }
537 if (zip_entry_open($zip, $zip_entry, "r")) {
538 if ($fd = fopen($dir_atual.$complete_name, 'w')){
539 fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
540 fclose($fd);
541 } else echo "fopen($dir_atual.$complete_name) error<br>";
542 zip_entry_close($zip_entry);
543 } else echo "zip_entry_open($zip,$zip_entry) error<br>";
544 }
545 }
546 zip_close($zip);
547 }
548}
549// +--------------------------------------------------
550// | Data Formating
551// +--------------------------------------------------
552function htmlencode($str){
553 return htmlentities($str);
554}
555// html_entity_decode() replacement
556function html_entity_decode_for_php4_compatibility ($string) {
557 $trans_tbl = get_html_translation_table (HTML_ENTITIES);
558 $trans_tbl = array_flip ($trans_tbl);
559 $ret = strtr ($string, $trans_tbl);
560 return preg_replace('/\&\#([0-9]+)\;/me',
561 "chr('\\1')",$ret);
562}
563function htmldecode($str){
564 if (is_string($str)){
565 if (get_magic_quotes_gpc()) return stripslashes(html_entity_decode_for_php4_compatibility($str));
566 else return html_entity_decode($str);
567 } else return $str;
568}
569function rep($x,$y){
570 if ($x) {
571 $aux = "";
572 for ($a=1;$a<=$x;$a++) $aux .= $y;
573 return $aux;
574 } else return "";
575}
576function strzero($arg1,$arg2){
577 if (strstr($arg1,"-") == false){
578 $aux = intval($arg2) - strlen($arg1);
579 if ($aux) return rep($aux,"0").$arg1;
580 else return $arg1;
581 } else {
582 return "[$arg1]";
583 }
584}
585function replace_double($sub,$str){
586 $out=str_replace($sub.$sub,$sub,$str);
587 while ( strlen($out) != strlen($str) ){
588 $str=$out;
589 $out=str_replace($sub.$sub,$sub,$str);
590 }
591 return $out;
592}
593function remove_acentos($str){
594 $str = trim($str);
595 $str = strtr($str,"¥µÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃßà áâãäåæçèéêëìÃîïðñòóôõöøùúûüýÿ!@#%&*()[]{}+=?",
596 "YuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy_______________");
597 $str = str_replace("..","",str_replace("/","",str_replace("\\","",str_replace("\$","",$str))));
598 return $str;
599}
600function formatpath($str){
601 global $islinux;
602 $str = trim($str);
603 $str = str_replace("..","",str_replace("\\","/",str_replace("\$","",$str)));
604 $done = false;
605 while (!$done) {
606 $str2 = str_replace("//","/",$str);
607 if (strlen($str) == strlen($str2)) $done = true;
608 else $str = $str2;
609 }
610 $tam = strlen($str);
611 if ($tam){
612 $last_char = $tam - 1;
613 if ($str[$last_char] != "/") $str .= "/";
614 if (!$islinux) $str = ucfirst($str);
615 }
616 return $str;
617}
618function array_csort() {
619 $args = func_get_args();
620 $marray = array_shift($args);
621 $msortline = "return(array_multisort(";
622 foreach ($args as $arg) {
623 $i++;
624 if (is_string($arg)) {
625 foreach ($marray as $row) {
626 $sortarr[$i][] = $row[$arg];
627 }
628 } else {
629 $sortarr[$i] = $arg;
630 }
631 $msortline .= "\$sortarr[".$i."],";
632 }
633 $msortline .= "\$marray));";
634 eval($msortline);
635 return $marray;
636}
637function show_perms( $in_Perms ) {
638 $sP = "<b>";
639 if($in_Perms & 0x1000) $sP .= 'p'; // FIFO pipe
640 elseif($in_Perms & 0x2000) $sP .= 'c'; // Character special
641 elseif($in_Perms & 0x4000) $sP .= 'd'; // Directory
642 elseif($in_Perms & 0x6000) $sP .= 'b'; // Block special
643 elseif($in_Perms & 0x8000) $sP .= '−'; // Regular
644 elseif($in_Perms & 0xA000) $sP .= 'l'; // Symbolic Link
645 elseif($in_Perms & 0xC000) $sP .= 's'; // Socket
646 else $sP .= 'u'; // UNKNOWN
647 $sP .= "</b>";
648 // owner - group - others
649 $sP .= (($in_Perms & 0x0100) ? 'r' : '−') . (($in_Perms & 0x0080) ? 'w' : '−') . (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : (($in_Perms & 0x0800) ? 'S' : '−'));
650 $sP .= (($in_Perms & 0x0020) ? 'r' : '−') . (($in_Perms & 0x0010) ? 'w' : '−') . (($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) : (($in_Perms & 0x0400) ? 'S' : '−'));
651 $sP .= (($in_Perms & 0x0004) ? 'r' : '−') . (($in_Perms & 0x0002) ? 'w' : '−') . (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : (($in_Perms & 0x0200) ? 'T' : '−'));
652 return $sP;
653}
654function formatsize($arg) {
655 if ($arg>0){
656 $j = 0;
657 $ext = array(" bytes"," Kb"," Mb"," Gb"," Tb");
658 while ($arg >= pow(1024,$j)) ++$j;
659 return round($arg / pow(1024,$j-1) * 100) / 100 . $ext[$j-1];
660 } else return "0 Mb";
661}
662function getsize($file) {
663 return formatsize(filesize($file));
664}
665function limite($new_filesize=0) {
666 global $fm_root_atual;
667 global $quota_mb;
668 if($quota_mb){
669 $total = total_size($fm_root_atual);
670 if (floor(($total+$new_filesize)/(1024*1024)) > $quota_mb) return true;
671 }
672 return false;
673}
674function getuser ($arg) {
675 global $mat_passwd;
676 $aux = "x:".trim($arg).":";
677 for($x=0;$x<count($mat_passwd);$x++){
678 if (strstr($mat_passwd[$x],$aux)){
679 $mat = explode(":",$mat_passwd[$x]);
680 return $mat[0];
681 }
682 }
683 return $arg;
684}
685function getgroup ($arg) {
686 global $mat_group;
687 $aux = "x:".trim($arg).":";
688 for($x=0;$x<count($mat_group);$x++){
689 if (strstr($mat_group[$x],$aux)){
690 $mat = explode(":",$mat_group[$x]);
691 return $mat[0];
692 }
693 }
694 return $arg;
695}
696// +--------------------------------------------------
697// | Interface
698// +--------------------------------------------------
699function html_header($plus=""){
700 global $fm_color;
701echo "
702<html>
703<head>
704<title>...:::: ".et('FileMan')."</title>
705<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
706$plus
707</head>
708<script language=\"Javascript\" type=\"text/javascript\">
709<!--
710 function Is(){
711 this.appname = navigator.appName;
712 this.appversion = navigator.appVersion;
713 this.platform = navigator.platform;
714 this.useragent = navigator.userAgent.toLowerCase();
715 this.ie = ( this.appname == 'Microsoft Internet Explorer' );
716 if (( this.useragent.indexOf( 'mac' ) != -1 ) || ( this.platform.indexOf( 'mac' ) != -1 )){
717 this.sisop = 'mac';
718 } else if (( this.useragent.indexOf( 'windows' ) != -1 ) || ( this.platform.indexOf( 'win32' ) != -1 )){
719 this.sisop = 'windows';
720 } else if (( this.useragent.indexOf( 'inux' ) != -1 ) || ( this.platform.indexOf( 'linux' ) != -1 )){
721 this.sisop = 'linux';
722 }
723 }
724 var is = new Is();
725 function enterSubmit(keypressEvent,submitFunc){
726 var kCode = (is.ie) ? keypressEvent.keyCode : keypressEvent.which
727 if( kCode == 13) eval(submitFunc);
728 }
729 var W = screen.width;
730 var H = screen.height;
731 var FONTSIZE = 0;
732 switch (W){
733 case 640:
734 FONTSIZE = 8;
735 break;
736 case 800:
737 FONTSIZE = 10;
738 break;
739 case 1024:
740 FONTSIZE = 12;
741 break;
742 default:
743 FONTSIZE = 14;
744 break;
745 }
746";
747echo replace_double(" ",str_replace(chr(13),"",str_replace(chr(10),"","
748 document.writeln('
749 <style>
750 body {
751 font-family : Arial;
752 font-size: '+FONTSIZE+'px;
753 font-weight : normal;
754 color: ".$fm_color['Text'].";
755 background-color: ".$fm_color['Bg'].";
756 }
757 table {
758 font-family : Arial;
759 font-size: '+FONTSIZE+'px;
760 font-weight : normal;
761 color: ".$fm_color['Text'].";
762 cursor: default;
763 }
764 input {
765 font-family : Arial;
766 font-size: '+FONTSIZE+'px;
767 font-weight : normal;
768 color: ".$fm_color['Text'].";
769 }
770 textarea {
771 font-family : Courier;
772 font-size: 12px;
773 font-weight : normal;
774 color: ".$fm_color['Text'].";
775 }
776 A {
777 font-family : Arial;
778 font-size : '+FONTSIZE+'px;
779 font-weight : bold;
780 text-decoration: none;
781 color: ".$fm_color['Text'].";
782 }
783 A:link {
784 color: ".$fm_color['Text'].";
785 }
786 A:visited {
787 color: ".$fm_color['Text'].";
788 }
789 A:hover {
790 color: ".$fm_color['Link'].";
791 }
792 A:active {
793 color: ".$fm_color['Text'].";
794 }
795 </style>
796 ');
797")));
798echo "
799//-->
800</script>
801";
802}
803function reloadframe($ref,$frame_number,$plus=""){
804 global $dir_atual,$path_info;
805 echo "
806 <script language=\"Javascript\" type=\"text/javascript\">
807 <!--
808 ".$ref.".frame".$frame_number.".location.href='".$path_info["basename"]."?frame=".$frame_number."&dir_atual=".$dir_atual.$plus."';
809 //-->
810 </script>
811 ";
812}
813function alert($arg){
814 echo "
815 <script language=\"Javascript\" type=\"text/javascript\">
816 <!--
817 alert('$arg');
818 //-->
819 </script>
820 ";
821}
822function tree($dir_antes,$dir_corrente,$indice){
823 global $fm_root_atual, $dir_atual, $islinux;
824 global $expanded_dir_list;
825 $indice++;
826 $num_dir = 0;
827 $dir_name = str_replace($dir_antes,"",$dir_corrente);
828 $dir_corrente = str_replace("//","/",$dir_corrente);
829 $is_proibido = false;
830 if ($islinux) {
831 $proibidos = "/proc#/dev";
832 $mat = explode("#",$proibidos);
833 foreach($mat as $key => $val){
834 if ($dir_corrente == $val){
835 $is_proibido = true;
836 break;
837 }
838 }
839 unset($mat);
840 }
841 if (!$is_proibido){
842 if ($handle = @opendir($dir_corrente)){
843 // Permitido
844 while ($file = readdir($handle)){
845 if ($file != "." && $file != ".." && is_dir("$dir_corrente/$file"))
846 $mat_dir[] = $file;
847 }
848 closedir($handle);
849 if (count($mat_dir)){
850 sort($mat_dir,SORT_STRING);
851 // Com Sub-dir
852 if ($indice != 0){
853 for ($aux=1;$aux<$indice;$aux++) echo "Â Â Â Â ";
854 echo "•";
855 }
856 if ($dir_antes != $dir_corrente){
857 if (strstr($expanded_dir_list,":$dir_corrente/$dir_name")) $op_str = "[–]";
858 else $op_str = "[+]";
859 echo "Â <a href=\"JavaScript:go_dir('$dir_corrente/$dir_name')\"><b>$op_str</b></a>Â <a href=\"JavaScript:go('$dir_corrente')\"><b>$dir_name</b></a><br>\n";
860 } else {
861 echo "<a href=\"JavaScript:go('$dir_corrente')\"><b>$fm_root_atual</b></a><br>\n";
862 }
863 for ($x=0;$x<count($mat_dir);$x++){
864 if (($dir_antes == $dir_corrente)||(strstr($expanded_dir_list,":$dir_corrente/$dir_name"))){
865 tree($dir_corrente."/",$dir_corrente."/".$mat_dir[$x],$indice);
866 } else flush();
867 }
868 } else {
869 // Sem Sub-dir
870 if ($dir_antes != $dir_corrente){
871 for ($aux=1;$aux<$indice;$aux++) echo "Â Â Â Â ";
872 echo "•";
873 echo "<a href=\"JavaScript:go('$dir_corrente')\"> <b>$dir_name</b></a><br>\n";
874 } else {
875 echo "<a href=\"JavaScript:go('$dir_corrente')\"> <b>$fm_root_atual</b></a><br>\n";
876 }
877 }
878 } else {
879 // Negado
880 if ($dir_antes != $dir_corrente){
881 for ($aux=1;$aux<$indice;$aux++) echo "Â Â Â Â ";
882 echo "•";
883 echo "<a href=\"JavaScript:go('$dir_corrente')\"><font color=red> <b>$dir_name</b></font></a><br>\n";
884 } else {
885 echo "<a href=\"JavaScript:go('$dir_corrente')\"><font color=red> <b>$fm_root_atual</b></font></a><br>\n";
886 }
887
888 }
889 } else {
890 // Proibido
891 if ($dir_antes != $dir_corrente){
892 for ($aux=1;$aux<$indice;$aux++) echo "Â Â Â Â ";
893 echo "•";
894 echo "<a href=\"JavaScript:go('$dir_corrente')\"><font color=red> <b>$dir_name</b></font></a><br>\n";
895 } else {
896 echo "<a href=\"JavaScript:go('$dir_corrente')\"><font color=red> <b>$fm_root_atual</b></font></a><br>\n";
897 }
898 }
899}
900function show_tree(){
901 global $fm_root_atual,$path_info,$setflag,$islinux;
902 html_header();
903 echo "<body marginwidth=\"0\" marginheight=\"0\">\n";
904 echo "
905 <script language=\"Javascript\" type=\"text/javascript\">
906 <!--
907 // Disable text selection
908 function disableTextSelection(e){return false}
909 function enableTextSelection(){return true}
910 if (is.ie) document.onselectstart=new Function('return false')
911 else {
912 document.onmousedown=disableTextSelection
913 document.onclick=enableTextSelection
914 }
915 var flag = ".(($setflag)?"true":"false")."
916 function set_flag(arg) {
917 flag = arg;
918 }
919 function go_dir(arg) {
920 var setflag;
921 setflag = (flag)?1:0;
922 document.location.href='".$path_info["basename"]."?frame=2&setflag='+setflag+'&dir_atual=$dir_atual&ec_dir='+arg;
923 }
924 function go(arg) {
925 if (flag) {
926 parent.frame3.set_dir_dest(arg+'/');
927 flag = false;
928 } else {
929 parent.frame3.location.href='".$path_info["basename"]."?frame=3&dir_atual='+arg+'/';
930 }
931 }
932 function set_fm_root_atual(arg){
933 document.location.href='".$path_info["basename"]."?frame=2&set_fm_root_atual='+escape(arg);
934 }
935 function atualizar(){
936 document.location.href='".$path_info["basename"]."?frame=2';
937 }
938 //-->
939 </script>
940 ";
941 echo "<table width=\"100%\" height=\"100%\" border=0 cellspacing=0 cellpadding=5>\n";
942 echo "<form><tr valign=top height=10><td>";
943 if (!$islinux){
944 echo "<select name=drive onchange=\"set_fm_root_atual(this.value)\">";
945 $aux="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
946 for($x=0;$x<strlen($aux);$x++){
947 if (strstr(strtoupper($fm_root_atual),$aux[$x].":/")) $is_sel="selected";
948 else $is_sel="";
949 echo "<option $is_sel value=\"".$aux[$x].":/\">".$aux[$x].":/";
950 }
951 echo "</select> ";
952 }
953 echo "<input type=button value=".et('Refresh')." onclick=\"atualizar()\"></tr></form>";
954 //if (!$islinux) $aux=substr($fm_root_atual,0,strlen($fm_root_atual)-1);
955 //else
956 $aux=$fm_root_atual;
957 echo "<tr valign=top><td>";
958 clearstatcache();
959 tree($aux,$aux,-1,0);
960 echo "</td></tr>";
961 echo "
962 <form name=\"login_form\" action=\"".$path_info["basename"]."\" method=\"post\" target=\"_parent\">
963 <input type=hidden name=action value=1>
964 <tr>
965 <td height=10 colspan=2><input type=submit value=\"".et('Leave')."\">
966 </tr>
967 </form>
968 ";
969 echo "</table>\n";
970 echo "</body>\n</html>";
971}
972function getmicrotime(){
973 list($usec, $sec) = explode(" ", microtime());
974 return ((float)$usec + (float)$sec);
975}
976function dir_list_form() {
977 global $fm_root_atual,$dir_atual,$quota_mb,$resolveIDs,$order_dir_list_by,$islinux,$cmd_name,$ip,$is_reachable,$path_info,$fm_color;
978 $ti = getmicrotime();
979 clearstatcache();
980 $out = "<table border=0 cellspacing=1 cellpadding=4 width=\"100%\" bgcolor=\"#eeeeee\">\n";
981 if ($opdir = @opendir($dir_atual)) {
982 $entry_count = 0;
983 $file_count = 0;
984 $dir_count = 0;
985 $total_size = 0;
986 $uplink = "";
987 $entry_list = array();
988 $highlight_cols = 0;
989
990 while ($file = readdir($opdir)) {
991 if (($file != ".")&&($file != "..")){
992 if (is_file($dir_atual.$file)){
993 $ext = strtolower(strrchr($file,"."));
994 $entry_list[$entry_count]["type"] = "file";
995 // Função filetype() returns only "file"...
996 $entry_list[$entry_count]["size"] = filesize($dir_atual.$file);
997 $entry_list[$entry_count]["sizet"] = getsize($dir_atual.$file);
998 if (strstr($ext,".")){
999 $entry_list[$entry_count]["ext"] = $ext;
1000 $entry_list[$entry_count]["extt"] = $ext;
1001 } else {
1002 $entry_list[$entry_count]["ext"] = "";
1003 $entry_list[$entry_count]["extt"] = "Â ";
1004 }
1005 $file_count++;
1006 } elseif (is_dir($dir_atual.$file)) {
1007 // Recursive directory size disabled
1008 // $entry_list[$entry_count]["size"] = total_size($dir_atual.$file);
1009 $entry_list[$entry_count]["size"] = 0;
1010 $entry_list[$entry_count]["sizet"] = 0;
1011 $entry_list[$entry_count]["type"] = "dir";
1012 $dir_count++;
1013 }
1014 $entry_list[$entry_count]["name"] = $file;
1015 $entry_list[$entry_count]["date"] = date("Ymd", filemtime($dir_atual.$file));
1016 $entry_list[$entry_count]["time"] = date("his", filemtime($dir_atual.$file));
1017 $entry_list[$entry_count]["datet"] = date("d/m/Y h:i:s", filemtime($dir_atual.$file));
1018 if ($islinux && $resolveIDs){
1019 $entry_list[$entry_count]["p"] = show_perms(fileperms($dir_atual.$file));
1020 $entry_list[$entry_count]["u"] = getuser(fileowner($dir_atual.$file));
1021 $entry_list[$entry_count]["g"] = getgroup(filegroup($dir_atual.$file));
1022 } else {
1023 $entry_list[$entry_count]["p"] = base_convert(fileperms($dir_atual.$file),10,8);
1024 $entry_list[$entry_count]["p"] = substr($entry_list[$entry_count]["p"],strlen($entry_list[$entry_count]["p"])-3);
1025 $entry_list[$entry_count]["u"] = fileowner($dir_atual.$file);
1026 $entry_list[$entry_count]["g"] = filegroup($dir_atual.$file);
1027 }
1028 $total_size += $entry_list[$entry_count]["size"];
1029 $entry_count++;
1030 }
1031 }
1032 closedir($opdir);
1033
1034 if ($file_count) $highlight_cols = ($islinux)?7:5;
1035 else $highlight_cols = ($islinux)?6:4;
1036
1037 if($entry_count){
1038 $or1="1A";
1039 $or2="2D";
1040 $or3="3A";
1041 $or4="4A";
1042 $or5="5A";
1043 $or6="6D";
1044 $or7="7D";
1045 switch($order_dir_list_by){
1046 case "1A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"name",SORT_STRING,SORT_ASC); $or1="1D"; break;
1047 case "1D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"name",SORT_STRING,SORT_DESC); $or1="1A"; break;
1048 case "2A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"p",SORT_STRING,SORT_ASC,"g",SORT_STRING,SORT_ASC,"u",SORT_STRING,SORT_ASC); $or2="2D"; break;
1049 case "2D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"p",SORT_STRING,SORT_DESC,"g",SORT_STRING,SORT_ASC,"u",SORT_STRING,SORT_ASC); $or2="2A"; break;
1050 case "3A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"u",SORT_STRING,SORT_ASC,"g",SORT_STRING,SORT_ASC); $or3="3D"; break;
1051 case "3D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"u",SORT_STRING,SORT_DESC,"g",SORT_STRING,SORT_ASC); $or3="3A"; break;
1052 case "4A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"g",SORT_STRING,SORT_ASC,"u",SORT_STRING,SORT_DESC); $or4="4D"; break;
1053 case "4D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"g",SORT_STRING,SORT_DESC,"u",SORT_STRING,SORT_DESC); $or4="4A"; break;
1054 case "5A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"size",SORT_NUMERIC,SORT_ASC); $or5="5D"; break;
1055 case "5D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"size",SORT_NUMERIC,SORT_DESC); $or5="5A"; break;
1056 case "6A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"date",SORT_STRING,SORT_ASC,"time",SORT_STRING,SORT_ASC,"name",SORT_STRING,SORT_ASC); $or6="6D"; break;
1057 case "6D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"date",SORT_STRING,SORT_DESC,"time",SORT_STRING,SORT_DESC,"name",SORT_STRING,SORT_ASC); $or6="6A"; break;
1058 case "7A": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"ext",SORT_STRING,SORT_ASC,"name",SORT_STRING,SORT_ASC); $or7="7D"; break;
1059 case "7D": $entry_list = array_csort ($entry_list,"type",SORT_STRING,SORT_ASC,"ext",SORT_STRING,SORT_DESC,"name",SORT_STRING,SORT_ASC); $or7="7A"; break;
1060 }
1061 }
1062 $out .= "
1063 <script language=\"Javascript\" type=\"text/javascript\">
1064 <!--
1065 function getCookieVal (offset) {
1066 var endstr = document.cookie.indexOf (';', offset);
1067 if (endstr == -1) endstr = document.cookie.length;
1068 return unescape(document.cookie.substring(offset, endstr));
1069 }
1070 function getCookie (name) {
1071 var arg = name + '=';
1072 var alen = arg.length;
1073 var clen = document.cookie.length;
1074 var i = 0;
1075 while (i < clen) {
1076 var j = i + alen;
1077 if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
1078 i = document.cookie.indexOf(' ', i) + 1;
1079 if (i == 0) break;
1080 }
1081 return null;
1082 }
1083 function setCookie (name, value) {
1084 var argv = SetCookie.arguments;
1085 var argc = SetCookie.arguments.length;
1086 var expires = (argc > 2) ? argv[2] : null;
1087 var path = (argc > 3) ? argv[3] : null;
1088 var domain = (argc > 4) ? argv[4] : null;
1089 var secure = (argc > 5) ? argv[5] : false;
1090 document.cookie = name + '=' + escape (value) +
1091 ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +
1092 ((path == null) ? '' : ('; path=' + path)) +
1093 ((domain == null) ? '' : ('; domain=' + domain)) +
1094 ((secure == true) ? '; secure' : '');
1095 }
1096 function delCookie (name) {
1097 var exp = new Date();
1098 exp.setTime (exp.getTime() - 1);
1099 var cval = GetCookie (name);
1100 document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString();
1101 }
1102 function go(arg) {
1103 document.location.href='".$path_info["basename"]."?frame=3&dir_atual=$dir_atual'+arg+'/';
1104 }
1105 function resolveIDs() {
1106 document.location.href='".$path_info["basename"]."?frame=3&set_resolveIDs=1&dir_atual=$dir_atual';
1107 }
1108 var entry_list = new Array();
1109 // Custom object constructor
1110 function entry(name, type, size, selected){
1111 this.name = name;
1112 this.type = type;
1113 this.size = size;
1114 this.selected = false;
1115 }
1116 // Declare entry_list for selection procedures";
1117 foreach ($entry_list as $i=>$data){
1118 $out .= "\nentry_list['entry$i'] = new entry('".$data["name"]."', '".$data["type"]."', ".$data["size"].", false);";
1119 }
1120 $out .= "
1121 // Select/Unselect Rows OnClick/OnMouseOver
1122 var lastRows = new Array(null,null);
1123 function selectEntry(Row, Action){
1124 var MarkColor = '#".$fm_color['Mark']."';
1125 var Cells = Row.getElementsByTagName('td');
1126 if (multipleSelection){
1127 // Avoid repeated onmouseover events from same Row ( cell transition )
1128 if (Row != lastRows[0]){
1129 if (Action == 'over') {
1130 if (entry_list[Row.id].selected){
1131 if (entry_list[Row.id].type == 'dir') DefaultColor = '#".$fm_color['Dir']."';
1132 else DefaultColor = '#".$fm_color['File']."';
1133 if (unselect(entry_list[Row.id])) {
1134 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1135 if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#".$fm_color['FileFirstCell']."';
1136 else Cells[c].style.backgroundColor = DefaultColor;
1137 }
1138 }
1139 // Change the last Row when you change the movement orientation
1140 if (lastRows[0] != null && lastRows[1] != null){
1141 var LastRowID = lastRows[0].id;
1142 var LastRowDefaultColor;
1143 if (entry_list[LastRowID].type == 'dir') LastRowDefaultColor = '#".$fm_color['Dir']."';
1144 else LastRowDefaultColor = '#".$fm_color['File']."';
1145 if (Row.id == lastRows[1].id){
1146 var LastRowCells = lastRows[0].getElementsByTagName('td');
1147 if (unselect(entry_list[LastRowID])) {
1148 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1149 if (c == 0 && entry_list[LastRowID].type=='file' && !entry_list[LastRowID].selected) LastRowCells[c].style.backgroundColor = '#".$fm_color['FileFirstCell']."';
1150 else LastRowCells[c].style.backgroundColor = LastRowDefaultColor;
1151 }
1152 }
1153 }
1154 }
1155 } else {
1156 if (select(entry_list[Row.id])){
1157 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1158 if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#".$fm_color['FileFirstCell']."';
1159 else Cells[c].style.backgroundColor = MarkColor;
1160 }
1161 }
1162 // Change the last Row when you change the movement orientation
1163 if (lastRows[0] != null && lastRows[1] != null){
1164 var LastRowID = lastRows[0].id;
1165 if (Row.id == lastRows[1].id){
1166 var LastRowCells = lastRows[0].getElementsByTagName('td');
1167 if (select(entry_list[LastRowID])) {
1168 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1169 if (c == 0 && entry_list[LastRowID].type=='file' && !entry_list[LastRowID].selected) LastRowCells[c].style.backgroundColor = '#".$fm_color['FileFirstCell']."';
1170 else LastRowCells[c].style.backgroundColor = MarkColor;
1171 }
1172 }
1173 }
1174 }
1175 }
1176 lastRows[1] = lastRows[0];
1177 lastRows[0] = Row;
1178 }
1179 }
1180 } else {
1181 if (Action == 'click') {
1182 var newColor = null;
1183 if (entry_list[Row.id].selected){
1184 var DefaultColor;
1185 if (entry_list[Row.id].type == 'dir') DefaultColor = '#".$fm_color['Dir']."';
1186 else DefaultColor = '#".$fm_color['File']."';
1187 if (unselect(entry_list[Row.id])) newColor = DefaultColor;
1188 } else {
1189 if (select(entry_list[Row.id])) newColor = MarkColor;
1190 }
1191 if (newColor) {
1192 lastRows[0] = lastRows[1] = Row;
1193 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1194 if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#".$fm_color['FileFirstCell']."';
1195 else Cells[c].style.backgroundColor = newColor;
1196 }
1197 }
1198 }
1199 }
1200 return true;
1201 }
1202 // Disable text selection and bind multiple selection flag
1203 var multipleSelection = false;
1204 if (is.ie) {
1205 document.onselectstart=new Function('return false');
1206 document.onmousedown=switch_flag_on;
1207 document.onmouseup=switch_flag_off;
1208 // Event mouseup is not generated over scrollbar.. curiously, mousedown is.. go figure.
1209 window.onscroll=new Function('multipleSelection=false');
1210 } else {
1211 if (document.layers) window.captureEvents(Event.MOUSEDOWN);
1212 if (document.layers) window.captureEvents(Event.MOUSEUP);
1213 window.onmousedown=switch_flag_on;
1214 window.onmouseup=switch_flag_off;
1215 }
1216 // Using same function and a ternary operator couses bug on double click
1217 function switch_flag_on(e) {
1218 lastRows[0] = lastRows[1] = null;
1219 if (is.ie){
1220 multipleSelection = (event.button == 1);
1221 } else {
1222 multipleSelection = (e.which == 1);
1223 }
1224 return false;
1225 }
1226 function switch_flag_off(e) {
1227 if (is.ie){
1228 multipleSelection = (event.button != 1);
1229 } else {
1230 multipleSelection = (e.which != 1);
1231 }
1232 return false;
1233 }
1234 var total_dirs_selected = 0;
1235 var total_files_selected = 0;
1236 function unselect(Entry){
1237 if (!Entry.selected) return false;
1238 Entry.selected = false;
1239 sel_totalsize -= Entry.size;
1240 if (Entry.type == 'dir') total_dirs_selected--;
1241 else total_files_selected--;
1242 update_sel_status();
1243 return true;
1244 }
1245 function select(Entry){
1246 if(Entry.selected) return false;
1247 Entry.selected = true;
1248 sel_totalsize += Entry.size;
1249 if(Entry.type == 'dir') total_dirs_selected++;
1250 else total_files_selected++;
1251 update_sel_status();
1252 return true;
1253 }
1254 function is_anything_selected(){
1255 var selected_dir_list = new Array();
1256 var selected_file_list = new Array();
1257 for(var x=0;x<".(integer)count($entry_list).";x++){
1258 if(entry_list['entry'+x].selected){
1259 if(entry_list['entry'+x].type == 'dir') selected_dir_list.push(entry_list['entry'+x].name);
1260 else selected_file_list.push(entry_list['entry'+x].name);
1261 }
1262 }
1263 document.form_action.selected_dir_list.value = selected_dir_list.join('<|*|>');
1264 document.form_action.selected_file_list.value = selected_file_list.join('<|*|>');
1265 return (total_dirs_selected>0 || total_files_selected>0);
1266 }
1267 function formatsize (arg) {
1268 var resul = '';
1269 if (arg>0){
1270 var j = 0;
1271 var ext = new Array(' bytes',' Kb',' Mb',' Gb',' Tb');
1272 while (arg >= Math.pow(1024,j)) ++j;
1273 resul = (Math.round(arg/Math.pow(1024,j-1)*100)/100) + ext[j-1];
1274 } else resul = '0 Mb';
1275 return resul;
1276 }
1277 var sel_totalsize = 0;
1278 function update_sel_status(){
1279 var t = total_dirs_selected+' ".et('Dir_s')." ".et('And')." '+total_files_selected+' ".et('File_s')." ".et('Selected_s')." = '+formatsize(sel_totalsize);
1280 document.getElementById(\"sel_status\").innerHTML = t;
1281 }
1282 // Select all/none/inverse
1283 function selectANI(Butt){
1284 var MarkColor = '#".$fm_color['Mark']."';
1285 for(var x=0;x<". (integer)count($entry_list).";x++){
1286 if (entry_list['entry'+x].type == 'dir'){
1287 var DefaultColor = '#".$fm_color['Dir']."';
1288 } else {
1289 var DefaultColor = '#".$fm_color['File']."';
1290 }
1291 var Row = document.getElementById('entry'+x);
1292 var Cells = Row.getElementsByTagName('td');
1293 var newColor = null;
1294 switch (Butt.value){
1295 case '".et('SelAll')."':
1296 if (select(entry_list[Row.id])) newColor = MarkColor;
1297 break;
1298 case '".et('SelNone')."':
1299 if (unselect(entry_list[Row.id])) newColor = DefaultColor;
1300 break;
1301 case '".et('SelInverse')."':
1302 if (entry_list[Row.id].selected){
1303 if (unselect(entry_list[Row.id])) newColor = DefaultColor;
1304 } else {
1305 if (select(entry_list[Row.id])) newColor = MarkColor;
1306 }
1307 break;
1308 }
1309 if (newColor) {
1310 for (var c=0; c < ".(integer)$highlight_cols."; c++) {
1311 if (entry_list[Row.id].type=='file' && c==0 && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#". $fm_color['FileFirstCell']."';
1312 else Cells[c].style.backgroundColor = newColor;
1313 }
1314 }
1315 }
1316 if (Butt.value == '".et('SelAll')."'){
1317 Butt.value = '".et('SelNone')."';
1318 } else if (Butt.value == '".et('SelNone')."'){
1319 Butt.value = '".et('SelAll')."';
1320 }
1321 return true;
1322 }
1323 function download(arg){
1324 parent.frame1.location.href='".$path_info["basename"]."?action=3&dir_atual=$dir_atual&filename='+escape(arg);
1325 }
1326 function upload(){
1327 var w = 400;
1328 var h = 200;
1329 window.open('".$path_info["basename"]."?action=10&dir_atual=$dir_atual', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1330 }
1331 function execute(){
1332 document.form_action.cmd_arg.value = prompt('".et('TypeCmd').".');
1333 if(document.form_action.cmd_arg.value.length>0){
1334 if(confirm('".et('ConfExec')." \\' '+document.form_action.cmd_arg.value+' \\' ?')) {
1335 var w = 800;
1336 var h = 600;
1337 window.open('".$path_info["basename"]."?action=6&dir_atual=$dir_atual&cmd='+escape(document.form_action.cmd_arg.value), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1338 }
1339 }
1340 }
1341 function decompress(arg){
1342 if(confirm('".strtoupper(et('Decompress'))." \\' '+arg+' \\' ?')) {
1343 document.form_action.action.value = 72;
1344 document.form_action.cmd_arg.value = arg;
1345 document.form_action.submit();
1346 }
1347 }
1348 function edit_file(arg){
1349 var w = 800;
1350 var h = 600;
1351 if(confirm('".strtoupper(et('Edit'))." \\' '+arg+' \\' ?')) window.open('".$path_info["basename"]."?action=7&dir_atual=$dir_atual&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1352 }
1353 function config(){
1354 var w = 600;
1355 var h = 400;
1356 window.open('".$path_info["basename"]."?action=2', 'win_config', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1357 }
1358 function server_info(arg){
1359 var w = 800;
1360 var h = 600;
1361 window.open('".$path_info["basename"]."?action=5', 'win_serverinfo', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1362 }
1363 function shell(){
1364 var w = 800;
1365 var h = 600;
1366 window.open('".$path_info["basename"]."?action=9', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1367 }
1368 function view(arg){
1369 var w = 800;
1370 var h = 600;
1371 if(confirm('".strtoupper(et('View'))." \\' '+arg+' \\' ?')) window.open('".$path_info["basename"]."?action=4&dir_atual=$dir_atual&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=yes');
1372 }
1373 function rename(arg){
1374 var nome = '';
1375 if (nome = prompt('".strtoupper(et('Ren'))." \\' '+arg+' \\' ".et('To')." ...')) document.location.href='".$path_info["basename"]."?frame=3&action=3&dir_atual=$dir_atual&old_name='+escape(arg)+'&new_name='+escape(nome);
1376 }
1377 function set_dir_dest(arg){
1378 document.form_action.dir_dest.value=arg;
1379 if (document.form_action.action.value.length>0) test(document.form_action.action.value);
1380 else alert('".et('JSError').".');
1381 }
1382 function sel_dir(arg){
1383 document.form_action.action.value = arg;
1384 document.form_action.dir_dest.value='';
1385 if (!is_anything_selected()) alert('".et('NoSel').".');
1386 else {
1387 if (!getCookie('sel_dir_warn')) {
1388 alert('".et('SelDir').".');
1389 document.cookie='sel_dir_warn'+'='+escape('true')+';';
1390 }
1391 parent.frame2.set_flag(true);
1392 }
1393 }
1394 function set_chmod_arg(arg){
1395 document.form_action.chmod_arg.value=arg;
1396 if (document.form_action.action.value.length>0) test(document.form_action.action.value);
1397 else alert('".et('JSError')."');
1398 }
1399 function chmod(arg){
1400 document.form_action.action.value = arg;
1401 document.form_action.dir_dest.value='';
1402 document.form_action.chmod_arg.value='';
1403 if (!is_anything_selected()) alert('".et('NoSel').".');
1404 else {
1405 var w = 280;
1406 var h = 180;
1407 window.open('".$path_info["basename"]."?action=8', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');
1408 }
1409 }
1410 function test_action(){
1411 if (document.form_action.action.value != 0) return true;
1412 else return false;
1413 }
1414 function test_prompt(arg){
1415 var erro='';
1416 var conf='';
1417 if (arg == 1){
1418 document.form_action.cmd_arg.value = prompt('".et('TypeDir').".');
1419 } else if (arg == 2){
1420 document.form_action.cmd_arg.value = prompt('".et('TypeArq').".');
1421 } else if (arg == 71){
1422 if (!is_anything_selected()) erro = '".et('NoSel').".';
1423 else document.form_action.cmd_arg.value = prompt('".et('TypeArqComp')."');
1424 }
1425 if (erro!=''){
1426 document.form_action.cmd_arg.focus();
1427 alert(erro);
1428 } else if(document.form_action.cmd_arg.value.length>0) {
1429 document.form_action.action.value = arg;
1430 document.form_action.submit();
1431 }
1432 }
1433 function strstr(haystack,needle){
1434 var index = haystack.indexOf(needle);
1435 return (index==-1)?false:index;
1436 }
1437 function valid_dest(dest,orig){
1438 return (strstr(dest,orig)==false)?true:false;
1439 }
1440 // ArrayAlert - Selection debug only
1441 function aa(){
1442 var str = 'selected_dir_list:\\n';
1443 for (x=0;x<selected_dir_list.length;x++){
1444 str += selected_dir_list[x]+'\\n';
1445 }
1446 str += '\\nselected_file_list:\\n';
1447 for (x=0;x<selected_file_list.length;x++){
1448 str += selected_file_list[x]+'\\n';
1449 }
1450 alert(str);
1451 }
1452 function test(arg){
1453 var erro='';
1454 var conf='';
1455 if (arg == 4){
1456 if (!is_anything_selected()) erro = '".et('NoSel').".\\n';
1457 conf = '".et('RemSel')." ?\\n';
1458 } else if (arg == 5){
1459 if (!is_anything_selected()) erro = '".et('NoSel').".\\n';
1460 else if(document.form_action.dir_dest.value.length == 0) erro = '".et('NoDestDir').".';
1461 else if(document.form_action.dir_dest.value == document.form_action.dir_atual.value) erro = '".et('DestEqOrig').".';
1462 else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.dir_atual.value)) erro = '".et('InvalidDest').".';
1463 conf = '".et('CopyTo')." \\' '+document.form_action.dir_dest.value+' \\' ?\\n';
1464 } else if (arg == 6){
1465 if (!is_anything_selected()) erro = '".et('NoSel').".';
1466 else if(document.form_action.dir_dest.value.length == 0) erro = '".et('NoDestDir').".';
1467 else if(document.form_action.dir_dest.value == document.form_action.dir_atual.value) erro = '".et('DestEqOrig').".';
1468 else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.dir_atual.value)) erro = '".et('InvalidDest').".';
1469 conf = '".et('MoveTo')." \\' '+document.form_action.dir_dest.value+' \\' ?\\n';
1470 } else if (arg == 9){
1471 if (!is_anything_selected()) erro = '".et('NoSel').".';
1472 else if(document.form_action.chmod_arg.value.length == 0) erro = '".et('NoNewPerm').".';
1473 conf = '".et('AlterPermTo')." \\' '+document.form_action.chmod_arg.value+' \\' ?\\n';
1474 }
1475 if (erro!=''){
1476 document.form_action.cmd_arg.focus();
1477 alert(erro);
1478 } else if(conf!='') {
1479 if(confirm(conf)) {
1480 document.form_action.action.value = arg;
1481 document.form_action.submit();
1482 }
1483 } else {
1484 document.form_action.action.value = arg;
1485 document.form_action.submit();
1486 }
1487 }
1488 //-->
1489 </script>";
1490 $out .= "
1491 <form name=\"form_action\" action=\"".$path_info["basename"]."\" method=\"post\" onsubmit=\"return test_action();\">
1492 <input type=hidden name=\"frame\" value=3>
1493 <input type=hidden name=\"action\" value=0>
1494 <input type=hidden name=\"dir_dest\" value=\"\">
1495 <input type=hidden name=\"chmod_arg\" value=\"\">
1496 <input type=hidden name=\"cmd_arg\" value=\"\">
1497 <input type=hidden name=\"dir_atual\" value=\"$dir_atual\">
1498 <input type=hidden name=\"dir_antes\" value=\"$dir_antes\">
1499 <input type=hidden name=\"selected_dir_list\" value=\"\">
1500 <input type=hidden name=\"selected_file_list\" value=\"\">";
1501 $out .= "
1502 <tr>
1503 <td bgcolor=\"#DDDDDD\" colspan=20><nobr>
1504 <input type=button onclick=\"config()\" value=\"".et('Config')."\">
1505 <input type=button onclick=\"server_info()\" value=\"".et('ServerInfo')."\">
1506 <input type=button onclick=\"test_prompt(1)\" value=\"".et('CreateDir')."\">
1507 <input type=button onclick=\"test_prompt(2)\" value=\"".et('CreateArq')."\">
1508 <input type=button onclick=\"execute()\" value=\"".et('ExecCmd')."\">
1509 <input type=button onclick=\"upload()\" value=\"".et('Upload')."\">
1510 <input type=button onclick=\"shell()\" value=\"".et('Shell')."\">
1511 <b>$ip</b>
1512 </nobr>";
1513 if ($dir_atual != $fm_root_atual){
1514 $mat = explode("/",$dir_atual);
1515 $dir_antes = "";
1516 for($x=0;$x<(count($mat)-2);$x++) $dir_antes .= $mat[$x]."/";
1517 $uplink = "<a href=\"".$path_info["basename"]."?frame=3&dir_atual=$dir_antes\"><<</a> ";
1518 }
1519 if($entry_count){
1520 $out .= "
1521 <tr><td bgcolor=\"#DDDDDD\" colspan=20><nobr>$uplink <a href=\"".$path_info["basename"]."?frame=3&dir_atual=$dir_atual\">$dir_atual</a></nobr>
1522 <tr>
1523 <td bgcolor=\"#DDDDDD\" colspan=20><nobr>
1524 <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"".et('SelAll')."\">
1525 <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"".et('SelInverse')."\">
1526 <input type=\"button\" style=\"width:60\" onclick=\"test(4)\" value=\"".et('Rem')."\">
1527 <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(5)\" value=\"".et('Copy')."\">
1528 <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(6)\" value=\"".et('Move')."\">
1529 <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"".et('Compress')."\">";
1530 if ($islinux) $out .= "
1531 <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"".et('ResolveIDs')."\">";
1532 $out .= "
1533 <input type=\"button\" style=\"width:100\" onclick=\"chmod(9)\" value=\"".et('Perms')."\">";
1534 $out .= "
1535 </nobr>
1536 <tr><td bgcolor=\"#DDDDDD\" colspan=20><DIV ID=\"sel_status\"></DIV></td></tr>";
1537 $dir_out="";
1538 $file_out="";
1539 foreach ($entry_list as $ind=>$dir_entry) {
1540 $file = $dir_entry["name"];
1541 if ($dir_entry["type"]=="dir"){
1542 $dir_out .= "
1543 <tr ID=\"entry$ind\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">
1544 <td align=left bgcolor=\"#".$fm_color['Dir']."\"><nobr><a href=\"JavaScript:go('$file')\">$file</a></nobr>
1545 <td bgcolor=\"#".$fm_color['Dir']."\">".$dir_entry["p"];
1546 if ($islinux) $dir_out .= "<td bgcolor=\"#".$fm_color['Dir']."\">".$dir_entry["u"]."<td bgcolor=\"#".$fm_color['Dir']."\">".$dir_entry["g"];
1547 $dir_out .= "
1548 <td bgcolor=\"#".$fm_color['Dir']."\">".$dir_entry["sizet"]."
1549 <td bgcolor=\"#".$fm_color['Dir']."\">".$dir_entry["datet"];
1550 if ($file_count) $dir_out .= "
1551 <td bgcolor=\"#".$fm_color['Dir']."\" align=center>";
1552 // Opções de diretório
1553 if ( is_writable($dir_atual.$file) ) $dir_out .= "
1554 <td bgcolor=\"#FFFFFF\" align=center><a href=\"JavaScript:if(confirm('".et('ConfRem')." \\'".$file."\\' ?')) document.location.href='".$path_info["basename"]."?frame=3&action=8&cmd_arg=".$file."&dir_atual=$dir_atual'\">".et('Rem')."</a>
1555 <td bgcolor=\"#FFFFFF\" align=center><a href=\"JavaScript:rename('$file')\">".et('Ren')."</a>";
1556 $dir_out .= "
1557 </tr>";
1558 } else {
1559 $file_out .= "
1560 <tr ID=\"entry$ind\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">
1561 <td align=left bgcolor=\"#FFFFFF\"><nobr><a href=\"JavaScript:download('$file')\">$file</a></nobr>
1562 <td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["p"];
1563 if ($islinux) $file_out .= "<td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["u"]."<td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["g"];
1564 $file_out .= "
1565 <td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["sizet"]."
1566 <td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["datet"]."
1567 <td bgcolor=\"#".$fm_color['File']."\">".$dir_entry["extt"];
1568 // Opções de arquivo
1569 if ( is_writable($dir_atual.$file) ) $file_out .= "
1570 <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:if(confirm('".strtoupper(et('Rem'))." \\'".$file."\\' ?')) document.location.href='".$path_info["basename"]."?frame=3&action=8&cmd_arg=".$file."&dir_atual=$dir_atual'\">".et('Rem')."</a>
1571 <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:rename('$file')\">".et('Ren')."</a>";
1572 if ( is_readable($dir_atual.$file) && (strpos(".wav#.mp3#.mid#.avi#.mov#.mpeg#.mpg#.rm#.iso#.bin#.img#.dll#.psd#.fla#.swf#.class#.ppt#.jpg#.gif#.png#.wmf#.eps#.bmp#.msi#.exe#.com#.rar#.tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"]."#" ) === false)) $file_out .= "
1573 <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:edit_file('$file')\">".et('Edit')."</a>";
1574 if ( is_readable($dir_atual.$file) && strlen($dir_entry["ext"]) && (strpos(".tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"]."#" ) !== false)) $file_out .= "
1575 <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:decompress('$file')\">".et('Decompress')."</a>";
1576 if( $is_reachable && is_readable($dir_atual.$file) && (strpos(".txt#.sys#.bat#.ini#.conf#.swf#.php#.php3#.asp#.html#.htm#.jpg#.gif#.png#.bmp#", $dir_entry["ext"]."#" ) !== false)) $file_out .= "
1577 <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:view('$file');\">".et('View')."</a>";
1578 $file_out .= "</tr>";
1579 }
1580 }
1581 $out .= $dir_out;
1582 if ($entry_count){
1583 $out .= "
1584 <tr>
1585 <td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or1&dir_atual=$dir_atual\">".et('Name')."</a>
1586 <td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or2&dir_atual=$dir_atual\">".et('Perms')."</a>";
1587 if ($islinux) $out .= "<td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or3&dir_atual=$dir_atual\">".et('Owner')."</a><td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or4&dir_atual=$dir_atual\">".et('Group')."</a>";
1588 $out .= "
1589 <td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or5&dir_atual=$dir_atual\">".et('Size')."</a>
1590 <td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or6&dir_atual=$dir_atual\">".et('Date')."</a>";
1591 if ($file_count) $out .= "
1592 <td bgcolor=\"#DDDDDD\"><a href=\"".$path_info["basename"]."?frame=3&or_by=$or7&dir_atual=$dir_atual\">".et('Type')."</a>";
1593 $out .= "
1594 <td bgcolor=\"#DDDDDD\" colspan=20>";
1595
1596 }
1597 $out .= $file_out;
1598 $out .= "
1599 <tr>
1600 <td bgcolor=\"#DDDDDD\" colspan=20><nobr>
1601 <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"".et('SelAll')."\">
1602 <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"".et('SelInverse')."\">
1603 <input type=\"button\" style=\"width:60\" onclick=\"test(4)\" value=\"".et('Rem')."\">
1604 <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(5)\" value=\"".et('Copy')."\">
1605 <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(6)\" value=\"".et('Move')."\">
1606 <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"".et('Compress')."\">";
1607 if ($islinux) $out .= "
1608 <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"".et('ResolveIDs')."\">";
1609 $out .= "
1610 <input type=\"button\" style=\"width:100\" onclick=\"chmod(9)\" value=\"".et('Perms')."\">";
1611 $out .= "
1612 </nobr></td>
1613 </tr>";
1614 $out .= "
1615 </form>";
1616 $out .= "
1617 <tr><td bgcolor=\"#DDDDDD\" colspan=20>$dir_count ".et('Dir_s')." ".et('And')." $file_count ".et('File_s')." = ".formatsize($total_size)."</td></tr>";
1618 if ($quota_mb) {
1619 $out .= "
1620 <tr><td bgcolor=\"#DDDDDD\" colspan=20>".et('Partition').": ".formatsize(($quota_mb*1024*1024))." ".et('Total')." - ".formatsize(($quota_mb*1024*1024)-total_size($fm_root_atual))." ".et('Free')."</td></tr>";
1621 } else {
1622 $out .= "
1623 <tr><td bgcolor=\"#DDDDDD\" colspan=20>".et('Partition').": ".formatsize(disk_total_space($dir_atual))." ".et('Total')." - ".formatsize(disk_free_space($fm_root_atual))." ".et('Free')."</td></tr>";
1624 }
1625 $tf = getmicrotime();
1626 $tt = ($tf - $ti);
1627 $out .= "
1628 <tr><td bgcolor=\"#DDDDDD\" colspan=20>".et('RenderTime').": ".substr($tt,0,strrpos($tt,".")+5)." ".et('Seconds')."</td></tr>";
1629 $out .= "
1630 <script language=\"Javascript\" type=\"text/javascript\">
1631 <!--
1632 update_sel_status();
1633 //-->
1634 </script>";
1635 } else {
1636 $out .= "
1637 <tr>
1638 <td bgcolor=\"#DDDDDD\" width=\"1%\">$uplink<td bgcolor=\"#DDDDDD\" colspan=20><nobr><a href=\"".$path_info["basename"]."?frame=3&dir_atual=$dir_atual\">$dir_atual</a></nobr>
1639 <tr><td bgcolor=\"#DDDDDD\" colspan=20>".et('EmptyDir').".</tr>";
1640 }
1641 } else $out .= "<tr><td><font color=red>".et('IOError').".<br>$dir_atual</font>";
1642 $out .= "</table>";
1643 echo $out;
1644}
1645function upload_form(){
1646 global $_FILES,$dir_atual,$dir_dest,$fechar,$quota_mb,$path_info;
1647 $num_uploads = 5;
1648 html_header();
1649 echo "<body marginwidth=\"0\" marginheight=\"0\">";
1650 if (count($_FILES)==0){
1651 echo "
1652 <table height=\"100%\" border=0 cellspacing=0 cellpadding=2 align=center>
1653 <form name=\"upload_form\" action=\"".$path_info["basename"]."\" method=\"post\" ENCTYPE=\"multipart/form-data\">
1654 <input type=hidden name=dir_dest value=\"$dir_atual\">
1655 <input type=hidden name=action value=10>
1656 <tr><th colspan=2>".et('Upload')."</th></tr>
1657 <tr><td align=right><b>".et('Destination').":<td><b><nobr>$dir_atual</nobr>";
1658 for ($x=0;$x<$num_uploads;$x++){
1659 echo "<tr><td width=1 align=right><b>".et('File').":<td><nobr><input type=\"file\" name=\"file$x\"></nobr>";
1660 $test_js .= "(document.upload_form.file$x.value.length>0)||";
1661 }
1662 echo "
1663 <input type=button value=\"".et('Send')."\" onclick=\"test_upload_form()\"></nobr>
1664 <tr><td>Â <td><input type=checkbox name=fechar value=\"1\"> <a href=\"JavaScript:troca();\">".et('AutoClose')."</a>
1665 <tr><td colspan=2>Â </td></tr>
1666 </form>
1667 </table>
1668 <script language=\"Javascript\" type=\"text/javascript\">
1669 <!--
1670 function troca(){
1671 if(document.upload_form.fechar.checked){document.upload_form.fechar.checked=false;}else{document.upload_form.fechar.checked=true;}
1672 }
1673 foi = false;
1674 function test_upload_form(){
1675 if(".substr($test_js,0,strlen($test_js)-2)."){
1676 if (foi) alert('".et('SendingForm')."...');
1677 else {
1678 foi = true;
1679 document.upload_form.submit();
1680 }
1681 } else alert('".et('NoFileSel').".');
1682 }
1683 window.moveTo((window.screen.width-400)/2,((window.screen.height-200)/2)-20);
1684 //-->
1685 </script>";
1686 } else {
1687 $out = "<tr><th colspan=2>".et('UploadEnd')."</th></tr>
1688 <tr><th colspan=2><nobr>".et('Destination').": $dir_dest</nobr>";
1689 for ($x=0;$x<$num_uploads;$x++){
1690 $temp_file = $_FILES["file".$x]["tmp_name"];
1691 $filename = $_FILES["file".$x]["name"];
1692 if (strlen($filename)) $resul = save_upload($temp_file,$filename,$dir_dest);
1693 else $resul = 7;
1694 switch($resul){
1695 case 1:
1696 $out .= "<tr><td><b>".strzero($x+1,3).".<font color=green><b> ".et('FileSent').":</font><td>".$filename."</td></tr>\n";
1697 break;
1698 case 2:
1699 $out .= "<tr><td colspan=2><font color=red><b>".et('IOError')."</font></td></tr>\n";
1700 $x = $upload_num;
1701 break;
1702 case 3:
1703 $out .= "<tr><td colspan=2><font color=red><b>".et('SpaceLimReached')." ($quota_mb Mb)</font></td></tr>\n";
1704 $x = $upload_num;
1705 break;
1706 case 4:
1707 $out .= "<tr><td><b>".strzero($x+1,3).".<font color=red><b> ".et('InvExt').":</font><td>".$filename."</td></tr>\n";
1708 break;
1709 case 5:
1710 $out .= "<tr><td><b>".strzero($x+1,3).".<font color=red><b> ".et('FileNoOverw')."</font><td>".$filename."</td></tr>\n";
1711 break;
1712 case 6:
1713 $out .= "<tr><td><b>".strzero($x+1,3).".<font color=green><b> ".et('FileOverw').":</font><td>".$filename."</td></tr>\n";
1714 break;
1715 case 7:
1716 $out .= "<tr><td colspan=2><b>".strzero($x+1,3).".<font color=red><b> ".et('FileIgnored')."</font></td></tr>\n";
1717 }
1718 }
1719 if ($fechar) {
1720 echo "
1721 <script language=\"Javascript\" type=\"text/javascript\">
1722 <!--
1723 window.close();
1724 //-->
1725 </script>
1726 ";
1727 } else {
1728 echo "
1729 <table height=\"100%\" border=0 cellspacing=0 cellpadding=2 align=center>
1730 $out
1731 <tr><td colspan=2>Â </td></tr>
1732 </table>
1733 <script language=\"Javascript\" type=\"text/javascript\">
1734 <!--
1735 window.focus();
1736 //-->
1737 </script>
1738 ";
1739 }
1740 }
1741 echo "</body>\n</html>";
1742}
1743function chmod_form(){
1744 $aux = "
1745 <script language=\"Javascript\" type=\"text/javascript\">
1746 <!--
1747 function octalchange()
1748 {
1749 var val = document.chmod_form.t_total.value;
1750 var stickybin = parseInt(val.charAt(0)).toString(2);
1751 var ownerbin = parseInt(val.charAt(1)).toString(2);
1752 while (ownerbin.length<3) { ownerbin=\"0\"+ownerbin; };
1753 var groupbin = parseInt(val.charAt(2)).toString(2);
1754 while (groupbin.length<3) { groupbin=\"0\"+groupbin; };
1755 var otherbin = parseInt(val.charAt(3)).toString(2);
1756 while (otherbin.length<3) { otherbin=\"0\"+otherbin; };
1757 document.chmod_form.sticky.checked = parseInt(stickybin.charAt(0));
1758 document.chmod_form.owner4.checked = parseInt(ownerbin.charAt(0));
1759 document.chmod_form.owner2.checked = parseInt(ownerbin.charAt(1));
1760 document.chmod_form.owner1.checked = parseInt(ownerbin.charAt(2));
1761 document.chmod_form.group4.checked = parseInt(groupbin.charAt(0));
1762 document.chmod_form.group2.checked = parseInt(groupbin.charAt(1));
1763 document.chmod_form.group1.checked = parseInt(groupbin.charAt(2));
1764 document.chmod_form.other4.checked = parseInt(otherbin.charAt(0));
1765 document.chmod_form.other2.checked = parseInt(otherbin.charAt(1));
1766 document.chmod_form.other1.checked = parseInt(otherbin.charAt(2));
1767 calc_chmod(1);
1768 };
1769
1770 function calc_chmod(nototals)
1771 {
1772 var users = new Array(\"owner\", \"group\", \"other\");
1773 var totals = new Array(\"\",\"\",\"\");
1774 var syms = new Array(\"\",\"\",\"\");
1775
1776 for (var i=0; i<users.length; i++)
1777 {
1778 var user=users[i];
1779 var field4 = user + \"4\";
1780 var field2 = user + \"2\";
1781 var field1 = user + \"1\";
1782 var symbolic = \"sym_\" + user;
1783 var number = 0;
1784 var sym_string = \"\";
1785 var sticky = \"0\";
1786 var sticky_sym = \" \";
1787 if (document.chmod_form.sticky.checked){
1788 sticky = \"1\";
1789 sticky_sym = \"t\";
1790 }
1791 if (document.chmod_form[field4].checked == true) { number += 4; }
1792 if (document.chmod_form[field2].checked == true) { number += 2; }
1793 if (document.chmod_form[field1].checked == true) { number += 1; }
1794
1795 if (document.chmod_form[field4].checked == true) {
1796 sym_string += \"r\";
1797 } else {
1798 sym_string += \"-\";
1799 }
1800 if (document.chmod_form[field2].checked == true) {
1801 sym_string += \"w\";
1802 } else {
1803 sym_string += \"-\";
1804 }
1805 if (document.chmod_form[field1].checked == true) {
1806 sym_string += \"x\";
1807 } else {
1808 sym_string += \"-\";
1809 }
1810
1811 totals[i] = totals[i]+number;
1812 syms[i] = syms[i]+sym_string;
1813
1814 };
1815 if (!nototals) document.chmod_form.t_total.value = sticky + totals[0] + totals[1] + totals[2];
1816 document.chmod_form.sym_total.value = syms[0] + syms[1] + syms[2] + sticky_sym;
1817 }
1818 function troca(){
1819 if(document.chmod_form.sticky.checked){document.chmod_form.sticky.checked=false;}else{document.chmod_form.sticky.checked=true;}
1820 }
1821
1822 window.onload=octalchange
1823 window.moveTo((window.screen.width-400)/2,((window.screen.height-200)/2)-20);
1824 //-->
1825 </script>
1826 ";
1827 html_header($aux);
1828 echo "<body marginwidth=\"0\" marginheight=\"0\">
1829 <form name=\"chmod_form\">
1830 <TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"4\" ALIGN=CENTER>
1831 <tr><th colspan=4>".et('Perms')."</th></tr>
1832 <TR ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">
1833 <TD><input type=\"text\" name=\"t_total\" value=\"0777\" size=\"4\" onKeyUp=\"octalchange()\"> </TD>
1834 <TD><input type=\"text\" name=\"sym_total\" value=\"\" size=\"12\" READONLY=\"1\"></TD>
1835 </TR>
1836 </TABLE>
1837 <table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" ALIGN=CENTER>
1838 <tr bgcolor=\"#333333\">
1839 <td WIDTH=\"60\" align=\"left\"> </td>
1840 <td WIDTH=\"55\" align=\"center\" style=\"color:#FFFFFF\"><b>".et('Owner')."
1841 </b></td>
1842 <td WIDTH=\"55\" align=\"center\" style=\"color:#FFFFFF\"><b>".et('Group')."
1843 </b></td>
1844 <td WIDTH=\"55\" align=\"center\" style=\"color:#FFFFFF\"><b>".et('Other')."
1845 <b></td>
1846 </tr>
1847 <tr bgcolor=\"#DDDDDD\">
1848 <td WIDTH=\"60\" align=\"left\" nowrap BGCOLOR=\"#FFFFFF\">".et('Read')."</td>
1849 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1850 <input type=\"checkbox\" name=\"owner4\" value=\"4\" onclick=\"calc_chmod()\">
1851 </td>
1852 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#FFFFFF\"><input type=\"checkbox\" name=\"group4\" value=\"4\" onclick=\"calc_chmod()\">
1853 </td>
1854 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1855 <input type=\"checkbox\" name=\"other4\" value=\"4\" onclick=\"calc_chmod()\">
1856 </td>
1857 </tr>
1858 <tr bgcolor=\"#DDDDDD\">
1859 <td WIDTH=\"60\" align=\"left\" nowrap BGCOLOR=\"#FFFFFF\">".et('Write')."</td>
1860 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1861 <input type=\"checkbox\" name=\"owner2\" value=\"2\" onclick=\"calc_chmod()\"></td>
1862 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#FFFFFF\"><input type=\"checkbox\" name=\"group2\" value=\"2\" onclick=\"calc_chmod()\">
1863 </td>
1864 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1865 <input type=\"checkbox\" name=\"other2\" value=\"2\" onclick=\"calc_chmod()\">
1866 </td>
1867 </tr>
1868 <tr bgcolor=\"#DDDDDD\">
1869 <td WIDTH=\"60\" align=\"left\" nowrap BGCOLOR=\"#FFFFFF\">".et('Exec')."</td>
1870 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1871 <input type=\"checkbox\" name=\"owner1\" value=\"1\" onclick=\"calc_chmod()\">
1872 </td>
1873 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#FFFFFF\"><input type=\"checkbox\" name=\"group1\" value=\"1\" onclick=\"calc_chmod()\">
1874 </td>
1875 <td WIDTH=\"55\" align=\"center\" bgcolor=\"#EEEEEE\">
1876 <input type=\"checkbox\" name=\"other1\" value=\"1\" onclick=\"calc_chmod()\">
1877 </td>
1878 </tr>
1879 </TABLE>
1880 <TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"4\" ALIGN=CENTER>
1881 <tr><td colspan=2><input type=checkbox name=sticky value=\"1\" onclick=\"calc_chmod()\"> <a href=\"JavaScript:troca();\">".et('StickyBit')."</a><td colspan=2 align=right><input type=button value=\"".et('Apply')."\" onClick=\"window.opener.set_chmod_arg(document.chmod_form.t_total.value); window.close();\"></tr>
1882 </table>
1883 </form>
1884 </body>\n</html>";
1885}
1886function view(){
1887 global $doc_root,$path_info,$url_info,$dir_atual,$islinux,$filename,$is_reachable;
1888 html_header();
1889 echo "<body marginwidth=\"0\" marginheight=\"0\">
1890 <script language=\"Javascript\" type=\"text/javascript\">
1891 <!--
1892 window.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);";
1893 if ($is_reachable){
1894 $url = $url_info["scheme"]."://".$url_info["host"];
1895 if (strlen($url_info["port"])) $url .= ":".$url_info["port"];
1896 // Malditas variaveis de sistema!! No windows doc_root é sempre em lowercase... cadê o str_ireplace() ??
1897 $url .= str_replace($doc_root,"",$dir_atual).$filename;
1898 echo "
1899 document.location.href='$url';";
1900 } else {
1901 echo "
1902 alert('".et('OutDocRoot').":\\n".$doc_root."\\n');
1903 window.close();";
1904 }
1905 echo "
1906 //-->
1907 </script>
1908 </body>\n</html>";
1909}
1910function edit_file_form(){
1911 global $dir_atual,$filename,$file_data,$save_file,$path_info;
1912 $file = $dir_atual.$filename;
1913 if ($save_file){
1914 $fh=fopen($file,"w");
1915 fputs($fh,$file_data,strlen($file_data));
1916 fclose($fh);
1917 }
1918 $fh=fopen($file,"r");
1919 $file_data=fread($fh, filesize($file));
1920 fclose($fh);
1921 html_header();
1922 echo "<body marginwidth=\"0\" marginheight=\"0\">
1923 <table border=0 cellspacing=0 cellpadding=5 align=center>
1924 <form name=\"edit_form\" action=\"".$path_info["basename"]."\" method=\"post\">
1925 <input type=hidden name=action value=\"7\">
1926 <input type=hidden name=save_file value=\"1\">
1927 <input type=hidden name=dir_atual value=\"$dir_atual\">
1928 <input type=hidden name=filename value=\"$filename\">
1929 <tr><th colspan=2>".$file."</th></tr>
1930 <tr><td colspan=2><textarea name=file_data rows=33 cols=105>".htmlencode($file_data)."</textarea></td></tr>
1931 <tr><td><input type=button value=\"".et('Refresh')."\" onclick=\"document.edit_form_refresh.submit()\"></td><td align=right><input type=button value=\"".et('SaveFile')."\" onclick=\"go_save()\"></td></tr>
1932 </form>
1933 <form name=\"edit_form_refresh\" action=\"".$path_info["basename"]."\" method=\"post\">
1934 <input type=hidden name=action value=\"7\">
1935 <input type=hidden name=dir_atual value=\"$dir_atual\">
1936 <input type=hidden name=filename value=\"$filename\">
1937 </form>
1938 </table>
1939 <script language=\"Javascript\" type=\"text/javascript\">
1940 <!--
1941 window.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);
1942 function go_save(){";
1943 if (is_writable($file)) {
1944 echo "
1945 document.edit_form.submit();";
1946 } else {
1947 echo "
1948 if(confirm('".et('ConfTrySave')." ?')) document.edit_form.submit();";
1949 }
1950 echo "
1951 }
1952 //-->
1953 </script>
1954 </body>\n</html>";
1955}
1956function config_form(){
1957 global $cfg;
1958 global $dir_atual,$script_filename,$doc_root,$path_info,$fm_root_atual,$lang,$error_reporting,$version;
1959 global $config_action,$newsenha,$newlang,$newerror,$newfm_root;
1960 $Warning = "";
1961 switch ($config_action){
1962 case 1:
1963 if ($fh = fopen("http://phpfm.sf.net/latest.php","r")){
1964 $data = "";
1965 while (!feof($fh)) $data .= fread($fh,1024);
1966 fclose($fh);
1967 $data = unserialize($data);
1968 $ChkVerWarning = "<tr><td align=right>Â ";
1969 if (is_array($data)&&count($data)){
1970 // sf.net logo
1971 $ChkVerWarning .= "<a href=\"JavaScript:open_win('http://sourceforge.net')\"><img src=\"http://sourceforge.net/sflogo.php?group_id=114392&type=1\" width=\"88\" height=\"31\" border=\"0\" alt=\"SourceForge.net Logo\" /></a>";
1972 if (str_replace(".","",$data['version'])>str_replace(".","",$cfg->data['version'])) $ChkVerWarning .= "<td><a href=\"JavaScript:open_win('http://prdownloads.sourceforge.net/phpfm/phpFileManager-".$data['version'].".zip?download')\"><font color=green>".et('ChkVerAvailable')."</font></a>";
1973 else $ChkVerWarning .= "<td><font color=red>".et('ChkVerNotAvailable')."</font>";
1974 } else $ChkVerWarning .= "<td><font color=red>".et('ChkVerError')."</font>";
1975 } else $ChkVerWarning .= "<td><font color=red>".et('ChkVerError')."</font>";
1976 break;
1977 case 2:
1978 $reload = false;
1979 if ($cfg->data['lang'] != $newlang){
1980 $cfg->data['lang'] = $newlang;
1981 $lang = $newlang;
1982 $reload = true;
1983 }
1984 if ($cfg->data['error_reporting'] != $newerror){
1985 $cfg->data['error_reporting'] = $newerror;
1986 $error_reporting = $newerror;
1987 $reload = true;
1988 }
1989 $newfm_root = formatpath($newfm_root);
1990 if ($cfg->data['fm_root'] != $newfm_root){
1991 $cfg->data['fm_root'] = $newfm_root;
1992 if (strlen($newfm_root)) $dir_atual = $newfm_root;
1993 else $dir_atual = $path_info["dirname"]."/";
1994 setcookie("fm_root_atual", $newfm_root , 0 , "/");
1995 $reload = true;
1996 }
1997 $cfg->save();
1998 if ($reload){
1999 reloadframe("window.opener.parent",2);
2000 reloadframe("window.opener.parent",3);
2001 }
2002 $Warning1 = et('ConfSaved')."...";
2003 break;
2004 case 3:
2005 if ($cfg->data['auth_pass'] != md5($newsenha)){
2006 $cfg->data['auth_pass'] = md5($newsenha);
2007 setcookie("loggedon", md5($newsenha) , 0 , "/");
2008 }
2009 $cfg->save();
2010 $Warning2 = et('PassSaved')."...";
2011 break;
2012 }
2013 html_header();
2014 echo "<body marginwidth=\"0\" marginheight=\"0\">\n";
2015 echo "
2016 <table border=0 cellspacing=0 cellpadding=5 align=center width=\"100%\">
2017 <form name=\"config_form\" action=\"".$path_info["basename"]."\" method=\"post\">
2018 <input type=hidden name=action value=2>
2019 <input type=hidden name=config_action value=0>
2020 <tr><td colspan=2 align=center><b>".strtoupper(et('Configurations'))."</b></td></tr>
2021 </table>
2022 <table border=0 cellspacing=0 cellpadding=5 align=center width=\"100%\">
2023 <tr><td align=right width=\"1%\">".et('Version').":<td>$version</td></tr>
2024 <tr><td align=right>".et('Size').":<td>".getsize($script_filename)."</td></tr>
2025 <tr><td align=right>".et('Website').":<td><a href=\"JavaScript:open_win('http://phpfm.sf.net')\">http://phpfm.sf.net</a></td></tr>";
2026 if (strlen($ChkVerWarning)) echo $ChkVerWarning.$data['warnings'];
2027 else echo "<tr><td align=right>Â <td><input type=button value=\"".et('ChkVer')."\" onclick=\"test_config_form(1)\">";
2028 echo "
2029 <tr><td align=right width=1><nobr>".et('DocRoot').":</nobr><td>".$doc_root."</td></tr>
2030 <tr><td align=right><nobr>".et('FLRoot').":</nobr><td><input type=text size=60 name=newfm_root value=\"".$cfg->data['fm_root']."\" onkeypress=\"enterSubmit(event,'test_config_form(2)')\"></td></tr>
2031 <tr><td align=right>".et('Lang').":<td><select name=newlang><option value=en>English<option value=pt>Português</select></td></tr>
2032 <tr><td align=right>".et('ErrorReport').":<td><select name=newerror><option value=\"\">NONE<option value=\"".E_ALL."\">E_ALL<option value=\"".E_ERROR."\">E_ERROR<option value=\"".(E_ERROR | E_WARNING)."\">E_ERROR & E_WARNING<option value=\"".(E_ERROR | E_WARNING | E_NOTICE)."\">E_ERROR & E_WARNING & E_NOTICE</select></td></tr>
2033 <tr><td>Â <td><input type=button value=\"".et('SaveConfig')."\" onclick=\"test_config_form(2)\">";
2034 if (strlen($Warning1)) echo " <font color=red>$Warning1</font>";
2035 echo "
2036 <tr><td align=right>".et('Pass').":<td><input type=text size=30 name=newsenha value=\"\" onkeypress=\"enterSubmit(event,'test_config_form(3)')\"></td></tr>
2037 <tr><td>Â <td><input type=button value=\"".et('SavePass')."\" onclick=\"test_config_form(3)\">";
2038 if (strlen($Warning2)) echo " <font color=red>$Warning2</font>";
2039 echo "</td></tr>";
2040 echo "
2041 </form>
2042 </table>
2043 <script language=\"Javascript\" type=\"text/javascript\">
2044 <!--
2045 function set_select(sel,val){
2046 for(var x=0;x<sel.length;x++){
2047 if(sel.options[x].value==val){
2048 sel.options[x].selected=true;
2049 break;
2050 }
2051 }
2052 }
2053 set_select(document.config_form.newlang,'".$cfg->data['lang']."');
2054 set_select(document.config_form.newerror,'".$cfg->data['error_reporting']."');
2055 function test_config_form(arg){
2056 document.config_form.config_action.value = arg;
2057 document.config_form.submit();
2058 }
2059 function open_win(url){
2060 var w = 800;
2061 var h = 600;
2062 window.open(url, '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes');
2063 }
2064 window.moveTo((window.screen.width-600)/2,((window.screen.height-400)/2)-20);
2065 window.focus();
2066 //-->
2067 </script>
2068 ";
2069 echo "</body>\n</html>";
2070}
2071function shell_form(){
2072 global $dir_atual,$shell_form,$cmd_arg,$path_info;
2073 $data_out = "";
2074 if (strlen($cmd_arg)){
2075 exec($cmd_arg,$mat);
2076 if (count($mat)) $data_out = trim(implode("\n",$mat));
2077 }
2078 switch ($shell_form){
2079 case 1:
2080 html_header();
2081 echo "
2082 <body marginwidth=\"0\" marginheight=\"0\">
2083 <table border=0 cellspacing=0 cellpadding=0 align=center>
2084 <form name=\"data_form\">
2085 <tr><td><textarea name=data_out rows=36 cols=105 READONLY=\"1\"></textarea></td></tr>
2086 </form>
2087 </table>
2088 </body></html>";
2089 break;
2090 case 2:
2091 html_header();
2092 echo "
2093 <body marginwidth=\"0\" marginheight=\"0\">
2094 <table border=0 cellspacing=0 cellpadding=0 align=center>
2095 <form name=\"shell_form\" action=\"".$path_info["basename"]."\" method=\"post\">
2096 <input type=hidden name=dir_atual value=\"$dir_atual\">
2097 <input type=hidden name=action value=\"9\">
2098 <input type=hidden name=shell_form value=\"2\">
2099 <tr><td align=center><input type=text size=90 name=cmd_arg></td></tr>
2100 </form>";
2101 echo "
2102 <script language=\"Javascript\" type=\"text/javascript\">
2103 <!--";
2104 if (strlen($data_out)) echo "
2105 var val = '# ".htmlencode($cmd_arg)."\\n".htmlencode(str_replace("<","[",str_replace(">","]",str_replace("\n","\\n",str_replace("\\","\\\\",$data_out)))))."\\n';
2106 parent.frame1.document.data_form.data_out.value += val;";
2107 echo "
2108 document.shell_form.cmd_arg.focus();
2109 //-->
2110 </script>
2111 ";
2112 echo "
2113 </table>
2114 </body></html>";
2115 break;
2116 default:
2117 $aux = "
2118 <script language=\"Javascript\" type=\"text/javascript\">
2119 <!--
2120 window.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);
2121 //-->
2122 </script>";
2123 html_header($aux);
2124 echo "
2125 <frameset rows=\"570,*\" framespacing=\"0\" frameborder=no>
2126 <frame src=\"".$path_info["basename"]."?action=9&shell_form=1\" name=frame1 border=\"0\" marginwidth=\"0\" marginheight=\"0\">
2127 <frame src=\"".$path_info["basename"]."?action=9&shell_form=2\" name=frame2 border=\"0\" marginwidth=\"0\" marginheight=\"0\">
2128 </frameset>
2129 </html>";
2130 }
2131}
2132function server_info(){
2133 if (!@phpinfo()) echo et('NoPhpinfo')."...";
2134 echo "<br><br>";
2135 $a=ini_get_all();
2136 $output="<table border=1 cellspacing=0 cellpadding=4 align=center>";
2137 while(list($key, $value)=each($a)) {
2138 list($k, $v)= each($a[$key]);
2139 $output.="<tr><td align=right>$key</td><td>$v</td></tr>";
2140 }
2141 $output.="</table>";
2142 echo $output;
2143 echo "<br><br><table border=1 cellspacing=0 cellpadding=4 align=center>";
2144 $safe_mode=trim(ini_get("safe_mode"));
2145 if ((strlen($safe_mode)==0)||($safe_mode==0)) $safe_mode=false;
2146 else $safe_mode=true;
2147 $is_windows_server = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
2148 echo "<tr><td colspan=2>".php_uname();
2149 echo "<tr><td>safe_mode<td>".($safe_mode?"on":"off");
2150 if ($is_windows_server) echo "<tr><td>sisop<td>Windows<br>";
2151 else echo "<tr><td>sisop<td>Linux<br>";
2152 echo "</table><br><br><table border=1 cellspacing=0 cellpadding=4 align=center>";
2153 $display_errors=ini_get("display_errors");
2154 $ignore_user_abort = ignore_user_abort();
2155 $max_execution_time = ini_get("max_execution_time");
2156 $upload_max_filesize = ini_get("upload_max_filesize");
2157 $memory_limit=ini_get("memory_limit");
2158 $output_buffering=ini_get("output_buffering");
2159 $default_socket_timeout=ini_get("default_socket_timeout");
2160 $allow_url_fopen = ini_get("allow_url_fopen");
2161 $magic_quotes_gpc = ini_get("magic_quotes_gpc");
2162 ignore_user_abort(true);
2163 ini_set("display_errors",0);
2164 ini_set("max_execution_time",0);
2165 ini_set("upload_max_filesize","10M");
2166 ini_set("memory_limit","20M");
2167 ini_set("output_buffering",0);
2168 ini_set("default_socket_timeout",30);
2169 ini_set("allow_url_fopen",1);
2170 ini_set("magic_quotes_gpc",0);
2171 echo "<tr><td>Â <td>Get<td>Set<td>Get";
2172 echo "<tr><td>display_errors<td>$display_errors<td>0<td>".ini_get("display_errors");
2173 echo "<tr><td>ignore_user_abort<td>".($ignore_user_abort?"on":"off")."<td>on<td>".(ignore_user_abort()?"on":"off");
2174 echo "<tr><td>max_execution_time<td>$max_execution_time<td>0<td>".ini_get("max_execution_time");
2175 echo "<tr><td>upload_max_filesize<td>$upload_max_filesize<td>10M<td>".ini_get("upload_max_filesize");
2176 echo "<tr><td>memory_limit<td>$memory_limit<td>20M<td>".ini_get("memory_limit");
2177 echo "<tr><td>output_buffering<td>$output_buffering<td>0<td>".ini_get("output_buffering");
2178 echo "<tr><td>default_socket_timeout<td>$default_socket_timeout<td>30<td>".ini_get("default_socket_timeout");
2179 echo "<tr><td>allow_url_fopen<td>$allow_url_fopen<td>1<td>".ini_get("allow_url_fopen");
2180 echo "<tr><td>magic_quotes_gpc<td>$magic_quotes_gpc<td>0<td>".ini_get("magic_quotes_gpc");
2181 echo "</table><br><br>";
2182 echo "
2183 <script language=\"Javascript\" type=\"text/javascript\">
2184 <!--
2185 window.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);
2186 window.focus();
2187 //-->
2188 </script>";
2189 echo "</body>\n</html>";
2190}
2191// +--------------------------------------------------
2192// | Session
2193// +--------------------------------------------------
2194function logout(){
2195 setcookie("loggedon",0,0,"/");
2196 form_login();
2197}
2198function login(){
2199 global $senha,$auth_pass,$path_info;
2200 if (md5(trim($senha)) == $auth_pass){
2201 setcookie("loggedon",$auth_pass,0,"/");
2202 header ("Location: ".$path_info["basename"]."");
2203 } else header ("Location: ".$path_info["basename"]."?erro=1");
2204}
2205function form_login(){
2206 global $erro,$auth_pass,$path_info;
2207 html_header();
2208 echo "<body onLoad=\"if(parent.location.href != self.location.href){ parent.location.href = self.location.href } return true;\">\n";
2209 if ($auth_pass != md5("")){
2210 echo "
2211 <table border=0 cellspacing=0 cellpadding=5>
2212 <form name=\"login_form\" action=\"".$path_info["basename"]."\" method=\"post\">
2213 <tr>
2214 <td><b>".et('FileMan')."</b>
2215 </tr>
2216 <tr>
2217 <td align=left><font size=4>".et('TypePass').".</font>
2218 </tr>
2219 <tr>
2220 <td><input name=senha type=password size=10> <input type=submit value=\"".et('Send')."\">
2221 </tr>
2222 ";
2223 if (strlen($erro)) echo "
2224 <tr>
2225 <td align=left><font color=red size=4>".et('InvPass').".</font>
2226 </tr>
2227 ";
2228 echo "
2229 </form>
2230 </table>
2231 <script language=\"Javascript\" type=\"text/javascript\">
2232 <!--
2233 document.login_form.senha.focus();
2234 //-->
2235 </script>
2236 ";
2237 } else {
2238 echo "
2239 <table border=0 cellspacing=0 cellpadding=5>
2240 <form name=\"login_form\" action=\"".$path_info["basename"]."\" method=\"post\">
2241 <input type=hidden name=frame value=3>
2242 <input type=hidden name=senha value=\"\">
2243 <tr>
2244 <td><b>".et('FileMan')."</b>
2245 </tr>
2246 <tr>
2247 <td><input type=submit value=\"".et('Enter')."\">
2248 </tr>
2249 </form>
2250 </table>
2251 ";
2252 }
2253 echo "</body>\n</html>";
2254}
2255function frame3(){
2256 global $islinux,$cmd_arg,$chmod_arg,$zip_dir,$fm_root_atual;
2257 global $dir_dest,$dir_atual,$dir_antes;
2258 global $selected_file_list,$selected_dir_list,$old_name,$new_name;
2259 global $action,$or_by,$order_dir_list_by;
2260 if (!isset($order_dir_list_by)){
2261 $order_dir_list_by = "1A";
2262 setcookie("order_dir_list_by", $order_dir_list_by , $cookie_cache_time , "/");
2263 } elseif (strlen($or_by)){
2264 $order_dir_list_by = $or_by;
2265 setcookie("order_dir_list_by", $or_by , $cookie_cache_time , "/");
2266 }
2267 html_header();
2268 echo "<body>\n";
2269 if ($action){
2270 switch ($action){
2271 case 1: // create dir
2272 if (strlen($cmd_arg)){
2273 $cmd_arg = formatpath($dir_atual.$cmd_arg);
2274 if (!file_exists($cmd_arg)){
2275 mkdir($cmd_arg,0777);
2276 chmod($cmd_arg,0777);
2277 reloadframe("parent",2,"&ec_dir=".$cmd_arg);
2278 } else alert(et('FileDirExists').".");
2279 }
2280 break;
2281 case 2: // create arq
2282 if (strlen($cmd_arg)){
2283 $cmd_arg = $dir_atual.$cmd_arg;
2284 if (!file_exists($cmd_arg)){
2285 if ($fh = @fopen($cmd_arg, "w")){
2286 @fclose($fh);
2287 }
2288 chmod($cmd_arg,0666);
2289 } else alert(et('FileDirExists').".");
2290 }
2291 break;
2292 case 3: // rename arq ou dir
2293 if ((strlen($old_name))&&(strlen($new_name))){
2294 rename($dir_atual.$old_name,$dir_atual.$new_name);
2295 if (is_dir($dir_atual.$new_name)) reloadframe("parent",2);
2296 }
2297 break;
2298 case 4: // delete sel
2299 if(strstr($dir_atual,$fm_root_atual)){
2300 if (strlen($selected_file_list)){
2301 $selected_file_list = explode("<|*|>",$selected_file_list);
2302 if (count($selected_file_list)) {
2303 for($x=0;$x<count($selected_file_list);$x++) {
2304 $selected_file_list[$x] = trim($selected_file_list[$x]);
2305 if (strlen($selected_file_list[$x])) total_delete($dir_atual.$selected_file_list[$x],$dir_dest.$selected_file_list[$x]);
2306 }
2307 }
2308 }
2309 if (strlen($selected_dir_list)){
2310 $selected_dir_list = explode("<|*|>",$selected_dir_list);
2311 if (count($selected_dir_list)) {
2312 for($x=0;$x<count($selected_dir_list);$x++) {
2313 $selected_dir_list[$x] = trim($selected_dir_list[$x]);
2314 if (strlen($selected_dir_list[$x])) total_delete($dir_atual.$selected_dir_list[$x],$dir_dest.$selected_dir_list[$x]);
2315 }
2316 reloadframe("parent",2);
2317 }
2318 }
2319 }
2320 break;
2321 case 5: // copy sel
2322 if (strlen($dir_dest)){
2323 if(strtoupper($dir_dest) != strtoupper($dir_atual)){
2324 if (strlen($selected_file_list)){
2325 $selected_file_list = explode("<|*|>",$selected_file_list);
2326 if (count($selected_file_list)) {
2327 for($x=0;$x<count($selected_file_list);$x++) {
2328 $selected_file_list[$x] = trim($selected_file_list[$x]);
2329 if (strlen($selected_file_list[$x])) total_copy($dir_atual.$selected_file_list[$x],$dir_dest.$selected_file_list[$x]);
2330 }
2331 }
2332 }
2333 if (strlen($selected_dir_list)){
2334 $selected_dir_list = explode("<|*|>",$selected_dir_list);
2335 if (count($selected_dir_list)) {
2336 for($x=0;$x<count($selected_dir_list);$x++) {
2337 $selected_dir_list[$x] = trim($selected_dir_list[$x]);
2338 if (strlen($selected_dir_list[$x])) total_copy($dir_atual.$selected_dir_list[$x],$dir_dest.$selected_dir_list[$x]);
2339 }
2340 reloadframe("parent",2);
2341 }
2342 }
2343 $dir_atual = $dir_dest;
2344 }
2345 }
2346 break;
2347 case 6: // move sel
2348 if (strlen($dir_dest)){
2349 if(strtoupper($dir_dest) != strtoupper($dir_atual)){
2350 if (strlen($selected_file_list)){
2351 $selected_file_list = explode("<|*|>",$selected_file_list);
2352 if (count($selected_file_list)) {
2353 for($x=0;$x<count($selected_file_list);$x++) {
2354 $selected_file_list[$x] = trim($selected_file_list[$x]);
2355 if (strlen($selected_file_list[$x])) total_move($dir_atual.$selected_file_list[$x],$dir_dest.$selected_file_list[$x]);
2356 }
2357 }
2358 }
2359 if (strlen($selected_dir_list)){
2360 $selected_dir_list = explode("<|*|>",$selected_dir_list);
2361 if (count($selected_dir_list)) {
2362 for($x=0;$x<count($selected_dir_list);$x++) {
2363 $selected_dir_list[$x] = trim($selected_dir_list[$x]);
2364 if (strlen($selected_dir_list[$x])) total_move($dir_atual.$selected_dir_list[$x],$dir_dest.$selected_dir_list[$x]);
2365 }
2366 reloadframe("parent",2);
2367 }
2368 }
2369 $dir_atual = $dir_dest;
2370 }
2371 }
2372 break;
2373 case 71: // compress sel
2374 if (strlen($cmd_arg)){
2375 ignore_user_abort(true);
2376 ini_set("display_errors",0);
2377 ini_set("max_execution_time",0);
2378 $zipfile=false;
2379 if (strstr($cmd_arg,".tar")) $zipfile = new tar_file($cmd_arg);
2380 elseif (strstr($cmd_arg,".zip")) $zipfile = new zip_file($cmd_arg);
2381 elseif (strstr($cmd_arg,".bzip")) $zipfile = new bzip_file($cmd_arg);
2382 elseif (strstr($cmd_arg,".gzip")) $zipfile = new gzip_file($cmd_arg);
2383 if ($zipfile){
2384 $zipfile->set_options(array('basedir'=>$dir_atual,'overwrite'=>1,'level'=>3));
2385 if (strlen($selected_file_list)){
2386 $selected_file_list = explode("<|*|>",$selected_file_list);
2387 if (count($selected_file_list)) {
2388 for($x=0;$x<count($selected_file_list);$x++) {
2389 $selected_file_list[$x] = trim($selected_file_list[$x]);
2390 if (strlen($selected_file_list[$x])) $zipfile->add_files($selected_file_list[$x]);
2391 }
2392 }
2393 }
2394 if (strlen($selected_dir_list)){
2395 $selected_dir_list = explode("<|*|>",$selected_dir_list);
2396 if (count($selected_dir_list)) {
2397 for($x=0;$x<count($selected_dir_list);$x++) {
2398 $selected_dir_list[$x] = trim($selected_dir_list[$x]);
2399 if (strlen($selected_dir_list[$x])) $zipfile->add_files($selected_dir_list[$x]);
2400 }
2401 }
2402 }
2403 $zipfile->create_archive();
2404 }
2405 unset($zipfile);
2406 }
2407 break;
2408 case 72: // decompress arq
2409 if (strlen($cmd_arg)){
2410 if (file_exists($dir_atual.$cmd_arg)){
2411 $zipfile=false;
2412 if (strstr($cmd_arg,".zip")) zip_extract();
2413 elseif (strstr($cmd_arg,".bzip")||strstr($cmd_arg,".bz2")||strstr($cmd_arg,".tbz2")||strstr($cmd_arg,".bz")||strstr($cmd_arg,".tbz")) $zipfile = new bzip_file($cmd_arg);
2414 elseif (strstr($cmd_arg,".gzip")||strstr($cmd_arg,".gz")||strstr($cmd_arg,".tgz")) $zipfile = new gzip_file($cmd_arg);
2415 elseif (strstr($cmd_arg,".tar")) $zipfile = new tar_file($cmd_arg);
2416 if ($zipfile){
2417 $zipfile->set_options(array('basedir'=>$dir_atual,'overwrite'=>1));
2418 $zipfile->extract_files();
2419 }
2420 unset($zipfile);
2421 reloadframe("parent",2);
2422 }
2423 }
2424 break;
2425 case 8: // delete arq/dir
2426 if (strlen($cmd_arg)){
2427 if (file_exists($dir_atual.$cmd_arg)) total_delete($dir_atual.$cmd_arg);
2428 if (is_dir($dir_atual.$cmd_arg)) reloadframe("parent",2);
2429 }
2430 break;
2431 case 9: // CHMOD
2432 if((strlen($chmod_arg) == 4)&&(strlen($dir_atual))){
2433 if ($chmod_arg[0]=="1") $chmod_arg = "0".$chmod_arg;
2434 else $chmod_arg = "0".substr($chmod_arg,strlen($chmod_arg)-3);
2435 $new_mod = octdec($chmod_arg);
2436 $selected_file_list = explode("<|*|>",$selected_file_list);
2437 if (count($selected_file_list)) for($x=0;$x<count($selected_file_list);$x++) @chmod($dir_atual.$selected_file_list[$x],$new_mod);
2438 $selected_dir_list = explode("<|*|>",$selected_dir_list);
2439 if (count($selected_dir_list)) for($x=0;$x<count($selected_dir_list);$x++) @chmod($dir_atual.$selected_dir_list[$x],$new_mod);
2440 }
2441 break;
2442 }
2443 if ($action != 10) dir_list_form();
2444 } else dir_list_form();
2445 echo "</body>\n</html>";
2446}
2447function frame2(){
2448 global $expanded_dir_list,$ec_dir;
2449 if (!isset($expanded_dir_list)) $expanded_dir_list = "";
2450 if (strlen($ec_dir)){
2451 if (strstr($expanded_dir_list,":".$ec_dir)) $expanded_dir_list = str_replace(":".$ec_dir,"",$expanded_dir_list);
2452 else $expanded_dir_list .= ":".$ec_dir;
2453 setcookie("expanded_dir_list", $expanded_dir_list , 0 , "/");
2454 }
2455 show_tree();
2456}
2457function frameset(){
2458 global $path_info;
2459 html_header();
2460 echo "
2461 <frameset cols=\"300,*\" framespacing=\"0\">
2462 <frameset rows=\"0,*\" framespacing=\"0\" frameborder=no>
2463 <frame src=\"".$path_info["basename"]."?frame=1\" name=frame1 border=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=no>
2464 <frame src=\"".$path_info["basename"]."?frame=2\" name=frame2 border=\"0\" marginwidth=\"0\" marginheight=\"0\">
2465 </frameset>
2466 <frame src=\"".$path_info["basename"]."?frame=3\" name=frame3 border=\"0\" marginwidth=\"0\" marginheight=\"0\">
2467 </frameset>
2468 ";
2469 echo "</html>";
2470}
2471// +--------------------------------------------------
2472// | Open Source Contributions
2473// +--------------------------------------------------
2474 /*-------------------------------------------------
2475 | TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.0
2476 | By Devin Doucette
2477 | Copyright (c) 2004 Devin Doucette
2478 | Email: darksnoopy@shaw.ca
2479 +--------------------------------------------------
2480 | Email bugs/suggestions to darksnoopy@shaw.ca
2481 +--------------------------------------------------
2482 | This script has been created and released under
2483 | the GNU GPL and is free to use and redistribute
2484 | only if this copyright statement is not removed
2485 +--------------------------------------------------
2486 | Limitations:
2487 | - Only USTAR archives are officially supported for extraction, but others may work.
2488 | - Extraction of bzip2 and gzip archives is limited to compatible tar files that have
2489 | been compressed by either bzip2 or gzip. For greater support, use the functions
2490 | bzopen and gzopen respectively for bzip2 and gzip extraction.
2491 | - Zip extraction is not supported due to the wide variety of algorithms that may be
2492 | used for compression and newer features such as encryption.
2493 +--------------------------------------------------
2494 */
2495class archive
2496{
2497 function archive($name)
2498 {
2499 $this->options = array(
2500 'basedir'=>".",
2501 'name'=>$name,
2502 'prepend'=>"",
2503 'inmemory'=>0,
2504 'overwrite'=>0,
2505 'recurse'=>1,
2506 'storepaths'=>1,
2507 'level'=>3,
2508 'method'=>1,
2509 'sfx'=>"",
2510 'type'=>"",
2511 'comment'=>""
2512 );
2513 $this->files = array();
2514 $this->exclude = array();
2515 $this->storeonly = array();
2516 $this->error = array();
2517 }
2518
2519 function set_options($options)
2520 {
2521 foreach($options as $key => $value)
2522 {
2523 $this->options[$key] = $value;
2524 }
2525 if(!empty($this->options['basedir']))
2526 {
2527 $this->options['basedir'] = str_replace("\\","/",$this->options['basedir']);
2528 $this->options['basedir'] = preg_replace("/\/+/","/",$this->options['basedir']);
2529 $this->options['basedir'] = preg_replace("/\/$/","",$this->options['basedir']);
2530 }
2531 if(!empty($this->options['name']))
2532 {
2533 $this->options['name'] = str_replace("\\","/",$this->options['name']);
2534 $this->options['name'] = preg_replace("/\/+/","/",$this->options['name']);
2535 }
2536 if(!empty($this->options['prepend']))
2537 {
2538 $this->options['prepend'] = str_replace("\\","/",$this->options['prepend']);
2539 $this->options['prepend'] = preg_replace("/^(\.*\/+)+/","",$this->options['prepend']);
2540 $this->options['prepend'] = preg_replace("/\/+/","/",$this->options['prepend']);
2541 $this->options['prepend'] = preg_replace("/\/$/","",$this->options['prepend']) . "/";
2542 }
2543 }
2544
2545 function create_archive()
2546 {
2547 $this->make_list();
2548
2549 if($this->options['inmemory'] == 0)
2550 {
2551 $pwd = getcwd();
2552 chdir($this->options['basedir']);
2553 if($this->options['overwrite'] == 0 && file_exists($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip"? ".tmp" : "")))
2554 {
2555 $this->error[] = "File {$this->options['name']} already exists.";
2556 chdir($pwd);
2557 return 0;
2558 }
2559 else if($this->archive = @fopen($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip"? ".tmp" : ""),"wb+"))
2560 {
2561 chdir($pwd);
2562 }
2563 else
2564 {
2565 $this->error[] = "Could not open {$this->options['name']} for writing.";
2566 chdir($pwd);
2567 return 0;
2568 }
2569 }
2570 else
2571 {
2572 $this->archive = "";
2573 }
2574
2575 switch($this->options['type'])
2576 {
2577 case "zip":
2578 if(!$this->create_zip())
2579 {
2580 $this->error[] = "Could not create zip file.";
2581 return 0;
2582 }
2583 break;
2584 case "bzip":
2585 if(!$this->create_tar())
2586 {
2587 $this->error[] = "Could not create tar file.";
2588 return 0;
2589 }
2590 if(!$this->create_bzip())
2591 {
2592 $this->error[] = "Could not create bzip2 file.";
2593 return 0;
2594 }
2595 break;
2596 case "gzip":
2597 if(!$this->create_tar())
2598 {
2599 $this->error[] = "Could not create tar file.";
2600 return 0;
2601 }
2602 if(!$this->create_gzip())
2603 {
2604 $this->error[] = "Could not create gzip file.";
2605 return 0;
2606 }
2607 break;
2608 case "tar":
2609 if(!$this->create_tar())
2610 {
2611 $this->error[] = "Could not create tar file.";
2612 return 0;
2613 }
2614 }
2615
2616 if($this->options['inmemory'] == 0)
2617 {
2618 fclose($this->archive);
2619 chmod($this->options['name'],0666);
2620 if($this->options['type'] == "gzip" || $this->options['type'] == "bzip")
2621 {
2622 unlink($this->options['basedir'] . "/" . $this->options['name'] . ".tmp");
2623 }
2624 }
2625 }
2626
2627 function add_data($data)
2628 {
2629 if($this->options['inmemory'] == 0)
2630 {
2631 fwrite($this->archive,$data);
2632 }
2633 else
2634 {
2635 $this->archive .= $data;
2636 }
2637 }
2638
2639 function make_list()
2640 {
2641 if(!empty($this->exclude))
2642 {
2643 foreach($this->files as $key => $value)
2644 {
2645 foreach($this->exclude as $current)
2646 {
2647 if($value['name'] == $current['name'])
2648 {
2649 unset($this->files[$key]);
2650 }
2651 }
2652 }
2653 }
2654 if(!empty($this->storeonly))
2655 {
2656 foreach($this->files as $key => $value)
2657 {
2658 foreach($this->storeonly as $current)
2659 {
2660 if($value['name'] == $current['name'])
2661 {
2662 $this->files[$key]['method'] = 0;
2663 }
2664 }
2665 }
2666 }
2667 unset($this->exclude,$this->storeonly);
2668 }
2669
2670
2671 function add_files($list)
2672 {
2673 $temp = $this->list_files($list);
2674 foreach($temp as $current)
2675 {
2676 $this->files[] = $current;
2677 }
2678 }
2679
2680 function exclude_files($list)
2681 {
2682 $temp = $this->list_files($list);
2683 foreach($temp as $current)
2684 {
2685 $this->exclude[] = $current;
2686 }
2687 }
2688
2689 function store_files($list)
2690 {
2691 $temp = $this->list_files($list);
2692 foreach($temp as $current)
2693 {
2694 $this->storeonly[] = $current;
2695 }
2696 }
2697
2698 function list_files($list)
2699 {
2700 if(!is_array($list))
2701 {
2702 $temp = $list;
2703 $list = array($temp);
2704 unset($temp);
2705 }
2706
2707 $files = array();
2708
2709 $pwd = getcwd();
2710 chdir($this->options['basedir']);
2711
2712 foreach($list as $current)
2713 {
2714 $current = str_replace("\\","/",$current);
2715 $current = preg_replace("/\/+/","/",$current);
2716 $current = preg_replace("/\/$/","",$current);
2717 if(strstr($current,"*"))
2718 {
2719 $regex = preg_replace("/([\\\^\$\.\[\]\|\(\)\?\+\{\}\/])/","\\\\\\1",$current);
2720 $regex = str_replace("*",".*",$regex);
2721 $dir = strstr($current,"/")? substr($current,0,strrpos($current,"/")) : ".";
2722 $temp = $this->parse_dir($dir);
2723 foreach($temp as $current2)
2724 {
2725 if(preg_match("/^{$regex}$/i",$current2['name']))
2726 {
2727 $files[] = $current2;
2728 }
2729 }
2730 unset($regex,$dir,$temp,$current);
2731 }
2732 else if(@is_dir($current))
2733 {
2734 $temp = $this->parse_dir($current);
2735 foreach($temp as $file)
2736 {
2737 $files[] = $file;
2738 }
2739 unset($temp,$file);
2740 }
2741 else if(@file_exists($current))
2742 {
2743 $files[] = array('name'=>$current,'name2'=>$this->options['prepend'] .
2744 preg_replace("/(\.+\/+)+/","",($this->options['storepaths'] == 0 && strstr($current,"/"))?
2745 substr($current,strrpos($current,"/") + 1) : $current),'type'=>0,
2746 'ext'=>substr($current,strrpos($current,".")),'stat'=>stat($current));
2747 }
2748 }
2749
2750 chdir($pwd);
2751
2752 unset($current,$pwd);
2753
2754 usort($files,array("archive","sort_files"));
2755
2756 return $files;
2757 }
2758
2759 function parse_dir($dirname)
2760 {
2761 if($this->options['storepaths'] == 1 && !preg_match("/^(\.+\/*)+$/",$dirname))
2762 {
2763 $files = array(array('name'=>$dirname,'name2'=>$this->options['prepend'] .
2764 preg_replace("/(\.+\/+)+/","",($this->options['storepaths'] == 0 && strstr($dirname,"/"))?
2765 substr($dirname,strrpos($dirname,"/") + 1) : $dirname),'type'=>5,'stat'=>stat($dirname)));
2766 }
2767 else
2768 {
2769 $files = array();
2770 }
2771 $dir = @opendir($dirname);
2772
2773 while($file = @readdir($dir))
2774 {
2775 if($file == "." || $file == "..")
2776 {
2777 continue;
2778 }
2779 else if(@is_dir($dirname."/".$file))
2780 {
2781 if(empty($this->options['recurse']))
2782 {
2783 continue;
2784 }
2785 $temp = $this->parse_dir($dirname."/".$file);
2786 foreach($temp as $file2)
2787 {
2788 $files[] = $file2;
2789 }
2790 }
2791 else if(@file_exists($dirname."/".$file))
2792 {
2793 $files[] = array('name'=>$dirname."/".$file,'name2'=>$this->options['prepend'] .
2794 preg_replace("/(\.+\/+)+/","",($this->options['storepaths'] == 0 && strstr($dirname."/".$file,"/"))?
2795 substr($dirname."/".$file,strrpos($dirname."/".$file,"/") + 1) : $dirname."/".$file),'type'=>0,
2796 'ext'=>substr($file,strrpos($file,".")),'stat'=>stat($dirname."/".$file));
2797 }
2798 }
2799
2800 @closedir($dir);
2801
2802 return $files;
2803 }
2804
2805 function sort_files($a,$b)
2806 {
2807 if($a['type'] != $b['type'])
2808 {
2809 return $a['type'] > $b['type']? -1 : 1;
2810 }
2811 else if($a['type'] == 5)
2812 {
2813 return strcmp(strtolower($a['name']),strtolower($b['name']));
2814 }
2815 else
2816 {
2817 if($a['ext'] != $b['ext'])
2818 {
2819 return strcmp($a['ext'],$b['ext']);
2820 }
2821 else if($a['stat'][7] != $b['stat'][7])
2822 {
2823 return $a['stat'][7] > $b['stat'][7]? -1 : 1;
2824 }
2825 else
2826 {
2827 return strcmp(strtolower($a['name']),strtolower($b['name']));
2828 }
2829 }
2830 return 0;
2831 }
2832
2833 function download_file()
2834 {
2835 if($this->options['inmemory'] == 0)
2836 {
2837 $this->error[] = "Can only use download_file() if archive is in memory. Redirect to file otherwise, it is faster.";
2838 return;
2839 }
2840 switch($this->options['type'])
2841 {
2842 case "zip":
2843 header("Content-type:application/zip");
2844 break;
2845 case "bzip":
2846 header("Content-type:application/x-compressed");
2847 break;
2848 case "gzip":
2849 header("Content-type:application/x-compressed");
2850 break;
2851 case "tar":
2852 header("Content-type:application/x-tar");
2853 }
2854 $header = "Content-disposition: attachment; filename=\"";
2855 $header .= strstr($this->options['name'],"/")? substr($this->options['name'],strrpos($this->options['name'],"/") + 1) : $this->options['name'];
2856 $header .= "\"";
2857 header($header);
2858 header("Content-length: " . strlen($this->archive));
2859 header("Content-transfer-encoding: binary");
2860 header("Cache-control: no-cache, must-revalidate, post-check=0, pre-check=0");
2861 header("Pragma: no-cache");
2862 header("Expires: 0");
2863 print($this->archive);
2864 }
2865}
2866
2867class tar_file extends archive
2868{
2869 function tar_file($name)
2870 {
2871 $this->archive($name);
2872 $this->options['type'] = "tar";
2873 }
2874
2875 function create_tar()
2876 {
2877 $pwd = getcwd();
2878 chdir($this->options['basedir']);
2879
2880 foreach($this->files as $current)
2881 {
2882 if($current['name'] == $this->options['name'])
2883 {
2884 continue;
2885 }
2886 if(strlen($current['name2']) > 99)
2887 {
2888 $path = substr($current['name2'],0,strpos($current['name2'],"/",strlen($current['name2']) - 100) + 1);
2889 $current['name2'] = substr($current['name2'],strlen($path));
2890 if(strlen($path) > 154 || strlen($current['name2']) > 99)
2891 {
2892 $this->error[] = "Could not add {$path}{$current['name2']} to archive because the filename is too long.";
2893 continue;
2894 }
2895 }
2896 $block = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",$current['name2'],decoct($current['stat'][2]),
2897 sprintf("%6s ",decoct($current['stat'][4])),sprintf("%6s ",decoct($current['stat'][5])),
2898 sprintf("%11s ",decoct($current['stat'][7])),sprintf("%11s ",decoct($current['stat'][9])),
2899 " ",$current['type'],"","ustar","00","Unknown","Unknown","","",!empty($path)? $path : "","");
2900
2901 $checksum = 0;
2902 for($i = 0; $i < 512; $i++)
2903 {
2904 $checksum += ord(substr($block,$i,1));
2905 }
2906 $checksum = pack("a8",sprintf("%6s ",decoct($checksum)));
2907 $block = substr_replace($block,$checksum,148,8);
2908
2909 if($current['stat'][7] == 0)
2910 {
2911 $this->add_data($block);
2912 }
2913 else if($fp = @fopen($current['name'],"rb"))
2914 {
2915 $this->add_data($block);
2916 while($temp = fread($fp,1048576))
2917 {
2918 $this->add_data($temp);
2919 }
2920 if($current['stat'][7] % 512 > 0)
2921 {
2922 $temp = "";
2923 for($i = 0; $i < 512 - $current['stat'][7] % 512; $i++)
2924 {
2925 $temp .= "\0";
2926 }
2927 $this->add_data($temp);
2928 }
2929 fclose($fp);
2930 }
2931 else
2932 {
2933 $this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
2934 }
2935 }
2936
2937 $this->add_data(pack("a512",""));
2938
2939 chdir($pwd);
2940
2941 return 1;
2942
2943 }
2944
2945 function extract_files()
2946 {
2947 $pwd = getcwd();
2948 chdir($this->options['basedir']);
2949
2950 if($fp = $this->open_archive())
2951 {
2952 if($this->options['inmemory'] == 1)
2953 {
2954 $this->files = array();
2955 }
2956
2957 while($block = fread($fp,512))
2958 {
2959 $temp = unpack("a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100temp/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp",$block);
2960 $file = array(
2961 'name'=>$temp['prefix'] . $temp['name'],
2962 'stat'=>array(
2963 2=>$temp['mode'],
2964 4=>octdec($temp['uid']),
2965 5=>octdec($temp['gid']),
2966 7=>octdec($temp['size']),
2967 9=>octdec($temp['mtime']),
2968 ),
2969 'checksum'=>octdec($temp['checksum']),
2970 'type'=>$temp['type'],
2971 'magic'=>$temp['magic'],
2972 );
2973 if($file['checksum'] == 0x00000000)
2974 {
2975 break;
2976 }
2977 else if($file['magic'] != "ustar")
2978 {
2979 $this->error[] = "This script does not support extracting this type of tar file.";
2980 break;
2981 }
2982 $block = substr_replace($block," ",148,8);
2983 $checksum = 0;
2984 for($i = 0; $i < 512; $i++)
2985 {
2986 $checksum += ord(substr($block,$i,1));
2987 }
2988 if($file['checksum'] != $checksum)
2989 {
2990 $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
2991 }
2992
2993 if($this->options['inmemory'] == 1)
2994 {
2995 $file['data'] = fread($fp,$file['stat'][7]);
2996 fread($fp,(512 - $file['stat'][7] % 512) == 512? 0 : (512 - $file['stat'][7] % 512));
2997 unset($file['checksum'],$file['magic']);
2998 $this->files[] = $file;
2999 }
3000 else
3001 {
3002 if($file['type'] == 5)
3003 {
3004 if(!is_dir($file['name']))
3005 {
3006 mkdir($file['name'],0777);
3007 //mkdir($file['name'],$file['stat'][2]);
3008 //chown($file['name'],$file['stat'][4]);
3009 //chgrp($file['name'],$file['stat'][5]);
3010 }
3011 }
3012 else if($this->options['overwrite'] == 0 && file_exists($file['name']))
3013 {
3014 $this->error[] = "{$file['name']} already exists.";
3015 }
3016 else if($new = @fopen($file['name'],"wb"))
3017 {
3018 fwrite($new,fread($fp,$file['stat'][7]));
3019 fread($fp,(512 - $file['stat'][7] % 512) == 512? 0 : (512 - $file['stat'][7] % 512));
3020 fclose($new);
3021 chmod($file['name'],0666);
3022 //chmod($file['name'],$file['stat'][2]);
3023 //chown($file['name'],$file['stat'][4]);
3024 //chgrp($file['name'],$file['stat'][5]);
3025 }
3026 else
3027 {
3028 $this->error[] = "Could not open {$file['name']} for writing.";
3029 }
3030 }
3031 unset($file);
3032 }
3033 }
3034 else
3035 {
3036 $this->error[] = "Could not open file {$this->options['name']}";
3037 }
3038
3039 chdir($pwd);
3040 }
3041
3042 function open_archive()
3043 {
3044 return @fopen($this->options['name'],"rb");
3045 }
3046}
3047
3048class gzip_file extends tar_file
3049{
3050 function gzip_file($name)
3051 {
3052 $this->tar_file($name);
3053 $this->options['type'] = "gzip";
3054 }
3055
3056 function create_gzip()
3057 {
3058 if($this->options['inmemory'] == 0)
3059 {
3060 $pwd = getcwd();
3061 chdir($this->options['basedir']);
3062 if($fp = gzopen($this->options['name'],"wb{$this->options['level']}"))
3063 {
3064 fseek($this->archive,0);
3065 while($temp = fread($this->archive,1048576))
3066 {
3067 gzwrite($fp,$temp);
3068 }
3069 gzclose($fp);
3070 chdir($pwd);
3071 }
3072 else
3073 {
3074 $this->error[] = "Could not open {$this->options['name']} for writing.";
3075 chdir($pwd);
3076 return 0;
3077 }
3078 }
3079 else
3080 {
3081 $this->archive = gzencode($this->archive,$this->options['level']);
3082 }
3083
3084 return 1;
3085 }
3086
3087 function open_archive()
3088 {
3089 return @gzopen($this->options['name'],"rb");
3090 }
3091}
3092
3093class bzip_file extends tar_file
3094{
3095 function bzip_file($name)
3096 {
3097 $this->tar_file($name);
3098 $this->options['type'] = "bzip";
3099 }
3100
3101 function create_bzip()
3102 {
3103 if($this->options['inmemory'] == 0)
3104 {
3105 $pwd = getcwd();
3106 chdir($this->options['basedir']);
3107 if($fp = bzopen($this->options['name'],"wb"))
3108 {
3109 fseek($this->archive,0);
3110 while($temp = fread($this->archive,1048576))
3111 {
3112 bzwrite($fp,$temp);
3113 }
3114 bzclose($fp);
3115 chdir($pwd);
3116 }
3117 else
3118 {
3119 $this->error[] = "Could not open {$this->options['name']} for writing.";
3120 chdir($pwd);
3121 return 0;
3122 }
3123 }
3124 else
3125 {
3126 $this->archive = bzcompress($this->archive,$this->options['level']);
3127 }
3128
3129 return 1;
3130 }
3131
3132 function open_archive()
3133 {
3134 return @bzopen($this->options['name'],"rb");
3135 }
3136}
3137
3138class zip_file extends archive
3139{
3140 function zip_file($name)
3141 {
3142 $this->archive($name);
3143 $this->options['type'] = "zip";
3144 }
3145
3146 function create_zip()
3147 {
3148 $files = 0;
3149 $offset = 0;
3150 $central = "";
3151
3152 if(!empty($this->options['sfx']))
3153 {
3154 if($fp = @fopen($this->options['sfx'],"rb"))
3155 {
3156 $temp = fread($fp,filesize($this->options['sfx']));
3157 fclose($fp);
3158 $this->add_data($temp);
3159 $offset += strlen($temp);
3160 unset($temp);
3161 }
3162 else
3163 {
3164 $this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
3165 }
3166 }
3167
3168 $pwd = getcwd();
3169 chdir($this->options['basedir']);
3170
3171 foreach($this->files as $current)
3172 {
3173 if($current['name'] == $this->options['name'])
3174 {
3175 continue;
3176 }
3177 $translate = array('Ç'=>pack("C",128),'ü'=>pack("C",129),'é'=>pack("C",130),'â'=>pack("C",131),'ä'=>pack("C",132),
3178 'à '=>pack("C",133),'å'=>pack("C",134),'ç'=>pack("C",135),'ê'=>pack("C",136),'ë'=>pack("C",137),
3179 'è'=>pack("C",138),'ï'=>pack("C",139),'î'=>pack("C",140),'ì'=>pack("C",141),'Ä'=>pack("C",142),
3180 'Å'=>pack("C",143),'É'=>pack("C",144),'æ'=>pack("C",145),'Æ'=>pack("C",146),'ô'=>pack("C",147),
3181 'ö'=>pack("C",148),'ò'=>pack("C",149),'û'=>pack("C",150),'ù'=>pack("C",151),'_'=>pack("C",152),
3182 'Ö'=>pack("C",153),'Ü'=>pack("C",154),'£'=>pack("C",156),'¥'=>pack("C",157),'_'=>pack("C",158),
3183 'ƒ'=>pack("C",159),'á'=>pack("C",160),'Ã'=>pack("C",161),'ó'=>pack("C",162),'ú'=>pack("C",163),
3184 'ñ'=>pack("C",164),'Ñ'=>pack("C",165));
3185 $current['name2'] = strtr($current['name2'],$translate);
3186
3187 $timedate = explode(" ",date("Y n j G i s",$current['stat'][9]));
3188 $timedate = ($timedate[0] - 1980 << 25) | ($timedate[1] << 21) | ($timedate[2] << 16) |
3189 ($timedate[3] << 11) | ($timedate[4] << 5) | ($timedate[5]);
3190
3191 $block = pack("VvvvV",0x04034b50,0x000A,0x0000,(isset($current['method']) || $this->options['method'] == 0)? 0x0000 : 0x0008,$timedate);
3192
3193 if($current['stat'][7] == 0 && $current['type'] == 5)
3194 {
3195 $block .= pack("VVVvv",0x00000000,0x00000000,0x00000000,strlen($current['name2']) + 1,0x0000);
3196 $block .= $current['name2'] . "/";
3197 $this->add_data($block);
3198 $central .= pack("VvvvvVVVVvvvvvVV",0x02014b50,0x0014,$this->options['method'] == 0? 0x0000 : 0x000A,0x0000,
3199 (isset($current['method']) || $this->options['method'] == 0)? 0x0000 : 0x0008,$timedate,
3200 0x00000000,0x00000000,0x00000000,strlen($current['name2']) + 1,0x0000,0x0000,0x0000,0x0000,$current['type'] == 5? 0x00000010 : 0x00000000,$offset);
3201 $central .= $current['name2'] . "/";
3202 $files++;
3203 $offset += (31 + strlen($current['name2']));
3204 }
3205 else if($current['stat'][7] == 0)
3206 {
3207 $block .= pack("VVVvv",0x00000000,0x00000000,0x00000000,strlen($current['name2']),0x0000);
3208 $block .= $current['name2'];
3209 $this->add_data($block);
3210 $central .= pack("VvvvvVVVVvvvvvVV",0x02014b50,0x0014,$this->options['method'] == 0? 0x0000 : 0x000A,0x0000,
3211 (isset($current['method']) || $this->options['method'] == 0)? 0x0000 : 0x0008,$timedate,
3212 0x00000000,0x00000000,0x00000000,strlen($current['name2']),0x0000,0x0000,0x0000,0x0000,$current['type'] == 5? 0x00000010 : 0x00000000,$offset);
3213 $central .= $current['name2'];
3214 $files++;
3215 $offset += (30 + strlen($current['name2']));
3216 }
3217 else if($fp = @fopen($current['name'],"rb"))
3218 {
3219 $temp = fread($fp,$current['stat'][7]);
3220 fclose($fp);
3221 $crc32 = crc32($temp);
3222 if(!isset($current['method']) && $this->options['method'] == 1)
3223 {
3224 $temp = gzcompress($temp,$this->options['level']);
3225 $size = strlen($temp) - 6;
3226 $temp = substr($temp,2,$size);
3227 }
3228 else
3229 {
3230 $size = strlen($temp);
3231 }
3232 $block .= pack("VVVvv",$crc32,$size,$current['stat'][7],strlen($current['name2']),0x0000);
3233 $block .= $current['name2'];
3234 $this->add_data($block);
3235 $this->add_data($temp);
3236 unset($temp);
3237 $central .= pack("VvvvvVVVVvvvvvVV",0x02014b50,0x0014,$this->options['method'] == 0? 0x0000 : 0x000A,0x0000,
3238 (isset($current['method']) || $this->options['method'] == 0)? 0x0000 : 0x0008,$timedate,
3239 $crc32,$size,$current['stat'][7],strlen($current['name2']),0x0000,0x0000,0x0000,0x0000,0x00000000,$offset);
3240 $central .= $current['name2'];
3241 $files++;
3242 $offset += (30 + strlen($current['name2']) + $size);
3243 }
3244 else
3245 {
3246 $this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
3247 }
3248 }
3249
3250 $this->add_data($central);
3251
3252 $this->add_data(pack("VvvvvVVv",0x06054b50,0x0000,0x0000,$files,$files,strlen($central),$offset,
3253 !empty($this->options['comment'])? strlen($this->options['comment']) : 0x0000));
3254
3255 if(!empty($this->options['comment']))
3256 {
3257 $this->add_data($this->options['comment']);
3258 }
3259
3260 chdir($pwd);
3261
3262 return 1;
3263 }
3264}
3265// +--------------------------------------------------
3266// | THE END
3267// +--------------------------------------------------
3268?>