File: /home/ddir12/up/up.txt
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<title>دانلود فایل با درصد زنده</title>
<!-- اضافه کردن فونت وزیر از گوگل -->
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
/* استایلهای جدید با فونت وزیر */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Vazirmatn', sans-serif;
}
body {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
color: #333;
min-height: 100vh;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.container {
width: 100%;
max-width: 600px;
background-color: white;
border-radius: 16px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
padding: 30px;
margin: 20px 0;
}
h1 {
text-align: center;
color: #2c3e50;
margin-bottom: 25px;
font-weight: 700;
font-size: 1.8rem;
border-bottom: 2px solid #f0f0f0;
padding-bottom: 15px;
}
form {
display: flex;
flex-direction: column;
gap: 20px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 8px;
}
label {
font-weight: 600;
color: #444;
font-size: 0.95rem;
}
input[type="text"] {
padding: 12px 15px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 0.95rem;
transition: all 0.3s;
background-color: #f9f9f9;
}
input[type="text"]:focus {
outline: none;
border-color: #4CAF50;
background-color: white;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}
button[type="submit"] {
background: linear-gradient(to left, #4CAF50, #2E7D32);
color: white;
border: none;
padding: 14px 20px;
border-radius: 10px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
margin-top: 10px;
box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}
button[type="submit"]:hover {
transform: translateY(-2px);
box-shadow: 0 6px 15px rgba(76, 175, 80, 0.4);
}
button[type="submit"]:active {
transform: translateY(0);
}
hr {
margin: 30px 0;
border: none;
height: 1px;
background-color: #eaeaea;
}
.progress-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
padding: 20px;
background-color: #f8f9fa;
border-radius: 12px;
}
#progress {
width: 100%;
height: 30px;
border: 2px solid #ddd;
border-radius: 15px;
overflow: hidden;
background-color: #f1f1f1;
box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
#bar {
height: 100%;
width: 0%;
background: linear-gradient(90deg, #4CAF50, #81C784, #4CAF50);
border-radius: 15px;
transition: width 0.5s ease;
position: relative;
overflow: hidden;
}
#bar::after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-image: linear-gradient(
-45deg,
rgba(255, 255, 255, 0.2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, 0.2) 50%,
rgba(255, 255, 255, 0.2) 75%,
transparent 75%,
transparent
);
z-index: 1;
background-size: 50px 50px;
animation: move 2s linear infinite;
border-radius: 15px;
}
@keyframes move {
0% {
background-position: 0 0;
}
100% {
background-position: 50px 50px;
}
}
#percent {
font-weight: 700;
font-size: 1.2rem;
margin-top: 15px;
color: #2c3e50;
text-align: center;
direction: ltr; /* برای نمایش صحیح درصد */
}
.message {
padding: 15px;
border-radius: 10px;
margin-top: 20px;
text-align: center;
font-weight: 500;
}
.error {
background-color: #ffebee;
color: #c62828;
border-right: 4px solid #f44336;
}
.success {
background-color: #e8f5e9;
color: #2e7d32;
border-right: 4px solid #4CAF50;
}
.footer {
text-align: center;
margin-top: 20px;
color: #666;
font-size: 0.85rem;
}
/* استایل برای دسکتاپهای بزرگ */
@media (min-width: 768px) {
.container {
padding: 40px;
}
h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<div class="container">
<h1> دانلود فایل از هاست دیگر</h1>
<form method="post">
<div class="form-group">
<label for="url">آدرس فایل (URL):</label>
<input type="text" id="url" name="url" value="<?php echo htmlspecialchars($_POST['url'] ?? ''); ?>" placeholder="https://example.com/file.zip">
</div>
<div class="form-group">
<label for="savePath">نام یا مسیر ذخیرهسازی (Save Path):</label>
<input type="text" id="savePath" name="savePath" value="<?php echo htmlspecialchars($_POST['savePath'] ?? ''); ?>" placeholder="file.zip یا /path/to/file.zip">
</div>
<button type="submit" name="download">شروع دانلود</button>
</form>
<hr>
<div class="progress-container">
<div id="progress">
<div id="bar"></div>
</div>
<p id="percent">0%</p>
</div>
<?php
if (isset($_POST['download'])) {
$url = $_POST['url'];
$savePath = $_POST['savePath'];
if (empty($url) || empty($savePath)) {
echo '<div class="message error">لطفاً هر دو فیلد را پر کنید.</div>';
exit;
}
// بررسی وجود فایل قبلی برای Resume
$existingSize = file_exists($savePath) ? filesize($savePath) : 0;
$fp = fopen($savePath, $existingSize > 0 ? 'a+' : 'w+');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0); // بدون محدودیت زمان
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');
if ($existingSize > 0) {
curl_setopt($ch, CURLOPT_RESUME_FROM, $existingSize);
echo '<div class="message">ادامه دانلود از نقطه توقف...</div>';
}
// تابع نمایش درصد پیشرفت
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function ($resource, $dltotal, $dlnow) {
if ($dltotal > 0) {
$percent = round(($dlnow / $dltotal) * 100, 2);
echo "<script>
document.getElementById('bar').style.width = '{$percent}%';
document.getElementById('percent').innerText = '{$percent}%';
</script>";
flush();
ob_flush();
}
});
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo '<div class="message error">❌ خطا در دانلود: ' . curl_error($ch) . '</div>';
} else {
echo "<script>
document.getElementById('bar').style.width = '100%';
document.getElementById('percent').innerText = 'دانلود کامل شد ✅';
</script>";
echo '<div class="message success">فایل با موفقیت دانلود شد.</div>';
}
curl_close($ch);
fclose($fp);
}
?>
<div class="footer">
<p>طراحی توسط استاد مرادپور </p>
</div>
</div>
</body>
</html>