Exemplo n.º 1
0
<?php

$data = file_get_contents("php://input");
$query = json_decode($data);
$guid = '66acd610-159d-4881-bb04-b48f9452b98c';
$userid = 'AFPPR46VI4HFCERSD2ENKTJBTCGHF6J6ERFIWCEI7GP4YDXFRBEJI';
include '../validate-echo-request-php/valid_request.php';
$valid = validate_request($guid, $userid);
$help = "Welcome to St. Andrew Orthodox Info. Ask me who todays saint is, whether today is a fast day, or for today's reading. What would you like to know?";
if ($valid['success']) {
    if ($query) {
        $action = $query->request->intent->name;
        $response = '';
        if ($action == "GetSaint") {
            $response = getsaint();
        } elseif ($action == "GetFast") {
            $response = getfast();
        } elseif ($action == "GetReading") {
            $response = getreading();
        } elseif ($action = 'AMAZON.HelpIntent') {
            sendresponse($help, false);
        } else {
            sendresponse($help, false);
        }
        if ($response) {
            sendresponse($response, true);
        }
    } else {
        sendresponse($help, true);
    }
} else {
        $count += getinfo("SELECT * FROM `factures_etal` WHERE `reglement` = '0' AND `acceptation` = '1'");
        $count += getinfo("SELECT * FROM `factures_amarrage` WHERE `reglement` = '0' AND `acceptation` = '1'");
        print "{\"num\":\"{$count}\"}";
        break;
    case "client":
        $count = 0;
        $count += getinfo("SELECT * FROM `clients` WHERE `clientstatus` = '1'");
        print "{\"num\":\"{$count}\"}";
        break;
    case "enfant":
        $count = 0;
        $count += getinfo("SELECT * FROM `enfants` WHERE `active` = '1'");
        print "{\"num\":\"{$count}\"}";
        break;
    case "saint":
        print getsaint("01/01");
        break;
    case "rolmre_cantine":
        print getrol("rolmre_cantine");
        break;
}
function getinfo($query)
{
    $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    $result = $mysqli->query($query);
    $num_rows = mysqli_num_rows($result);
    $mysqli->close();
    return $num_rows;
}
function getsaint()
{