extranet/www/index.fct.php
2009-10-07 08:27:30 +00:00

98 lines
3.8 KiB
PHP
Raw Blame History

<?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 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;
}
?>