-
Notifications
You must be signed in to change notification settings - Fork 11
/
showScenariosForGlest.php
68 lines (56 loc) · 2.25 KB
/
showScenariosForGlest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
// Copyright (C) 2012 Mark Vejvoda, Titus Tscharntke and Tom Reynolds
// The MegaGlest Team, under GNU GPL v3.0
// ==============================================================
define( 'INCLUSION_PERMITTED', true );
require_once( 'registry.php' );
require_once( 'config.php' );
require_once( 'functions.php' );
define( 'DB_LINK', db_connect() );
if ( isset( $_GET['glestVersion'] ) ) {
$glestVersion = (string) clean_str( $_GET['glestVersion'] );
}
else {
$glestVersion = "";
}
$scenarios_in_db = mysqli_query( Registry::$mysqliLink, 'SELECT * FROM glestscenarios WHERE disabled=0 ORDER BY scenarioname;' );
$all_scenarios = array();
while ( $scenario = mysqli_fetch_array( $scenarios_in_db ) )
{
array_push( $all_scenarios, $scenario );
}
unset( $scenarios_in_db );
unset( $scenario );
db_disconnect( Registry::$mysqliLink );
// Representation starts here
header( 'Content-Type: text/plain; charset=utf-8' );
foreach( $all_scenarios as &$scenario )
{
$itemVersion = 'v' . "${scenario['glestversion']}";
$addItem = false;
if($glestVersion == '') {
if (version_compare("v3.6.0.3",$itemVersion,">=")) {
$addItem = true;
}
}
else if (version_compare($glestVersion,$itemVersion,">=")) {
$addItem = true;
}
if($addItem == true) {
if ( isset( $_GET['version'] ) ) { $mgversion = $_GET['version']; } else { $mgversion = ''; };
if($mgversion == '')
{
$outString =
"${scenario['scenarioname']}|${scenario['crc']}|${scenario['description']}|${scenario['url']}|${scenario['imageUrl']}|";
}
else {
$outString =
"${scenario['scenarioname']}|${scenario['crcnew']}|${scenario['description']}|${scenario['url']}|${scenario['imageUrl']}|";
}
$outString = $outString . "\n";
echo ($outString);
}
}
unset( $all_scenarios );
unset( $scenario );
?>