-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.php
More file actions
80 lines (79 loc) · 3.44 KB
/
Copy pathnew.php
File metadata and controls
80 lines (79 loc) · 3.44 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
<?
error_reporting(0);
include 'functions.inc.php';
outputHeader("Create a new map", "", "GENERIC", true, true);
$post = false;
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$post = true;
$errors = array();
if(trim($_POST['mapname']) == "")
{
$errors[] = 'Map short name not set';
$bad['mapname'] = true;
}
if(trim($_POST['title']) == "")
{
$errors[] = 'Map title not set';
$bad['title'] = true;
}
foreach($errors as $error)
{
echo $error.'<br />';
}
}
if(!$post || count($errors) > 0)
{
?>
<form action='new' method='post'>
<table>
<tr class='comp <?= $post && $bad['mapname'] ? "bad" : "" ?>'><td class='label'><label for='mapname'>Map URL:</label></td><td class='field'>http://<?= $_SERVER['SERVER_NAME'] ?>/mymap/<?= $_SESSION['username'] ?>/<input id='mapname' name='mapname' style='width:9em' value='<?= $_POST['mapname'] ?>' /></td><td class='desc'>This is the URL that the RDF for the map will become available at.</tr>
<tr><td colspan='3'><hr /></td></tr>
<tr class='comp <?= $post && $bad['title'] ? "bad" : "" ?>'><td class='label'><label for='title'>Map title:</label></td><td><input id='title' name='title' style='width:35em' value='<?= $_POST['title'] ?>' /></td><td class='desc'>This is the title of your map.</td></tr>
<tr class='comp <?= $post && $bad['source'] ? "bad" : "" ?>'><td class='label'><label for='source'>Map source:</label></td><td><input id='source' name='source' style='width:35em' value='<?= $_POST['source'] ?>' /></td><td class='desc'>This is the location (URL) of the source CSV file for your map. The CSV file should begin with a header row identifying the following columns (case insensitive):
<dl>
<dt>code</dt>
<dd>Unique code for the location (will be appended to the <i>base URI</i> below to create the location's URI).</dd>
<dt>name</dt>
<dd>Name of the location.</dd>
<dt>icon</dt>
<dd>URL of the icon used to represent the location on the map.</dd>
<dt>latitude</dt>
<dd>(optional) The latitude of the location.</dd>
<dt>longitude</dt>
<dd>(optional) The longitude of the location.</dd>
<dt>postcode</dt>
<dd>(optional) The postcode of the location.</dd>
</dl>
Rows which begin with the string '*COMMENT' will be treated as comment lines and not processed further.
</td></tr>
<tr class='comp <?= $post && $bad['base'] ? "bad" : "" ?>'><td class='label'><label for='base'>Base URI:</label></td><td><input id='base' name='base' style='width:35em' value='<?= $_POST['base'] ?>' /></td><td class='desc'>This is the base URI that is used as a prefix to the unique codes in the source file in order to generate a full URI for each location.</td></tr>
<tr><td /><td><input type='submit' /></td></tr>
</table>
</form>
<?
}
else
{
session_start();
require_once('/home/opendatamap/mysql.inc.php');
$params = array();
$params[] = "'".mysql_real_escape_string($_SESSION['username'])."'";
$params[] = "'".mysql_real_escape_string($_POST['mapname'])."'";
$params[] = "'".mysql_real_escape_string($_POST['title'])."'";
$params[] = "'".mysql_real_escape_string($_POST['source'])."'";
$params[] = "'".mysql_real_escape_string($_POST['base'])."'";
$q = "INSERT INTO maps VALUES (".implode(',', $params).")";
$res = mysql_query($q);
if(!$res)
{
echo 'Failed to create map.';
}
else
{
// $_SESSION['username'] = $_POST['username'];
echo "You have successfully created a new map. <a href='".$_SESSION['username']."/".$_POST['mapname']."/edit'>Edit map</a>.";
}
}
outputFooter();
?>