| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- function action($db = null){
- global $AREA_TYPE;
- global $DIFFICULTY;
- global $SCENARIO;
- global $DUNGEON;
- global $ELEMENTAL_RIFT_DUNGEON;
- global $LABYRINTH_STAGES;
- global $UID;
- //$player = SQLite3::escapeString($_POST["uid"]);
- $player = filter_input(INPUT_POST, 'uid');
- $area_type = filter_input(INPUT_POST, 'area_type');
- $area = filter_input(INPUT_POST, 'area');
- $stage = filter_input(INPUT_POST, 'stage');
- error_log("STAGE1: " . $stage);
- $difficulty = filter_input(INPUT_POST, 'difficulty');
- $ids = filter_input(INPUT_POST, 'ids');
- $name = filter_input(INPUT_POST, 'name');
- $description = filter_input(INPUT_POST, 'description');
- $id = preg_split("/[\s,]+/", $ids);
- $id_count = sizeof($id);
- if ($name == null || strlen($name) == 0){
- return -1;
- }
- switch ($area_type){
- case $AREA_TYPE["SCENARIO"]:
- if ($stage < 0 || $stage > 7){
- return -31;
- }
- if (!($difficulty == 0 || in_array($difficulty, $DIFFICULTY) || $difficulty == $DIFFICULTY["EASY"])){
- return -32;
- }
- if ($id_count < 1 || $id_count > 4){
- return -33;
- }
- if (!in_array($area, $SCENARIO)){
- return -34;
- }
- break;
- case $AREA_TYPE["CAIROS_DUNGEON"]:
- if ($stage < 0 || $stage > 10){
- return -35;
- }
- $difficulty = null;
- if ($id_count < 1 || $id_count > 5){
- return -36;
- }
- if (!in_array($area, $DUNGEON)){
- return -37;
- }
- break;
- case $AREA_TYPE["RIFT_DUNGEON"]:
- $stage = null;
- $difficulty = null;
- if ($id_count < 1 || $id_count > 6){
- return -39;
- }
- if (!in_array($area, $ELEMENTAL_RIFT_DUNGEON)){
- return -40;
- }
- break;
- case $AREA_TYPE["RIFT_RAID"]:
- if ($stage < 0 || $stage > 5){
- return -41;
- }
- $difficulty = null;
- if ($id_count < 1 || $id_count > 6){
- return -42;
- }
- $area = null;
- break;
- case $AREA_TYPE["ARENA"]:
- $area = null;
- $stage = null;
- $difficulty = null;
- break;
- case $AREA_TYPE["GUILD_WAR"]:
- $area = null;
- $stage = null;
- $difficulty = null;
- break;
- case $AREA_TYPE["GUILD_SIEGE"]:
- $area = null;
- $stage = null;
- $difficulty = null;
- break;
- case $AREA_TYPE["TARTARUS_LABYRINTH"]:
- $stage = null;
- if ($difficulty < 0 || !in_array($difficulty, $DIFFICULTY)){
- return -43;
- }
- if ($id_count < 1 || $id_count > 5){
- return -44;
- }
- if (!in_array($area, $LABYRINTH_STAGES)){
- return -45;
- }
- break;
- case $AREA_TYPE["TRIAL_OF_ASCENSION"]:
- if ($difficulty != 0 && $difficulty != $DIFFICULTY["NORMAL"] && $difficulty != $DIFFICULTY["HARD"]){
- return -46;
- }
- $stage = null;
- if ($id_count < 1 || $id_count > 5){
- return -47;
- }
- $area = null;
- break;
- case $AREA_TYPE["DIMENSIONAL_HOLE"]:
- if ($stage < 0 || $stage > 5){
- return -48;
- }
- $difficulty = null;
- if ($id_count < 1 || $id_count > 4){
- return -49;
- }
- if (!in_array($area, $DUNGEON)){
- return -50;
- }
- break;
- case $AREA_TYPE["DIMENSIONAL_RIFT"]:
- if ($difficulty != 0 && $difficulty != $DIFFICULTY["NORMAL"] && $difficulty != $DIFFICULTY["HARD"]){
- return -51;
- }
- $stage = null;
- if ($id_count < 1 || $id_count > 5){
- return -52;
- }
- $area = null;
- break;
- default:
- return -3;
- }
- $unique_id = array_unique($id);
- if ($id_count != sizeof($unique_id)){
- return -4;
- }
-
-
- error_log("STAGE2: " . $stage);
-
- $s = "SELECT CASE WHEN MAX(id) IS NULL THEN 1 ELSE MAX(id) + 1 END AS id FROM team;";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $team_id = $r["id"];
-
- $statement = $db->prepare('INSERT INTO team (uid, id, name, description, area_type, area, stage, difficulty) VALUES (:uid, :id, :name, :description, :area_type, :area, :stage, :difficulty);');
- $statement->bindValue(':uid', $player);
- $statement->bindValue(':id', $team_id);
- $statement->bindValue(':name', $name);
- $statement->bindValue(':description', $description);
- $statement->bindValue(':area_type', $area_type);
- $statement->bindValue(':area', $area);
- $statement->bindValue(':stage', $stage);
- $statement->bindValue(':difficulty', $difficulty);
- $res = $statement->execute();
-
- if (!$res){
- return -5;
- }
-
- foreach ($id as $i){
- $s = "INSERT INTO team_unit VALUES ($team_id, $i);";
- $db->query($s);
- }
-
- return 0;
- }
- ?>
|