| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* @file FlashGames
|
| 5 |
* Server script to talk to games
|
| 6 |
*/
|
| 7 |
|
| 8 |
|
| 9 |
//define security function
|
| 10 |
function arcade_check_secure($nid, $uid) {
|
| 11 |
//make sure we got back the checksum and key that we stored
|
| 12 |
$key = db_fetch_object(db_query("SELECT `token`, `key` FROM {arcade_keys} WHERE nid = %d AND uid = %d", $nid, $uid));
|
| 13 |
if (isset($key) && $_POST['arcade'] == $key->key &&
|
| 14 |
isset($_POST[$key->token])) {
|
| 15 |
return TRUE;
|
| 16 |
} else {
|
| 17 |
watchdog('arcade', 'Cheating attempt detected by '. l('user #'.$uid, 'user/'. $uid));
|
| 18 |
drupal_set_message('Cheating attempt detected. If you have recieved this message in error, please inform a site administrator.');
|
| 19 |
return FALSE;
|
| 20 |
}
|
| 21 |
}
|
| 22 |
|
| 23 |
// If we're accessing this file directly, bootstrap Drupal
|
| 24 |
if (!function_exists('drupal_get_path')) {
|
| 25 |
$prefix = "";
|
| 26 |
while(!file_exists($prefix ."includes/bootstrap.inc")) {
|
| 27 |
$prefix .= "../";
|
| 28 |
}
|
| 29 |
if ($prefix != "") chdir($prefix);
|
| 30 |
include_once("./includes/bootstrap.inc");
|
| 31 |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
| 32 |
}
|
| 33 |
chdir(drupal_get_path('module','arcade'));
|
| 34 |
|
| 35 |
//watchdog('arcade','triggered: '. var_export($_POST, TRUE));
|
| 36 |
|
| 37 |
//cover for older pnFlashGames that may not use the pn_mods variable
|
| 38 |
if (isset($_POST['module']) && $_POST['module']=='pnFlashGames') $_POST['game_protocol'] = 'pnFlashGames';
|
| 39 |
|
| 40 |
//Check if we've been sent any requests from a game.
|
| 41 |
if ($_POST['game_protocol']) {
|
| 42 |
include_once("protocols/{$_POST['game_protocol']}.inc");
|
| 43 |
} elseif ($_POST) {
|
| 44 |
include_once("protocols/default.inc");
|
| 45 |
}
|