<?php
/*
#####################################
#  ShopOS: Shopping Cart Software.
#  Copyright (c) 2008-2010
#  http://www.shopos.ru
#  http://www.shoposs.com
#  Ver. 1.0.0
#####################################
*/

defined('_VALID_OS') or die('Direct Access to this location is not allowed.');

if (isset($_GET['cache']))
{
   switch ($_GET['cache'])
   {
      case 'set_all_cache':
	     set_all_cache();
		 $messageStack->add('Обновлен кэш', 'ok');
      break;
	  
	  case 'articles_url':
          set_articles_url_cache();
	  break;
	  
	  case 'category':
          set_category_cache();
	  break;
	  
	  case 'content_url':
          set_content_url_cache();
	  break;
	  
	  case 'news_url':
          set_news_url_cache();
	  break;
	  
	  case 'products_url':
	      set_products_url_cache();
	  break;
	  
	  case 'categories_url':
	      set_categories_url_cache();
	  break;
	  
	  case 'topics_url':
	      set_topics_url_cache();
	  break;	  
	  
	  case 'cache_clean_all':
	      $dir = _CACHE;

          if ($d = opendir($dir)) {

          $i=0;
          while (false !== ($file = readdir($d))) 
		  {
          if ($file != "." && $file != ".." && $file !=".htaccess" && $file !=".svn" && $file !="system") 
		  {
             $i++;
              if ($_GET['action'] == 'unlink') 
			  {
                 os_delete_file($dir . $file);
              }
          }
          }

         closedir($d);
         }
	  break;
   }
}

?>
<tr>
    <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		<tr> 
            <td colspan="3" class="pageHeading" width="100%">
	            <?php os_header('campaigns.png', 'Контроль кэша'); ?> 		   
			</td>
		</tr>

        <tr>
            <td class="dataTableContentRss" valign="top">	  

			  
			  <table width="100%" border="0">
			<?php
			   

			   if ($fp = opendir(_CACHE.'system/')) 
			   {
		            while ($file = readdir($fp)) 
					{
			            if (is_file(_CACHE.'system/'.$file) && $file != '.htaccess' && $file != 'index.php') 
						{
						    $color = $color == '#f9f9ff' ? '#f0f1ff':'#f9f9ff';
							$size = filesize(_CACHE.'system/'.$file);
  
                            if ($size == 1) $size = 0;
							$size = os_format_filesize($size);
				            // $size = filesize($dir.$file);
							echo '<tr bgcolor="'.$color.'">';
				            echo '<td width="33%">'.$file.'</td>';
				            echo '<td width="33%" align="center">'.$size.'</td>';
							$file = str_replace('.php', '', $file);
				            echo '<td width="33%" align="center"><a href="index2.php?cache='.$file.'">Обновить</a></td>';
							echo '</tr>';
			            } 
		            } 
		            closedir($fp);
	           }
			   
			   os_spaceUsed(_CACHE);
		
	
			?>
			</table>
<span style="left:50px;"><a href="index2.php?cache=set_all_cache">Обновить весь кэш</a></span><br />
					
		   </td>
        </tr>
</table></td></tr>