Last modified: Tue, 03 Sep 2019 11:26:13 +0900
<html> <head> <META http-equiv="Content-Type" content="text/html;charset=Shift_JIS"> <title>CASH VIEW</title> </head> <body> <?php $passwordfile = $_SERVER['DOCUMENT_ROOT']."/exclusive/password.csv"; $grouplist = array( "food" => "食費", "living" => "日用品", "transportation" => "交通費", "charge" => "公共料金", "other" => "その他", ); function hiddenInput($name, $value) { return "<input type=\"hidden\" name=\"$name\" value=\"$value\" />\n"; } $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 VIEW ($user)</h1>\n"; if ($_SERVER["REQUEST_METHOD"] == "POST") { $group = $_POST["group"]; $purpose = $_POST["purpose"]; $year = $_POST["year"]; $month = $_POST["month"]; $day_m = $_POST["day_m"]; $index_start = $_POST["index_start"]; $amount = $_POST["amount"]; if ($year == "" || $month == "") { echo "<p><font color=\"Red\">検索できませんでした。年と月は必ず指定してください。</font></p>"; } else if (($fp = fopen($datafile, "r")) == false) { echo "<p><font color=\"Red\">検索できませんでした。内部エラー。</font></p>"; } else { $index = 0; $bytes = 0; echo "<dl>\n"; while ($bytes < 500 && ($data = fgetcsv($fp, 1000))) { if (($data[0] == $year + 2000) && ($data[1] == $month) && ($day_m == "" || $data[2] == $day_m) && ($group == "" || $data[3] == $group) && ($purpose == "" || strstr($data[5], $purpose)) && ($index++ >= $index_start)) { echo "<dt>$data[0]/$data[1]/$data[2]</dt><dd>"; $bytes += 23; foreach ($grouplist as $key => $value) { if ($data[3] == $key) { echo "$value "; $bytes += strlen($value); } } echo number_format($data[4]), "円"; $amount += $data[4]; $bytes += 9; if ($data[5] != "") { echo "($data[5])"; $bytes += strlen($data[5]) + 2; } echo "</dd>\n"; } } if (fgetcsv($fp, 1000)) { echo "</dl>\n"; echo "<form action=\"cashview.php\" method=\"POST\">\n"; echo hiddenInput("user", $user); echo hiddenInput("pass", $pass); echo hiddenInput("group", $group); echo hiddenInput("purpose", $purpose); echo hiddenInput("year", $year); echo hiddenInput("month", $month); echo hiddenInput("day_m", $day_m); echo hiddenInput("amount", $amount); echo hiddenInput("index_start", $index); echo "<input type=\"submit\" value=\"5.続き...\" accesskey=\"5\">\n"; echo "</form>\n"; } else if ($bytes == 0) { echo "<dt>見つかりませんでした。</dt></dl>\n"; } else { echo "<dt><b>合計</b></dt><dd><b>", number_format($amount), " 円</b></dd></dl>\n"; } fclose($fp); echo "<hr>\n"; } } else { $year = date("y", time()); $month = date("m", time()); } ?> <form action="cashview.php" method="POST"> <p>検索条件 <br> 費目 <select name="group"> <?php echo "<option value=\"\"", $group == "" ? " selected" : "", ">全ての費目</option>"; foreach ($grouplist as $key => $value) { echo "<option value=\"$key\"", $group == $key ? " selected>" : ">", $value, "</option>"; } ?> </select> <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=\"cashmemo.php?user=$user&pass=$pass\" accesskey=\"3\">3.登録画面へ</a><br>\n"; echo "<a href=\"cashview.php?user=$user&pass=$pass\" accesskey=\"0\">0.検索条件リセット</a></p>\n"; } else { echo "<p><font color=\"Red\">ユーザ名かパスワードが間違っています。</font></p>\n"; } ?> <p><a href="/">ホームに戻る</a></p> </body> </html>