function validate_max_length($fields_with_max_lengths)
{
    global $errors;
    foreach ($fields_with_max_lengths as $field => $max) {
        $value = trim($_POST[$field]);
        if (max_length($value, $max)) {
            $errors[$field] = fieldname_as_text($field) . " is too long";
        }
    }
}
Esempio n. 2
0
<p>Let op: indien niet lokaal uitgevoerd, kunnen bestanden op amsterdamopendata.nl onterecht als 404 gezien worden.</p>
    <table>
        <thead>
            <tr><th>status</th><th>url</th><th>dataset</th><th>beschijving url</th></tr>
        </thead>
        <tbody>
    <?php 
$count = 0;
$ckan = new CKAN();
$ckan->getDatasets();
foreach ($ckan->datasets as $key => $set) {
    foreach ($set->res_url as $i => $url) {
        $count++;
        $code = is_available($url);
        if ($code != 200) {
            print "<TR><TD><a onClick='\$(\".row\").hide(); \$(\"#row" . $count . "\").show();'>&gt;</a></TD><TD>" . $code . "</TD><TD><a href='" . $url . "' target='_blank'>" . max_length($url, 60) . "</a></TD><TD>" . $set->name . "</TD><TD>" . $set->res_description[$i] . "</TR>";
            print "<TR id='row" . $count . "' class='row' style='display:none'><TD colspan = 5>";
            print "<form onSubmit='\$.post(\"setresource.php\", {name: \"" . $key . "\", res: " . $i . ", url: this.url" . $count . ".value, desc: this.desc" . $count . ".value}, function(data){\n                 \$(\"#feedback" . $count . "\").html(data);});return false; '>";
            print "URL: <input type='text' id='url" . $count . "' value='" . $url . "' SIZE=80><BR/>";
            print "DESC: <input type='text' id='desc" . $count . "' value='" . addslashes($set->res_description[$i]) . "' SIZE=80><BR/>";
            print "<input type='submit' value='Change'><br/>";
            print "</form>";
            print "<div id='feedback" . $count . "'></div>";
            print "</TD></TR>";
        }
    }
}
?>
  

        </tbody>
Esempio n. 3
0
    $year = (int) $year;
    $dateObj = DateTime::createFromFormat('!m', $month);
    $monthName = $dateObj->format('F');
    // March
    $required = array("name", "month", "day", "year", "hour", "minute", "period", "location", "description");
    if (!checkdate($month, $day, $year)) {
        array_push($errors, $monthName . " " . $day . ", " . $year . " is an invalid date.");
    }
    foreach ($required as $require) {
        $value = trim($_POST[$require]);
        if (!has_value($value)) {
            $errors[$require] = ucfirst($require) . " can't be blank.";
        }
    }
    $max_lengths = array("name" => 40, "location" => 50);
    max_length($max_lengths);
    if (empty($errors)) {
        $uploadEvent = addEvent($name, $month, $day, $year, $hour, $minute, $period, $imagesrc, $location, $desc);
        $message = $uploadEvent;
    }
}
?>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>EDFC | Admin - Add an Event</title>
<link rel="stylesheet" href="../css/normalize.css"/>
  <link rel="stylesheet" href="../css/foundation.css" />
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
Esempio n. 4
0
function length($value, $between)
{
    if (!is_array($between) || count($between) != 2) {
        throw new \InvalidArgumentException("'length' rule takes an array of exactly two values");
    }
    list($min, $max) = $between;
    if ($min !== null) {
        if (!min_length($value, $min)) {
            return false;
        }
    }
    if ($max !== null) {
        if (!max_length($value, $max)) {
            return false;
        }
    }
    return true;
}