NA\n"); else echo("$msg\n"); else { if ($failedPos==0) echo("$msg"); if ($passedPos==0) echo("invalid"); } return; } /* if have posix compiled in function clean_up () { echo "

Incomplete Test Run

"; exit(0); } // install handler for cancelling this process pcntl_signal(SIGTERM, "clean_up"); */ // The following big if allows either tricle of URLS from web or // tons from Command line if (isset($_REQUEST['urls']) ) { $urls = preg_split('/[\s,]+/', $_REQUEST['urls']); if (DEBUG) print_r($_REQUEST); } else if ( $_SERVER['argc'] > 0 && isset($_SERVER['argv']) ) { // The following gets a list of links to all the svg in the collection. for ($i=1; $i < $_SERVER['argc']; $i++) { $file = &$_SERVER['argv'][$i]; // do file tests hopefully if (file_exists($file)) $urls = array_merge($urls, array_map('rtrim',file($file)) ); } if (DEBUG) print_r($_SERVER['argv']); } else { echo "You must either run this from the web or from the commandline."; echo "\tWEB: http://openclipart.org/tools/stelt/ocal_validate.php?urls=http://somedomain.com/somesvgfile.svg,http://somedomain2.com/anothersvg.svg"; echo "\tCLI: php ocal_validate.php filename.txt anotherfile.txt"; echo "\t\tIn the above have one URL per files."; } // print_r($urls); // we want things to process!!! if ( count($urls) == 0 ) exit(1); ?> OCAL SVG Validation

W3C Validation of Open Clip Art Library content

Thanks to Stelt & ~:" for developing this.

Key

VALID INCOMPLETE INVALID NO_TITLE
\n"; echo "File URL" . "Validation URL" . "IS VALID (VERSION)" . "Title\n"; foreach ($urls as $url) { // NOTE: if you don't sleep here for 10 seconds, then you will be // banned from w3.org for 24 hours // setting sleep here so if we start with too many up front...better sleep(10); echo ""; // the following is pretty hacky and could be solved with one regex // I'm pretty sure (jon), but not interested in doing... $content = ""; // test to see if this URL is even valid and if not continue if ( parse_url($url) ) $content = file_get_contents($url); else { echo "$urlNA"; print_file_status(0, 0, "URL error"); echo "\n"; continue; } if ( empty($content) ) { echo "$urlNA"; print_file_status(0, 0, "NO CONTENT"); echo "\n"; continue; } $sq10 = strpos($content," version='1.0'"); $dq10 = strpos($content,' version="1.0"'); $sq11 = strpos($content," version='1.1'"); $dq11 = strpos($content,' version="1.1"'); $sq12 = strpos($content," version='1.2'"); $dq12 = strpos($content,' version="1.2"'); $novs = 1; $v0 = max($sq10, $dq10, $sq11, $dq11,$sq12, $dq12); if ( $sq10 == $v0) $v = "1.0"; elseif ( $dq10 == $v0) $v = "1.0"; if ($v == "1.0") $testURL = W3C_JIGGLES_VALIDATOR . "/validator?profile=1.0&warnings=yes&uri=" . rawurlencode($url) ; else $testURL = W3C_VALIDATOR . "/check?uri=". rawurlencode($url); // don't want doctype . "&doctype=SVG+1.2"; echo("$url" . "validated at W3C\n"); // if screwed up url, kill this attempt $result = file_get_contents($testURL); $failedPos = strpos($result,"ailed validation"); $passedPos = strpos($result,"assed validation"); // the 1.0 validator also reports warnings if ($passedPos == 0) $passedPos = strpos($result,"no error was found"); // the $v prints the version number print_file_status($failedPos, $passedPos, $v); $tt10 = strpos($content,""); if ($tt10 >= $v0) echo("<td>Title</td>\n"); else echo("<td class='notitle'>No Title</td>\n"); echo "</tr>"; flush(); } echo "</table>\n"; ?> </body></html>