Advertisement
animdenis

index.php

Jul 6th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. if(!function_exists('gt_rm_delete_cache'))
  2. {
  3.     function gt_rm_delete_cache($path)
  4.     {
  5.         if (strlen($path) == 0 || $path == '/')
  6.             return false;
  7.    
  8.         $full_path = $_SERVER["DOCUMENT_ROOT"].$path;
  9.    
  10.         $f = true;
  11.         if (is_file($full_path) || is_link($full_path))
  12.         {
  13.             if(@unlink($full_path))
  14.                 return true;
  15.             return false;
  16.         }
  17.         elseif (is_dir($full_path))
  18.         {
  19.             if($handle = opendir($full_path))
  20.             {
  21.                 while(($file = readdir($handle)) !== false)
  22.                 {
  23.                     if ($file == "." || $file == "..")
  24.                         continue;
  25.    
  26.                     if (!DeleteDirFilesEx($path."/".$file))
  27.                         $f = false;
  28.                 }
  29.                 closedir($handle);
  30.             }
  31.             return $f;
  32.         }
  33.         return false;
  34.     }
  35. }
  36. if(!function_exists('gt_rm_info'))
  37. {
  38.     function gt_rm_info($path) {
  39.         $full_path = $path;
  40.         $info = array(
  41.             'count' => 0,
  42.             'size' => 0
  43.         );
  44.        
  45.         foreach (scandir($full_path) as $file) {
  46.             if ($file != '.' && $file != '..') {
  47.                 $file_path = $full_path.DIRECTORY_SEPARATOR.$file;
  48.                 if (is_dir($file_path)) {
  49.                     $tmp = gt_rm_info($file_path);
  50.    
  51.                     $info['count'] += $tmp['count'];
  52.                     $info['size'] += $tmp['size'];
  53.                 }
  54.                 else {
  55.                     $info['count']++;
  56.                     $info['size'] += filesize($file_path);
  57.                 }
  58.             }
  59.         }
  60.        
  61.         return $info;  
  62.     }
  63. }
  64. if(!function_exists('gt_rm_delete_seo_cache'))
  65. {
  66.     function gt_rm_delete_seo_cache(){
  67.         $db_result = \CIBlock::GetList(
  68.             array(),
  69.             array(
  70.                 'SITE_ID'=>SITE_ID,
  71.                 'ACTIVE'=>'Y',
  72.             ),
  73.             false
  74.         );
  75.         while($row = $db_result->Fetch())
  76.         {
  77.             var_dump($row);
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement