function doupload() { @header('Content-type: text/html; charset=' . WIKI_CHARSET); $did = $this->post['did'] ? $this->post['did'] : 0; if (!$this->setting['attachment_open']) { exit; } $okfile = ''; $this->setting['coin_download'] = isset($this->setting['coin_download']) ? $this->setting['coin_download'] : 10; $count = count($_FILES['attachment']['name']); for ($i = 0; $i < $count; $i++) { if (!(bool) $_FILES['attachment']['name'][$i]) { continue; } $size = $_FILES['attachment']['size'][$i] / 1024; $name = $_FILES['attachment']['name'][$i]; $attachment_type = $_ENV['attachment']->get_attachment_type(); $filetype = strtolower(substr($name, strrpos($name, ".") + 1)); if ($attachment_type[0] != '*' && !in_array($filetype, $attachment_type)) { echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachTypeError'] . '");</script>'; continue; } if ($size > $this->setting['attachment_size'] || empty($size)) { echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachSizeError2'] . '");</script>'; continue; } $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach'; file::createaccessfile('data/attachment/' . date('y-m') . '/'); $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->setting['attachment_size'], 0); if ($result) { $okfile .= $name . '|'; $coindown = $this->post['coin_download'][$i]; if (empty($coindown) || !is_numeric($coindown)) { $coindown = 0; } else { if (0 > $coindown) { $coindown = 0; } else { if ($this->setting['coin_download'] < $coindown) { $coindown = $this->setting['coin_download']; } } } $_ENV['attachment']->add_attachment($this->user['uid'], $did, $name, $destfile, $this->post['attachmentdesc'][$i], $filetype, 0, $coindown); } } echo '<script>'; if ($okfile) { echo 'parent.Attachment.addok("' . $okfile . '");'; } echo '</script>'; }
public function add() { if (!isset($_POST['submit'])) { $pid = $this->get[0]; $categr = self::cate($pid); $this->assign('code', strtoupper(util::random(14))); $this->assign('goodcate', $categr); $tag = M('GoodsTag'); $this->assign('list_goods_tag', $tag->select()); $listConTag = M('GoodsTagContent'); $this->assign('list_this_goods_tag', $listConTag->select()); $type = M('GoodsType'); $this->assign('list_goods_type', $type->select()); $list_brand = M('Brand'); $this->assign('list_brand', $list_brand->select()); $this->display(); } else { $goods = M('Good'); //图片上传 if (!empty($_FILES)) { //print_r($_FILES); //exit; //如果有文件上传 上传附件 $up_result = $this->_upload(); //dump($up_result);exit; if (false == $up_result) { $this->assign('message', '上传图片失败'); $this->display(); exit; } } else { $this->assign('message', '请选图片上传'); $this->display(); exit; } if ($data = $goods->create()) { for ($i = 0; $i <= count($up_result); $i++) { $data['goodspic' . ($i + 1)] = $up_result[$i]['savename']; } if (false !== $goods->add($data)) { $this->redirect('lists', array('message' => 'MESSAGE_SUCCESS')); } else { $this->assign('message', '添加失败'); $this->display(); } } else { $this->assign('message', '添加失败'); $this->display(); } } }
function add_randomstr(&$text) { if (empty($this->base->setting['random_text'])) { return false; } $random_text = explode('<br />', nl2br($this->base->setting['random_text'])); $totalitem = count($random_text); if (0 == $totalitem) { return false; } $maxpos = 256; $fontColor = "#FFFFFF"; $st = util::random(6, 2); $rndstyleValue = ".{$st} { display:none; }"; $rndstyleName = $st; $reString = "<style> {$rndstyleValue} </style>\r\n"; $rndem[1] = 'font'; $rndem[2] = 'div'; $rndem[3] = 'span'; $rndem[4] = 'p'; $bodylen = strlen($text) - 1; $prepos = 0; for ($i = 0; $i <= $bodylen; $i++) { if ($i + 2 >= $bodylen || $i < 50) { $reString .= $text[$i]; } else { $ntag = @strtolower($text[$i] . $text[$i + 1] . $text[$i + 2]); if ($ntag == '</p' || $ntag == '<br' && $i - $prepos > $maxpos) { $dd = mt_rand(1, 4); $emname = $rndem[$dd]; $dd = mt_rand(0, $totalitem - 1); $rnstr = $random_text[$dd]; if ($emname != 'font') { $rnstr = " <{$emname} class='{$rndstyleName}'>{$rnstr}</{$emname}> "; } else { $rnstr = " <font color='{$fontColor}'>{$rnstr}</font> "; } $reString .= $rnstr . $text[$i]; $prepos = $i; } else { $reString .= $text[$i]; } } } $text = $reString; return true; }
function doinstall() { $appid = $this->get[2]; if (is_numeric($appid)) { $pluginurl = $this->setting['app_url'] . '/hdapp.php?action=download&type=plugin&install=1&id=' . $appid . '&url=' . urlencode(WIKI_URL); $zipcontent = @util::hfopen($pluginurl); if (empty($zipcontent)) { $this->message($this->view->lang['msgConnectFailed']); } $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip'; file::writetofile($tmpname, $zipcontent); if (function_exists('gzopen')) { require HDWIKI_ROOT . "/lib/zip.class.php"; $zip = new zip(); if (!$zip->chk_zip) { $this->message($this->view->lang['pluginInstallNoZlib'], ''); } $ziplist = @$zip->get_List($tmpname); if (!(bool) $ziplist) { unlink($tmpname); $this->message($this->view->lang['pluginAddr'] . $pluginurl . $this->view->lang['pluginAddrFail']); } $lastpos = strpos($ziplist[0]['filename'], '/'); $identifier = substr($ziplist[0]['filename'], 0, $lastpos); @$zip->Extract($tmpname, HDWIKI_ROOT . '/plugins'); } else { $this->message($this->view->lang['pluginInstallNoZlib']); } unlink($tmpname); } else { $identifier = $this->get[2]; } $plugin = $this->db->fetch_by_field('plugin', 'identifier', $identifier); if ($plugin) { $this->message($this->view->lang['pluginAddrName'] . $identifier . $this->view->lang['pluginHasInstall'], 'index.php?admin_plugin-list'); } $this->loadplugin($identifier); $plugin = $_ENV["{$identifier}"]->install(); $_ENV['plugin']->add_plugin($plugin); $this->cache->removecache('plugin'); $this->message($this->view->lang['pluginInstallSuccess'], 'index.php?admin_plugin-list'); }
function init_user() { $sid = $this->hgetcookie('sid'); //notice error $auth = $this->hgetcookie('auth'); list($uid, $password) = empty($auth) ? array(0, 0) : string::haddslashes(explode("\t", $this->authcode($auth, 'DECODE')), 1); if (!$sid) { $sid = util::random(6); $this->hsetcookie('sid', $sid, 24 * 3600 * 365); } if ($uid) { if ($password == '') { $sql = 'select u.*, g.grouptitle,g.regulars,g.default,g.type,g.creditslower,g.creditshigher,g.stars,g.color,g.groupavatar from ' . DB_TABLEPRE . 'user u,' . DB_TABLEPRE . 'usergroup g where u.uid=' . $uid . ' and g.groupid=1'; } else { $sql = 'select u.*, g.* from ' . DB_TABLEPRE . 'user u,' . DB_TABLEPRE . 'usergroup g where u.uid=' . $uid . ' and u.groupid=g.groupid'; } $user = $this->db->fetch_first($sql); if ($password == $user['password']) { $this->user = $user; UC_OPEN && $_ENV['ucenter']->avatar(); } } if (!(bool) $this->user) { $this->user = $this->db->fetch_first('select * from ' . DB_TABLEPRE . 'usergroup where groupid=1'); $this->user['uid'] = 0; } $this->user['sid'] = $sid; }
function dobackup() { set_time_limit(0); $filedir = HDWIKI_ROOT . "/data/db_backup/"; file::createaccessfile($filedir); if (!isset($this->post['backupsubmit']) && !isset($this->get[9])) { $sqlfilename = date("Ymd", $this->time) . "_" . util::random(8); $tables = $_ENV['db']->showtables(); file::forcemkdir($filedir); $filename = $_ENV['db']->get_sqlfile_list($filedir); $this->view->assign('filename', $filename); $this->view->assign('filedir', $filedir); $this->view->assign('tables', $tables); $this->view->assign('sqlfilename', $sqlfilename); $this->view->display("admin_dbbackup"); } else { $sqldump = ''; $type = isset($this->post['type']) ? $this->post['type'] : $this->get[2]; $sqlfilename = isset($this->post['sqlfilename']) ? $this->post['sqlfilename'] : rawurldecode($this->get[3]); $sizelimit = isset($this->post['sizelimit']) ? $this->post['sizelimit'] : intval($this->get[4]); $tableid = intval($this->get[5]); $startfrom = intval($this->get[6]); $volume = intval($this->get[7]) + 1; $compression = isset($this->post['compression']) ? $this->post['compression'] : intval($this->get[8]); $backupfilename = $filedir . $sqlfilename; $backupsubmit = 1; $tables = array(); if (substr(trim(ini_get('memory_limit')), 0, -1) < 32 && substr(trim(ini_get('memory_limit')), 0, -1) > 0) { @ini_set('memory_limit', '32M'); } if (!util::is_mem_available($sizelimit * 1024 * 3)) { $this->message($sizelimit . "KB" . $this->view->lang['dblimitsizeBig'], 'index.php?admin_db-backup'); } switch ($type) { case "full": $tables = $_ENV['db']->showtables(); break; case "stand": $tables = array(DB_TABLEPRE . "category", DB_TABLEPRE . "doc", DB_TABLEPRE . "edition", DB_TABLEPRE . "user"); break; case "min": $tables = array(DB_TABLEPRE . "doc", DB_TABLEPRE . "user"); break; case "custom": if (!(bool) $this->post['tables']) { $tables = $this->cache->getcache('backup_tables', '0'); } else { $tables = $this->post['tables']; $this->cache->writecache('backup_tables', $tables); } break; } if ($sizelimit < 512) { $this->message($this->view->lang['dblimitsizeSmall'], 'BACK'); } if (count($tables) == 0) { $this->message($this->view->lang['dbChooseOne'], 'BACK'); } if (!file_exists($filedir)) { file::forcemkdir($filedir); } if (!file::iswriteable($filedir)) { $this->message($this->view->lang['dbFileNotWrite'], 'index.php?admin_db-backup'); } if (in_array(DB_TABLEPRE . "usergroup", $tables)) { $num = array_search(DB_TABLEPRE . "usergroup", $tables); $tables[$num] = $tables[0]; $tables[0] = DB_TABLEPRE . "usergroup"; } if (in_array(DB_TABLEPRE . "user", $tables)) { $num = array_search(DB_TABLEPRE . "user", $tables); if ($tables[0] == DB_TABLEPRE . "usergroup") { $tables[$num] = $tables[1]; $tables[1] = DB_TABLEPRE . "user"; } else { $tables[$num] = $tables[0]; $tables[0] = DB_TABLEPRE . "user"; } } $complete = TRUE; for (; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) { $result = $_ENV['db']->sqldumptable($tables[$tableid], $complete, $sizelimit, $startfrom, strlen($sqldump)); $sqldump .= $result['tabledump']; $complete = $result['complete']; if ($complete) { $startfrom = 0; } else { $startfrom = $result['startfrom']; } } $dumpfile = $backupfilename . "_%s" . '.sql'; !$complete && $tableid--; if (trim($sqldump)) { $result = $_ENV['db']->write_to_sql($sqldump, $dumpfile, $volume); if (!$result) { $this->message($this->view->lang['dbBackupWriteSqlFiled'], 'BACK'); } else { $url = "index.php?admin_db-backup-{$type}-" . rawurlencode($sqlfilename) . "-{$sizelimit}-{$tableid}-{$startfrom}-{$volume}-{$compression}-{$backupsubmit}"; $this->message("<image src='style/default/loading.gif'><br />" . $this->view->lang['dbBackupNext1'] . $volume . $this->view->lang['dbBackupNext2'] . "<script type=\"text/JavaScript\">setTimeout(\"window.location.replace('{$url}');\", 2000);</script>", ''); } } else { $volume--; if ($compression && util::is_mem_available($sizelimit * 1024 * 3 * $volume)) { $_ENV['db']->write_to_zip($backupfilename, $dumpfile, $volume); } $this->cache->removecache('backup_tables'); $this->header("admin_db-backup"); } } }
function doEachHex(&$hako, &$island) { global $init; // 導出値 $name = $island['name']; $id = $island['id']; $land = $island['land']; $landValue = $island['landValue']; $oilFlag = $island['oil']; // 増える人口のタネ値 $addpop = 10; // 村、町 $addpop2 = 0; // 都市 // ??? $pop = $island['pop']; // if (isset($island['food'])) { } if (!isset($island['propaganda'])) { $island['propaganda'] = ""; } if ($island['food'] <= 0) { // 食料不足 $addpop = -30; } elseif ($island['ship'][10] + $island['ship'][11] + $island['ship'][12] + $island['ship'][13] + $island['ship'][14] > 0) { // 海賊船が出没中は成長しない $addpop = 0; } elseif ($island['park'] > 0) { // 遊園地があると人が集まる $addpop += 10; $addpop2 += 1; } elseif ($island['propaganda'] == 1) { // 誘致活動中 $addpop = 30; $addpop2 = 3; } else { } $monsterMove = array(); $bx = 0; $by = 0; // ループ for ($i = 0; $i < $init->pointNumber; $i++) { $x = $this->rpx[$i]; $y = $this->rpy[$i]; $landKind = $land[$x][$y]; $lv = $landValue[$x][$y]; switch ($landKind) { case $init->landWaste: //荒地 if ($island['isBF'] == 1) { $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; } break; case $init->landTown: case $init->landSeaCity: // 町系 if ($addpop < 0) { // 不足 $lv -= Util::random(-$addpop) + 1; if ($lv <= 0 && $landKind == $init->landSeaCity) { // 海に戻す $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; continue; } elseif ($lv <= 0 && $landKind == $init->landTown) { $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; continue; } } else { // 成長 if ($lv < 100) { $lv += Util::random($addpop) + 1; if ($lv > 100) { $lv = 100; } } else { // 都市になると成長遅い if ($addpop2 > 0) { $lv += Util::random($addpop2) + 1; } } } if ($lv > 250) { $lv = 250; } $landValue[$x][$y] = $lv; break; case $init->landNewtown: // ニュータウン系 $townCount = Turn::countAround($land, $x, $y, 19, array($init->landTown, $init->landNewtown, $init->landBigtown)); if ($townCount > 17) { if (Util::random(1000) < 3) { if ($lv > 200) { $land[$x][$y] = $init->landBigtown; } } } if ($addpop < 0) { // 不足 $lv -= Util::random(-$addpop) + 1; if ($lv <= 0) { // 平地に戻す $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; continue; } } else { // 成長 if ($lv < 100) { $lv += Util::random($addpop) + 1; if ($lv > 100) { $lv = 100; } } else { // 都市になると成長遅い if ($addpop2 > 0) { $lv += Util::random($addpop2) + 1; } } } if ($lv > 300) { $lv = 300; } $landValue[$x][$y] = $lv; break; case $init->landBigtown: // 現代都市系 if ($addpop < 0) { // 不足 $lv -= Util::random(-$addpop) + 1; if ($lv <= 0) { // 平地に戻す $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; continue; } } else { // 成長 if ($lv < 200) { $lv += Util::random($addpop) + 1; if ($lv > 200) { $lv = 200; } } else { // 都市になると成長遅い if ($addpop2 > 0) { $lv += Util::random($addpop2) + 1; } } } if ($lv > 500) { $lv = 500; } $landValue[$x][$y] = $lv; break; case $init->landPlains: // 平地 if ($island['isBF'] == 1) { // BF勝手に村生成 $land[$x][$y] = $init->landTown; $landValue[$x][$y] = 10; } elseif (Util::random(5) == 0) { // 周りに農場、町があれば、ここも町になる if ($this->countGrow($land, $landValue, $x, $y)) { $land[$x][$y] = $init->landTown; $landValue[$x][$y] = 1; if (Util::random(1000) < 75) { $land[$x][$y] = $init->landNewtown; $landValue[$x][$y] = 1; } } } break; case $init->landPoll: // 汚染土壌 if (Util::random(3) == 0) { // 汚染浄化 $land[$x][$y] = $init->landPoll; $landValue[$x][$y]--; if ($landKind == $init->landPoll && $landValue[$x][$y] == 0) { // 汚染浄化され平地になる $land[$x][$y] = $init->landPlains; } } break; case $init->landProcity: // 防災都市 if ($addpop < 0) { // 不足 $lv -= Util::random(-$addpop) + 1; if ($lv <= 0) { // 平地に戻す $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; continue; } } else { // 成長 if ($lv < 100) { $lv += Util::random($addpop) + 1; if ($lv > 100) { $lv = 100; } } else { // 都市になると成長遅い if ($addpop2 > 0) { $lv += Util::random($addpop2) + 1; } } } if ($lv > 200) { $lv = 200; } $landValue[$x][$y] = $lv; break; case $init->landFroCity: // 海上都市 if ($addpop < 0) { // 不足 $lv -= Util::random(-$addpop) + 1; if ($lv <= 0) { // 海に戻す $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; } } else { // 成長 if ($lv < 100) { $lv += Util::random($addpop) + 1; if ($lv > 100) { $lv = 100; } } else { // 都市になると成長遅い if ($addpop2 > 0) { $lv += Util::random($addpop2) + 1; } } } if ($lv > 250) { $lv = 250; } // 動く方向を決定 for ($fro = 0; $fro < 3; $fro++) { $d = Util::random(6) + 1; $sx = $x + $init->ax[$d]; $sy = $y + $init->ay[$d]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } // 範囲外判定 if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { continue; } // 海しか動かない if ($land[$sx][$sy] == $init->landSea && $landValue[$sx][$sy] == 0) { break; } } if ($fro == 3) { // 動かなかった break; } // 移動 $land[$sx][$sy] = $land[$x][$y]; $landValue[$sx][$sy] = $lv; // もと居た位置を海に $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; break; case $init->landForest: // 森 if ($lv < 200) { // 木を増やす if ($island['zin'][3] == 1) { $landValue[$x][$y] += 2; } else { $landValue[$x][$y]++; } } break; case $init->landCommerce: // 商業ビル if (Util::random(1000) < $init->disSto) { // ストライキ $landValue[$x][$y] -= 5; if ($landValue[$x][$y] <= 0) { $land[$x][$y] = $init->landCommerce; $landValue[$x][$y] = 0; } $this->log->Sto($id, $name, $this->landName($landKind, $lv), "({$x}, {$y})"); } break; case $init->landMonument: // 記念碑 $lv = $landValue[$x][$y]; $lName = $this->landName($landKind, $lv); if ($lv == 5 || $lv == 6 || $lv == 21 || $lv == 24 || $lv == 32) { if (util::random(100) < 5) { // お土産 $value = 1 + Util::random(49); if ($value > 0) { $island['money'] += $value; $str = "{$value}{$init->unitMoney}"; $this->log->Miyage($id, $name, $lName, "({$x},{$y})", $str); break; } } } elseif ($lv == 1 || $lv == 7 || $lv == 33) { if (util::random(100) < 5) { // 収穫 $value = round($island['pop'] / 100) * 10 + Util::random(11); // 人口1万人ごとに1000トンの収穫 if ($value > 0) { $island['food'] += $value; $str = "{$value}{$init->unitFood}"; $this->log->Syukaku($id, $name, $lName, "({$x},{$y})", $str); break; } } } elseif ($lv == 15) { if (util::random(100) < 5) { // 銀行化 $land[$x][$y] = $init->landBank; $landValue[$x][$y] = 1; // メッセージ $this->log->Bank($id, $name, $lName, "({$x},{$y})"); break; } } elseif ($lv == 40 || $lv == 41 || $lv == 42 || $lv == 43) { if (util::random(100) < 1) { // 卵孵化 $kind = Util::random($init->monsterLevel1) + 1; $lv = $kind * 100 + $init->monsterBHP[$kind] + Util::random($init->monsterDHP[$kind]); // そのヘックスを怪獣に $land[$x][$y] = $init->landMonster; $landValue[$x][$y] = $lv; // 怪獣情報 $monsSpec = Util::monsterSpec($lv); // メッセージ $this->log->EggBomb($id, $name, $mName, "({$x},{$y})", $lName); break; } } break; case $init->landSeaResort: // 海の家 $nt = Turn::countAround($land, $x, $y, 19, array($init->landTown)); // 周囲2ヘックスの人口 $ns = Turn::countAround($land, $x, $y, 19, array($init->landSeaSide)); // 周囲2ヘックスの砂浜収容人数 // 収益の計算 if ($nt > 0) { $value = $ns / $nt; } $value = (int) ($lv * $value * $nt); if ($value > 0) { $island['money'] += $value; // 収入ログ $str = "{$value}{$init->unitMoney}"; $this->log->oilMoney($id, $name, $this->landName($landKind, $lv), "({$x},{$y})", $str); } if ($lv < 30) { // 海の家 $n = 1; } elseif ($lv < 100) { // 民宿 $n = 2; } else { // リゾートホテル $n = 4; } $lv += (int) (Util::random($nt / $n) * ($nt < $ns ? -1 : 1)); if ($lv < 1) { $lv = 1; } elseif ($lv > 200) { $lv = 200; } $landValue[$x][$y] = $lv; break; case $init->landDefence: if ($lv == 0) { // 防衛施設自爆 $lName = $this->landName($landKind, $lv); $this->log->bombFire($id, $name, $lName, "({$x}, {$y})"); // 広域被害ルーチン $this->wideDamage($id, $name, $land, $landValue, $x, $y); } break; case $init->landHatuden: // 発電所 $lName = $this->landName($landKind, $lv); if (Util::random(100000) < $landValue[$x][$y]) { // メルトダウン $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; $this->log->CrushElector($id, $name, $lName, "({$x}, {$y})"); } break; case $init->landSoukoM: case $init->landSoukoF: // 倉庫 $lName = $this->landName($landKind, $lv); // セキュリティと貯蓄を算出 $sec = (int) ($landValue[$x][$y] / 100); $tyo = $landValue[$x][$y] % 100; if (Util::random(100) < 10 - $sec) { // 強盗 $tyo = (int) ($tyo / 100 * Util::random(100)); $sec--; if ($sec < 0) { $sec = 0; } $landValue[$x][$y] = $sec * 100 + $tyo; $this->log->SoukoLupin($id, $name, $lName, "({$x}, {$y})"); } break; case $init->landOil: // 海底油田 $lName = $this->landName($landKind, $lv); $value = $init->oilMoney; $island['money'] += $value; $island['oilincome'] += $value; // 枯渇判定 if (Util::random(1000) < $init->oilRatio) { // 枯渇 $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; $this->log->oilEnd($id, $name, $lName, "({$x}, {$y})"); } break; case $init->landBank: // 銀行 $island['bank']++; break; case $init->landSoccer: // スタジアム $lName = $this->landName($landKind, $lv); $value = $island['team']; if ($value > 200) { $value = 200; } $island['money'] += $value; $str = "{$value}{$init->unitMoney}"; // 収入ログ if ($value > 0) { $this->log->oilMoney($id, $name, $lName, "({$x}, {$y})", $str); } break; case $init->landPark: // 遊園地 $lName = $this->landName($landKind, $lv); //$value = floor($island['pop'] / 50); // 人口5千人ごとに1億円の収入 //収益は人口増加とともに横ばい傾向 //人口の平方根の1~2倍 ex 1万=10~20億円 100万=100~200億円 $value = floor(sqrt($island['pop']) * (Util::random(100) / 100 + 1)); $island['money'] += $value; $str = "{$value}{$init->unitMoney}"; //収入ログ if ($value > 0) { $this->log->ParkMoney($id, $name, $lName, "({$x},{$y})", $str); } //イベント判定 if (Util::random(100) < 30) { // 毎ターン 30% の確率でイベントが発生する //遊園地のイベント $value2 = $value; //食料消費 $value = floor($island['pop'] * $init->eatenFood / 2); // 規定食料消費の半分消費 $island['food'] -= $value; $str = "{$value}{$init->unitFood}"; if ($value > 0) { $this->log->ParkEvent($id, $name, $lName, "({$x},{$y})", $str); } //イベントの収支 $value = floor((Util::random(200) - 100) / 100 * $value2); //マイナス100%~プラス100% $island['money'] += $value; if ($value > 0) { $str = "{$value}{$init->unitMoney}"; $this->log->ParkEventLuck($id, $name, $lName, "({$x},{$y})", $str); } if ($value < 0) { $value = -$value; $str = "{$value}{$init->unitMoney}"; $this->log->ParkEventLoss($id, $name, $lName, "({$x},{$y})", $str); } } // 老築化判定 if (Util::random(100) < 5) { // 施設が老築化したため閉園 $land[$x][$y] = $init->landPlains; $landValue[$x][$y] = 0; $this->log->ParkEnd($id, $name, $lName, "({$x},{$y})"); } break; case $init->landPort: // 港 $lName = $this->landName($landKind, $lv); $seaCount = Turn::countAround($land, $x, $y, 7, array($init->landSea)); if ($seaCount == 0 || $seaCount == 6) { // 周囲に最低1Hexの海も無い場合、閉鎖 // 周囲に最低1Hexの陸地が無い場合、閉鎖 $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 1; $this->log->ClosedPort($id, $name, $lName, "({$x},{$y})"); } break; case $init->landTrain: // 電車 if ($TrainMove[$x][$y] == 1) { // すでに動いた後 break; } // 動く方向を決定 for ($t = 0; $t < 3; $t++) { $d = Util::random(6) + 1; $sx = $x + $init->ax[$d]; $sy = $y + $init->ay[$d]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } // 範囲外判定 if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { continue; } // 線路しか動かない if ($land[$sx][$sy] == $init->landRail) { break; } } if ($t == 3) { // 動かなかった break; } $l = $land[$sx][$sy]; $lv = $landValue[$sx][$sy]; $lName = $this->landName($l, $lv); $point = "({$sx}, {$sy})"; // 移動 $land[$sx][$sy] = $land[$x][$y]; // もと居た位置を線路に $land[$x][$y] = $init->landRail; // 移動ずみフラグ、セット $TrainMove[$sx][$sy] = 1; break; case $init->landZorasu: // 海怪獣 if ($ZorasuMove[$x][$y] == 1) { // すでに動いた後 break; } // 動く方向を決定 for ($j = 0; $j < 3; $j++) { $d = Util::random(6) + 1; $sx = $x + $init->ax[$d]; $sy = $y + $init->ay[$d]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } // 範囲外判定 if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { continue; } // 海、船舶、海基、海防、海底都市、海上都市、海底消防署、海底農場、油田 if ($land[$sx][$sy] == $init->landSea || $land[$sx][$sy] == $init->landShip || $land[$sx][$sy] == $init->landSbase || $land[$sx][$sy] == $init->landSdefence || $land[$sx][$sy] == $init->landSeaCity || $land[$sx][$sy] == $init->landFroCity || $land[$sx][$sy] == $init->landSsyoubou || $land[$sx][$sy] == $init->landSfarm || $land[$sx][$sy] == $init->landOil) { break; } } if ($j == 3) { // 動かなかった break; } // 動いた先の地形によりメッセージ $l = $land[$sx][$sy]; $lv = $landValue[$sx][$sy]; $lName = $this->landName($l, $lv); $point = "({$sx}, {$sy})"; if ($land[$sx][$sy] != $init->landSea) { $this->log->ZorasuMove($id, $name, $lName, $point); } // 移動 $land[$sx][$sy] = $land[$x][$y]; $landValue[$sx][$sy] = $landValue[$x][$y]; // もと居た位置を海に $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; // 移動ずみフラグ、セット $ZorasuMove[$sx][$sy] = 1; break; case $init->landMonster: // 怪獣 if (isset($monsterMove[$x][$y])) { if ($monsterMove[$x][$y] == 2) { // すでに動いた後 break; } } // 各要素の取り出し $monsSpec = Util::monsterSpec($landValue[$x][$y]); $special = $init->monsterSpecial[$monsSpec['kind']]; $mName = $monsSpec['name']; // 怪獣の体力回復 if ($monsSpec['hp'] < $init->monsterBHP[$monsSpec['kind']] && Util::random(100) < 20) { $landValue[$x][$y]++; } if (Turn::countAroundValue($island, $x, $y, $init->landProcity, 200, 7) && $monsSpec['kind'] != 26) { // 周囲1Hexに別の怪獣がいる場合、その怪獣を攻撃する // 対象の怪獣が倒れて荒地になる $land[$x][$y] = $init->landWaste; $landValue[$x][$y] = 0; $this->log->BariaAttack($id, $name, $lName, "({$x},{$y})", $mName, $tPoint); // 収入 $value = $init->monsterValue[$monsSpec['kind']]; if ($value > 0) { $island['money'] += $value; $this->log->msMonMoney($id, $target, $mName, $value); } break; } // 硬化中? if ($special & 0x4 && $hako->islandTurn % 2 == 1 || $special & 0x10 && $hako->islandTurn % 2 == 0) { // 硬化中 break; } if ($special & 0x20) { // 仲間を呼ぶ怪獣 if (Util::random(100) < 5 && $pop >= $init->disMonsBorder1) { // 怪獣出現 $pop = $island['pop']; $this->log->monsCall($id, $name, $mName, "({$x}, {$y})"); if ($pop >= $init->disMonsBorder5) { // level5まで $kind = Util::random($init->monsterLevel5) + 1; } elseif ($pop >= $init->disMonsBorder4) { // level4のみ $kind = Util::random($init->monsterLevel4) + 1; } elseif ($pop >= $init->disMonsBorder3) { // level3のみ $kind = Util::random($init->monsterLevel3) + 1; } elseif ($pop >= $init->disMonsBorder2) { // level2のみ $kind = Util::random($init->monsterLevel2) + 1; } else { // level1のみ $kind = Util::random($init->monsterLevel1) + 1; } // lvの値を決める $lv = $kind * 100 + $init->monsterBHP[$kind] + Util::random($init->monsterDHP[$kind]); // どこに現れるか決める for ($i = 0; $i < $init->pointNumber; $i++) { $bx = $this->rpx[$i]; $by = $this->rpy[$i]; if ($land[$bx][$by] == $init->landTown) { // 地形名 $lName = $this->landName($init->landTown, $landValue[$bx][$by]); // そのヘックスを怪獣に $land[$bx][$by] = $init->landMonster; $landValue[$bx][$by] = $lv; // 怪獣情報 $monsSpec = Util::monsterSpec($lv); // メッセージ $this->log->monsCome($id, $name, $mName, "({$bx}, {$by})", $lName); break; } } } } // ワープする怪獣 if ($special & 0x40) { $r = mt_rand(0, 100); if ($r < 20) { // 20% // ワープする $tg; $tIsland = $island; $r = mt_rand(0, 100); if ($r < 50) { // 50% // ワープする島を決める $tg = Util::random($hako->islandNumber); $tIsland = $hako->islands[$tg]; if ($hako->islandTurn - $tIsland['starturn'] < $init->noAssist && $tIsland['isBF'] != 1) { // 初心者期間中の島にはワープしない(自島へワープ) $tIsland = $island; } } $tId = $tIsland['id']; $tName = $tIsland['name']; // ワープ地点を決める $tLand = $tIsland['land']; $tLandValue = $tIsland['landValue']; for ($w = 0; $w < $init->pointNumber; $w++) { $bx = $this->rpx[$w]; $by = $this->rpy[$w]; // 海、船舶、海基、海防、海底都市、海上都市、海底消防署、養殖場、油田、港、怪獣、山、ぞらす、記念碑以外 if ($tLand[$bx][$by] != $init->landSea && $tLand[$bx][$by] != $init->landShip && $tLand[$bx][$by] != $init->landSbase && $tLand[$bx][$by] != $init->landSdefence && $tLand[$bx][$by] != $init->landSeaCity && $tLand[$bx][$by] != $init->landFroCity && $tLand[$bx][$by] != $init->landSsyoubou && $tLand[$bx][$by] != $init->landSfarm && $tLand[$bx][$by] != $init->landNursery && $tLand[$bx][$by] != $init->landOil && $tLand[$bx][$by] != $init->landPort && $tLand[$bx][$by] != $init->landMountain && $tLand[$bx][$by] != $init->landMonument && $tLand[$bx][$by] != $init->landZorasu && $tLand[$bx][$by] != $init->landSleeper && $tLand[$bx][$by] != $init->landMonster) { break; } } // ワープ! $this->log->monsWarp($id, $tId, $name, $mName, "({$x}, {$y})", $tName); $this->log->monsCome($tId, $tName, $mName, "({$bx}, {$by})", $this->landName($tLand[$bx][$by], $tLandValue[$bx][$by])); if ($id == $tId) { $land[$bx][$by] = $init->landMonster; $landValue[$bx][$by] = $lv; } else { $tLand[$bx][$by] = $init->landMonster; $tLandValue[$bx][$by] = $lv; } $monsterMove[$bx][$bx] = 2; $land[$x][$y] = $init->landWaste; $landValue[$x][$y] = 0; if ($id != $tId) { // ターゲットが異なる場合は、値を戻す $tIsland['land'] = $tLand; $tIsland['landValue'] = $tLandValue; $hako->islands[$tg] = $tIsland; } break; } else { // ワープしない } } if ($special & 0x400) { // 瀕死になると大爆発 if ($monsSpec['hp'] <= 1) { // 残り体力1なら $point = "({$x}, {$y})"; // 瀕死になったので爆発する $this->log->MonsExplosion($id, $name, $point, $mName); // 広域被害ルーチン $this->wideDamage($id, $name, $land, $landValue, $x, $y); break; } } if ($special & 0x1000) { // 出現中はお金を増やしてくれる $point = "({$x}, {$y})"; $money = Util::random(100) + 1; // 1億円~100億円 $island['money'] += $money; $str = "{$money}{$init->unitMoney}"; $this->log->MonsMoney($id, $name, $mName, $point, "{$str}"); } if ($special & 0x2000) { // 出現中は食料を増やしてくれる $point = "({$x}, {$y})"; $food = Util::random(10) + 1; // 1000トン~10000トン $island['food'] += $food; $str = "{$food}{$init->unitFood}"; $this->log->MonsFood($id, $name, $mName, $point, "{$str}"); } if ($special & 0x4000) { // 出現中はお金を減らしてしまう $point = "({$x}, {$y})"; $money = Util::random(100) + 1; // 1億円~100億円 $island['money'] -= $money; $str = "{$money}{$init->unitMoney}"; $this->log->MonsMoney2($id, $name, $mName, $point, "{$str}"); } if ($special & 0x10000) { // 出現中は食料を腐らせてしまう $point = "({$x}, {$y})"; $food = Util::random(10) + 1; // 1000トン~10000トン $island['food'] -= $food; $str = "{$food}{$init->unitFood}"; $this->log->MonsFood2($id, $name, $mName, $point, "{$str}"); } // 動く方向を決定 for ($j = 0; $j < 3; $j++) { $d = Util::random(6) + 1; if ($special & 0x200) { // 飛行移動能力 $d = Util::random(12) + 7; } $sx = $x + $init->ax[$d]; $sy = $y + $init->ay[$d]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } // 範囲外判定 if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { continue; } // 海、船舶、海基、海防、海底都市、海上都市、海底消防署、養殖場、油田、港、怪獣、山、ぞらす、記念碑以外 if ($land[$sx][$sy] != $init->landSea && $land[$sx][$sy] != $init->landShip && $land[$sx][$sy] != $init->landSbase && $land[$sx][$sy] != $init->landSdefence && $land[$sx][$sy] != $init->landSeaCity && $land[$sx][$sy] != $init->landFroCity && $land[$sx][$sy] != $init->landSsyoubou && $land[$sx][$sy] != $init->landSfarm && $land[$sx][$sy] != $init->landNursery && $land[$sx][$sy] != $init->landOil && $land[$sx][$sy] != $init->landPort && $land[$sx][$sy] != $init->landMountain && $land[$sx][$sy] != $init->landMonument && $land[$sx][$sy] != $init->landZorasu && $land[$sx][$sy] != $init->landSleeper && $land[$sx][$sy] != $init->landMonster) { break; } } if ($j == 3) { // 動かなかった break; } // 動いた先の地形によりメッセージ $l = $land[$sx][$sy]; $lv = $landValue[$sx][$sy]; $lName = $this->landName($l, $lv); $point = "({$sx}, {$sy})"; // 移動 $land[$sx][$sy] = $land[$x][$y]; $landValue[$sx][$sy] = $landValue[$x][$y]; if ($special & 0x20000 && Util::random(100) < 30) { // 分裂確率30% // 分裂する怪獣 // もと居た位置を怪獣に $land[$bx][$by] = $init->landMonster; $landValue[$bx][$by] = $lv; // 怪獣情報 $monsSpec = Util::monsterSpec($lv); // メッセージ $this->log->monsBunretu($id, $name, $lName, $point, $mName); } else { // もと居た位置を荒地に $land[$x][$y] = $init->landWaste; $landValue[$x][$y] = 0; } // 移動済みフラグ if ($init->monsterSpecial[$monsSpec['kind']] & 0x2) { // 移動済みフラグは立てない } elseif ($init->monsterSpecial[$monsSpec['kind']] & 0x1) { // 速い怪獣 if (isset($monsterMove[$sx][$sy])) { $monsterMove[$sx][$sy] = $monsterMove[$x][$y] + 1; } else { $monsterMove[$sx][$sy] = 1; } } else { // 普通の怪獣 $monsterMove[$sx][$sy] = 2; } if ($l == $init->landDefence && $init->dBaseAuto == 1) { // 防衛施設を踏んだ $this->log->monsMoveDefence($id, $name, $lName, $point, $mName); // 広域被害ルーチン $this->wideDamage($id, $name, $land, $landValue, $sx, $sy); } else { // 行き先が荒地になる if ($island['isBF'] != 1) { $this->log->monsMove($id, $name, $lName, $point, $mName); } } break; case $init->landSleeper: // 捕獲怪獣 // 各要素の取り出し $monsSpec = Util::monsterSpec($landValue[$x][$y]); $special = $init->monsterSpecial[$monsSpec['kind']]; $mName = $monsSpec['name']; if (Util::random(1000) < $monsSpec['hp'] * 10) { // (怪獣の体力 * 10)% の確率で捕獲解除 $point = "({$x}, {$y})"; $land[$x][$y] = $init->landMonster; // 捕獲解除 $this->log->MonsWakeup($id, $name, $lName, $point, $mName); } break; case $init->landShip: // 船舶 if (isset($shipMove[$x][$y])) { if ($shipMove[$x][$y] != 1) { //船がまだ動いていない時 $ship = Util::navyUnpack($landValue[$x][$y]); $lName = $init->shipName[$ship[1]]; $tLname .= "({$this->islands[$ship[0]]['name']}島所属)"; $tn = $hako->idToNumber[$ship[0]]; $tIsland =& $hako->islands[$tn]; $tName = $hako->idToName[$ship[0]]; if ($init->shipCost[$ship[1]] > $tIsland['money'] && $ship[0] != 0) { // 維持費を払えなくなり海の藻屑となる $this->log->ShipRelease($id, $ship[0], $name, $tName, "({$x},{$y})", $init->shipName[$ship[1]]); $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; break; } if ($ship[1] == 2) { // 海底探索船 $cntTreasure = Turn::countAroundValue($island, $x, $y, $init->landSea, 100, 7); if ($cntTreasure) { // 周囲1ヘックス以内に財宝あり for ($s1 = 0; $s1 < 7; $s1++) { $sx = $x + $init->ax[$s1]; $sy = $y + $init->ay[$s1]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { // 範囲外の場合何もしない continue; } else { // 範囲内の場合 if ($land[$sx][$sy] == $init->landSea && $landValue[$sx][$sy] >= 100) { // 財宝発見 if ($ship[0] == $island['id']) { // 自島所属であればすぐに財宝回収 $island['money'] += $landValue[$sx][$sy]; } else { // 他島所属であれば積載して帰還するまで回収しない $ship[3] = round($landValue[$sx][$sy] / 1000); $ship[4] = round(($landValue[$sx][$sy] - $ship[3] * 1000) / 100); $landValue[$x][$y] = Util::navyPack($ship[0], $ship[1], $ship[2], $ship[3], $ship[4]); } $tName = $hako->idToName[$ship[0]]; $this->log->FindTreasure($id, $ship[0], $name, $tName, "({$x},{$y})", $init->shipName[$ship[1]], $landValue[$sx][$sy]); // 財宝があった地形は海になる $land[$sx][$sy] = $init->landSea; $landValue[$sx][$sy] = 0; break; } } } } } elseif ($ship[1] == 3) { // 戦艦 if ($island['monster'] > 0 && $ship[4] != intval($hako->islandTurn) % 10) { // 怪獣が出現しており、現在のターンで未攻撃の場合 for ($s2 = 0; $s2 < $init->pointNumber; $s2++) { $sx = $this->rpx[$s2]; $sy = $this->rpy[$s2]; if ($land[$sx][$sy] == $init->landMonster || $land[$sx][$sy] == $init->landSleeper) { // 対象となる怪獣の各要素取り出し $monsSpec = Util::monsterSpec($landValue[$sx][$sy]); $tLv = $landValue[$sx][$sy]; $tspecial = $init->monsterSpecial[$monsSpec['tkind']]; $tmonsName = $monsSpec['name']; // 硬化中? if ($special & 0x4 && $hako->islandTurn % 2 == 1 || $special & 0x10 && $hako->islandTurn % 2 == 0) { // 硬化中なら効果なし break; } if ($monsSpec['hp'] > 1) { // 対象の体力を減らす $landValue[$sx][$sy]--; } else { // 対象の怪獣が倒れて荒地になる $land[$sx][$sy] = $init->landWaste; $landValue[$sx][$sy] = 0; // 収入 $value = $init->monsterValue[$monsSpec['kind']]; if ($value > 0) { $island['money'] += $value; $this->log->msMonMoney($id, $target, $tmonsName, $value); } } $tName = $hako->idToName[$ship[0]]; $this->log->SenkanMissile($id, $ship[0], $name, $tName, $lName, "({$x},{$y})", "({$sx},{$sy})", $tmonsName); break; } } // 1ターンに1度しか攻撃できない $ship[4] = intval($hako->islandTurn) % 10; } else { } // 海賊船が出現していた場合攻撃する $cntViking = Turn::countAround($land, $x, $y, 19, array($init->landShip)); if ($cntViking && $ship[4] != intval($hako->islandTurn) % 10) { //周囲2ヘックス以内に船舶あり for ($s3 = 0; $s3 < 19; $s3++) { $sx = $x + $init->ax[$s3]; $sy = $y + $init->ay[$s3]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { // 範囲外の場合何もしない continue; } else { // 範囲内の場合 if ($land[$sx][$sy] == $init->landShip) { $tShip = Util::navyUnpack($landValue[$sx][$sy]); $tName = $hako->idToName[$ship[0]]; $tshipName = $init->shipName[$tShip[1]]; if ($tShip[1] >= 10) { // 海賊船だった場合攻撃する $tShip[2] -= 2; if ($tShip[2] <= 0) { // 海賊船を沈没させた $land[$sx][$sy] = $init->landSea; $this->log->SenkanAttack($id, $ship[0], $name, $tName, $init->shipName[$ship[1]], "({$x},{$y})", "({$sx},{$sy})", $tshipName); $this->log->BattleSinking($id, $tShip[0], $name, $tshipName, "({$sx},{$sy})"); // 30%の確率で財宝になる $treasure = $tShip[3] * 1000 + $tShip[4] * 100; if (Util::random(100) < 30 && $treasure > 0) { $landValue[$sx][$sy] = $treasure; $this->log->VikingTreasure($id, $name, "({$sx},{$sy})"); } else { $landValue[$sx][$sy] = 0; } } else { // 海賊船にダメージ与えた $landValue[$sx][$sy] = Util::navyPack($tShip[0], $tShip[1], $tShip[2], $tShip[3], $tShip[4]); $this->log->SenkanAttack($id, $ship[0], $name, $tName, $init->shipName[$ship[1]], "({$x},{$y})", "({$sx},{$sy})", $tshipName); } break; } } } } // 1ターンに1度しか攻撃できない $ship[4] = intval($hako->islandTurn) % 10; } } elseif ($ship[1] >= 10) { // 海賊船 if (Util::random(1000) < $init->disVikingRob) { // 強奪 $vMoney = round(Util::random($island['money']) / 10); $vFood = round(Util::random($island['food']) / 10); $island['money'] -= $vMoney; $island['food'] -= $vFood; $this->log->RobViking($island['id'], $island['name'], "({$x},{$y})", $init->shipName[$ship[1]], $vMoney, $vFood); // 所持金 $treasure = $ship[3] * 1000 + $ship[4] * 100; $treasure += $vMoney; $ship[3] = $treasure / 1000; $ship[4] = ($treasure - $ship[1] * 1000) / 100; if ($ship[3] > 32) { $ship[3] = 32; } // 海賊船ステータス更新 $landValue[$x][$y] = Util::navyPack($ship[0], $ship[1], $ship[2], $ship[3], $ship[4]); } // 攻撃 $cntShip = Turn::countAround($land, $x, $y, 19, array($init->landPort, $init->landShip, $init->landFroCity)); if ($cntShip) { //周囲2ヘックス以内に港または船舶または海上都市あり if (Util::random(1000) < $init->disVikingAttack) { // 海賊船の襲撃 for ($s4 = 0; $s4 < 19; $s4++) { $sx = $x + $init->ax[$s4]; $sy = $y + $init->ay[$s4]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { // 範囲外の場合何もしない continue; } else { // 範囲内の場合 if ($land[$sx][$sy] == $init->landPort) { // 港の場合浅瀬になる $land[$sx][$sy] = $init->landSea; $landValue[$sx][$sy] = 1; $this->log->BattleSinking($id, 0, $name, $this->landName($init->landPort, 1), "({$sx},{$sy})"); $this->log->VikingAttack($id, $id, $name, $name, $init->shipName[$ship[1]], "({$x},{$y})", "({$sx},{$sy})", $this->landName($init->landPort, 1)); break; } elseif ($land[$sx][$sy] == $init->landShip) { // 船舶の場合 $tShip = Util::navyUnpack($landValue[$sx][$sy]); $tName = $hako->idToName[$tShip[0]]; $tshipName = $init->shipName[$tShip[1]]; if ($tShip[1] < 10) { // 海賊船の攻撃 $tShip[2] -= $init->disVikingMinAtc + Util::random($init->disVikingMaxAtc - $init->disVikingMinAtc); if ($tShip[2] <= 0) { // 船舶沈没 $land[$sx][$sy] = $init->landSea; $landValue[$sx][$sy] = 0; $this->log->ShipSinking($id, $tShip[0], $name, $tName, $tshipName, "({$sx},{$sy})"); break; } else { // 船舶ダメージ $landValue[$sx][$sy] = Util::navyPack($tShip[0], $tShip[1], $tShip[2], $tShip[3], $tShip[4]); $this->log->VikingAttack($id, $tShip[0], $name, $tName, $init->shipName[$ship[1]], "({$x},{$y})", "({$sx},{$sy})", $tshipName); break; } } } elseif ($land[$sx][$sy] == $init->landFroCity) { // 海上都市の場合海になる $land[$sx][$sy] = $init->landSea; $landValue[$sx][$sy] = 0; $this->log->BattleSinking($id, 0, $name, $this->landName($init->landFroCity, 0), "({$sx},{$sy})"); $this->log->VikingAttack($id, $id, $name, $name, $init->shipName[$ship[1]], "({$x},{$y})", "({$sx},{$sy})", $this->landName($init->landFroCity, 0)); break; } } } } } if (Util::random(1000) < $init->disVikingAway) { // 海賊船 去る $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; $this->log->VikingAway($id, $name, "({$x},{$y})"); break; } } if ($landValue[$x][$y] != 0) { // 船がまだ存在していたら // 動く方向を決定 for ($s5 = 0; $s5 < 3; $s5++) { $d = Util::random(6) + 1; $sx = $x + $init->ax[$d]; $sy = $y + $init->ay[$d]; // 行による位置調整 if ($sy % 2 == 0 && $y % 2 == 1) { $sx--; } // 範囲外判定 if ($sx < 0 || $sx >= $init->islandSize || $sy < 0 || $sy >= $init->islandSize) { continue; } // 海であれば、動く方向を決定 if ($land[$sx][$sy] == $init->landSea && $landValue[$sx][$sy] < 1) { break; } } if ($s5 == 3) { // 動かなかった } else { // 移動 $land[$sx][$sy] = $land[$x][$y]; $landValue[$sx][$sy] = Util::navyPack($ship[0], $ship[1], $ship[2], $ship[3], $ship[4]); if ($ship[1] == 2) { if (Util::random(100) < 7 && $island['tenki'] == 1 && $island['item'][18] == 1 && $island['item'][19] != 1) { // レッドダイヤ発見 $island['item'][19] = 1; $this->log->RedFound($id, $name, '赤い宝石'); } // 油田見っけ if (Util::random(100) < 3) { $lName = $init->shipName[$ship[1]]; $island['oil']++; $land[$x][$y] = $init->landOil; $landValue[$x][$y] = 0; $this->log->tansakuoil($id, $name, $lName, $point); } else { // もと居た位置を海に $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; } } else { // もと居た位置を海に $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; } // 移動済みフラグ if (Util::random(2)) { $shipMove[$sx][$sy] = 1; } } } } } break; } // すでに$init->landTownがcase文で使われているのでswitchを別に用意 switch ($landKind) { case $init->landTown: case $init->landHaribote: case $init->landFactory: case $init->landHatuden: case $init->landPark: case $init->landSeaResort: case $init->landSyoubou: case $init->landSsyoubou: case $init->landSeaCity: case $init->landFroCity: case $init->landNewtown: case $init->landBigtown: // 火災判定 if (Turn::countAround($land, $x, $y, 19, array($init->landSyoubou, $init->landSsyoubou)) > 0) { break; } if ($landKind == $init->landSeaResort && $lv <= 30 || $landKind == $init->landFactory && $lv >= 100 || $landKind == $init->landHatuden && $lv >= 100 || $landKind == $init->landTown && $lv <= 30) { break; } if (Util::random(1000) < $init->disFire - (int) ($island['eisei'][0] / 20)) { // 周囲の森と記念碑を数える if (Turn::countAround($land, $x, $y, 7, array($init->landForest, $init->landProcity, $init->landFusya, $init->landMonument)) == 0) { // 無かった場合、火災で壊滅 $l = $land[$x][$y]; $lv = $landValue[$x][$y]; $point = "({$x}, {$y})"; $lName = $this->landName($l, $lv); if ($landKind == $init->landNewtown || $landKind == $init->landBigtown) { // ニュータウン、現代都市の場合 $landValue[$x][$y] -= Util::random(100) + 50; $this->log->firenot($id, $name, $lName, $point); if ($landValue[$x][$y] <= 0) { $land[$x][$y] = $init->landWaste; $landValue[$x][$y] = 0; $this->log->fire($id, $name, $lName, $point); } } elseif ($landKind == $init->landSeaCity || $landKind == $init->landFroCity) { $land[$x][$y] = $init->landSea; $landValue[$x][$y] = 0; $this->log->fire($id, $name, $lName, $point); } else { $land[$x][$y] = $init->landWaste; $landValue[$x][$y] = 0; $this->log->fire($id, $name, $lName, $point); } } } break; } } // 変更された可能性のある変数を書き戻す $island['land'] = $land; $island['landValue'] = $landValue; }
function upload_attachment($did) { if (!$this->base->setting['attachment_open']) { return false; } $count = count($_FILES['attachment']['name']); for ($i = 0; $i < $count; $i++) { if (!(bool) $_FILES['attachment']['name'][$i]) { continue; } $attachment_type = $this->get_attachment_type(); $filetype = strtolower(substr($_FILES['attachment']['name'][$i], strrpos($_FILES['attachment']['name'][$i], ".") + 1)); if (!in_array($filetype, $attachment_type)) { $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachTypeError'] . "<br />"; continue; } if ($this->base->setting['attachment_size'] < $_FILES['attachment']['size'][$i] / 1024) { $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachSizeError'] . "<br />"; continue; } $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach'; file::createaccessfile('data/attachment/' . date('y-m') . '/'); $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->base->setting['attachment_size'], 0); if ($result) { $_ENV['attachment']->add_attachment($this->base->user['uid'], $did, $_FILES['attachment']['name'][$i], $destfile, $this->base->post['attachmentdesc'][$i], $filetype, 0); } } return $message; }
function doedit() { if (!isset($this->post['submit'])) { $id = $this->get[2]; $gift = $_ENV['gift']->get($id); $this->view->assign("gift", $gift); $this->view->display('admin_editgift'); } else { $id = trim($this->post['id']); $gift = $_ENV['gift']->get($id); $title = htmlspecialchars(trim($this->post['title'])); $credit = trim($this->post['credit']); $description = htmlspecialchars(trim($this->post['description'])); $imgname = $_FILES['giftfile']['name']; /* if($gift['image']){ $destfile=str_replace('_s.', '.', $gift['image']); }else{ $extname=file::extname($imgname); $destfile = 'uploads/gift/'.util::random(8).'.'.$extname; } */ if ('' != $imgname) { $extname = file::extname($imgname); $destfile = 'uploads/gift/' . util::random(8) . '.' . $extname; file::uploadfile($_FILES['giftfile'], $destfile); util::image_compress($destfile, '', 500, 500, ''); $iamge = util::image_compress($destfile, '', 106, 106, '_s'); $destfile = $iamge['tempurl']; } $_ENV['gift']->edit($id, $title, $credit, $description, $destfile); $this->message($this->view->lang['usermanageOptSuccess'], 'index.php?admin_gift-search'); } }
function dopreview() { $settingsnew = $this->post['settingsnew']; if ($settingsnew['watermarktype'] == 2) { //文字水印 $settingsnew['watermarktext']['size'] = intval($this->post['settingsnew']['watermarktext']['size']); $settingsnew['watermarktext']['angle'] = intval($this->post['settingsnew']['watermarktext']['angle']); $settingsnew['watermarktext']['shadowx'] = intval($this->post['settingsnew']['watermarktext']['shadowx']); $settingsnew['watermarktext']['shadowy'] = intval($this->post['settingsnew']['watermarktext']['shadowy']); $settingsnew['watermarktext']['fontpath'] = str_replace(array('\\', '/'), '', $this->post['settingsnew']['watermarktext']['fontpath']); if ($settingsnew['watermarktype'] == 2 && $settingsnew['watermarktext']['fontpath']) { $fontpath = $settingsnew['watermarktext']['fontpath']; $settingsnew['watermarktext']['fontpath'] = file_exists('./style/default/' . $fontpath) ? $fontpath : (file_exists('./style/default/' . $fontpath) ? $fontpath : ''); if (!$settingsnew['watermarktext']['fontpath']) { $this->message($this->view->lang['watermark_fontpath_error'], 'index.php?admin_setting-watermark'); } } } else { unset($settingsnew['watermarktext']); } if ($settingsnew[watermarkstatus] == '0') { $this->message($this->view->lang['noWaterMark'], ''); } $this->load("watermark"); $pic = "./style/default/watermark/preview.jpg"; $previewpic = "./style/default/watermark/preview_tem.jpg"; @unlink($previewpic); if (!is_file($pic)) { $this->message('预览需要的图片不存在。', ''); } if ($_ENV['watermark']->image($pic, $previewpic, $settingsnew)) { echo '<img src="' . $previewpic . '?' . util::random() . '" />'; } else { $this->message('图片加水印失败,请检查你设置的参数。', ''); } }
function doinstall() { if (isset($this->get[2]) && is_numeric($this->get[2])) { $style_download_url = $this->setting['app_url'] . "/hdapp.php?action=download&type=template&install=1&id=" . $this->get[2] . "&url=" . WIKI_URL; $zipcontent = @util::hfopen($style_download_url); $tmpdir = HDWIKI_ROOT . '/data/tmp/'; file::forcemkdir($tmpdir); $tmpname = $tmpdir . util::random(6) . '.zip'; file::writetofile($tmpname, $zipcontent); require HDWIKI_ROOT . "/lib/zip.class.php"; require HDWIKI_ROOT . "/lib/xmlparser.class.php"; $zip = new zip(); if (!$zip->chk_zip) { $this->message($this->view->lang['styleInstallNoZlib'], ''); } $ziplist = @$zip->get_List($tmpname); if (!(bool) $ziplist) { @unlink($tmpname); $this->message($this->view->lang['styleZipFail'], 'BACK'); } $theme_name = $_ENV['theme']->get_theme_name($ziplist); @$zip->Extract($tmpname, $tmpdir); @unlink($tmpname); //move file $syle_path = $tmpdir . 'hdwiki'; if (is_dir(HDWIKI_ROOT . '/style/' . $theme_name)) { @file::removedir($syle_path); $this->message($this->view->lang['stylePathRepeat'], 'BACK'); } @file::copydir($syle_path, HDWIKI_ROOT); @file::removedir($syle_path); //save db $style_xml = HDWIKI_ROOT . '/style/' . $theme_name . '/desc.xml'; if (!is_file($style_xml)) { $this->message($this->view->lang['styleXmlNotExist'], 'BACK'); } $xmlnav = $_ENV['theme']->read_xml($theme_name); $style['name'] = $xmlnav['name']; $style['copyright'] = $xmlnav['copyright']; $style['path'] = $theme_name; $stylecon = $_ENV['theme']->add_check_style($style['path']); if ($stylecon == null) { $_ENV['theme']->add_style($style); $this->cache->removecache('style'); $this->message($this->view->lang['styleInstallSuccess'], 'BACK'); } else { $this->message($this->view->lang['styleDbPathRepeat'], 'index.php?admin_theme'); } } else { $this->message($this->view->lang['commonParametersInvalidTip'], 'index.php?admin_theme'); } }
function share_plugin($plugin) { $identifier = $plugin['identifier']; $descxml = "<?xml version=\"1.0\" encoding=\"" . WIKI_CHARSET . "\"?>\n" . "<theme>\n" . "<author><![CDATA[" . $plugin['author'] . "]]></author>\n" . "<authorurl><![CDATA[" . $plugin['authorurl'] . "]]></authorurl>\n" . "<name><![CDATA[" . $plugin['name'] . "]]></name>\n" . "<tag><![CDATA[" . $plugin['tag'] . "]]></tag>\n" . "<desc><![CDATA[" . $plugin['description'] . "]]></desc>\n" . "<weburl><![CDATA[" . $plugin['weburl'] . "]]></weburl>\n" . "<version><![CDATA[" . $plugin['version'] . "]]></version>\n" . "<hdversion><![CDATA[" . $plugin['hdversion'] . "]]></hdversion>\n" . "<copyright><![CDATA[" . $plugin['copyright'] . "]]></copyright>\n" . "<charset><![CDATA[" . WIKI_CHARSET . "]]></charset>\n" . "</theme>"; file::writetofile(HDWIKI_ROOT . '/plugins/' . $identifier . '/desc.xml', $descxml); require_once HDWIKI_ROOT . '/lib/zip.class.php'; $zip = new zip(); $filedir = array('plugins/' . $identifier); $zipdir = array($identifier); $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip'; @$zip->zip_dir($filedir, $tmpname, $zipdir); $zip_content = file::readfromfile($tmpname); $upload_url = $this->base->setting['app_url'] . '/hdapp.php?action=upload&type=plugin'; $data = 'data=' . base64_encode($zip_content); if ('1' == @util::hfopen($upload_url, 0, $data)) { unlink($tmpname); return true; } return false; }