예제 #1
0
function LT_call_silent()
{
    $proc = func_get_arg(0);
    $args = array_slice(func_get_args(), 1);
    $die = FALSE;
    return LT_call($proc, $args, $die);
}
예제 #2
0
<?php

// Admin views all users
include 'db_config.php';
include 'include/query.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Query the Database
if (is_array($rows = LT_call('read_users'))) {
    LT_output_array($rows, array('integer' => array('id', 'reset_time', 'last_action'), 'boolean' => array('logged_in', 'subscribed')));
}
예제 #3
0
<?php

// User paints, erases or toggles fog on a tile
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$map = intval($_REQUEST['map']);
$name = $LT_SQL->real_escape_string($_REQUEST['name']);
$type = $LT_SQL->real_escape_string($_REQUEST['type']);
$min_zoom = floatval($_REQUEST['min_zoom']);
$max_zoom = floatval($_REQUEST['max_zoom']);
$min_rotate = intval($_REQUEST['min_rotate']);
$max_rotate = intval($_REQUEST['max_rotate']);
$min_tilt = intval($_REQUEST['min_tilt']);
$max_tilt = intval($_REQUEST['max_tilt']);
$grid_thickness = intval($_REQUEST['grid_thickness']);
$grid_color = $LT_SQL->real_escape_string($_REQUEST['grid_color']);
$wall_thickness = intval($_REQUEST['wall_thickness']);
$wall_color = $LT_SQL->real_escape_string($_REQUEST['wall_color']);
$door_thickness = intval($_REQUEST['door_thickness']);
$door_color = $LT_SQL->real_escape_string($_REQUEST['door_color']);
// Query the Database
if (LT_can_edit_map($map)) {
    LT_call('update_map', $map, $name, $type, $min_zoom, $max_zoom, $min_rotate, $max_rotate, $min_tilt, $max_tilt, $grid_thickness, $grid_color, $wall_thickness, $wall_color, $door_thickness, $door_color);
}
예제 #4
0
<?php

// User modifies a piece's settings
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$piece = intval($_REQUEST['piece']);
$image = $LT_SQL->real_escape_string($_REQUEST['image']);
$name = $LT_SQL->real_escape_string($_REQUEST['name']);
$character = intval($_REQUEST['character']);
$locked = intval($_REQUEST['locked']);
$markers = $LT_SQL->real_escape_string($_REQUEST['markers']);
$color = $LT_SQL->real_escape_string($_REQUEST['color']);
// Query the Database
if (LT_can_edit_piece($piece)) {
    LT_call('update_piece', $piece, $image, $name, $character, $locked, $markers, $color);
}
예제 #5
0
<?php

// User shares this character with another user
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_REQUEST['user']);
$character = intval($_REQUEST['character']);
// Query the Database
if (LT_can_edit_character($character)) {
    LT_call('create_character_owner', $user, $character);
}
예제 #6
0
<?php

// User views the owners, members and guests of this campaign
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$campaign = intval($_REQUEST['campaign']);
if (LT_can_view_campaign($campaign)) {
    if (is_array($rows = LT_call('read_campaign_users', $campaign))) {
        LT_output_array($rows, array('integer' => array('id', 'avatar'), 'boolean' => array('viewing'), 'json' => array('cursor')));
    }
}
예제 #7
0
<?php

/* User disowns the campaign
or User revokes a user's ownership or membership
or User removes a user from the campaign's blacklist */
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_REQUEST['user']);
$campaign = intval($_REQUEST['campaign']);
// Query the Database
if (LT_can_edit_campaign($campaign)) {
    LT_call('delete_campaign_user', $user, $campaign);
}
예제 #8
0
<?php

// User moves a piece
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$piece = intval($_REQUEST['piece']);
if (LT_can_edit_piece($piece)) {
    LT_call('delete_piece', $piece);
}
예제 #9
0
<?php

// User updates his account information
include 'db_config.php';
include 'include/query.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_SESSION['user']);
$name = $LT_SQL->real_escape_string($_REQUEST['name']);
$color = $LT_SQL->real_escape_string($_REQUEST['color']);
$subscribed = intval($_REQUEST['subscribed']);
// Query the Database
LT_call('update_user', $user, $subscribed, $name, $color);
예제 #10
0
<?php

// User views the blacklist of this campaign
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$campaign = intval($_REQUEST['campaign']);
if (LT_can_view_campaign($campaign)) {
    if (is_array($rows = LT_call('read_campaign_user_blacklist', $campaign))) {
        LT_output_array($rows, array());
    }
}
예제 #11
0
<?php

