[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
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&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\">» {$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(!empty($awaitingusers['users'])) 178 { 179 $awaitingusers = (int)$awaitingusers['users']; 180 } 181 else 182 { 183 $awaitingusers = 0; 184 } 185 186 if($awaitingusers < 1) 187 { 188 $awaitingusers = 0; 189 } 190 else 191 { 192 $awaitingusers = my_number_format($awaitingusers); 193 } 194 195 // Get the number of new users for today 196 $timecut = TIME_NOW - 86400; 197 $query = $db->simple_select("users", "COUNT(uid) AS newusers", "regdate > '$timecut'"); 198 $newusers = my_number_format($db->fetch_field($query, "newusers")); 199 200 // Get the number of active users today 201 $query = $db->simple_select("users", "COUNT(uid) AS activeusers", "lastvisit > '$timecut'"); 202 $activeusers = my_number_format($db->fetch_field($query, "activeusers")); 203 204 // Get the number of threads 205 $threads = my_number_format($stats['numthreads']); 206 207 // Get the number of unapproved threads 208 $unapproved_threads = my_number_format($stats['numunapprovedthreads']); 209 210 // Get the number of new threads for today 211 $query = $db->simple_select("threads", "COUNT(*) AS newthreads", "dateline > '$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'"); 212 $newthreads = my_number_format($db->fetch_field($query, "newthreads")); 213 214 // Get the number of posts 215 $posts = my_number_format($stats['numposts']); 216 217 // Get the number of unapproved posts 218 if($stats['numunapprovedposts'] < 0) 219 { 220 $stats['numunapprovedposts'] = 0; 221 } 222 223 $unapproved_posts = my_number_format($stats['numunapprovedposts']); 224 225 // Get the number of new posts for today 226 $query = $db->simple_select("posts", "COUNT(*) AS newposts", "dateline > '$timecut' AND visible='1'"); 227 $newposts = my_number_format($db->fetch_field($query, "newposts")); 228 229 // Get the number of reported post 230 $query = $db->simple_select("reportedcontent", "COUNT(*) AS reported_posts", "type = 'post' OR type = ''"); 231 $reported_posts = my_number_format($db->fetch_field($query, "reported_posts")); 232 233 // Get the number of reported posts that haven't been marked as read yet 234 $query = $db->simple_select("reportedcontent", "COUNT(*) AS new_reported_posts", "reportstatus='0' AND (type = 'post' OR type = '')"); 235 $new_reported_posts = my_number_format($db->fetch_field($query, "new_reported_posts")); 236 237 // Get the number and total file size of attachments 238 $query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid > '0'"); 239 $attachs = $db->fetch_array($query); 240 $attachs['spaceused'] = get_friendly_size($attachs['spaceused']); 241 $approved_attachs = my_number_format($attachs['numattachs']); 242 243 // Get the number of unapproved attachments 244 $query = $db->simple_select("attachments", "COUNT(*) AS numattachs", "visible='0' AND pid > '0'"); 245 $unapproved_attachs = my_number_format($db->fetch_field($query, "numattachs")); 246 247 // Fetch the last time an update check was run 248 $update_check = $cache->read("update_check"); 249 250 // If last update check was greater than two weeks ago (14 days) show an alert 251 if(isset($update_check['last_check']) && $update_check['last_check'] <= TIME_NOW-60*60*24*14) 252 { 253 $lang->last_update_check_two_weeks = $lang->sprintf($lang->last_update_check_two_weeks, "index.php?module=home&action=version_check"); 254 $page->output_error("<p>{$lang->last_update_check_two_weeks}</p>"); 255 } 256 257 // If the update check contains information about a newer version, show an alert 258 if(isset($update_check['latest_version_code']) && $update_check['latest_version_code'] > $mybb->version_code) 259 { 260 $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>"); 261 $page->output_error("<p><em>{$lang->new_version_available}</em></p>"); 262 } 263 264 $plugins->run_hooks("admin_home_index_output_message"); 265 266 $adminmessage = $cache->read("adminnotes"); 267 268 if($adminmessage === false) 269 { 270 $adminmessage = array( 271 'adminmessage' => '', 272 ); 273 } 274 275 $table = new Table; 276 $table->construct_header($lang->mybb_server_stats, array("colspan" => 2)); 277 $table->construct_header($lang->forum_stats, array("colspan" => 2)); 278 279 $table->construct_cell("<strong>{$lang->mybb_version}</strong>", array('width' => '25%')); 280 $table->construct_cell($mybb->version, array('width' => '25%')); 281 $table->construct_cell("<strong>{$lang->threads}</strong>", array('width' => '25%')); 282 $table->construct_cell("<strong>{$threads}</strong> {$lang->threads}<br /><strong>{$newthreads}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&type=threads\"><strong>{$unapproved_threads}</strong> {$lang->unapproved}</a>", array('width' => '25%')); 283 $table->construct_row(); 284 285 $table->construct_cell("<strong>{$lang->php_version}</strong>", array('width' => '25%')); 286 $table->construct_cell(PHP_VERSION, array('width' => '25%')); 287 $table->construct_cell("<strong>{$lang->posts}</strong>", array('width' => '25%')); 288 289 $table->construct_cell("<strong>{$posts}</strong> {$lang->posts}<br /><strong>{$newposts}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&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%')); 290 291 $table->construct_row(); 292 293 $table->construct_cell("<strong>{$lang->sql_engine}</strong>", array('width' => '25%')); 294 $table->construct_cell($db->short_title." ".$db->get_version(), array('width' => '25%')); 295 $table->construct_cell("<strong>{$lang->users}</strong>", array('width' => '25%')); 296 $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%')); 297 $table->construct_row(); 298 299 $table->construct_cell("<strong>{$lang->server_load}</strong>", array('width' => '25%')); 300 $table->construct_cell($serverload, array('width' => '25%')); 301 $table->construct_cell("<strong>{$lang->attachments}</strong>", array('width' => '25%')); 302 $table->construct_cell("<strong>{$approved_attachs}</strong> {$lang->attachments}<br /><a href=\"index.php?module=forum-moderation_queue&type=attachments\"><strong>{$unapproved_attachs}</strong> {$lang->unapproved}</a><br /><strong>{$attachs['spaceused']}</strong> {$lang->used}", array('width' => '25%')); 303 $table->construct_row(); 304 305 $table->output($lang->dashboard); 306 307 echo ' 308 <div class="float_right" style="width: 48%;">'; 309 310 $table = new Table; 311 $table->construct_header($lang->admin_notes_public); 312 313 $form = new Form("index.php", "post"); 314 $table->construct_cell($form->generate_text_area("adminnotes", $adminmessage['adminmessage'], array('style' => 'width: 99%; height: 200px;'))); 315 $table->construct_row(); 316 317 $table->output($lang->admin_notes); 318 319 $buttons[] = $form->generate_submit_button($lang->save_notes); 320 $form->output_submit_wrapper($buttons); 321 $form->end(); 322 323 echo '</div> 324 <div class="float_left" style="width: 48%;">'; 325 326 // Latest news widget 327 $table = new Table; 328 $table->construct_header($lang->news_description); 329 330 if(!empty($update_check['news']) && is_array($update_check['news'])) 331 { 332 foreach($update_check['news'] as $news_item) 333 { 334 $posted = my_date('relative', (int)$news_item['dateline']); 335 $link = htmlspecialchars_uni($news_item['link']); 336 $title = htmlspecialchars_uni($news_item['title']); 337 $description = htmlspecialchars_uni(strip_tags($news_item['description'])); 338 339 $table->construct_cell("<strong><a href=\"{$link}\" target=\"_blank\" rel=\"noopener\">{$title}</a></strong><br /><span class=\"smalltext\">{$posted}</span>"); 340 $table->construct_row(); 341 342 $table->construct_cell($description); 343 $table->construct_row(); 344 } 345 } 346 else 347 { 348 $table->construct_cell($lang->no_announcements); 349 $table->construct_row(); 350 } 351 352 $table->output($lang->latest_mybb_announcements); 353 echo '</div>'; 354 355 $page->output_footer(); 356 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |