Exemple #1
0
function createSession($token, $eid, $name = "", $description = "", $street = "", $city = "", $country = "", $default_read = 1, $default_contribute = 0, $finalized = 0, $debug_data = "")
{
    global $db;
    $uid = $token['uid'];
    $session = $token['session'];
    $data = $db->query("SELECT sessions.session_id, sessions.finalized FROM sessions, experimentSessionMap WHERE sessions.session_id = experimentSessionMap.session_id AND experimentSessionMap.experiment_id = {$eid}");
    $numOfSessions = $db->numOfRows;
    if ($db->numOfRows == 1 && $data[0]['finalized'] == 0) {
        $cords = getLatAndLon($street, $city, $country);
        $lat = $cords[1];
        $lon = $cords[0];
        $db->query("UPDATE sessions SET sessions.owner_id = '{$uid}',\n\t\t\t\t\t\t\t\t\t\tsessions.name = '{$name}',\n\t\t\t\t\t\t\t\t\t\tsessions.description = '{$description}',\n\t\t\t\t\t\t\t\t\t\tsessions.street = '{$street}',\n\t\t\t\t\t\t\t\t\t\tsessions.city = '{$city}',\n\t\t\t\t\t\t\t\t\t\tsessions.country = '{$country}',\n\t\t\t\t\t\t\t\t\t\tsessions.timecreated = NOW(),\n\t\t\t\t\t\t\t\t\t\tsessions.finalized = 1,\n\t\t\t\t\t\t\t\t\t\tsessions.timemodified = NOW(),\n\t\t\t\t\t\t\t\t\t\tsessions.default_read = {$default_read},\n\t\t\t\t\t\t\t\t\t\tsessions.default_contribute = {$default_contribute},\n\t\t\t\t\t\t\t\t\t\tsessions.latitude = '{$lat}',\n\t\t\t\t\t\t\t\t\t\tsessions.longitude = '{$lon}',\n\t\t\t\t\t\t\t\t\t\tsessions.debug_data = '{$debug_data}'\n\t\t\t\t\t\t\t\t\t\tWHERE sessions.session_id = {$data[0]['session_id']}");
        if ($db->numOfRows) {
            return $data[0]['session_id'];
        }
        return false;
    } else {
        if ($numOfSessions == 0) {
            $finalized = 0;
        } else {
            $finalized = 1;
        }
        $cords = getLatAndLon($street, $city, $country);
        $lat = $cords[1];
        $lon = $cords[0];
        $db->query("INSERT INTO sessions (owner_id, name, description, finalized, street, city, country, timecreated, timemodified, default_read, default_contribute, latitude, longitude, debug_data) VALUES( {$uid}, '{$name}', '{$description}', {$finalized}, '{$street}', '{$city}', '{$country}', NOW(), NOW(), {$default_read}, {$default_contribute}, {$lat}, {$lon}, '{$debug_data}')");
        if ($db->numOfRows) {
            $sid = $db->lastInsertId();
            $db->query("INSERT INTO experimentSessionMap (session_id, experiment_id) VALUES({$sid}, {$eid})");
            return $sid;
        }
    }
    return false;
}
Exemple #2
0
function createVideoItem($uid, $eid, $title, $description, $street, $citystate, $provider_id, $provider_url, $published = 1, $country = "United States", $provider = "youtube")
{
    global $db;
    $cords = getLatAndLon($street, $citystate, $country);
    $latitude = $cords[1];
    $longitude = $cords[0];
    $output = $db->query("INSERT INTO videos (`owner_id`, `experiment_id`, `title`, `description`, `street`, `city`, `country`, `latitude`, `longitude`, `provider`, `provider_id`, `provider_url`, `published`, `uploaded`) VALUES({$uid}, {$eid}, '{$title}', '{$description}', '{$street}', '{$citystate}', '{$country}', '{$latitude}', '{$longitude}', '{$provider}', '{$provider_id}', '{$provider_url}', {$published}, NOW())");
    if ($db->numOfRows) {
        return true;
    }
    return false;
}
Exemple #3
0
function updateUserProfile($uid, $firstname, $lastname, $email, $street, $city, $country)
{
    global $db;
    $cords = getLatAndLon($street, $city, $country);
    $lat = $cords[1];
    $lon = $cords[0];
    $db->query("UPDATE users SET \tusers.firstname = '{$firstname}',\n\t\t\t\t\t\t\t\t\tusers.lastname = '{$lastname}',\n\t\t\t\t\t\t\t\t\tusers.street = '{$street}',\n\t\t\t\t\t\t\t\t\tusers.city = '{$city}',\n\t\t\t\t\t\t\t\t\tusers.country = '{$country}',\n\t\t\t\t\t\t\t\t\tusers.email = '{$email}',\n\t\t\t\t\t\t\t\t\tusers.latitude = '{$lat}',\n\t\t\t\t\t\t\t\t\tusers.longitude = '{$lon}'\n\t\t\t\t\t\t\t\t\tWHERE users.user_id = {$uid}");
    if ($db->numOfRows) {
        return true;
    }
    return false;
}
Exemple #4
0
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */
require_once '../includes/config.php';
$results = $db->query("SELECT * FROM sessions WHERE latitude = 200 AND longitude = 200");
$total = $db->numOfRows;
$count = 0;
foreach ($results as $result) {
    $cords = getLatAndLon($result['street'], $result['city']);
    $id = $result['session_id'];
    $lat = $cords[1];
    $lon = $cords[0];
    if ($lat != 200 && $lon != 200) {
        $db->query("UPDATE sessions SET latitude = {$lat}, longitude = {$lon} WHERE session_id = {$id}");
        $count++;
    }
    sleep(2);
}
echo "Total Found: " . $total . "<br/>";
echo "Total Fixed: " . $count . "<br/>";
Exemple #5
0
    $smarty->assign('values', $values);
}
if (isset($_POST['session_create'])) {
    $sid = (int) safeString($_POST['id']);
    $org_values = getSession($sid);
    $city = safeString($_POST['session_citystate']);
    $street = safeString($_POST['session_street']);
    $hidden_val = isset($_POST['session_hidden']) ? safeString($_POST['session_hidden']) : "off";
    if (strcasecmp($hidden_val, "on") == 0) {
        $hidden_val = 0;
    } else {
        $hidden_val = 1;
    }
    $values = array('name' => safeString($_POST['session_name']), 'description' => safeString($_POST['session_description']), 'city' => $city, 'street' => $street, 'finalized' => $hidden_val);
    if ($city != $org_values['city'] || $street != $org_values['street']) {
        $cords = getLatAndLon($street, $city, "United States");
        $lat = $cords[1];
        $lon = $cords[0];
        $values['latitude'] = $lat;
        $values['longitude'] = $lon;
    }
    updateSession($sid, $values);
    $created = true;
    $title = "Successfully Edited Session";
}
// Process the images for displayi
global $db;
$images = array();
$images = getImagesForSession($sid);
$image_urls = array();
if ($images) {
Exemple #6
0
<?php

/* Copyright (c) 2011, iSENSE Project. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer. Redistributions in binary
 * form must reproduce the above copyright notice, this list of conditions and
 * the following disclaimer in the documentation and/or other materials
 * provided with the distribution. Neither the name of the University of
 * Massachusetts Lowell nor the names of its contributors may be used to
 * endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */
require_once '../includes/config.php';
print_r(getLatAndLon($_GET['street'], $_GET['citystate']));