public function query()
 {
     $data = json_decode(file_get_contents('php://input'), TRUE);
     $text = print_r($data, true);
     $ver = $data['version'];
     $requestType = $data['request'][type];
     // request type just writes the type of request to the file
     // the text variable file_put_contents writes the php array to disk
     // tail this file
     //file_put_contents('fromamazon.txt',$requestType);
     file_put_contents('fromamazon.txt', $text);
     // if for some reason you wanted to show something to web users.
     if (!$ver) {
         //echo("<html>web request detected</html>");
     }
     if ($requestType == 'SessionEndedRequest') {
         endSession('goodbye');
     }
     //$requestType = 'LaunchRequest';
     if ($requestType == 'LaunchRequest') {
         // new session!
         speechOut('What is your question?');
     }
     //$requestType = 'IntentRequest';
     if ($requestType == 'IntentRequest') {
         $answer = $this->processIntent($data);
         // now it's plaintext, lets have alexa say it.
         speechOut($answer);
     }
     // end of intent request
 }
function protegePagina()
{
    global $_SG;
    if (!isset($_SESSION['userID']) or !isset($_SESSION['userName']) or !isset($_SESSION['userEmail'])) {
        // Não há usuário logado, manda pra página de login
        endSession();
    } else {
        if (isset($_SESSION['userID']) or isset($_SESSION['userName'])) {
            // Há usuário logado, verifica se precisa validar o login novamente
            if ($_SG['validaSempre'] == true) {
                // Verifica se os dados salvos na sessão batem com os dados do banco de dados
                if (!validaUsuario($_SESSION['userEmail'], $_SESSION['userPasswd'])) {
                    // Os dados não batem, manda pra tela de login
                    endSession();
                }
            }
        }
    }
}
Example #3
0
<?php

