Example #1
0
                    if ($reqdb3->count_to_blocked >= 3) {
                        $DB->execute('UPDATE {nitrocard_cards} SET blocked="1" WHERE fullcardid="' . strip_tags($card) . '"');
                        throw new Exception('NitroCard is blocked.');
                    }
                    throw new Exception('PIN is incorrect.');
                }
            } else {
                //remote
            }
        } catch (Exception $e) {
            setError($e->getMessage());
        }
        return false;
    }
}
$server = new Zend\Json\Server\Server();
function setError($msg = null, $code = 404, $data = null)
{
    global $server;
    $server->fault($msg, $code, $data);
}
$server->setClass('NitroCard')->setTarget('https://' . $_SERVER['SERVER_NAME'] . '/' . $_SERVER['SCRIPT_NAME'])->setDescription('NitroCard Server API')->setEnvelope(Zend\Json\Server\Smd::ENV_JSONRPC_2);
if (isset($_GET['smd'])) {
    echo $server->getServiceMap();
    exit;
}
if ('GET' == $_SERVER['REQUEST_METHOD']) {
    echo "Access denied.";
    exit;
}
if ('POST' == $_SERVER['REQUEST_METHOD']) {
Example #2
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
require_once 'Calculator.php';
// Check authentication
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== 'username' || $_SERVER['PHP_AUTH_PW'] !== 'password') {
    header('WWW-Authenticate: Basic realm="PHP JSON-RPC Server"');
    header('HTTP/1.1 401 Unauthorized');
    exit;
}
// Instantiate the JSON-RPC server
$server = new \Zend\Json\Server\Server();
$server->setClass('Calculator');
$server->handle();