[ Index ]

PHP Cross Reference of MyBB 1.8.30

title

Body

[close]

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


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