[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

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

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $page->add_breadcrumb_item($lang->cache_manager, "index.php?module=tools-cache");
  18  
  19  $plugins->run_hooks("admin_tools_cache_begin");
  20  
  21  if($mybb->input['action'] == 'view')
  22  {
  23      if(!trim($mybb->input['title']))
  24      {
  25          flash_message($lang->error_no_cache_specified, 'error');
  26          admin_redirect("index.php?module=tools-cache");
  27      }
  28  
  29      $plugins->run_hooks("admin_tools_cache_view");
  30  
  31      // Rebuilds forum settings
  32      if($mybb->input['title'] == 'settings')
  33      {
  34          $cachedsettings = (array)$mybb->settings;
  35          if(isset($cachedsettings['internal']))
  36          {
  37              unset($cachedsettings['internal']);
  38          }
  39  
  40          $cacheitem = array(
  41              'title'    => 'settings',
  42              'cache'    => my_serialize($cachedsettings)
  43          );
  44      }
  45      else
  46      {
  47          $query = $db->simple_select("datacache", "*", "title = '".$db->escape_string($mybb->input['title'])."'");
  48          $cacheitem = $db->fetch_array($query);
  49      }
  50  
  51      if(!$cacheitem)
  52      {
  53          flash_message($lang->error_incorrect_cache, 'error');
  54          admin_redirect("index.php?module=tools-cache");
  55      }
  56  
  57      // use native_unserialize() over my_unserialize() for performance reasons
  58      $cachecontents = native_unserialize($cacheitem['cache']);
  59  
  60      if(empty($cachecontents))
  61      {
  62          $cachecontents = $lang->error_empty_cache;
  63      }
  64      ob_start();
  65      print_r($cachecontents);
  66      $cachecontents = htmlspecialchars_uni(ob_get_contents());
  67      ob_end_clean();
  68  
  69      $page->add_breadcrumb_item($lang->view);
  70      $page->output_header($lang->cache_manager);
  71  
  72      $table = new Table;
  73  
  74      $table->construct_cell("<pre>\n{$cachecontents}\n</pre>");
  75      $table->construct_row();
  76      $table->output($lang->cache." {$cacheitem['title']}");
  77  
  78      $page->output_footer();
  79  
  80  }
  81  
  82  if($mybb->input['action'] == "rebuild" || $mybb->input['action'] == "reload")
  83  {
  84      if(!verify_post_check($mybb->get_input('my_post_key')))
  85      {
  86          flash_message($lang->invalid_post_verify_key2, 'error');
  87          admin_redirect("index.php?module=tools-cache");
  88      }
  89  
  90      $plugins->run_hooks("admin_tools_cache_rebuild");
  91  
  92      // Rebuilds forum settings
  93      if($mybb->input['title'] == 'settings')
  94      {
  95          rebuild_settings();
  96  
  97          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
  98  
  99          // Log admin action
 100          log_admin_action($mybb->input['title']);
 101  
 102          flash_message($lang->success_cache_reloaded, 'success');
 103          admin_redirect("index.php?module=tools-cache");
 104      }
 105  
 106      if(method_exists($cache, "update_{$mybb->input['title']}"))
 107      {
 108          $func = "update_{$mybb->input['title']}";
 109          $cache->$func();
 110  
 111          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 112  
 113          // Log admin action
 114          log_admin_action($mybb->input['title']);
 115  
 116          flash_message($lang->success_cache_rebuilt, 'success');
 117          admin_redirect("index.php?module=tools-cache");
 118      }
 119      elseif(method_exists($cache, "reload_{$mybb->input['title']}"))
 120      {
 121          $func = "reload_{$mybb->input['title']}";
 122          $cache->$func();
 123  
 124          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 125  
 126          // Log admin action
 127          log_admin_action($mybb->input['title']);
 128  
 129          flash_message($lang->success_cache_reloaded, 'success');
 130          admin_redirect("index.php?module=tools-cache");
 131      }
 132      elseif(function_exists("update_{$mybb->input['title']}"))
 133      {
 134          $func = "update_{$mybb->input['title']}";
 135          $func();
 136  
 137          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 138  
 139          // Log admin action
 140          log_admin_action($mybb->input['title']);
 141  
 142          flash_message($lang->success_cache_rebuilt, 'success');
 143          admin_redirect("index.php?module=tools-cache");
 144      }
 145      elseif(function_exists("reload_{$mybb->input['title']}"))
 146      {
 147          $func = "reload_{$mybb->input['title']}";
 148          $func();
 149  
 150          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 151  
 152          // Log admin action
 153          log_admin_action($mybb->input['title']);
 154  
 155          flash_message($lang->success_cache_reloaded, 'success');
 156          admin_redirect("index.php?module=tools-cache");
 157      }
 158      else
 159      {
 160          flash_message($lang->error_cannot_rebuild, 'error');
 161          admin_redirect("index.php?module=tools-cache");
 162      }
 163  }
 164  
 165  if($mybb->input['action'] == "rebuild_all")
 166  {
 167      if(!verify_post_check($mybb->get_input('my_post_key')))
 168      {
 169          flash_message($lang->invalid_post_verify_key2, 'error');
 170          admin_redirect("index.php?module=tools-cache");
 171      }
 172  
 173      $plugins->run_hooks("admin_tools_cache_rebuild_all");
 174  
 175      $query = $db->simple_select("datacache");
 176      while($cacheitem = $db->fetch_array($query))
 177      {
 178          if(method_exists($cache, "update_{$cacheitem['title']}"))
 179          {
 180              $func = "update_{$cacheitem['title']}";
 181              $cache->$func();
 182          }
 183          elseif(method_exists($cache, "reload_{$cacheitem['title']}"))
 184          {
 185              $func = "reload_{$cacheitem['title']}";
 186              $cache->$func();
 187          }
 188          elseif(function_exists("update_{$cacheitem['title']}"))
 189          {
 190              $func = "update_{$cacheitem['title']}";
 191              $func();
 192          }
 193          elseif(function_exists("reload_{$cacheitem['title']}"))
 194          {
 195              $func = "reload_{$cacheitem['title']}";
 196              $func();
 197          }
 198      }
 199  
 200      // Rebuilds forum settings
 201      rebuild_settings();
 202  
 203      $plugins->run_hooks("admin_tools_cache_rebuild_all_commit");
 204  
 205      // Log admin action
 206      log_admin_action();
 207  
 208      flash_message($lang->success_cache_reloaded, 'success');
 209      admin_redirect("index.php?module=tools-cache");
 210  }
 211  
 212  if(!$mybb->input['action'])
 213  {
 214      $page->output_header($lang->cache_manager);
 215  
 216      $sub_tabs['cache_manager'] = array(
 217          'title' => $lang->cache_manager,
 218          'link' => "index.php?module=tools-cache",
 219          'description' => $lang->cache_manager_description
 220      );
 221  
 222      $plugins->run_hooks("admin_tools_cache_start");
 223  
 224      $page->output_nav_tabs($sub_tabs, 'cache_manager');
 225  
 226      $table = new Table;
 227      $table->construct_header($lang->name);
 228      $table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
 229      $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 230  
 231      $query = $db->simple_select("datacache", "*", "", array("order_by" => "title"));
 232      while($cacheitem = $db->fetch_array($query))
 233      {
 234          $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=".urlencode($cacheitem['title'])."\">{$cacheitem['title']}</a></strong>");
 235          $table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
 236  
 237          if(method_exists($cache, "update_".$cacheitem['title']))
 238          {
 239              $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"));
 240          }
 241          elseif(method_exists($cache, "reload_".$cacheitem['title']))
 242          {
 243              $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"));
 244          }
 245          elseif(function_exists("update_".$cacheitem['title']))
 246          {
 247              $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"));
 248          }
 249          elseif(function_exists("reload_".$cacheitem['title']))
 250          {
 251              $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"));
 252          }
 253          else
 254          {
 255              $table->construct_cell("");
 256          }
 257  
 258          $table->construct_row();
 259      }
 260  
 261      // Rebuilds forum settings
 262      $cachedsettings = (array)$mybb->settings;
 263      if(isset($cachedsettings['internal']))
 264      {
 265          unset($cachedsettings['internal']);
 266      }
 267  
 268      $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=settings\">settings</a></strong>");
 269      $table->construct_cell(get_friendly_size(strlen(my_serialize($cachedsettings))), array("class" => "align_center"));
 270      $table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=reload&amp;title=settings&amp;my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));
 271  
 272      $table->construct_row();
 273  
 274      $table->output("<div style=\"float: right;\"><small><a href=\"index.php?module=tools-cache&amp;action=rebuild_all&amp;my_post_key={$mybb->post_code}\">".$lang->rebuild_reload_all."</a></small></div>".$lang->cache_manager);
 275  
 276      $page->output_footer();
 277  }
 278  


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref