예제 #1
0
파일: admin.php 프로젝트: hiro0218/hakoniwa
 function passCheck()
 {
     global $init;
     if (file_exists("{$init->passwordFile}")) {
         $fp = fopen("{$init->passwordFile}", "r");
         $masterPassword = chop(fgets($fp, READ_LINE));
         fclose($fp);
     }
     if (!isset($this->dataSet['PASSWORD'])) {
         HakoError::wrongPassword();
         return 0;
     }
     if (strcmp(crypt($this->dataSet['PASSWORD'], 'ma'), $masterPassword) == 0) {
         return 1;
     } else {
         HakoError::wrongPassword();
         return 0;
     }
 }
예제 #2
0
 function execute()
 {
     global $init;
     $ally = new Ally();
     $cgi = new Cgi();
     $this->parseInputData();
     $cgi->getCookies();
     if (!$ally->readIslands($cgi)) {
         HTML::header();
         HakoError::noDataFile();
         HTML::footer();
         exit;
     }
     $cgi->setCookies();
     $html = new HtmlAlly();
     $com = new MakeAlly();
     $html->header();
     switch ($this->mode) {
         case "JoinA":
             // 同盟の結成・変更・解散・加盟・脱退
             $html->newAllyTop($ally, $this->dataSet);
             break;
         case "newally":
             // 同盟の結成・変更
             $com->makeAllyMain($ally, $this->dataSet);
             break;
         case "delally":
             // 同盟の解散
             $com->deleteAllyMain($ally, $this->dataSet);
             break;
         case "inoutally":
             // 同盟の加盟・脱退
             $com->joinAllyMain($ally, $this->dataSet);
             break;
         case "Allypact":
             // コメントの変更
             $html->tempAllyPactPage($ally, $this->dataSet);
             break;
         case "AllypactUp":
             // コメントの更新
             $com->allyPactMain($ally, $this->dataSet);
             break;
         case "AmiOfAlly":
             // 同盟の情報
             $html->amityOfAlly($ally, $this->dataSet);
             break;
         default:
             // 箱庭データとのデータ統合処理(ターン処理に組み込んでいないため)
             if ($com->allyReComp($ally)) {
                 break;
             }
             $html->allyTop($ally, $this->dataSet);
             break;
     }
     $html->footer();
 }
예제 #3
0
파일: main.php 프로젝트: hiro0218/hakoniwa
 function execute()
 {
     $hako = new Hako();
     $cgi = new Cgi();
     $cgi->parseInputData();
     $cgi->getCookies();
     $fp = "";
     if (!$hako->readIslands($cgi)) {
         HTML::header();
         HakoError::noDataFile();
         HTML::footer();
         Util::unlock($lock);
         exit;
     }
     $lock = Util::lock($fp);
     if (FALSE == $lock) {
         exit;
     }
     $cgi->setCookies();
     $_developmode = isset($cgi->dataSet['DEVELOPEMODE']) ? $cgi->dataSet['DEVELOPEMODE'] : "";
     if (mb_strtolower($_developmode) == "javascript") {
         $html = new HtmlMapJS();
         $com = new MakeJS();
     } else {
         $html = new HtmlMap();
         $com = new Make();
     }
     switch ($cgi->mode) {
         case "turn":
             $turn = new Turn();
             $html = new HtmlTop();
             $html->header();
             $turn->turnMain($hako, $cgi->dataSet);
             $html->main($hako, $cgi->dataSet);
             // ターン処理後、TOPページopen
             $html->footer();
             break;
         case "owner":
             $html->header();
             $html->owner($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "command":
             $html->header();
             $com->commandMain($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "new":
             $html->header();
             $com->newIsland($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "comment":
             $html->header();
             $com->commentMain($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "print":
             $html->header();
             $html->visitor($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "targetView":
             $html->head();
             $html->printTarget($hako, $cgi->dataSet);
             //$html->footer();
             break;
         case "change":
             $html->header();
             $com->changeMain($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "ChangeOwnerName":
             $html->header();
             $com->changeOwnerName($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "conf":
             $html = new HtmlTop();
             $html->header();
             $html->register($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "log":
             $html = new HtmlTop();
             $html->header();
             $html->log();
             $html->footer();
             break;
         default:
             $html = new HtmlTop();
             $html->header();
             $html->main($hako, $cgi->dataSet);
             $html->footer();
     }
     Util::unlock($lock);
     exit;
 }
예제 #4
0
    function printTarget($hako, $data)
    {
        global $init;
        // idから島番号を取得
        $id = $data['ISLANDID'];
        $number = $hako->idToNumber[$id];
        // なぜかその島がない場合
        if ($number < 0 || $number > $hako->islandNumber) {
            HakoError::problem();
            return;
        }
        $island = $hako->islands[$number];
        echo <<<END
<script>
function ps(x, y) {
\twindow.opener.document.InputPlan.POINTX.options[x].selected = true;
\twindow.opener.document.InputPlan.POINTY.options[y].selected = true;
\treturn true;
}
</script>

<div class="text-center">
{$init->tagBig_}{$init->tagName_}{$island['name']}{$init->nameSuffix}{$init->_tagName}{$init->_tagBig}<br>
</div>
END;
        //島の地図
        $this->islandMap($hako, $island, 2);
    }
예제 #5
0
 function execute()
 {
     $hako = new HakoEdit();
     $cgi = new CgiImitation();
     $cgi->parseInputData();
     $cgi->getCookies();
     if (!$hako->readIslands($cgi)) {
         HTML::header();
         HakoError::noDataFile();
         HTML::footer();
         exit;
     }
     $cgi->setCookies();
     $edit = new Edit();
     switch ($cgi->mode) {
         case "enter":
             $html = new HtmlTop();
             $html->header();
             $edit->main($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "list":
             $html = new HtmlTop();
             $html->header();
             $edit->main($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "map":
             $html = new HtmlTop();
             $html->header();
             $edit->editMap($hako, $cgi->dataSet);
             $html->footer();
             break;
         case "regist":
             $html = new HtmlTop();
             $html->header();
             $edit->register($hako, $cgi->dataSet);
             $html->footer();
             break;
         default:
             $html = new HtmlTop();
             $html->header();
             $edit->enter();
             $html->footer();
     }
     exit;
 }
예제 #6
0
파일: util.php 프로젝트: hiro0218/hakoniwa
 static function lock()
 {
     global $init;
     $fp = fopen("{$init->dirName}/lock.dat", "w");
     for ($count = 0; $count < LOCK_RETRY_COUNT; $count++) {
         if (flock($fp, LOCK_EX)) {
             // ロック成功
             return $fp;
         }
         // 一定時間sleepし、ロックが解除されるのを待つ
         // 乱数時間sleepすることで、ロックが何度も衝突しないようにする
         usleep((LOCK_RETRY_INTERVAL - mt_rand(0, 300)) * 1000);
     }
     // ロック失敗
     fclose($fp);
     HakoError::lockFail();
     return FALSE;
 }
예제 #7
0
 function readIsland($fp, $num)
 {
     global $init;
     $name = chop(fgets($fp, READ_LINE));
     list($name, $owner, $monster, $port, $ship0, $ship1, $ship2, $ship3, $ship4, $ship5, $ship6, $ship7, $ship8, $ship9, $ship10, $ship11, $ship12, $ship13, $ship14) = array_pad(explode(",", $name), 20, 0);
     $id = chop(fgets($fp, READ_LINE));
     list($id, $starturn, $isBF, $keep) = array_pad(explode(",", $id), 4, 0);
     if ($isBF) {
         $isBF = 1;
     }
     if ($keep) {
         $keep = 1;
     }
     $prize = chop(fgets($fp, READ_LINE));
     $absent = chop(fgets($fp, READ_LINE));
     $comment = chop(fgets($fp, READ_LINE));
     list($comment, $comment_turn) = array_pad(explode(",", $comment), 2, 0);
     $password = chop(fgets($fp, READ_LINE));
     $point = chop(fgets($fp, READ_LINE));
     list($point, $pots) = array_pad(explode(",", $point), 2, NULL);
     $eisei = chop(fgets($fp, READ_LINE));
     list($eisei0, $eisei1, $eisei2, $eisei3, $eisei4, $eisei5) = array_pad(explode(",", $eisei), 6, 0);
     $zin = chop(fgets($fp, READ_LINE));
     list($zin0, $zin1, $zin2, $zin3, $zin4, $zin5, $zin6) = array_pad(explode(",", $zin), 7, 0);
     $item = chop(fgets($fp, READ_LINE));
     list($item0, $item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9, $item10, $item11, $item12, $item13, $item14, $item15, $item16, $item17, $item18, $item19, $item20) = array_pad(explode(",", $item), 21, NULL);
     $money = chop(fgets($fp, READ_LINE));
     list($money, $lot, $gold) = array_pad(explode(",", $money), 3, 0);
     $food = chop(fgets($fp, READ_LINE));
     list($food, $rice) = array_pad(explode(",", $food), 2, 0);
     $pop = chop(fgets($fp, READ_LINE));
     list($pop, $peop) = array_pad(explode(",", $pop), 2, 0);
     $area = chop(fgets($fp, READ_LINE));
     $job = chop(fgets($fp, READ_LINE));
     list($farm, $factory, $commerce, $mountain, $hatuden) = array_pad(explode(",", $job), 5, 0);
     $power = chop(fgets($fp, READ_LINE));
     list($taiji, $rena, $fire) = array_pad(explode(",", $power), 3, 0);
     $tenki = chop(fgets($fp, READ_LINE));
     $soccer = chop(fgets($fp, READ_LINE));
     list($soccer, $team, $shiai, $kachi, $make, $hikiwake, $kougeki, $bougyo, $tokuten, $shitten) = array_pad(explode(",", $soccer), 10, 0);
     $this->idToName[$id] = $name;
     if ($num == -1 || $num == $id) {
         $fp_i;
         // データファイルの存在チェック
         if (file_exists("{$init->dirName}/island.{$id}")) {
             $fp_i = fopen("{$init->dirName}/island.{$id}", "r");
         } else {
             $fp_i = false;
         }
         if ($fp_i === false) {
             HTML::header();
             HakoError::problem();
         }
         // 地形
         $offset = 7;
         // 一対のデータが何文字か
         for ($y = 0; $y < $init->islandSize; $y++) {
             $line = chop(fgets($fp_i, READ_LINE));
             for ($x = 0; $x < $init->islandSize; $x++) {
                 $l = substr($line, $x * $offset, 2);
                 $v = substr($line, $x * $offset + 2, 5);
                 $land[$x][$y] = hexdec($l);
                 $landValue[$x][$y] = hexdec($v);
             }
         }
         // コマンド
         for ($i = 0; $i < $init->commandMax; $i++) {
             $line = chop(fgets($fp_i, READ_LINE));
             list($kind, $target, $x, $y, $arg) = explode(",", $line);
             $command[$i] = array('kind' => $kind, 'target' => $target, 'x' => $x, 'y' => $y, 'arg' => $arg);
         }
         fclose($fp_i);
     }
     return array('name' => $name, 'owner' => $owner, 'id' => $id, 'starturn' => $starturn, 'isBF' => $isBF, 'keep' => $keep, 'prize' => $prize, 'absent' => $absent, 'comment' => $comment, 'comment_turn' => $comment_turn, 'password' => $password, 'point' => $point, 'pots' => $pots, 'money' => $money, 'lot' => $lot, 'gold' => $gold, 'food' => $food, 'rice' => $rice, 'pop' => $pop, 'peop' => $peop, 'area' => $area, 'farm' => $farm, 'factory' => $factory, 'commerce' => $commerce, 'mountain' => $mountain, 'hatuden' => $hatuden, 'monster' => $monster, 'taiji' => $taiji, 'rena' => $rena, 'fire' => $fire, 'tenki' => $tenki, 'soccer' => $soccer, 'team' => $team, 'shiai' => $shiai, 'kachi' => $kachi, 'make' => $make, 'hikiwake' => $hikiwake, 'kougeki' => $kougeki, 'bougyo' => $bougyo, 'tokuten' => $tokuten, 'shitten' => $shitten, 'land' => isset($land) ? $land : "", 'landValue' => isset($landValue) ? $landValue : "", 'command' => isset($command) ? $command : "", 'lbbs' => isset($lbbs) ? $lbbs : "", 'port' => $port, 'ship' => array(0 => $ship0, 1 => $ship1, 2 => $ship2, 3 => $ship3, 4 => $ship4, 5 => $ship5, 6 => $ship6, 7 => $ship7, 8 => $ship8, 9 => $ship9, 10 => $ship10, 11 => $ship11, 12 => $ship12, 13 => $ship13, 14 => $ship14), 'eisei' => array(0 => $eisei0, 1 => $eisei1, 2 => $eisei2, 3 => $eisei3, 4 => $eisei4, 5 => $eisei5), 'zin' => array(0 => $zin0, 1 => $zin1, 2 => $zin2, 3 => $zin3, 4 => $zin4, 5 => $zin5, 6 => $zin6), 'item' => array(0 => $item0, 1 => $item1, 2 => $item2, 3 => $item3, 4 => $item4, 5 => $item5, 6 => $item6, 7 => $item7, 8 => $item8, 9 => $item9, 10 => $item10, 11 => $item11, 12 => $item12, 13 => $item13, 14 => $item14, 15 => $item15, 16 => $item16, 17 => $item17, 18 => $item18, 19 => $item19, 20 => $item20));
 }
예제 #8
0
파일: mente.php 프로젝트: hiro0218/hakoniwa
 function setupMode()
 {
     global $init;
     if (empty($this->dataSet['MPASS1']) || empty($this->dataSet['MPASS2']) || strcmp($this->dataSet['MPASS1'], $this->dataSet['MPASS2'])) {
         HakoError::wrongMasterPassword();
         return 0;
     } else {
         if (empty($this->dataSet['SPASS1']) || empty($this->dataSet['SPASS2']) || strcmp($this->dataSet['SPASS1'], $this->dataSet['SPASS2'])) {
             HakoError::wrongSpecialPassword();
             return 0;
         }
     }
     $masterPassword = crypt($this->dataSet['MPASS1'], 'ma');
     $specialPassword = crypt($this->dataSet['SPASS1'], 'sp');
     $fp = fopen("{$init->passwordFile}", "w");
     fputs($fp, "{$masterPassword}\n");
     fputs($fp, "{$specialPassword}\n");
     fclose($fp);
 }
예제 #9
0
 function commandMain($hako, $data)
 {
     global $init;
     $id = $data['ISLANDID'];
     $num = $hako->idToNumber[$id];
     $island = $hako->islands[$num];
     $name = $island['name'];
     // パスワード
     if (!Util::checkPassword($island['password'], $data['PASSWORD'])) {
         // password間違い
         HakoError::wrongPassword();
         return;
     }
     // モードで分岐
     $command = $island['command'];
     $comary = explode(" ", $data['COMARY']);
     for ($i = 0; $i < $init->commandMax; $i++) {
         $pos = $i * 5;
         $kind = $comary[$pos];
         $x = $comary[$pos + 1];
         $y = $comary[$pos + 2];
         $arg = $comary[$pos + 3];
         $target = $comary[$pos + 4];
         // コマンド登録
         if ($kind == 0) {
             $kind = $init->comDoNothing;
         }
         $command[$i] = array('kind' => $kind, 'x' => $x, 'y' => $y, 'arg' => $arg, 'target' => $target);
     }
     Success::commandAdd();
     // データの書き出し
     $island['command'] = $command;
     $hako->islands[$num] = $island;
     $hako->writeIslandsFile($island['id']);
     // owner modeへ
     $html = new HtmlMapJS();
     $html->owner($hako, $data);
 }