Last modified: Tue, 03 Sep 2019 11:25:42 +0900
<html> <head> <META http-equiv="Content-Type" content="text/html;charset=Shift_JIS"> <title>CASH MEMO</title> </head> <body> <?php $passwordfile = $_SERVER['DOCUMENT_ROOT']."/exclusive/password.csv"; $grouplist = array( "food" => "食費", "living" => "日用品", "transportation" => "交通費", "charge" => "公共料金", "other" => "その他", ); $user = $_GET["user"]; if ($user == "") $user = $_POST["user"]; $pass = $_GET["pass"]; if ($pass == "") $pass = $_POST["pass"]; $datafile = ""; if ($fp = fopen($passwordfile, "r")) { while ($data = fgetcsv($fp, 1000)) { if (trim($data[0]) == $user && trim($data[1]) == $pass) { $datafile = $_SERVER['DOCUMENT_ROOT'].trim($data[2]); } } fclose($fp); } if ($datafile != "") { echo "<h1>CASH MEMO ($user)</h1>\n"; if ($_SERVER["REQUEST_METHOD"] == "POST") { $group = $_POST["group"]; $money = $_POST["money"]; $purpose = $_POST["purpose"]; $year = $_POST["year"]; $month = $_POST["month"]; $day_m = $_POST["day_m"]; if (checkdate($month, $day_m, $year + 2000) == false) { echo "<p><font color=\"Red\">登録できませんでした。日付が間違っています。</font></p>"; } else if ($money < 1) { echo "<p><font color=\"Red\">登録できませんでした。金額が間違っています。</font></p>"; } else { if (($fp = fopen($datafile, "a")) == false) { echo "<p><font color=\"Red\">登録できませんでした。内部エラー。</font></p>"; } else { $year4 = $year + 2000; fputs($fp, "$year4, $month, $day_m, " ."$group, $money, $purpose\r\n"); fclose($fp); echo "<p>登録しました。</p><hr>"; $group = "food"; $money = ""; $purpose = ""; } } } else { $group = "food"; $money = ""; $purpose = ""; $year = date("y", time()); $month = date("m", time()); $day_m = date("d", time()); } ?> <form action="cashmemo.php" method="POST"> <p>新規登録<br> <select name="group"> <?php foreach ($grouplist as $key => $value) { echo "<option value=\"$key\"", $group == $key ? " selected>" : ">", $value, "</option>"; } ?> </select> <?php echo "<input type=\"text\" name=\"money\" size=\"6\" maxlength=\"6\" value=\"$money\" istyle=\"4\" />円"; ?> <br> 摘要 <?php echo "<input type=\"text\" name=\"purpose\" size=\"16\" maxlength=\"100\" value=\"$purpose\" />"; ?> <br> <?php echo "20<input type=\"text\" name=\"year\" size=\"2\" maxlength=\"2\" value=\"$year\" istyle=\"4\" />年"; echo "<input type=\"text\" name=\"month\" size=\"2\" maxlength=\"2\" value=\"$month\" istyle=\"4\" />月"; echo "<input type=\"text\" name=\"day_m\" size=\"2\" maxlength=\"2\" value=\"$day_m\" istyle=\"4\" />日"; echo "<input type=\"hidden\" name=\"user\" value=\"$user\" />", "<input type=\"hidden\" name=\"pass\" value=\"$pass\" />\n"; ?> <br><input type="submit" value="1.登録" accesskey="1" /> </form> <?php echo "<p><a href=\"cashview.php?user=$user&pass=$pass\" accesskey=\"3\">3.検索画面へ</a><br>\n"; echo "<a href=\"cashmemo.php?user=$user&pass=$pass\" accesskey=\"0\">0.登録画面リセット</a></p>\n"; echo "<p><a href=\"mailto:?subject=CASHMEMO&", "body=http://masasoft.ddo.jp/hgw/cashmemo.php%3F", "user=$user%26pass=$pass\">このURLをメール送信</a></p>\n"; } else { echo "<p><font color=\"Red\">ユーザ名かパスワードが間違っています。</font></p>\n"; } ?> <p><a href="/">ホームに戻る</a></p> </body> </html>