Example #1
0
function register($firstname, $lastname, $email, $password, $userId = 0, $send_welcome = true)
{
    global $db;
    $userId = (int) $userId;
    $email = strtolower($email);
    $res = pg_query($db, "SELECT * FROM users WHERE email = '" . pg_escape_string($email) . "'") or die("Database Error");
    if (pg_num_rows($res) > 0) {
        return false;
    }
    $apikey = generateRandomString(32);
    $activationKey = $send_welcome ? generateRandomString(40) : "";
    $res = pg_query($db, "INSERT INTO users(firstname, lastname, email, password, apikey, users_id, activationkey) VALUES('" . pg_escape_string($firstname) . "', '" . pg_escape_string($lastname) . "', '" . pg_escape_string($email) . "', '" . md5($password) . "', '" . $apikey . "', " . $userId . ", '" . pg_escape_string($activationKey) . "'); SELECT currval(pg_get_serial_sequence('users','id')) as last_insert_id;") or die("Database Error");
    if ($d = pg_fetch_assoc($res)) {
        $userId = $d['last_insert_id'];
        $layers_my_group = array();
        $layers_ssl_maps = array();
        $layers_style_maps = array();
        $layers_outdoor_maps = array();
        $layers_satellite_maps = array();
        $layers_style_maps[] = $layers_my_group[] = addLayers($userId, 'CartoDB Light', 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', '', '', 'Map tiles by <a href="http://cartodb.com/attributions#basemaps" target="_blank">CartoDB</a>, under <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY 3.0</a>. Data by <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>, under ODbL.');
        $layers_outdoor_maps[] = $layers_my_group[] = addLayers($userId, 'Loniva Hiking', 'http://tile.waymarkedtrails.org/hiking/{z}/{x}/{y}.png', '', '', '<a href="https://openpistemap.org" target="_blank">OpenStreetMap</a>');
        $layers_style_maps[] = $layers_my_group[] = addLayers($userId, 'MapQuest Sat', 'https://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', '', '', '<a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a>');
        $layers_style_maps[] = $layers_my_group[] = addLayers($userId, 'Stamen.Watercolor', 'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg', '', '', 'Map tiles by <a href="http://stamen.com" target="_blank">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0" target="_blank">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org" target="_blank">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0" target="_blank">CC BY SA</a>.');
        $layers_outdoor_maps[] = $layers_my_group[] = addLayers($userId, 'OpenCycleMap', 'http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png', '', '', '<a href="http://thunderforest.com/" target="_blank">Thunderforest</a>');
        $layers_ssl_maps[] = $layers_my_group[] = addLayers($userId, 'OpenStreetMap', 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', '', '', '<a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a>');
        $layers_satellite_maps[] = $layers_my_group[] = addLayers($userId, 'Esri World Imagery', 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', '', '', 'Attribution: <a href="http://www.esri.com/" target="_blank">ESRI</a>');
        $layers_satellite_maps[] = $layers_my_group[] = addLayers($userId, 'Google Maps', 'http://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}', '', '', '<a href="http://www.google.com/intl/en-GB_US/help/terms_maps.html" target="_blank">Google - Terms of Use</a>');
        $layers_my_group[] = addLayers($userId, 'MapBox', 'https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', 'examples.map-i875mjb7', '', '<a href="https://mapbox.com" target="_blank">MapBox</a>');
        $layers_outdoor_maps[] = $layers_my_group[] = addLayers($userId, 'Loniva Biking', 'http://tile.waymarkedtrails.org/cycling/{z}/{x}/{y}.png', '', '', '<a href="http://cycling.waymarkedtrails.org/" target="_blank">OpenStreetMap</a>');
        $layers_style_maps[] = $layers_my_group[] = addLayers($userId, 'Stamen.Toner', 'http://a.tile.stamen.com/toner/{z}/{x}/{y}.png', '', '', 'Map tiles by <a href="http://stamen.com" target="_blank">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0" target="_blank">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org" target="_blank">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright" target="_blank">ODbL</a>.');
        $layers_style_maps[] = $layers_my_group[] = addLayers($userId, 'CartoDB Dark', 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png', '', '', 'Map tiles by <a href="http://cartodb.com/attributions#basemaps" target="_blank">CartoDB</a>, under <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY 3.0</a>. Data by <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>, under ODbL.');
        $layers_ssl_maps[] = $layers_my_group[] = addLayers($userId, 'MapQuest', 'https://otile3-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', '', '', '<a href="https://openstreetmap.org" target="_blank">OpenStreetMap. </a> Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a>');
        $layers_my_group[] = addLayers($userId, 'MapFig Greenwaters', 'https://{s}.tile.thunderforest.com/mapfig-2a6/{z}/{x}/{y}.png', '', '', '&copy; <a href="http://mapfig.org" target="_blank">MapFig </a> Greenwaters by <a href="http://thunderforest.com" target="_blank">Thunderforest,</a> Data by <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>.');
        $layers_ssl_maps[] = $layers_my_group[] = addLayers($userId, 'MapFig Darkwaters', 'https://{s}.tile.thunderforest.com/mapfig-darkwaters/{z}/{x}/{y}.png', '', '', '&copy; <a href="http://mapfig.org" target="_blank">MapFig </a> Darkwaters by <a href="http://thunderforest.com" target="_blank">Thunderforest,</a> Data by <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>.');
        $layers_ssl_maps[] = $layers_my_group[] = addLayers($userId, 'MapFig Bluewaters', 'https://{s}.tile.thunderforest.com/mapfig-bluewaters/{z}/{x}/{y}.png', '', '', '&copy; <a href="http://mapfig.org" target="_blank">MapFig </a> Bluewaters by <a href="http://thunderforest.com" target="_blank">Thunderforest,</a> Data by <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>.');
        $g1 = addGroup($userId, 'My Group');
        addGroupHasLayers($userId, $g1, $layers_my_group);
        $g1 = addGroup($userId, 'SSL Maps');
        addGroupHasLayers($userId, $g1, $layers_ssl_maps);
        $g1 = addGroup($userId, 'Style Maps');
        addGroupHasLayers($userId, $g1, $layers_style_maps);
        $g1 = addGroup($userId, 'Outdoor Maps');
        addGroupHasLayers($userId, $g1, $layers_outdoor_maps);
        $g1 = addGroup($userId, 'Satellite Maps');
        addGroupHasLayers($userId, $g1, $layers_satellite_maps);
        if ($send_welcome) {
            sendWelcomeEmail($userId, $password);
        }
        return $userId;
    } else {
        return false;
    }
}
Example #2
0
<?php

require_once dirname(__FILE__) . "/../../../include/master.inc.php";
$error = "";
$success = "";
if (!isLogin()) {
    redirect(BASEURL . "app/login.php");
}
if (isset($_POST['save'])) {
    if (!addGroupHasLayers($_SESSION['user']['id'], (int) $_POST['id'], $_POST['assigned'])) {
        $error = "Something went wrong. Please refresh and try again!";
    } else {
        $success = "Successfully Saved!";
    }
} else {
    $error = "Invalid Request";
}
$_SESSION['response']['group-add-layers']['error'] = $error;
$_SESSION['response']['group-add-layers']['success'] = $success;
redirect(BASEURL . "app/group-add-layers.php?id=" . (int) $_POST['id']);