Last active
February 2, 2023 15:35
-
-
Save hishamdalal/a4ba554f110e6dd5860e59c98f1c9d80 to your computer and use it in GitHub Desktop.
download all free-css.com bootstrap templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
// رابط قسم قوالب بوتستراب | |
$url = 'https://www.free-css.com/template-categories/bootstrap?start='; | |
// رابط مسار ملفات القوالب المضغوطة | |
$file_url = 'https://www.free-css.com/assets/files/free-css-templates/download/'; | |
// رابط مسار صور القوالب | |
$image_url = 'https://www.free-css.com/assets/images/free-css-templates/'; | |
// رابط مسار صفحة القالب | |
$template_url = 'https://www.free-css.com/free-css-templates/'; | |
// مسار تنزيل القوالب في السيرفر المحلي أو في الموقع الخاص بنا | |
$uploads_dir = 'uploads/'; | |
// متغير لتخزين اسماء وصور القوالب بلغة html | |
$items_html = ''; | |
echo '<pre>'; | |
// في كل صفحة في قسم قوالب البوتستراب يوجد 12 قالب | |
// رابط الصفحة التالية لا يتزايد بمقدار واحد ولكن يأخذ عدد القوالب | |
// فالصفحة الثانية تأخذ الرقم 12 والثالثة 24 أي بتزايد 12 في كل مرة | |
// لذلك نعمل دوارة تزيد كل مرة 12 لنحصل على رابط الصفحة التالية | |
// آخر صفحة حتى هذا التاريخ تأخذ الرقم 408 | |
for($i=0; $i<=408; $i+=12){ | |
// نضيف رقم الصفحة في نهاية الرابط | |
// https://www.free-css.com/template-categories/bootstrap?start=$i | |
$page_url = $url.$i; | |
// طباعة رقم الصفحة مع رابطها | |
echo '<h3><a target="_blank" href="'.$url.$i.'">Page ('.$i.')</a><h3><ul>'; | |
// إنشاء جدول | |
$items_html .= "<table>\n"; | |
// نسخ محتوى الصفحة إلى متغير، طبعا المحتوى بلغة HTML | |
$templates_html = file_get_contents($page_url); | |
// البحث عن روابط القوالب في الصفحة، في كل صفحة 12 قالب | |
preg_match_all("/\"\/free-css-templates\/(\S+)\" title/i", $templates_html, $matches); | |
if(isset($matches[1])){ | |
// انشاء صف | |
$items_html .= "\t<tr>\n"; | |
// عمل دوارة للمرور على جميع القوالب في الصفحة | |
foreach($matches[1] as $n=>$path){ | |
// كل رابط في المتغير $path | |
// يحتوي على مسار كالتالي | |
// page228/bino | |
// اسم القالب هو الجزء الأخير بعد السلاش | |
$name = explode('/',$path)[1]; | |
// رابط القالب | |
$file = $file_url.$path.'.zip'; | |
// رابط صورة القالب | |
$image = $image_url.$path.'.jpg'; | |
// في السطور التالية سيتم إنشاء كود صفحة HTML | |
// يحتوي على معلومات القوالب التي تم تنزيلها ليسهل استعراضها محليا بدون انترنت | |
// ستحتوي الصفحة على | |
// صورة القالب الذي تم تنزيله مع رابط الملف في السيرفر المحلي | |
// وسيتم تخزين بيانات الصور والروابط في متغير $items_html | |
// تقسم الجدول إلى 3 أعمدة | |
if($n %3 ==0) | |
$items_html .= "\t</tr>\n\t<tr>\n"; | |
$items_html .= "\t\t<td>\n"; | |
$items_html .= "\t\t\t<figure>"; | |
$items_html .= '<a href="'.$uploads_dir.$name.'.zip">'; | |
$items_html .= '<img src="'.$uploads_dir.$name.'.jpg" />'; | |
$items_html .= "</a>\n"; | |
$items_html .= "\t\t\t\t<figcaption>".$name; | |
$items_html .= ' <a target="_blank" href="'.$template_url.$path.'">visit</a>'; | |
$items_html .= "</figcaption>\n"; | |
$items_html .= "\t\t\t</figure>\n"; | |
$items_html .= "\t\t</td>\n"; | |
// طباعة اسم القالب مع رابط صفحة القالب | |
echo '<li><a target="_blank" href="'.$template_url.$path.'">'.$name.'</a></li>'; | |
// التأكد من ان القالب لم يتم تنزيله مسبقاً لمنع تكرار التنزيل | |
if(!file_exists($uploads_dir.'/'.$name.'.zip')){ | |
// تنزيل الصورة بالطريقة السهلة، هناك طريقة باستخدام دوال curl | |
file_put_contents($uploads_dir.'/'.$name.'.jpg', file_get_contents($image)); | |
// تنزيل القالب | |
file_put_contents($uploads_dir.'/'.$name.'.zip', file_get_contents($file)); | |
} | |
} | |
$items_html .= "\t</tr>\n"; | |
} | |
echo '</ul>'; | |
$items_html .= "</table>\n"; | |
// لتنزيل عدد معين من الصفحات احذف التعليق من أمام السطر التالي وعدل الرقم بمضاعفات الرقم 12 | |
// فائدة هذا السطر لتجربة السكريبت دون آخذ وقت طويل | |
#if($i>= (2*12) ) break; | |
} | |
// كود صفحة عرض القوالب التي تم تنزيلها مع صور وروابط القوالب | |
$html = '<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Free CSS / Bootstrap</title> | |
<meta name="description" content="Free Bootstrap templates"> | |
<meta name="author" content="hishamdalal@gmail.com"> | |
<style>body{background:#f1f1f1;}img{box-shadow: 0px 0px 12px #9f9f9f}img:hover{border:2px solid #fff;margin:-2px}</style> | |
</head> | |
<body> | |
'.$items_html.' | |
</body> | |
</html>'; | |
// إنشاء صفحة لاستعراض القوالب في السيرفر المحلي | |
file_put_contents('gallery.html', $html); | |
echo '<h1><a target="_blank" href="gallery.html">Gallery</a></h1>'; | |
#print_r($html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment