-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.php
111 lines (94 loc) · 2.93 KB
/
map.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
<?php
// define page-specific and other variables
$pageid = 'map.php';
$pagetype = '';
require ('includes/config.php');
require ('includes/dbconnect.php');
require ('includes/session.php');
require ('includes/functions.php');
if ($action == "logout") {
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
// Finally, destroy the session.
session_destroy();
}
if ($action == "leaveroom") {
// The user wants to leave the room
unset($_SESSION['roomID']);
}
$pagename = 'Room ' . $roomID;
$path = get_path() . 'instance.php?id=' . $roomID;
$filename = $_FILES['mapload'];
if (isset($filename)) {
$ext = strtolower(strrchr($filename['name'], '.'));
$newfilename = $roomID . $ext;
$themap = $newfilename;
// Process map file
$target = "uploaded/";
$target = $target . $newfilename;
$ok=1;
$mapload_size=$_FILES['mapload']['size'];
$mapload_type=$_FILES['mapload']['type'];
//This is our size condition
if ($mapload_size > 6291456) {
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($mapload_type !="image/jpeg" && $mapload_type !="image/png" && $maplaod_type !="image/gif") {
echo "Incorrect File Type.<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0) {
Echo "Sorry your file was not uploaded.";
} else {
if(move_uploaded_file($_FILES['mapload']['tmp_name'], $target)) {
echo "The file ". basename( $_FILES['mapload']['name']). " has been uploaded";
$map = $_FILES['mapload']['name'];
$query = "REPLACE INTO room_" . $roomID . " (map) VALUES ('" . $themap . "')";
$result = mysql_query($query, $link) or die("A MySQL error has occurred.<br />Query: " . $query . "<br />Error: (" . mysql_errno() . ") " . mysql_error());
} else {
echo "Sorry, there was a problem uploading your file.";
}
}
}
?>
<?php include ('includes/header.php'); ?>
<body>
<div id="wrapper" class="clearfix">
<section id="header">
<img src="images/rollforit.png" alt="Rollfor.it" class="logo" />
</section>
<!-- end #header -->
<?php include ('includes/pagenav.php'); ?>
<section id="content2">
<header id="getrolling">
<?php
if (empty($themap) || $ok==0) {
echo "Upload a map.";
} else {
echo "<a href=" . $path . ">Continue</a>";
}
?>
</header>
<form enctype="multipart/form-data" action="map.php" method="post">
<input type="file" name="mapload" />
<input type="submit" value="Submit">
</form>
<section id="map">
<?php
if (isset($themap) && $ok!=0) {
echo "<img src=uploaded/" . $themap . " alt='the map' />";
}
?>
</section>
<div style="clear:both;"></div>
</section><!-- end #content -->
</div><!-- end #wrapper -->
<?php include ('includes/footer.php'); ?>