31 require
'./include.inc';
32 require
'./validator.inc';
35 if (!defined(
'UPLOAD_ERR_CANT_WRITE'))
36 define(
'UPLOAD_ERR_CANT_WRITE', 7);
43 if (empty($_SERVER[
'HTTP_ACCEPT_LANGUAGE']))
46 $langs = explode(
',', $_SERVER[
'HTTP_ACCEPT_LANGUAGE']);
47 foreach ($langs as
$lang) {
48 list($lang) = explode(
';', $lang);
49 list($lang) = explode(
'-', $lang);
52 if (isset($valid_langs[$lang]))
65 define(
'MOZILLA', (isset($_SERVER[
'HTTP_USER_AGENT']) && strpos($_SERVER[
'HTTP_USER_AGENT'],
'Mozilla/') !==
false && strpos($_SERVER[
'HTTP_USER_AGENT'],
'Gecko/') !==
false));
74 if (isset(
$_GET[
'lang'])) {
76 } elseif (isset(
$_POST[
'lang'])) {
82 if (!isset(
$_GET[
'langchooser']) &&
86 !empty($_REQUEST[
'url'])
91 $lang = isset($_REQUEST[
'lang']) ? $_REQUEST[
'lang'] :
'en';
97 setcookie(
'lang',
$lang, time()+60*60*24*90,
'/',
'validator.aborla.net');
100 output_add_rewrite_var(
'lang',
$lang);
102 require
'./local/en.inc';
105 require
"./local/$lang.inc";
110 echo
'<p id="redir">We have automatically choosen the "' . $valid_langs[
$lang] .
111 '" language for you. <a href="/?langchooser">Click here to change</a>.</p>';
117 require
"./local/en.inc";
120 echo
"<p>Choose a language, please:</p>\n" .
121 "<form method=\"get\" action=\"index.php\">\n" .
122 "<p><select name=\"lang\">\n";
124 foreach($valid_langs as $k => $v) {
125 echo
"<option value=\"$k\">$v</option>\n";
128 echo
"</select></p>\n<p><input type=\"submit\" value=\" Submit \" /></p>\n</form>\n";
130 die(common_footer());
138 if (isset(
$_GET[
'docs'])) {
140 echo
"<h2>$message[5]</h2>\n".
141 "<p>$message[99]</p><p> </p>\n";
144 echo
"<h2>$message[0]</h2>";
145 foreach($opts as $v) {
146 echo
"<p><strong>$v[name]</strong>: $v[explain]</p>\n";
149 die(common_footer());
158 if (empty($_REQUEST[
'url']) && (!isset($_FILES[
'file']) || $_FILES[
'file'][
'error'] == UPLOAD_ERR_NO_FILE)) {
160 echo
'<form method="post" action="index.php" enctype="multipart/form-data"><p>' . $message[3].
161 '<input type="hidden" name="MAX_FILE_SIZE" value="' . validator::FILE_LIMIT .
'" />' .
162 ': <input type="text" name="url" size="50" value="http://" /><br />'.
163 $message[19] .
': <input name="file" type="file" /></p>';
165 $aditional =
"$message[8]:\n" .
mozilla(
"<label title=\"$message[1]\">\n") .
166 "<input type=\"radio\" name=\"errors\" checked=\"checked\" value=\"along\" /> $message[6]\n" .
167 "<input type=\"radio\" name=\"errors\" value=\"alone\" /> $message[7]\n" .
170 "<br />$message[9]:\n" .
mozilla(
"<label title=\"$message[2]\">\n") .
171 "<input type=\"radio\" name=\"repair\" checked=\"checked\" value=\"full\" /> $message[10]\n" .
172 "<input type=\"radio\" name=\"repair\" value=\"diff\" /> $message[11]\n" .
173 "<input type=\"radio\" name=\"repair\" value=\"none\" /> $message[12]\n" .
174 mozilla(
"</label>\n") .
"<br />\n";
177 echo validator::html_opts($aditional);
180 <p><input type=
"submit" value=
" $message[4] " /></p>
182 <p><a href=
"index.php?docs">$message[5]</a></p>
186 die(common_footer());
194 $validator =
new validator($_REQUEST);
198 if(isset($_FILES[
'file']) && $_FILES[
'file'][
'error'] != UPLOAD_ERR_NO_FILE) {
200 switch($_FILES[
'file'][
'error']) {
202 $result = $validator->parse_string(file_get_contents($_FILES[
'file'][
'tmp_name']));
205 case UPLOAD_ERR_INI_SIZE:
206 case UPLOAD_ERR_FORM_SIZE:
208 $int_error = $validator->_error(8, validator::FILE_LIMIT);
211 case UPLOAD_ERR_PARTIAL:
212 case UPLOAD_ERR_NO_TMP_DIR:
213 case UPLOAD_ERR_CANT_WRITE:
215 $int_error = $validator->_error(9);
221 $result = $validator->parse_url((
string)$_REQUEST[
'url']);
228 if ($validator->internal_error()) {
229 echo
"<p>$message[13]:<br />\n";
230 echo nl2br($validator->internal_errors_string()) .
"</p>\n";
236 if(isset($_FILES[
'file']) && $_FILES[
'file'][
'error'] == UPLOAD_ERR_OK) {
237 echo isset($_FILES[
'file'][
'name']) ?
"<strong>$message[18]</strong>: {$_FILES['file']['name']}<br />\n" :
'';
241 echo
'<strong>URL</strong>: ' . htmlspecialchars($_REQUEST[
'url'], ENT_QUOTES,
'UTF-8') .
"<br />\n";
245 if ($detected_version = $validator->detected_version()) {
246 echo
"<strong>$message[14]</strong>: $detected_version<br />\n";
250 echo
"<strong>$message[20]</strong>: {$validator->readable_charset()}";
253 if ($validator->lang)
254 echo
"<br />\n<strong>$message[24]</strong>: {$langs[$validator->lang]}";
258 if (
$errors = $validator->error()) {
260 echo
"<br />\n<strong>$message[21]</strong>: $errors</p>\n".
261 "<h2>$message[16]</h2>\n";
263 if (empty($_REQUEST[
'errors']) || $_REQUEST[
'errors'] ==
'along') {
264 echo
'<code>' . $validator->errors_source() .
"</code>\n\n";
267 echo
'<p>' . $validator->errors_string() .
"</p>\n\n";
272 echo
"</p><p>$message[15]</p>\n";
277 if (!isset($_REQUEST[
'repair']) || $_REQUEST[
'repair'] ==
'full') {
278 $html = strtr(nl2br(htmlspecialchars($validator->repaired_source(), ENT_QUOTES,
'UTF-8')), array(
' ' =>
' '));
280 echo
"\n<p> </p>\n<h2>$message[17]</h2>\n";
281 echo
'<div class="code"><code>' . $html .
"</code></div>\n";
284 } elseif ($_REQUEST[
'repair'] ==
'diff' &&
$diff = $validator->repaired_diff()) {
285 $diff = strtr(
$diff, array(
' ' =>
' '));
287 echo
"\n<p> </p>\n<h2>$message[11]</h2>\n";
288 echo
'<div class="code"><code>' .
$diff .
"</code></div>\n";
294 echo
"<p>$message[13]:<br />\n";
295 echo nl2br($validator->internal_errors_string()) .
"</p>\n";
299 if (isset(
$_GET[
'dump_debug'])) {
300 echo
'<pre>' . htmlspecialchars($validator->debug()) .
'</pre>';