function insertDatabaseFunc($username, $password, $queryType, $entity)
{
    require_once 'queryDatabaseHelper.php';
    if (validUsernameAndPassword($username, $password)) {
        $link = mysqli_connect("localhost", "Tommy", "pickles", "Model");
        if (strcmp($queryType, 'Unsubs') == 0) {
            $query = 'DELETE FROM `subscription` WHERE `username`=\'' . $username . '\' AND `orgnumber`=\'' . $entity . '\'';
        } elseif (strcmp($queryType, 'RSVP') == 0) {
            $query = 'INSERT IGNORE INTO `rsvp`(`username`, `eventnumber`) VALUES (\'' . $username . '\',' . $entity . ')';
        } elseif (strcmp($queryType, 'Subs') == 0) {
            $query = 'INSERT INTO `subscription`(`username`, `orgnumber`) VALUES (\'' . $username . '\',\'' . $entity . '\')';
        } elseif (strcmp($queryType, 'AndroidDevice') == 0) {
            $query = 'INSERT IGNORE INTO `androiddevice`(`username`, `device_id`) VALUES (\'' . $username . '\',\'' . $entity . '\')';
        }
        if (mysqli_connect_errno()) {
            printf("Connect failed: %s\n", mysqli_connect_error());
            exit;
        }
        if (mysqli_query($link, $query)) {
            echo 'true';
        } else {
            echo 'false';
        }
        mysqli_close($link);
    } else {
        echo 'false';
    }
}
Esempio n. 2
0
<?php

//HTTP Post allowing mobile and browser clients to call the queries specified in queryDatabaseFunc.
if (isset($_POST["Username"]) && isset($_POST["Password"]) && isset($_POST['QueryType'])) {
    require_once 'queryDatabaseHelper.php';
    $username = $_POST["Username"];
    $password = $_POST["Password"];
    $queryType = $_POST["QueryType"];
    $valid = validUsernameAndPassword($username, $password);
    if ($valid === True) {
        $json_to_send = array();
        $results = queryDatabaseFunc($username, $password, $queryType);
        $subscribed = false;
        if (strcmp($queryType, "myOrgs") == 0 || strcmp($queryType, "browseOrgs") == 0) {
            if (strcmp($queryType, "myOrgs") == 0) {
                $subscribed = true;
            }
            $link = mysqli_connect("localhost", "Tommy", "pickles", "Model");
            if (mysqli_connect_errno()) {
                printf("Connect failed: %s\n", mysqli_connect_error());
                exit;
            }
            $orglist = array();
            $orgnumberlist = array();
            foreach ($results as $orgrow) {
                $found = false;
                for ($x = 0; $x < count($orgnumberlist); $x++) {
                    if ($orgnumberlist[$x] === $orgrow['orgnumber']) {
                        $found = true;
                        break;
                    }
Esempio n. 3
0
<?php

//General purpose HTTP post to validate a username and password from the database.
if (isset($_POST["Username"]) && isset($_POST["Password"])) {
    require_once 'queryDatabaseHelper.php';
    $username = $_POST["Username"];
    $password = $_POST["Password"];
    if (validUsernameAndPassword($username, $password)) {
        echo 'true';
    } else {
        echo 'false';
    }
}