Beispiel #1
0
    // Attempt to apply a specific format.
    // Obtain the import script for the format.
    $res = $rpgDB->query(sprintf("SELECT imp_file, title FROM %s WHERE id = %d", $TABLE_SERIALIZE, (int) $format));
    if (!$res) {
        __printFatalErr("Failed to query database.", __LINE__, __FILE__);
    }
    if ($rpgDB->num_rows() != 1) {
        __printFatalErr("Failed to obtain import script location.", __FILE__, __LINE__);
    }
    $row = $rpgDB->fetch_row($res);
}
// Include the proper script.
include_once "{$INCLUDE_PATH}/serialization/" . $row['imp_file'];
// Call the import routine.
$char = new Character($id);
if (!$char->IsValid()) {
    __printFatalErr("Failed to obtain current character data.");
}
if (import_character($contents, $char)) {
    if ($char->Save($sid)) {
        print_upload_success($sid);
    }
}
// By now, we've  failed if we got here.
print_upload_failed($sid, $row['title']);
////////////////////////////////////////////////////////////////////////
// Helper functions
// Show that the autodetect has failed.
function print_autodetect_failed($sid, $id)
{
    global $title, $formats;
Beispiel #2
0
include_once "{$INCLUDE_PATH}/engine/character.class.php";
include_once "{$INCLUDE_PATH}/engine/campaign.class.php";
include_once "{$INCLUDE_PATH}/engine/templates.php";
include_once "{$INCLUDE_PATH}/engine/serialization.php";
$sid = RespawnSession(__LINE__, __FILE__);
// Validate permission for the requested character.
$id = (int) $_POST['id'];
if (!$id) {
    $id = (int) $_GET['id'];
}
if (!$sid->HasAccessTo($id)) {
    __printFatalErr("Access denied.");
}
// Get character details.
$character = new Character($id);
if (!$character->IsValid()) {
    __printFatalErr("Failed to retrieve character data.", __LINE__, __FILE__);
}
// Perform any simple actions that are requested.
if (isset($_POST['public'])) {
    $public_updated = apply_public($sid, $character, $_POST['public'] == 'true') ? 'Updated!' : 'Update Failed!';
}
if (isset($_POST['inactive'])) {
    $inactive_updated = apply_inactive($sid, $character, $_POST['inactive'] == 'true') ? 'Updated!' : 'Update Failed!';
}
if (isset($_POST['add_profile'])) {
    $profiles_updated = apply_add_profile($character, $_POST['add_profile']) ? 'Updated!' : 'Update Failed!';
}
if (isset($_POST['tid'])) {
    $template_updated = apply_template($sid, $character, (int) $_POST['tid']) ? 'Updated!' : 'Update Failed!';
}