1.0
This commit is contained in:
31
inc/functions.php
Executable file
31
inc/functions.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user