* @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. * */ // // Security message: // // This script is potentially dangerous. // Remove or comment the next line (die(".... ) to enable this script. // Do NOT FORGET to either remove this script or disable it after you have used it. // die("Please read the first lines of this script for instructions on how to enable it"); define('IN_PHPBB', true); $phpbb_root_path = './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); set_time_limit(0); header('Expires: 0'); ignore_user_abort(true); // number of topics to create $num_topics = 10000; // number of topics to be generated per call $batch_size = 2000; // max number of posts per topic $posts_per_topic = 500; // general vars $mode = $request->variable('mode', 'generate'); $start = $request->variable('start', 0); switch ($mode) { case 'generate': $user_ids = $forum_ids = $topic_rows = array(); $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') OR user_id = ' . ANONYMOUS; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $user_ids[] = $row['user_id']; } $db->sql_freeresult($result); $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_ids[$row['forum_id']] = $row['forum_id']; } $db->sql_freeresult($result); if (!$start) { $db->sql_query('TRUNCATE TABLE ' . POSTS_TABLE); $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE); // $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE . '_prefetch'); } $db->sql_query('LOCK TABLES ' . POSTS_TABLE . ' WRITE, ' . TOPICS_TABLE . ' WRITE'); for ($topic_id = $start + 1; $topic_id < min($start + $batch_size, $num_topics + 1); ++$topic_id) { $forum_id = array_rand($forum_ids); if (count($topic_rows) == 10) { $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported) VALUES " . implode(', ', $topic_rows); $db->sql_query($sql); $topic_rows = array(); } $topic_rows[] = "($topic_id, $forum_id, '$forum_id-$topic_id', " . (($topic_id % 34) ? '0' : '1') . ')'; $sql = 'INSERT IGNORE INTO ' . POSTS_TABLE . ' (topic_id, forum_id, poster_id, post_subject, post_text, post_username, post_visibility, post_time, post_reported) VALUES '; $rows = array(); $post_time = mt_rand(0, time()); $num_posts = $posts_per_topic; //mt_rand(1, $posts_per_topic); for ($i = 0; $i < $num_posts; ++$i) { $poster_id = $user_ids[array_rand($user_ids)]; $poster_name = ($poster_id == ANONYMOUS) ? rndm_username() : ''; $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') . ')'; } $db->sql_query($sql . implode(', ', $rows)); } if (count($topic_rows)) { $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported) VALUES " . implode(', ', $topic_rows); $db->sql_query($sql); } $db->sql_query('UNLOCK TABLES'); if ($topic_id >= $num_topics) { echo 'And now for something completely different...'; $db->sql_query('ANALYZE TABLES ' . TOPICS_TABLE . ', ' . POSTS_TABLE); flush(); } else { echo 'To the next page... (' . $topic_id . '/' . $num_topics . ')'; flush(); } break; case 'sync': /* error_reporting(E_ALL); $sync_all = TRUE; if ($sync_all) { $s = explode(' ', microtime()); sync('topic', '', '', TRUE, FALSE); // sync('forum'); $e = explode(' ', microtime()); echo '
' . ($e[0] + $e[1] - $s[0] - $s[1]) . ''; echo 'Here we go again'; } else { $batch_size = $batch_size * 10; $end = $start + $batch_size; $s = explode(' ', microtime()); sync('topic', 'range', "topic_id BETWEEN $start AND $end", TRUE, FALSE); $e = explode(' ', microtime()); echo '
Time taken: ' . ($e[0] + $e[1] - $s[0] - $s[1]) . ''; if ($end < $num_topics) { $start += $batch_size; echo 'And now for something completely different... ($start/$num_topics)"; } else { echo 'Here we go again'; } } if (isset($_GET['explain'])) { trigger_error('Done'); } */ } $db->sql_close(); function rndm_username() { static $usernames; if (!isset($usernames)) { $usernames = get_defined_functions(); $usernames = $usernames['internal']; } return $usernames[array_rand($usernames)]; } sX^,lkҙ:J>%lc9h \^2/q&B䞑AQFo6HǍ\:>e¹ۣEPR̖ؔW<^vǬ}_W{9RP. L_U`+ՅiZn),"ѽedl%3ĞwJڞhL*B,&r#:6eg*~g}Rhb&GܫoӒX;61 E\n۔.l"Л^hm,: t).!$ SƊ WFEmADO~ 7D(EKe;(Fe &cgO j,{d0|m |p|$0)I[^0s"),ڭݢ fީF~J겿ɴQ#ii>Zue.!BJi\L$KCBjgx;1z}mƠ i)A/6"fۓѫ} JM-%i x^E\ˎ?;9g^PZ/m5CM?N4E,-3e[iC&sψ"wۡ6q f~X}}:==u*Ul4#dwνR[fhy qD ңj+nmo{\0E(c\Zok|qJq`cW#@Uy?aVxjUyUzo`$-ay]ػbc&jn&^T{(1>kNkp%L?2uS`]Jk^z}6 [=`u̥%?zx|B"3@ˁ= >4;*w7]Jz.\41|h5%)!Ѣz W\;܁zkIxڔ@wRFT82B| uՉB]˗rj fFiVɉcX]3뽮]zUHwa<CKOAYv Sa*aaړCRMNDw6]US@2T5:giSg< dqnw.W|S/)\VTsiNO;7/,71Fu? CiVl(1@/Y})u3 K\T>qf]\50otu!&*FUgq@ rzWO5:j!\@r,GUw֓y?rI`np=j> M^^[^%n| :a,vvG8?x MA .i8x?֤9&4b#UA!3}bb*S,#q:478+밈Z5ЉILl3MhMn-T\uW-a:[5YDv$jÁn7 +ʼn1xw?-jқ@Pɣ쟻t-'ӵY(g?V}ske]sХͻM;Z,g[و;<5NA~uI`F)\mU}B;IL"Nj;c_(?80 Feql6YU7>`18dCD\|S[dS^+Y%snBGub2f8 rul:""J6<a`V'Y?D{x P7VJH6)(^{bR\jEdxbg5+EwY(7R7EpEE[bX±$%zGl0O3^9LU^ tܶ5DnbYeQ5+|d~dP,VED3<w=EWe;qpH0 L4FA@ 'a>A rzooc۷_mlҟrȎ)NJ7(s9ʒINCS8{2 FFr~UİTBoDUP 䄯sQ ݬ͙,;gQen}WU$@DzkEbM7$46nӣ|t,'V%U