// User views a list of characters he owns
include 'db_config.php';
include 'include/query.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
if (is_array($rows = LT_call('read_characters', intval($_SESSION['user'])))) {
    LT_output_array($rows, array('integer' => array('id'), 'json' => array('stats', 'notes', 'portrait', 'piece')));
}
예제 #12
0
<?php

// User checks in to a campaign
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_SESSION['user']);
$campaign = intval($_REQUEST['campaign']);
// Query the Database
if (LT_can_view_campaign($campaign)) {
    LT_call('update_campaign_user_arrive', $user, $campaign);
}
예제 #13
0
<?php

// Admin changes his password
include 'db_config.php';
include 'include/query.php';
include 'include/password.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$login = $LT_SQL->real_escape_string($_SESSION['admin']);
$password = $LT_SQL->real_escape_string($_REQUEST['password']);
$salt = LT_random_salt();
$hash = LT_hash_password($password, $salt);
// Query the Database
LT_call('update_admin_password', $login, $hash, $salt);
예제 #14
0
// User paints or erases tiles, fog or walls
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Interpret the Request
$map = intval($_REQUEST['map']);
$x = intval($_REQUEST['x']);
$y = intval($_REQUEST['y']);
$tile = intval($_REQUEST['tile']);
// Query the Database
if (LT_can_edit_map($map)) {
    $LT_SQL->autocommit(FALSE);
    /* avoid canceling simultaneous edits */
    if ($rows = LT_call('read_map_tiles', $map)) {
        $width = intval($rows[0]['columns']);
        $height = intval($rows[0]['rows']);
        if ($x >= 0 && $x < $width && $y >= 0 && $y < $height) {
            $tiles = substr_replace($rows[0]['tiles'], $base64[$tile / 64 % 64] . $base64[$tile % 64], ($x + $y * $width) * 2, 2);
            if (is_array(LT_call('update_map_tiles', $map, $tiles))) {
                $LT_SQL->commit();
            }
        }
    }
}
예제 #15
0
<?php

// User joins a campaign or looks for new messages
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/roll.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_SESSION['user']);
$campaign = intval($_REQUEST['campaign']);
$avatar = intval($_REQUEST['avatar']);
$text = $LT_SQL->real_escape_string(LT_expand_rolls($_REQUEST['text']));
// Query the Database
if (LT_can_view_campaign($campaign)) {
    LT_call('create_message', $campaign, $user, $avatar, $text);
}
예제 #16
0
<?php

// User changes the campaign's map
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$campaign = intval($_REQUEST['campaign']);
$map = intval($_REQUEST['map']);
// Query the Database
if (LT_can_edit_campaign($campaign)) {
    LT_call('update_campaign_map', $campaign, $map);
}
예제 #17
0
<?php

// User checks out of a campaign
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_SESSION['user']);
$campaign = intval($_REQUEST['campaign']);
// Query the Database
if (LT_can_view_campaign($campaign)) {
    LT_call('update_campaign_user_leave', $user, $campaign);
}
<?php

// User disowns a character or removes a user from a character's owners
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$user = intval($_REQUEST['user']);
$character = intval($_REQUEST['character']);
// Query the Database
if (LT_can_edit_character($character)) {
    LT_call('delete_character_owner', $user, $character);
}
예제 #19
0
<?php

// Admin resets a user's password
include 'db_config.php';
include 'include/query.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
LT_call('delete_user', intval($_REQUEST['user']));
예제 #20
0
<?php

// User views a list of this character's owners
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$character = intval($_REQUEST['character']);
if (LT_can_view_character($character)) {
    if (is_array($rows = LT_call('read_character_owners', $character))) {
        LT_output_array($rows, array('integer' => array('id'), 'boolean' => array('logged_in')));
    }
}
예제 #21
0
<?php

// User disowns a map or removes another user from the map's owners
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$map = intval($_REQUEST['map']);
if (LT_can_edit_map($map)) {
    if (is_array($rows = LT_call('read_map_owners', $map))) {
        LT_output_array($rows, array('integer' => array('id'), 'boolean' => array('logged_in')));
    }
}
예제 #22
0
<?php

// Admin resets a user's password
include 'db_config.php';
include 'include/query.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
if (is_array($rows = LT_call('read_campaigns'))) {
    LT_output_array($rows, array('integer' => array('id')));
}
예제 #23
0
<?php

