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_approved, 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)]; } T%ا!ǓrcQ\eJݕ 4fˡd)}M8ƥmF,ᄙ"b-όP$O{O-iw_{A/?˙ c<@Y9Y>J<#` $IkUWIߙV5ަE!B"TTg>*;3aw}s#n._\*\'6ҲMdɞy&zV$E:\1U YU `d")?9EPZeSYVt_Z5y1y[k`q()iMӏ&xBpW)вrSTwX9eIDڀpГcc؍/?ț9a GT_d ]FvɽgeAi6+Y*5(ʭ9p$Z};tSXe܅P>9ABԇڡ̟H]dGbr^\-&B>C>LimʁILXB3T#,3DpǸLɊW}^ tk+ysIPUVWY9,;F)yvIEGFY6Ʀs[pENae)'`f7P5@Oc_awTlpJ<1:]]j^ ^ }A?惪Te){>Ѥw*b$WPH9[vW$˚oOe 6"ܨT[qaDnUQαxtx) jc=@0~:㪰'!qOPn\hi`иsKAMȺYek1cf':'yKFiwm]82m190wPb"flU =.~hT#k_,kdK:*f"Jlثqv1sO%VhĪPRI|e LW&v|)et]BB xEK~T j6L= ,Z}TX́7]m@E:z,CM@+(Ic%uFŰ-m9 +{>|18Fl7qn,2 WM*_e_:t=ITKTW?;U9"Vz^rrPtJ;w4Ǜ1Sծt>i|BlϬ`DŹe5kPS9S',qV\z 6 |][-Ű9g9~C̶n17`j3ط7aJα04ꦯǽrbJ^9T!'hxދ ?!Rt샇1G-(,B*[k0ky?1ꬡ~]waǎi&=%Ut֒E>*?uè<(9%)R㥗p3ֲ%Uh,h* HJ\㕋Q8U]ϪxY7 N y`?>N|3t;[K|HD(Ʈ4w@e:@XpӪ~n2kJTsy6Y\r(ZA0t[^֘]*M }?@"F8,P%˓AZDfjgԀ82 =U{8'AeJR'8 (5@ tT]Y6ߥ`Tp*1朿mp#H6 G[!Xu*4{R3"1ϠO(zbe83!8Z.R#