[ Index ]

PHP Cross Reference of MyBB 1.8.21

title

Body

[close]

/admin/modules/tools/ -> recount_rebuild.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  $page->add_breadcrumb_item($lang->recount_rebuild, "index.php?module=tools-recount_rebuild");
  18  
  19  $plugins->run_hooks("admin_tools_recount_rebuild");
  20  
  21  /**
  22   * Rebuild forum counters
  23   */
  24  function acp_rebuild_forum_counters()
  25  {
  26      global $db, $mybb, $lang;
  27  
  28      $query = $db->simple_select("forums", "COUNT(*) as num_forums");
  29      $num_forums = $db->fetch_field($query, 'num_forums');
  30  
  31      $page = $mybb->get_input('page', MyBB::INPUT_INT);
  32      $per_page = $mybb->get_input('forumcounters', MyBB::INPUT_INT);
  33  
  34      $start = ($page-1) * $per_page;
  35      $end = $start + $per_page;
  36  
  37      $query = $db->simple_select("forums", "fid", '', array('order_by' => 'fid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
  38      while($forum = $db->fetch_array($query))
  39      {
  40          $update['parentlist'] = make_parent_list($forum['fid']);
  41          $db->update_query("forums", $update, "fid='{$forum['fid']}'");
  42          rebuild_forum_counters($forum['fid']);
  43      }
  44  
  45      check_proceed($num_forums, $end, ++$page, $per_page, "forumcounters", "do_rebuildforumcounters", $lang->success_rebuilt_forum_counters);
  46  }
  47  
  48  /**
  49   * Rebuild thread counters
  50   */
  51  function acp_rebuild_thread_counters()
  52  {
  53      global $db, $mybb, $lang;
  54  
  55      $query = $db->simple_select("threads", "COUNT(*) as num_threads");
  56      $num_threads = $db->fetch_field($query, 'num_threads');
  57  
  58      $page = $mybb->get_input('page', MyBB::INPUT_INT);
  59      $per_page = $mybb->get_input('threadcounters', MyBB::INPUT_INT);
  60  
  61      $start = ($page-1) * $per_page;
  62      $end = $start + $per_page;
  63  
  64      $query = $db->simple_select("threads", "tid", '', array('order_by' => 'tid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
  65      while($thread = $db->fetch_array($query))
  66      {
  67          rebuild_thread_counters($thread['tid']);
  68      }
  69  
  70      check_proceed($num_threads, $end, ++$page, $per_page, "threadcounters", "do_rebuildthreadcounters", $lang->success_rebuilt_thread_counters);
  71  }
  72  
  73  /**
  74   * Rebuild poll counters
  75   */
  76  function acp_rebuild_poll_counters()
  77  {
  78      global $db, $mybb, $lang;
  79  
  80      $query = $db->simple_select("polls", "COUNT(*) as num_polls");
  81      $num_polls = $db->fetch_field($query, 'num_polls');
  82  
  83      $page = $mybb->get_input('page', MyBB::INPUT_INT);
  84      $per_page = $mybb->get_input('pollcounters', MyBB::INPUT_INT);
  85  
  86      $start = ($page-1) * $per_page;
  87      $end = $start + $per_page;
  88  
  89      $query = $db->simple_select("polls", "pid", '', array('order_by' => 'pid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
  90      while($poll = $db->fetch_array($query))
  91      {
  92          rebuild_poll_counters($poll['pid']);
  93      }
  94  
  95      check_proceed($num_polls, $end, ++$page, $per_page, "pollcounters", "do_rebuildpollcounters", $lang->success_rebuilt_poll_counters);
  96  }
  97  
  98  /**
  99   * Recount user posts
 100   */
 101  function acp_recount_user_posts()
 102  {
 103      global $db, $mybb, $lang;
 104  
 105      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 106      $num_users = $db->fetch_field($query, 'num_users');
 107  
 108      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 109      $per_page = $mybb->get_input('userposts', MyBB::INPUT_INT);
 110  
 111      $start = ($page-1) * $per_page;
 112      $end = $start + $per_page;
 113  
 114      $query = $db->simple_select("forums", "fid", "usepostcounts = 0");
 115      while($forum = $db->fetch_array($query))
 116      {
 117          $fids[] = $forum['fid'];
 118      }
 119      if(is_array($fids))
 120      {
 121          $fids = implode(',', $fids);
 122      }
 123      if($fids)
 124      {
 125          $fids = " AND p.fid NOT IN($fids)";
 126      }
 127      else
 128      {
 129          $fids = "";
 130      }
 131  
 132      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 133      while($user = $db->fetch_array($query))
 134      {
 135          $query2 = $db->query("
 136              SELECT COUNT(p.pid) AS post_count
 137              FROM ".TABLE_PREFIX."posts p
 138              LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
 139              WHERE p.uid='{$user['uid']}' AND t.visible > 0 AND p.visible > 0{$fids}
 140          ");
 141          $num_posts = $db->fetch_field($query2, "post_count");
 142  
 143          $db->update_query("users", array("postnum" => (int)$num_posts), "uid='{$user['uid']}'");
 144      }
 145  
 146      check_proceed($num_users, $end, ++$page, $per_page, "userposts", "do_recountuserposts", $lang->success_rebuilt_user_post_counters);
 147  }
 148  
 149  /**
 150   * Recount user threads
 151   */
 152  function acp_recount_user_threads()
 153  {
 154      global $db, $mybb, $lang;
 155  
 156      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 157      $num_users = $db->fetch_field($query, 'num_users');
 158  
 159      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 160      $per_page = $mybb->get_input('userthreads', MyBB::INPUT_INT);
 161  
 162      $start = ($page-1) * $per_page;
 163      $end = $start + $per_page;
 164  
 165      $query = $db->simple_select("forums", "fid", "usethreadcounts = 0");
 166      while($forum = $db->fetch_array($query))
 167      {
 168          $fids[] = $forum['fid'];
 169      }
 170      if(is_array($fids))
 171      {
 172          $fids = implode(',', $fids);
 173      }
 174      if($fids)
 175      {
 176          $fids = " AND t.fid NOT IN($fids)";
 177      }
 178      else
 179      {
 180          $fids = "";
 181      }
 182  
 183      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 184      while($user = $db->fetch_array($query))
 185      {
 186          $query2 = $db->query("
 187              SELECT COUNT(t.tid) AS thread_count
 188              FROM ".TABLE_PREFIX."threads t
 189              WHERE t.uid='{$user['uid']}' AND t.visible > 0 AND t.closed NOT LIKE 'moved|%'{$fids}
 190          ");
 191          $num_threads = $db->fetch_field($query2, "thread_count");
 192  
 193          $db->update_query("users", array("threadnum" => (int)$num_threads), "uid='{$user['uid']}'");
 194      }
 195  
 196      check_proceed($num_users, $end, ++$page, $per_page, "userthreads", "do_recountuserthreads", $lang->success_rebuilt_user_thread_counters);
 197  }
 198  
 199  /**
 200   * Recount reputation values
 201   */
 202  function acp_recount_reputation()
 203  {
 204      global $db, $mybb, $lang;
 205  
 206      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 207      $num_users = $db->fetch_field($query, 'num_users');
 208  
 209      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 210      $per_page = $mybb->get_input('reputation', MyBB::INPUT_INT);
 211  
 212      $start = ($page-1) * $per_page;
 213      $end = $start + $per_page;
 214  
 215      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 216      while($user = $db->fetch_array($query))
 217      {
 218          $query2 = $db->query("
 219              SELECT SUM(reputation) as total_rep
 220              FROM ".TABLE_PREFIX."reputation
 221              WHERE uid='{$user['uid']}'
 222          ");
 223          $total_rep = $db->fetch_field($query2, "total_rep");
 224  
 225          $db->update_query("users", array("reputation" => (int)$total_rep), "uid='{$user['uid']}'");
 226      }
 227  
 228      check_proceed($num_users, $end, ++$page, $per_page, "reputation", "do_recountreputation", $lang->success_rebuilt_reputation);
 229  }
 230  
 231  /**
 232   * Recount warnings for users
 233   */
 234  function acp_recount_warning()
 235  {
 236      global $db, $mybb, $lang;
 237  
 238      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 239      $num_users = $db->fetch_field($query, 'num_users');
 240  
 241      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 242      $per_page = $mybb->get_input('warning', MyBB::INPUT_INT);
 243  
 244      $start = ($page-1) * $per_page;
 245      $end = $start + $per_page;
 246  
 247      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 248      while($user = $db->fetch_array($query))
 249      {
 250          $query2 = $db->query("
 251              SELECT SUM(points) as warn_lev
 252              FROM ".TABLE_PREFIX."warnings
 253              WHERE uid='{$user['uid']}' AND expired='0'
 254          ");
 255          $warn_lev = $db->fetch_field($query2, "warn_lev");
 256  
 257          $db->update_query("users", array("warningpoints" => (int)$warn_lev), "uid='{$user['uid']}'");
 258      }
 259  
 260      check_proceed($num_users, $end, ++$page, $per_page, "warning", "do_recountwarning", $lang->success_rebuilt_warning);
 261  }
 262  
 263  /**
 264   * Recount private messages (total and unread) for users
 265   */
 266  function acp_recount_private_messages()
 267  {
 268      global $db, $mybb, $lang;
 269  
 270      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 271      $num_users = $db->fetch_field($query, 'num_users');
 272  
 273      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 274      $per_page = $mybb->get_input('privatemessages', MyBB::INPUT_INT);
 275  
 276      $start = ($page-1) * $per_page;
 277      $end = $start + $per_page;
 278  
 279      require_once  MYBB_ROOT."inc/functions_user.php";
 280  
 281      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 282      while($user = $db->fetch_array($query))
 283      {
 284          update_pm_count($user['uid']);
 285      }
 286  
 287      check_proceed($num_users, $end, ++$page, $per_page, "privatemessages", "do_recountprivatemessages", $lang->success_rebuilt_private_messages);
 288  }
 289  
 290  /**
 291   * Recount referrals for users
 292   */
 293  function acp_recount_referrals()
 294  {
 295      global $db, $mybb, $lang;
 296  
 297      $query = $db->simple_select("users", "COUNT(uid) as num_users");
 298      $num_users = $db->fetch_field($query, 'num_users');
 299  
 300      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 301      $per_page = $mybb->get_input('referral', MyBB::INPUT_INT);
 302      $start = ($page-1) * $per_page;
 303      $end = $start + $per_page;
 304  
 305      $query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 306      while($user = $db->fetch_array($query))
 307      {
 308          $query2 = $db->query("
 309              SELECT COUNT(uid) as num_referrers
 310              FROM ".TABLE_PREFIX."users
 311              WHERE referrer='{$user['uid']}'
 312          ");
 313          $num_referrers = $db->fetch_field($query2, "num_referrers");
 314  
 315          $db->update_query("users", array("referrals" => (int)$num_referrers), "uid='{$user['uid']}'");
 316      }
 317  
 318      check_proceed($num_users, $end, ++$page, $per_page, "referral", "do_recountreferral", $lang->success_rebuilt_referral);
 319  }
 320  
 321  /**
 322   * Recount thread ratings
 323   */
 324  function acp_recount_thread_ratings()
 325  {
 326      global $db, $mybb, $lang;
 327  
 328      $query = $db->simple_select("threads", "COUNT(*) as num_threads");
 329      $num_threads = $db->fetch_field($query, 'num_threads');
 330  
 331      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 332      $per_page = $mybb->get_input('threadrating', MyBB::INPUT_INT);
 333  
 334      $start = ($page-1) * $per_page;
 335      $end = $start + $per_page;
 336  
 337      $query = $db->simple_select("threads", "tid", '', array('order_by' => 'tid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 338      while($thread = $db->fetch_array($query))
 339      {
 340          $query2 = $db->query("
 341              SELECT COUNT(tid) as num_ratings, SUM(rating) as total_rating
 342              FROM ".TABLE_PREFIX."threadratings
 343              WHERE tid='{$thread['tid']}'
 344          ");
 345          $recount = $db->fetch_array($query2);
 346  
 347          $db->update_query("threads", array("numratings" => (int)$recount['num_ratings'], "totalratings" => (int)$recount['total_rating']), "tid='{$thread['tid']}'");
 348      }
 349  
 350      check_proceed($num_threads, $end, ++$page, $per_page, "threadrating", "do_recountthreadrating", $lang->success_rebuilt_thread_ratings);
 351  }
 352  
 353  /**
 354   * Rebuild thumbnails for attachments
 355   */
 356  function acp_rebuild_attachment_thumbnails()
 357  {
 358      global $db, $mybb, $lang;
 359  
 360      $query = $db->simple_select("attachments", "COUNT(aid) as num_attachments");
 361      $num_attachments = $db->fetch_field($query, 'num_attachments');
 362  
 363      $page = $mybb->get_input('page', MyBB::INPUT_INT);
 364      $per_page = $mybb->get_input('attachmentthumbs', MyBB::INPUT_INT);
 365  
 366      $start = ($page-1) * $per_page;
 367      $end = $start + $per_page;
 368  
 369      $uploadspath = $mybb->settings['uploadspath'];
 370      if(my_substr($uploadspath, 0, 1) == '.')
 371      {
 372          $uploadspath = MYBB_ROOT . $mybb->settings['uploadspath'];
 373      }
 374  
 375      require_once  MYBB_ROOT."inc/functions_image.php";
 376  
 377      $query = $db->simple_select("attachments", "*", '', array('order_by' => 'aid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
 378      while($attachment = $db->fetch_array($query))
 379      {
 380          $ext = my_strtolower(my_substr(strrchr($attachment['filename'], "."), 1));
 381          if($ext == "gif" || $ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "jpe")
 382          {
 383              $thumbname = str_replace(".attach", "_thumb.$ext", $attachment['attachname']);
 384              $thumbnail = generate_thumbnail($uploadspath."/".$attachment['attachname'], $uploadspath, $thumbname, $mybb->settings['attachthumbh'], $mybb->settings['attachthumbw']);
 385              if($thumbnail['code'] == 4)
 386              {
 387                  $thumbnail['filename'] = "SMALL";
 388              }
 389              $db->update_query("attachments", array("thumbnail" => $thumbnail['filename']), "aid='{$attachment['aid']}'");
 390          }
 391      }
 392  
 393      check_proceed($num_attachments, $end, ++$page, $per_page, "attachmentthumbs", "do_rebuildattachmentthumbs", $lang->success_rebuilt_attachment_thumbnails);
 394  }
 395  
 396  /**
 397   * @param int $current
 398   * @param int $finish
 399   * @param int $next_page
 400   * @param int $per_page
 401   * @param string $name
 402   * @param string $name2
 403   * @param string $message
 404   */
 405  function check_proceed($current, $finish, $next_page, $per_page, $name, $name2, $message)
 406  {
 407      global $page, $lang;
 408  
 409      if($finish >= $current)
 410      {
 411          flash_message($message, 'success');
 412          admin_redirect("index.php?module=tools-recount_rebuild");
 413      }
 414      else
 415      {
 416          $page->output_header();
 417  
 418          $form = new Form("index.php?module=tools-recount_rebuild", 'post');
 419  
 420          echo $form->generate_hidden_field("page", $next_page);
 421          echo $form->generate_hidden_field($name, $per_page);
 422          echo $form->generate_hidden_field($name2, $lang->go);
 423          echo "<div class=\"confirm_action\">\n";
 424          echo "<p>{$lang->confirm_proceed_rebuild}</p>\n";
 425          echo "<br />\n";
 426          echo "<script type=\"text/javascript\">
 427              $(function() { 
 428                  var button = $(\"#proceed_button\"); 
 429                  if(button.length > 0) {
 430                      button.val(\"{$lang->automatically_redirecting}\");
 431                      button.attr(\"disabled\", true);
 432                      button.css(\"color\", \"#aaa\");
 433                      button.css(\"borderColor\", \"#aaa\");
 434                      
 435                      var parent_form = button.closest('form');
 436  
 437                      if (parent_form.length > 0) {
 438                          parent_form.submit();
 439                      }
 440                  }
 441              });
 442          </script>";
 443          echo "<p class=\"buttons\">\n";
 444          echo $form->generate_submit_button($lang->proceed, array('class' => 'button_yes', 'id' => 'proceed_button'));
 445          echo "</p>\n";
 446          echo "</div>\n";
 447  
 448          $form->end();
 449  
 450          $page->output_footer();
 451          exit;
 452      }
 453  }
 454  
 455  if(!$mybb->input['action'])
 456  {
 457      $plugins->run_hooks("admin_tools_recount_rebuild_start");
 458  
 459      if($mybb->request_method == "post")
 460      {
 461          require_once  MYBB_ROOT."inc/functions_rebuild.php";
 462  
 463          if(!isset($mybb->input['page']) || $mybb->get_input('page', MyBB::INPUT_INT) < 1)
 464          {
 465              $mybb->input['page'] = 1;
 466          }
 467  
 468          $plugins->run_hooks("admin_tools_do_recount_rebuild");
 469  
 470          if(isset($mybb->input['do_rebuildforumcounters']))
 471          {
 472              $plugins->run_hooks("admin_tools_recount_rebuild_forum_counters");
 473  
 474              if($mybb->input['page'] == 1)
 475              {
 476                  // Log admin action
 477                  log_admin_action("forum");
 478              }
 479  
 480              $per_page = $mybb->get_input('forumcounters', MyBB::INPUT_INT);
 481              if(!$per_page || $per_page <= 0)
 482              {
 483                  $mybb->input['forumcounters'] = 50;
 484              }
 485  
 486              acp_rebuild_forum_counters();
 487          }
 488          elseif(isset($mybb->input['do_rebuildthreadcounters']))
 489          {
 490              $plugins->run_hooks("admin_tools_recount_rebuild_thread_counters");
 491  
 492              if($mybb->input['page'] == 1)
 493              {
 494                  // Log admin action
 495                  log_admin_action("thread");
 496              }
 497  
 498              $per_page = $mybb->get_input('threadcounters', MyBB::INPUT_INT);
 499              if(!$per_page || $per_page <= 0)
 500              {
 501                  $mybb->input['threadcounters'] = 500;
 502              }
 503  
 504              acp_rebuild_thread_counters();
 505          }
 506          elseif(isset($mybb->input['do_recountuserposts']))
 507          {
 508              $plugins->run_hooks("admin_tools_recount_rebuild_user_posts");
 509  
 510              if($mybb->input['page'] == 1)
 511              {
 512                  // Log admin action
 513                  log_admin_action("userposts");
 514              }
 515  
 516              $per_page = $mybb->get_input('userposts', MyBB::INPUT_INT);
 517              if(!$per_page || $per_page <= 0)
 518              {
 519                  $mybb->input['userposts'] = 500;
 520              }
 521  
 522              acp_recount_user_posts();
 523          }
 524          elseif(isset($mybb->input['do_recountuserthreads']))
 525          {
 526              $plugins->run_hooks("admin_tools_recount_rebuild_user_threads");
 527  
 528              if($mybb->input['page'] == 1)
 529              {
 530                  // Log admin action
 531                  log_admin_action("userthreads");
 532              }
 533  
 534              $per_page = $mybb->get_input('userthreads', MyBB::INPUT_INT);
 535              if(!$per_page || $per_page <= 0)
 536              {
 537                  $mybb->input['userthreads'] = 500;
 538              }
 539  
 540              acp_recount_user_threads();
 541          }
 542          elseif(isset($mybb->input['do_rebuildattachmentthumbs']))
 543          {
 544              $plugins->run_hooks("admin_tools_recount_rebuild_attachment_thumbs");
 545  
 546              if($mybb->input['page'] == 1)
 547              {
 548                  // Log admin action
 549                  log_admin_action("attachmentthumbs");
 550              }
 551  
 552              $per_page = $mybb->get_input('attachmentthumbs', MyBB::INPUT_INT);
 553              if(!$per_page || $per_page <= 0)
 554              {
 555                  $mybb->input['attachmentthumbs'] = 500;
 556              }
 557  
 558              acp_rebuild_attachment_thumbnails();
 559          }
 560          elseif(isset($mybb->input['do_recountreputation']))
 561          {
 562              $plugins->run_hooks("admin_tools_recount_recount_reputation");
 563  
 564              if($mybb->input['page'] == 1)
 565              {
 566                  // Log admin action
 567                  log_admin_action("reputation");
 568              }
 569  
 570              $per_page = $mybb->get_input('reputation', MyBB::INPUT_INT);
 571              if(!$per_page || $per_page <= 0)
 572              {
 573                  $mybb->input['reputation'] = 500;
 574              }
 575  
 576              acp_recount_reputation();
 577          }
 578          elseif(isset($mybb->input['do_recountwarning']))
 579          {
 580              $plugins->run_hooks("admin_tools_recount_recount_warning");
 581  
 582              if($mybb->input['page'] == 1)
 583              {
 584                  // Log admin action
 585                  log_admin_action("warning");
 586              }
 587  
 588              $per_page = $mybb->get_input('warning', MyBB::INPUT_INT);
 589              if(!$per_page || $per_page <= 0)
 590              {
 591                  $mybb->input['warning'] = 500;
 592              }
 593  
 594              acp_recount_warning();
 595          }
 596          elseif(isset($mybb->input['do_recountprivatemessages']))
 597          {
 598              $plugins->run_hooks("admin_tools_recount_recount_private_messages");
 599  
 600              if($mybb->input['page'] == 1)
 601              {
 602                  // Log admin action
 603                  log_admin_action("privatemessages");
 604              }
 605  
 606              $per_page = $mybb->get_input('privatemessages', MyBB::INPUT_INT);
 607              if(!$per_page || $per_page <= 0)
 608              {
 609                  $mybb->input['privatemessages'] = 500;
 610              }
 611  
 612              acp_recount_private_messages();
 613          }
 614          elseif(isset($mybb->input['do_recountreferral']))
 615          {
 616              $plugins->run_hooks("admin_tools_recount_recount_referral");
 617  
 618              if($mybb->input['page'] == 1)
 619              {
 620                  // Log admin action
 621                  log_admin_action("referral");
 622              }
 623  
 624              $per_page = $mybb->get_input('referral', MyBB::INPUT_INT);
 625              if(!$per_page || $per_page <= 0)
 626              {
 627                  $mybb->input['referral'] = 500;
 628              }
 629  
 630              acp_recount_referrals();
 631          }
 632          elseif(isset($mybb->input['do_recountthreadrating']))
 633          {
 634              $plugins->run_hooks("admin_tools_recount_recount_thread_ratings");
 635  
 636              if($mybb->input['page'] == 1)
 637              {
 638                  // Log admin action
 639                  log_admin_action("threadrating");
 640              }
 641  
 642              $per_page = $mybb->get_input('threadrating', MyBB::INPUT_INT);
 643              if(!$per_page || $per_page <= 0)
 644              {
 645                  $mybb->input['threadrating'] = 500;
 646              }
 647  
 648              acp_recount_thread_ratings();
 649          }
 650          elseif(isset($mybb->input['do_rebuildpollcounters']))
 651          {
 652              $plugins->run_hooks("admin_tools_recount_rebuild_poll_counters");
 653  
 654              if($mybb->input['page'] == 1)
 655              {
 656                  // Log admin action
 657                  log_admin_action("poll");
 658              }
 659  
 660              $per_page = $mybb->get_input('pollcounters', MyBB::INPUT_INT);
 661              if(!$per_page || $per_page <= 0)
 662              {
 663                  $mybb->input['pollcounters'] = 500;
 664              }
 665  
 666              acp_rebuild_poll_counters();
 667          }
 668          else
 669          {
 670              $plugins->run_hooks("admin_tools_recount_rebuild_stats");
 671  
 672              $cache->update_stats();
 673  
 674              // Log admin action
 675              log_admin_action("stats");
 676  
 677              flash_message($lang->success_rebuilt_forum_stats, 'success');
 678              admin_redirect("index.php?module=tools-recount_rebuild");
 679          }
 680      }
 681  
 682      $page->output_header($lang->recount_rebuild);
 683  
 684      $sub_tabs['recount_rebuild'] = array(
 685          'title' => $lang->recount_rebuild,
 686          'link' => "index.php?module=tools-recount_rebuild",
 687          'description' => $lang->recount_rebuild_desc
 688      );
 689  
 690      $page->output_nav_tabs($sub_tabs, 'recount_rebuild');
 691  
 692      $form = new Form("index.php?module=tools-recount_rebuild", "post");
 693  
 694      $form_container = new FormContainer($lang->recount_rebuild);
 695      $form_container->output_row_header($lang->name);
 696      $form_container->output_row_header($lang->data_per_page, array('width' => 50));
 697      $form_container->output_row_header("&nbsp;");
 698  
 699      $form_container->output_cell("<label>{$lang->rebuild_forum_counters}</label><div class=\"description\">{$lang->rebuild_forum_counters_desc}</div>");
 700      $form_container->output_cell($form->generate_numeric_field("forumcounters", 50, array('style' => 'width: 150px;', 'min' => 0)));
 701      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildforumcounters")));
 702      $form_container->construct_row();
 703  
 704      $form_container->output_cell("<label>{$lang->rebuild_thread_counters}</label><div class=\"description\">{$lang->rebuild_thread_counters_desc}</div>");
 705      $form_container->output_cell($form->generate_numeric_field("threadcounters", 500, array('style' => 'width: 150px;', 'min' => 0)));
 706      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildthreadcounters")));
 707      $form_container->construct_row();
 708  
 709      $form_container->output_cell("<label>{$lang->rebuild_poll_counters}</label><div class=\"description\">{$lang->rebuild_poll_counters_desc}</div>");
 710      $form_container->output_cell($form->generate_numeric_field("pollcounters", 500, array('style' => 'width: 150px;', 'min' => 0)));
 711      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildpollcounters")));
 712      $form_container->construct_row();
 713  
 714      $form_container->output_cell("<label>{$lang->recount_user_posts}</label><div class=\"description\">{$lang->recount_user_posts_desc}</div>");
 715      $form_container->output_cell($form->generate_numeric_field("userposts", 500, array('style' => 'width: 150px;', 'min' => 0)));
 716      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountuserposts")));
 717      $form_container->construct_row();
 718  
 719      $form_container->output_cell("<label>{$lang->recount_user_threads}</label><div class=\"description\">{$lang->recount_user_threads_desc}</div>");
 720      $form_container->output_cell($form->generate_numeric_field("userthreads", 500, array('style' => 'width: 150px;', 'min' => 0)));
 721      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountuserthreads")));
 722      $form_container->construct_row();
 723  
 724      $form_container->output_cell("<label>{$lang->rebuild_attachment_thumbs}</label><div class=\"description\">{$lang->rebuild_attachment_thumbs_desc}</div>");
 725      $form_container->output_cell($form->generate_numeric_field("attachmentthumbs", 20, array('style' => 'width: 150px;', 'min' => 0)));
 726      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildattachmentthumbs")));
 727      $form_container->construct_row();
 728  
 729      $form_container->output_cell("<label>{$lang->recount_stats}</label><div class=\"description\">{$lang->recount_stats_desc}</div>");
 730      $form_container->output_cell($lang->na);
 731      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountstats")));
 732      $form_container->construct_row();
 733  
 734      $form_container->output_cell("<label>{$lang->recount_reputation}</label><div class=\"description\">{$lang->recount_reputation_desc}</div>");
 735      $form_container->output_cell($form->generate_numeric_field("reputation", 500, array('style' => 'width: 150px;', 'min' => 0)));
 736      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountreputation")));
 737      $form_container->construct_row();
 738  
 739      $form_container->output_cell("<label>{$lang->recount_warning}</label><div class=\"description\">{$lang->recount_warning_desc}</div>");
 740      $form_container->output_cell($form->generate_numeric_field("warning", 500, array('style' => 'width: 150px;', 'min' => 0)));
 741      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountwarning")));
 742      $form_container->construct_row();
 743  
 744      $form_container->output_cell("<label>{$lang->recount_private_messages}</label><div class=\"description\">{$lang->recount_private_messages_desc}</div>");
 745      $form_container->output_cell($form->generate_numeric_field("privatemessages", 500, array('style' => 'width: 150px;', 'min' => 0)));
 746      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountprivatemessages")));
 747      $form_container->construct_row();
 748  
 749      $form_container->output_cell("<label>{$lang->recount_referrals}</label><div class=\"description\">{$lang->recount_referrals_desc}</div>");
 750      $form_container->output_cell($form->generate_numeric_field("referral", 500, array('style' => 'width: 150px;', 'min' => 0)));
 751      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountreferral")));
 752      $form_container->construct_row();
 753  
 754      $form_container->output_cell("<label>{$lang->recount_thread_ratings}</label><div class=\"description\">{$lang->recount_thread_ratings_desc}</div>");
 755      $form_container->output_cell($form->generate_numeric_field("threadrating", 500, array('style' => 'width: 150px;', 'min' => 0)));
 756      $form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountthreadrating")));
 757      $form_container->construct_row();
 758  
 759      $plugins->run_hooks("admin_tools_recount_rebuild_output_list");
 760  
 761      $form_container->end();
 762  
 763      $form->end();
 764  
 765      $page->output_footer();
 766  }
 767  


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