| Server IP : 104.21.37.246 / Your IP : 104.23.243.33 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/kainumber.com/convert/ |
Upload File : |
<?php
/*
$folder = isset($_GET['folder']) ? rtrim($_GET['folder'], '/') . '/' : '';
$allowed_ext = ['jpg', 'jpeg', 'png', 'webp'];
// ตรวจสอบโฟลเดอร์
$files = [];
if ($folder && is_dir($folder)) {
$scan = scandir($folder);
foreach ($scan as $file) {
if (is_file($folder . $file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (in_array($ext, $allowed_ext)) {
$files[] = $file;
}
}
}
}
*/
?>
<?php
$folder = isset($_GET['folder']) ? rtrim($_GET['folder'], '/') . '/' : '';
// ตรวจสอบโฟลเดอร์
$files = [];
if ($folder && is_dir($folder)) {
$scan = scandir($folder);
foreach ($scan as $file) {
if (is_file($folder . $file)) {
$files[] = $file;
}
}
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<title>จัดการไฟล์ในโฟลเดอร์</title>
<style>
body { font-family: sans-serif; background: #f2f2f2; padding: 20px; }
.container { background: #fff; padding: 20px; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ccc; padding: 8px; text-align: center; }
th { background-color: #333; color: white; }
.btn { padding: 5px 10px; text-decoration: none; background-color: #007bff; color: white; border-radius: 5px; }
.btn-danger { background-color: #dc3545; }
.btn-success { background-color: #28a745; }
.btn-warning { background-color: #ffc107; color: black; }
</style>
</head>
<body>
<div class="container">
<h2>🗂️ จัดการไฟล์ในโฟลเดอร์</h2>
<form method="get">
ชื่อโฟลเดอร์:
<input type="text" name="folder" placeholder="เช่น upload หรือ myimages" value="<?= htmlspecialchars($_GET['folder'] ?? '') ?>" required>
<input type="submit" value="ดูไฟล์">
</form>
<?php if ($folder): ?>
<h3>📂 โฟลเดอร์: <?= htmlspecialchars($folder) ?></h3>
<?php if (is_dir($folder)): ?>
<?php if (count($files) > 0): ?>
<!-- ปุ่มแปลงทั้งหมดในโฟลเดอร์ -->
<p>
<a class="btn btn-warning" href="convert_all.php?folder=<?= urlencode($folder) ?>" onclick="return confirm('แปลงไฟล์ทั้งหมดในโฟลเดอร์นี้เป็น .webp ?')">
🔄 Convert ทั้งหมดในโฟลเดอร์เป็น .webp
</a>
</p>
<table>
<tr>
<th>ไฟล์</th>
<th>ดู</th>
<th>ดาวน์โหลด</th>
<th>ลบ</th>
<th>Convert เป็น .webp</th>
</tr>
<?php foreach ($files as $file): ?>
<tr>
<td><?= htmlspecialchars($file) ?></td>
<td><a class="btn" href="<?= $folder . $file ?>" target="_blank">ดู</a></td>
<td><a class="btn" href="<?= $folder . $file ?>" download>ดาวน์โหลด</a></td>
<td>
<a class="btn btn-danger" href="delete.php?folder=<?= urlencode($folder) ?>&file=<?= urlencode($file) ?>" onclick="return confirm('ลบไฟล์นี้ใช่หรือไม่?')">ลบ</a>
</td>
<td>
<?php
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if ($ext !== 'webp'):
?>
<a class="btn btn-success" href="convert.php?folder=<?= urlencode($folder) ?>&file=<?= urlencode($file) ?>" onclick="return confirm('Convert ไฟล์นี้เป็น .webp ?')">
Convert
</a>
<?php else: ?>
✅ เป็น .webp แล้ว
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>⚠️ ไม่มีไฟล์รูปในโฟลเดอร์นี้</p>
<?php endif; ?>
<?php else: ?>
<p style="color:red;">❌ ไม่พบโฟลเดอร์: <?= htmlspecialchars($folder) ?></p>
<?php endif; ?>
<?php endif; ?>
</div>
</body>
</html>