31 lines
901 B
PHP
Executable File
31 lines
901 B
PHP
Executable File
<?php
|
|
|
|
function getPage($sPath, $asVars, $bSavePage=false)
|
|
{
|
|
if($bSavePage)
|
|
{
|
|
$asFileIds = array_filter($asVars);
|
|
unset($asFileIds['_']);
|
|
$sFileName = $sPath.'.'.implode('.', $asFileIds).'.log';
|
|
}
|
|
if(!$bSavePage || !file_exists($sFileName) || date('dmY', filemtime($sFileName))!=date('dmY'))
|
|
{
|
|
$sPath = 'http://www.ugc.fr/'.$sPath.'?'.http_build_query($asVars);
|
|
$oCurl = curl_init();
|
|
curl_setopt($oCurl, CURLOPT_URL, $sPath);
|
|
curl_setopt($oCurl, CURLOPT_HEADER, false);
|
|
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
|
$sContent = curl_exec($oCurl);
|
|
curl_close($oCurl);
|
|
if($bSavePage) file_put_contents($sFileName, $sContent);
|
|
}
|
|
return $bSavePage?file_get_contents($sFileName):$sContent;
|
|
}
|
|
|
|
function setPageMime($sType='html')
|
|
{
|
|
if($sType!='html') header('Content-type: application/'.$sType);
|
|
}
|
|
|
|
?>
|