-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsched_news.php
342 lines (312 loc) · 19.5 KB
/
sched_news.php
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?php
// Blacknova Traders - A web-based massively multiplayer space combat and trading game
// Copyright (C) 2001-2012 Ron Harwood and the BNT development team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// File: sched_news.php
/***********************************************************
This file includes the default language for now, so that news
are generated in the server's default language. The news text
will have to be removed from the database for the next version
************************************************************/
if (preg_match("/sched_news.php/i", $_SERVER['PHP_SELF']))
{
echo "You can not access this file directly!";
die();
}
global $default_lang;
// New database driven language entries
load_languages($db, $lang, array('admin', 'common', 'global_includes', 'global_funcs', 'footer', 'news'), $langvars, $db_logging);
echo "<strong>Posting News</strong><br><br>";
// Generation of planet amount
$sql = $db->Execute("SELECT COUNT(owner) AS amount, owner FROM {$db->prefix}planets WHERE owner !='0' GROUP BY owner ORDER BY amount ASC");
db_op_result ($db, $sql, __LINE__, __FILE__, $db_logging);
while (!$sql->EOF)
{
$row = $sql->fields;
if ($row['amount'] >= 150)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='planet150';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_p_text150 = "The enormous vast empire of [name], represented by 150 planets in the whole galaxy is getting a threatening strength. One of the BNN reporters found out that [name] is upgrading his ship planning a major war. In an interview [name] announced that is done on defence purpose only!";
$planetcount = 150;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text1502=str_replace("[name]",$name,$l_news_p_text150);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet100');", array($headline, $l_news_p_text1502, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 100)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='planet100';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_p_text100 = "The enormous vast empire of [name], represented by 100 planets in the whole galaxy is getting a threatening strength. One of the BNN reporters found out that [name] is upgrading his ship planning a major war. In an interview [name] announced that is done on defence purpose only!";
$planetcount = 100;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text1002=str_replace("[name]",$name,$l_news_p_text100);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet100');", array($headline, $l_news_p_text1002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 50)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='planet50';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$planetcount = 50;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text502=str_replace("[name]",$name,$l_news_p_text50);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet50');", array($headline, $l_news_p_text502, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 25)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='planet25';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$planetcount = 25;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text252=str_replace("[name]",$name,$l_news_p_text25);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet25');", array($headline, $l_news_p_text252, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 10)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id='$row[owner]' AND news_type='planet10'");
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$planetcount = 10;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text102=str_replace("[name]",$name,$l_news_p_text10);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet10');", array($headline, $l_news_p_text102, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 5)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='planet5';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$planetcount = 5;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $planetcount ." ". $l_news_planets;
$l_news_p_text52=str_replace("[name]",$name,$l_news_p_text5);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'planet5');", array($headline, $l_news_p_text52, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
$sql->MoveNext();
} // while
// end generation of planet amount
// generation of colonist amount
$sql = $db->Execute("SELECT SUM(colonists) AS amount, owner FROM {$db->prefix}planets WHERE owner !='0' GROUP BY owner ORDER BY amount ASC;");
db_op_result ($db, $sql, __LINE__, __FILE__, $db_logging);
while (!$sql->EOF)
{
$row = $sql->fields;
if ($row['amount'] >= 1000000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'col_X2';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_c_text_X2 = "The humongous empire of [name] now has 1 Trillion colonists, BNN reporters found out that [name] is in possesion of some weird cloning mechanism allowing him to breed new colonists in huge amounts. With this amount of colonists, the econmic strength of this empire is enormous, BNN hopes that [name] does not spend his money on warfare";
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." 1 Trillion Colonists";
$l_news_c_text_X22=str_replace("[name]",$name,$l_news_c_text_X2);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col_X2');", array($headline, $l_news_c_text_X22, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 500000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'col_X1';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_c_text_X1 = "The humongous empire of [name] now has 500 Billion colonists, BNN reporters found out that [name] is in possesion of some weird cloning mechanism allowing him to breed new colonists in huge amounts. With this amount of colonists, the econmic strength of this empire is enormous, BNN hopes that [name] does not spend his money on warfare";
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." 500 Billion Colonists";
$l_news_c_text_X12=str_replace("[name]",$name,$l_news_c_text_X1);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col_X1');", array($headline, $l_news_c_text_X12, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 100000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'col100000';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_c_text100000 = "The humongous empire of [name] now has 100 Billion colonists, BNN reporters found out that [name] is in possesion of some weird cloning mechanism allowing him to breed new colonists in huge amounts. With this amount of colonists, the econmic strength of this empire is enormous, BNN hopes that [name] does not spend his money on warfare";
$colcount = 100000;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." 100 Billion Colonists";
$l_news_c_text1000002=str_replace("[name]",$name,$l_news_c_text100000);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col100000');", array($headline, $l_news_c_text1000002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 10000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'col10000';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$l_news_c_text10000 = "The humongous empire of [name] now has 10 Billion colonists, BNN reporters found out that [name] is in possesion of some weird cloning mechanism allowing him to breed new colonists in huge amounts. With this amount of colonists, the econmic strength of this empire is enormous, BNN hopes that [name] does not spend his money on warfare";
$colcount = 10000;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." 10 Billion Colonists";
$l_news_c_text100002=str_replace("[name]",$name,$l_news_c_text10000);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col10000');", array($headline, $l_news_c_text100002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 1000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'col1000';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$colcount = 1000;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $colcount ." ". $l_news_cols;
$l_news_c_text10002=str_replace("[name]",$name,$l_news_c_text1000);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col1000');", array($headline, $l_news_c_text10002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 500000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='col500';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$colcount = 500;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $colcount ." ". $l_news_cols;
$l_news_c_text5002=str_replace("[name]",$name,$l_news_c_text500);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col500');", array($headline, $l_news_c_text5002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 100000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='col100';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$colcount = 100;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $colcount ." ". $l_news_cols;
$l_news_c_text1002=str_replace("[name]",$name,$l_news_c_text100);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col100');", array($headline, $l_news_c_text1002, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
elseif ($row['amount'] >= 25000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id=? AND news_type='col25';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$colcount = 25;
$name = get_player_name($row['owner']);
$l_news_p_headline2=str_replace("[player]",$name,$l_news_p_headline);
$headline = $l_news_p_headline2 ." ". $colcount ." ". $l_news_cols;
$l_news_c_text252=str_replace("[name]",$name,$l_news_c_text25);
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'col25');", array($headline, $l_news_c_text252, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
$sql->MoveNext();
} // while
// end generation of colonist amount
$sql = $db->Execute("SELECT SUM(credits) AS amount, owner FROM {$db->prefix}planets WHERE owner !='0' GROUP BY owner ORDER BY amount ASC;");
db_op_result ($db, $sql, __LINE__, __FILE__, $db_logging);
while (!$sql->EOF)
{
$row = $sql->fields;
if ($row['amount'] >= 500000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'credit_1';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$name = get_player_name($row['owner']);
$headline = "Federation Credit Inspection Report";
$l_news = "While doing routine checks on planets, it was discovered that ".$name."'s empire has amassed a vast wealth of over 500 Billion credits in storage, we will be keeping a close eye on the books from here on out.";
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'credit_1');", array($headline, $l_news, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 1000000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'credit_2';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$name = get_player_name($row['owner']);
$headline = "Federation Credit Inspection Report";
$l_news = "While doing routine checks on planets, it was discovered that ".$name."'s empire has amassed a vast wealth of over 1 Trillion credits in storage, why ".$name." is building up a large cash reserve has yet to be determined!.";
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'credit_2');", array($headline, $l_news, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
else if ($row['amount'] >= 100000000000000)
{
$sql2 = $db->Execute("SELECT * FROM {$db->prefix}news WHERE user_id = ? AND news_type = 'credit_3';", array($row['owner']));
db_op_result ($db, $sql2, __LINE__, __FILE__, $db_logging);
if ($sql2->EOF)
{
$name = get_player_name($row['owner']);
$headline = "Federation Credit Inspection Report";
$l_news = "After previous reports, inspectors organised another inspection of ".$name."'s banks, however while carrying out this inspection, the inspectors went missing. A coded message was later intercepted, and contain the following.. ".$name." has amassed a vast wealth of over 100 trillion credits, and is in a position to threaten the stability of the federation.";
$news = $db->Execute("INSERT INTO {$db->prefix}news (headline, newstext, user_id, date, news_type) VALUES (?, ?, ?, NOW(), 'credit_3');", array($headline, $l_news, $row['owner']));
db_op_result ($db, $news, __LINE__, __FILE__, $db_logging);
}
}
$sql->MoveNext();
} // while
$multiplier = 0; // No need to run this again
?>