public static function getConfig($game) { $file = file_get_contents(dir::games('config.json', $game)); $file = preg_replace("/#\\s*([a-zA-Z ]*)/", "", $file); self::$params = json_decode($file, true); return self::$params; }
public function create($array) { $id = $this->id; $SSH = rp::get('SSH'); $host = $SSH['ip']; $user = $SSH['user']; $pass = $SSH['password']; unset($SSH); $sftp = new sftp($host, $user, $pass); $sftp->makedir((string) $id); $sftp->chdir((string) $id); $control = games::replaceControl($this->sql->get('gameID'), $array); $this->createControl($control); $dir = dir::backup("control/{$id}/"); $sftp->put('control.sh', $dir . 'control.sh', NET_SFTP_LOCAL_FILE); $sftp->chmod(0777, 'control.sh'); $sftp->makedir("functions"); $sftp->chdir("functions"); $functions = ['fn_install', 'fn_install_complete', 'fn_install_config']; foreach ($functions as $file) { $path = dir::functions('control/' . $file); $sftp->put($file, $path, NET_SFTP_LOCAL_FILE); $sftp->chmod(0777, $file); } return true; }
public static function removeEditorFromGame($pack) { $pack->auth->game_id = $pack->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } //note $pack->user_id is DIFFERENT than $pack->auth->user_id dbconnection::query("DELETE FROM user_games WHERE user_id = '{$pack->user_id}' AND game_id = '{$pack->game_id}'"); games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteGroup($pack) { $group = dbconnection::queryObject("SELECT * FROM groups WHERE group_id = '{$pack->group_id}'"); $pack->auth->game_id = $group->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM groups WHERE group_id = '{$pack->group_id}' LIMIT 1"); //cleanup dbconnection::query("UPDATE game_user_groups SET group_id = 0 WHERE game_id = '{$group->game_id}' AND group_id = '{$group->group_id}';"); games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteOverlay($pack) { $overlay = dbconnection::queryObject("SELECT * FROM overlays WHERE overlay_id = '{$pack->overlay_id}'"); $pack->auth->game_id = $overlay->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM overlays WHERE overlay_id = '{$pack->overlay_id}' LIMIT 1"); //cleanup $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$overlay->requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteWebHook($pack) { $webhook = dbconnection::queryObject("SELECT * FROM web_hooks WHERE web_hook_id = '{$pack->web_hook_id}'"); $pack->auth->game_id = $webhook->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM web_hooks WHERE web_hook_id = '{$pack->web_hook_id}' LIMIT 1"); //cleanup $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$webhook->requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_RECEIVED_INCOMING_WEB_HOOK' AND content_id = '{$pack->web_hook_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } games::bumpGameVersion($pack); return new return_package(0); }
return; } // -------------------------------------------------------------------------------------------- // APPEL de fichiers // define('ROOT_STYLE', 'admin'); $phpbb_root_path = '../../../'; require $phpbb_root_path . 'extension.inc'; require $phpbb_root_path . 'admin/pagestart.' . $phpEx; include $phpbb_root_path . 'areabb/fonctions/preload.' . $phpEx; load_lang('admin'); load_lang('admin_arcade'); load_function('class_games'); load_function('fonctions_chaine'); $games_root = $phpbb_root_path . 'areabb/games/'; $jeux = new games($games_root); // -------------------------------------------------------------------------------------------- // TRAITEMENT DES PARAMETRES // if (isset($HTTP_POST_VARS['action']) || isset($HTTP_GET_VARS['action'])) { if (isset($HTTP_POST_VARS['action'])) { $action = $HTTP_POST_VARS['action']; $check = $HTTP_POST_VARS['check']; } else { $action = $HTTP_GET_VARS['action']; } } $url = $HTTP_POST_VARS['url']; $nom = $HTTP_GET_VARS['nom']; $version = $HTTP_GET_VARS['version']; switch ($action) {
function getResultRound($round_id) { $this->SimpleDB->connect(); $SQL = "select games_id, members_name from t_games where id_round_tour='{$round_id}' "; $rst = $this->SimpleDB->query($SQL); $this->SimpleDB->disconnect(); $key = 0; $arrList = array(); while (is_object($rst) && $rst->next()) { $games = new games($rst->get(0)); $data = $games->getDetail(); $arrList[$key]['name'] = $rst->get(1); $out = 0; $in = 0; for ($a = 1; $a <= 18; $a++) { if ($a <= 9) { $out += $data[$a]['score']; } if ($a > 9) { $in += $data[$a]['score']; } $arrList[$key]['hole' . $a . '_score'] = $data[$a]['score']; } $arrList[$key]['holeout_score'] = $out; $arrList[$key]['holein_score'] = $in; $arrList[$key]['holetotal_score'] = $out + $in; $key++; } return $arrList; }
public static function deleteEvent($pack) { $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM events WHERE event_id = '{$pack->event_id}'")->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM events WHERE event_id = '{$pack->event_id}' LIMIT 1"); games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteObjectTagsForObject($pack) { $pack->auth->game_id = $pack->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM object_tags WHERE game_id = '{$pack->game_id}' AND object_type = '{$pack->object_type}' AND object_id = '{$pack->object_id}';"); games::bumpGameVersion($pack); }
public static function deleteMedia($pack) { $media_sql = dbconnection::queryObject("SELECT * FROM media WHERE media_id = '{$pack->media_id}'"); $pack->auth->game_id = $media_sql->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } if (!unlink(Config::v2_gamedata_folder . "/" . $media_sql->file_folder . "/" . $media_sql->file_name)) { return new return_package(1, "Could not delete file."); } dbconnection::query("DELETE FROM media WHERE media_id = '{$pack->media_id}' LIMIT 1"); //cleanup dbconnection::query("UPDATE games SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE games SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE tabs SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE items SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE items SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE dialogs SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE dialog_characters SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE plaques SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE plaques SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE web_pages SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE tags SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE overlays SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE note_media SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE quests SET active_media_id = 0 WHERE active_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE quests SET active_icon_media_id = 0 WHERE active_icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE quests SET complete_media_id = 0 WHERE complete_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE quests SET complete_icon_media_id = 0 WHERE complete_icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE triggers SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE factories SET trigger_icon_media_id = 0 WHERE trigger_icon_media_id = '{$pack->media_id}'"); dbconnection::query("UPDATE users SET media_id = 0 WHERE media_id = '{$pack->media_id}'"); games::bumpGameVersion($pack); return new return_package(0); }
public static function getFullGame($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $sql_game = dbconnection::queryObject("SELECT * FROM games WHERE game_id = '{$pack->game_id}' LIMIT 1"); if (!$sql_game) { return new return_package(2, NULL, "The game you've requested does not exist"); } $game = games::getGame($pack)->data; $game->authors = users::getUsersForGame($pack)->data; //pack already has auth and game_id //heres where we just hack the pack for use in other requests without overhead of creating new packs $pack->media_id = $game->media_id; $game->media = media::getMedia($pack)->data; $pack->media_id = $game->icon_media_id; $game->icon_media = media::getMedia($pack)->data; return new return_package(0, $game); }
</div> <div class="input row"> <label class="col-sm-5"><?php echo lang::get('game'); ?> </label> <div class="col-sm-7"> <select name="gameID"> <option value=""><?php echo lang::get('game_select'); ?> </option> <?php $games = games::getAll(); foreach ($games as $var) { echo '<option value="' . $var['id'] . '">' . $var['name'] . '</option>'; } ?> </select> </div> </div> </div> </div> <hr> <h2><?php
public static function noauth_deleteRequirementAtom($pack) { //and this "fixes" the security risk... if (strpos($_server['request_uri'], 'noauth') !== false) { return new return_package(6, null, "attempt to bypass authentication externally."); } dbconnection::query("DELETE FROM requirement_atoms WHERE requirement_atom_id = '{$pack->requirement_atom_id}'"); games::bumpGameVersion($pack); return new return_package(0); }
function saveScore(&$smarty) { $games_id = trim($_POST['games_id']); $games = new games($games_id); for ($i = 1; $i <= 18; $i++) { $field_par = "hole" . $i . "_par"; $field_score = "hole" . $i . "_score"; $hole = $i; $par = trim($_POST[$field_par]); $score = trim($_POST[$field_score]); $games->updateScore($hole, $par, $score); } $games->calculate(); $smarty->assign('msg', 'Score berhasil disimpan'); }
public static function deleteScene($pack) { $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM scenes WHERE scene_id = '{$pack->scene_id}'")->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM scenes WHERE scene_id = '{$pack->scene_id}' LIMIT 1"); //cleanup $s = dbconnection::queryObject("SELECT * FROM scenes WHERE game_id = '{$pack->game_id}' LIMIT 1"); $s_id = $s ? $s->scene_id : 0; dbconnection::query("UPDATE games SET intro_scene_id = '{$s_id}' WHERE intro_scene_id = '{$pack->scene_id}'"); $triggers = dbconnection::queryArray("SELECT * FROM triggers WHERE scene_id = '{$pack->scene_id}'"); for ($i = 0; $i < count($triggers); $i++) { $pack->trigger_id = $triggers[$i]->trigger_id; triggers::deleteTrigger($pack); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'SCENE' AND object_id = '{$pack->scene_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteTab($pack) { $tab = dbconnection::queryObject("SELECT * FROM tabs WHERE tab_id = '{$pack->tab_id}'"); $pack->auth->game_id = $tab->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM tabs WHERE tab_id = '{$pack->tab_id}' LIMIT 1"); //cleanup $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_TAB' AND link_id = '{$pack->tab_id}'"); for ($i = 0; $i < count($options); $i++) { $pack->dialog_option_id = $options[$i]->dialog_option_id; dialogs::deleteDialogOption($pack); } $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$tab->requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteInstance($pack) { $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM instances WHERE instance_id = '{$pack->instance_id}'")->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } games::bumpGameVersion($pack); return instances::noauth_deleteInstance($pack); }
public static function deleteNote($pack) { $note = dbconnection::queryObject("SELECT * FROM notes WHERE note_id = '{$pack->note_id}'"); $pack->auth->game_id = $note->game_id; $pack->auth->permission = "read_write"; if (($pack->auth->user_id != $note->user_id || !users::authenticateUser($pack->auth)) && !editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } // Cleanup related items. $noteComments = dbconnection::queryArray("SELECT * FROM note_comments WHERE note_id = '{$pack->note_id}'"); for ($i = 0; $i < count($note_comments); $i++) { $pack->note_comment_id = $noteComments[$i]->note_comment_id; note_comments::deleteNoteComment($pack); } // NOTE duplicated from tags.php/instances.php/triggers.php due to amf framework public methods being accessible via url. $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'NOTE' AND object_id = '{$pack->note_id}'"); for ($i = 0; $i < count($tags); $i++) { $pack->object_tag_id = $tags[$i]->object_tag_id; dbconnection::query("DELETE FROM object_tags WHERE object_tag_id = '{$pack->object_tag_id}' LIMIT 1"); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'NOTE' AND object_id = '{$pack->note_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; dbconnection::query("DELETE FROM instances WHERE instance_id = '{$pack->instance_id}' LIMIT 1"); $triggers = dbconnection::queryArray("SELECT * FROM triggers WHERE instance_id = '{$pack->instance_id}'"); for ($i = 0; $i < count($triggers); $i++) { $pack->trigger_id = $triggers[$i]->trigger_id; dbconnection::query("DELETE FROM triggers WHERE trigger_id = '{$pack->trigger_id}' LIMIT 1"); // TODO fix and clean the rest of the hierarchy (requirement package) } } // After everything is cleaned up. dbconnection::query("DELETE FROM notes WHERE note_id = '{$pack->note_id}' LIMIT 1"); games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteFactory($pack) { $factory = dbconnection::queryObject("SELECT * FROM factories WHERE factory_id = '{$pack->factory_id}'"); $pack->auth->game_id = $factory->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM factories WHERE factory_id = '{$pack->factory_id}' LIMIT 1"); //cleanup $instances = dbconnection::queryArray("SELECT * FROM instances WHERE factory_id = '{$pack->factory_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'FACTORY' AND object_id = '{$pack->factory_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$factory->requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$factory->trigger_requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteQuest($pack) { $quest = dbconnection::queryObject("SELECT * FROM quests WHERE quest_id = '{$pack->quest_id}'"); $pack->auth->game_id = $quest->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM quests WHERE quest_id = '{$pack->quest_id}' LIMIT 1"); //cleanup $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_COMPLETED_QUEST' AND content_id = '{$pack->quest_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } /* Comment out until we've decided on desired behavior... $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$quest->active_event_package_id}'"); if($eventpack) { $pack->event_package_id = $eventpack->event_package_id; events::deleteEventPackage($pack); } $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$quest->complete_event_package_id}'"); if($eventpack) { $pack->event_package_id = $eventpack->event_package_id; events::deleteEventPackage($pack); } */ $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$quest->active_requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$quest->complete_requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::deleteRequirementPackage($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteNoteComment($pack) { $note_comment = dbconnection::queryObject("SELECT * FROM note_comments WHERE note_comment_id = '{$pack->note_comment_id}'"); $note = dbconnection::queryObject("SELECT * FROM notes WHERE note_id = '{$note_comment->note_id}'"); $pack->auth->game_id = $note_comment->game_id; $pack->auth->permission = "read_write"; //tl;dr: must be game owner, note owner, or comment owner to delete comment if (!(users::authenticateUser($pack->auth) && ($pack->auth->user_id == $note_comment->user_id || $pack->auth->user_id == $note->user_id)) && !editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM note_comments WHERE note_comment_id = '{$pack->note_comment_id}' LIMIT 1"); games::bumpGameVersion($pack); return new return_package(0); }
public static function noauth_deleteTrigger($pack) { //and this "fixes" the security risk... if (strpos($_SERVER['REQUEST_URI'], 'noauth') !== false) { return new return_package(6, NULL, "Attempt to bypass authentication externally."); } dbconnection::query("DELETE FROM triggers WHERE trigger_id = '{$pack->trigger_id}' LIMIT 1"); //cleanup $instances = dbconnection::queryArray("SELECT * FROM instances WHERE instance_id = '{$trigger->instance_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::noauth_deleteInstance($pack); } $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$trigger->requirement_root_package_id}'"); if ($reqPack) { $pack->requirement_root_package_id = $reqPack->requirement_root_package_id; requirements::noauth_deleteRequirementPackage($pack); } games::bumpGameVersion($pack); return new return_package(0); }
function saveSecond() { $games_id = trim($_POST['games_id']); $games = new games($games_id); for ($i = 1; $i <= 18; $i++) { $field_par = "hole" . $i . "_par"; $field_gir = "hole" . $i . "_gir"; $field_fairway = "hole" . $i . "_fairway"; $field_rr2 = "hole" . $i . "_rr2"; $field_lr2 = "hole" . $i . "_lr2"; $field_on = "hole" . $i . "_on"; $field_bunker2 = "hole" . $i . "_bunker2"; $field_penalty2 = "hole" . $i . "_penalty2"; $field_putts = "hole" . $i . "_putts"; $hole = $i; $par = trim($_POST[$field_par]); $gir = trim($_POST[$field_gir]); $fairway = trim($_POST[$field_fairway]); $rr2 = trim($_POST[$field_rr2]); $lr2 = trim($_POST[$field_lr2]); $on = trim($_POST[$field_on]); $bunker2 = trim($_POST[$field_bunker2]); $penalty2 = trim($_POST[$field_penalty2]); $putts = trim($_POST[$field_putts]); $games->updateSecond($hole, $par, $gir, $fairway, $rr2, $lr2, $on, $bunker2, $penalty2, $putts); } $games->calculate(); }
* * Intégralement réecrit le 15 Juin 2006 * Par Saint-Pere www.yep-yop.com * ***************************************************************************/ define('IN_PHPBB', 1); define('ROOT_STYLE', 'admin'); $phpbb_root_path = '../../../'; require $phpbb_root_path . 'extension.inc'; require $phpbb_root_path . 'admin/pagestart.' . $phpEx; include $phpbb_root_path . 'areabb/fonctions/preload.' . $phpEx; load_lang('admin'); load_lang('admin_arcade'); load_function('class_games'); $games_root = $phpbb_root_path . 'areabb/games/'; $jeux = new games($games_root); // -------------------------------------------------------------------------------------------- // TRAITEMENT DES PARAMETRES // $arcade_catid = eregi_replace('[^0-9]', '', $HTTP_GET_VARS['arcade_catid']); if (isset($HTTP_POST_VARS['action']) || isset($HTTP_GET_VARS['action'])) { // nettoyage des données. ... if (isset($HTTP_POST_VARS['action'])) { $action = $HTTP_POST_VARS['action']; $game_name = $HTTP_POST_VARS['game_name']; $game_id = eregi_replace('[^0-9]', '', $HTTP_POST_VARS['game_id']); $game_swf = $HTTP_POST_VARS['game_swf']; $game_pic = $HTTP_POST_VARS['game_pic']; $game_pic_large = $HTTP_POST_VARS['game_pic_large']; $game_desc = $HTTP_POST_VARS['game_desc']; $game_scorevar = $HTTP_POST_VARS['game_scorevar'];
public static function logGroupLostItem($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::queryInsert("INSERT INTO user_log (user_id, group_id, game_id, event_type, content_id, qty, created) VALUES ('{$pack->auth->user_id}', '{$pack->group_id}', '{$pack->game_id}', 'GROUP_LOSE_ITEM', '{$pack->item_id}', '{$pack->qty}', CURRENT_TIMESTAMP);"); games::bumpGameVersion($pack); return new return_package(0); }
private static function importGameData($pack) { $tables = array(); //not actually used $columns = array(); //not actually used $coltablemap = array(); duplicate::getSchema($tables, $columns, $coltablemap); $maps = array(); $import = $pack->import; $game_id = $import->game_id; $table_data = $import->table_data; for ($i = 0; $i < count($table_data); $i++) { $table = $table_data[$i]->table; $cols = $table_data[$i]->columns; $old_data = $table_data[$i]->data; $maps[$table] = array(); $maps[$table][0] = 0; for ($j = 0; $j < count($old_data); $j++) { $old_datum = $old_data[$j]; $col_query = ""; $val_query = ""; $old_id = 0; for ($k = 0; $k < count($cols); $k++) { $col = $cols[$k]; $old_datum[$col->name] = addslashes($old_datum[$col->name]); //best thing I can think of for sanitation... if ($col->meta == 'id') { $old_id = $old_datum[$col->name]; //just store old id } else { if ($col->meta == 'timestamp') { if ($col_query != "") { $col_query .= ', '; $val_query .= ', '; } $col_query .= "{$col->name}"; $val_query .= "CURRENT_TIMESTAMP"; } else { if ($col_query != "") { $col_query .= ', '; $val_query .= ', '; } $col_query .= "{$col->name}"; if ($col->meta == 'special') { if ($col->name == 'siftr_url') { $val_query .= "NULL"; } else { $val_query .= "'0'"; } } else { if ($col->meta == 'map') { $val_query .= "'0'"; } else { $val_query .= "'{$old_datum[$col->name]}'"; } } } } } if ($pack->verbose) { echo "INSERT INTO {$table} ({$col_query}) VALUES ({$val_query});"; } $maps[$table][$old_id] = dbconnection::queryInsert("INSERT INTO {$table} ({$col_query}) VALUES ({$val_query});"); if ($pack->verbose) { echo " (id: {$maps[$table][$old_id]})\n"; } } } //NOTE- must do setup normally handled by games::createGame mkdir(Config::v2_gamedata_folder . "/{$maps['games'][$game_id]}", 0777); //second pass- fill in bogus mappings with known maps for ($i = 0; $i < count($table_data); $i++) { $table = $table_data[$i]->table; $cols = $table_data[$i]->columns; $old_data = $table_data[$i]->data; for ($j = 0; $j < count($old_data); $j++) { $old_datum = $old_data[$j]; $update_query = ""; $id_col = ""; $old_id = 0; for ($k = 0; $k < count($cols); $k++) { $col = $cols[$k]; $old_datum[$col->name] = addslashes($old_datum[$col->name]); //best thing I can think of for sanitation... if ($col->meta == 'id') { $id_col = $col->name; $old_id = $old_datum[$col->name]; //just store old id to find new id to update } else { if ($col->meta == '') { } else { if ($col->meta == 'map') { if ($update_query != '') { $update_query .= ', '; } $update_query .= "{$col->name} = '{$maps[$coltablemap[$col->name]][$old_datum[$col->name]]}'"; } else { if ($col->meta == 'special') { if ($update_query != '') { $update_query .= ', '; } if ($col->name == 'siftr_url') { $update_query .= "siftr_url = NULL"; } else { if ($col->name == 'file_folder') { //copy media to new folder $filenametitle = substr($old_datum['file_name'], 0, strrpos($old_datum['file_name'], '.')); $filenameext = substr($old_datum['file_name'], strrpos($old_datum['file_name'], '.')); $old_file_path = Config::v2_gamedata_folder . "/" . $old_datum['file_folder'] . "/" . $old_datum['file_name']; $new_file_path = Config::v2_gamedata_folder . "/" . $maps['games'][$game_id] . "/" . $old_datum['file_name']; $new_file_path_128 = Config::v2_gamedata_folder . "/" . $maps['games'][$game_id] . "/" . $filenametitle . "_128" . $filenameext; if (file_exists($old_file_path)) { copy($old_file_path, $new_file_path); if ($filenameext == ".jpg" || $filenameext == ".png" || $filenameext == ".gif") { try { if (exif_imagetype($new_file_path)) { $image = new Imagick($new_file_path); //aspect fill to 128x128 $w = $image->getImageWidth(); $h = $image->getImageHeight(); if ($w < $h) { $image->thumbnailImage(128, 128 / $w * $h, 1, 1); } else { $image->thumbnailImage(128 / $h * $w, 128, 1, 1); } //crop around center $w = $image->getImageWidth(); $h = $image->getImageHeight(); $image->cropImage(128, 128, ($w - 128) / 2, ($h - 128) / 2); $image->writeImage($new_file_path_128); } } catch (ImagickException $e) { //do nothing } } } $update_query .= "file_folder = '{$maps['games'][$game_id]}'"; } else { if ($col->name == 'content_id') { if ($table == 'events') { $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; } else { if ($table == 'requirement_atoms') { switch ($old_datum['requirement']) { case 'PLAYER_HAS_ITEM': case 'PLAYER_HAS_TAGGED_ITEM': case 'GAME_HAS_ITEM': case 'GAME_HAS_TAGGED_ITEM': case 'PLAYER_VIEWED_ITEM': $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_PLAQUE': $update_query .= "content_id = '{$maps['plaques'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_DIALOG': $update_query .= "content_id = '{$maps['dialogs'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_DIALOG_SCRIPT': $update_query .= "content_id = '{$maps['dialog_scripts'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_WEB_PAGE': $update_query .= "content_id = '{$maps['web_pages'][$old_datum['content_id']]}'"; break; case 'PLAYER_HAS_COMPLETED_QUEST': $update_query .= "content_id = '{$maps['quests'][$old_datum['content_id']]}'"; break; case 'PLAYER_HAS_RECEIVED_INCOMING_WEB_HOOK': $update_query .= "content_id = '{$maps['web_hooks'][$old_datum['content_id']]}'"; break; case 'ALWAYS_TRUE': case 'ALWAYS_FALSE': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_IMAGE': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_AUDIO': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_VIDEO': case 'PLAYER_HAS_NOTE': case 'PLAYER_HAS_NOTE_WITH_TAG': case 'PLAYER_HAS_NOTE_WITH_LIKES': case 'PLAYER_HAS_NOTE_WITH_COMMENTS': case 'PLAYER_HAS_GIVEN_NOTE_COMMENTS': default: $update_query .= "content_id = '{$old_datum['content_id']}'"; break; } } else { if ($table == 'tabs') { switch ($old_datum['type']) { case 'NOTE': $update_query .= "content_id = '{$maps['notes'][$old_datum['content_id']]}'"; break; case 'DIALOG': $update_query .= "content_id = '{$maps['dialogs'][$old_datum['content_id']]}'"; break; case 'ITEM': $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; break; case 'PLAQUE': $update_query .= "content_id = '{$maps['plaques'][$old_datum['content_id']]}'"; break; case 'WEB_PAGE': $update_query .= "content_id = '{$maps['web_pages'][$old_datum['content_id']]}'"; break; case 'MAP': case 'DECODER': case 'SCANNER': case 'QUESTS': case 'INVENTORY': case 'PLAYER': case 'NOTEBOOK': default: $update_query .= "content_id = '{$old_datum['content_id']}'"; break; } } } } } else { if ($col->name == 'object_id') { switch ($old_datum['object_type']) { case 'PLAQUE': $update_query .= "object_id = '{$maps['plaques'][$old_datum['object_id']]}'"; break; case 'ITEM': $update_query .= "object_id = '{$maps['items'][$old_datum['object_id']]}'"; break; case 'DIALOG': $update_query .= "object_id = '{$maps['dialogs'][$old_datum['object_id']]}'"; break; case 'WEB_PAGE': $update_query .= "object_id = '{$maps['web_pages'][$old_datum['object_id']]}'"; break; case 'NOTE': $update_query .= "object_id = '{$maps['notes'][$old_datum['object_id']]}'"; break; case 'FACTORY': $update_query .= "object_id = '{$maps['factories'][$old_datum['object_id']]}'"; break; case 'SCENE': $update_query .= "object_id = '{$maps['scenes'][$old_datum['object_id']]}'"; break; default: $update_query .= "object_id = '{$old_datum['object_id']}'"; break; } } else { if ($col->name == 'link_id') { switch ($old_datum['link_type']) { case 'EXIT_TO_PLAQUE': $update_query .= "link_id = '{$maps['plaques'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_ITEM': $update_query .= "link_id = '{$maps['items'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_WEB_PAGE': $update_query .= "link_id = '{$maps['web_pages'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_DIALOG': $update_query .= "link_id = '{$maps['dialogs'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_TAB': $update_query .= "link_id = '{$maps['tabs'][$old_datum['link_id']]}'"; break; case 'DIALOG_SCRIPT': $update_query .= "link_id = '{$maps['dialog_scripts'][$old_datum['link_id']]}'"; break; case 'EXIT': default: $update_query .= "link_id = '{$old_datum['link_id']}'"; break; } } } } } } } } } } } if ($update_query != "") { if ($pack->verbose) { echo "UPDATE {$table} SET {$update_query} WHERE {$id_col} = '{$maps[$table][$old_id]}';"; } dbconnection::query("UPDATE {$table} SET {$update_query} WHERE {$id_col} = '{$maps[$table][$old_id]}';"); if ($pack->verbose) { echo " (id: {$maps[$table][$old_id]})\n"; } } } } // Now make the game visible to the user, so they don't see a half-imported game dbconnection::query("INSERT INTO user_games (game_id, user_id, created) VALUES ('{$maps['games'][$game_id]}','{$pack->auth->user_id}',CURRENT_TIMESTAMP);"); $pack->game_id = $maps['games'][$game_id]; return games::getGame($pack); }
public static function deleteWebPage($pack) { $webpage = dbconnection::queryObject("SELECT * FROM web_pages WHERE web_page_id = '{$pack->web_page_id}'"); $pack->auth->game_id = $webpage->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM web_pages WHERE web_page_id = '{$pack->web_page_id}' LIMIT 1"); //cleanup $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_WEB_PAGE' AND link_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($options); $i++) { $pack->dialog_option_id = $options[$i]->dialog_option_id; dialogs::deleteDialogOption($pack); } $tabs = dbconnection::queryArray("SELECT * FROM tabs WHERE type = 'WEB_PAGE' AND content_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($tabs); $i++) { $pack->tab_id = $tabs[$i]->tab_id; tabs::deleteTab($pack); } $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'WEB_PAGE' AND object_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($tags); $i++) { $pack->object_tag_id = $tags[$i]->object_tag_id; tags::deleteObjectTag($pack); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'WEB_PAGE' AND object_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } $factories = dbconnection::queryArray("SELECT * FROM factories WHERE object_type = 'WEB_PAGE' AND object_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($factories); $i++) { $pack->factory_id = $factories[$i]->factory_id; factories::deleteFactory($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_VIEWED_WEB_PAGE' AND content_id = '{$pack->web_page_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deletePlaque($pack) { $plaque = dbconnection::queryObject("SELECT * FROM plaques WHERE plaque_id = '{$pack->plaque_id}'"); $pack->auth->game_id = $plaque->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM plaques WHERE plaque_id = '{$pack->plaque_id}' LIMIT 1"); //cleanup /* Comment out until we've decided on desired behavior... $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$plaque->event_package_id}'"); if($eventpack) { $pack->event_package_id = $eventpack->event_package_id; events::deleteEventPackage($pack); } */ $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_PLAQUE' AND link_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($options); $i++) { $pack->dialog_option_id = $options[$i]->dialog_option_id; dialogs::deleteDialogOption($pack); } $tabs = dbconnection::queryArray("SELECT * FROM tabs WHERE type = 'PLAQUE' AND content_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($tabs); $i++) { $pack->tab_id = $tabs[$i]->tab_id; tabs::deleteTab($pack); } $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($tags); $i++) { $pack->object_tag_id = $tags[$i]->object_tag_id; tags::deleteObjectTag($pack); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } $factories = dbconnection::queryArray("SELECT * FROM factories WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($factories); $i++) { $pack->factory_id = $factories[$i]->factory_id; factories::deleteFactory($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_VIEWED_PLAQUE' AND content_id = '{$pack->plaque_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } games::bumpGameVersion($pack); return new return_package(0); }