コード例 #1
0
ファイル: checkdata.lib.php プロジェクト: mmr/b1n
function b1n_checkDateHour($month, $day, $year, $hour, $min, $mandatory = false)
{
    return b1n_checkDate($month, $day, $year, $mandatory) && b1n_checkHour($hour, $min, $mandatory);
}
コード例 #2
0
ファイル: reg.lib.php プロジェクト: mmr/b1n
function b1n_regCheckChange($sql, &$ret_msgs, $reg_data, $reg_config)
{
    $ret = true;
    foreach ($reg_config as $t => $r) {
        $msg = "";
        switch ($r['check']) {
            case "none":
                if ($r['mand'] && empty($reg_data[$r['reg_data']]) && $r['type'] != 'password') {
                    $msg = "Please, fill the <b>" . $t . "</b> field.";
                }
                break;
            case "numeric":
                if (!b1n_checkNumeric($reg_data[$r["reg_data"]], $r['mand'])) {
                    $msg = "Invalid <b>" . $t . "</b> (Only numbers are allowed).";
                }
                break;
            case "date":
                if (!b1n_checkDate($reg_data[$r["reg_data"]]["month"], $reg_data[$r["reg_data"]]["day"], $reg_data[$r["reg_data"]]["year"], $r['mand'])) {
                    $msg = "Invalid date in <b>" . $t . "</b>.";
                }
                break;
            case "date_hour":
                if (!b1n_checkDate($reg_data[$r["reg_data"]]["month"], $reg_data[$r["reg_data"]]["day"], $reg_data[$r["reg_data"]]["year"], $reg_data[$r["reg_data"]]["hour"], $reg_data[$r["reg_data"]]["min"], $r['mand'])) {
                    $msg = "Invalid date/hour in <b>" . $t . "</b>.";
                }
                break;
            case "email":
                if (!b1n_checkEmail($reg_data[$r["reg_data"]])) {
                    $msg = "Invalid <b>" . $t . "</b> (Example: user@domain.org).";
                }
                break;
            case "length":
                if (strlen($reg_data[$r["reg_data"]]) > $r["extra"]["maxlen"]) {
                    $msg = "No more than '" . $r["extra"]["maxlen"] . "' characters are allowed in <b>" . $t . "</b>";
                }
                break;
            case "radio":
                if (!b1n_checkFilled($reg_data[$r["reg_data"]])) {
                    $msg = "Please, choose something on <b>" . $t . "</b>.";
                }
                break;
            case "boolean":
                if (!b1n_checkBoolean($reg_data[$r["reg_data"]], $r['mand'])) {
                    $msg = "Please, choose something on <b>" . $t . "</b>.";
                }
                break;
            case "unique":
                if ($r['mand'] && empty($reg_data[$r['reg_data']])) {
                    $msg = "Please, fill the <b>" . $t . "</b> field.";
                    break;
                }
                $query = "SELECT " . $reg_config['ID']['db'] . " AS id FROM \"" . $r['extra']['table'] . "\" WHERE " . $r['db'] . " = '" . b1n_inBd($reg_data[$r["reg_data"]]) . "' AND " . $reg_config['ID']['db'] . " != '" . b1n_inBd($reg_data["id"]) . "'";
                $rs = $sql->singleQuery($query);
                if (is_array($rs)) {
                    global $page1_title;
                    $msg = "There is already one " . $page1_title . " with this <b>" . $t . "</b>.";
                    unset($page1_title);
                }
                break;
            case "fk":
                if (is_array($reg_data[$r['reg_data']]) && $r['mand'] && !sizeof($reg_data[$r['reg_data']])) {
                    $msg = "Please, select something in <b>" . $t . "</b>.";
                } else {
                    if (!b1n_checkNumeric($reg_data[$r["reg_data"]], $r['mand'])) {
                        $msg = "Please, select something in <b>" . $t . "</b>.";
                    }
                }
                break;
            case "hour":
                if (isset($reg_data[$r["reg_data"]]["hour"])) {
                    if (!b1n_checkHour($reg_data[$r["reg_data"]]["hour"], $reg_data[$r["reg_data"]]["min"], $r["mand"])) {
                        $msg = "Invalid Hour/Minute in <b>" . $t . "</b>.";
                    }
                }
                break;
        }
        if (!empty($msg)) {
            b1n_retMsg($ret_msgs, b1n_FIZZLES, $msg);
            $ret = false;
        }
    }
    return $ret;
}