Ejemplo n.º 1
0
<?php

require_once '../../php/db/connection.php';
require_once '../../php/submit_helper.php';
$json_return['status'] = "NA";
$json_return['message'] = "Could not add ability.";
try {
    // variables
    $table = 'ability';
    $unique_id = 'name';
    $original_unique_id = 'original_' . $unique_id;
    $exceptions = array($original_unique_id);
    $primary_key = array($unique_id, 'rpg');
    checkDataUnique($database, $_POST, $table, $unique_id, $json_return);
    checkDataValid($database, $_POST, 'abilityType', 'type', $json_return);
    checkDataValid($database, $_POST, 'target', 'target', $json_return);
    if (inputExists($_POST, 'radiusType')) {
        checkDataValid($database, $_POST, 'radiusType', 'radiusType', $json_return);
    }
    checkInputExists($_POST, 'description', $json_return);
    if ($json_return['status'] === "OK") {
        $_POST['rpg'] = 'dales';
        insertInto($table, $_POST, $exceptions, $primary_key, $database, $json_return);
    }
} catch (PDOException $e) {
    $json_return['status'] = "FAILED";
    $json_return['message'] = $e->getMessage();
}
// send json
header("Content-Type: application/json", true);
echo json_encode($json_return);
Ejemplo n.º 2
0
         } else {
             if ($_POST['primaryType'] === 'Melee Weapon' || $_POST['primaryType'] === 'Ranged Weapon') {
                 checkDiceValid($_POST, 'damage', $json_return);
                 if (inputExists($_POST, 'property')) {
                     checkDiceValid($_POST, 'secondaryDamage', $json_return);
                 }
                 checkDataValid($database, $_POST, 'damageType', 'damageType', $json_return);
                 if (inputExists($_POST, 'property')) {
                     checkDataValid($database, $_POST, 'property', 'property', $json_return);
                 }
                 if ($_POST['primaryType'] === 'Ranged Weapon') {
                     checkDataValid($database, $_POST, 'ammunition', 'ammunitionType', $json_return);
                 }
                 if (inputExists($_POST, 'secondaryDamageType')) {
                     // TODO: doesn't actually check secondaryDamageType, just checks damageType, modify checkDataValid to include ability to rename the field
                     checkDataValid($database, $_POST, 'damageType', 'damageType', $json_return);
                 }
                 if ($json_return['status'] === "OK") {
                     insertInto('consumable', $_POST, $exceptions, $primary_key, $database, $json_return);
                 }
             } else {
                 if ($_POST['primaryType'] === 'Gear' || $_POST['primaryType'] === 'Miscellaneous' || $_POST['primaryType'] === 'Tool') {
                     // do nothing more
                 } else {
                     $json_return['status'] = "FAILED";
                     $json_return['message'] = 'Not a recognized type.';
                 }
             }
         }
     }
 }