Minor fix: correct url checking and add gsearch help

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@195 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2008-12-04 14:50:55 +00:00
parent 3a46b91c78
commit 6b70f8355a
2 changed files with 20 additions and 8 deletions

View file

@ -95,11 +95,15 @@ function shortenString($string, $maxSize=75) {
return $output;
}
/* Check online if a url is a valid page (Not a 404 error for example) */
function checkUrl($url) {
$h = @get_headers($url);
/* Check url format and check online if the url is a valid page (Not a 404 error for example) */
function checkUrl($url) {
//check format
if(!preg_match("#(ht|f)tp(s?)\://\S+\.\S+#i",$url)) {
return false;
}
//look if the page doesn't return a void or 40X or 50X HTTP code error
$h = @get_headers($url);
if(is_array($h) && strpos($h[0], '40') === false && strpos($h[0], '50') === false) {
return true;
} else {

View file

@ -4,6 +4,9 @@ if($GLOBALS['enableGoogleCustomSearch']==false) {
echo "Google Custom Search disabled. You can enable it into the config.inc.php file.";
die;
}
$userservice = & ServiceFactory :: getServiceInstance('UserService');
$currentUser = $userservice->getCurrentObjectUser();
?>
<html>
@ -23,11 +26,16 @@ if($GLOBALS['enableGoogleCustomSearch']==false) {
<small>Based on <a href="http://www.google.com/coop/cse/">Google Custom Search</a> over this <a href="../api/export_gcs.php">list of websites</a> from <?php echo $GLOBALS['sitename'] ?>.</small>
<!--
To refresh manually Google Custom Search Engine, goes to: http://www.google.com/coop/cse/cref
-->
<?php if($userservice->isLoggedOn() && $currentUser->isAdmin()){
echo '<p><small>';
echo T_('Admin tips: ');
echo T_('To refresh manually Google Custom Search Engine, goes to: ');
echo '<a href="http://www.google.com/coop/cse/cref?cref='.ROOT.'search/context.php">http://www.google.com/coop/cse/cref</a><br/>';
echo T_('If no result appears, check that all the urls are valid in the admin section.');
echo '</small></p>';
}
?>
</center>
</body>