[ Index ]

PHP Cross Reference of MyBB 1.8.40

title

Body

[close]

/admin/modules/home/ -> index.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  $plugins->run_hooks("admin_home_index_begin");
  18  
  19  $sub_tabs['dashboard'] = array(
  20      'title' => $lang->dashboard,
  21      'link' => "index.php",
  22      'description' => $lang->dashboard_description
  23  );
  24  
  25  $sub_tabs['version_check'] = array(
  26      'title' => $lang->version_check,
  27      'link' => "index.php?module=home&amp;action=version_check",
  28      'description' => $lang->version_check_description
  29  );
  30  
  31  if($mybb->input['action'] == "version_check")
  32  {
  33      $plugins->run_hooks("admin_home_version_check_start");
  34  
  35      $current_version = rawurlencode($mybb->version_code);
  36  
  37      $updated_cache = array(
  38          "last_check" => TIME_NOW
  39      );
  40  
  41      $contents = fetch_remote_file("https://mybb.com/version_check.php");
  42  
  43      if(!$contents)
  44      {
  45          flash_message($lang->error_communication, 'error');
  46          admin_redirect('index.php');
  47      }
  48  
  49      $plugins->run_hooks("admin_home_version_check");
  50  
  51      $page->add_breadcrumb_item($lang->version_check, "index.php?module=home-version_check");
  52      $page->output_header($lang->version_check);
  53      $page->output_nav_tabs($sub_tabs, 'version_check');
  54  
  55      $contents = trim($contents);
  56  
  57      $parser = create_xml_parser($contents);
  58      $tree = $parser->get_tree();
  59  
  60      $latest_code = (int)$tree['mybb']['version_code']['value'];
  61      $latest_version = "<strong>".htmlspecialchars_uni($tree['mybb']['latest_version']['value'])."</strong> (".$latest_code.")";
  62      if($latest_code > $mybb->version_code)
  63      {
  64          $latest_version = "<span style=\"color: #C00;\">".$latest_version."</span>";
  65          $updated_cache['latest_version'] = $latest_version;
  66          $updated_cache['latest_version_code'] = $latest_code;
  67          $page->output_error("<p><em>{$lang->error_out_of_date}</em> {$lang->update_forum}</p>");
  68      }
  69      else
  70      {
  71          $latest_version = "<span style=\"color: green;\">".$latest_version."</span>";
  72          $page->output_success("<p><em>{$lang->success_up_to_date}</em></p>");
  73      }
  74  
  75      $table = new Table;
  76      $table->construct_header($lang->your_version);
  77      $table->construct_header($lang->latest_version);
  78  
  79      $table->construct_cell("<strong>".$mybb->version."</strong> (".$mybb->version_code.")");
  80      $table->construct_cell($latest_version);
  81      $table->construct_row();
  82  
  83      $table->output($lang->version_check);
  84  
  85      require_once  MYBB_ROOT."inc/class_feedparser.php";
  86  
  87      $feed_parser = new FeedParser();
  88      $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
  89  
  90      $updated_cache['news'] = array();
  91  
  92      if($feed_parser->error == '')
  93      {
  94          require_once  MYBB_ROOT . '/inc/class_parser.php';
  95          $post_parser = new postParser();
  96  
  97          foreach($feed_parser->items as $item)
  98          {
  99              if(!isset($updated_cache['news'][2]))
 100              {
 101                  $updated_cache['news'][] = array(
 102                      'title' => $item['title'],
 103                      'description' => $item['description'],
 104                      'link' => $item['link'],
 105                      'author' => $item['author'],
 106                      'dateline' => $item['date_timestamp'],
 107                  );
 108              }
 109  
 110              $stamp = '';
 111              if($item['date_timestamp'])
 112              {
 113                  $stamp = my_date('relative', (int)$item['date_timestamp']);
 114              }
 115  
 116              $link = htmlspecialchars_uni($item['link']);
 117              $title = htmlspecialchars_uni($item['title']);
 118              $description = htmlspecialchars_uni(strip_tags($item['description']));
 119  
 120              $table->construct_cell("<span style=\"font-size: 16px;\"><strong>{$title}</strong></span><br /><br />{$description}<strong><span style=\"float: right;\">{$stamp}</span><br /><br /><a href=\"{$link}\" target=\"_blank\" rel=\"noopener\">&raquo; {$lang->read_more}</a></strong>");
 121              $table->construct_row();
 122          }
 123      }
 124      else
 125      {
 126          $table->construct_cell("{$lang->error_fetch_news} <!-- error code: {$feed_parser->error} -->");
 127          $table->construct_row();
 128      }
 129  
 130      $cache->update("update_check", $updated_cache);
 131  
 132      $table->output($lang->latest_mybb_announcements);
 133      $page->output_footer();
 134  }
 135  elseif(!$mybb->input['action'])
 136  {
 137      $plugins->run_hooks("admin_home_index_start");
 138  
 139      if($mybb->request_method == "post" && isset($mybb->input['adminnotes']))
 140      {
 141          // Update Admin Notes cache
 142          $update_cache = array(
 143              "adminmessage" => $mybb->input['adminnotes']
 144          );
 145  
 146          $cache->update("adminnotes", $update_cache);
 147  
 148          $plugins->run_hooks("admin_home_index_start_begin");
 149  
 150          flash_message($lang->success_notes_updated, 'success');
 151          admin_redirect("index.php");
 152      }
 153  
 154      $page->add_breadcrumb_item($lang->dashboard);
 155      $page->output_header($lang->dashboard);
 156  
 157      $sub_tabs['dashboard'] = array(
 158          'title' => $lang->dashboard,
 159          'link' => "index.php",
 160          'description' => $lang->dashboard_description
 161      );
 162  
 163      $page->output_nav_tabs($sub_tabs, 'dashboard');
 164  
 165      // Load stats cache
 166      $stats = $cache->read("stats");
 167  
 168      $serverload = get_server_load();
 169  
 170      // Get the number of users
 171      $query = $db->simple_select("users", "COUNT(uid) AS numusers");
 172      $users = my_number_format($db->fetch_field($query, "numusers"));
 173  
 174      // Get the number of users awaiting validation
 175      $awaitingusers = $cache->read('awaitingactivation');
 176  
 177      if(isset($awaitingusers['time']) && $awaitingusers['time'] + 86400 < TIME_NOW)
 178      {
 179          $cache->update_awaitingactivation();
 180          $awaitingusers = $cache->read('awaitingactivation');
 181      }
 182  
 183      if(!empty($awaitingusers['users']))
 184      {
 185          $awaitingusers = (int)$awaitingusers['users'];
 186      }
 187      else
 188      {
 189          $awaitingusers = 0;
 190      }
 191  
 192      if($awaitingusers < 1)
 193      {
 194          $awaitingusers = 0;
 195      }
 196      else
 197      {
 198          $awaitingusers = my_number_format($awaitingusers);
 199      }
 200  
 201      // Get the number of new users for today
 202      $timecut = TIME_NOW - 86400;
 203      $query = $db->simple_select("users", "COUNT(uid) AS newusers", "regdate > '$timecut'");
 204      $newusers = my_number_format($db->fetch_field($query, "newusers"));
 205  
 206      // Get the number of active users today
 207      $query = $db->simple_select("users", "COUNT(uid) AS activeusers", "lastvisit > '$timecut'");
 208      $activeusers = my_number_format($db->fetch_field($query, "activeusers"));
 209  
 210      // Get the number of threads
 211      $threads = my_number_format($stats['numthreads']);
 212  
 213      // Get the number of unapproved threads
 214      $unapproved_threads = my_number_format($stats['numunapprovedthreads']);
 215  
 216      // Get the number of new threads for today
 217      $query = $db->simple_select("threads", "COUNT(*) AS newthreads", "dateline > '$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'");
 218      $newthreads = my_number_format($db->fetch_field($query, "newthreads"));
 219  
 220      // Get the number of posts
 221      $posts = my_number_format($stats['numposts']);
 222  
 223      // Get the number of unapproved posts
 224      if($stats['numunapprovedposts'] < 0)
 225      {
 226          $stats['numunapprovedposts'] = 0;
 227      }
 228  
 229      $unapproved_posts = my_number_format($stats['numunapprovedposts']);
 230  
 231      // Get the number of new posts for today
 232      $query = $db->simple_select("posts", "COUNT(*) AS newposts", "dateline > '$timecut' AND visible='1'");
 233      $newposts = my_number_format($db->fetch_field($query, "newposts"));
 234  
 235      // Get the number of reported post
 236      $query = $db->simple_select("reportedcontent", "COUNT(*) AS reported_posts", "type = 'post' OR type = ''");
 237      $reported_posts = my_number_format($db->fetch_field($query, "reported_posts"));
 238  
 239      // Get the number of reported posts that haven't been marked as read yet
 240      $query = $db->simple_select("reportedcontent", "COUNT(*) AS new_reported_posts", "reportstatus='0' AND (type = 'post' OR type = '')");
 241      $new_reported_posts = my_number_format($db->fetch_field($query, "new_reported_posts"));
 242  
 243      // Get the number and total file size of attachments
 244      $query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid > '0'");
 245      $attachs = $db->fetch_array($query);
 246      $attachs['spaceused'] = get_friendly_size($attachs['spaceused']);
 247      $approved_attachs = my_number_format($attachs['numattachs']);
 248  
 249      // Get the number of unapproved attachments
 250      $query = $db->simple_select("attachments", "COUNT(*) AS numattachs", "visible='0' AND pid > '0'");
 251      $unapproved_attachs = my_number_format($db->fetch_field($query, "numattachs"));
 252  
 253      // Fetch the last time an update check was run
 254      $update_check = $cache->read("update_check");
 255  
 256      // If last update check was greater than two weeks ago (14 days) show an alert
 257      if(isset($update_check['last_check']) && $update_check['last_check'] <= TIME_NOW-60*60*24*14)
 258      {
 259          $lang->last_update_check_two_weeks = $lang->sprintf($lang->last_update_check_two_weeks, "index.php?module=home&amp;action=version_check");
 260          $page->output_error("<p>{$lang->last_update_check_two_weeks}</p>");
 261      }
 262  
 263      // If the update check contains information about a newer version, show an alert
 264      if(isset($update_check['latest_version_code']) && $update_check['latest_version_code'] > $mybb->version_code)
 265      {
 266          $lang->new_version_available = $lang->sprintf($lang->new_version_available, "MyBB {$mybb->version}", "<a href=\"https://mybb.com/download\" target=\"_blank\" rel=\"noopener\">MyBB {$update_check['latest_version']}</a>");
 267          $page->output_error("<p><em>{$lang->new_version_available}</em></p>");
 268      }
 269  
 270      $plugins->run_hooks("admin_home_index_output_message");
 271  
 272      $adminmessage = $cache->read("adminnotes");
 273  
 274      if($adminmessage === false)
 275      {
 276          $adminmessage = array(
 277              'adminmessage' => '',
 278          );
 279      }
 280  
 281      $table = new Table;
 282      $table->construct_header($lang->mybb_server_stats, array("colspan" => 2));
 283      $table->construct_header($lang->forum_stats, array("colspan" => 2));
 284  
 285      $table->construct_cell("<strong>{$lang->mybb_version}</strong>", array('width' => '25%'));
 286      $table->construct_cell($mybb->version, array('width' => '25%'));
 287      $table->construct_cell("<strong>{$lang->threads}</strong>", array('width' => '25%'));
 288      $table->construct_cell("<strong>{$threads}</strong> {$lang->threads}<br /><strong>{$newthreads}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=threads\"><strong>{$unapproved_threads}</strong> {$lang->unapproved}</a>", array('width' => '25%'));
 289      $table->construct_row();
 290  
 291      $table->construct_cell("<strong>{$lang->php_version}</strong>", array('width' => '25%'));
 292      $table->construct_cell(PHP_VERSION, array('width' => '25%'));
 293      $table->construct_cell("<strong>{$lang->posts}</strong>", array('width' => '25%'));
 294  
 295      $table->construct_cell("<strong>{$posts}</strong> {$lang->posts}<br /><strong>{$newposts}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=posts\"><strong>{$unapproved_posts}</strong> {$lang->unapproved}</a><br /><strong>{$reported_posts}</strong> {$lang->reported_posts}<br /><strong>{$new_reported_posts}</strong> {$lang->unread_reports}", array('width' => '25%'));
 296      
 297      $table->construct_row();
 298  
 299      $table->construct_cell("<strong>{$lang->sql_engine}</strong>", array('width' => '25%'));
 300      $table->construct_cell($db->short_title." ".$db->get_version(), array('width' => '25%'));
 301      $table->construct_cell("<strong>{$lang->users}</strong>", array('width' => '25%'));
 302      $table->construct_cell("<a href=\"index.php?module=user-users\"><strong>{$users}</strong> {$lang->registered_users}</a><br /><strong>{$activeusers}</strong> {$lang->active_users}<br /><strong>{$newusers}</strong> {$lang->registrations_today}<br /><a href=\"index.php?module=user-awaiting_activation\"><strong>{$awaitingusers}</strong> {$lang->awaiting_activation}</a>", array('width' => '25%'));
 303      $table->construct_row();
 304  
 305      $table->construct_cell("<strong>{$lang->server_load}</strong>", array('width' => '25%'));
 306      $table->construct_cell($serverload, array('width' => '25%'));
 307      $table->construct_cell("<strong>{$lang->attachments}</strong>", array('width' => '25%'));
 308      $table->construct_cell("<strong>{$approved_attachs}</strong> {$lang->attachments}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=attachments\"><strong>{$unapproved_attachs}</strong> {$lang->unapproved}</a><br /><strong>{$attachs['spaceused']}</strong> {$lang->used}", array('width' => '25%'));
 309      $table->construct_row();
 310      
 311      if(isset($_SERVER['SERVER_SOFTWARE'])) 
 312      {
 313          $table->construct_cell("<strong>{$lang->server_software}</strong>", array('width' => '25%'));
 314          $table->construct_cell($_SERVER['SERVER_SOFTWARE'], array('colspan' => 3));
 315          $table->construct_row();
 316      }
 317  
 318      $table->output($lang->dashboard);
 319  
 320      echo '
 321      <div class="float_right" style="width: 48%;">';
 322  
 323      $table = new Table;
 324      $table->construct_header($lang->admin_notes_public);
 325  
 326      $form = new Form("index.php", "post");
 327      $table->construct_cell($form->generate_text_area("adminnotes", $adminmessage['adminmessage'], array('style' => 'width: 99%; height: 200px;')));
 328      $table->construct_row();
 329  
 330      $table->output($lang->admin_notes);
 331  
 332      $buttons[] = $form->generate_submit_button($lang->save_notes);
 333      $form->output_submit_wrapper($buttons);
 334      $form->end();
 335  
 336      echo '</div>
 337      <div class="float_left" style="width: 48%;">';
 338  
 339      // Latest news widget
 340      $table = new Table;
 341      $table->construct_header($lang->news_description);
 342  
 343      if(!empty($update_check['news']) && is_array($update_check['news']))
 344      {
 345          foreach($update_check['news'] as $news_item)
 346          {
 347              $posted = my_date('relative', (int)$news_item['dateline']);
 348              $link = htmlspecialchars_uni($news_item['link']);
 349              $title = htmlspecialchars_uni($news_item['title']);
 350              $description = htmlspecialchars_uni(strip_tags($news_item['description']));
 351  
 352              $table->construct_cell("<strong><a href=\"{$link}\" target=\"_blank\" rel=\"noopener\">{$title}</a></strong><br /><span class=\"smalltext\">{$posted}</span>");
 353              $table->construct_row();
 354  
 355              $table->construct_cell($description);
 356              $table->construct_row();
 357          }
 358      }
 359      else
 360      {
 361          $table->construct_cell($lang->no_announcements);
 362          $table->construct_row();
 363      }
 364  
 365      $table->output($lang->latest_mybb_announcements);
 366      echo '</div>';
 367  
 368      $page->output_footer();
 369  }


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