コード例 #1
0
ファイル: schedule.php プロジェクト: koguma22/public
<?php

require "CalendarDB.php";
try {
    $dbh = new CalendarDB();
} catch (Exception $e) {
    die("カレンダーDBに繋がらない (" . $e->getMessage() . ")");
}
if (isset($_POST["ok"]) || isset($_POST["cancel"])) {
    $year = $_POST["y"];
    $month = $_POST["m"];
    $day = $_POST["d"];
    $item = $_POST["item"];
    if (isset($_POST["ok"])) {
        $dbh->set_schedule($year, $month, $day, $item);
    }
    $url = "calendar.php?year={$year}&month={$month}";
    header("location: {$url}");
    exit;
}
function check_params($y, $m, $d)
{
    if (!ctype_digit("{$y}")) {
        return "年 '{$y}' に数字ではない文字があります";
    }
    if (!ctype_digit("{$m}")) {
        return "月 '{$m}' に数字ではない文字があります";
    }
    if (!ctype_digit("{$d}")) {
        return "日 '{$d}' に数字ではない文字があります";
    }
コード例 #2
0
ファイル: calendar.php プロジェクト: koguma22/public
<?php

require "CalendarDB.php";
$error = "";
try {
    $dbh = new CalendarDB();
} catch (Exception $e) {
    $error .= "カレンダーDBに繋がらない (" . $e->getMessage() . ")<br/>";
}
function check_params($y, $m)
{
    if (!ctype_digit("{$y}")) {
        return "年 '{$y}' に数字ではない文字があります";
    }
    if (!ctype_digit("{$m}")) {
        return "月 '{$m}' に数字ではない文字があります";
    }
    if (!checkdate($m, 1, $y)) {
        return "{$y}年{$m}月は不正です";
    }
    return true;
}
$t = time();
$year = $y = date("Y", $t);
$month = $m = date("m", $t);
if (isset($_REQUEST["year"])) {
    $y = $_REQUEST["year"];
}
if (isset($_REQUEST["month"])) {
    $m = $_REQUEST["month"];
}