function validate_max_lengths($fields_with_max_lengths)
{
    global $errors;
    foreach ($fields_with_max_lengths as $field => $max) {
        $value = trim($_POST[$field]);
        if (!has_max_length($value, $max)) {
            $errors[$field] = fieldname_as_text($field) . " is to long";
        }
    }
}
function validate_presences($required_fields)
{
    global $errors;
    foreach ($required_fields as $field) {
        $value = trim($_POST[$field]);
        if (!has_presence($value)) {
            $errors[$field] = fieldname_as_text($field) . " can't be blank";
        }
    }
}
示例#3
0
function validate_presences($required_fields)
{
    global $errors;
    foreach ($required_fields as $field) {
        $value = trim($_POST[$field]);
        if (!has_precence($value)) {
            $errors[$field] = fieldname_as_text($field) . " mag niet leeg zijn.";
        }
    }
}
function validate_phone($field)
{
    global $errors;
    if (ctype_digit($_POST[$field])) {
        return 1;
    } else {
        $errors[$field] = fieldname_as_text($field) . " must be a series of digits";
        return 0;
    }
}
function validate_max_lengths($fields_with_max_length)
{
    global $errors;
    // Using an assoc array
    foreach ($fields_with_max_length as $field => $max) {
        $value = trim($_POST[$field]);
        if (!has_max_length($value, $max)) {
            $errors[$field] = fieldname_as_text($field) . " is too long.";
        }
    }
}
function validate_max_lengths($fields_with_max_length)
{
    // variable: is a assoc. array (dict, from python)
    global $errors;
    foreach ($fields_with_max_length as $field => $max) {
        $value = trim($_POST[$field]);
        if (!has_max_length($value, $max)) {
            $errors[$field] = fieldname_as_text($field) . " is too long";
        }
    }
}
function validate_min_lengths($fields_with_min_lengths)
{
    global $errors;
    //Using an assoc. array
    foreach ($fields_with_min_lengths as $field => $min) {
        $value = trim($_POST[$field]);
        if (has_min_length($value, $min) && $value !== "" && isset($value)) {
            $errors[] = fieldname_as_text($field) . " is too short";
        }
    }
}
示例#8
0
function check_date_vs_now($str_time, $warning_me = false)
{
    // attention contrairement aux autres validation $warning_me part défaut true
    // pour error  rajouter false en appellant la fonction après la date
    global $errors;
    global $warnings;
    $unix_time_date = strtotime($str_time);
    $unix_time_now = strtotime('now');
    $date_input = strftime("%Y-%m-%d", $unix_time_date);
    $date_now = strftime("%Y-%m-%d", $unix_time_now);
    list($date_fr, $date_fr_short, $date_fr_long, $date_fr_hr, $date_fr_short_hr, $date_fr_long_hr, $date_fr_full_hr) = date_fr($date_input);
    $date_input_fr = $date_fr_short;
    list($date_fr, $date_fr_short, $date_fr_long, $date_fr_hr, $date_fr_short_hr, $date_fr_long_hr, $date_fr_full_hr) = date_fr($date_now);
    $date_now_fr = $date_fr_short;
    $field = "Attention date";
    $msg = "";
    $text_array = "";
    $text_return = "Attention la date est au <strong>{$date_input_fr}</strong> aujourd'hui est <strong>{$date_now_fr}</strong>. Assurez-vous si nécéssaire de rentrer la bonne date ";
    if ($date_input === $date_now) {
        return null;
    } else {
        if ($warning_me) {
            $warnings[$field] = fieldname_as_text($field) . " car elle n'est pas aujourd'hui. Assurez-vous de changer la date si nécéssaire ";
            return $text_return;
        } else {
            $errors[$field] = fieldname_as_text($field) . " car elle n'est pas aujourd'hui. Assurez-vous de changer la date si nécéssaire ";
            return $text_return;
        }
    }
}
if ($validated_chauffeur == 2) {
    $required_fields = array("course_date", "heure", "pseudo");
} else {
    $required_fields = array("course_date", "chauffeur", "heure", "pseudo", "depart", "arrivee");
}
validate_presences_non_post($required_fields, $program);
$pseudo = $program["pseudo"];
$pseudo_autres = $program["pseudo_autres"];
$nom_patient = $program["nom_patient"];
$prix_course = $program["prix_course"];
$chauffeur = $program["chauffeur"];
if ($validated_chauffeur === 0) {
    $errors["validation_chauffeur"] = fieldname_as_text($field) . " doit etre auparavant validé ou annulé par chauffeur avant manager!";
}
if ($validated_mgr === 0) {
    $errors["validation_manager"] = fieldname_as_text($field) . " doit etre auparavant validé ou annulé par chauffeur avant manager!";
}
if (!$validated_chauffeur == 2) {
    validate_pseudo($pseudo, $pseudo_autres, $nom_patient);
    validate_chauffeur_by_name($chauffeur);
    validation_pseudo_clients($pseudo);
}
if (!empty($errors)) {
    $_SESSION["errors"] = $errors;
    //  redirect_to("manage_program.php");
    redirect_to($url);
}
if (empty($errors)) {
    $id = $program["id"];
    settype($id_valid, "integer");
    if ($validated_final === 1) {
		<a href="logout.php">&laquo; Logout</a><br>
		<a href="manage_content.php">&laquo; Main Menu</a><br />
		<?php 
echo navigation($current_subject, $current_page);
?>
	</div>
	<div id="page">	
		<?php 
echo message();
if ($sort_mode != "name_of_work" && $sort_mode != "agency" && $sort_mode != "client" && $sort_mode != "head_of_account") {
    $sort_mode = "name_of_work";
}
?>
		 <div class="container">
		<h1>List of Projects sorted by <?php 
echo fieldname_as_text($sort_mode);
?>
</h1><hr/>
		<div id="view_list">
		<?php 
$query = "SELECT * FROM projects ORDER BY {$sort_mode}";
$result = mysqli_query($connection, $query);
$count = 1;
echo "<table width=1000 cellpadding=5 style=\"text-align: left;\"";
echo "<tr>";
echo "<td>Sl No.</td>";
echo "<td>Name of Work</td>";
echo "<td>Agency</td>";
echo "<td>Client</td>";
echo "<td>Head of Account</td>";
echo "<td>Date of Start</td>";