134 lines
4.9 KiB
PHP
134 lines
4.9 KiB
PHP
<?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;
|
||
}
|
||
|
||
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
|
||
header("Accept-Ranges: ".strlen($body));
|
||
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';
|
||
|
||
$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);
|
||
|
||
$fp=fopen($fichierHtm,'w');
|
||
fwrite($fp, $buffer);
|
||
fclose($fp);
|
||
|
||
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);
|
||
|
||
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"');
|
||
//header("Accept-Ranges: ".filesize($fichierPdf));
|
||
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.'"');
|
||
}
|
||
|
||
|
||
function getLogo($siteWeb, $siren) {
|
||
require_once 'common/curl.php';
|
||
if (substr($siteWeb,-1)<>'/')
|
||
$siteWeb.='/';
|
||
|
||
$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);
|
||
|
||
$page=getUrl($urlLogo, '', '', $siteWeb, false, $arrUrl['host']);
|
||
$body=$page['body'];
|
||
$fp=fopen(PATH_LOGOS.$siren.'.'.$ext, 'a');
|
||
fwrite($fp, $body);
|
||
fclose($fp);
|
||
return '/logos/'.$siren.'.'.$ext;
|
||
}/*
|
||
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;
|
||
|
||
//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
|
||
$size = GetImageSize($img_src);
|
||
$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;
|
||
}
|
||
?>
|