-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
81 lines (64 loc) · 2.64 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<title>Validate JF2</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="single-column">
<h1>JF2 Validator</h1>
<h2>This validator is only recently developed, there may well be bugs. Please report any issues <a href="https://github.com/dissolve/jf2_validator/issues">Here</a>.</h2>
<?php
$input_data = filter_input(INPUT_POST, 'data' ); // removing actual filter from this for now
$fix_quotes = isset($_POST['fix_quotes']);
$jf2feed = isset($_POST['jf2feed']);
?>
<section class="content">
<form method="POST">
<textarea name="data" placeholder="jf2 data here"><?php echo htmlspecialchars($input_data) ?></textarea>
<br>
<label for="fix_quotes">Auto Convert all single quotes to double quotes: </label><input id="fix_quotes" type="checkbox" name="fix_quotes" value="true" <?php echo ($fix_quotes ? 'checked="checked"' : '') ?>/><br>
<label for="jf2feed">Validate with JF2 Feed Profile: </label><input id="jf2feed" type="checkbox" name="jf2feed" value="true" <?php echo ($jf2feed ? 'checked="checked"' : '') ?>/><br>
<input class="button" type="submit" name="submit" value="Validate"/>
</form>
</section>
<?php
if($input_data){
require_once __DIR__ . '/validator.php';
if($jf2feed){
$validator = new JF2FeedValidator();
} else {
$validator = new JF2Validator();
}
$results = $validator->validate($input_data, $fix_quotes);
$success = true;
$count = 0;
foreach($results as $result){
$count += 1;
$type = 'warn';
if($result->type == P_ERROR){
$success = false;
$type = 'error';
}
echo '<section class="content result '.$type.'">';
echo $result->message ;
if(!empty($result->line)){
echo '<label for="error-'.$count.'" class="expander-label">...</label>
<input id="error-'.$count.'" type="checkbox" class="expander-check" />
<pre class="errorline">';
echo htmlentities($result->line) ;
echo '</pre>';
}
echo '</section>';
}
}
if(isset($success) && $success){
echo '<section class=" content result success">This validator is not yet complete, but theres no errors in it thus far.</section>';
}
?>
<div class="small">
This validator is open source and available on <a href="https://github.com/dissolve/jf2_validator">GitHub</a>
<div>
</div>
</body>
</html>