Пример #1
0
<?php

require 'config.php';
//makes connection to database
Submit::processSubmit();
class Submit
{
    static $response_array = array('advanced' => 0, 'message' => '', 'status' => 'success');
    static $userId = 0;
    static $deviceId = 0;
    static $passcode = 0;
    static $marker = 0;
    public static function processSubmit()
    {
        global $con;
        self::getParams();
        self::$userId = self::getUserId(self::$deviceId, self::$passcode);
        //check if user is authorized:
        if (self::$userId != -1) {
            self::addLocationToDB();
        } else {
            self::$response_array['message'] = 'not authorized';
        }
        echo json_encode(self::$response_array);
        mysql_close($con);
    }
    /**
     * Return int of userId or -1 if not valid
     */
    static function getUserId($deviceId, $passcode)
    {