Esempio n. 1
0
         }
     }
 }
 if ($canEdit) {
     // Check that user can edit this property
     $errors = array();
     // Check if post values are set. If false, user has opened page the first time
     if (isset($_POST['day1']) || isset($_POST['time1']) || isset($_POST['day2']) || isset($_POST['time2'])) {
         require $relative . 'data/php/user/validate.inc';
         if ($_POST['day1'] != '') {
             // Day selected, check if time is valid
             validate_time($errors, $_POST['time1'], 'day1');
         }
         if ($_POST['day2'] != '') {
             // Day selected, check if time is valid
             validate_time($errors, $_POST['time2'], 'day2');
         }
         if ($_POST['day1'] == $_POST['day2'] && $_POST['time1'] == $_POST['time2'] && ($_POST['day1'] != '' && $_POST['time1'] != '')) {
             // Cannot set simultaneous inspections
             $errors['day2'] = 'Cannot set simultaneous inspections';
         }
         if (!isset($errors['day1']) && !isset($errors['day2'])) {
             // form is valid
             if ($_POST['day1'] == '' && $_POST['day2'] != '') {
                 // Second inspection set, but not first
                 $day1 = intval($_POST['day2']);
                 $time1 = $_POST['time2'] . ':00';
                 $day2 = null;
                 $time2 = null;
             } else {
                 if ($_POST['day1'] == '') {
Esempio n. 2
0
$avg_rpms = $_POST["avg_rpms"];
$calsburned = array($_POST["s_calsburned"], $_POST["b_calsburned"], $_POST["r_calsburned"], 0);
$updatingswim = $_POST["updatingswim"];
$updatingbike = $_POST["updatingbike"];
$updatingrun = $_POST["updatingrun"];
$updatingblognotes = $_POST["updatingblognotes"];
$blog_notes = $_POST["blog_notes"];
for ($i = 0; $i < 3; $i++) {
    // Validate data.
    if (!validate_date($workout_date[$i])) {
        $error[$i] = true;
    }
    if (!validate_time($workout_time[$i])) {
        $error[$i] = true;
    }
    if (!validate_time($duration[$i])) {
        $error[$i] = true;
    }
    if (!validate_distance($distance[$i])) {
        $error[$i] = true;
    }
    if (!validate_notes($notes[$i])) {
        $error[$i] = true;
    }
    if (!validate_heartrate($min_hr[$i])) {
        $error[$i] = true;
    }
    if (!validate_heartrate($avg_hr[$i])) {
        $error[$i] = true;
    }
    if (!validate_heartrate($max_hr[$i])) {
/**
 * Validation of a date/time which checks if the string passed is a valid date and time.
 * **Allowed date formats**
 *
 * - `d-m-y` 31-12-2014 separators can be a period, dash, forward slash, but not allow space
 * - `m-d-y` 12-31-2014 separators can be a period, dash, forward slash, but not allow space
 * - `y-m-d` 2014-12-31 separators can be a period, dash, forward slash, but not allow space
 *
 * @param string $value The date/time string being checked
 * @param string $dateFormat The date format only to be validated against. Default is y-m-d for 2014-12-31.
 * @param string $timeFormat The time format: 12, 24 or both
 *
 * @return bool TRUE on success; FALSE on failure
 */
function validate_datetime($value, $dateFormat = 'y-m-d', $timeFormat = 'both')
{
    if (empty($value)) {
        return true;
    }
    $value = trim($value);
    $generalPattern = '/^([\\d]{1,4}[-\\/.][\\d]{1,2}[-\\/.][\\d]{1,4})(\\s+.{4,}\\s*(am|pm)?)$/i';
    if (preg_match_all($generalPattern, $value, $matches)) {
        $date = $matches[1][0];
        $time = $matches[2][0];
        return validate_date($date, $dateFormat) && validate_time($time, $timeFormat);
    } else {
        return false;
    }
}
Esempio n. 4
0
     require "partials/_schedule_form.php";
     echo "</form>\n        <div class=\"footnote\">** if any links are over 128 characters: use <a href=\"http://www.bit.ly\" target=_new>bit.ly</a> to shorten the url</div>";
 } elseif ($action == "copy") {
     echo "<form action=\"schedule_add.php?id=" . $id . "\" method=\"post\" class=\"form-internal inline input-seperation\" id=\"admin\">";
     require "partials/_schedule_form.php";
     echo "</form>\n        <div class=\"footnote\">** if any links are over 128 characters: use <a href=\"http://www.bit.ly\" target=_new>bit.ly</a> to shorten the url</div>";
 } else {
     $host = $_POST['host'];
     $date = $_POST['date'];
     $start_time_submit = $_POST['start_time_submit'];
     $end_time_submit = $_POST['end_time_submit'];
     $start_time = $_POST['end_time'];
     $end_time = $_POST['end_time'];
     $note = $_POST['note'];
     $start_time = validate_time($start_time_submit, $id, "start_time");
     $end_time = validate_time($end_time_submit, $id, "end_time");
     if (!$host || !$date || !$start_time || !$end_time) {
         echo '<div class="top-spacer_20 center error">Error - missing required value(s)</div>';
     } else {
         $result = update_schedule($id, $host, $date, $start_time, $end_time, $note);
         if ($result) {
             echo '<div class="top-spacer_20 center"><h1>Update was successful!</h1>';
             display_schedule(get_schedule($id));
             echo "</div>";
         }
     }
 }
 ?>
 <div class="top-spacer_20">
   <a href="schedule_view_all.php">View all Schedules</a>
   <p>
 */
function validate_time($time)
{
    return preg_match("/(((^[0-9]{1})|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9])/", $time, $regs) ? true : false;
}
$TID = $_GET['tid'];
$txtcommand = $_GET['txtcommand'];
$slctTMonth = $_GET['slctTMonth'];
$slctTDay = $_GET['slctTDay'];
$slctTYear = $_GET['slctTYear'];
$txtTStartTime = $_GET['txtTStartTime'];
$bInvalidDate = false;
$TIME = "";
if ($txtcommand != "") {
    if ($slctTMonth != "-" && $slctTDay != "-" && $slctTYear != "-" && $txtTStartTime != "") {
        if (validate_time($txtTStartTime)) {
            list($hour, $minute, $second) = explode(":", $txtTStartTime);
            $time = mktime(intval($hour), intval($minute), intval($second), intval($slctTMonth), intval($slctTDay), intval($slctTYear));
            $TIME = $time;
        } else {
            $bInvalidDate = true;
            $txtcommand = "";
        }
    }
}
if ($txtcommand != "") {
    if ($txtcommand == 0) {
        $oR3DCQuery->AcceptTournamentproposal($config, $TID);
    }
    if ($txtcommand == 1) {
        $oR3DCQuery->RevokeTournamentproposal($config, $TID);