|
إنضمامك إلي منتديات استراحات زايد يحقق لك معرفة كل ماهو جديد في عالم الانترنت ...
انضم الينا
#1
| ||
| ||
السلام عليكم ورحمة الله وبركاتة .. كلاس قمت ببرمجتة لكي يقوم بإنشاء cache لملفات السكربت الكلاس كامل : رمز PHP: <span style="color: #000000">class CacheC { public function __construct($dirCache, $typeFiles, $typeFilesCache, $timeToDeleteCache) { $this->dirCache = $dirCache; $this->typeFiles = $typeFiles; $this->typeFilesCache = $typeFilesCache; $this->timeToDeleteCache = $timeToDeleteCache; if(!file_exists($this->dirCache)) { $this->showError('Dir '.$this->dirCache.' Not Found'); } } public function existsFile($filename) { $filename = $filename.$this->typeFiles; return file_exists($filename) ? true : false; } public function cacheExists($filename) { $filename = $this->dirCache.$filename.$this->typeFilesCache; return file_exists($filename) ? true : false; } public function createCache($files) { if(is_array($files)) { foreach ($files as $file) { $this->createCache2($file); } } else { $this->createCache2($files); } } public function createCache2($filename) { if(!$this->existsFile($filename)) { $this->showError('File Not Found'); } if($this->cacheExists($filename)) { return false; } $file = $filename.$this->typeFiles; $fileCache = $this->dirCache.$filename.$this->typeFilesCache; $x = file_get_contents('http://'.$this->getDomain().$file, true); file_put_contents($fileCache, $x); } public function getCache($files) { if(is_array($files)) { foreach ($files as $file) { $this->getCache2($file); } } else { $this->getCache2($files); } } public function getCache2($file) { if($this->cacheExists($file)) { $filenax = $this->dirCache.$file.$this->typeFilesCache; $time = filemtime($filenax); $time2 = $time+$this->timeToDeleteCache; if(time() >= $time2) { unlink($filenax); } else { require_once $filenax; } } } public function getDomain() { $surl = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $surl = preg_replace( "/^(www\\.)/", "", $surl ); $arr = explode( "/", $surl ); $count = sizeof( $arr ) - 1; if ( 0 <span style="color: #007700">$cache = new CacheC('html/', '.php', '.html', 60); تشغيل الكلاس html = الملف الخاص بتخزين ملفات الكاش .php = صيغة الملفات .html = صيغة الملفات للكاش 60 = عدد الثواني لتجديد ملفات الكاش لإستدعاء الكاش رمز PHP: $cache->getCache(['index', 'login']); او رمز PHP: $cache->getCache('index'); لإنشاء الكلاس رمز PHP: $cache->createCache(['index', 'login']); او رمز PHP: $cache->createCache('index'); ارائكم في الكلاس + اتمنى تستفيدو منه بالتوفيق . __DEFINE_LIKE_SHARE__ |
مواقع النشر (المفضلة) |
| |
المواضيع المتشابهه | ||||
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
[ كلاس ] Traidnt.Net : كلاس لإيقاف الـflooding مع حجب الاي بي ! | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 09-19-2014 03:30 PM |
[ كلاس ] كلاس تسجيل الدخول مع عمل جلسه ( اول مره اعمل كلاس ) ارائكم وانتقاداتكم تهمني | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-09-2014 03:40 AM |
[ كلاس ] كلاس تسجيل الدخول مع عمل جلسه ( اول مره اعمل كلاس ) ارائكم وانتقاداتكم تهمني | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-09-2014 03:40 AM |
n7100: questions about firmware upgrade, dalvik cache, cache partition... | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 12-30-2012 11:30 AM |
[ كلاس ] كلاس الاتصال بالقاعدة وتسجيل الدخول هدية من saudi.ok | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 01-05-2012 02:10 PM |