includes/functions.php
changeset 613 c08670a77871
parent 610 de33b0d26741
child 620 58852672ff12
equal deleted inserted replaced
612:3e73e4996d64 613:c08670a77871
  4563   $fh = @fopen( ENANO_ROOT . '/cache/cache_ranks.php', 'w' );
  4563   $fh = @fopen( ENANO_ROOT . '/cache/cache_ranks.php', 'w' );
  4564   if ( !$fh )
  4564   if ( !$fh )
  4565     return false;
  4565     return false;
  4566   fwrite($fh, $ranks_exported);
  4566   fwrite($fh, $ranks_exported);
  4567   fclose($fh);
  4567   fclose($fh);
       
  4568   
       
  4569   return true;
  4568 }
  4570 }
  4569 
  4571 
  4570 /**
  4572 /**
  4571  * Loads the rank data, first attempting the cache file and then the database.
  4573  * Loads the rank data, first attempting the cache file and then the database.
  4572  */
  4574  */
  4587  * Function to purge all caches used in Enano. Useful for upgrades, maintenance, backing the site up, etc.
  4589  * Function to purge all caches used in Enano. Useful for upgrades, maintenance, backing the site up, etc.
  4588  */
  4590  */
  4589 
  4591 
  4590 function purge_all_caches()
  4592 function purge_all_caches()
  4591 {
  4593 {
       
  4594   global $cache;
  4592   if ( $dh = opendir(ENANO_ROOT . '/cache') )
  4595   if ( $dh = opendir(ENANO_ROOT . '/cache') )
  4593   {
  4596   {
       
  4597     $cache->purge('page_meta');
       
  4598     $cache->purge('anon_sidebar');
       
  4599     $cache->purge('plugins');
       
  4600     
  4594     $data_files = array(
  4601     $data_files = array(
  4595         'aes_decrypt.php',
  4602         'aes_decrypt.php',
  4596         'cache_anon_sidebar.php',
  4603         // ranks cache is stored using a custom engine (not enano's default cache)
  4597         'cache_page_meta.php',
       
  4598         'cache_plugins.php',
       
  4599         'cache_ranks.php'
  4604         'cache_ranks.php'
  4600       );
  4605       );
  4601     while ( $file = @readdir($dh) )
  4606     while ( $file = @readdir($dh) )
  4602     {
  4607     {
  4603       $fullpath = ENANO_ROOT . "/cache/$file";
  4608       $fullpath = ENANO_ROOT . "/cache/$file";
  4616         unlink($fullpath);
  4621         unlink($fullpath);
  4617       // tinymce stuff
  4622       // tinymce stuff
  4618       else if ( preg_match('/^tiny_mce_(?:[a-f0-9]+)\.gz$/', $file) )
  4623       else if ( preg_match('/^tiny_mce_(?:[a-f0-9]+)\.gz$/', $file) )
  4619         unlink($fullpath);
  4624         unlink($fullpath);
  4620       // language files
  4625       // language files
  4621       else if ( preg_match('/^lang_json_(?:[a-f0-9]+?)\.php$/', $file) || preg_match('/^lang_(?:[0-9]+?)\.php$/', $file) )
  4626       else if ( preg_match('/^lang_json_(?:[a-f0-9]+?)\.php$/', $file) || preg_match('/^(?:cache_)?lang_(?:[0-9]+?)\.php$/', $file) )
  4622         unlink($fullpath);
  4627         unlink($fullpath);
  4623     }
  4628     }
  4624     return true;
  4629     return true;
  4625   }
  4630   }
  4626   return false;
  4631   return false;