require_once dirname(__FILE__) . "/includes/global_deploy_config.php";
require_once dirname(__FILE__) . "/includes/common.inc.php";
require_once dirname(__FILE__) . "/database/users.php";
startSession();
// log session end
$users = new users();
$users->recordLogout($_SESSION['user_id']);
$users->close();
// end PHP session
endSession();
// kill Shibboleth session
header("Location: {$logoutURL}");
exit;
Example #4
0
// what's happening in the session
$data = json_decode(file_get_contents('php://input'), TRUE);
$text = print_r($data, true);
$ver = $data['version'];
$requestType = $data['request'][type];
// request type just writes the type of request to the file
// the text variable file_put_contents writes the php array to disk
// tail this file
//file_put_contents('fromamazon.txt',$requestType);
file_put_contents('fromamazon.txt', $text);
// if for some reason you wanted to show something to web users.
if (!$ver) {
    //echo("<html>web request detected</html>");
}
if ($requestType == 'SessionEndedRequest') {
    endSession('goodbye');
}
//$requestType = 'LaunchRequest';
if ($requestType == 'LaunchRequest') {
    // new session!
    speechOut('What is your question?');
}
//$requestType = 'IntentRequest';
if ($requestType == 'IntentRequest') {
    // the question comes from the header sent by 'mamazon
    $myQ = $data['request'][intent][slots][Ans][value];
    // build the string
    $path = 'http://api.wolframalpha.com/v2/query?input=';
    $append_id = '&appid=';
    // GET YOUR OWN WOLFRAM API KEY ITS FREE
    $append_id .= 'XXXXXX-XXXXXXXX';
<?php

session_start();
if ($_SESSION['user'] == null || isset($_POST['username'])) {
    $_SESSION['user'] = $_POST["username"];
    $_SESSION['password'] = $_POST["password"];
}
//create Database connection with given user name and password
$myconnection = mysql_pconnect('localhost', $_SESSION['user'], $_SESSION['password']) or endSession();
//Select Database
$mydb = mysql_select_db('project_database') or die('Could not select database');
function endSession()
{
    session_destroy();
    echo "invalid login";
    die('invalid login');
}
Example #6
0
 function surveyEntry()
 {
     global $engine;
     if ($this->checkDateTime() == false) {
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $login = new Login(session_id());
         return $login->getClosedScreen();
     }
     $logactions = new LogActions();
     $nosessionactions = $logactions->getNumberOfSurveyActionsBySession($this->phpid, USCIC_SURVEY);
     /* no entry yet, then ask for prim_key in login screen */
     if ($nosessionactions == 0 || loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
         //no entry yet: ask for prim_key!
         if (loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
             $logactions->deleteLoggedInSurveySession($this->phpid);
         }
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $logactions->addAction('', '', "loginstart", USCIC_SURVEY, 1);
         $login = new Login($this->phpid);
         return $login->getLoginScreen();
     } else {
         //entry: is this person logged in?
         $loggedin = $logactions->getLoggedInSurveySession($this->phpid);
         // gets the last logged in action
         /* no prim_key assigned to this sessionid. Assign if given (and check for pwd etc??)! */
         if ($loggedin["count"] == 0) {
             /* we don't have active session, so take the template we can get */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             // we don't have an active session, so fall back to whatever was passed along as language in post OR is the default language
             $l = getSurveyLanguage();
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             $primkey = loadvarSurvey(POST_PARAM_PRIMKEY);
             $_SESSION['PRIMKEY'] = $primkey;
             if ($primkey != '' && strlen($primkey) < 20) {
                 // make sure primkey is not encrypted!
                 //check!!!!!!
                 $login = new Login($this->phpid);
                 if ($login->checkAccess()) {
                     $primkey = $_SESSION['PRIMKEY'];
                     $logactions->addAction($primkey, '', "loggedin", USCIC_SURVEY, 1);
                     // pass along primkey to load correct engine!
                     $engine = loadEngine(getSurvey(), $primkey, $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $primkey));
                     $engine->setFirstForm(true);
                     return $engine->getNextQuestion();
                 } else {
                     // incorrect login..start new session
                     endSession();
                     session_start();
                     session_regenerate_id(true);
                     $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                     $login = new Login(session_id());
                     global $survey;
                     return $login->getLoginScreen($survey->getLoginError());
                 }
             } else {
                 $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                 $login = new Login($this->phpid);
                 global $survey;
                 if ($survey->getAccessType() == LOGIN_ANONYMOUS) {
                     return $login->getLoginScreen(Language::messageEnterPrimKey());
                 } else {
                     if ($survey->getAccessType() == LOGIN_LOGINCODE) {
                         return $login->getLoginScreen($survey->getLoginError());
                     } else {
                         return $login->getLoginScreen(Language::messageEnterPrimKeyDirectAccess());
                     }
                 }
             }
         } else {
             //continue interview! EXTRA CHECK!!!
             /* update survey info with what we know from the last session action */
             setSurvey($loggedin["suid"]);
             /* include survey template now that we know which survey we are in */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             /* update interview mode with what we know from the last session action
              * IF we are not changing the interview mode right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_MODE_CHANGE && $survey->getReentryMode() == MODE_REENTRY_YES) {
                 setSurveyMode($loggedin["mode"]);
             }
             /* update language with what we know from the last session action 
              * IF we are not changing the language right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_LANGUAGE_CHANGE && $survey->getReentryLanguage(getSurveyMode()) == LANGUAGE_REENTRY_YES) {
                 setSurveyLanguage($loggedin["language"]);
             }
             /* update version with what we know from the last session action */
             setSurveyVersion($loggedin["version"]);
             // include language file
             $l = getSurveyLanguage();
             //echo 'NOW: ' . $l;
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             // pass along primkey to load correct engine!
             $engine = loadEngine(getSurvey(), $loggedin["primkey"], $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $loggedin["primkey"]));
             /* handle button click */
             return $engine->getNextQuestion();
         }
     }
 }
Example #7
0
<?php

function endSession($words)
{
    header('Content-type: application/json');
    $open = '{"version": "1.0","sessionAttributes":"","response":{"outputSpeech":{"type": "PlainText","text": "';
    $card = '"},"card": {"type": "Simple","title": "Cat Fact","content": "';
    $close = '"},"shouldEndSession": true}}';
    echo $open;
    echo $words;
    echo $card;
    echo $words;
    echo $close;
}
$data = json_decode(file_get_contents('http://catfacts-api.appspot.com/api/facts?number=1'), TRUE);
$text = print_r($data, true);
$ver = $data['facts'][0];
endSession($ver);