function check_input_errors($edit) { $errors = array(); if (!validate_nonhtml($edit['name'])) { $errors[] = "A valid league name must be entered"; } if (!validate_yyyymmdd_input($edit['roster_deadline'])) { $errors[] = 'You must provide a valid roster deadline'; } switch ($edit['schedule_type']) { case 'none': case 'roundrobin': break; case 'ratings_ladder': case 'ratings_wager_ladder': if ($edit['games_before_repeat'] == null || $edit['games_before_repeat'] == 0) { $errors[] = "Invalid 'Games Before Repeat' specified!"; } break; default: $errors[] = "Values for allow schedule are none, roundrobin, ratings_ladder, and ratings_wager_ladder"; } if ($edit['schedule_type'] != 'none') { if (!$edit['day']) { $errors[] = "One or more days of play must be selected"; } } if (!validate_number($edit['finalize_after']) || $edit['finalize_after'] < 0) { $errors[] = "A valid number must be entered for the game finalization delay"; } return $errors; }
function validate_score_value($string) { if (!validate_number($string)) { return false; } return $string >= 0; }
return $max; } else { return $input; } } else { return $default; } } $csv_file = escapeshellarg($_FILES['csv_file']['tmp_name']); $report_dir = get_report_dir(); $width = validate_number($_POST['width'], 64, 1024, 512); $height = validate_number($_POST['height'], 64, 1024, 192); $disk_limit = validate_number($_POST['disk_limit'], 0, PHP_INT_MAX, 0); $net_limit = validate_number($_POST['net_limit'], 0, PHP_INT_MAX, 0); $offset = validate_number($_POST['offset'], 0, PHP_INT_MAX, 0); $duration = validate_number($_POST['duration'], 0, PHP_INT_MAX, 0); $message = ''; if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) { exec("perl dstat2graphs.pl {$csv_file} {$report_dir} {$width} {$height} {$disk_limit} {$net_limit} {$offset} {$duration} 2>&1", $output, $return_var); if ($return_var == 0) { header("Location: {$report_dir}/"); exit; } else { foreach ($output as $line) { $message .= htmlspecialchars($line) . "<br />\n"; } } } else { if ($_FILES['csv_file']['error'] == UPLOAD_ERR_INI_SIZE || $_FILES['csv_file']['error'] == UPLOAD_ERR_FORM_SIZE) { $message = "File size limit exceeded.\n"; } else {
function check_input_errors($edit) { $errors = array(); if (!validate_nonhtml($edit['name'])) { $errors[] = 'Name cannot be left blank, and cannot contain HTML'; } if (!validate_currency_code($edit['currency_code'])) { $errors[] = 'You must provide a valid currency code'; } if (!validate_number($edit['cost'])) { $errors[] = 'Invalid cost: not a number'; } else { if ($edit['cost'] < 0) { $errors[] = 'Invalid cost: cannot be negative'; } } if (!validate_number($edit['gst'])) { $errors[] = 'Invalid GST: not a number'; } else { if ($edit['gst'] < 0) { $errors[] = 'Invalid GST: cannot be negative'; } } if (!validate_number($edit['pst'])) { $errors[] = 'Invalid PST: not a number'; } else { if ($edit['pst'] < 0) { $errors[] = 'Invalid PST: cannot be negative'; } } if (!validate_yyyymmdd_input($edit['open_date'])) { $errors[] = 'You must provide a valid open date'; } if (!validate_yyyymmdd_input($edit['close_date'])) { $errors[] = 'You must provide a valid close date'; } if (!validate_number($edit['cap_male'])) { $errors[] = 'Invalid male cap: not a number'; } else { if ($edit['cap_male'] < -1) { $errors[] = 'Invalid male cap: cannot be less than -1'; } } if (!validate_number($edit['cap_female'])) { $errors[] = 'Invalid female cap: not a number'; } else { if ($edit['cap_female'] < -2) { $errors[] = 'Invalid female cap: cannot be less than -2'; } else { if ($edit['cap_female'] == -2 && $edit['cap_male'] <= 0) { $errors[] = 'Invalid female cap: can only be -2 if male cap is > 0'; } } } return $errors; }
function isDataInvalid($edit) { $errors = ""; if (!validate_number($edit['num'])) { $errors .= "<li>Number of field must be provided"; } $rating = field_rating_values(); if (!array_key_exists($edit['rating'], $rating)) { $errors .= "<li>Rating must be provided"; } if ($edit['parent_fid'] > 0) { if (!validate_number($edit['parent_fid'])) { $errors .= "<li>Parent must be a valid value"; return $errors; } if ($edit['parent_fid'] == $this->field->fid) { $errors .= "<li>Field cannot be a parent of itself!"; return $errors; } return false; } if (!validate_nonhtml($edit['name'])) { $errors .= "<li>Name cannot be left blank, and cannot contain HTML"; } if (!validate_nonhtml($edit['code'])) { $errors .= "<li>Code cannot be left blank and cannot contain HTML"; } if (!validate_nonhtml($edit['region'])) { $errors .= "<li>Region cannot be left blank and cannot contain HTML"; } if (validate_nonblank($edit['location_url'])) { if (!validate_nonhtml($edit['location_url'])) { $errors .= "<li>If you provide a location URL, it must be valid."; } } if (validate_nonblank($edit['layout_url'])) { if (!validate_nonhtml($edit['layout_url'])) { $errors .= "<li>If you provide a site layout URL, it must be valid."; } } if (strlen($errors) > 0) { return $errors; } else { return false; } }
function check_input_errors($edit = array()) { $errors = array(); if (!validate_number($edit['num'])) { $errors[] = "Number of field must be provided"; } $rating = field_rating_values(); if (!array_key_exists($edit['rating'], $rating)) { $errors[] = "Rating must be provided"; } if ($edit['parent_fid'] > 0) { if (!validate_number($edit['parent_fid'])) { $errors[] = "Parent must be a valid value"; } return $errors; } if (!validate_nonhtml($edit['name'])) { $errors[] = "Name cannot be left blank, and cannot contain HTML"; } if (!validate_nonhtml($edit['code'])) { $errors[] = "Code cannot be left blank and cannot contain HTML"; } if (!validate_nonhtml($edit['region'])) { $errors[] = "Region cannot be left blank and cannot contain HTML"; } if (validate_nonblank($edit['location_url'])) { if (!validate_nonhtml($edit['location_url'])) { $errors[] = "If you provide a location URL, it must be valid."; } } if (validate_nonblank($edit['layout_url'])) { if (!validate_nonhtml($edit['layout_url'])) { $errors[] = "If you provide a site layout URL, it must be valid."; } } return $error; }
function isDataInvalid($games) { if (!is_array($games)) { return "Invalid data supplied for games"; } $rc = true; $seen_slot = array(); $seen_team = array(); foreach ($games as $game) { if (!validate_number($game['game_id'])) { return "Game entry missing a game ID"; } if (!validate_number($game['slot_id'])) { return "Game entry missing field ID"; } if ($game['slot_id'] == 0) { return "You cannot choose the '---' as the game time/place!"; } if (in_array($game['slot_id'], $seen_slot)) { return "Cannot schedule the same gameslot twice"; } else { $seen_slot[] = $game['slot_id']; } $seen_team[$game['home_id']]++; $seen_team[$game['away_id']]++; if (!validate_number($game['home_id'])) { return "Game entry missing home team ID"; } if (!validate_number($game['away_id'])) { return "Game entry missing away team ID"; } if ($seen_team[$game['home_id']] > 1 || $seen_team[$game['away_id']] > 1) { // TODO: Needs to be fixed to deal with doubleheader games. return "Cannot schedule a team to play two games at the same time"; } if ($game['home_id'] != 0 && $game['home_id'] == $game['away_id']) { return "Cannot schedule a team to play themselves."; } // TODO Check the database to ensure that no other game is // scheduled on this field for this timeslot } return false; }
} else { return $input; } } else { return $default; } } $csv_file = escapeshellarg($_FILES['csv_file']['tmp_name']); $report_dir = get_report_dir(); $width = validate_number($_POST['width'], 64, 1024, 512); $height = validate_number($_POST['height'], 64, 1024, 192); $requests_limit = validate_number($_POST['requests_limit'], 0, PHP_INT_MAX, 0); $bytes_limit = validate_number($_POST['bytes_limit'], 0, PHP_INT_MAX, 0); $qlength_limit = validate_number($_POST['qlength_limit'], 0, PHP_INT_MAX, 0); $wtime_limit = validate_number($_POST['wtime_limit'], 0, PHP_INT_MAX, 0); $stime_limit = validate_number($_POST['stime_limit'], 0, PHP_INT_MAX, 0); $message = ''; if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) { exec("perl iostat2graphs.pl {$csv_file} {$report_dir} {$width} {$height} {$requests_limit} {$bytes_limit} {$qlength_limit} {$wtime_limit} {$stime_limit} 2>&1", $output, $return_var); if ($return_var == 0) { header("Location: {$report_dir}/"); exit; } else { foreach ($output as $line) { $message .= htmlspecialchars($line) . "<br />\n"; } } } else { if ($_FILES['csv_file']['error'] == UPLOAD_ERR_INI_SIZE || $_FILES['csv_file']['error'] == UPLOAD_ERR_FORM_SIZE) { $message = "File size limit exceeded.\n"; } else {
function isDataInvalid($games) { if (!is_array($games)) { return "Invalid data supplied for games"; } $rc = true; $seen_slot = array(); $seen_team = array(); foreach ($games as $game) { if (!validate_number($game['game_id'])) { return "Game entry missing a game ID"; } if (!validate_number($game['slot_id'])) { return "Game entry missing field ID"; } if ($game['slot_id'] == 0) { return "You cannot choose the '---' as the game time/place!"; } if (in_array($game['slot_id'], $seen_slot)) { return "Cannot schedule the same gameslot twice"; } else { $seen_slot[] = $game['slot_id']; } if (!validate_number($game['home_id'])) { return "Game entry missing home team ID"; } if (!validate_number($game['away_id'])) { return "Game entry missing away team ID"; } $tmp_teams = array($game['home_id'], $game['away_id']); if (array_key_exists($game['home_id'], $seen_team) || array_key_exists($game['away_id'], $seen_team)) { $new_slot = GameSlot::load(array('slot_id' => $game['slot_id'])); foreach ($tmp_teams as $team_id) { if (!array_key_exists($seen_team[$team_id])) { continue; } foreach ($seen_team[$team_id] as $existing_slot_id) { $exist_slot = GameSlot::load(array('slot_id' => $existing_slot_id)); if ($new_slot->overlaps_with($exist_slot)) { return "Cannot schedule team {$team_id} to play two games at the same time"; } } } } if ($game['home_id'] != 0 && $game['home_id'] == $game['away_id']) { return "Cannot schedule a team to play themselves."; } // Set up datastructure for avoiding game overlaps foreach ($tmp_teams as $team_id) { if (!array_key_exists($team_id, $seen_team)) { $seen_team[$team_id] = array(); } array_push($seen_team[$team_id], $game['slot_id']); } // TODO Check the database to ensure that no other game is // scheduled on this field for this timeslot } return false; }