cvs: peardoc /scripts linkcheck_pear.php

From: Date: Mon, 19 Jun 2006 03:09:20 +0000
Subject: cvs: peardoc /scripts linkcheck_pear.php
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8054@lists.php.net to get a copy of this message
alexmerz Mon Jun 19 03:09:20 2006 UTC Added files: /peardoc/scripts linkcheck_pear.php Log: script to check url entities in global.ent http://cvs.php.net/viewcvs.cgi/peardoc/scripts/linkcheck_pear.php?view=markup&rev=1.1 Index: peardoc/scripts/linkcheck_pear.php +++ peardoc/scripts/linkcheck_pear.php #!/usr/bin/php -q <?php /* # +----------------------------------------------------------------------+ # | Copyright (c) 1997-2004 The PHP Group | # +----------------------------------------------------------------------+ # | This source file is subject to version 2.02 of the PHP licience, | # | that is bundled with this package in the file LICENCE and is | # | avalible through the world wide web at | # | http://www.php.net/license/2_02.txt. | # | If you did not receive a copy of the PHP license and are unable to | # | obtain it through the world wide web, please send a note to | # | license@php.net so we can mail you a copy immediately | # +----------------------------------------------------------------------+ # | Authors: Alexander Merz <alexmerz@php.net> | # +----------------------------------------------------------------------+ # $Id: linkcheck_pear.php,v 1.1 2006/06/19 03:09:20 alexmerz Exp $ */ ?> <html> <head> <title>Link check for PEARDOC</title> </head> <body> <h1>Link check for PEARDOC</h1> <p> Meaning of colors: </p> <table width="100%" border="1"> <tr> <td width="10%" style="background-color:green">green</td> <td>Everything is ok!</td> </tr> <tr> <td width="10%" style="background-color:yellow">yellow</td> <td>There could be a problem. Maybe a permanent redirect to a new location.</td> </tr> <tr> <td width="10%" style="background-color:red">red</td> <td>Website not found or a server error! Check link!</td> </tr> <tr> <td width="10%">&nbsp;</td> <td>An blank field indicates a connection problem like a timeout.</td> </tr> </table> <?php require_once 'HTTP/Request.php'; $globalfile = '../global.ent'; if(file_exists($globalfile)) { $content = file_get_contents($globalfile); $content = preg_replace('/<!-- .* -->/sU', '', $content); $lines = explode("\n", $content); $urls = array(); foreach($lines as $line) { if($line!='') { if(preg_match("/<!ENTITY url.(\S*)\s*['\"](.*)['\"]>/U", $line, $entitydata)) { $urls[] = array('name'=>$entitydata[1],'url'=>$entitydata[2], 'code'=>null); } } } ?> <p> The results: <b><?php echo count($urls);?></b> links found in <i>globals.ent</i>. </p> <table width="100%" border="1"> <tr> <th>Entity</th> <th>Status</th> </tr> <? $req = new HTTP_Request(); for($i = 0; $i < count($urls); $i++) { $req->setURL($urls[$i]['url']); $req->setMethod(HTTP_REQUEST_METHOD_HEAD); $req->sendRequest(); $urls[$i]['code'] = $req->getResponseCode(); if(is_integer($urls[$i]['code'])) { if($urls[$i]['code']<=299) { $color = "green"; } else if($urls[$i]['code']<=399){ $color = "yellow"; } else if($urls[$i]['code'] >= 400 ){ $color = "red"; } } else { $color = ""; } ?> <tr> <td><b><?php echo 'url.'.$urls[$i]['name']."</b><br/>".$urls[$i]['url'];?></td> <td width="10%" style="background-color:<?php echo $color;?>">&nbsp;<?php echo $urls[$i]['code'];?></td> </tr> <?php } ?> </table> <? } else { ?> <p>The file <i>global.ent</i> could not be found in the parent directory!</p> <? } ?> </body> </html>

« previous php.pear.doc (#8054) next »