This repository has been archived by the owner on Sep 5, 2021. It is now read-only.
forked from avs-code/PREM-Podium-race-E-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrace_chg_do.php
55 lines (44 loc) · 2.16 KB
/
race_chg_do.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
<?
require_once("session_start.php");
if(!isset($login)) error("You do not have administrator rights\n");
$id = addslashes($_POST['id']);
$name = htmlspecialchars($_POST['name']);
$track = htmlspecialchars($_POST['track']);
$laps = addslashes($_POST['laps']);
$season = addslashes($_POST['season']);
$diff_ruleset = isset($_POST['diff_ruleset']);
$division = addslashes($_POST['division']);
$ruleset = addslashes($_POST['ruleset']);
$ruleset_qualifying = addslashes($_POST['ruleset_qualifying']);
$date = mktime($_POST['hour'], $_POST['minute'], 0, $_POST['month'], $_POST['day'], $_POST['year']);
$date = date("Y-m-d H:i:s",$date);
$maxplayers = addslashes($_POST['maxplayers']);
$imagelink = htmlspecialchars($_POST['imagelink']);
$error = "";
if(empty($name)) $error .= "You must fill in a name\n";
if(empty($track)) $error .= "You must fill in a track\n";
if(empty($laps)) $error .= "You must fill in the number of laps\n";
if(empty($maxplayers)) $error .= "You must fill in the number of max players\n";
if(empty($imagelink)) $error .= "You must fill in a image_url\n";
if(!empty($error)) error($error);
$msg = "";
require_once("functions.php"); // import mysql function
$link = mysqlconnect(); // call mysql function to get the link to the database
// Take division and ruleset from season
if($season != 0) {
$query = "SELECT division, ruleset, ruleset_qualifying FROM season s WHERE id='$season'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL error: " . mysqli_error($link) . "\n");
if(mysqli_num_rows($result) == 0) error("Season does not exist\n");
$item = mysqli_fetch_array($result);
$division = $item['division'];
if(!$diff_ruleset) {
$ruleset = $item['ruleset'];
$ruleset_qualifying = $item['ruleset_qualifying'];
}
}
$query = "UPDATE race SET name='$name', track='$track', laps='$laps', season='$season', division='$division', ruleset='$ruleset', ruleset_qualifying='$ruleset_qualifying', date='$date', maxplayers='$maxplayers', imagelink='$imagelink' WHERE id='$id'";
$result = mysqli_query($link,$query);
if(!$result) error("MySQL Error: " . mysqli_error($link) . "\n");
return_do(".?page=races&season=$season", "Race succesfully modified\n$msg");
?>