2009-03-24 08:10:48 +00:00
|
|
|
|
<?php
|
|
|
|
|
function logAction($login, $page, $siret, $ip, $host, $resolution, $nbcolors, $user_agent, $referer, $date_login, $date_last_action, $request) {
|
|
|
|
|
if (!file_exists(PATH_LOGS.'actions.log')) {
|
|
|
|
|
$fp=fopen(PATH_LOGS.'actions.log', 'a');
|
|
|
|
|
fwrite($fp, 'Date et Heure;Login;Page;Siret;Ip;Host;Resolution;Nbcolors;User Agent;Referer;Date login;Date last action;Request'."\n");
|
|
|
|
|
} else {
|
|
|
|
|
$fp=fopen(PATH_LOGS.'actions.log', 'a');
|
|
|
|
|
}
|
|
|
|
|
fwrite($fp, date('Y/m/d H:i:s').";$login;$page;$siret;$ip;$host;$resolution;$nbcolors;$user_agent;$referer;$date_login;$date_last_action;$request\n");
|
|
|
|
|
fclose($fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function strWsToHtml($str) {
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
function afficheErreur($message, $refresh=5) {
|
|
|
|
|
include('./pages/erreur.php');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html2pdf($buffer) {
|
|
|
|
|
/*$body=getAvisSituation($siret, 'pdf');
|
|
|
|
|
header("Pragma: public");
|
|
|
|
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
|
|
|
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
|
|
|
|
header("Cache-Control: must-revalidate");
|
|
|
|
|
header("Content-type: application/pdf");
|
|
|
|
|
header("Content-Length: ".strlen($body));
|
|
|
|
|
header('Content-disposition: inline; filename="avis-'.$siret.'.pdf"');// attachement or inline
|
2009-07-07 16:35:28 +00:00
|
|
|
|
header("Accept-Ranges: ".strlen($body));
|
2009-03-24 08:10:48 +00:00
|
|
|
|
echo $body;*/
|
|
|
|
|
global $fichierPdf;
|
|
|
|
|
$fichier='printable_'.$_REQUEST['page'].'_'.$_REQUEST['siret'].$_SERVER['REMOTE_ADDR'].'_'.date('YmdHis');
|
|
|
|
|
$fichierHtm = '/tmp/'.$fichier.'.htm';
|
|
|
|
|
$fichierPdf = PATH_DATA.'/pdf/'.$fichier.'.pdf';
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
$buffer=str_replace('<link rel="stylesheet" type="text/css" href="/',
|
|
|
|
|
'<link rel="stylesheet" type="text/css" href="'.EXTRANET_URL,$buffer);
|
|
|
|
|
$buffer=str_replace(' src="./',
|
|
|
|
|
' src="'.EXTRANET_URL,$buffer);
|
|
|
|
|
$buffer=str_replace(' src="/',
|
|
|
|
|
' src="'.EXTRANET_URL,$buffer);
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
$fp=fopen($fichierHtm,'w');
|
|
|
|
|
fwrite($fp, $buffer);
|
|
|
|
|
fclose($fp);
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
exec('/usr/bin/htmldoc -t pdf14 --size A4 --no-links --webpage --compression=1 --no-toc --pagemode document --left 1.5cm --right 1.5cm -f '.$fichierPdf.' '.$fichierHtm);
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
header('Content-type: application/pdf');
|
|
|
|
|
header('Content-Disposition: inline; filename=doc.pdf');
|
|
|
|
|
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
|
|
|
|
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
|
|
|
|
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
|
|
|
|
|
header('Pragma: anytextexeptno-cache', true);
|
|
|
|
|
header('Cache-control: private');
|
|
|
|
|
header('Expires: 0');
|
|
|
|
|
/*
|
|
|
|
|
header('Pragma: public');
|
|
|
|
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
|
|
|
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
|
header("Content-Type: application/pdf");
|
|
|
|
|
header("Content-Length: ".filesize($fichierPdf));
|
|
|
|
|
header('Content-Type: application/force-download');
|
|
|
|
|
header('Content-Disposition: attachment; filename="'.$_REQUEST['page'].'-'.$_REQUEST['siret'].'-'.date('Ymd').'.pdf"');
|
2009-07-07 16:35:28 +00:00
|
|
|
|
//header("Accept-Ranges: ".filesize($fichierPdf));
|
2009-03-24 08:10:48 +00:00
|
|
|
|
header('Accept-Ranges: bytes');
|
|
|
|
|
/*
|
|
|
|
|
header('HTTP/1.1 200 OK');
|
|
|
|
|
header('Status: 200 OK');
|
|
|
|
|
|
|
|
|
|
header('Accept-Ranges: bytes');
|
|
|
|
|
header('Content-Transfer-Encoding: Binary');
|
|
|
|
|
header("Content-Lenght: ".strval( $pdf->TailleFichierTemporaire( ) ));
|
|
|
|
|
*/
|
|
|
|
|
//header('Location: http://extranet"'.$NomFichier.'"');
|
|
|
|
|
}
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
function getLogo($siteWeb, $siren) {
|
2009-07-21 07:17:54 +00:00
|
|
|
|
require_once 'common/curl.php';
|
2009-03-24 08:10:48 +00:00
|
|
|
|
if (substr($siteWeb,-1)<>'/')
|
|
|
|
|
$siteWeb.='/';
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
$arrUrl=parse_url($siteWeb);
|
|
|
|
|
$page=getUrl($siteWeb, '', '', '', false, $arrUrl['host'], '', 3);
|
|
|
|
|
$body=$page['body'];
|
|
|
|
|
if (preg_match('/<img(?:.*)src=(?:"|\')((?:.*)logo(?:.*)(?:gif|png|jpg|jpeg))/Ui', $body, $matches)) {
|
|
|
|
|
$logo=trim(strtr($matches[1],'"\'',' '));
|
|
|
|
|
$urlLogo=$siteWeb.$logo;
|
|
|
|
|
|
|
|
|
|
$tmp=explode('.', basename($logo));
|
|
|
|
|
$ext=end($tmp);
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
$page=getUrl($urlLogo, '', '', $siteWeb, false, $arrUrl['host']);
|
|
|
|
|
$body=$page['body'];
|
|
|
|
|
$fp=fopen(PATH_LOGOS.$siren.'.'.$ext, 'a');
|
|
|
|
|
fwrite($fp, $body);
|
|
|
|
|
fclose($fp);
|
2009-07-07 16:35:28 +00:00
|
|
|
|
return '/logos/'.$siren.'.'.$ext;
|
2009-03-24 08:10:48 +00:00
|
|
|
|
}/*
|
|
|
|
|
elseif (preg_match_all('/<frame (?:.*)src=(?:"|\')(.*)(?:"|\')(?:.*)>/Ui', $body, $matches)) {
|
|
|
|
|
foreach ($matches[1] as $url) {
|
|
|
|
|
if (substr($url,0,1)=='/' || substr($url,0,1)=='./' || substr($url,0,7)<>'http://')
|
|
|
|
|
$url=$siteWeb.$url;
|
2009-07-07 16:35:28 +00:00
|
|
|
|
|
2009-03-24 08:10:48 +00:00
|
|
|
|
//echo "Chercher dans : $url.<br/>";
|
|
|
|
|
$logo2=getLogo($url, $siren);
|
|
|
|
|
if ($logo2<>'') return $logo2;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function redimage($img_src,$dst_w,$dst_h) {
|
|
|
|
|
// Lit les dimensions de l'image
|
2009-07-07 16:35:28 +00:00
|
|
|
|
$size = GetImageSize($img_src);
|
2009-03-24 08:10:48 +00:00
|
|
|
|
$src_w = $size[0]; $src_h = $size[1];
|
|
|
|
|
// Teste les dimensions tenant dans la zone
|
|
|
|
|
$test_h = round(($dst_w / $src_w) * $src_h);
|
|
|
|
|
$test_w = round(($dst_h / $src_h) * $src_w);
|
|
|
|
|
// Si Height final non pr<70>cis<69> (0)
|
|
|
|
|
if(!$dst_h) $dst_h = $test_h;
|
|
|
|
|
// Sinon si Width final non pr<70>cis<69> (0)
|
|
|
|
|
elseif(!$dst_w) $dst_w = $test_w;
|
|
|
|
|
// Sinon teste quel redimensionnement tient dans la zone
|
|
|
|
|
elseif($test_h>$dst_h) $dst_w = $test_w;
|
|
|
|
|
else $dst_h = $test_h;
|
|
|
|
|
|
|
|
|
|
// Affiche les dimensions optimales
|
|
|
|
|
return "width=".$dst_w." height=".$dst_h;
|
|
|
|
|
}
|
|
|
|
|
?>
|