Ejemplo n.º 1
0
<?php

// Inialize session
session_start();
// Load config
include '../../../config.php';
// Initialize variables
$goodApiKey = false;
$goodSessionKey = false;
$sessionKey = "";
$goodApiKey = isApiKeyValid($_GET['apikey']);
// Load game info
$sessions = mysql_query("SELECT * FROM sessions");
while ($row = mysql_fetch_array($sessions)) {
    if ($row['sessionkey'] == $_GET['sessionkey']) {
        $goodSessionKey = true;
        $sessionKey = $_GET['sessionkey'];
    }
}
// Check game and user info
if ($goodSessionKey && $goodApiKey) {
    mysql_query("DELETE FROM sessions WHERE sessionkey = '" . $sessionKey . "'");
    echo "true\n";
} else {
    echo "false";
    echo "<br>";
    echo "Invalid key(s)\n";
}
function isApiKeyValid($key)
{
    // Load game info
Ejemplo n.º 2
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    return Redirect::to('recipe');
});
Route::get('api/shopping_list/', function () {
    if (!isApiKeyValid(Input::get('key'))) {
        App::abort(401, 'Not authenticated');
    }
    if (Input::has('updatedOnOrAfter')) {
        //$date = new DateTime(Input::get('updatedOnOrAfter'));
        //$dateString = $date->format('Y-m-d H:i:s');
        //$items = ShoppingListItem::where('updated_at', '>=', Input::get('updatedOnOrAfter'))->get();
        $items = DB::table('shopping_list_item')->leftJoin('category', 'shopping_list_item.category_id', '=', 'category.id')->select('shopping_list_item.id', 'shopping_list_item.item_size', 'shopping_list_item.name', 'shopping_list_item.item_count', 'shopping_list_item.price', 'shopping_list_item.category_id', 'shopping_list_item.created_at', 'shopping_list_item.updated_at')->where('updated_at', '>=', Input::get('updatedOnOrAfter'))->orderBy('category.sort_order', 'ASC')->orderBy('shopping_list_item.name', 'ASC')->get();
    } else {
        //$items = ShoppingListItem::get();
        $items = DB::table('shopping_list_item')->leftJoin('category', 'shopping_list_item.category_id', '=', 'category.id')->select('shopping_list_item.id', 'shopping_list_item.item_size', 'shopping_list_item.name', 'shopping_list_item.item_count', 'shopping_list_item.price', 'shopping_list_item.category_id', 'shopping_list_item.created_at', 'shopping_list_item.updated_at')->orderBy('category.sort_order', 'ASC')->orderBy('shopping_list_item.name', 'ASC')->get();
    }
    return Response::json($items);
});
Route::get('api/shopping_list/upsert_item', function () {
    if (Input::has('id')) {
Ejemplo n.º 3
0
<?php

// Inialize session
session_start();
// Load config
include '../../../config.php';
$good = isApiKeyValid($_GET['key']);
$gameId = getGameIdFromApiKey($_GET['key']);
// Load user info
$userLogin = mysql_query("SELECT * FROM users WHERE (username = '******'username']) . "') and (application_password = '******'password']) . "')");
// Check game and user info
if ($good) {
    if (mysql_num_rows($userLogin) == 1) {
        // Get data
        $row = mysql_fetch_array($userLogin);
        $userId = $row['id'];
        // Print info
        $key = createRandomKey(10);
        while (keyExists($key)) {
            $key = createRandomKey(10);
        }
        echo "true\n";
        echo $key;
        echo "\n";
        // Revoke previous sessions
        mysql_query("DELETE FROM sessions WHERE userid = '" . $userId . "'");
        // Save session
        mysql_query("INSERT INTO sessions (userid, gameid, sessionkey) VALUES ('{$userId}','{$gameId}','{$key}')");
    } else {
        echo "false";
        echo "<br>";