示例#1
0
function printCSV($listData, $data)
{
    $s = "Completed,Priority,Task,Notes,Tags,Due,DateCreated,DateCompleted\n";
    foreach ($data as $r) {
        $s .= ($r['compl'] ? '1' : '0') . ',' . $r['prio'] . ',' . escape_csv($r['title']) . ',' . escape_csv($r['note']) . ',' . escape_csv($r['tags']) . ',' . $r['duedate'] . ',' . date('Y-m-d H:i:s O', $r['d_created']) . ',' . ($r['d_completed'] ? date('Y-m-d H:i:s O', $r['d_completed']) : '') . "\n";
    }
    header('Content-type: text/csv; charset=utf-8');
    header('Content-disposition: attachment; filename=list_' . $listData['id'] . '.csv');
    print $s;
}
*/
define('SERVICE_NAME', 'get_pois');
define('DEFAULT_DYN_DATA_VALID_TIME', 60);
// used, if fw_dynamic.valid_duration
// is not defined
require_once 'db.php';
require_once 'util.php';
require_once 'get_dyn_pois.php';
require_once 'data_manager.php';
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $components = get_supported_components();
    $dlog = array();
    // string array for debug tracing
    if (isset($_GET['poi_id'])) {
        $poi_id = $_GET['poi_id'];
        $esc_ids = escape_csv($poi_id, "'");
        if (isset($_GET['component'])) {
            $component = $_GET['component'];
            $esc_components = pg_escape_string($component);
            $components = explode(",", $esc_components);
        }
        $fetch_for_update = false;
        if (isset($_GET['fetch_for_update'])) {
            if ($_GET['fetch_for_update'] == "true") {
                $fetch_for_update = true;
            }
        }
        $data = array();
        $esc_ids_arr = explode(",", $esc_ids);
        foreach ($esc_ids_arr as $poi_uuid) {
            $poi_uuid = str_replace("'", "", $poi_uuid);
示例#3
0
function handle_common_search_params()
{
    $params = array();
    $params['max_results'] = 9999;
    $params['components'] = get_supported_components();
    if (isset($_GET['category'])) {
        $category = $_GET['category'];
        $esc_categories = escape_csv($category, "\"");
        $params['categories'] = $esc_categories;
    }
    if (isset($_GET['component'])) {
        $component = $_GET['component'];
        $esc_components = pg_escape_string($component);
        $components = explode(",", $esc_components);
        $params['components'] = $components;
    }
    if (isset($_GET['max_results'])) {
        $max_res = $_GET['max_results'];
        if (!is_numeric($max_res)) {
            header("HTTP/1.0 400 Bad Request");
            die("'max_results' must be a positive integer value!");
        }
        $max_results = intval($max_res);
        if ($max_results < 1) {
            header("HTTP/1.0 400 Bad Request");
            die("'max_results' must be a positive integer value!");
        }
        $params['max_results'] = $max_results;
    }
    if (isset($_GET['begin_time']) and isset($_GET['end_time'])) {
        $min_minutes = 1;
        //Default value
        if (isset($_GET['min_minutes'])) {
            $min_minutes = $_GET['min_minutes'];
            if (!is_numeric($min_minutes)) {
                header("HTTP/1.0 400 Bad Request");
                die("'min_minutes' must be a positive integer value!");
            }
            $min_minutes = intval($min_minutes);
            if ($min_minutes < 1) {
                header("HTTP/1.0 400 Bad Request");
                die("'min_minutes' must be a positive integer value!");
            }
        }
        $params['min_minutes'] = $min_minutes;
        if (isset($_GET['schedule'])) {
            $schedule_json = $_GET['schedule'];
            $schedule = json_decode($schedule_json);
            if ($schedule == NULL) {
                header("HTTP/1.0 400 Bad Request");
                die("JSON decoding failed for 'schedule'. Is it valid JSON and properly url-encoded?");
            }
            //TODO: Validate the schedule JSON against schema!
            $schedule_valid = validate_poi_data($schedule, 'schedule_schema_3.3.json');
            if (!$schedule_valid) {
                header("HTTP/1.0 400 Bad Request");
                die("'schedule' does not validate against JSON schema!");
            }
            $schedule = json_decode($schedule_json, true);
            $params['schedule'] = $schedule;
        }
        $begin_time = $_GET['begin_time'];
        $end_time = $_GET['end_time'];
        $begin_time_obj = date_parse($begin_time);
        $end_time_obj = date_parse($end_time);
        if ($begin_time_obj['error_count'] != 0) {
            header("HTTP/1.0 400 Bad Request");
            die("Error parsing 'begin_time'!");
        }
        if ($end_time_obj['error_count'] != 0) {
            header("HTTP/1.0 400 Bad Request");
            die("Error parsing 'end_time'!");
        }
        $params['begin_time'] = $begin_time_obj;
        $params['end_time'] = $end_time_obj;
    }
    return $params;
}
示例#4
0
/*
* Project: FI-WARE
* Copyright (c) 2014 Center for Internet Excellence, University of Oulu, 
* All Rights Reserved
* For conditions of distribution and use, see copyright notice in LICENSE
*/
define('SERVICE_NAME', 'get_user');
require_once 'db.php';
require_once 'user_data_manager.php';
require_once 'util.php';
require 'security.php';
$debug_log = array();
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    if (isset($_GET['user_id'])) {
        $user_id_param = pg_escape_string($_GET['user_id']);
        $esc_ids = escape_csv($user_id_param, "'");
        $user_id_arr = explode(",", $esc_ids);
        foreach ($user_id_arr as &$user_id) {
            $user_id = str_replace("'", "", $user_id);
            $data[$user_id] = array();
        }
        // viewing a user requires administrator permission
        $session = get_session();
        $update_permission = $session['permissions']['admin'];
        if (!$update_permission) {
            header("HTTP/1.0 403 Forbidden");
            die("Permission denied.");
        }
        $db_opts = get_db_options();
        $mongodb = connectMongoDB($db_opts['mongo_db_name']);
        $users = $mongodb->_users;