コード例 #1
0
ファイル: class.main.php プロジェクト: skyser2003/hof
    function FirstLogin()
    {
        // 返値:設定済み=false / 非設定=true
        if ($this->name) {
            return false;
        }
        do {
            if (!$_POST["Done"]) {
                break;
            }
            if (is_numeric(strpos($_POST["name"], "\t"))) {
                $error = 'error1';
                break;
            }
            if (is_numeric(strpos($_POST["name"], "\n"))) {
                $error = 'error';
                break;
            }
            $_POST["name"] = trim($_POST["name"]);
            $_POST["name"] = stripslashes($_POST["name"]);
            if (!$_POST["name"]) {
                $error = 'Name is blank.';
                break;
            }
            $length = strlen($_POST["name"]);
            if (0 == $length || 16 < $length) {
                $error = '1 to 16 letters?';
                break;
            }
            $userName = userNameLoad();
            if (in_array($_POST["name"], $userName)) {
                $error = '该名字已被使用。';
                break;
            }
            // 最初のキャラの名前
            $_POST["first_name"] = trim($_POST["first_name"]);
            $_POST["first_name"] = stripslashes($_POST["first_name"]);
            if (is_numeric(strpos($_POST["first_name"], "\t"))) {
                $error = 'error';
                break;
            }
            if (is_numeric(strpos($_POST["first_name"], "\n"))) {
                $error = 'error';
                break;
            }
            if (!$_POST["first_name"]) {
                $error = 'Character name is blank.';
                break;
            }
            $length = strlen($_POST["first_name"]);
            if (0 == $length || 16 < $length) {
                $error = '1 to 16 letters?';
                break;
            }
            if (!$_POST["fjob"]) {
                $error = 'Select characters job.';
                break;
            }
            $_POST["name"] = htmlspecialchars($_POST["name"], ENT_QUOTES);
            $_POST["first_name"] = htmlspecialchars($_POST["first_name"], ENT_QUOTES);
            $this->name = $_POST["name"];
            userNameAdd($this->name);
            $this->SaveData();
            switch ($_POST["fjob"]) {
                case "1":
                    $job = 1;
                    $gend = 0;
                    break;
                case "2":
                    $job = 1;
                    $gend = 1;
                    break;
                case "3":
                    $job = 2;
                    $gend = 0;
                    break;
                default:
                    $job = 2;
                    $gend = 1;
            }
            include DATA_BASE_CHAR;
            $char = new char();
            $char->SetCharData(array_merge(BaseCharStatus($job), array("name" => $_POST[first_name], "gender" => "{$gend}")));
            $char->SaveCharData($this->id);
            return false;
        } while (0);
        include DATA_BASE_CHAR;
        $war_male = new char();
        $war_male->SetCharData(array_merge(BaseCharStatus("1"), array("gender" => "0")));
        $war_female = new char();
        $war_female->SetCharData(array_merge(BaseCharStatus("1"), array("gender" => "1")));
        $sor_male = new char();
        $sor_male->SetCharData(array_merge(BaseCharStatus("2"), array("gender" => "0")));
        $sor_female = new char();
        $sor_female->SetCharData(array_merge(BaseCharStatus("2"), array("gender" => "1")));
        ?>
	<form action="<?php 
        print INDEX;
        ?>
" method="post" style="margin:15px">
<?php 
        ShowError($error);
        ?>
	<h4>Name of Team</h4>
	<p>Decide the Name of the team.<br />
	It should be more than 1 and less than 16 letters.<br />
	Japanese characters count as 2 letters.</p>
	<p>1-16字符的队伍名。<br /></p>
	<div class="bold u">TeamName</div>
	<input class="text" style="width:160px" maxlength="16" name="name"
<?php 
        print $_POST["name"] ? "value=\"{$_POST['name']}\"" : "";
        ?>
>
	<h4>First Character</h4>
	<p>Decide the name of Your First Charactor.<br>
	more than 1 and less than 16 letters.</p>
	<p>第一个人物的名称。</p>
	<div class="bold u">CharacterName</div>
	<input class="text" type="text" name="first_name" maxlength="16" style="width:160px;margin-bottom:10px">
	<table cellspacing="0" style="width:400px"><tbody>
	<tr><td class="td1" valign="bottom"><div style="text-align:center"><?php 
        print $war_male->ShowImage();
        ?>
<br><input type="radio" name="fjob" value="1" style="margin:3px"></div></td>
	<td class="td1" valign="bottom"><div style="text-align:center"><?php 
        print $war_female->ShowImage();
        ?>
<br><input type="radio" name="fjob" value="2" style="margin:3px"></div></td>
	<td class="td1" valign="bottom"><div style="text-align:center"><?php 
        print $sor_male->ShowImage();
        ?>
<br><input type="radio" name="fjob" value="3" style="margin:3px"></div></td>
	<td class="td1" valign="bottom"><div style="text-align:center"><?php 
        print $sor_female->ShowImage();
        ?>
<br><input type="radio" name="fjob" value="4" style="margin:3px"></div></td></tr>
	<tr><td class="td2"><div style="text-align:center">male</div></td><td class="td3"><div style="text-align:center">female</div></td>
	<td class="td2"><div style="text-align:center">male</div></td><td class="td3"><div style="text-align:center">female</div></td></tr>
	<tr><td colspan="2" class="td4"><div style="text-align:center">Warrior</div></td><td colspan="2" class="td4"><div style="text-align:center">Socerer</div></td></tr>
	</tbody></table>
	<p>Choose your first character's job & Gender.</p>
	<p>最初的人物性别与职业</p>
	<input class="btn" style="width:160px" type="submit" value="Done" name="Done">
	<input type="hidden" value="1" name="Done">
	<input class="btn" style="width:160px" type="submit" value="logout" name="logout"></form>
<?php 
        return true;
    }
コード例 #2
0
ファイル: list_char.php プロジェクト: skyser2003/Hall-of-Fame
include "./class/class.char.php";
include "./class/global.php";
$folder = glob("./user/*");
//print("<pre>".print_r($folder,1)."</pre>");
foreach ($folder as $val) {
    $UserFile = glob($val . "/*.dat");
    foreach ($UserFile as $FileName) {
        $file = basename($FileName, ".dat");
        if (is_numeric($file)) {
            $chars[] = $FileName;
        }
    }
    //print("<pre>".print_r($UserFile,1)."</pre>");
}
print '<table border="0" cellspacing="1"><tbody>';
foreach ($chars as $file) {
    $char = new char(ParseFile($file));
    print "<tr><td>";
    $char->ShowImage();
    print "</td><td>";
    print $char->Name(bold);
    print "</td><td>";
    print "Lv:" . $char->level;
    print "</td><td>";
    print "Str:{$char->str}<br />Int:{$char->int}<br />Dex:{$char->dex}<br />Spd:{$char->spd}";
    print "</td></tr>";
}
print "</tbody></table>";
?>
</body>
</html>