[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/home/ -> index.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  $plugins->run_hooks("admin_home_index_begin");
  19  
  20  if(!$mybb->input['action'])
  21  {
  22      $plugins->run_hooks("admin_home_index_start");
  23      
  24      if($mybb->request_method == "post" && isset($mybb->input['adminnotes']))
  25      {
  26          // Update Admin Notes cache
  27          $update_cache = array(
  28              "adminmessage" => $mybb->input['adminnotes']
  29          );
  30          
  31          $cache->update("adminnotes", $update_cache);
  32          
  33          $plugins->run_hooks("admin_home_index_start_begin");
  34      
  35          flash_message($lang->success_notes_updated, 'success');
  36          admin_redirect("index.php");
  37      }
  38      
  39      $page->add_breadcrumb_item($lang->dashboard);
  40      $page->output_header($lang->dashboard);
  41      
  42      $sub_tabs['dashboard'] = array(
  43          'title' => $lang->dashboard,
  44          'link' => "index.php",
  45          'description' => $lang->dashboard_description
  46      );
  47  
  48      $page->output_nav_tabs($sub_tabs, 'dashboard');
  49      
  50      // Load stats cache
  51      $stats = $cache->read("stats");
  52      
  53      $serverload = get_server_load();
  54      
  55      // Get the number of users
  56      $query = $db->simple_select("users", "COUNT(uid) AS numusers");
  57      $users = my_number_format($db->fetch_field($query, "numusers"));
  58  
  59      // Get the number of users awaiting validation
  60      $query = $db->simple_select("users", "COUNT(uid) AS awaitingusers", "usergroup='5'");
  61      $awaitingusers = my_number_format($db->fetch_field($query, "awaitingusers"));
  62  
  63      // Get the number of new users for today
  64      $timecut = TIME_NOW - 86400;
  65      $query = $db->simple_select("users", "COUNT(uid) AS newusers", "regdate > '$timecut'");
  66      $newusers = my_number_format($db->fetch_field($query, "newusers"));
  67  
  68      // Get the number of active users today
  69      $query = $db->simple_select("users", "COUNT(uid) AS activeusers", "lastvisit > '$timecut'");
  70      $activeusers = my_number_format($db->fetch_field($query, "activeusers"));
  71  
  72      // Get the number of threads
  73      $threads = my_number_format($stats['numthreads']);
  74  
  75      // Get the number of unapproved threads
  76      $unapproved_threads = my_number_format($stats['numunapprovedthreads']);
  77  
  78      // Get the number of new threads for today
  79      $query = $db->simple_select("threads", "COUNT(*) AS newthreads", "dateline > '$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'");
  80      $newthreads = my_number_format($db->fetch_field($query, "newthreads"));
  81  
  82      // Get the number of posts
  83      $posts = my_number_format($stats['numposts']);
  84  
  85      // Get the number of unapproved posts
  86      if($stats['numunapprovedposts'] < 0)
  87      {
  88          $status['numunapprovedposts'] = 0;
  89      }
  90      
  91      $unapproved_posts = my_number_format($stats['numunapprovedposts']);
  92  
  93      // Get the number of new posts for today
  94      $query = $db->simple_select("posts", "COUNT(*) AS newposts", "dateline > '$timecut' AND visible='1'");
  95      $newposts = my_number_format($db->fetch_field($query, "newposts"));
  96  
  97      // Get the number and total file size of attachments
  98      $query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid > '0'");
  99      $attachs = $db->fetch_array($query);
 100      $attachs['spaceused'] = get_friendly_size($attachs['spaceused']);
 101  
 102      // Get the number of unapproved attachments
 103      $query = $db->simple_select("attachments", "COUNT(*) AS numattachs", "visible='0' AND pid > '0'");
 104      $unapproved_attachs = my_number_format($db->fetch_field($query, "numattachs"));
 105  
 106      // Fetch the last time an update check was run
 107      $update_check = $cache->read("update_check");
 108  
 109      // If last update check was greater than two weeks ago (14 days) show an alert
 110      if(isset($update_check['last_check']) && $update_check['last_check'] <= TIME_NOW-60*60*24*14)
 111      {
 112          $lang->last_update_check_two_weeks = $lang->sprintf($lang->last_update_check_two_weeks, "index.php?module=home-version_check");
 113          $page->output_error("<p>{$lang->last_update_check_two_weeks}</p>");
 114      }
 115  
 116      // If the update check contains information about a newer version, show an alert
 117      if(isset($update_check['latest_version_code']) && $update_check['latest_version_code'] > $mybb->version_code)
 118      {
 119          $lang->new_version_available = $lang->sprintf($lang->new_version_available, "MyBB {$mybb->version}", "<a href=\"http://mybb.com/downloads\" target=\"_blank\">MyBB {$update_check['latest_version']}</a>");
 120          $page->output_error("<p><em>{$lang->new_version_available}</em></p>");
 121      }
 122      
 123      $adminmessage = $cache->read("adminnotes");
 124  
 125      $table = new Table;
 126      $table->construct_header($lang->mybb_server_stats, array("colspan" => 2));
 127      $table->construct_header($lang->forum_stats, array("colspan" => 2));
 128      
 129      $table->construct_cell("<strong>{$lang->mybb_version}</strong>", array('width' => '25%'));
 130      $table->construct_cell($mybb->version, array('width' => '25%'));
 131      $table->construct_cell("<strong>{$lang->threads}</strong>", array('width' => '25%'));
 132      $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%'));
 133      $table->construct_row();
 134      
 135      $table->construct_cell("<strong>{$lang->php_version}</strong>", array('width' => '25%'));
 136      $table->construct_cell(PHP_VERSION, array('width' => '25%'));
 137      $table->construct_cell("<strong>{$lang->posts}</strong>", array('width' => '25%'));
 138      $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>", array('width' => '25%'));
 139      $table->construct_row();
 140      
 141      $table->construct_cell("<strong>{$lang->sql_engine}</strong>", array('width' => '25%'));
 142      $table->construct_cell($db->short_title." ".$db->get_version(), array('width' => '25%'));
 143      $table->construct_cell("<strong>{$lang->users}</strong>", array('width' => '25%'));
 144      $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-users&amp;action=search&amp;results=1&amp;conditions=".urlencode(serialize(array('usergroup' => '5')))."&amp;from=home\"><strong>{$awaitingusers}</strong> {$lang->awaiting_activation}</a>", array('width' => '25%'));
 145      $table->construct_row();
 146      
 147      $table->construct_cell("<strong>{$lang->server_load}</strong>", array('width' => '25%'));
 148      $table->construct_cell($serverload, array('width' => '25%'));
 149      $table->construct_cell("<strong>{$lang->attachments}</strong>", array('width' => '25%'));
 150      $table->construct_cell("<strong>{$attachs['numattachs']}</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%'));
 151      $table->construct_row();
 152      
 153      $table->output($lang->dashboard);
 154      
 155      $table->construct_header($lang->admin_notes_public);
 156      
 157      $form = new Form("index.php", "post");
 158      $table->construct_cell($form->generate_text_area("adminnotes", $adminmessage['adminmessage'], array('style' => 'width: 99%; height: 200px;')));
 159      $table->construct_row();
 160      
 161      $table->output($lang->admin_notes);    
 162      
 163      $buttons[] = $form->generate_submit_button($lang->save_notes);
 164      $form->output_submit_wrapper($buttons);
 165      
 166      $form->end();
 167      
 168      $page->output_footer();
 169  }
 170  ?>


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