Пример #1
0
} else {
    $o->isactive = 'N';
}
switch ($action) {
    case "create":
        // if the token is exist and not yet expired
        $log->showLog(4, "Accessing create record event, with races name={$o->races_name}");
        if ($s->check(true, $token, "CREATE_RCE")) {
            if ($o->insertRaces()) {
                $latest_id = $o->getLatestRacesID();
                redirect_header("races.php", $pausetime, "Your data is saved, the new id={$latest_id}. Redirect to create new races.");
            } else {
                $log->showLog(1, "Can't create races '{$o->races_name}', please verified your data!");
                $token = $s->createToken($tokenlife, "CREATE_RCE");
                $o->getInputForm("new", -1, $token);
                $o->showRacesTable();
            }
        } else {
            // if the token is not valid or the token is expired, it back to previous form with previous inputed data
            $log->showLog(1, "Can't create races '{$o->races_name}' due to token expired!");
            $token = $s->createToken($tokenlife, "CREATE_RCE");
            $o->getInputForm("new", -1, $token);
            $o->showRacesTable();
        }
        break;
    case "edit":
        if ($o->fetchRaces($o->races_id)) {
            //create a new token for editing a form
            $token = $s->createToken($tokenlife, "CREATE_RCE");
            $o->getInputForm("edit", $o->races, $token);
            $o->showRacesTable();