[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/tools/ -> file_verification.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$
  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  @set_time_limit(0);
  19  
  20  $page->add_breadcrumb_item($lang->file_verification, "index.php?module=tools-file_verification");
  21  
  22  $plugins->run_hooks("admin_tools_file_verification_begin");
  23  
  24  if(!$mybb->input['action'])
  25  {
  26      $plugins->run_hooks("admin_tools_file_verification_check");
  27      
  28      if($mybb->request_method == "post")
  29      {
  30          // User clicked no
  31          if($mybb->input['no'])
  32          {
  33              admin_redirect("index.php?module=tools-system_health");
  34          }
  35          
  36          $page->add_breadcrumb_item($lang->checking, "index.php?module=tools-file_verification");
  37          
  38          $page->output_header($lang->file_verification." - ".$lang->checking);
  39          
  40          $file = explode("\n", fetch_remote_file("http://www.mybb.com/checksums/release_mybb_{$mybb->version_code}.txt"));
  41          
  42          if(strstr($file[0], "<?xml") !== false || empty($file[0]))
  43          {
  44              $page->output_inline_error($lang->error_communication);
  45              $page->output_footer();
  46              exit;
  47          }
  48          
  49          // Parser-up our checksum file from the MyBB Server
  50          foreach($file as $line)
  51          {            
  52              $parts = explode(" ", $line, 2);
  53              if(empty($parts[0]) || empty($parts[1]))
  54              {
  55                  continue;
  56              }
  57              
  58              if(substr($parts[1], 0, 7) == "./admin")
  59              {
  60                  $parts[1] = "./{$mybb->config['admin_dir']}".substr($parts[1], 7);
  61              }
  62              
  63              if(file_exists(MYBB_ROOT."forums.php") && !file_exists(MYBB_ROOT."portal.php"))
  64              {
  65                  if(trim($parts[1]) == "./index.php")
  66                  {
  67                      $parts[1] = "./forums.php";
  68                  }
  69                  elseif($parts[1] == "./portal.php")
  70                  {
  71                      $parts[1] = "./index.php";
  72                  }
  73              }
  74              
  75              $checksums[trim($parts[1])][] = $parts[0];
  76          }
  77          
  78          $bad_files = verify_files();
  79          
  80          $table = new Table;
  81          $table->construct_header($lang->file);
  82          $table->construct_header($lang->status, array("class" => "align_center", "width" => 100));
  83          
  84          foreach($bad_files as $file)
  85          {
  86              switch($file['status'])
  87              {
  88                  case "changed":
  89                      $file['status'] = $lang->changed;
  90                      $color = "#F22B48";
  91                      break;
  92                  case "missing":
  93                      $file['status'] = $lang->missing;
  94                      $color = "#5B5658";
  95                      break;
  96              }
  97              
  98              $table->construct_cell("<strong><span style=\"color: {$color};\">".substr($file['path'], 2)."</span></strong>");
  99              
 100              $table->construct_cell("<strong><span style=\"color: {$color};\">{$file['status']}</span></strong>", array("class" => "align_center"));
 101              $table->construct_row();
 102          }
 103  
 104          $no_errors = false;
 105          if($table->num_rows() == 0)
 106          {
 107              $no_errors = true;
 108              $table->construct_cell($lang->no_corrupt_files_found, array('colspan' => 3));
 109              $table->construct_row();
 110          }
 111  
 112          if($no_errors)
 113          {
 114              $table->output($lang->file_verification.": ".$lang->no_problems_found);
 115          }
 116          else
 117          {
 118              $table->output($lang->file_verification.": ".$lang->found_problems);
 119          }
 120          
 121          $page->output_footer();
 122          exit;
 123      }
 124      
 125      $page->output_confirm_action("index.php?module=tools-file_verification", $lang->file_verification_message, $lang->file_verification);
 126  }
 127  
 128  ?>


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