create_log_entry()   F
last analyzed

Complexity

Conditions 324

Size

Total Lines 1182
Code Lines 718

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 324
eloc 718
c 1
b 0
f 0
nop 6
dl 0
loc 1182
rs 3.3333

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/***************************************************************************
3
 *                                functions.php
4
 *                            --------------------------
5
 *   begin                : Monday, 26 January, 2004
6
 *   copyright            : (C) 2003 Atari Legend
7
 *   email                : [email protected]
8
 *   actual update        :
9
 *
10
 *   Id: functions.php,v 0.10 2004/01/26 00:55 silver
11
 *   Id: functions.php,v 0.20 2016/08/17 STG - Added change log function
12
 *
13
 ***************************************************************************/
14
15
const MIME_TYPES_TO_EXT = array(
16
    "image/jpeg" => "jpg",
17
    "image/png" => "png",
18
    "image/x-png" => "png"
19
);
20
21
function InsertALCode($alcode) {
22
    $alcode = preg_replace(
23
        "#\[color\=(\#[0-9A-F]{0,6}|[A-z]+)\](.*)\[\/color\]#Ui",
24
        "<span style=\"color: $1;\">$2</span>", $alcode
25
    );
26
    //$alcode = eregi_replace("\\[style=([^\\[]*)\\]","<span class=\"\\1\">",$alcode);
27
    //$alcode = str_replace("[/style]", "</span>", $alcode);
28
    $alcode = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is", "<span style=\"font-size: $1px\">$2</span>", $alcode);
29
    $alcode = preg_replace("#\[font\=(.*)\](.*)\[\/font\]#Ui", "<span style=\"font-family: $1;\">$2</span>", $alcode);
30
    $alcode = preg_replace("#\[align\=(.*)\](.*)\[\/align\]#Ui", "<span style=\" $1;\">$2</span>", $alcode);
31
    $alcode = str_replace("[move]", "<marquee>", $alcode);
32
    $alcode = str_replace("[/move]", "</marquee>", $alcode);
33
    $alcode = str_replace("[hr]", "<hr>", $alcode);
34
    $alcode = str_replace("[img]", "<img src=\"", $alcode);
35
    $alcode = str_replace("[/img]", "\" alt=''>", $alcode);
36
    $alcode = str_replace("[sub]", "<sub>", $alcode);
37
    $alcode = str_replace("[/sub]", "</sub>", $alcode);
38
    $alcode = str_replace("[tt]", "<tt>", $alcode);
39
    $alcode = str_replace("[/tt]", "</tt>", $alcode);
40
    $alcode = str_replace("[sup]", "<sup>", $alcode);
41
    $alcode = str_replace("[/sup]", "</sup>", $alcode);
42
    $alcode = str_replace("[screenstar]", "", $alcode);
43
    $alcode = str_replace("[/screenstar]", "", $alcode);
44
    $alcode = str_replace("[frontpage]", "", $alcode);
45
    $alcode = str_replace("[/frontpage]", "", $alcode);
46
    $alcode = preg_replace("#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $alcode);
47
    $alcode = preg_replace("#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $alcode);
48
    $alcode = preg_replace("#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $alcode);
49
    $alcode = preg_replace("#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $alcode);
50
    $alcode = str_replace("[*]", "<li>", $alcode);
51
    $alcode = str_replace("[list]", "<ul>", $alcode);
52
    $alcode = str_replace("[/list]", "</ul>", $alcode);
53
    $alcode = preg_replace("#\[email\=(.*)\](.*)\[\/email\]#Ui", "<a href=\"mailto: $1\">$2</a>", $alcode);
54
    $alcode = preg_replace("#\[email\](.*)\[\/email\]#Ui", "<a href=\"mailto: $1\">$1</a>", $alcode);
55
    $alcode = preg_replace("#\[hotspot\=(.*)\](.*)\[\/hotspot\]#Ui", "<a name=\"$1\">$2</a>", $alcode);
56
    $alcode = str_replace("[quote]", "<blockquote><span class=\"12px\">quote:</span><hr>", $alcode);
57
    $alcode = str_replace("[/quote]", "<hr></blockquote>", $alcode);
58
    $alcode = str_replace("[code]", "<blockquote><pre>", $alcode);
59
    $alcode = str_replace("[/code]", "</pre></blockquote>", $alcode);
60
    $alcode = preg_replace("#\[url\](www\..+)\[\/url\]#i", "[url=http://$1]$1[/url]", $alcode);
61
    $alcode = preg_replace("#\[url\=(www\..+)\](.*)\[\/url\]#i", "[url=http://$1]$2[/url]", $alcode);
62
    $alcode = preg_replace(
63
        "#\[url\=(.*)\](.*)\[\/url\]#Ui", "<a href=\"$1\" class=\"standard_tile_link_black\">$2</a>",
64
        $alcode
65
    );
66
    $alcode = preg_replace(
67
        "#\[url\](.*)\[\/url\]#Ui",
68
        "<a href=\"$1\" class=\"standard_tile_link_black\">$1</a>",
69
        $alcode
70
    );
71
    $alcode = preg_replace(
72
        "#\[hotspotUrl\=(.*)\](.*)\[\/hotspotUrl\]#Ui",
73
        "<a href=\"$1\" class=\"standard_tile_link_black\">$2</a>",
74
        $alcode
75
    );
76
    $alcode = preg_replace(
77
        "#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is",
78
        "\\1<a href=\"\\2\" target=\"_blank\" class=\"standard_tile_link_black\">\\2</a>",
79
        $alcode
80
    );
81
    $alcode = preg_replace(
82
        "#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is",
83
        "\\1<a href=\"http://\\2\" target=\"_blank\" class=\"standard_tile_link_black\">\\2</a>",
84
        $alcode
85
    );
86
87
    $alcode = preg_replace(
88
        "@\[game=([0-9]+)\](.*?)\[/game\]@i",
89
        "<a href=\"".FRONT_URL."/games/$1\" class=\"standard_tile_link_black\">$2</a>",
0 ignored issues
show
Bug introduced by
The constant FRONT_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90
        $alcode
91
    );
92
93
    $alcode = preg_replace(
94
        "@\[review=([0-9]+)\](.*?)\[/review\]@i",
95
        "<a href=\"".FRONT_URL."/reviews/$1\" class=\"standard_tile_link_black\">$2</a>",
96
        $alcode
97
    );
98
99
    $alcode = preg_replace(
100
        "@\[interview=([0-9]+)\](.*?)\[/interview\]@i",
101
        "<a href=\"".FRONT_URL."/interviews/$1\""
102
            ." class=\"standard_tile_link_black\">$2</a>",
103
        $alcode
104
    );
105
106
    $alcode = preg_replace(
107
        "@\[article=([0-9]+)\](.*?)\[/article\]@i",
108
        "<a href=\"".FRONT_URL."/articles/$1\" class=\"standard_tile_link_black\">$2</a>",
109
        $alcode
110
    );
111
112
    $alcode = preg_replace(
113
        "@\[developer=([0-9]+)\](.*?)\[/developer\]@i",
114
        "<a href=\"".FRONT_URL."/games/search?developer_id=$1\" class=\"standard_tile_link_black\">$2</a>",
115
        $alcode
116
    );
117
118
    $alcode = preg_replace(
119
        "@\[publisher=([0-9]+)\](.*?)\[/publisher\]@i",
120
        "<a href=\"".FRONT_URL."/games/search?publisher_id=$1\" class=\"standard_tile_link_black\">$2</a>",
121
        $alcode
122
    );
123
124
    $alcode = preg_replace(
125
        "@\[individual=([0-9]+)\](.*?)\[/individual\]@i",
126
        "<a href=\"".FRONT_URL."/games/search?individual_id=$1\" class=\"standard_tile_link_black\">$2</a>",
127
        $alcode
128
    );
129
130
    $alcode = preg_replace(
131
        "@\[releaseYear]([0-9]+)\[/releaseYear\]@i",
132
        "<a href=\"".FRONT_URL."/games/search?year_id=$1\" class=\"standard_tile_link_black\">$1</a>",
133
        $alcode
134
    );
135
136
    return $alcode;
137
}
138
139
function BBCode($Text) {
140
    // Replace any html brackets with HTML Entities to prevent executing HTML or script
141
    // Don't use strip_tags here because it breaks [url] search by replacing & with amp
142
    $Text = str_replace("<", "&lt", $Text);
143
    $Text = str_replace(">", "&gt", $Text);
144
145
    // Set up the parameters for a URL search string
146
    $URLSearchString  = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
147
    // Set up the parameters for a MAIL search string
148
    $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
149
150
    // Perform URL Search
151
    $Text = preg_replace(
152
        "/\[url\]([$URLSearchString]*)\[\/url\]/",
153
        '<a href="$1" target="_blank" class="standard_tile_link_black">$1</a>',
154
        $Text
155
    );
156
    $Text = preg_replace(
157
        "(\[url\=([$URLSearchString]*)\](.+?)\[/url\])",
158
        '<a href="$1" target="_blank" class="standard_tile_link_black">$2</a>',
159
        $Text
160
    );
161
162
    // Perform MAIL Search
163
    $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
164
    $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
165
166
    // Check for bold text
167
    $Text = preg_replace("(\[b\](.+?)\[\/b])is", '<span style="font-weight:bold;">$1</span>', $Text);
168
169
    // Check for Italics text
170
    $Text = preg_replace("(\[i\](.+?)\[\/i\])is", '<span style="font-style: italic;">$1</span>', $Text);
171
172
    // Check for Underline text
173
    $Text = preg_replace("(\[u\](.+?)\[\/u\])is", '<span style="text-decoration: underline;">$1</span>', $Text);
174
175
    // Check for strike-through text
176
    $Text = preg_replace("(\[s\](.+?)\[\/s\])is", '<span class="strikethrough">$1</span>', $Text);
177
178
    // Check for over-line text
179
    $Text = preg_replace("(\[o\](.+?)\[\/o\])is", '<span class="overline">$1</span>', $Text);
180
181
    // Check for colored text
182
    $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is", "<span style=\"color: $1\">$2</span>", $Text);
183
184
    // Check for sized text
185
    $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is", "<span style=\"font-size: $1px\">$2</span>", $Text);
186
187
    // Check for list text
188
    $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>', $Text);
189
    $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>', $Text);
190
    $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>', $Text);
191
    $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>', $Text);
192
    $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>', $Text);
193
    $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>', $Text);
194
    $Text = str_replace("[*]", "<li>", $Text);
195
196
    // Check for font change text
197
    $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])", "<span style=\"font-family: $1;\">$2</span>", $Text);
