79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
|
<?php
|
|||
|
//**********************
|
|||
|
// Common tools.
|
|||
|
//**********************
|
|||
|
// Pr<50>pare une chaine de caract<63>res <20> <20>tre inserer dans l'html.
|
|||
|
function sanitize_output( $string )
|
|||
|
{
|
|||
|
$html = mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
|||
|
$html = htmlentities($html, ENT_QUOTES, 'UTF-8');
|
|||
|
return $html;
|
|||
|
}
|
|||
|
|
|||
|
// diff<66>rentes fonctions pour lire les donn<6E>es transmisent via GET POST et SESSION
|
|||
|
// Tout en verifiant leur existance et si celle ci sont vie ou non.
|
|||
|
// Renvoi la valeur par d<>faut fournit en param<61>tre, par d<>fault ''.
|
|||
|
function check_get( $param, $defaut = '' )
|
|||
|
{
|
|||
|
$result = $defaut;
|
|||
|
if ( isset( $_GET[ $param ] ) )
|
|||
|
$result = $_GET[ $param ] ;
|
|||
|
|
|||
|
return $result;
|
|||
|
}
|
|||
|
|
|||
|
function check_post( $param, $defaut = '' )
|
|||
|
{
|
|||
|
$result = $defaut;
|
|||
|
if ( isset( $_POST[ $param ] ) )
|
|||
|
$result = $_POST[ $param ] ;
|
|||
|
|
|||
|
return $result;
|
|||
|
}
|
|||
|
|
|||
|
function check( $param, $defaut = '' )
|
|||
|
{
|
|||
|
$result = check_get( $param, check_post( $param, $defaut ) );
|
|||
|
return $result;
|
|||
|
}
|
|||
|
|
|||
|
function param( $param, $defaut = '' )
|
|||
|
{
|
|||
|
$result = check( $param, (isset( $_SESSION[APP_SLUG.'_'.$param] ) ? $_SESSION[APP_SLUG.'_'.$param] : $defaut) );
|
|||
|
if ( $result )
|
|||
|
$_SESSION[APP_SLUG.'_'.$param] = $result;
|
|||
|
return $result;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
// R<>cupp<70>re le contenu d'une page web distante, sans les headers, et la renvoi sous forme d'une chaine.
|
|||
|
function get_web_page($url)
|
|||
|
{
|
|||
|
$options = array(
|
|||
|
CURLOPT_RETURNTRANSFER => true, // return web page
|
|||
|
CURLOPT_HEADER => false, // don't return headers
|
|||
|
CURLOPT_FOLLOWLOCATION => true, // follow redirects
|
|||
|
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
|
|||
|
CURLOPT_ENCODING => "", // handle compressed
|
|||
|
CURLOPT_USERAGENT => "test", // name of client
|
|||
|
CURLOPT_AUTOREFERER => true, // set referrer on redirect
|
|||
|
CURLOPT_CONNECTTIMEOUT => 120, // time-out on connect
|
|||
|
CURLOPT_TIMEOUT => 120, // time-out on response
|
|||
|
);
|
|||
|
|
|||
|
$ch = curl_init($url);
|
|||
|
curl_setopt_array($ch, $options);
|
|||
|
|
|||
|
$content = curl_exec($ch);
|
|||
|
|
|||
|
curl_close($ch);
|
|||
|
|
|||
|
echo $content;
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
?>
|
|||
|
|