FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpbb3/phpBB/develop/fill.php at develop · imsoftware/phpbb3 · GitHub
imsoftware
/
phpbb3
Public
forked from
phpbb/phpbb
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
phpbb3
/
phpBB
/
develop
/
fill.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
186 lines (150 loc) · 5.32 KB
Breadcrumbs
phpbb3
/
phpBB
/
develop
/
fill.php
Copy path
File metadata and controls
186 lines (150 loc) · 5.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
// -------------------------------------------------------------
//
// FILENAME : fill.php
// STARTED : Mon Sep 15, 2003
// COPYRIGHT : © 2001, 2003 phpBB Group
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
//
// 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
= (
isset
(
$
_REQUEST
[
'
mode
'
])) ?
$
_REQUEST
[
'
mode
'
] :
'
generate
'
;
$
start
= (
isset
(
$
_REQUEST
[
'
start
'
])) ?
intval
(
$
_REQUEST
[
'
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_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
'
<meta http-equiv="refresh" content="10; url=fill.
'
.
$
phpEx
.
'
?mode=sync&
'
.
time
() .
'
">And now for something completely different...
'
;
$
db
->
sql_query
(
'
ANALYZE TABLES
'
.
TOPICS_TABLE
.
'
,
'
.
POSTS_TABLE
);
flush
();
}
else
{
echo
'
<meta http-equiv="refresh" content="10; url=fill.
'
.
$
phpEx
.
'
?start=
'
.
$
topic_id
.
'
&
'
.
time
() .
'
">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 '<pre><b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
}
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 '<pre>Time taken: <b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
if ($end < $num_topics)
{
$start += $batch_size;
echo '<meta http-equiv="refresh" content="0; url=fill.' . $phpEx . "?mode=sync&start=$start&" . time() . "\">And now for something completely different... ($start/$num_topics)";
}
else
{
echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
}
}
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
)];
}
Back
|
FazBrowse Home
|
New Git URL