[ Index ]

PHP Cross Reference of MyBB 1.8.27

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      $cachecontents = unserialize($cacheitem['cache']);
  58      if(empty($cachecontents))
  59      {
  60          $cachecontents = $lang->error_empty_cache;
  61      }
  62      ob_start();
  63      print_r($cachecontents);
  64      $cachecontents = htmlspecialchars_uni(ob_get_contents());
  65      ob_end_clean();
  66  
  67      $page->add_breadcrumb_item($lang->view);
  68      $page->output_header($lang->cache_manager);
  69  
  70      $table = new Table;
  71  
  72      $table->construct_cell("<pre>\n{$cachecontents}\n</pre>");
  73      $table->construct_row();
  74      $table->output($lang->cache." {$cacheitem['title']}");
  75  
  76      $page->output_footer();
  77  
  78  }
  79  
  80  if($mybb->input['action'] == "rebuild" || $mybb->input['action'] == "reload")
  81  {
  82      if(!verify_post_check($mybb->input['my_post_key']))
  83      {
  84          flash_message($lang->invalid_post_verify_key2, 'error');
  85          admin_redirect("index.php?module=tools-cache");
  86      }
  87  
  88      $plugins->run_hooks("admin_tools_cache_rebuild");
  89  
  90      // Rebuilds forum settings
  91      if($mybb->input['title'] == 'settings')
  92      {
  93          rebuild_settings();
  94  
  95          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
  96  
  97          // Log admin action
  98          log_admin_action($mybb->input['title']);
  99  
 100          flash_message($lang->success_cache_reloaded, 'success');
 101          admin_redirect("index.php?module=tools-cache");
 102      }
 103  
 104      if(method_exists($cache, "update_{$mybb->input['title']}"))
 105      {
 106          $func = "update_{$mybb->input['title']}";
 107          $cache->$func();
 108  
 109          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 110  
 111          // Log admin action
 112          log_admin_action($mybb->input['title']);
 113  
 114          flash_message($lang->success_cache_rebuilt, 'success');
 115          admin_redirect("index.php?module=tools-cache");
 116      }
 117      elseif(method_exists($cache, "reload_{$mybb->input['title']}"))
 118      {
 119          $func = "reload_{$mybb->input['title']}";
 120          $cache->$func();
 121  
 122          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 123  
 124          // Log admin action
 125          log_admin_action($mybb->input['title']);
 126  
 127          flash_message($lang->success_cache_reloaded, 'success');
 128          admin_redirect("index.php?module=tools-cache");
 129      }
 130      elseif(function_exists("update_{$mybb->input['title']}"))
 131      {
 132          $func = "update_{$mybb->input['title']}";
 133          $func();
 134  
 135          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 136  
 137          // Log admin action
 138          log_admin_action($mybb->input['title']);
 139  
 140          flash_message($lang->success_cache_rebuilt, 'success');
 141          admin_redirect("index.php?module=tools-cache");
 142      }
 143      elseif(function_exists("reload_{$mybb->input['title']}"))
 144      {
 145          $func = "reload_{$mybb->input['title']}";
 146          $func();
 147  
 148          $plugins->run_hooks("admin_tools_cache_rebuild_commit");
 149  
 150          // Log admin action
 151          log_admin_action($mybb->input['title']);
 152  
 153          flash_message($lang->success_cache_reloaded, 'success');
 154          admin_redirect("index.php?module=tools-cache");
 155      }
 156      else
 157      {
 158          flash_message($lang->error_cannot_rebuild, 'error');
 159          admin_redirect("index.php?module=tools-cache");
 160      }
 161  }
 162  
 163  if($mybb->input['action'] == "rebuild_all")
 164  {
 165      if(!verify_post_check($mybb->input['my_post_key']))
 166      {
 167          flash_message($lang->invalid_post_verify_key2, 'error');
 168          admin_redirect("index.php?module=tools-cache");
 169      }
 170  
 171      $plugins->run_hooks("admin_tools_cache_rebuild_all");
 172  
 173      $query = $db->simple_select("datacache");
 174      while($cacheitem = $db->fetch_array($query))
 175      {
 176          if(method_exists($cache, "update_{$cacheitem['title']}"))
 177          {
 178              $func = "update_{$cacheitem['title']}";
 179              $cache->$func();
 180          }
 181          elseif(method_exists($cache, "reload_{$cacheitem['title']}"))
 182          {
 183              $func = "reload_{$cacheitem['title']}";
 184              $cache->$func();
 185          }
 186          elseif(function_exists("update_{$cacheitem['title']}"))
 187          {
 188              $func = "update_{$cacheitem['title']}";
 189              $func();
 190          }
 191          elseif(function_exists("reload_{$cacheitem['title']}"))
 192          {
 193              $func = "reload_{$cacheitem['title']}";
 194              $func();
 195          }
 196      }
 197  
 198      // Rebuilds forum settings
 199      rebuild_settings();
 200  
 201      $plugins->run_hooks("admin_tools_cache_rebuild_all_commit");
 202  
 203      // Log admin action
 204      log_admin_action();
 205  
 206      flash_message($lang->success_cache_reloaded, 'success');
 207      admin_redirect("index.php?module=tools-cache");
 208  }
 209  
 210  if(!$mybb->input['action'])
 211  {
 212      $page->output_header($lang->cache_manager);
 213  
 214      $sub_tabs['cache_manager'] = array(
 215          'title' => $lang->cache_manager,
 216          'link' => "index.php?module=tools-cache",
 217          'description' => $lang->cache_manager_description
 218      );
 219  
 220      $plugins->run_hooks("admin_tools_cache_start");
 221  
 222      $page->output_nav_tabs($sub_tabs, 'cache_manager');
 223  
 224      $table = new Table;
 225      $table->construct_header($lang->name);
 226      $table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
 227      $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 228  
 229      $query = $db->simple_select("datacache");
 230      while($cacheitem = $db->fetch_array($query))
 231      {
 232          $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=".urlencode($cacheitem['title'])."\">{$cacheitem['title']}</a></strong>");
 233          $table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
 234  
 235          if(method_exists($cache, "update_".$cacheitem['title']))
 236          {
 237              $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"));
 238          }
 239          elseif(method_exists($cache, "reload_".$cacheitem['title']))
 240          {
 241              $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"));
 242          }
 243          elseif(function_exists("update_".$cacheitem['title']))
 244          {
 245              $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"));
 246          }
 247          elseif(function_exists("reload_".$cacheitem['title']))
 248          {
 249              $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"));
 250          }
 251          else
 252          {
 253              $table->construct_cell("");
 254          }
 255  
 256          $table->construct_row();
 257      }
 258  
 259      // Rebuilds forum settings
 260      $cachedsettings = (array)$mybb->settings;
 261      if(isset($cachedsettings['internal']))
 262      {
 263          unset($cachedsettings['internal']);
 264      }
 265  
 266      $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=settings\">settings</a></strong>");
 267      $table->construct_cell(get_friendly_size(strlen(my_serialize($cachedsettings))), array("class" => "align_center"));
 268      $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"));
 269  
 270      $table->construct_row();
 271  
 272      $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);
 273  
 274      $page->output_footer();
 275  }
 276  


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