-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcms.php
133 lines (116 loc) · 3.45 KB
/
cms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
include_once('./core/start.php');
include_once('./core/data/staticdata.php');
if(!isset($_SESSION['accid']) && $_SESSION['accid']!=0){
session_unset();
redirect('frontpage.php', 0);
}
include_once('./core/GameFactory.php');
$starttime = microtime();
$MyDB = new DBHelper($dbhost, $dbuser, $dbpass, $dbname);
$MyDB -> OpenDB();
$StaticData = new StaticData();
$page = '';
$action = '';
if(isset($_REQUEST['page']))
$page = validate_input($_REQUEST['page']);
if(isset($_REQUEST['action']))
$action = validate_input($_REQUEST['action']);
//Document
echo createlayout_header('');
echo createlayout_start();
echo CreateCMSMenu($MyDB, $page);
switch($page){
case 'vehicles': showPageVehicles($MyDB, $action); break;
}
echo createlayout_footer();
echo createlayout_end();
//End
//Methods
function showPageVehicles($MyDB, $action){
if($action == 'storeNew'){
$vehicleData = $MyDB-> QuerySQL("INSERT INTO `data_vehicles` (`uid`, `name`, `travel`, `type`, `tank`, `consume`, `speed`, `storage`, `seats`, `pollution`) VALUES
(NULL,
'".$_POST['name']."',
'".$_POST['travel']."',
'".$_POST['type']."',
'".$_POST['tank']."',
'".$_POST['consume']."',
'".$_POST['speed']."',
'".$_POST['storage']."',
'".$_POST['seats']."',
'".$_POST['pollution']."');");
redirect("cms.php?page=vehicles");
}
else{
echo ShowVehicleList($MyDB);
}
}
function ShowVehicleList($MyDB){
$vehicleData = $MyDB-> QuerySQL("SELECT * FROM `data_vehicles`");
$content = '';
$out ='';
$content .= '<form action="cms.php?page=vehicles&action=storeNew" method="post">';
$content .= '<input type="submit" value="Create new Vehicle">';
$content .= '<table>';
$content .= '
<tr>
<th>ID</th>
<th>name</th>
<th>Travel</th>
<th>Type</th>
<th>Tank</th>
<th>Consumption</th>
<th>Speed</th>
<th>Storage</th>
<th>Seats</th>
<th>Pollution</th>
</tr>
';
$tdTag = ' style="padding:0 4px;"';
$inputTag = ' style="width:100%;"';
$content .= '
<tr>
<td'.$tdTag.'>New</td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="name"></td>
<td style="padding:0 4px; min-width:70px;">'.GetTravelDropdown('travel', $inputTag).'</td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="type"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="tank"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="consume"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="speed"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="storage"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="seats"></td>
<td'.$tdTag.'><input '.$inputTag.' type="text" name="pollution"></td>
</tr>
';
if($vehicleData!=null){
for($i=0;$i<count($vehicleData);$i++){
$data = $vehicleData[$i];
$content .= '
<tr>
<td>'.$data['uid'].'</td>
<td>'.$data['name'].'</td>
<td>'.$data['travel'].'</td>
<td>'.$data['type'].'</td>
<td>'.$data['tank'].'</td>
<td>'.$data['consume'].'</td>
<td>'.$data['speed'].'</td>
<td>'.$data['storage'].'</td>
<td>'.$data['seats'].'</td>
<td>'.$data['pollution'].'</td>
</tr>
';
}
}
$content .= '</table>';
$content .= '</form>';
$out = showWindow($content, 'Vehicles');
return $out;
}
function GetTravelDropdown($name, $tag=''){
return '<select '.$tag.' name="'.$name.'">
<option value="land">Land</option>
<option value="sea">See</option>
<option value="air">Luft</option>
</select>';
}