header("Pragma: no-cache"); header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); include_once 'ressources/class.templates.inc'; include_once 'ressources/class.ldap.inc'; include_once 'ressources/class.users.menus.inc'; include_once 'ressources/class.artica.inc'; include_once 'ressources/class.ini.inc'; include_once 'ressources/class.system.network.inc'; include_once 'ressources/class.squid.inc'; include_once 'ressources/class.ccurl.inc'; include_once "ressources/class.compile.ufdbguard.expressions.inc"; page(); if (isset($_GET["checks"])) { check_js(); exit; } if (isset($_POST["checks"])) { check(); exit; } function check_js() { header("content-type: application/x-javascript"); $website = $_GET["checks"]; $category = $_GET["category"]; $mdd5 = $_GET["md5"]; $t = time(); $page = CurrentPageName(); echo "\n\tvar xSave{$t}=function(obj){\n\t\tvar results=obj.responseText;\n\t\tdocument.getElementById('category-{$mdd5}').innerHTML='{$category}';\n\t\tif(results.length>3){\n\t\t\tdocument.getElementById('img-{$mdd5}').innerHTML=results;\n\t\t}\n\t\t\n }\n\t\n\t\nfunction Save{$t}(){\n\tif(!document.getElementById('category-{$mdd5}')){return;}\n\tvar XHR = new XHRConnection();\n XHR.appendData('checks','{$website}');\n XHR.appendData('category','{$category}');\n \tAnimateDiv('img-{$mdd5}'); \n XHR.sendAndLoad('{$page}', 'POST',xSave{$t}); \n\t\n\t\n\t}\n\t\nSave{$t}();";
/** * Checks the content under a tag's external references. * * @param string The name of the tag to check * @param map A map of attributes (name=>value) the tag has * @param boolean Whether this is a self-closing tag * @param boolean Whether this is a closing tag * @return ?list Array of errors (NULL: none) */ function _check_externals($tag, $attributes, $self_close, $close) { if (function_exists('get_param_integer') && get_param_integer('keep_no_ext_check', 0) == 1) { return NULL; } unset($self_close); unset($close); global $VALIDATED_ALREADY, $TAG_ATTRIBUTES, $IDS_SO_FAR, $ANCESTER_BLOCK, $ANCESTER_INLINE, $EXPECTING_TAG, $OUT, $POS, $LAST_A_TAG; $errors = array(); if ($tag == 'link' && $GLOBALS['VALIDATION_CSS'] && $GLOBALS['NO_XHTML_LINK_FOLLOW'] == 0 && isset($attributes['href']) && isset($attributes['type']) && $attributes['type'] == 'text/css' && !isset($VALIDATED_ALREADY[$attributes['href']])) { $VALIDATED_ALREADY[$attributes['href']] = 1; $url = qualify_url($attributes['href'], $GLOBALS['URL_BASE']); if ($url != '') { $sheet = http_download_file($url, NULL, false); if (!is_null($sheet)) { $css_validity = _validate_css_sheet($sheet); if (is_array($css_validity)) { $errors = array_merge($errors, $css_validity); } // Some kind of error } } } if ($GLOBALS['VALIDATION_JAVASCRIPT'] && $tag == 'script' && $GLOBALS['NO_XHTML_LINK_FOLLOW'] == 0 && isset($attributes['src']) && isset($attributes['type']) && ($attributes['type'] == 'text/javascript' || $attributes['type'] == 'application/x-javascript') && !isset($VALIDATED_ALREADY[$attributes['src']])) { $VALIDATED_ALREADY[$attributes['src']] = 1; $url = qualify_url($attributes['src'], $GLOBALS['URL_BASE']); if ($url != '') { $js = http_download_file($url, NULL, false); if (!is_null($js)) { $js = convert_to_internal_encoding($js); $VALIDATED_ALREADY[$attributes['src']] = 1; if (function_exists('require_code')) { require_code('js_validator'); } $js_validity = check_js($js, true); if (is_array($js_validity)) { $errors = array_merge($errors, $js_validity); } // Some kind of error } } } if ($tag == 'iframe' && isset($attributes['src']) && $attributes['src'] != '' && $GLOBALS['NO_XHTML_LINK_FOLLOW'] == 0 && !isset($VALIDATED_ALREADY[$attributes['src']])) { $VALIDATED_ALREADY[$attributes['src']] = 1; $url = qualify_url($attributes['src'], $GLOBALS['URL_BASE']); if ($url != '') { $iframe = http_download_file($url, NULL, false); // Sometimes disabled due to my iframe producing a weird PHP exception, that was stopping me working if (!is_null($iframe) && $iframe != '') { $iframe = convert_to_internal_encoding($iframe); global $HTTP_DOWNLOAD_MIME_TYPE; if ($HTTP_DOWNLOAD_MIME_TYPE == 'text/html' || $HTTP_DOWNLOAD_MIME_TYPE == 'application/xhtml+xml') { global $EXTRA_CHECK; $EXTRA_CHECK[] = $iframe; } } } } return $errors == array() ? NULL : $errors; }
#!/usr/bin/php -q <?php $extensions = array(".js", ".pjs"); error_reporting(E_ALL); define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); foreach ($extensions as $ext) { $files = array(); exec("find " . SF_ROOT_DIR . "/apps -name '*{$ext}'", $files); foreach ($files as $file) { check_js($file); } } function check_js($file) { if (!($js = file_get_contents($file))) { die("\nError: failed to read {$file}\n"); } $js = str_replace(array("\r", "\n", " "), array("", "", ""), $js); foreach (array(",}", ",]", ",)", "console.log(") as $search) { if ($search == 'console.log(' && preg_match('/miframe-debug\\.js$|storeLoader\\.js$/', $file)) { continue; } check_char($js, $search, $file); } echo "."; } function check_char($string, $chr, $file) { $pos = strpos($string, $chr); if ($pos) { die("\nError: found ,] in {$file}\nDetails: " . substr($string, $pos - 15, 30) . "\n");
header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); include_once('ressources/class.templates.inc'); include_once('ressources/class.ldap.inc'); include_once('ressources/class.users.menus.inc'); include_once('ressources/class.artica.inc'); include_once('ressources/class.ini.inc'); include_once('ressources/class.system.network.inc'); include_once('ressources/class.squid.inc'); include_once('ressources/class.ccurl.inc'); include_once("ressources/class.compile.ufdbguard.expressions.inc"); page(); if(isset($_GET["checks"])){check_js();exit;} if(isset($_POST["checks"])){check();exit;} function check_js(){ header("content-type: application/x-javascript"); $website=$_GET["checks"]; $category=$_GET["category"]; $mdd5=$_GET["md5"]; $t=time(); $page=CurrentPageName(); echo " var xSave$t=function(obj){ var results=obj.responseText; document.getElementById('category-$mdd5').innerHTML='$category';
$line = 1; $pos = 1; for ($i = 0; $i < strlen($contents); $i++) { $next = $contents[$i]; if (ord($next) > 128) { echo 'ISSUE "' . $to_use . '" ' . strval($line) . ' ' . strval($pos) . ' ' . do_lang_local('XHTML_UNSAFE_CHAR', $next, strval(ord($next))) . "\n"; } if ($next == chr(10)) { $line++; $pos = 1; } else { $pos++; } } if ($javascript) { $results = check_js($contents, false); } elseif (substr($to_use, -4) == '.css') { $results = check_css($contents); } else { $is_fragment = substr($to_use, -5) != '.html' && substr($to_use, -4) != '.htm' && substr($to_use, -4) != '.php'; $manual = in_array('checks', $_SERVER['argv']) || array_key_exists('checks', $_SERVER['argv']) && $_SERVER['argv']['checks'] == '1'; $ext = false; if (strpos($to_use, '/_mail.html') !== false || strpos($to_use, '_mail.htm') !== false || $to_use == '_mail.html' || $to_use == '_mail.htm') { $GLOBALS['MAIL_MODE'] = true; $matches = array(); $num_matches = preg_match_all('#^.*$#m', $contents, $matches); $pos = 1; $line = 1; for ($i = 0; $i < $num_matches; $i++) { if (strlen($matches[0][$i]) > 512) { echo 'ISSUE "' . $to_use . '" ' . strval($line) . ' ' . strval($pos) . ' ' . do_lang_local('MAIL_LONG_LINE') . "\n";