Beispiel #1
0
function fail($msg)
{
    $meta["ok"] = false;
    $debug[] = $msg;
    sendResults(array(), $meta, $debug);
    exit(-1);
}
<?php

/* yadl_spaceid - Skip Stamping */
header('Content-type: text/plain');
$search_queries = initArray();
$query = $_GET['query'];
$results = search($search_queries, $query);
sendResults($query, $results);
function search($search_queries, $query)
{
    if (strlen($query) == 0) {
        return;
    }
    $query = strtolower($query);
    $firstChar = $query[0];
    if (!preg_match('/[0-9a-z]/', $firstChar, $matches)) {
        return;
    }
    $charQueries = $search_queries[$firstChar];
    $results = array();
    for ($i = 0; $i < count($charQueries); $i++) {
        if (strcasecmp(substr($charQueries[$i], 0, strlen($query)), $query) == 0) {
            $results[] = $charQueries[$i];
        }
    }
    return $results;
}
function sendResults($query, $results)
{
    for ($i = 0; $i < count($results); $i++) {
        print "{$results[$i]}\n";
Beispiel #3
0
<?php

/*
Returns the current contents of the Linora database as a
JSON object, representing the arry of results, sorted on
first the category, then on the caption.
*/
include __DIR__ . '/../../../inc/all.php';
$in = extractVars();
$results = get_links($in);
sendResults($results);
Beispiel #4
0
<?php

date_default_timezone_set('UTC');
error_reporting(E_ALL);
ini_set('display_errors', 1);
$db_host = 'localhost';
$db_database = 'tenbreaths';
$db_user = '******';
$db_password = '******';
// create and initialise the database connection
$mysqli = new mysqli($db_host, $db_user, $db_password, $db_database);
// connect to the database
if ($mysqli->connect_error) {
    $returnObject['error'] = $mysqli->connect_error;
    sendResults($returnObject);
}
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
}
Beispiel #5
0
{
    $connectionString = "host=ec2-54-225-101-64.compute-1.amazonaws.com port=5432 dbname=d1nigmib60rp1v user=jykiewmddlbjft password=kRqkD183znoOpPNTlDq6f_Xs29";
    $dbconnection = pg_connect($connectionString);
    $result = pg_query($dbconnection, "SELECT u.fname, u.lname, u.id, r.quizname, q.coursecode, r.score, r.timetaken, r.datetaken\n\t\tFROM result r\n\t\tinner join useraccount u on r.userid=u.id\n\t\tinner join quiz q on r.quizname=q.name\n\t\twhere u.fname like '%{$fname}%'\n\t\tand u.lname like '%{$lname}%'\n\t\tand r.quizname like '%{$quiz}%'\n\t\tand q.coursecode like '%{$coursecode}%'\n\t\torder by score desc");
    return json_encode(pg_fetch_all($result));
}
if (isset($_POST['funcName'])) {
    switch ($_POST['funcName']) {
        case 'checkPasswordAdmin':
            echo checkPasswordAdmin($_POST['username'], $_POST['password']);
            break;
        case 'getAllQuestionsFromQuiz':
            echo getAllQuestionsFromQuiz($_POST['quizname']);
            break;
        case 'sendResults':
            echo sendResults($_POST['username'], $_POST['password'], $_POST['quizname'], $_POST['timetaken'], $_POST['score'], $_POST['date']);
            break;
        case 'getResults':
            echo getResults($_POST['username'], $_POST['password']);
            break;
        case 'checkPassword':
            echo checkPassword($_POST['username'], $_POST['password']);
            break;
        case 'getAllResults':
            echo getAllResults();
            break;
        case 'getQueryResults':
            echo getQueryResults($_POST['fname'], $_POST['lname'], $_POST['quiz'], $_POST['coursecode']);
            break;
        case 'getQuizzes':
            echo getQuizes();