-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
3539 lines (3459 loc) · 154 KB
/
index.php
File metadata and controls
3539 lines (3459 loc) · 154 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
//a:9:{s:4:"lang";s:3:"fr1";s:9:"auth_pass";s:32:"d41d8cd98f00b204e9800998ecf8427e";s:8:"quota_mb";i:0;s:17:"upload_ext_filter";a:0:{}s:19:"download_ext_filter";a:0:{}s:15:"error_reporting";i:1;s:7:"fm_root";s:0:"";s:17:"cookie_cache_time";i:2592000;s:7:"version";s:5:"0.9.8";}
/*--------------------------------------------------
| PHP FILE MANAGER
+--------------------------------------------------
| phpFileManager 0.9.8
| By Fabricio Seger Kolling
| Copyright (c) 2004-2013 Fabrício Seger Kolling
| E-mail: dulldusk@gmail.com
| URL: http://phpfm.sf.net
| Last Changed: 2013-10-15
+--------------------------------------------------
| OPEN SOURCE CONTRIBUTIONS
+--------------------------------------------------
| TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.0
| By Devin Doucette
| Copyright (c) 2004 Devin Doucette
| E-mail: darksnoopy@shaw.ca
| URL: http://www.phpclasses.org
+--------------------------------------------------
| It is the AUTHOR'S REQUEST that you keep intact the above header information
| and notify him if you conceive any BUGFIXES or IMPROVEMENTS to this program.
+--------------------------------------------------
| LICENSE
+--------------------------------------------------
| Licensed under the terms of any of the following licenses at your choice:
| - GNU General Public License Version 2 or later (the "GPL");
| - GNU Lesser General Public License Version 2.1 or later (the "LGPL");
| - Mozilla Public License Version 1.1 or later (the "MPL").
| You are not required to, but if you want to explicitly declare the license
| you have chosen to be bound to when using, reproducing, modifying and
| distributing this software, just include a text file titled "LEGAL" in your version
| of this software, indicating your license choice. In any case, your choice will not
| restrict any recipient of your version of this software to use, reproduce, modify
| and distribute this software under any of the above licenses.
+--------------------------------------------------
| CONFIGURATION AND INSTALATION NOTES
+--------------------------------------------------
| This program does not include any instalation or configuration
| notes because it simply does not require them.
| Just throw this file anywhere in your webserver and enjoy !!
+--------------------------------------------------
*/
// +--------------------------------------------------
// | Header and Globals
// +--------------------------------------------------
$charset = "UTF-8";
//@setlocale(LC_CTYPE, 'C');
header("Pragma: no-cache");
header("Cache-Control: no-store");
header("Content-Type: text/html; charset=".$charset);
//@ini_set('default_charset', $charset);
if (@get_magic_quotes_gpc()) {
function stripslashes_deep($value){
return is_array($value)? array_map('stripslashes_deep', $value):$value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
// Server Vars
function get_client_ip() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED'])) $ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR'])) $ipaddress = $_SERVER['REMOTE_ADDR'];
// proxy transparente não esconde o IP local, colocando ele após o IP da rede, separado por vírgula
if (strpos($ipaddress, ',') !== false) {
$ips = explode(',', $ipaddress);
$ipaddress = trim($ips[0]);
}
if ($ipaddress == '::1') $ipaddress = '';
return $ipaddress;
}
$ip = get_client_ip();
$islinux = !(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
function getServerURL() {
$url = (isset($_SERVER["HTTPS"]))?"https://":"http://";
$url .= $_SERVER["SERVER_NAME"]; // $_SERVER["HTTP_HOST"] is equivalent
if ($_SERVER["SERVER_PORT"] != "80") $url .= ":".$_SERVER["SERVER_PORT"];
return $url;
}
function getCompleteURL() {
return getServerURL().$_SERVER["REQUEST_URI"];
}
$url = getCompleteURL();
$url_info = parse_url($url);
if( !isset($_SERVER['DOCUMENT_ROOT']) ) {
if ( isset($_SERVER['SCRIPT_FILENAME']) ) $path = $_SERVER['SCRIPT_FILENAME'];
elseif ( isset($_SERVER['PATH_TRANSLATED']) ) $path = str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']);
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($path, 0, 0-strlen($_SERVER['PHP_SELF'])));
}
$doc_root = str_replace('//','/',str_replace(DIRECTORY_SEPARATOR,'/',$_SERVER["DOCUMENT_ROOT"]));
$fm_self = $doc_root.$_SERVER["PHP_SELF"];
$path_info = pathinfo($fm_self);
// Register Globals
$blockKeys = array('_SERVER','_SESSION','_GET','_POST','_COOKIE','charset','ip','islinux','url','url_info','doc_root','fm_self','path_info');
foreach ($_GET as $key => $val) if (array_search($key,$blockKeys) === false) $$key=$val;
foreach ($_POST as $key => $val) if (array_search($key,$blockKeys) === false) $$key=$val;
foreach ($_COOKIE as $key => $val) if (array_search($key,$blockKeys) === false) $$key=$val;
// +--------------------------------------------------
// | Config
// +--------------------------------------------------
$cfg = new config();
$cfg->load();
switch ($error_reporting){
case 0: error_reporting(0); @ini_set("display_errors",0); break;
case 1: error_reporting(E_ERROR | E_PARSE | E_COMPILE_ERROR); @ini_set("display_errors",1); break;
case 2: error_reporting(E_ALL); @ini_set("display_errors",1); break;
}
if (!isset($current_dir)){
$current_dir = $path_info["dirname"]."/";
if (!$islinux) $current_dir = ucfirst($current_dir);
//@chmod($current_dir,0755);
} else $current_dir = format_path($current_dir);
// Auto Expand Local Path
if (!isset($expanded_dir_list)){
$expanded_dir_list = "";
$mat = explode("/",$path_info["dirname"]);
for ($x=0;$x<count($mat);$x++) $expanded_dir_list .= ":".$mat[$x];
setcookie("expanded_dir_list", $expanded_dir_list, 0, "/");
}
if (!isset($fm_current_root)){
if (strlen($fm_root)) $fm_current_root = $fm_root;
else {
if (!$islinux) $fm_current_root = ucfirst($path_info["dirname"]."/");
else $fm_current_root = $doc_root."/";
}
setcookie("fm_current_root", $fm_current_root, 0, "/");
} elseif (isset($set_fm_current_root)) {
if (!$islinux) $fm_current_root = ucfirst($set_fm_current_root);
setcookie("fm_current_root", $fm_current_root, 0, "/");
}
if (!isset($resolveIDs)){
setcookie("resolveIDs", 0, time()+$cookie_cache_time, "/");
} elseif (isset($set_resolveIDs)){
$resolveIDs=($resolveIDs)?0:1;
setcookie("resolveIDs", $resolveIDs, time()+$cookie_cache_time, "/");
}
if ($resolveIDs){
exec("cat /etc/passwd",$mat_passwd);
exec("cat /etc/group",$mat_group);
}
$fm_color['Bg'] = "EEEEEE";
$fm_color['Text'] = "000000";
$fm_color['Link'] = "0A77F7";
$fm_color['Entry'] = "FFFFFF";
$fm_color['Over'] = "C0EBFD";
$fm_color['Mark'] = "A7D2E4";
foreach($fm_color as $tag=>$color){
$fm_color[$tag]=strtolower($color);
}
// +--------------------------------------------------
// | File Manager Actions
// +--------------------------------------------------
if ($loggedon==$auth_pass){
switch ($frame){
case 1: break; // Empty Frame
case 2: frame2(); break;
case 3: frame3(); break;
default:
switch($action){
case 1: logout(); break;
case 2: config_form(); break;
case 3: download(); break;
case 4: view(); break;
case 5: server_info(); break;
case 6: execute_cmd(); break;
case 7: edit_file_form(); break;
case 8: chmod_form(); break;
case 9: shell_form(); break;
case 10: upload_form(); break;
case 11: execute_file(); break;
default: frameset();
}
}
} else {
if (isset($pass)) login();
else login_form();
}
// +--------------------------------------------------
// | Config Class
// +--------------------------------------------------
class config {
var $data;
var $filename;
function config(){
global $fm_self;
$this->data = array(
'lang'=>'en',
'auth_pass'=>md5(''),
'quota_mb'=>0,
'upload_ext_filter'=>array(),
'download_ext_filter'=>array(),
'error_reporting'=>1,
'fm_root'=>'',
'cookie_cache_time'=>60*60*24*30, // 30 Days
'version'=>'0.9.8'
);
$data = false;
$this->filename = $fm_self;
if (file_exists($this->filename)){
$mat = file($this->filename);
$objdata = trim(substr($mat[1],2));
if (strlen($objdata)) $data = unserialize($objdata);
}
if (is_array($data)&&count($data)==count($this->data)) $this->data = $data;
else $this->save();
}
function save(){
$objdata = "<?php".chr(13).chr(10)."//".serialize($this->data).chr(13).chr(10);
if (strlen($objdata)){
if (file_exists($this->filename)){
$mat = file($this->filename);
if ($fh = @fopen($this->filename, "w")){
@fputs($fh,$objdata,strlen($objdata));
for ($x=2;$x<count($mat);$x++) @fputs($fh,$mat[$x],strlen($mat[$x]));
@fclose($fh);
}
}
}
}
function load(){
foreach ($this->data as $key => $val) $GLOBALS[$key] = $val;
}
}
// +--------------------------------------------------
// | Internationalization
// +--------------------------------------------------
function et($tag){
global $lang;
// French - by Jean Bilwes
$fr1['Version'] = 'Version';
$fr1['DocRoot'] = 'Racine des documents';
$fr1['FLRoot'] = 'Racine du gestionnaire de fichers';
$fr1['Name'] = 'Nom';
$fr1['And'] = 'et';
$fr1['Enter'] = 'Enter';
$fr1['Send'] = 'Envoyer';
$fr1['Refresh'] = 'Rafraichir';
$fr1['SaveConfig'] = 'Enregistrer la Configuration';
$fr1['SavePass'] = 'Enregistrer le mot de passe';
$fr1['SaveFile'] = 'Enregistrer le fichier';
$fr1['Save'] = 'Enregistrer';
$fr1['Leave'] = 'Quitter';
$fr1['Edit'] = 'Modifier';
$fr1['View'] = 'Voir';
$fr1['Config'] = 'Config';
$fr1['Ren'] = 'Renommer';
$fr1['Rem'] = 'Detruire';
$fr1['Compress'] = 'Compresser';
$fr1['Decompress'] = 'Decompresser';
$fr1['ResolveIDs'] = 'Resoudre les IDs';
$fr1['Move'] = 'Déplacer';
$fr1['Copy'] = 'Copier';
$fr1['ServerInfo'] = 'info du serveur';
$fr1['CreateDir'] = 'Créer un répertoire';
$fr1['CreateArq'] = 'Créer un fichier';
$fr1['ExecCmd'] = 'Executer une Commande';
$fr1['Upload'] = 'Téléversement(upload)';
$fr1['UploadEnd'] = 'Téléversement Fini';
$fr1['Perm'] = 'Perm';
$fr1['Perms'] = 'Permissions';
$fr1['Owner'] = 'Propriétaire';
$fr1['Group'] = 'Groupe';
$fr1['Other'] = 'Autre';
$fr1['Size'] = 'Taille';
$fr1['Date'] = 'Date';
$fr1['Type'] = 'Type';
$fr1['Free'] = 'libre';
$fr1['Shell'] = 'Shell';
$fr1['Read'] = 'Lecture';
$fr1['Write'] = 'Ecriture';
$fr1['Exec'] = 'Executer';
$fr1['Apply'] = 'Appliquer';
$fr1['StickyBit'] = 'Sticky Bit';
$fr1['Pass'] = 'Mot de passe';
$fr1['Lang'] = 'Langage';
$fr1['File'] = 'Fichier';
$fr1['File_s'] = 'fichier(s)';
$fr1['Dir_s'] = 'répertoire(s)';
$fr1['To'] = 'à';
$fr1['Destination'] = 'Destination';
$fr1['Configurations'] = 'Configurations';
$fr1['JSError'] = 'Erreur JavaScript';
$fr1['NoSel'] = 'Rien n\'est sélectionné';
$fr1['SelDir'] = 'Selectionnez le répertoire de destination dans le panneau gauche';
$fr1['TypeDir'] = 'Entrer le nom du répertoire';
$fr1['TypeArq'] = 'Entrer le nom du fichier';
$fr1['TypeCmd'] = 'Entrer la commande';
$fr1['TypeArqComp'] = 'Entrer le nom du fichier.\\nL\'extension définira le type de compression.\\nEx:\\nnome.zip\\nnome.tar\\nnome.bzip\\nnome.gzip';
$fr1['RemSel'] = 'EFFACER les objets sélectionnés';
$fr1['NoDestDir'] = 'Aucun répertoire de destination n\'est sélectionné';
$fr1['DestEqOrig'] = 'Les répertoires source et destination sont identiques';
$fr1['InvalidDest'] = 'Le répertoire de destination est invalide';
$fr1['NoNewPerm'] = 'Nouvelle permission non établie';
$fr1['CopyTo'] = 'COPIER vers';
$fr1['MoveTo'] = 'DEPLACER vers';
$fr1['AlterPermTo'] = 'CHANGER LES PERMISSIONS';
$fr1['ConfExec'] = 'Confirmer l\'EXECUTION';
$fr1['ConfRem'] = 'Confirmer la DESTRUCTION';
$fr1['EmptyDir'] = 'Répertoire vide';
$fr1['IOError'] = 'I/O Error';
$fr1['FileMan'] = 'PHP File Manager';
$fr1['TypePass'] = 'Entrer le mot de passe';
$fr1['InvPass'] = 'Mot de passe invalide';
$fr1['ReadDenied'] = 'Droit de lecture refusé';
$fr1['FileNotFound'] = 'Fichier introuvable';
$fr1['AutoClose'] = 'Fermer sur fin';
$fr1['OutDocRoot'] = 'Fichier au delà de DOCUMENT_ROOT';
$fr1['NoCmd'] = 'Erreur: Commande non renseignée';
$fr1['ConfTrySave'] = 'Fichier sans permission d\'écriture.\\nJ\'essaie de l\'enregister';
$fr1['ConfSaved'] = 'Configurations enreristrée';
$fr1['PassSaved'] = 'Mot de passe enreristré';
$fr1['FileDirExists'] = 'Le fichier ou le répertoire existe déjà';
$fr1['NoPhpinfo'] = 'Function phpinfo désactivée';
$fr1['NoReturn'] = 'pas de retour';
$fr1['FileSent'] = 'Fichier envoyé';
$fr1['SpaceLimReached'] = 'Espace maxi atteint';
$fr1['InvExt'] = 'Extension invalide';
$fr1['FileNoOverw'] = 'Le fichier ne peut pas etre écrasé';
$fr1['FileOverw'] = 'Fichier écrasé';
$fr1['FileIgnored'] = 'Fichier ignoré';
$fr1['ChkVer'] = 'Verifier nouvelle version';
$fr1['ChkVerAvailable'] = 'Nouvelle version, cliquer ici pour la téléchager!!';
$fr1['ChkVerNotAvailable'] = 'Aucune mise a jour de disponible. :(';
$fr1['ChkVerError'] = 'Erreur de connection.';
$fr1['Website'] = 'siteweb';
$fr1['SendingForm'] = 'Envoi des fichiers en cours, Patienter';
$fr1['NoFileSel'] = 'Aucun fichier sélectionné';
$fr1['SelAll'] = 'Tous';
$fr1['SelNone'] = 'Aucun';
$fr1['SelInverse'] = 'Inverser';
$fr1['Selected_s'] = 'selectioné';
$fr1['Total'] = 'total';
$fr1['Partition'] = 'Partition';
$fr1['RenderTime'] = 'Temps pour afficher cette page';
$fr1['Seconds'] = 'sec';
$fr1['ErrorReport'] = 'Rapport d\'erreur';
$lang_ = $$lang;
if (isset($lang_[$tag])) return html_encode($lang_[$tag]);
//else return "[$tag]"; // So we can know what is missing
return $en[$tag];
}
// +--------------------------------------------------
// | File System
// +--------------------------------------------------
function total_size($arg) {
$total = 0;
if (file_exists($arg)) {
if (is_dir($arg)) {
$handle = opendir($arg);
while($aux = readdir($handle)) {
if ($aux != "." && $aux != "..") $total += total_size($arg."/".$aux);
}
@closedir($handle);
} else $total = filesize($arg);
}
return $total;
}
function total_delete($arg) {
if (file_exists($arg)) {
@chmod($arg,0755);
if (is_dir($arg)) {
$handle = opendir($arg);
while($aux = readdir($handle)) {
if ($aux != "." && $aux != "..") total_delete($arg."/".$aux);
}
@closedir($handle);
rmdir($arg);
} else unlink($arg);
}
}
function total_copy($orig,$dest) {
$ok = true;
if (file_exists($orig)) {
if (is_dir($orig)) {
mkdir($dest,0755);
$handle = opendir($orig);
while(($aux = readdir($handle))&&($ok)) {
if ($aux != "." && $aux != "..") $ok = total_copy($orig."/".$aux,$dest."/".$aux);
}
@closedir($handle);
} else $ok = copy((string)$orig,(string)$dest);
}
return $ok;
}
function total_move($orig,$dest) {
// Just why doesn't it has a MOVE alias?!
return rename((string)$orig,(string)$dest);
}
function download(){
global $current_dir,$filename;
$file = $current_dir.$filename;
if(file_exists($file)){
$is_denied = false;
foreach($download_ext_filter as $key=>$ext){
if (eregi($ext,$filename)){
$is_denied = true;
break;
}
}
if (!$is_denied){
$size = filesize($file);
header("Content-Type: application/save");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Transfer-Encoding: binary");
if ($fh = fopen("$file", "rb")){
fpassthru($fh);
fclose($fh);
} else alert(et('ReadDenied').": ".$file);
} else alert(et('ReadDenied').": ".$file);
} else alert(et('FileNotFound').": ".$file);
}
function execute_cmd(){
global $cmd;
header("Content-type: text/plain");
if (strlen($cmd)){
echo "# ".$cmd."\n";
exec($cmd,$mat);
if (count($mat)) echo trim(implode("\n",$mat));
else echo "exec(\"$cmd\") ".et('NoReturn')."...";
} else echo et('NoCmd');
}
function execute_file(){
global $current_dir,$filename;
header("Content-type: text/plain");
$file = $current_dir.$filename;
if(file_exists($file)){
echo "# ".$file."\n";
exec($file,$mat);
if (count($mat)) echo trim(implode("\n",$mat));
} else alert(et('FileNotFound').": ".$file);
}
function save_upload($temp_file,$filename,$dir_dest) {
global $upload_ext_filter;
$filename = remove_special_chars($filename);
$file = $dir_dest.$filename;
$filesize = filesize($temp_file);
$is_denied = false;
foreach($upload_ext_filter as $key=>$ext){
if (eregi($ext,$filename)){
$is_denied = true;
break;
}
}
if (!$is_denied){
if (!check_limit($filesize)){
if (file_exists($file)){
if (unlink($file)){
if (copy($temp_file,$file)){
@chmod($file,0755);
$out = 6;
} else $out = 2;
} else $out = 5;
} else {
if (copy($temp_file,$file)){
@chmod($file,0755);
$out = 1;
} else $out = 2;
}
} else $out = 3;
} else $out = 4;
return $out;
}
function zip_extract(){
global $cmd_arg,$current_dir,$islinux;
$zip = zip_open($current_dir.$cmd_arg);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
if (zip_entry_filesize($zip_entry)) {
$complete_path = $path.dirname(zip_entry_name($zip_entry));
$complete_name = $path.zip_entry_name($zip_entry);
if(!file_exists($complete_path)) {
$tmp = '';
foreach(explode('/',$complete_path) AS $k) {
$tmp .= $k.'/';
if(!file_exists($tmp)) {
@mkdir($current_dir.$tmp, 0755);
}
}
}
if (zip_entry_open($zip, $zip_entry, "r")) {
if ($fd = fopen($current_dir.$complete_name, 'w')){
fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
fclose($fd);
} else echo "fopen($current_dir.$complete_name) error<br>";
zip_entry_close($zip_entry);
} else echo "zip_entry_open($zip,$zip_entry) error<br>";
}
}
zip_close($zip);
}
}
// +--------------------------------------------------
// | Data Formating
// +--------------------------------------------------
function html_encode($str){
global $charSet;
$str = preg_replace(array('/&/', '/</', '/>/', '/"/'), array('&', '<', '>', '"'), $str); // Bypass PHP to allow any charset!!
$str = htmlentities($str, ENT_QUOTES, $charSet, false);
return $str;
}
function rep($x,$y){
if ($x) {
$aux = "";
for ($a=1;$a<=$x;$a++) $aux .= $y;
return $aux;
} else return "";
}
function str_zero($arg1,$arg2){
if (strstr($arg1,"-") == false){
$aux = intval($arg2) - strlen($arg1);
if ($aux) return rep($aux,"0").$arg1;
else return $arg1;
} else {
return "[$arg1]";
}
}
function replace_double($sub,$str){
$out=str_replace($sub.$sub,$sub,$str);
while ( strlen($out) != strlen($str) ){
$str=$out;
$out=str_replace($sub.$sub,$sub,$str);
}
return $out;
}
function remove_special_chars($str){
$str = trim($str);
$str = strtr($str,"¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ!@#%&*()[]{}+=?",
"YuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy_______________");
$str = str_replace("..","",str_replace("/","",str_replace("\\","",str_replace("\$","",$str))));
return $str;
}
function format_path($str){
global $islinux;
$str = trim($str);
$str = str_replace("..","",str_replace("\\","/",str_replace("\$","",$str)));
$done = false;
while (!$done) {
$str2 = str_replace("//","/",$str);
if (strlen($str) == strlen($str2)) $done = true;
else $str = $str2;
}
$tam = strlen($str);
if ($tam){
$last_char = $tam - 1;
if ($str[$last_char] != "/") $str .= "/";
if (!$islinux) $str = ucfirst($str);
}
return $str;
}
function array_csort() {
$args = func_get_args();
$marray = array_shift($args);
$msortline = "return(array_multisort(";
foreach ($args as $arg) {
$i++;
if (is_string($arg)) {
foreach ($marray as $row) {
$sortarr[$i][] = $row[$arg];
}
} else {
$sortarr[$i] = $arg;
}
$msortline .= "\$sortarr[".$i."],";
}
$msortline .= "\$marray));";
eval($msortline);
return $marray;
}
function show_perms( $P ) {
$sP = "<b>";
if($P & 0x1000) $sP .= 'p'; // FIFO pipe
elseif($P & 0x2000) $sP .= 'c'; // Character special
elseif($P & 0x4000) $sP .= 'd'; // Directory
elseif($P & 0x6000) $sP .= 'b'; // Block special
elseif($P & 0x8000) $sP .= '−'; // Regular
elseif($P & 0xA000) $sP .= 'l'; // Symbolic Link
elseif($P & 0xC000) $sP .= 's'; // Socket
else $sP .= 'u'; // UNKNOWN
$sP .= "</b>";
// owner - group - others
$sP .= (($P & 0x0100) ? 'r' : '−') . (($P & 0x0080) ? 'w' : '−') . (($P & 0x0040) ? (($P & 0x0800) ? 's' : 'x' ) : (($P & 0x0800) ? 'S' : '−'));
$sP .= (($P & 0x0020) ? 'r' : '−') . (($P & 0x0010) ? 'w' : '−') . (($P & 0x0008) ? (($P & 0x0400) ? 's' : 'x' ) : (($P & 0x0400) ? 'S' : '−'));
$sP .= (($P & 0x0004) ? 'r' : '−') . (($P & 0x0002) ? 'w' : '−') . (($P & 0x0001) ? (($P & 0x0200) ? 't' : 'x' ) : (($P & 0x0200) ? 'T' : '−'));
return $sP;
}
function format_size($arg) {
if ($arg>0){
$j = 0;
$ext = array(" bytes"," Kb"," Mb"," Gb"," Tb");
while ($arg >= pow(1024,$j)) ++$j;
return round($arg / pow(1024,$j-1) * 100) / 100 . $ext[$j-1];
} else return "0 bytes";
}
function get_size($file) {
return format_size(filesize($file));
}
function check_limit($new_filesize=0) {
global $fm_current_root;
global $quota_mb;
if($quota_mb){
$total = total_size($fm_current_root);
if (floor(($total+$new_filesize)/(1024*1024)) > $quota_mb) return true;
}
return false;
}
function get_user($arg) {
global $mat_passwd;
$aux = "x:".trim($arg).":";
for($x=0;$x<count($mat_passwd);$x++){
if (strstr($mat_passwd[$x],$aux)){
$mat = explode(":",$mat_passwd[$x]);
return $mat[0];
}
}
return $arg;
}
function get_group($arg) {
global $mat_group;
$aux = "x:".trim($arg).":";
for($x=0;$x<count($mat_group);$x++){
if (strstr($mat_group[$x],$aux)){
$mat = explode(":",$mat_group[$x]);
return $mat[0];
}
}
return $arg;
}
function uppercase($str){
global $charset;
return mb_strtoupper($str, $charset);
}
function lowercase($str){
global $charset;
return mb_strtolower($str, $charset);
}
// +--------------------------------------------------
// | Interface
// +--------------------------------------------------
function html_header($header=""){
global $charset,$fm_color;
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=".$charset."\" />
<title>".et('FileMan')."</title>
<script language=\"Javascript\" type=\"text/javascript\">
<!--
function Is(){
this.appname = navigator.appName;
this.appversion = navigator.appVersion;
this.platform = navigator.platform;
this.useragent = navigator.userAgent.toLowerCase();
this.ie = ( this.appname == 'Microsoft Internet Explorer' );
if (( this.useragent.indexOf( 'mac' ) != -1 ) || ( this.platform.indexOf( 'mac' ) != -1 )){
this.sisop = 'mac';
} else if (( this.useragent.indexOf( 'windows' ) != -1 ) || ( this.platform.indexOf( 'win32' ) != -1 )){
this.sisop = 'windows';
} else if (( this.useragent.indexOf( 'inux' ) != -1 ) || ( this.platform.indexOf( 'linux' ) != -1 )){
this.sisop = 'linux';
}
}
var is = new Is();
function enterSubmit(keypressEvent,submitFunc){
var kCode = (is.ie) ? keypressEvent.keyCode : keypressEvent.which
if( kCode == 13) eval(submitFunc);
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (';', offset);
if (endstr == -1) endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (name) {
var arg = name + '=';
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
i = document.cookie.indexOf(' ', i) + 1;
if (i == 0) break;
}
return null;
}
function setCookie (name, value, expires) {
var argv = setCookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + '=' + escape (value) +
((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +
((path == null) ? '' : ('; path=' + path)) +
((domain == null) ? '' : ('; domain=' + domain)) +
((secure == true) ? '; secure' : '');
}
function delCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie (name);
document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString();
}
var frameWidth, frameHeight;
function getFrameSize(){
if (self.innerWidth){
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}else if (document.documentElement && document.documentElement.clientWidth){
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
}else if (document.body){
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}else return false;
return true;
}
getFrameSize();
//-->
</script>
$header
</head>
<script language=\"Javascript\" type=\"text/javascript\">
<!--
var W = screen.width;
var H = screen.height;
var FONTSIZE = 0;
switch (W){
case 640:
FONTSIZE = 8;
break;
case 800:
FONTSIZE = 10;
break;
case 1024:
FONTSIZE = 12;
break;
default:
FONTSIZE = 14;
break;
}
";
echo replace_double(" ",str_replace(chr(13),"",str_replace(chr(10),"","
document.writeln('
<style type=\"text/css\">
body {
font-family : Arial;
font-size: '+FONTSIZE+'px;
font-weight : normal;
color: #".$fm_color['Text'].";
background-color: #".$fm_color['Bg'].";
}
table {
font-family : Arial;
font-size: '+FONTSIZE+'px;
font-weight : normal;
color: #".$fm_color['Text'].";
cursor: default;
}
input {
font-family : Arial;
font-size: '+FONTSIZE+'px;
font-weight : normal;
color: #".$fm_color['Text'].";
}
textarea {
font-family : Courier;
font-size: 12px;
font-weight : normal;
color: #".$fm_color['Text'].";
}
a {
font-family : Arial;
font-size : '+FONTSIZE+'px;
font-weight : bold;
text-decoration: none;
color: #".$fm_color['Text'].";
}
a:link {
color: #".$fm_color['Text'].";
}
a:visited {
color: #".$fm_color['Text'].";
}
a:hover {
color: #".$fm_color['Link'].";
}
a:active {
color: #".$fm_color['Text'].";
}
tr.entryUnselected {
background-color: #".$fm_color['Entry'].";
}
tr.entryUnselected:hover {
background-color: #".$fm_color['Over'].";
}
tr.entrySelected {
background-color: #".$fm_color['Mark'].";
}
</style>
');
")));
echo "
//-->
</script>
";
}
function reloadframe($ref,$frame_number,$Plus=""){
global $current_dir,$path_info;
echo "
<script language=\"Javascript\" type=\"text/javascript\">
<!--
".$ref.".frame".$frame_number.".location.href='".$path_info["basename"]."?frame=".$frame_number."¤t_dir=".$current_dir.$Plus."';
//-->
</script>
";
}
function alert($arg){
echo "
<script language=\"Javascript\" type=\"text/javascript\">
<!--
alert('$arg');
//-->
</script>
";
}
function tree($dir_before,$dir_current,$indice){
global $fm_current_root, $current_dir, $islinux;
global $expanded_dir_list;
$indice++;
$num_dir = 0;
$dir_name = str_replace($dir_before,"",$dir_current);
$dir_before = str_replace("//","/",$dir_before);
$dir_current = str_replace("//","/",$dir_current);
$is_denied = false;
if ($islinux) {
$denied_list = "/proc#/dev";
$mat = explode("#",$denied_list);
foreach($mat as $key => $val){
if ($dir_current == $val){
$is_denied = true;
break;
}
}
unset($mat);
}
if (!$is_denied){
if ($handle = @opendir($dir_current)){
// Permitido
while ($file = readdir($handle)){
if ($file != "." && $file != ".." && is_dir("$dir_current/$file"))
$mat_dir[] = $file;
}
@closedir($handle);
if (count($mat_dir)){
sort($mat_dir,SORT_STRING);
// with Sub-dir
if ($indice != 0){
for ($aux=1;$aux<$indice;$aux++) echo " ";
}
if ($dir_before != $dir_current){
if (strstr($expanded_dir_list,":$dir_current/$dir_name")) $op_str = "[–]";
else $op_str = "[+]";
echo "<nobr><a href=\"JavaScript:go_dir('$dir_current/$dir_name')\">$op_str</a> <a href=\"JavaScript:go('$dir_current')\">$dir_name</a></nobr><br>\n";
} else {
echo "<nobr><a href=\"JavaScript:go('$dir_current')\">$fm_current_root</a></nobr><br>\n";
}
for ($x=0;$x<count($mat_dir);$x++){
if (($dir_before == $dir_current)||(strstr($expanded_dir_list,":$dir_current/$dir_name"))){
tree($dir_current."/",$dir_current."/".$mat_dir[$x],$indice);
} else flush();
}
} else {
// no Sub-dir
if ($dir_before != $dir_current){
for ($aux=1;$aux<$indice;$aux++) echo " ";
echo "<b>[ ]</b>";
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"> $dir_name</a></nobr><br>\n";
} else {
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"> $fm_current_root</a></nobr><br>\n";
}
}
} else {
// denied
if ($dir_before != $dir_current){
for ($aux=1;$aux<$indice;$aux++) echo " ";
echo "<b>[ ]</b>";
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"><font color=red> $dir_name</font></a></nobr><br>\n";
} else {
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"><font color=red> $fm_current_root</font></a></nobr><br>\n";
}
}
} else {
// denied
if ($dir_before != $dir_current){
for ($aux=1;$aux<$indice;$aux++) echo " ";
echo "<b>[ ]</b>";
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"><font color=red> $dir_name</font></a></nobr><br>\n";
} else {
echo "<nobr><a href=\"JavaScript:go('$dir_current')\"><font color=red> $fm_current_root</font></a></nobr><br>\n";
}
}
}
function show_tree(){
global $fm_current_root,$path_info,$setflag,$islinux,$cookie_cache_time;
html_header("
<script language=\"Javascript\" type=\"text/javascript\">
<!--
function saveFrameSize(){
if (getFrameSize()){
var exp = new Date();
exp.setTime(exp.getTime()+$cookie_cache_time);
setCookie('leftFrameWidth',frameWidth,exp);
}
}
window.onresize = saveFrameSize;
//-->
</script>");
echo "<body marginwidth=\"0\" marginheight=\"0\">\n";
echo "
<script language=\"Javascript\" type=\"text/javascript\">
<!--
// Disable text selection, binding the onmousedown, but not for some elements, it must work.
function disableTextSelection(e){
var type = String(e.target.type);
return (type.indexOf('select') != -1 || type.indexOf('button') != -1 || type.indexOf('input') != -1 || type.indexOf('radio') != -1);
}
function enableTextSelection(){return true}
if (is.ie) document.onselectstart=new Function('return false')
else {
document.body.onmousedown=disableTextSelection
document.body.onclick=enableTextSelection
}
var flag = ".(($setflag)?"true":"false")."
function set_flag(arg) {
flag = arg;
}
function go_dir(arg) {
var setflag;
setflag = (flag)?1:0;
document.location.href='".addslashes($path_info["basename"])."?frame=2&setflag='+setflag+'¤t_dir=".addslashes($current_dir)."&ec_dir='+arg;
}
function go(arg) {
if (flag) {
parent.frame3.set_dir_dest(arg+'/');
flag = false;
} else {
parent.frame3.location.href='".addslashes($path_info["basename"])."?frame=3¤t_dir='+arg+'/';
}
}
function set_fm_current_root(arg){
document.location.href='".addslashes($path_info["basename"])."?frame=2&set_fm_current_root='+escape(arg);
}
function atualizar(){
document.location.href='".addslashes($path_info["basename"])."?frame=2';
}
//-->
</script>
";
echo "<table width=\"100%\" height=\"100%\" border=0 cellspacing=0 cellpadding=5>\n";
echo "<form><tr valign=top height=10><td>";
if (!$islinux){
echo "<select name=drive onchange=\"set_fm_current_root(this.value)\">";
$aux="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($x=0;$x<strlen($aux);$x++){
if ($handle = opendir($aux[$x].":/")){
@closedir($handle);
if (strstr(uppercase($fm_current_root),$aux[$x].":/")) $is_sel="selected";
else $is_sel="";
echo "<option $is_sel value=\"".$aux[$x].":/\">".$aux[$x].":/";
}
}
echo "</select> ";
}
echo "<input type=button value=".et('Refresh')." onclick=\"atualizar()\"></tr></form>";
echo "<tr valign=top><td>";
clearstatcache();
tree($fm_current_root,$fm_current_root,-1,0);
echo "</td></tr>";
echo "
<form name=\"login_form\" action=\"".$path_info["basename"]."\" method=\"post\" target=\"_parent\">
<input type=hidden name=action value=1>
<tr>
<td height=10 colspan=2><input type=submit value=\"".et('Leave')."\">
</tr>