From 269a40ca9da40d748168577376d20908d1f5ded7 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 9 Apr 2018 02:56:45 +0900 Subject: [PATCH] =?UTF-8?q?stylesheet=20=EC=9E=98=EB=AA=BB=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0.=20jquery.redirect=20=EC=B6=94=EA=B0=80.=20global=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20extract=20=EC=9A=B0=ED=9A=8C=EA=B0=80=20?= =?UTF-8?q?=EC=A0=9C=EB=8C=80=EB=A1=9C=20=EB=8F=99=EC=9E=91=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e_lib/jquery.redirect.js | 152 ++++++++++++++++++++++++++++++ hwe/_119_b.php | 1 + hwe/a_status.php | 2 +- hwe/b_diplomacy.php | 2 +- hwe/b_myPage.php | 2 +- hwe/func_command.php | 43 ++++++--- hwe/index.php | 5 +- hwe/join.php | 2 +- hwe/js/main.js | 5 + hwe/lib.php | 14 ++- hwe/preprocessing.php | 1 + hwe/processing.php | 7 +- hwe/sammo/Event/Action/RegNPC.php | 4 +- hwe/sammo/Event/EventHandler.php | 2 +- 14 files changed, 216 insertions(+), 26 deletions(-) create mode 100644 e_lib/jquery.redirect.js diff --git a/e_lib/jquery.redirect.js b/e_lib/jquery.redirect.js new file mode 100644 index 00000000..895e5cff --- /dev/null +++ b/e_lib/jquery.redirect.js @@ -0,0 +1,152 @@ +/* +jQuery Redirect v1.1.1 + +Copyright (c) 2013-2017 Miguel Galante +Copyright (c) 2011-2013 Nemanja Avramovic, www.avramovic.info + +Licensed under CC BY-SA 4.0 License: http://creativecommons.org/licenses/by-sa/4.0/ + +This means everyone is allowed to: + +Share - copy and redistribute the material in any medium or format +Adapt - remix, transform, and build upon the material for any purpose, even commercially. +Under following conditions: + +Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +*/ +(function ($) { + 'use strict'; + + /** + * jQuery Redirect + * @param {string} url - Url of the redirection + * @param {Object} values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url. + * @param {string} method - (optional) The HTTP verb can be GET or POST (defaults to POST) + * @param {string} target - (optional) The target of the form. "_blank" will open the url in a new window. + * @param {boolean} traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others. + * @param {boolean} redirectTop - (optional) If its called from a iframe, force to navigate the top window. + */ + $.redirect = function (url, values, method, target, traditional, redirectTop) { + redirectTop = redirectTop || false; + var generatedForm = $.redirect.getForm(url, values, method, target, traditional); + $('body', redirectTop ? window.top.document : undefined).append(generatedForm.form); + generatedForm.submit(); + }; + + + $.redirect.getForm = function (url, values, method, target, traditional) { + method = (method && ["GET", "POST", "PUT", "DELETE"].indexOf(method.toUpperCase()) !== -1) ? method.toUpperCase() : 'POST'; + + url = url.split("#"); + var hash = url[1] ? ("#" + url[1]) : ""; + url = url[0]; + + if (!values) { + var obj = $.parseUrl(url); + url = obj.url; + values = obj.params; + } + + values = removeNulls(values); + + var form = $('
') + .attr("method", method) + .attr("action", url + hash); + + + if (target) { + form.attr("target", target); + } + + var submit = form[0].submit; + iterateValues(values, [], form, null, traditional); + + return { form: form, submit: function () { submit.call(form[0]); } }; + } + //Utility Functions + /** + * Url and QueryString Parser. + * @param {string} url - a Url to parse. + * @returns {object} an object with the parsed url with the following structure {url: URL, params:{ KEY: VALUE }} + */ + $.parseUrl = function (url) { + + if (url.indexOf('?') === -1) { + return { + url: url, + params: {} + }; + } + var parts = url.split('?'), + query_string = parts[1], + elems = query_string.split('&'); + url = parts[0]; + + var i, pair, obj = {}; + for (i = 0; i < elems.length; i += 1) { + pair = elems[i].split('='); + obj[pair[0]] = pair[1]; + } + + return { + url: url, + params: obj + }; + }; + + //Private Functions + var getInput = function (name, value, parent, array, traditional) { + var parentString; + if (parent.length > 0) { + parentString = parent[0]; + var i; + for (i = 1; i < parent.length; i += 1) { + parentString += "[" + parent[i] + "]"; + } + + if (array) { + if (traditional) + name = parentString; + else + name = parentString + "[" + name + "]"; + } else { + name = parentString + "[" + name + "]"; + } + } + + return $("").attr("type", "hidden") + .attr("name", name) + .attr("value", value); + }; + + var iterateValues = function (values, parent, form, isArray, traditional) { + var i, iterateParent = []; + Object.keys(values).forEach(function (i) { + if (typeof values[i] === "object") { + iterateParent = parent.slice(); + iterateParent.push(i); + iterateValues(values[i], iterateParent, form, Array.isArray(values[i]), traditional); + } else { + form.append(getInput(i, values[i], parent, isArray, traditional)); + } + }); + }; + + var removeNulls = function (values) { + var propNames = Object.getOwnPropertyNames(values); + for (var i = 0; i < propNames.length; i++) { + var propName = propNames[i]; + if (values[propName] === null || values[propName] === undefined) { + delete values[propName]; + } else if (typeof values[propName] === 'object') { + values[propName] = removeNulls(values[propName]); + } else if (values[propName].length < 1) { + delete values[propName]; + } + } + return values; + }; + +}(window.jQuery || window.Zepto || window.jqlite)); diff --git a/hwe/_119_b.php b/hwe/_119_b.php index 65abc72e..84495ea7 100644 --- a/hwe/_119_b.php +++ b/hwe/_119_b.php @@ -20,6 +20,7 @@ if(!$v->validate()){ Error($v->errorStr()); } +$btn = Util::getReq('btn'); $minute = Util::getReq('minute', 'int'); $minute2 = Util::getReq('minute2', 'int'); diff --git a/hwe/a_status.php b/hwe/a_status.php index cc69ee98..05bc89f2 100644 --- a/hwe/a_status.php +++ b/hwe/a_status.php @@ -45,7 +45,7 @@ $(function(){ }); - + diff --git a/hwe/b_diplomacy.php b/hwe/b_diplomacy.php index 1ba79f3e..e5c17528 100644 --- a/hwe/b_diplomacy.php +++ b/hwe/b_diplomacy.php @@ -72,7 +72,7 @@ $(function(){ }); - + diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index 4519bc02..85d6774a 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -47,7 +47,7 @@ $me = MYDB_fetch_array($result); 내정보 - + "; - echo 'commandlist.php';//TODO:debug all and replace - + + header('location:commandlist.php'); } function command_Chief($turn, $command) { @@ -724,18 +723,36 @@ function command_Chief($turn, $command) { } function command_Other($turn, $commandtype) { - $db = DB::db(); - $connect=$db->get(); - echo ""; - $count = count($turn); - for($i=0; $i < $count; $i++) { - echo ""; + $target = "processing.php?commandtype={$commandtype}"; + foreach($turn as $turnItem){ + $target.="&turn[]={$turnItem}"; } - echo ""; - echo "
"; - echo "a"; // 없으면 파폭에서 아래 스크립트 실행 안됨 - echo ""; + $target.="&".mt_rand(); + ?> + + + + + + + + + + + + + + + +> +  + + @@ -81,7 +82,7 @@ $(function(){ }); - + @@ -223,7 +224,7 @@ if ($session->userGrade >= 5) { - +
diff --git a/hwe/join.php b/hwe/join.php index 997b68a7..f31b9aba 100644 --- a/hwe/join.php +++ b/hwe/join.php @@ -31,7 +31,7 @@ $connect=$db->get(); 장수생성 - + diff --git a/hwe/js/main.js b/hwe/js/main.js index 74ddba88..321cdff2 100644 --- a/hwe/js/main.js +++ b/hwe/js/main.js @@ -39,6 +39,11 @@ function refreshing(obj, arg1, arg2) { } } +function moveProcessing(commandtype, turn){ + console.log(commandtype, turn); + $.redirect("processing.php",{ commandtype: commandtype, turn: turn}, 'post'); +} + function go(type) { if(type == 1) location.replace('b_nationboard.php'); else if(type == 2) location.replace('b_troop.php'); diff --git a/hwe/lib.php b/hwe/lib.php index 5ea39a05..1e8a3178 100644 --- a/hwe/lib.php +++ b/hwe/lib.php @@ -102,13 +102,23 @@ function extractSuperGlobals() if (isset($_POST) && count($_POST) > 0) { LogText($_SERVER['REQUEST_URI'], $_POST); - extract($_POST, EXTR_SKIP); + foreach($_POST as $key=>$val){ + if(isset($GLOBALS[$key])){ + continue; + } + $GLOBALS[$key]=$val; + } } if (isset($_GET) && count($_GET) > 0) { LogText($_SERVER['REQUEST_URI'], $_GET); - extract($_POST, EXTR_SKIP); + foreach($_GET as $key=>$val){ + if(isset($GLOBALS[$key])){ + continue; + } + $GLOBALS[$key]=$val; + } } } diff --git a/hwe/preprocessing.php b/hwe/preprocessing.php index 17aa349a..f714f5c8 100644 --- a/hwe/preprocessing.php +++ b/hwe/preprocessing.php @@ -11,6 +11,7 @@ $db = DB::db(); $connect=$db->get(); $turn = Util::getReq('turn', 'array_int'); +$sel = Util::getReq('sel', 'int'); $commandtype = Util::getReq('commandtype', 'int'); increaseRefresh("턴입력", 1); diff --git a/hwe/processing.php b/hwe/processing.php index 0f05e468..3afa91d6 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -4,6 +4,10 @@ namespace sammo; include "lib.php"; include "func.php"; //로그인 검사 + +$commandtype = Util::getReq('commandtype', 'int', 0); +$turn = Util::getReq('turn', 'array_int', [0]); + $session = Session::requireGameLogin()->setReadOnly(); $db = DB::db(); @@ -120,7 +124,6 @@ function starter($name, $type=0) { - - + diff --git a/hwe/sammo/Event/Action/RegNPC.php b/hwe/sammo/Event/Action/RegNPC.php index 5a2cbecf..1d492407 100644 --- a/hwe/sammo/Event/Action/RegNPC.php +++ b/hwe/sammo/Event/Action/RegNPC.php @@ -19,7 +19,7 @@ class RegNPC extends \sammo\Event\Action{ int $death = 300, $ego = null, string $char = '', - string $text = '' + $text = '' ){ $this->npc = new \sammo\Scenario\NPC( $affinity, @@ -34,7 +34,7 @@ class RegNPC extends \sammo\Event\Action{ $death, $ego, $char, - $text + $text?:'' ); } diff --git a/hwe/sammo/Event/EventHandler.php b/hwe/sammo/Event/EventHandler.php index cda46ff1..b4fe78bf 100644 --- a/hwe/sammo/Event/EventHandler.php +++ b/hwe/sammo/Event/EventHandler.php @@ -23,7 +23,7 @@ class EventHandler{ $resultAction = []; foreach($this->actions as $action){ - $resultAction[] = $action->run(); + $resultAction[] = $action->run($env); } $result['action'] = $resultAction;