Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

fill.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 5.33 KiB


 001  <?php
 002  // -------------------------------------------------------------
 003  //
 004  // $Id$
 005  //
 006  // FILENAME  : fill.php
 007  // STARTED   : Mon Sep 15, 2003
 008  // COPYRIGHT : � 2001, 2003 phpBB Group
 009  // WWW       : http://www.phpbb.com/
 010  // LICENCE   : GPL vs2.0 [ see /docs/COPYING ]
 011  //
 012  // -------------------------------------------------------------
 013  //
 014  // Security message:
 015  //
 016  // This script is potentially dangerous.
 017  // Remove or comment the next line (die(".... ) to enable this script.
 018  // Do NOT FORGET to either remove this script or disable it after you have used it.
 019  //
 020  die("Please read the first lines of this script for instructions on how to enable it");
 021   
 022   
 023  define('IN_PHPBB', true);
 024  $phpbb_root_path = './../';
 025  $phpEx = substr(strrchr(__FILE__, '.'), 1);
 026  include($phpbb_root_path . 'common.'.$phpEx);
 027  include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
 028   
 029  set_time_limit(0);
 030  header('Expires: 0');
 031  ignore_user_abort(true);
 032   
 033  // number of topics to create
 034  $num_topics = 10000;
 035   
 036  // number of topics to be generated per call
 037  $batch_size = 2000;
 038   
 039  // max number of posts per topic
 040  $posts_per_topic = 500;
 041   
 042   
 043  // general vars
 044  $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : 'generate';
 045  $start = (isset($_REQUEST['start'])) ? intval($_REQUEST['start']) : 0;
 046   
 047  switch ($mode)
 048  {
 049      case 'generate':
 050          $user_ids = $forum_ids = $topic_rows = array();
 051   
 052          $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') OR user_id = ' . ANONYMOUS;
 053          $result = $db->sql_query($sql);
 054          while ($row = $db->sql_fetchrow($result))
 055          {
 056              $user_ids[] = $row['user_id'];
 057          }
 058          $db->sql_freeresult($result);
 059   
 060          $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST;
 061          $result = $db->sql_query($sql);
 062          while ($row = $db->sql_fetchrow($result))
 063          {
 064              $forum_ids[$row['forum_id']] = $row['forum_id'];
 065          }
 066          $db->sql_freeresult($result);
 067   
 068          if (!$start)
 069          {
 070              $db->sql_query('TRUNCATE TABLE ' . POSTS_TABLE);
 071              $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE);
 072  //            $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE . '_prefetch');
 073          }
 074   
 075          $db->sql_query('LOCK TABLES ' . POSTS_TABLE . ' WRITE, ' . TOPICS_TABLE . ' WRITE');
 076   
 077          for ($topic_id = $start + 1; $topic_id < min($start + $batch_size, $num_topics + 1); ++$topic_id)
 078          {
 079              $forum_id = array_rand($forum_ids);
 080   
 081              if (count($topic_rows) == 10)
 082              {
 083                  $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported)
 084                      VALUES " . implode(', ', $topic_rows);
 085                  $db->sql_query($sql);
 086   
 087                  $topic_rows = array();
 088              }
 089   
 090              $topic_rows[] = "($topic_id, $forum_id, '$forum_id-$topic_id', " . (($topic_id % 34) ? '0' : '1') . ')';
 091   
 092              $sql = 'INSERT IGNORE INTO ' . POSTS_TABLE . ' (topic_id, forum_id, poster_id, post_subject, post_text, post_username, post_approved, post_time, post_reported)
 093                  VALUES ';
 094   
 095              $rows = array();
 096              $post_time = mt_rand(0, time());
 097   
 098              $num_posts = $posts_per_topic; //mt_rand(1, $posts_per_topic);
 099              for ($i = 0; $i < $num_posts; ++$i)
 100              {
 101                  $poster_id = $user_ids[array_rand($user_ids)];
 102                  $poster_name = ($poster_id == ANONYMOUS) ? rndm_username() : '';
 103                  $rows[] = "($topic_id, $forum_id, $poster_id, '$forum_id-$topic_id-$i', '$forum_id-$topic_id-$i', '$poster_name', " . (mt_rand(0, 12) ? '1' : '0') . ', ' . ($post_time + $i * 60) . ', ' . (mt_rand(0, 32) ? '0' : '1') . ')';
 104              }
 105   
 106              $db->sql_query($sql . implode(', ', $rows));
 107          }
 108   
 109          if (count($topic_rows))
 110          {
 111              $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported)
 112                  VALUES " . implode(', ', $topic_rows);
 113              $db->sql_query($sql);
 114          }
 115   
 116          $db->sql_query('UNLOCK TABLES');
 117   
 118          if ($topic_id >= $num_topics)
 119          {
 120              echo '<meta http-equiv="refresh" content="10; url=fill.' . $phpEx . '?mode=sync&amp;' . time() . '">And now for something completely different...';
 121   
 122              $db->sql_query('ANALYZE TABLES ' . TOPICS_TABLE . ', ' . POSTS_TABLE);
 123              flush();
 124          }
 125          else
 126          {
 127              echo '<meta http-equiv="refresh" content="10; url=fill.' . $phpEx . '?start=' . $topic_id . '&amp;' . time() . '">To the next page... (' . $topic_id . '/' . $num_topics . ')';
 128              flush();
 129          }
 130      break;
 131   
 132      case 'sync':
 133  /*        error_reporting(E_ALL);
 134          $sync_all = TRUE;
 135   
 136          if ($sync_all)
 137          {
 138              $s = explode(' ', microtime());
 139              sync('topic', '', '', TRUE, FALSE);
 140  //            sync('forum');
 141              $e = explode(' ', microtime());
 142   
 143              echo '<pre><b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
 144              echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
 145          }
 146          else
 147          {
 148              $batch_size = $batch_size * 10;
 149              $end = $start + $batch_size;
 150   
 151              $s = explode(' ', microtime());
 152              sync('topic', 'range', "topic_id BETWEEN $start AND $end", TRUE, FALSE);
 153              $e = explode(' ', microtime());
 154   
 155              echo '<pre>Time taken: <b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
 156   
 157              if ($end < $num_topics)
 158              {
 159                  $start += $batch_size;
 160                  echo '<meta http-equiv="refresh" content="0; url=fill.' . $phpEx . "?mode=sync&amp;start=$start&amp;" . time() . "\">And now for something completely different... ($start/$num_topics)";
 161              }
 162              else
 163              {
 164                  echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
 165              }
 166          }
 167   
 168          if (isset($_GET['explain']))
 169          {
 170              trigger_error('Done');
 171          }
 172      */
 173  }
 174   
 175  $db->sql_close();
 176   
 177  function rndm_username()
 178  {
 179      static $usernames;
 180   
 181      if (!isset($usernames))
 182      {
 183          $usernames = get_defined_functions();
 184          $usernames = $usernames['internal'];
 185      }
 186   
 187      return $usernames[array_rand($usernames)];
 188  }
 189   
 190  ?>