198
199
    // Declare the format for [code] layout
200
    $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
201
                        <tr>
202
                            <td class="quotecodeheader"> Code:</td>
203
                        </tr>
204
                        <tr>
205
                            <td class="codebody">$1</td>
206
                        </tr>
207
                   </table>';
208
    // Check for [code] text
209
    $Text       = preg_replace("/\[code\](.+?)\[\/code\]/is", "$CodeLayout", $Text);
210
211
    // Declare the format for [quote] layout
212
    $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
213
                        <tr>
214
                            <td class="quotecodeheader"> Quote:</td>
215
                        </tr>
216
                        <tr>
217
                            <td class="quotebody">$1</td>
218
                        </tr>
219
                   </table>';
220
221
    // Check for [code] text
222
    $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is", "$QuoteLayout", $Text);
223
224
    // Images
225
    // [img]pathtoimage[/img]
226
    $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text);
227
228
    // [img=widthxheight]image source[/img]
229
    $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" height="$2" width="$1">', $Text);
230
231
    // urls without using the url tag
232
    $Text = preg_replace(
233
        "#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is",
234
        "\\1<a href=\"\\2\" target=\"_blank\" class=\"standard_tile_link\">\\2</a>",
235
        $Text
236
    );
237
238
    $Text = preg_replace(
239
        "#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is",
240
        "\\1<a href=\"http://\\2\" target=\"_blank\" class=\"standard_tile_link\">\\2</a>",
241
        $Text
242
    );
243
244
    return $Text;
