This repository was archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_tour.php
More file actions
executable file
·141 lines (127 loc) · 4.19 KB
/
start_tour.php
File metadata and controls
executable file
·141 lines (127 loc) · 4.19 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
foreach ($_POST as $key => $value) {
switch ($key) {
case 'authcode':
$authcode = $value;
break;
case 'cargo':
$cargo = $value;
break;
case 'depature':
$source = $value;
break;
case 'destination':
$destination = $value;
break;
case 'truck_manufacturer':
$truck_manu = $value;
break;
case 'truck_model':
$truck_model = $value;
break;
case 'weight':
$weight = $value;
break;
case 'depature_company':
$depature_company = $value;
break;
case 'destination_company':
$destination_company = $value;
break;
case 'distance':
$distance_tour = $value;
break;
default:
break;
}
}
$passwdhsh = hash('sha256',$passwd);
$host = 'localhost:3306';
$conn = mysqli_connect($host, "system_user_vtc", "8rh98w23nrfubsediofnm<pbi9ufuoipbgiwtFFF","vtcmanager");
$authcode = $conn->real_escape_string($authcode);
$cargo = $conn->real_escape_string($cargo);
$source = $conn->real_escape_string($source);
$destination = $conn->real_escape_string($destination);
$truck_manu = $conn->real_escape_string($truck_manu);
$truck_model = $conn->real_escape_string($truck_model);
$weight = $conn->real_escape_string($weight);
$depature_company = $conn->real_escape_string($depature_company);
$destination_company = $conn->real_escape_string($destination_company);
$distance_tour = $conn->real_escape_string($distance_tour);
$sql = "SELECT User FROM authCode_table WHERE Token='$authcode'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$found_user = $row["User"];
}
} else {
mysqli_close($conn);
$host = 'localhost:3306';
$conn = mysqli_connect($host, "system_user_vtc", "8rh98w23nrfubsediofnm<pbi9ufuoipbgiwtFFF","vtcmanager_en");
if(! $conn )
{
die("2");
}
$sql = "SELECT User FROM authCode_table WHERE Token='$authcode'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$found_user = $row["User"];
}
} else {
echo "0 results";
die();
}
}
$sql = "SELECT * FROM user_data WHERE username='$found_user'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$latest_tour = $row["last_tour_id"];
$company = $row["userCompanyID"];
}
} else {
echo $found_user;
die("no user");
}
/*
if ($conn->query($sql) === TRUE) {
} else {
echo "Error updating record: " . $conn->error;
}
*/
// frage
$sql2 = "SELECT * FROM tour_table WHERE tour_id = '$latest_tour' AND status = 'accepted by driver' AND username = '$found_user'";
$result2 = $conn->query($sql2);
if ($result2->num_rows >= 1) {
$sql3 = "UPDATE tour_table SET username = '$found_user',
departure = '$source',
destination = '$destination',
truck_manufacturer = '$truck_manu',
truck_model = '$truck_model',
cargo_weight = '$weight',
cargo = '$cargo',
money_earned = '',
status = 'accepted by driver',
companyID = '$company',
depature_company = '$depature_company',
destination_company = '$destination_company',
distance = '$distance_tour' WHERE tour_id = '$latest_tour' AND username = '$found_user'";
} else {
$latest_tour++;
$sql = "UPDATE user_data SET last_tour_id='$latest_tour' WHERE username='$found_user'";
$sql3 = "INSERT INTO tour_table (username, departure, destination, truck_manufacturer, truck_model, cargo_weight, cargo, money_earned, tour_id, status, companyID, depature_company, destination_company, distance)
VALUES ('$found_user', '$source', '$destination', '$truck_manu', '$truck_model', '$weight', '$cargo', '','$latest_tour', 'accepted by driver', $company, '$depature_company', '$destination_company', $distance_tour)";
}
if ($conn->query($sql3) === TRUE) {
$conn->query($sql);
echo $latest_tour;
exit;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
mysqli_close($conn);
?>