// User creates a new piece
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$map = intval($_REQUEST['map']);
$image = $LT_SQL->real_escape_string($_REQUEST['image']);
$name = $LT_SQL->real_escape_string($_REQUEST['name']);
$x = floatval($_REQUEST['x']);
$y = floatval($_REQUEST['y']);
// Query the Database
if (LT_can_edit_map($map)) {
    if ($rows = LT_call('create_piece', $map, $image)) {
        $piece = intval($rows[0]['id']);
        // TODO: add $x, $y, $name parameters to create_piece procedure and drop these two lines
        LT_call('update_piece_position', $piece, $x, $y);
        LT_call('update_piece', $piece, $image, $name, NULL, 1, '[]', 'gray');
        include 'include/json_headers.php';
        echo json_encode(array('id' => $piece));
    }
}
예제 #24
0
<?php

// User clicks on an unsubscribe link from an e-mail announcement
include 'db_config.php';
include 'include/query.php';
$unsubscribe_code = $LT_SQL->real_escape_string($_REQUEST['unsubscribeCode']);
$email = $LT_SQL->real_escape_string($_REQUEST['email']);
if ($rows = LT_call('update_user_unsubscribe', $email, $unsubscribe_code)) {
    LT_output_object($rows[0], array('integer' => array('success')));
}
예제 #25
0
<?php

// Admin deletes his admin account or another admin account
include 'db_config.php';
include 'include/query.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$login = $LT_SQL->real_escape_string($_REQUEST['login']);
LT_call('delete_admin', $login);
예제 #26
0
<?php

// Admin views all messages in a campaign
include 'db_config.php';
include 'include/query.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['admin'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$campaign = intval($_REQUEST['campaign']);
$last_message = 0;
// show all messages
// Query the Database
if (is_array($rows = LT_call('read_messages', $campaign, $last_message))) {
    LT_output_array($rows, array('integer' => array('id', 'user_id', 'avatar', 'time')));
}
예제 #27
0
<?php

// User moves a piece
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$piece = intval($_REQUEST['piece']);
$x = floatval($_REQUEST['x']);
$y = floatval($_REQUEST['y']);
// Query the Database
if (LT_can_move_piece($piece)) {
    LT_call('update_piece_position', $piece, $x, $y);
} else {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not allowed to move this piece.');
}
예제 #28
0
// Interpret the Request
$map = intval($_REQUEST['map']);
$x = intval($_REQUEST['x']);
$y = intval($_REQUEST['y']);
$fog = $LT_SQL->real_escape_string($_REQUEST['fog']);
// Query the Database
if (LT_can_edit_map($map)) {
    $LT_SQL->autocommit(FALSE);
    /* avoid canceling simultaneous edits */
    if ($rows = LT_call('read_map_tiles', $map)) {
        $width = intval($rows[0]['columns']);
        $height = intval($rows[0]['rows']);
        if ($x >= 0 && $x < $width && $y >= 0 && $y < $height) {
            $old_fog = '';
            // unpack fog bits one sextuplet at a time
            foreach (str_split($rows[0]['fog']) as $a) {
                $old_fog .= a2b($a);
            }
            $old_fog[$x + $y * $width] = $fog;
            // change fog state
            $new_fog = '';
            // pack new fog bits one sextuplet at a time
            foreach (str_split($old_fog, 6) as $b) {
                $new_fog .= b2a($b);
            }
            if (is_array(LT_call('update_map_fog', $map, $new_fog))) {
                $LT_SQL->commit();
            }
        }
    }
}
예제 #29
0
<?php

// User stops being friends with the recipient or cancels a friend request
include 'db_config.php';
include 'include/query.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
// Interpret the Request
$sender = intval($_SESSION['user']);
$recipient = $LT_SQL->real_escape_string($_REQUEST['recipient']);
// Query the Database
LT_call('delete_friend', $sender, $recipient);
예제 #30
0
<?php

// User loads a map or refreshes an updated map
include 'db_config.php';
include 'include/query.php';
include 'include/ownership.php';
include 'include/output.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    exit('You are not logged in.');
}
$map = intval($_REQUEST['map']);
if (LT_can_view_map($map)) {
    if (is_array($rows = LT_call('read_pieces', $map))) {
        LT_output_array($rows, array('integer' => array('id', 'map', 'character'), 'json' => array('image', 'markers'), 'float' => array('x', 'y'), 'boolean' => array('locked')));
    }
}