189 lines
5.4 KiB
PHP
189 lines
5.4 KiB
PHP
<?php
|
|
function logAction($login, $page, $siret, $ip, $host, $resolution, $nbcolors,
|
|
$user_agent, $referer, $date_login, $date_last_action, $request) {
|
|
$file = PATH_LOGS.'actions-'.date('Ym').'.log';
|
|
if (!file_exists($file)) {
|
|
$fp=fopen($file, '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($file, '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 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écisé (0)
|
|
if(!$dst_h) $dst_h = $test_h;
|
|
// Sinon si Width final non précisé (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;
|
|
}
|
|
|
|
/**
|
|
* Retourne la raison sociale de la session / du webservice
|
|
* @param string $siret
|
|
* @param int $idEntreprise
|
|
* @return string
|
|
*/
|
|
function etabSession($siret, $idEntreprise = 0)
|
|
{
|
|
global $client;
|
|
$compare = false;
|
|
//Comparaison Siren / Siret
|
|
if (isset($_SESSION['tabInfo']['entrep']) && !empty($siret) && $siret*1!=0)
|
|
{
|
|
if (strlen($siret)==9) {
|
|
//Comparaison entre siren
|
|
if ($siret==$_SESSION['tabInfo']['entrep']['siren'])
|
|
$compare = true;
|
|
} elseif (strlen($siret)==14) {
|
|
//Comparaison entre siret
|
|
if ($siret==$_SESSION['tabInfo']['entrep']['siret'])
|
|
$compare = true;
|
|
}
|
|
}
|
|
|
|
//Comparaison id
|
|
if (isset($_SESSION['tabInfo']['entrep']) && empty($siret) && $siret*1==0)
|
|
{
|
|
if ($idEntreprise!=0 && $idEntreprise==$_SESSION['tabInfo']['entrep']['id'])
|
|
$compare = true;
|
|
}
|
|
|
|
if ( !$compare )
|
|
{
|
|
FB::info('getIdentite');
|
|
$O2 = $client->getIdentite($siret, $idEntreprise, false);
|
|
$etab = $O2['result'];
|
|
$tabEntrep = array();
|
|
$tabEntrep['raisonSociale'] = $etab['Nom'];
|
|
$tabEntrep['id'] = $etab['id'];
|
|
$tabEntrep['siren'] = $etab['Siren'];
|
|
$tabEntrep['siret'] = $etab['Siret'];
|
|
$tabEntrep['siretSiege'] = $etab['SiretSiege'];
|
|
$tabEntrep['tva'] = $etab['TvaNumero'];
|
|
$tabEntrep['isin'] = $etab['Isin'];
|
|
$tabEntrep['AutreId'] = $etab['AutreId'];
|
|
$tabEntrep['active'] = array_key_exists('Statut',$etab)? $etab['Statut'] : '';
|
|
$tabEntrep['Source'] = $etab['Source'];
|
|
$tabEntrep['SourceId'] = $etab['SourceId'];
|
|
$tabEntrep['codeCommune'] = $etab['Dept'].$etab['codeCommune'];
|
|
$tabEntrep['nafEn'] = $etab['NafEnt'];
|
|
$tabEntrep['nafEt'] = $etab['NafEtab'];
|
|
$tabEntrep['fj'] = $etab['FJ'];
|
|
$_SESSION['tabInfo']['entrep'] = $tabEntrep;
|
|
$raisonSociale = $etab['Nom'];
|
|
}
|
|
else if (isset($_SESSION['tabInfo']['entrep']['raisonSociale']) == true)
|
|
{
|
|
$raisonSociale = $_SESSION['tabInfo']['entrep']['raisonSociale'];
|
|
}
|
|
else
|
|
{
|
|
$raisonSociale = '';
|
|
}
|
|
return $raisonSociale;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// titreAvecSiren
|
|
// --------------------------------------------------------------------------- //
|
|
function titreAvecSiren($titre)
|
|
{
|
|
return $titre.' - Siren '.
|
|
substr($_REQUEST['siret'], 0, 3).' '.
|
|
substr($_REQUEST['siret'], 3, 3).' '.
|
|
substr($_REQUEST['siret'], 6, 3);
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// implode_r
|
|
// --------------------------------------------------------------------------- //
|
|
function implode_r($glue, $pieces)
|
|
{
|
|
$ret = '';
|
|
foreach ($pieces as $piece) {
|
|
if (is_array($piece)) {
|
|
$ret .= implode_r($glue, $piece);
|
|
} else {
|
|
$ret .= $glue . $piece;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Vérifie les paramètres globaux pour une page
|
|
* @param string $page
|
|
* @return boolean
|
|
*/
|
|
function page_checkParams($page = ''){
|
|
global $siren, $siret, $idEntreprise;
|
|
$check = true;
|
|
switch($page){
|
|
default:
|
|
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14){
|
|
$check = false;
|
|
}
|
|
if (($siret*1)==0 && $idEntreprise==0){
|
|
$check = false;
|
|
}
|
|
break;
|
|
}
|
|
return $check;
|
|
}
|
|
|
|
/**
|
|
* Retourne la valeur d'un paramètre global
|
|
* @param string $param
|
|
* @return int or string
|
|
*/
|
|
function page_param($param) {
|
|
switch($param) {
|
|
case 'siret':
|
|
if (isset($_REQUEST['siret']) == true) {
|
|
$value = trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
|
|
} else {
|
|
$value = '';
|
|
}
|
|
break;
|
|
case 'siren':
|
|
if (isset($_REQUEST['siret']) == true) {
|
|
$value = trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
|
|
$value = substr($value, 0, 9);
|
|
} else {
|
|
$value = '';
|
|
}
|
|
break;
|
|
case 'idEntreprise':
|
|
if (isset($_REQUEST['idEntreprise']) == true) {
|
|
$value = trim(preg_replace('/[^0-9]/', '',
|
|
$_REQUEST['idEntreprise']) ) * 1;
|
|
} else {
|
|
$value = '';
|
|
}
|
|
break;
|
|
}
|
|
return $value;
|
|
}
|
|
?>
|