-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataedit.php
More file actions
112 lines (94 loc) · 2.6 KB
/
dataedit.php
File metadata and controls
112 lines (94 loc) · 2.6 KB
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
<?php
session_start();
require_once 'global/functions/header.php';
require_once 'global/functions/footer.php';
require_once 'global/functions/apicalls.php';
require_once 'global/functions/telegram.php';
require_once 'global/functions/irm.php';
$config = require_once "config.php";
$menu = renderMenu();
$options['nav'] = $menu;
$options['title'] = "IRM | Modify data";
$header = getHeader($options);
$footer = renderFooter();
echo $header;
?>
<div class="topspacer"></div>
<main role="main">
<div class="container">
<?php
$tg_user = getTelegramUserData();
saveSessionArray($tg_user);
if($_SESSION['access'] >= 2){
//check if user is logged in
if ($tg_user !== false) {
//get attribute to add and add it
if(isset($_GET['addbrand'])){
$brand = $_POST['brand'];
$postfields = "{\"brand\": \"$brand\"}";
postcall($config->api_url . "carbrands", $postfields);
header('Location: car.php?new=1');
}
if(isset($_GET['addmodel'])){
$model = $_POST['model'];
$postfields = "{\"model\": \"$model\"}";
postcall($config->api_url . "carmodels", $postfields);
header('Location: car.php?new=1');
}
if(isset($_GET['addcolor'])){
$color = $_POST['color'];
$postfields = "{\"color\": \"$color\"}";
postcall($config->api_url . "colors", $postfields);
header('Location: car.php?new=1');
}
//get attribute user wants to add and display correspodenting form
if(isset($_GET['brand'])){
?>
<form method="POST" action="?addbrand=1">
<div class="form-group">
<label for="brand">New Brand</label>
<input type="text" class="form-control" id="brand" name="brand" placeholder="VW">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
<?php
}
if(isset($_GET['model'])){
?>
<form method="POST" action="?addmodel=1">
<div class="form-group">
<label for="model">New Model</label>
<input type="text" class="form-control" name="model" id="model" placeholder="Polo">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
<?php
}
if(isset($_GET['color'])){
?>
<form method="POST" action="?addcolor=1">
<div class="form-group">
<label for="color">New Color</label>
<input type="text" class="form-control" id="color" name="color" placeholder="Pink">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
<?php
}
} else {
echo '
<div class="alert alert-warning" role="alert">
<strong>Warning.</strong> Guest access is disabled
</div>
';
}
} else {
//user is not logged in
echo '
<div class="alert alert-danger" role="alert">
<strong>Error.</strong> You need to <a href="login.php>login</a> first
</div>
';
}
echo $footer;
?>