update_location.php 1.8 KB
Newer Older
Eric - kg6wxc's avatar
Eric - kg6wxc committed
1
2
3
<?php
/*Aug 6, 2017 4:14:14 PM
*update_location.php
4
*Eric Satterlee - KG6WXC
Eric - kg6wxc's avatar
Eric - kg6wxc committed
5
6
7
*/
//simple page to change node locations on the map
//this page does the actual changing
8
9
10
11
12
session_start();
if (!isset($_SESSION['userLoggedIn'])) {
	echo "You are not logged in!<br>\n";
	echo "This page should be run from within the admin interface!\n";
	exit;
Eric - kg6wxc's avatar
Eric - kg6wxc committed
13
}else {
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
	$INCLUDE_DIR = "../..";
	$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
	require $INCLUDE_DIR . "/scripts/wxc_functions.inc";
	@include $INCLUDE_DIR . "/custom.inc";
	
	$sql_connection = wxc_connectToMySQL();
		
	$query =    "UPDATE " . $USER_SETTINGS['sql_db_tbl'] .
	            " SET " . $_POST['column'] . " = '" . $_POST['editval'] .
	            "', location_fix = 1 WHERE node = '" . $_POST['node'] . "'";
	if ($_POST['column'] == "location_fix") {
	    $_POST['editval'] = strtolower($_POST['editval']);
	    if ($_POST['editval'] == "yes<br>" || $_POST['editval'] == "yes") {
	         $_POST['editval'] = 1;
	     }
	     if ($_POST['editval'] == "no<br>" || $_POST['editval'] == "no") {
	         $_POST['editval'] = 0;
	     }
	     $query =   "UPDATE " . $USER_SETTINGS['sql_db_tbl'] .
	                " SET " . $_POST['column'] . " = '" . $_POST['editval'] .
	                "' WHERE node = '" . $_POST['node'] . "'";
	    $result = wxc_putMySql($query);
	}else {
	    $result = wxc_putMySql($query);
	}
	if ($_POST['column'] == "location_fix") {
	    $query = "SELECT if(" . $_POST['column'] . ", 'yes', 'no') as location_fix FROM " . $USER_SETTINGS['sql_db_tbl'] . " WHERE node = '" . $_POST['node'] . "'";
	}else {
	    $query = "SELECT " . $_POST['column'] . " FROM " . $USER_SETTINGS['sql_db_tbl'] . " WHERE node = '" . $_POST['node'] . "'";
	}
	$result = wxc_getMySql($query);
	mysqli_close($sql_connection);
	echo $result[$_POST['column']];
Eric - kg6wxc's avatar
Eric - kg6wxc committed
47
48
}
?>