[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/tools/ -> cache.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id: cache.php 5297 2010-12-28 22:01:14Z Tomm $
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  $page->add_breadcrumb_item($lang->cache_manager, "index.php?module=tools-cache");
  19  
  20  $plugins->run_hooks("admin_tools_cache_begin");
  21  
  22  if($mybb->input['action'] == 'view')
  23  {
  24      $plugins->run_hooks("admin_tools_cache_view");
  25      
  26      if(!trim($mybb->input['title']))
  27      {
  28          flash_message($lang->error_no_cache_specified, 'error');
  29          admin_redirect("index.php?module=tools-cache");
  30      }
  31      
  32      $query = $db->simple_select("datacache", "*", "title = '".$db->escape_string($mybb->input['title'])."'");
  33      $cacheitem = $db->fetch_array($query);
  34      
  35      if(!$cacheitem)
  36      {
  37          flash_message($lang->error_incorrect_cache, 'error');
  38          admin_redirect("index.php?module=tools-cache");
  39      }
  40      
  41      $cachecontents = unserialize($cacheitem['cache']);
  42      if(empty($cachecontents))
  43      {
  44          $cachecontents = $lang->error_empty_cache;
  45      }
  46      ob_start();
  47      print_r($cachecontents);
  48      $cachecontents = htmlspecialchars_uni(ob_get_contents());
  49      ob_end_clean();
  50      
  51      $page->add_breadcrumb_item($lang->view);    
  52      $page->output_header($lang->cache_manager);
  53  
  54  
  55      $table = new Table;
  56  
  57      $table->construct_cell("<pre>\n{$cachecontents}\n</pre>");
  58      $table->construct_row();
  59      $table->output($lang->cache." {$cacheitem['title']}");
  60      
  61      $page->output_footer();
  62      
  63  }
  64  
  65  if($mybb->input['action'] == "rebuild" || $mybb->input['action'] == "reload")
  66  {
  67      if(!verify_post_check($mybb->input['my_post_key']))
  68      {
  69          flash_message($lang->invalid_post_verify_key2, 'error');
  70          admin_redirect("index.php?module=tools-cache");
  71      }
  72      
  73      $plugins->run_hooks("admin_tools_cache_rebuild");
  74      
  75      if(method_exists($cache, "update_{$mybb->input['title']}"))
  76      {
  77          $func = "update_{$mybb->input['title']}";
  78          $cache->$func();
  79          
  80          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
  81  
  82          // Log admin action
  83          log_admin_action($mybb->input['title']);
  84  
  85          flash_message($lang->success_cache_rebuilt, 'success');
  86          admin_redirect("index.php?module=tools-cache");
  87      }
  88      elseif(method_exists($cache, "reload_{$mybb->input['title']}"))
  89      {
  90          $func = "reload_{$mybb->input['title']}";
  91          
  92          $cache->$func();
  93          
  94          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
  95  
  96          // Log admin action
  97          log_admin_action($mybb->input['title']);
  98  
  99          flash_message($lang->success_cache_reloaded, 'success');
 100          admin_redirect("index.php?module=tools-cache");
 101      }
 102      else
 103      {
 104          flash_message($lang->error_cannot_rebuild, 'error');
 105          admin_redirect("index.php?module=tools-cache");
 106      }
 107  }
 108  
 109  if(!$mybb->input['action'])
 110  {
 111      $plugins->run_hooks("admin_tools_cache_start");
 112      
 113      $page->output_header($lang->cache_manager);
 114      
 115      $sub_tabs['cache_manager'] = array(
 116          'title' => $lang->cache_manager,
 117          'link' => "index.php?module=tools-cache",
 118          'description' => $lang->cache_manager_description
 119      );
 120  
 121      $page->output_nav_tabs($sub_tabs, 'cache_manager');
 122  
 123      $table = new Table;
 124      $table->construct_header($lang->name);
 125      $table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
 126      $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 127  
 128      $query = $db->simple_select("datacache");
 129      while($cacheitem = $db->fetch_array($query))
 130      {
 131          $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=".urlencode($cacheitem['title'])."\">{$cacheitem['title']}</a></strong>");
 132          $table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
 133          
 134          if(method_exists($cache, "update_".$cacheitem['title']))
 135          {
 136              $table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=rebuild&amp;title=".urlencode($cacheitem['title'])."&amp;my_post_key={$mybb->post_code}\">".$lang->rebuild_cache."</a>", array("class" => "align_center"));
 137          }
 138          elseif(method_exists($cache, "reload_".$cacheitem['title']))
 139          {
 140              $table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=reload&amp;title=".urlencode($cacheitem['title'])."&amp;my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));
 141          }
 142          else
 143          {
 144              $table->construct_cell("");
 145          }        
 146          
 147          $table->construct_row();
 148      }
 149      $table->output($lang->cache_manager);
 150      
 151      $page->output_footer();
 152  }
 153  
 154  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1