PHP – Fonction is_url()
function is_url($url) {
$urlregex = "^(http|https|ftp)?\:\/\/";
// USER AND PASS (optional)
$urlregex .= "([a-z0-9+!*(),;?&=$_.-]+(\:[a-z0-9+!*(),;?&=$_.-]+)?@)?";
// HOSTNAME OR IP
$urlregex .= "[a-z0-9+$_-]+(\.[a-z0-9+$_-]+)*"; // http://x = allowed (ex. http://localhost, http://routerlogin)
//$urlregex .= "[a-z0-9+$_-]+(\.[a-z0-9+$_-]+)+"; // http://x.x = minimum
//$urlregex .= "([a-z0-9+$_-]+\.)*[a-z0-9+$_-]{2,3}"; // http://x.xx(x) = minimum
//use only one of the above
// PORT (optional)
$urlregex .= "(\:[0-9]{2,5})?";
// PATH (optional)
$urlregex .= "(\/([a-z0-9+$_-]\.?)+)*\/?";
// GET Query (optional)
$urlregex .= "(\?[a-z+&$_.-][a-z0-9;:@/&%=+$_.-]*)?";
// ANCHOR (optional)
$urlregex .= "(#[a-z_.-][a-z0-9+$_.-]*)?$";
return eregi($urlregex, $url)?true:false;
}
Source: topflood.com
Bash – Télécharger des scénarios de film
Pré-requis: Installer methabot
Création du répertoire qui va contenir les scénarios:
mkdir ~/moviescript && cd ~/moviescript
Extraction des urls:
for i in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ; do methabot -x :list http://web.archive.org/web/20030803234028/www.screentalk.biz/gallery${i}.htm | grep ".pdf" | sed -e '1d' >> scriptpdf.listing ; done
Téléchargement des scénarios (.pdf):
while read url; do wget $url; done < scriptpdf.listing
--2010-07-22 10:08:06-- http://web.archive.org/web/20030803234028/www.screentalk.biz/moviescripts/AceVentura.pdf Résolution de web.archive.org... 207.241.227.60 Connexion vers web.archive.org|207.241.227.60|:80...connecté. requête HTTP transmise, en attente de la réponse...
Dans un terminal:
sudo vi /private/etc/apache2/httpd.conf
Décommenter
LoadModule php5_module libexec/apache2/libphp5.so
Préférences Système > Partage > Partage web
Tester: http://localhost
Pour ajouter du code PHP (DocRoot Apache):
/Library/WebServer/Documents/
Firefox – Installer OpenSearch sur WordPress
Introduction
OpenSearch permet de créer un moteur de recherche pour Firefox.
Ce moteur de recherche une fois ajouté par l’utilisateur permettra d’effectuer des recherches sur un blog par exemple.
Pour cela il suffit de définir un fichier search.xml compréhensible par le navigateur et définissant l’url de recherche du blog et l’intégrer au header des pages du site.
Pour ce blog, l’url de recherche est la suivante:
http://www.benjaminbaudouin.com/?s=
search.xml
<OpenSearchDescription>
<ShortName>Benjamin Baudouin</ShortName>
−
<Description>
Administration Système Linux, Développement Web. Geek Stuff. Veille Techno !
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://www.benjaminbaudouin.com/favicon.ico</Image>
<Url type="text/html" method="get" template="http://www.benjaminbaudouin.com/?s={searchTerms}">
</Url>
<Url type="application/x-suggestions+json" template="suggestionURL"/>
<moz:SearchForm>searchFormURL</moz:SearchForm>
</OpenSearchDescription>
intégration de search.xml dans wordpress
Dans la partie d’administration, Apparence > Éditeur > En-tête (header.php)
<head>
...
<link rel="search" type="application/opensearchdescription+xml" title="Benjamin Baudouin" href="http://www.benjaminbaudouin.com/search.xml">
</head>
Cliquer sur Mettre à jour le fichier
Test
Avec Firefox,
aller sur l’adresse http://www.benjaminbaudouin.com et ajouter le moteur de recherche comme suit:

Il est maintenant possible d’effectuer des recherches directement dans Firefox sur ce blog.

