includes/functions.php
changeset 599 52bffa6c499f
parent 593 4f9bec0d65c1
child 606 daf8c556ada7
equal deleted inserted replaced
598:4e5985fffc4d 599:52bffa6c499f
  4537   {
  4537   {
  4538     fetch_rank_data();
  4538     fetch_rank_data();
  4539   }
  4539   }
  4540 }
  4540 }
  4541 
  4541 
       
  4542 /**
       
  4543  * Function to purge all caches used in Enano. Useful for upgrades, maintenance, backing the site up, etc.
       
  4544  */
       
  4545 
       
  4546 function purge_all_caches()
       
  4547 {
       
  4548   if ( $dh = opendir(ENANO_ROOT . '/cache') )
       
  4549   {
       
  4550     $data_files = array(
       
  4551         'aes_decrypt.php',
       
  4552         'cache_anon_sidebar.php',
       
  4553         'cache_page_meta.php',
       
  4554         'cache_plugins.php',
       
  4555         'cache_ranks.php'
       
  4556       );
       
  4557     while ( $file = @readdir($dh) )
       
  4558     {
       
  4559       $fullpath = ENANO_ROOT . "/cache/$file";
       
  4560       // we don't want to mess with directories
       
  4561       if ( !is_file($fullpath) )
       
  4562         continue;
       
  4563       
       
  4564       // data files
       
  4565       if ( in_array($file, $data_files) )
       
  4566         unlink($fullpath);
       
  4567       // template files
       
  4568       else if ( preg_match('/\.(?:tpl|css)\.php$/', $file) )
       
  4569         unlink($fullpath);
       
  4570       // compressed javascript
       
  4571       else if ( preg_match('/^jsres_(?:[A-z0-9_-]+)\.js\.json$/', $file) )
       
  4572         unlink($fullpath);
       
  4573       // tinymce stuff
       
  4574       else if ( preg_match('/^tiny_mce_(?:[a-f0-9]+)\.gz$/', $file) )
       
  4575         unlink($fullpath);
       
  4576       // language files
       
  4577       else if ( preg_match('/^lang_json_(?:[a-f0-9]+?)\.php$/', $file) || preg_match('/^lang_(?:[0-9]+?)\.php$/', $file) )
       
  4578         unlink($fullpath);
       
  4579     }
       
  4580     return true;
       
  4581   }
       
  4582   return false;
       
  4583 }
       
  4584 
  4542 //die('<pre>Original:  01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>');
  4585 //die('<pre>Original:  01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>');
  4543 
  4586 
  4544 ?>
  4587 ?>