示例#1
0
文件: index.php 项目: slh93/CEEO
<?php

/* Debug mode */
require "Constants/debug_mode.php";
require "Classes/StompAPI.php";
// Requests from the same server don't have a HTTP_ORIGIN header
if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) {
    $_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME'];
}
try {
    $API = new StompAPI($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']);
    echo $API->processAPI() . "\n";
} catch (Exception $e) {
    echo json_encode(array('error' => $e->getMessage()));
}
示例#2
0
 *
 */

<?php 
require "Conn.php";
require "StompAPI.php";
$email = htmlentities($_POST["email"]);
$password = htmlentities($_POST["password"]);
$returnValue = array();
if (empty($email) || empty($password)) {
    $returnValue["status"] = "error";
    $returnValue["message"] = "Missing required field";
    echo json_encode($returnValue);
    return;
}
$api = new StompAPI();
$api->openConnection();
$userDetails = $api->getUserDetails($email);
if (!empty($userDetails)) {
    $returnValue["status"] = "error";
    $returnValue["message"] = "User already exists";
    echo json_encode($returnValue);
    return;
}
// user password cannot be read by developer
$secure_password = md5($password);
$result = $api->registerUser($email, $secure_password);
if ($result) {
    $returnValue["status"] = "Success";
    $returnValue["message"] = "User is registered";
    echo json_encode($returnValue);
示例#3
0
文件: userLogin.php 项目: slh93/CEEO
/*
 *	userLogin.php
 *
 */

<?php 
require "Classes/Conn.php";
require "Classes/StompAPI.php";
$email = htmlentities($_POST["email"]);
$password = htmlentities($_POST["password"]);
$returnValue = array();
if (empty($email) || empty($password)) {
    $returnValue["status"] = "error";
    $returnValue["message"] = "Missing required field";
    echo json_encode($returnValue);
    return;
}
$api = new StompAPI();
$api->openConnection();
$userDetails = $api->getUserDetailsWithPassword($email, md5($password));
if (!empty($userDetails)) {
    $returnValue["status"] = "Success";
    $returnValue["message"] = "User is registered";
} else {
    $returnValue["status"] = "error";
    $returnValue["message"] = "User is not found";
}
echo json_encode($returnValue);
$api->closeConnection();