커맨드 유효성을 2개에서 3개구성으로 변경
This commit is contained in:
+86
-85
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -6,7 +7,7 @@ include "func.php";
|
||||
|
||||
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
if($session->userGrade < 4){
|
||||
if ($session->userGrade < 4) {
|
||||
header('location:_119.php');
|
||||
die();
|
||||
}
|
||||
@@ -16,7 +17,7 @@ $v->rule('integer', [
|
||||
'minute',
|
||||
'minutes2'
|
||||
]);
|
||||
if(!$v->validate()){
|
||||
if (!$v->validate()) {
|
||||
Error($v->errorStr());
|
||||
}
|
||||
|
||||
@@ -26,92 +27,92 @@ $minute2 = Util::getReq('minute2', 'int');
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
switch($btn) {
|
||||
case "분당김":
|
||||
$locked = false;
|
||||
for($i = 0; $i < 10; $i++){
|
||||
if(tryLock()){
|
||||
$locked = true;
|
||||
break;
|
||||
switch ($btn) {
|
||||
case "분당김":
|
||||
$locked = false;
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
if (tryLock()) {
|
||||
$locked = true;
|
||||
break;
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M"));
|
||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M"));
|
||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->sub(new \DateInterval("PT{$minute}M"));
|
||||
|
||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M"));
|
||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M"));
|
||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->sub(new \DateInterval("PT{$minute}M"));
|
||||
|
||||
$db->update('general', [
|
||||
'turntime'=>$db->sqleval('DATE_SUB(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
$db->update('auction', [
|
||||
'expire'=>$db->sqleval('DATE_SUB(expire, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
if($locked){
|
||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
|
||||
$db->update('general', [
|
||||
'turntime' => $db->sqleval('DATE_SUB(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
$db->update('auction', [
|
||||
'expire' => $db->sqleval('DATE_SUB(expire, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
if ($locked) {
|
||||
unlock();
|
||||
}
|
||||
break;
|
||||
case "분지연":
|
||||
$locked = false;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
if (tryLock()) {
|
||||
$locked = true;
|
||||
break;
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M"));
|
||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M"));
|
||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->add(new \DateInterval("PT{$minute}M"));
|
||||
|
||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
|
||||
$db->update('general', [
|
||||
'turntime' => $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
$db->update('auction', [
|
||||
'expire' => $db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
if ($locked) {
|
||||
unlock();
|
||||
}
|
||||
break;
|
||||
case "토너분당김":
|
||||
$tnmt_time = new \DateTime($gameStor->tnmt_time);
|
||||
$tnmt_time->sub(new \DateInterval("PT{$minute2}M"));
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
break;
|
||||
case "토너분지연":
|
||||
$tnmt_time = new \DateTimeImmutable($gameStor->tnmt_time);
|
||||
$tnmt_time->add(new \DateInterval("PT{$minute2}M"));
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
break;
|
||||
case "금지급":
|
||||
processGoldIncome();
|
||||
break;
|
||||
case "쌀지급":
|
||||
processRiceIncome();
|
||||
break;
|
||||
case "락걸기":
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
if (tryLock()) {
|
||||
$locked = true;
|
||||
break;
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
break;
|
||||
case "락풀기":
|
||||
unlock();
|
||||
}
|
||||
break;
|
||||
case "분지연":
|
||||
$locked = false;
|
||||
for($i = 0; $i < 5; $i++){
|
||||
if(tryLock()){
|
||||
$locked = true;
|
||||
break;
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M"));
|
||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M"));
|
||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->add(new \DateInterval("PT{$minute}M"));
|
||||
|
||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
|
||||
$db->update('general', [
|
||||
'turntime'=>$db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
$db->update('auction', [
|
||||
'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
if($locked){
|
||||
unlock();
|
||||
}
|
||||
break;
|
||||
case "토너분당김":
|
||||
$tnmt_time = new \DateTime($gameStor->tnmt_time);
|
||||
$tnmt_time->sub(new \DateInterval("PT{$minute2}M"));
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
break;
|
||||
case "토너분지연":
|
||||
$tnmt_time = new \DateTimeImmutable($gameStor->tnmt_time);
|
||||
$tnmt_time->add(new \DateInterval("PT{$minute2}M"));
|
||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
||||
break;
|
||||
case "금지급":
|
||||
processGoldIncome();
|
||||
break;
|
||||
case "쌀지급":
|
||||
processRiceIncome();
|
||||
break;
|
||||
case "락걸기":
|
||||
for($i = 0; $i < 10; $i++){
|
||||
if(tryLock()){
|
||||
$locked = true;
|
||||
break;
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
break;
|
||||
case "락풀기":
|
||||
unlock();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location:_119.php', true, 303);
|
||||
header('Location:_119.php', true, 303);
|
||||
|
||||
Reference in New Issue
Block a user