245
}
246
247
function InsertSmillies($alcode) {
248
    $alcode = str_replace(
249
        ":-D", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_biggrin.gif\">",
250
        $alcode
251
    );
252
    $alcode = str_replace(
253
        ":)", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_smile.gif\">",
254
        $alcode
255
    );
256
    $alcode = str_replace(
257
        ":(", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_sad.gif\">",
258
        $alcode
259
    );
260
    $alcode = str_replace(
261
        "8O", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_eek.gif\">",
262
        $alcode
263
    );
264
    $alcode = str_replace(
265
        ":?", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_confused.gif\">",
266
        $alcode
267
    );
268
    $alcode = str_replace(
269
        " 8)", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_cool.gif\">",
270
        $alcode
271
    );
272
    $alcode = str_replace(
273
        ":x", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_mad.gif\">",
274
        $alcode
275
    );
276
    $alcode = str_replace(
277
        ":P", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_razz.gif\">",
278
        $alcode
279
    );
280
    $alcode = str_replace(
281
        ":oops:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_redface.gif\">",
282
        $alcode
283
    );
284
    $alcode = str_replace(
285
        ":evil:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_evil.gif\">",
286
        $alcode
287
    );
288
    $alcode = str_replace(
289
        ":twisted:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_twisted.gif\">",
290
        $alcode
291
    );
292
    $alcode = str_replace(
293
        ":roll:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_rolleyes.gif\">",
294
        $alcode
295
    );
296
    $alcode = str_replace(
297
        ":frown:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_frown.gif\">",
298
        $alcode
299
    );
300
    $alcode = str_replace(
301
        ":|", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_neutral.gif\">",
302
        $alcode
303
    );
304
    $alcode = str_replace(
305
        ":mrgreen:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_mrgreen.gif\">",
306
        $alcode
307
    );
308
    $alcode = str_replace(
309
        ":o", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_surprised.gif\">",
310
        $alcode
311
    );
312
    $alcode = str_replace(
313
        ":lol:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_lol.gif\">",
314
        $alcode
315
    );
316
    $alcode = str_replace(
317
        ":cry:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_cry.gif\">",
318
        $alcode
319
    );
320
    $alcode = str_replace(
321
        ";)", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_wink.gif\">",
322
        $alcode
323
    );
324
    $alcode = str_replace(
325
        ":wink:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_wink.gif\">",
326
        $alcode
327
    );
328
    $alcode = str_replace(
329
        ":!:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_exclaim.gif\">",
330
        $alcode
331
    );
332
    $alcode = str_replace(
333
        ":arrow:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_arrow.gif\">",
334
        $alcode
335
    );
336
    $alcode = str_replace(
337
        ":?:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_question.gif\">",
338
        $alcode
339
    );
340
    $alcode = str_replace(
341
        ":idea:", "<img style=\"vertical-align: middle;\" src=\"../templates/0/emoticons/icon_idea.gif\">",
342
        $alcode
343
    );
344
    return $alcode;
345
}
346
347
function RemoveSmillies($alcode) {
348
    $alcode = str_replace(":-D", "", $alcode);
349
    $alcode = str_replace(":)", "", $alcode);
350
    $alcode = str_replace(":(", "", $alcode);
351
    $alcode = str_replace("8O", "", $alcode);
352
    $alcode = str_replace(":?", "", $alcode);
353
    $alcode = str_replace(" 8)", "", $alcode);
354
    $alcode = str_replace(":x", "", $alcode);
355
    $alcode = str_replace(":P", "", $alcode);
356
    $alcode = str_replace(":oops:", "", $alcode);
357
    $alcode = str_replace(":evil:", "", $alcode);
358
    $alcode = str_replace(":twisted:", "", $alcode);
359
    $alcode = str_replace(":roll:", "", $alcode);
360
    $alcode = str_replace(":frown:", "", $alcode);
361
    $alcode = str_replace(":|", "", $alcode);
362
    $alcode = str_replace(":mrgreen:", "", $alcode);
363
    $alcode = str_replace(":o", "", $alcode);
364
    $alcode = str_replace(":lol:", "", $alcode);
365
    $alcode = str_replace(":cry:", "", $alcode);
366
    $alcode = str_replace(";)", "", $alcode);
367
    $alcode = str_replace(":wink:", "", $alcode);
368
    $alcode = str_replace(":!:", "", $alcode);
369
    $alcode = str_replace(":arrow:", "", $alcode);
370
    $alcode = str_replace(":?:", "", $alcode);
371
    $alcode = str_replace(":idea:", "", $alcode);
372
    return $alcode;
373
}
374
375
function get_username_from_id($submitted) {
376
    global $mysqli;
377
    $result = $mysqli->query("SELECT userid FROM users WHERE user_id = $submitted") or die("Query failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
378
    if ($result->num_rows == 0) {
379
        return 0;
380
    } else {
381
        $query_data = $result->fetch_array(MYSQLI_BOTH);
382
        return $query_data['userid'];
383
    }
384
}
385
386
function date_to_timestamp($date_Year, $date_Month, $date_Day) {
387
    $timestamp = mktime(0, 0, 0, $date_Month, $date_Day, $date_Year);
388
    return $timestamp;
389
}
390
391
function filter($entry) {
392
    // Filter out strange characters like ^, $, &, change "it's" to "its"
393
    static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '"', '|', ',', '@', '_', '?', '%', '-',
394
        '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
395
    static $drop_char_replace = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
396
        '', '', '', '', '', '', '', '', '', '', '');
397
398
    for ($i = 0; $i < count($drop_char_match); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
399
        $entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
400
    }
401
    return $entry;
402
}
403
404
function search($entry) {
405
    // search for strange characters like ^, $, &, change "it's" to "its"
406
    static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '"', '|', ',', '@', '_', '?', '%', '-', '~',
407
         '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
408
409
    $count = 0;
410
411
    for ($i = 0; $i < count($drop_char_match); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
412
        if ($count == 0) {
413
            $count = substr_count($entry, $drop_char_match[$i]);
414
        }
415
    }
416
    return $count;
417
}
418
419
function az_dropdown_value($entry) {
0 ignored issues
show
Unused Code introduced by
The parameter $entry is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

419
function az_dropdown_value(/** @scrutinizer ignore-unused */ $entry) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
420
    $entry = array(
421
        'num',
422
        'a',
423
        'b',
424
        'c',
425
        'd',
426
        'e',
427
        'f',
428
        'g',
429
        'h',
430
        'i',
431
        'j',
432
        'k',
433
        'l',
434
        'm',
435
        'n',
436
        'o',
437
        'p',
438
        'q',
439
        'r',
440
        's',
441
        't',
442
        'u',
443
        'v',
444
        'w',
445
        'x',
446
        'y',
447
        'z'
448
    );
449
450
    return $entry;
451
}
452
453
function az_dropdown_output($entry) {
0 ignored issues
show
Unused Code introduced by
The parameter $entry is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

453
function az_dropdown_output(/** @scrutinizer ignore-unused */ $entry) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
454
    $entry = array(
455
        '0-9',
456
        'A',
457
        'B',
458
        'C',
459
        'D',
460
        'E',
461
        'F',
462
        'G',
463
        'H',
464
        'I',
465
        'J',
466
        'K',
467
        'L',
468
        'M',
469
        'N',
470
        'O',
471
        'P',
472
        'Q',
473
        'R',
474
        'S',
475
        'T',
476
        'U',
477
        'V',
478
        'W',
479
        'X',
480
        'Y',
481
        'Z'
482
    );
483
484
    return $entry;
485
}
486
487
function statistics_stack() {
488
    global $mysqli;
489
490
    //**************************
491
    // Get all the random stats
492
    //**************************
493
494
    // START - NUMBER OF GAMES IN ARCHIVE
495
    $query     = $mysqli->query("SELECT COUNT(*) AS count FROM game");
496
    $gamecount = $query->fetch_array(MYSQLI_BOTH);
497
    $stack[]   = "$gamecount[count] games in archive";
0 ignored issues
show
Comprehensibility Best Practice introduced by
$stack was never initialized. Although not strictly required by PHP, it is generally a good practice to add $stack = array(); before regardless.
Loading history...
498
499
    // END - NUMBER OF GAMES IN ARCHIVE
500
501
    mysqli_free_result($query);
502
503
    // START - RELEASE STATS
504
    $query     = $mysqli->query("SELECT COUNT(id) AS count FROM game_release");
505
    $game_releases = $query->fetch_array(MYSQLI_BOTH);
506
    $stack[]   = "$game_releases[count] releases in archive";
507
508
    // END - RELEASE STATS
509
510
    mysqli_free_result($query);
511
512
    // START - COUNT GAME SCREENSHOTS IN ARCHIVE
513
    $query           = $mysqli->query("SELECT COUNT(*) AS count FROM screenshot_game");
514
    $gamescreencount = $query->fetch_array(MYSQLI_BOTH);
515
    $stack[]         = "$gamescreencount[count] game screenshots in archive";
516
517
    // END - COUNT GAME SCREENSHOTS IN ARCHIVE
518
519
    mysqli_free_result($query);
520
521
    // START - COUNT HOW MANY GAMES HAS SCREENSHOT
522
    $query       = $mysqli->query("SELECT COUNT(DISTINCT game_id) AS count FROM screenshot_game");
523
    $screencount = $query->fetch_array(MYSQLI_BOTH);
524
    $stack[]     = "$screencount[count] games have screenshots";
525
526
    // END - COUNT HOW MANY GAMES HAS SCREENSHOT
527
528
    mysqli_free_result($query);
529
530
    // START - COUNT COMPANIES IN ARCHIVE
531
    $query   = $mysqli->query("SELECT COUNT(*) AS count FROM pub_dev");
532
    $pubdev  = $query->fetch_array(MYSQLI_BOTH);
533
    $stack[] = "$pubdev[count] companies in the archive";
534
535
    // END - COUNT COMPANIES IN ARCHIVE
536
537
    mysqli_free_result($query);
538
539
    // START - COUNT HOW MANY GAMES HAS PUBLISHER ASSIGNED
540
    $query     = $mysqli->query("SELECT COUNT(distinct id) AS count FROM game_release WHERE pub_dev_id != 0");
541
    $publisher = $query->fetch_array(MYSQLI_BOTH);
542
    $stack[]   = "$publisher[count] games have a publisher assigned";
543
544
    // END - COUNT HOW MANY GAMES HAS PUBLISHER ASSIGNED
545
546
    //mysqli_free_result($query);
547
548
    // START - COUNT HOW MANY GAMES HAS DEVELOPER ASSIGNED
549
    $query     = $mysqli->query("SELECT COUNT(DISTINCT game_id) AS count FROM game_developer");
550
    $developer = $query->fetch_array(MYSQLI_BOTH);
551
    $stack[]   = "$developer[count] games have a developer assigned";
552
553
    // END - COUNT HOW MANY GAMES HAS DEVELOPER ASSIGNED
554
555
    mysqli_free_result($query);
556
557
    // START - COUNT HOW MANY GAMES HAS CATEGORIES SET
558
    $query         = $mysqli->query("SELECT COUNT(DISTINCT game_id) AS count FROM game_genre_cross");
559
    // Special case here due to the migration from game_categories to game_genre
560
    // This fails until the DB update script is run because the game_genre_cross
561
    // table doesn't exist. It prevents accessing the site and CPANEL, preventing
562
    // to run the DB update script... So just handle the error and skip this line
563
    // of stats until the DB update script is run and the table exists.
564
    if ($query) {
565
        $game_genre    = $query->fetch_array(MYSQLI_BOTH);
566
        $stack[]       = "$game_genre[count] games have a genre set";
567
        mysqli_free_result($query);
568
    }
569
    // END - COUNT HOW MANY GAMES HAS CATEGORIES SET
570
571
    // START - COUNT HOW MANY GAMES HAS DOWNLOAD
572
    // To do
573
574
    // START - GAME REVIEW STATS
575
    $query       = $mysqli->query("SELECT COUNT(DISTINCT game_id) AS count FROM review_game");
576
    $review_game = $query->fetch_array(MYSQLI_BOTH);
577
    $stack[]     = "$review_game[count] games have been reviewed";
578
579
    // END - GAME REVIEW STATS
580
581
    mysqli_free_result($query);
582
583
    // START - USER STATS
584
    $query   = $mysqli->query("SELECT COUNT(user_id) AS count FROM users");
585
    $users   = $query->fetch_array(MYSQLI_BOTH);
586
    $stack[] = "$users[count] registered users";
587
588
    // END - USER STATS
589
590
    mysqli_free_result($query);
591
592
    // START - ARTICLE STATS
593
    $query        = $mysqli->query("SELECT COUNT(DISTINCT article_id) AS count FROM article_main");
594
    $article_main = $query->fetch_array(MYSQLI_BOTH);
595
    $stack[]      = "$article_main[count] articles in archive";
596
597
    // END - ARTICLE STATS
598
599
    mysqli_free_result($query);
600
601
    // START - LINKS STATS
602
    $query   = $mysqli->query("SELECT COUNT(website_id) AS count FROM website");
603
    $website = $query->fetch_array(MYSQLI_BOTH);
604
    $stack[] = "$website[count] links in archive";
605
606
    // END - LINKS STATS
607
608
    mysqli_free_result($query);
609
610
    // START - music STATS
611
    $query   = $mysqli->query("SELECT COUNT(DISTINCT game_id) AS count FROM game_sndh");
612
    $music   = $query->fetch_array(MYSQLI_BOTH);
613
    $stack[] = "$music[count] games have music attached";
614
615
    // END - music STATS
616
617
    mysqli_free_result($query);
618
619
    // START - music STATS
620
    $query   = $mysqli->query("SELECT COUNT(id) AS count FROM sndhs");
621
    $music   = $query->fetch_array(MYSQLI_BOTH);
622
    $stack[] = "$music[count] gamemusic files are uploaded";
623
624
    // END - music STATS
625
626
    return $stack;
627
}
628
629
//This function will create a change log table entry according to its parameters. In the db* files, with every DB
630
// transaction, this function is called. The table is used for the change log section of the cpanel.
631
function create_log_entry($section, $section_id, $subsection, $subsection_id, $action, $user_id) {
632
    global $mysqli;
633
634
    //  Everything we do for the GAMES SECTION
635
    if ($section == 'Games') {
636
        if ($subsection == 'Submission') {
637
            // get game id
638
            $query_game_id = "SELECT game_id FROM game_submitinfo WHERE game_submitinfo_id = '$section_id'";
639
            $result = $mysqli->query($query_game_id) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
640
            $query_data = $result->fetch_array(MYSQLI_BOTH);
641
            $section_id = $query_data['game_id'];
642
            $subsection_id = $query_data['game_id'];
643
        }
644
645
        //  get the game name
646
        $query_game = "SELECT game_name FROM game WHERE game_id = '$section_id'";
647
        $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
648
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
649
        $section_name = $query_data['game_name'];
650
651
        if ($subsection == 'Game' or $subsection == 'File' or $subsection == 'Screenshot' or $subsection == 'Mag score'
652
            or $subsection == 'Box back' or $subsection == 'Box front' or $subsection == 'Review'
653
            or $subsection == 'Review comment' or $subsection == 'Music' or $subsection == 'Submission'
654
            or $subsection == 'Fact' or $subsection == 'Sound hardware') {
655
            $subsection_name = $section_name;
656
        }
657
658
        if ($subsection == 'AKA') {
659
            //  get the AKA name
660
            $query_aka = "SELECT aka_name FROM game_aka WHERE game_aka_id = '$subsection_id'";
661
            $result = $mysqli->query($query_aka) or die("getting aka name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
662
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
663
            $subsection_name = $query_data['aka_name'];
664
            $subsection_id   = $section_id;
665
        }
666
667
        if ($subsection == 'Creator') {
668
            if ($action == 'Delete') {
669
                //  get the ind name & id
670
                $query_ind = "SELECT individuals.ind_id,
671
                                     individuals.ind_name FROM individuals
672
                                     LEFT JOIN game_author ON ( individuals.ind_id = game_author.ind_id )
673
                                     WHERE game_author.game_author_id = '$subsection_id'";
674
                $result = $mysqli->query($query_ind) or die("getting ind name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
675
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
676
                $subsection_name = $query_data['ind_name'];
677
                $subsection_id   = $query_data['ind_id'];
678
            } else {
679
                //  get the ind name
680
                $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$subsection_id'";
681
                $result = $mysqli->query($query_ind) or die("getting ind name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
682
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
683
                $subsection_name = $query_data['ind_name'];
684
            }
685
        }
686
687
        if ($subsection == 'Publisher' or $subsection == 'Developer') {
688
            //  get the pub/dev name
689
            $query_pubdev = "SELECT pub_dev_name FROM pub_dev WHERE pub_dev_id = '$subsection_id'";
690
            $result = $mysqli->query($query_pubdev) or die("getting pub/dev name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
691
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
692
            $subsection_name = $query_data['pub_dev_name'];
693
        }
694
695
        if ($subsection == 'Year') {
696
            die("The table game_year has been deprecated and should not be used anymore");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
697
        }
698
699
        if ($subsection == 'Similar') {
700
            if ($action == 'Delete') {
701
                // get the cross id
702
                $query_cross = "SELECT game_similar_cross FROM game_similar WHERE game_similar_id = '$subsection_id'";
703
                $result = $mysqli->query($query_cross) or die("getting cross failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
704
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
705
                $subsection_id = $query_data['game_similar_cross'];
706
            }
707
            //  get the game name
708
            $query_game = "SELECT game_name FROM game WHERE game_id = '$subsection_id'";
709
            $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
710
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
711
            $subsection_name = $query_data['game_name'];
712
            $subsection_id   = $section_id;
713
        }
714
715
        if ($subsection == 'Comment') {
716
            //get game_id and game_user_comments_id
717
            $query_user_comment = "SELECT game_user_comments.game_id,
718
                                          game_user_comments.game_user_comments_id,
719
                                          game.game_name
720
                                          FROM game_user_comments
721
                                          LEFT JOIN game ON ( game.game_id = game_user_comments.game_id )
722
                                          WHERE game_user_comments.comment_id = '$subsection_id'";
723
724
            $result = $mysqli->query($query_user_comment) or die("getting user comments id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
725
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
726
            $subsection_id   = $query_data['game_user_comments_id'];
727
            $section_id      = $query_data['game_id'];
728
            $section_name    = $query_data['game_name'];
729
            $subsection_name = $query_data['game_name'];
730
        }
731
    }
732
733
    //  Everything we do for the GAMES SERIES SECTION
734
    if ($section == 'Game series') {
735
        if ($subsection == 'Game') {
736
            if ($action == 'Delete') {
737
                //get the game_id and game_series_id
738
                $query_series = "SELECT game_id, game_series_id FROM game_series_cross
739
                    WHERE game_series_cross_id = '$subsection_id'";
740
                $result = $mysqli->query($query_series) or die("getting series info failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
741
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
742
                $subsection_id = $query_data['game_id'];
743
                $section_id    = $query_data['game_series_id'];
744
            }
745
746
            //  get the game name
747
            $query_game = "SELECT game_name FROM game WHERE game_id = '$subsection_id'";
748
            $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
749
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
750
            $subsection_name = $query_data['game_name'];
751
        }
752
753
        //  get the name of the series
754
        $query_series = "SELECT game_series_name FROM game_series WHERE game_series_id = '$section_id'";
755
        $result = $mysqli->query($query_series) or die("getting series name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
756
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
757
        $section_name = $query_data['game_series_name'];
758
759
        if ($subsection == 'Series') {
760
            $subsection_name = $section_name;
761
        }
762
    }
763
764
    //  Everything we do for the Trivia SECTION
765
    if ($section == 'Trivia') {
766
        if ($subsection == 'DYK' or $subsection == 'Quote' or $subsection == 'Spotlight') {
767
            $subsection_name = ("Trivia ID " . $subsection_id);
768
            $section_name    = ("Trivia ID " . $subsection_id);
769
        }
770
    }
771
772
    //  Everything we do for the LINKS section
773
    if ($section == 'Links') {
774
        // Get the website name
775
        $query_website = "SELECT website_name FROM website WHERE website_id = '$section_id'";
776
        $result = $mysqli->query($query_website) or die("getting website name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
777
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
778
        $section_name = $query_data['website_name'];
779
780
        if ($subsection == 'Link') {
781
            $subsection_name = $section_name;
782
        }
783
784
        if ($subsection == 'Category') {
785
            // Get the category name
786
            $query_cat = "SELECT website_category_name FROM website_category
787
                WHERE website_category_id = '$subsection_id'";
788
            $result = $mysqli->query($query_cat) or die("getting category name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
789
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
790
            $subsection_name = $query_data['website_category_name'];
791
        }
792
793
        if ($subsection == 'Link submit') {
794
            // Get the submitted link
795
            $query_link =  "SELECT website_name FROM website_validate WHERE website_id = $subsection_id";
796
            $result = $mysqli->query($query_link) or die("getting submitted link name failed: ".$mysqli->error);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
797
            $query_data = $result->fetch_array(MYSQLI_BOTH);
798
            $section_name = $query_data['website_name'];
799
            $subsection_name = $query_data['website_name'];
800
        }
801
    }
802
803
    //  Everything we do for the LINKS CATEGORY section
804
    if ($section == 'Links cat') {
805
        // Get the category name
806
        $query_cat = "SELECT website_category_name FROM website_category WHERE website_category_id = '$section_id'";
807
        $result = $mysqli->query($query_cat) or die("getting category name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
808
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
809
        $section_name = $query_data['website_category_name'];
810
811
        if ($subsection == 'Category') {
812
            $subsection_name = $section_name;
813
        }
814
    }
815
816
    //  Everything we do for the COMPANY section
817
    if ($section == 'Company') {
818
        // Get the company name
819
        $query_comp = "SELECT pub_dev_name FROM pub_dev WHERE pub_dev_id = '$section_id'";
820
        $result = $mysqli->query($query_comp) or die("getting comp name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
821
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
822
        $section_name = $query_data['pub_dev_name'];
823
824
        if ($subsection == 'Company' or $subsection == 'Logo') {
825
            $subsection_name = $section_name;
826
        }
827
    }
828
829
    //  Everything we do for the Individual section
830
    if ($section == 'Individuals') {
831
        if ($subsection == 'Nickname') {
832
            if ($action == 'Delete') {
833
                // we need to get the ind id
834
                $query_ind = "SELECT ind_id FROM individual_nicks WHERE nick_id = '$section_id'";
835
                $result = $mysqli->query($query_ind) or die("getting individual id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
836
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
837
                $section_id    = $query_data['ind_id'];
838
                $subsection_id = $query_data['ind_id'];
839
            }
840
        }
841
842
        // Get the individual name
843
        $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$section_id'";
844
        $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
845
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
846
        $section_name = $query_data['ind_name'];
847
848
        if ($subsection == 'Individual' or $subsection == 'Image' or $subsection == 'Nickname') {
849
            $subsection_name = $section_name;
850
        }
851
    }
852
853
    //  Everything we do for the AUTHor TYPE section
854
    if ($section == 'Author type') {
855
        // get the author type name
856
        $query_author = "SELECT author_type_info FROM author_type WHERE author_type_id = '$section_id'";
857
        $result = $mysqli->query($query_author) or die("getting author type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
858
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
859
        $section_name = $query_data['author_type_info'];
860
861
        if ($subsection == 'Author type') {
862
            $subsection_name = $section_name;
863
        }
864
    }
865
866
    //  Everything we do for the INTERVIEW section
867
    if ($section == 'Interviews') {
868
        if ($subsection == 'Interview') {
869
            if ($action == 'Update' or $action == 'Delete') {
870
                //we need to get the individual id
871
                $query_ind = "SELECT ind_id FROM interview_main WHERE interview_id = '$section_id'";
872
                $result = $mysqli->query($query_ind) or die("getting ind id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
873
                $query_data = $result->fetch_array(MYSQLI_BOTH);
874
                $section_id = $query_data['ind_id'];
875
            }
876
        }
877
878
        if ($subsection == 'Screenshots') {
879
            if ($action == 'Insert' or $action == 'Delete') {
880
                //we need to get the individual id
881
                $query_ind = "SELECT ind_id FROM interview_main WHERE interview_id = '$section_id'";
882
                $result = $mysqli->query($query_ind) or die("getting ind id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
883
                $query_data = $result->fetch_array(MYSQLI_BOTH);
884
                $section_id = $query_data['ind_id'];
885
            }
886
        }
887
888
        // get the name of the person that is interviewed
889
        $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$section_id'";
890
        $result = $mysqli->query($query_ind) or die("getting ind name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
891
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
892
        $section_name = $query_data['ind_name'];
893
894
        if ($subsection == 'Interview' or $subsection == 'Screenshots') {
895
            $subsection_name = $section_name;
896
        }
897
898
        if ($subsection == 'Comment') {
899
            //get game_id and interview_user_comments_id
900
            $query_user_comment = "SELECT interview_user_comments.interview_id,
901
                interview_user_comments.interview_user_comments_id,
902
                individuals.ind_name
903
                FROM interview_user_comments
904
                LEFT JOIN interview_main ON ( interview_user_comments.interview_id = interview_main.interview_id )
905
                LEFT JOIN individuals on (interview_main.ind_id = individuals.ind_id)
906
                WHERE interview_user_comments.comment_id = '$subsection_id'";
907
908
            $result = $mysqli->query($query_user_comment) or die("getting user comments id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
909
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
910
            $subsection_id   = $query_data['interview_user_comments_id'];
911
            $section_id      = $query_data['interview_id'];
912
            $section_name    = $query_data['ind_name'];
913
            $subsection_name = $query_data['ind_name'];
914
        }
915
    }
916
917
    //  Everything we do for the Review section
918
    if ($section == 'Reviews') {
919
        if ($subsection == 'Comment') {
920
            //get the game name
921
            $query_user_comment = "SELECT * FROM review_user_comments
922
                LEFT JOIN review_main ON (review_user_comments.review_id = review_main.review_id)
923
                LEFT JOIN review_game ON (review_main.review_id = review_game.review_id)
924
                LEFT JOIN game ON (game.game_id = review_game.game_id)
925
                WHERE review_user_comments.comment_id = '$subsection_id'";
926
927
            $result = $mysqli->query($query_user_comment) or die("getting user comments id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
928
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
929
            $subsection_id   = $query_data['review_user_comments_id'];
930
            $section_id      = $query_data['review_id'];
931
            $section_name    = $query_data['game_name'];
932
            $subsection_name = $query_data['game_name'];
933
        }
934
    }
935
936
    //  Everything we do for the AUTHor TYPE section
937
    if ($section == 'News') {
938
        if ($subsection == 'News submit') {
939
            // get the headline
940
            $query_news = "SELECT news_headline FROM news_submission WHERE news_submission_id = '$section_id'";
941
            $result = $mysqli->query($query_news) or die("getting headline failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
942
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
943
            $section_name = $query_data['news_headline'];
944
945
            $subsection_name = $section_name;
946
        }
947
948
        if ($subsection == 'News item') {
949
            // get the headline
950
            $query_news = "SELECT news_headline FROM news WHERE news_id = '$section_id'";
951
            $result = $mysqli->query($query_news) or die("getting headline failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
952
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
953
            $section_name = $query_data['news_headline'];
954
955
            $subsection_name = $section_name;
956
        }
957
958
        if ($subsection == 'Image') {
959
            // get the image name
960
            $query_image = "SELECT news_image_name FROM news_image WHERE news_image_id = '$section_id'";
961
            $result = $mysqli->query($query_image) or die("getting image name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
962
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
963
            $section_name = $query_data['news_image_name'];
964
965
            $subsection_name = $section_name;
966
        }
967
    }
968
969
    //  Everything we do for the Menu Set SECTION
970
    if ($section == 'Menu set') {
971
        //  get the menu set name
972
        $query_menu_Set = "SELECT menu_sets_name FROM menu_set WHERE menu_sets_id = '$section_id'";
973
        $result = $mysqli->query($query_menu_Set) or die("getting menu set name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
974
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
975
        $section_name = $query_data['menu_sets_name'];
976
977
        if ($subsection == 'Menu set' or $subsection == 'Menu disk (multiple)') {
978
            $subsection_name = $section_name;
979
        }
980
981
        if ($subsection == 'Crew') {
982
            // get the name of the crew
983
            $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$subsection_id'";
984
            $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
985
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
986
            $subsection_name = $query_data['crew_name'];
987
        }
988
989
        if ($subsection == 'Individual') {
990
            // get the name of the crew
991
            $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$subsection_id'";
992
            $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
993
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
994
            $subsection_name = $query_data['ind_name'];
995
        }
996
997
        if ($subsection == 'Menu type') {
998
            // get the name of the menu type
999
            $query_menu_type = "SELECT menu_types_text FROM menu_types_main
1000
                WHERE menu_types_main_id = '$subsection_id'";
1001
            $result = $mysqli->query($query_menu_type) or die("getting menu type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1002
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1003
            $subsection_name = $query_data['menu_types_text'];
1004
        }
1005
1006
        if ($subsection == 'Menu disk') {
1007
            // get the name of the menu disk
1008
            $sql_menus = "SELECT menu_disk.menu_sets_id,
1009
                                menu_set.menu_sets_name,
1010
                                menu_disk.menu_disk_number,
1011
                                menu_disk.menu_disk_letter,
1012
                                menu_disk.menu_disk_version,
1013
                                menu_disk.menu_disk_part
1014
                                FROM menu_disk
1015
                                LEFT JOIN menu_set ON (menu_disk.menu_sets_id = menu_set.menu_sets_id)
1016
                                WHERE menu_disk.menu_disk_id = '$subsection_id'";
1017
1018
            $result_menus = $mysqli->query($sql_menus) or die("error in query disk name");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1019
1020
            while ($row = $result_menus->fetch_array(MYSQLI_BOTH)) {
1021
                // Create Menu disk name
1022
                $menu_disk_name = "$row[menu_sets_name] ";
1023
                if (isset($row['menu_disk_number'])) {
1024
                    $menu_disk_name .= "$row[menu_disk_number]";
1025
                }
1026
                if (isset($row['menu_disk_letter'])) {
1027
                    $menu_disk_name .= "$row[menu_disk_letter]";
1028
                }
1029
                if (isset($row['menu_disk_part'])) {
1030
                    if (is_numeric($row['menu_disk_part'])) {
1031
                        $menu_disk_name .= " part $row[menu_disk_part]";
1032
                    } else {
1033
                        $menu_disk_name .= "$row[menu_disk_part]";
1034
                    }
1035
                }
1036
            }
1037
            $subsection_name = $menu_disk_name;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $menu_disk_name does not seem to be defined for all execution paths leading up to this point.
Loading history...
1038
        }
1039
    }
1040
1041
    //  Everything we do for the CREW SECTION
1042
    if ($section == 'Crew') {
1043
        // get the name of the crew
1044
        $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$section_id'";
1045
        $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1046
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1047
        $section_name = $query_data['crew_name'];
1048
1049
        if ($subsection == 'Crew' or $subsection == 'Logo') {
1050
            $subsection_name = $section_name;
1051
        }
1052
1053
        if ($subsection == 'Subcrew') {
1054
            if ($action == 'Delete') {
1055
                // get the id's
1056
                $query_crew = "SELECT * FROM sub_crew WHERE sub_crew_id = '$subsection_id'";
1057
                $result = $mysqli->query($query_crew) or die("getting crew ids failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1058
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1059
                $subsection_id = $query_data['crew_id'];
1060
                $section_id    = $query_data['parent_id'];
1061
1062
                // get the name of the crew
1063
                $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$section_id'";
1064
                $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1065
                $query_data   = $result->fetch_array(MYSQLI_BOTH);
1066
                $section_name = $query_data['crew_name'];
1067
            }
1068
1069
            // get the name of the subcrew
1070
            $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$subsection_id'";
1071
            $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1072
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1073
            $subsection_name = $query_data['crew_name'];
1074
        }
1075
1076
        if ($subsection == 'Member') {
1077
            if ($action == 'Delete') {
1078
                // get the id's
1079
                $query_crew = "SELECT * FROM crew_individual WHERE crew_individual_id = '$subsection_id'";
1080
                $result = $mysqli->query($query_crew) or die("getting crew ids failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1081
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1082
                $subsection_id = $query_data['ind_id'];
1083
                $section_id    = $query_data['crew_id'];
1084
1085
                // get the name of the crew
1086
                $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$section_id'";
1087
                $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1088
                $query_data   = $result->fetch_array(MYSQLI_BOTH);
1089
                $section_name = $query_data['crew_name'];
1090
            }
1091
1092
            $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$subsection_id'";
1093
            $result = $mysqli->query($query_ind) or die("getting ind name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1094
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1095
            $subsection_name = $query_data['ind_name'];
1096
        }
1097
1098
        if ($subsection == 'Nickname') {
1099
            // get the id's
1100
            $query_crew = "SELECT * FROM crew_individual WHERE crew_individual_id = '$subsection_id'";
1101
            $result = $mysqli->query($query_crew) or die("getting crew ids failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1102
            $query_data    = $result->fetch_array(MYSQLI_BOTH);
1103
            $subsection_id = $query_data['ind_id'];
1104
            $section_id    = $query_data['crew_id'];
1105
1106
            // get the name of the crew
1107
            $query_crew = "SELECT crew_name FROM crew WHERE crew_id = '$section_id'";
1108
            $result = $mysqli->query($query_crew) or die("getting crew name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1109
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1110
            $section_name = $query_data['crew_name'];
1111
1112
            // get the name of the member
1113
            $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$subsection_id'";
1114
            $result = $mysqli->query($query_ind) or die("getting ind name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1115
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1116
            $subsection_name = $query_data['ind_name'];
1117
        }
1118
    }
1119
1120
    //  Everything we do for the MENU TYPE SECTION
1121
    if ($section == 'Menu type') {
1122
        // get the name of the menu type
1123
        $query_menu_type = "SELECT menu_types_text FROM menu_types_main WHERE menu_types_main_id = '$section_id'";
1124
        $result = $mysqli->query($query_menu_type) or die("getting menu type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1125
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1126
        $section_name = $query_data['menu_types_text'];
1127
1128
        if ($subsection == 'Menu type') {
1129
            $subsection_name = $section_name;
1130
        }
1131
    }
1132
1133
    //  Everything we do for the MENU DISK
1134
    if ($section == 'Menu disk') {
1135
        // get the name of the menu disk
1136
        $sql_menus = "SELECT menu_disk.menu_sets_id,
1137
                            menu_set.menu_sets_name,
1138
                            menu_disk.menu_disk_number,
1139
                            menu_disk.menu_disk_letter,
1140
                            menu_disk.menu_disk_version,
1141
                            menu_disk.menu_disk_part
1142
                            FROM menu_disk
1143
                            LEFT JOIN menu_set ON (menu_disk.menu_sets_id = menu_set.menu_sets_id)
1144
                            WHERE menu_disk.menu_disk_id = '$section_id'";
1145
1146
        $result_menus = $mysqli->query($sql_menus) or die("error in query disk name");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1147
1148
        while ($row = $result_menus->fetch_array(MYSQLI_BOTH)) {
1149
            $section_id = $row['menu_sets_id'];
1150
1151
            // Create Menu disk name
1152
            $menu_disk_name = "$row[menu_sets_name] ";
1153
            if (isset($row['menu_disk_number'])) {
1154
                $menu_disk_name .= "$row[menu_disk_number]";
1155
            }
1156
            if (isset($row['menu_disk_letter'])) {
1157
                $menu_disk_name .= "$row[menu_disk_letter]";
1158
            }
1159
            if (isset($row['menu_disk_part'])) {
1160
                if (is_numeric($row['menu_disk_part'])) {
1161
                    $menu_disk_name .= " part $row[menu_disk_part]";
1162
                } else {
1163
                    $menu_disk_name .= "$row[menu_disk_part]";
1164
                }
1165
            }
1166
        }
1167
1168
        $section_name = $menu_disk_name;
1169
1170
        if ($subsection == 'State') {
1171
            // get the name of the menu type
1172
            $query_menu_state = "SELECT menu_state FROM menu_disk_state WHERE state_id = '$subsection_id'";
1173
            $result = $mysqli->query($query_menu_state) or die("getting menu state name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1174
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1175
            $subsection_name = $query_data['menu_state'];
1176
        }
1177
1178
        if ($subsection == 'Parent') {
1179
            // get the name of the parent
1180
            $sql_menus = "SELECT menu_disk.menu_sets_id,
1181
                                menu_set.menu_sets_name,
1182
                                menu_disk.menu_disk_number,
1183
                                menu_disk.menu_disk_letter,
1184
                                menu_disk.menu_disk_version,
1185
                                menu_disk.menu_disk_part
1186
                                FROM menu_disk
1187
                                LEFT JOIN menu_set ON (menu_disk.menu_sets_id = menu_set.menu_sets_id)
1188
                                WHERE menu_disk.menu_disk_id = '$subsection_id'";
1189
1190
            $result_menus = $mysqli->query($sql_menus) or die("error in query disk name");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1191
1192
            while ($row = $result_menus->fetch_array(MYSQLI_BOTH)) {
1193
                // Create Menu disk name
1194
                $menu_disk_name = "$row[menu_sets_name] ";
1195
                if (isset($row['menu_disk_number'])) {
1196
                    $menu_disk_name .= "$row[menu_disk_number]";
1197
                }
1198
                if (isset($row['menu_disk_letter'])) {
1199
                    $menu_disk_name .= "$row[menu_disk_letter]";
1200
                }
1201
                if (isset($row['menu_disk_part'])) {
1202
                    if (is_numeric($row['menu_disk_part'])) {
1203
                        $menu_disk_name .= " part $row[menu_disk_part]";
1204
                    } else {
1205
                        $menu_disk_name .= "$row[menu_disk_part]";
1206
                    }
1207
                }
1208
            }
1209
            $subsection_name = $menu_disk_name;
1210
        }
1211
1212
        if ($subsection == 'Year') {
1213
            $subsection_name = $subsection_id;
1214
        }
1215
1216
        if ($subsection == 'Menu disk' or $subsection == 'Screenshots' or $subsection == 'File') {
1217
            $subsection_name = $section_name;
1218
        }
1219
1220
        if ($subsection == 'Credits') {
1221
            if ($action == 'Delete') {
1222
                //get the ind id
1223
                $query_ind = "SELECT ind_id FROM menu_disk_credits WHERE menu_disk_credits_id = '$subsection_id'";
1224
                $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1225
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1226
                $subsection_id = $query_data['ind_id'];
1227
            }
1228
1229
            // get the name of the individual
1230
            $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$subsection_id'";
1231
            $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1232
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1233
            $subsection_name = $query_data['ind_name'];
1234
        }
1235
1236
        if ($subsection == 'Nickname') {
1237
            // get the individual id
1238
            $query_ind = "SELECT ind_id FROM menu_disk_credits WHERE individual_nicks_id = '$subsection_id'";
1239
            $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1240
            $query_data = $result->fetch_array(MYSQLI_BOTH);
1241
            $ind_id     = $query_data['ind_id'];
1242
1243
            //now get the individual name
1244
            $query_ind = "SELECT ind_name FROM individuals WHERE ind_id = '$ind_id'";
1245
            $result = $mysqli->query($query_ind) or die("getting individual name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1246
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1247
            $subsection_name = $query_data['ind_name'];
1248
        }
1249
1250
        if ($subsection == 'Game' or $subsection == 'Game doc') {
1251
            //  get the game name
1252
            $query_game = "SELECT game_name FROM game WHERE game_id = '$subsection_id'";
1253
            $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1254
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1255
            $subsection_name = $query_data['game_name'];
1256
        }
1257
1258
        if ($subsection == 'Demo') {
1259
            //  get the demo name
1260
            $query_demo = "SELECT demo_name FROM demo WHERE demo_id = '$subsection_id'";
1261
            $result = $mysqli->query($query_demo) or die("getting demo name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1262
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1263
            $subsection_name = $query_data['demo_name'];
1264
        }
1265
1266
        if ($subsection == 'Tool' or $subsection == 'Tool doc') {
1267
            //  get the tool name
1268
            $query_tool = "SELECT tools_name FROM tools WHERE tools_id = '$subsection_id'";
1269
            $result = $mysqli->query($query_tool) or die("getting tool name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1270
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1271
            $subsection_name = $query_data['tools_name'];
1272
        }
1273
1274
        if ($subsection == 'Doc type') {
1275
            // get the name of the doc type
1276
            $query_doc_type = "SELECT doc_type_name FROM doc_type WHERE doc_type_id = '$subsection_id'";
1277
            $result = $mysqli->query($query_doc_type) or die("getting doc type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1278
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1279
            $subsection_name = $query_data['doc_type_name'];
1280
        }
1281
1282
        if ($subsection == 'Software' or $subsection == 'Chain' or $subsection == 'Doc' or $subsection == 'Authors') {
1283
            //get the type of software
1284
            $query_soft = "SELECT menu_types_main_id FROM menu_disk_title WHERE menu_disk_title_id = '$subsection_id'";
1285
            $result = $mysqli->query($query_soft) or die("getting menu_type failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1286
            $query_data = $result->fetch_array(MYSQLI_BOTH);
1287
            $type       = $query_data['menu_types_main_id'];
1288
1289
            //get the name of the software
1290
            if ($type == '1') {
1291
                //get the id of the game
1292
                $query_game = "SELECT game_id FROM menu_disk_title_game WHERE menu_disk_title_id = '$subsection_id'";
1293
                $result = $mysqli->query($query_game) or die("getting game id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1294
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1295
                $subsection_id = $query_data['game_id'];
1296
1297
                //  get the game name
1298
                $query_game = "SELECT game_name FROM game WHERE game_id = '$subsection_id'";
1299
                $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1300
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
1301
                $subsection_name = $query_data['game_name'];
1302
1303
                if ($subsection != 'Chain' and $subsection != 'Authors') {
1304
                    $subsection = 'Game';
1305
                }
1306
            }
1307
1308
            if ($type == '2') {
1309
                //get the id of the demo
1310
                $query_demo = "SELECT demo_id FROM menu_disk_title_demo WHERE menu_disk_title_id = '$subsection_id'";
1311
                $result = $mysqli->query($query_demo) or die("getting demo id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1312
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1313
                $subsection_id = $query_data['demo_id'];
1314
1315
                //  get the demo name
1316
                $query_demo = "SELECT demo_name FROM demo WHERE demo_id = '$subsection_id'";
1317
                $result = $mysqli->query($query_demo) or die("getting demo name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1318
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
1319
                $subsection_name = $query_data['demo_name'];
1320
                if ($subsection != 'Chain' and $subsection != 'Authors') {
1321
                    $subsection = 'Demo';
1322
                }
1323
            }
1324
1325
            if ($type == '3') {
1326
                //get the id of the tool
1327
                $query_tool = "SELECT tools_id FROM menu_disk_title_tools WHERE menu_disk_title_id = '$subsection_id'";
1328
                $result = $mysqli->query($query_tool) or die("getting toold id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1329
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1330
                $subsection_id = $query_data['tools_id'];
1331
1332
                //  get the tool name
1333
                $query_tool = "SELECT tools_name FROM tools WHERE tools_id = '$subsection_id'";
1334
                $result = $mysqli->query($query_tool) or die("getting tool name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1335
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
1336
                $subsection_name = $query_data['tools_name'];
1337
                if ($subsection != 'Chain' and $subsection != 'Authors') {
1338
                    $subsection = 'Tool';
1339
                }
1340
            }
1341
1342
            if ($type == '6') {
1343
                //get the doc cross id
1344
                $query_game_doc = "SELECT doc_games_id FROM menu_disk_title_doc_games
1345
                    WHERE menu_disk_title_id = '$subsection_id'";
1346
                $result = $mysqli->query($query_game_doc) or die("getting doc_game_id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1347
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1348
                $subsection_id = $query_data['doc_games_id'];
1349
1350
                //  get the game id
1351
                $query_game_id = "SELECT game_id FROM doc_disk_game WHERE doc_disk_game_id = '$subsection_id'";
1352
                $result = $mysqli->query($query_game_id) or die("getting game id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1353
                $query_data    = $result->fetch_array(MYSQLI_BOTH);
1354
                $subsection_id = $query_data['game_id'];
1355
1356
                //  get the game name
1357
                $query_game = "SELECT game_name FROM game WHERE game_id = '$subsection_id'";
1358
                $result = $mysqli->query($query_game) or die("getting game name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1359
                $query_data      = $result->fetch_array(MYSQLI_BOTH);
1360
                $subsection_name = $query_data['game_name'];
1361
1362
                if ($subsection == 'Authors') {
1363
                } else {
1364
                    $subsection      = 'Game doc';
1365
                }
1366
1367
                if ($subsection_name == '') {
1368
                    //get the doc cross id
1369
                    $query_tool_doc = "SELECT doc_tools_id FROM menu_disk_title_doc_tools
1370
                        WHERE menu_disk_title_id = '$subsection_id'";
1371
                    $result = $mysqli->query($query_tool_doc) or die("getting doc_tools_id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1372
                    $query_data    = $result->fetch_array(MYSQLI_BOTH);
1373
                    $subsection_id = $query_data['doc_tools_id'];
1374
1375
                    //get the id of the tool
1376
                    $query_tool = "SELECT tools_id FROM menu_disk_title_tools
1377
                        WHERE menu_disk_title_id = '$subsection_id'";
1378
                    $result = $mysqli->query($query_tool) or die("getting toold id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1379
                    $query_data    = $result->fetch_array(MYSQLI_BOTH);
1380
                    $subsection_id = $query_data['tools_id'];
1381
1382
                    //  get the tool name
1383
                    $query_tool = "SELECT tools_name FROM tools WHERE tools_id = '$subsection_id'";
1384
                    $result = $mysqli->query($query_tool) or die("getting tool name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1385
                    $query_data      = $result->fetch_array(MYSQLI_BOTH);
1386
                    $subsection_name = $query_data['tools_name'];
1387
1388
                    if ($subsection == 'Authors') {
1389
                    } else {
1390
                        $subsection      = 'Tool doc';
1391
                    }
1392
                }
1393
            }
1394
        }
1395
    }
1396
1397
    //  Everything we do for the Articles section
1398
    if ($section == 'Articles') {
1399
        if ($subsection == 'Article') {
1400
            if ($action == 'Update' or $action == 'Delete' or $action == 'Insert') {
1401
                //we need to get the title
1402
                $query_title = "SELECT article_title FROM article_text WHERE article_id = '$section_id'";
1403
                $result = $mysqli->query($query_title) or die("getting title failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1404
                $query_data   = $result->fetch_array(MYSQLI_BOTH);
1405
                $section_name = $query_data['article_title'];
1406
            }
1407
        }
1408
1409
        if ($subsection == 'Screenshots') {
1410
            if ($action == 'Insert' or $action == 'Delete') {
1411
                //we need to get the title
1412
                $query_title = "SELECT article_title FROM article_text WHERE article_id = '$section_id'";
1413
                $result = $mysqli->query($query_title) or die("getting title failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1414
                $query_data   = $result->fetch_array(MYSQLI_BOTH);
1415
                $section_name = $query_data['article_title'];
1416
            }
1417
        }
1418
1419
        if ($subsection == 'Article' or $subsection == 'Screenshots') {
1420
            $subsection_name = $section_name;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $section_name does not seem to be defined for all execution paths leading up to this point.
Loading history...
1421
        }
1422
1423
        if ($subsection == 'Comment') {
1424
            //we need to get the title
1425
            $query_user_comment = "SELECT article_user_comments.article_id,
1426
                article_user_comments.article_user_comments_id,
1427
                article_text.article_title
1428
                FROM article_user_comments
1429
                LEFT JOIN article_main ON ( article_user_comments.article_id = article_main.article_id )
1430
                LEFT JOIN article_text on ( article_main.article_id = article_text.article_id )
1431
                WHERE article_user_comments.comments_id = '$subsection_id'";
1432
1433
            $result = $mysqli->query($query_user_comment) or die("getting user comments id failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1434
            $query_data      = $result->fetch_array(MYSQLI_BOTH);
1435
            $section_id      = $query_data['article_id'];
1436
            $section_name    = $query_data['article_title'];
1437
            $subsection_name = $section_name;
1438
        }
1439
    }
1440
1441
    //  Everything we do for the ARTICLE TYPE SECTION
1442
    if ($section == 'Article type') {
1443
        // get the name of the article type
1444
        $query_article_type = "SELECT article_type FROM article_type WHERE article_type_id = '$section_id'";
1445
        $result = $mysqli->query($query_article_type) or die("getting article type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1446
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1447
        $section_name = $query_data['article_type'];
1448
1449
        if ($subsection == 'Article type') {
1450
            $subsection_name = $section_name;
1451
        }
1452
    }
1453
1454
    //  Everything we do for the DOC TYPE SECTION
1455
    if ($section == 'Doc type') {
1456
        // get the name of the doc type
1457
        $query_doc_type = "SELECT doc_type_name FROM doc_type WHERE doc_type_id = '$section_id'";
1458
        $result = $mysqli->query($query_doc_type) or die("getting doc type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1459
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1460
        $section_name = $query_data['doc_type_name'];
1461
1462
        if ($subsection == 'Doc type') {
1463
            $subsection_name = $section_name;
1464
        }
1465
    }
1466
1467
    //  Everything we do for the DOC CATEGORY SECTION
1468
    if ($section == 'Doc category') {
1469
        // get the name of the doc type
1470
        $query_category_type = "SELECT doc_category_name FROM doc_category WHERE doc_category_id = '$section_id'";
1471
        $result = $mysqli->query($query_category_type) or die("getting doc category name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1472
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1473
        $section_name = $query_data['doc_category_name'];
1474
1475
        if ($subsection == 'Doc category') {
1476
            $subsection_name = $section_name;
1477
        }
1478
    }
1479
1480
    //  Everything we do for the DOWNLOAD FORMAT SECTION
1481
    if ($section == 'Format') {
1482
        // get the name of the format
1483
        $query_format = "SELECT format FROM format WHERE format_id = '$section_id'";
1484
        $result = $mysqli->query($query_format) or die("getting format name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1485
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1486
        $section_name = $query_data['format'];
1487
1488
        if ($subsection == 'Format') {
1489
            $subsection_name = $section_name;
1490
        }
1491
    }
1492
1493
    //  Everything we do for the DOWNLOAD LINGO SECTION
1494
    if ($section == 'Lingo') {
1495
        // get the name of the lingo
1496
        $query_lingo = "SELECT lingo_name FROM lingo WHERE lingo_id = '$section_id'";
1497
        $result = $mysqli->query($query_lingo) or die("getting lingo name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1498
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1499
        $section_name = $query_data['lingo_name'];
1500
1501
        if ($subsection == 'Lingo') {
1502
            $subsection_name = $section_name;
1503
        }
1504
    }
1505
1506
    //  Everything we do for the DOWNLOAD OPTION SECTION
1507
    if ($section == 'Option') {
1508
        // get the name of the lingo
1509
        $query_option = "SELECT download_option FROM download_options WHERE download_options_id = '$section_id'";
1510
        $result = $mysqli->query($query_option) or die("getting option name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1511
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1512
        $section_name = $query_data['download_option'];
1513
1514
        if ($subsection == 'Option') {
1515
            $subsection_name = $section_name;
1516
        }
1517
    }
1518
1519
    //  Everything we do for the TOS VERSION SECTION
1520
    if ($section == 'TOS') {
1521
        // get the name of the lingo
1522
        $query_tos = "SELECT tos_version FROM tos_version WHERE tos_version_id = '$section_id'";
1523
        $result = $mysqli->query($query_tos) or die("getting tos name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1524
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1525
        $section_name = $query_data['tos_version'];
1526
1527
        if ($subsection == 'TOS') {
1528
            $subsection_name = $section_name;
1529
        }
1530
    }
1531
1532
    //  Everything we do for the TRAINER SECTION
1533
    if ($section == 'Trainer') {
1534
        // get the name of the trainer option
1535
        $query_trainer = "SELECT trainer_options FROM trainer_options WHERE trainer_options_id = '$section_id'";
1536
        $result = $mysqli->query($query_trainer) or die("getting trainer optione failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1537
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1538
        $section_name = $query_data['trainer_options'];
1539
1540
        if ($subsection == 'Trainer') {
1541
            $subsection_name = $section_name;
1542
        }
1543
    }
1544
1545
    //  Everything we do for the DOWNLOADS EDIT SECTION
1546
    if ($section == 'Downloads') {
1547
        // get the name of the game
1548
        $query_game = "SELECT * FROM game WHERE game_id = '$section_id'";
1549
        $result = $mysqli->query($query_game) or die("getting game_name failed yooohoo");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1550
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1551
        $section_name = $query_data['game_name'];
1552
1553
        if ($subsection == 'Options') {
1554
            // get the name of the option
1555
            $query_option = "SELECT * FROM download_options WHERE download_options_id = '$subsection_id'";
1556
            $result = $mysqli->query($query_option) or die("getting option failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1557
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1558
            $subsection_name = $query_data['download_option'];
1559
            $subsection_id = $query_data['download_options_id'];
1560
        }
1561
1562
        if ($subsection == 'TOS') {
1563
            // get the name of the option
1564
            $query_tos = "SELECT * FROM tos_version
1565
                             WHERE tos_version_id = '$subsection_id'";
1566
            $result = $mysqli->query($query_tos) or die("getting tos failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1567
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1568
            $subsection_name = $query_data['tos_version'];
1569
            $subsection_id = $query_data['tos_version_id'];
1570
        }
1571
1572
        if ($subsection == 'Details') {
1573
            $subsection_name = $section_name;
1574
        }
1575
1576
        if ($subsection == 'Menudisk') {
1577
            $subsection_name = $section_name;
1578
        }
1579
1580
        if ($subsection == 'Chain') {
1581
            $subsection_name = $section_name;
1582
        }
1583
1584
        if ($subsection == 'Trainer') {
1585
            // get the name of the trainer option
1586
            $query_trainer = "SELECT * FROM trainer_options
1587
                             WHERE trainer_options_id = '$subsection_id'";
1588
            $result = $mysqli->query($query_trainer) or die("getting trainer failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1589
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1590
            $subsection_name = $query_data['trainer_options'];
1591
            $subsection_id = $query_data['trainer_options_id'];
1592
        }
1593
1594
        if ($subsection == 'Crew') {
1595
            // get the name of the trainer option
1596
            $query_crew = "SELECT * FROM crew WHERE
1597
                            crew_id = '$subsection_id'";
1598
            $result = $mysqli->query($query_crew) or die("getting crew failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1599
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1600
            $subsection_name = $query_data['crew_name'];
1601
        }
1602
1603
        if ($subsection == 'Authors') {
1604
            // get the name of the author option
1605
            $query_ind = "SELECT ind_name FROM individuals WHERE
1606
                            ind_id = '$subsection_id'";
1607
            $result = $mysqli->query($query_ind) or die("getting ind failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1608
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1609
            $subsection_name = $query_data['ind_name'];
1610
        }
1611
    }
1612
1613
    //  Everything we do for the BUG REPORT TYPE SECTION
1614
    if ($section == 'Bug type') {
1615
        // get the name of the type
1616
        $query_type = "SELECT bug_report_type FROM bug_report_type WHERE bug_report_type_id = '$section_id'";
1617
        $result = $mysqli->query($query_type) or die("getting type name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1618
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1619
        $section_name = $query_data['bug_report_type'];
1620
1621
        if ($subsection == 'Bug type') {
1622
            $subsection_name = $section_name;
1623
        }
1624
    }
1625
1626
    //  Everything we do for the BUG REPORT SECTION
1627
    if ($section == 'Bug') {
1628
        $subsection_name = ("Bug report ID " . $subsection_id);
1629
        $section_name    = ("Bug report ID " . $subsection_id);
1630
    }
1631
1632
    //  Everything we do for the GAMES CONFIG section
1633
    if ($section == 'Games Config') {
1634
        if ($subsection == 'Games Engine') {
1635
            // Get the engine name
1636
            $query = "SELECT name FROM engine WHERE id = '$section_id'";
1637
            $result = $mysqli->query($query) or die("getting engine name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1638
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1639
            $section_name = $query_data['name'];
1640
        } elseif ($subsection == 'Programming Language') {
1641
            // Get the programming language name
1642
            $query = "SELECT name FROM programming_language WHERE id = '$section_id'";
1643
            $result = $mysqli->query($query) or die("getting language name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1644
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1645
            $section_name = $query_data['name'];
1646
        } elseif ($subsection == 'Genre') {
1647
            // Get the genre name
1648
            $query = "SELECT name FROM game_genre WHERE id = '$section_id'";
1649
            $result = $mysqli->query($query) or die("getting genre name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1650
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1651
            $section_name = $query_data['name'];
1652
        } elseif ($subsection == 'Port') {
1653
            // Get the port name
1654
            $query = "SELECT name FROM port WHERE id = '$section_id'";
1655
            $result = $mysqli->query($query) or die("getting port name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1656
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1657
            $section_name = $query_data['name'];
1658
        } elseif ($subsection == 'Individual Role') {
1659
            // Get the role name
1660
            $query = "SELECT name FROM individual_role WHERE id = '$section_id'";
1661
            $result = $mysqli->query($query) or die("getting role name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1662
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1663
            $section_name = $query_data['name'];
1664
        } elseif ($subsection == 'Developer Role') {
1665
            // Get the role name
1666
            $query = "SELECT role FROM developer_role WHERE id = '$section_id'";
1667
            $result = $mysqli->query($query) or die("getting role name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1668
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1669
            $section_name = $query_data['name'];
1670
        } elseif ($subsection == 'Language') {
1671
            // Get the language name
1672
            $query = "SELECT name FROM language WHERE id = '$section_id'";
1673
            $result = $mysqli->query($query) or die("getting language name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1674
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1675
            $section_name = $query_data['name'];
1676
        } elseif ($subsection == 'Control') {
1677
            // Get the language name
1678
            $query = "SELECT name FROM control WHERE id = '$section_id'";
1679
            $result = $mysqli->query($query) or die("getting control type failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1680
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1681
            $section_name = $query_data['name'];
1682
        } elseif ($subsection == 'Resolution') {
1683
            // Get the resolution name
1684
            $query = "SELECT name FROM resolution WHERE id = '$section_id'";
1685
            $result = $mysqli->query($query) or die("getting resolution failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1686
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1687
            $section_name = $query_data['name'];
1688
        } elseif ($subsection == 'System') {
1689
            // Get the system name
1690
            $query = "SELECT name FROM system WHERE id = '$section_id'";
1691
            $result = $mysqli->query($query) or die("getting system failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1692
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1693
            $section_name = $query_data['name'];
1694
        } elseif ($subsection == 'Emulator') {
1695
            // Get the emulator name
1696
            $query = "SELECT name FROM emulator WHERE id = '$section_id'";
1697
            $result = $mysqli->query($query) or die("getting emulator failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1698
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1699
            $section_name = $query_data['name'];
1700
        } elseif ($subsection == 'Trainer') {
1701
            // Get the trainer option name
1702
            $query = "SELECT name FROM trainer_option WHERE id = '$section_id'";
1703
            $result = $mysqli->query($query) or die("getting trainer option failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1704
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1705
            $section_name = $query_data['name'];
1706
        } elseif ($subsection == 'Memory') {
1707
            // Get the memory amount
1708
            $query = "SELECT name FROM memory WHERE id = '$section_id'";
1709
            $result = $mysqli->query($query) or die("getting memory amount failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1710
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1711
            $section_name = $query_data['memory'];
1712
        } elseif ($subsection == 'Tos') {
1713
            // Get the tos amount
1714
            $query = "SELECT name FROM tos WHERE id = '$section_id'";
1715
            $result = $mysqli->query($query) or die("getting tos version failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1716
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1717
            $section_name = $query_data['name'];
1718
        } elseif ($subsection == 'Protection') {
1719
            // Get the protection type
1720
            $query = "SELECT name FROM copy_protection WHERE id = '$section_id'";
1721
            $result = $mysqli->query($query) or die("getting copy protection failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1722
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1723
            $section_name = $query_data['name'];
1724
        } elseif ($subsection == 'Disk Protection') {
1725
            // Get the protection type
1726
            $query = "SELECT name FROM disk_protection WHERE id = '$section_id'";
1727
            $result = $mysqli->query($query) or die("getting disk protection failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1728
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1729
            $section_name = $query_data['name'];
1730
        } elseif ($subsection == 'Enhancement') {
1731
            // Get the Enhancement
1732
            $query = "SELECT name FROM enhancement WHERE id = '$section_id'";
1733
            $result = $mysqli->query($query) or die("getting enhancement failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1734
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1735
            $section_name = $query_data['name'];
1736
        } elseif ($subsection == 'Media Type') {
1737
            // Get the Enhancement
1738
            $query = "SELECT name FROM media_type WHERE id = '$section_id'";
1739
            $result = $mysqli->query($query) or die("getting media type failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1740
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1741
            $section_name = $query_data['name'];
1742
        } elseif ($subsection == 'Media Scan Type') {
1743
            // Get the Enhancement
1744
            $query = "SELECT name FROM media_scan_type WHERE id = '$section_id'";
1745
            $result = $mysqli->query($query) or die("getting media type failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
1746
        } elseif ($subsection == 'Sound hardware') {
1747
            // Get the the hardware
1748
            $query = "SELECT name FROM sound_hardware WHERE id = '$section_id'";
1749
            $result = $mysqli->query($query) or die("getting sound hardware failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1750
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1751
            $section_name = $query_data['name'];
1752
        } elseif ($subsection == 'Progress System') {
1753
            // Get the the system
1754
            $query = "SELECT name FROM game_progress_system WHERE id = '$section_id'";
1755
            $result = $mysqli->query($query) or die("getting progress system failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1756
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1757
            $section_name = $query_data['name'];
1758
        }
1759
        $subsection_name = $section_name;
1760
    }
1761
1762
    //Everything we do for GAME RELEASES
1763
    if ($section == 'Game Release') {
1764
        //  get the release name
1765
        $query_game = "SELECT game_name FROM game WHERE game_id = '$section_id'";
1766
        $result = $mysqli->query($query_game) or die("getting name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1767
        $query_data   = $result->fetch_array(MYSQLI_BOTH);
1768
        $section_name = $query_data['game_name'];
1769
1770
        if ($subsection == 'Game Release' or $subsection == 'Release Info' or $subsection == 'Release AKA'
1771
            or $subsection == 'Compatibility' or $subsection == 'Distributor'
1772
            or $subsection == 'Scene' or $subsection == 'Memory Enhancement' or $subsection == 'Minimum Memory'
1773
            or $subsection == 'Incompatible Memory' or $subsection == 'Incompatible TOS'
1774
            or $subsection == 'Protection' or $subsection == 'Language' or $subsection == 'System Enhancement'
1775
            or $subsection == 'Copy Protection' or $subsection == 'Disk Protection' or $subsection == 'Media'
1776
            or $subsection == 'Dump' or $subsection == 'Media Scan' or $subsection == "Scan") {
1777
            $subsection_name = $section_name;
1778
        }
1779
1780
        if ($subsection == 'Distributor') {
1781
            // get the distributor name
1782
            $query_distributor = "SELECT * FROM pub_dev
1783
                                  LEFT JOIN game_release_distributor
1784
                                  ON (pub_dev.pub_dev_id = game_release_distributor.pub_dev_id)
1785
                                  WHERE pub_dev.pub_dev_id = '$subsection_id'";
1786
            $result = $mysqli->query($query_distributor) or die("getting name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1787
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1788
            $subsection_name = $query_data['pub_dev_name'];
1789
            $subsection_id = $query_data['game_release_id'];
1790
        }
1791
1792
        if ($subsection == 'Crew') {
1793
            // get the distributor name
1794
            $query_crew = "SELECT * FROM crew
1795
                                  LEFT JOIN game_release_crew
1796
                                  ON (crew.crew_id = game_release_crew.crew_id)
1797
                                  WHERE crew.crew_id = '$subsection_id'";
1798
            $result = $mysqli->query($query_crew) or die("getting name failed");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1799
            $query_data   = $result->fetch_array(MYSQLI_BOTH);
1800
            $subsection_name = $query_data['crew_name'];
1801
            $subsection_id = $query_data['game_release_id'];
1802
        }
1803
    }
1804
1805
    $section_name    = $mysqli->real_escape_string($section_name);
1806
    $subsection_name = $mysqli->real_escape_string($subsection_name);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $subsection_name does not seem to be defined for all execution paths leading up to this point.
Loading history...
1807
1808
    $log_time = time();
1809
    $sql_log = $mysqli->query("INSERT INTO change_log
0 ignored issues
show
Unused Code introduced by
The assignment to $sql_log is dead and can be removed.
Loading history...
1810
        (section, section_id, section_name, sub_section, sub_section_id, sub_section_name, user_id, action, timestamp)
1811
        VALUES ('$section', '$section_id', '$section_name', '$subsection', '$subsection_id', '$subsection_name',
1812
        '$user_id', '$action', '$log_time')") or die("Couldn't insert change log into database");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1813
}
1814