Intégration des fichiers
98
config/WebService/config.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?
|
||||
define('INCLUDE_PATH', realpath(dirname(__FILE__)).'/');
|
||||
|
||||
/** BATCH
|
||||
**/
|
||||
define('FILLER',' ');
|
||||
define('VERSION_FICHIER_BODACC','0106');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
|
||||
/** Paramétres du FTP des JO
|
||||
**/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/data/bodacc/');
|
||||
define('JAL_LOCAL_DIR', '/home/data/jal/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse
|
||||
**/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/data/infosreg/hugin/');
|
||||
|
||||
/** Paramétres du FTP de ActusNews : Communiqués de presse
|
||||
**/
|
||||
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
|
||||
define('ACTUSNEWS_FTP_USER', 'scores_act');
|
||||
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
|
||||
define('ACTUSNEWS_LOCAL_DIR', '/home/data/infosreg/actusnews/');
|
||||
|
||||
/** Paramétres du FTP de Di Release : Communiqués de presse
|
||||
**/
|
||||
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
|
||||
define('DIRELEASE_FTP_USER', 'scores_dir');
|
||||
define('DIRELEASE_FTP_PASS', '-gT52sQ');
|
||||
define('DIRELEASE_LOCAL_DIR', '/home/data/infosreg/direlease/');
|
||||
|
||||
/** Paramétres du FTP des Echos: Communiqués de presse
|
||||
**/
|
||||
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
|
||||
define('LESECHOS_FTP_USER', 'Scores');
|
||||
define('LESECHOS_FTP_PASS', 'scores2001');
|
||||
define('LESECHOS_LOCAL_DIR', '/home/data/infosreg/lesechos/');
|
||||
/*Directory : syndication*/
|
||||
|
||||
/** Paramétres du FTP de BusinessWire : Communiqués de presse
|
||||
**/
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
|
||||
|
||||
/** Base de données de S&D
|
||||
**/
|
||||
|
||||
define ('MYSQL_HOST', '192.168.3.30');//3');
|
||||
define ('MYSQL_USER', 'wsuser');
|
||||
define ('MYSQL_PASS', 'wspass2012');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
|
||||
define ('SPHINX_HOST', '192.168.3.32');
|
||||
define ('SPHINX_PORT', 9312);
|
||||
|
||||
|
||||
/** SERVEUR DE MESSAGERIE
|
||||
**/
|
||||
define ('SMTP_HOST', 'smtp.celeste.fr');
|
||||
//define ('SMTP_HOST', 'smtp.free.fr');
|
||||
define ('SMTP_PORT', 25);
|
||||
define ('SMTP_USER', '');
|
||||
define ('SMTP_PASS', '');
|
||||
|
||||
/** INFOGREFFE
|
||||
**/
|
||||
define('INFOGREFFE_DISPO', true);
|
||||
define('INFOGREFFE_DISPO_WS', true);
|
||||
define('INFOGREFFE_DISPO_WEB', true);
|
||||
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
||||
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
|
||||
// Nouvelle IP : 194.5.111.108
|
||||
// Ancienne IP : 194.5.120.108
|
||||
define('INFOGREFFE_WS_USER', '85000109');
|
||||
define('INFOGREFFE_WS_PASS', '166');
|
||||
|
||||
/** AMABIS
|
||||
**/
|
||||
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
|
||||
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');
|
||||
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define ('DOC_WEB_LOCAL', '/home/vhosts/data/');
|
||||
define ('DOC_WEB_URL', 'http://tville.scores-decisions.com/ws/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', '/var/log');
|
||||
|
||||
?>
|
1
config/install.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
104
config/local/config.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?
|
||||
define('INCLUDE_PATH', realpath(dirname(__FILE__)).'/');
|
||||
|
||||
/** BATCH
|
||||
**/
|
||||
define('FILLER',' ');
|
||||
define('VERSION_FICHIER_BODACC','0106');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
|
||||
/** Paramétres du FTP des JO
|
||||
**/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/data/bodacc/');
|
||||
define('JAL_LOCAL_DIR', '/home/data/jal/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse
|
||||
**/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/data/infosreg/hugin/');
|
||||
|
||||
/** Paramétres du FTP de ActusNews : Communiqués de presse
|
||||
**/
|
||||
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
|
||||
define('ACTUSNEWS_FTP_USER', 'scores_act');
|
||||
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
|
||||
define('ACTUSNEWS_LOCAL_DIR', '/home/data/infosreg/actusnews/');
|
||||
|
||||
/** Paramétres du FTP de Di Release : Communiqués de presse
|
||||
**/
|
||||
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
|
||||
define('DIRELEASE_FTP_USER', 'scores_dir');
|
||||
define('DIRELEASE_FTP_PASS', '-gT52sQ');
|
||||
define('DIRELEASE_LOCAL_DIR', '/home/data/infosreg/direlease/');
|
||||
|
||||
/** Paramétres du FTP des Echos: Communiqués de presse
|
||||
**/
|
||||
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
|
||||
define('LESECHOS_FTP_USER', 'Scores');
|
||||
define('LESECHOS_FTP_PASS', 'scores2001');
|
||||
define('LESECHOS_LOCAL_DIR', '/home/data/infosreg/lesechos/');
|
||||
/*Directory : syndication*/
|
||||
|
||||
/** Paramétres du FTP de BusinessWire : Communiqués de presse
|
||||
**/
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
|
||||
|
||||
/** Base de données de S&D
|
||||
**/
|
||||
|
||||
//define ('MYSQL_HOST', '192.168.3.24');
|
||||
define ('MYSQL_HOST', '192.168.3.30');//3');
|
||||
define ('MYSQL_USER', 'root');
|
||||
//define ('MYSQL_PASS', 'bj10sx');
|
||||
define ('MYSQL_PASS', 'scores');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
/*
|
||||
define ('SPHINX_HOST', '192.168.3.24');
|
||||
define ('SPHINX_PORT', 3312);
|
||||
*/
|
||||
|
||||
define ('SPHINX_HOST', '192.168.3.32');
|
||||
define ('SPHINX_PORT', 9312);
|
||||
|
||||
|
||||
/** SERVEUR DE MESSAGERIE
|
||||
**/
|
||||
define ('SMTP_HOST', 'smtp.celeste.fr');
|
||||
//define ('SMTP_HOST', 'smtp.free.fr');
|
||||
define ('SMTP_PORT', 25);
|
||||
define ('SMTP_USER', '');
|
||||
define ('SMTP_PASS', '');
|
||||
|
||||
/** INFOGREFFE
|
||||
**/
|
||||
define('INFOGREFFE_DISPO', true);
|
||||
define('INFOGREFFE_DISPO_WS', true);
|
||||
define('INFOGREFFE_DISPO_WEB', true);
|
||||
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
||||
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
|
||||
// Nouvelle IP : 194.5.111.108
|
||||
// Ancienne IP : 194.5.120.108
|
||||
define('INFOGREFFE_WS_USER', '85000109');
|
||||
define('INFOGREFFE_WS_PASS', '166');
|
||||
|
||||
/** AMABIS
|
||||
**/
|
||||
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
|
||||
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');
|
||||
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define ('DOC_WEB_LOCAL', '/var/www/html/ws/data/');
|
||||
define ('DOC_WEB_URL', 'http://tville.scores-decisions.com/ws/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', realpath('d:/www/dataws/log/'));
|
||||
|
||||
?>
|
104
config/sdsrvdev01/config.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?
|
||||
define('INCLUDE_PATH', realpath(dirname(__FILE__)).'/');
|
||||
|
||||
/** BATCH
|
||||
**/
|
||||
define('FILLER',' ');
|
||||
define('VERSION_FICHIER_BODACC','0106');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
|
||||
/** Paramétres du FTP des JO
|
||||
**/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/data/bodacc/');
|
||||
define('JAL_LOCAL_DIR', '/home/data/jal/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse
|
||||
**/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/data/infosreg/hugin/');
|
||||
|
||||
/** Paramétres du FTP de ActusNews : Communiqués de presse
|
||||
**/
|
||||
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
|
||||
define('ACTUSNEWS_FTP_USER', 'scores_act');
|
||||
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
|
||||
define('ACTUSNEWS_LOCAL_DIR', '/home/data/infosreg/actusnews/');
|
||||
|
||||
/** Paramétres du FTP de Di Release : Communiqués de presse
|
||||
**/
|
||||
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
|
||||
define('DIRELEASE_FTP_USER', 'scores_dir');
|
||||
define('DIRELEASE_FTP_PASS', '-gT52sQ');
|
||||
define('DIRELEASE_LOCAL_DIR', '/home/data/infosreg/direlease/');
|
||||
|
||||
/** Paramétres du FTP des Echos: Communiqués de presse
|
||||
**/
|
||||
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
|
||||
define('LESECHOS_FTP_USER', 'Scores');
|
||||
define('LESECHOS_FTP_PASS', 'scores2001');
|
||||
define('LESECHOS_LOCAL_DIR', '/home/data/infosreg/lesechos/');
|
||||
/*Directory : syndication*/
|
||||
|
||||
/** Paramétres du FTP de BusinessWire : Communiqués de presse
|
||||
**/
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
|
||||
|
||||
/** Base de données de S&D
|
||||
**/
|
||||
|
||||
//define ('MYSQL_HOST', '192.168.3.24');
|
||||
define ('MYSQL_HOST', '192.168.3.30');//3');
|
||||
define ('MYSQL_USER', 'root');
|
||||
//define ('MYSQL_PASS', 'bj10sx');
|
||||
define ('MYSQL_PASS', 'scores');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
/*
|
||||
define ('SPHINX_HOST', '192.168.3.24');
|
||||
define ('SPHINX_PORT', 3312);
|
||||
*/
|
||||
|
||||
define ('SPHINX_HOST', '192.168.3.32');
|
||||
define ('SPHINX_PORT', 9312);
|
||||
|
||||
|
||||
/** SERVEUR DE MESSAGERIE
|
||||
**/
|
||||
define ('SMTP_HOST', 'smtp.celeste.fr');
|
||||
//define ('SMTP_HOST', 'smtp.free.fr');
|
||||
define ('SMTP_PORT', 25);
|
||||
define ('SMTP_USER', '');
|
||||
define ('SMTP_PASS', '');
|
||||
|
||||
/** INFOGREFFE
|
||||
**/
|
||||
define('INFOGREFFE_DISPO', true);
|
||||
define('INFOGREFFE_DISPO_WS', true);
|
||||
define('INFOGREFFE_DISPO_WEB', true);
|
||||
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
||||
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
|
||||
// Nouvelle IP : 194.5.111.108
|
||||
// Ancienne IP : 194.5.120.108
|
||||
define('INFOGREFFE_WS_USER', '85000109');
|
||||
define('INFOGREFFE_WS_PASS', '166');
|
||||
|
||||
/** AMABIS
|
||||
**/
|
||||
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
|
||||
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');
|
||||
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define ('DOC_WEB_LOCAL', '/sites/dataws/');
|
||||
define ('DOC_WEB_URL', 'http://tville.scores-decisions.com/ws/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', '/sites/dataws/log');
|
||||
|
||||
?>
|
763
framework/common/chiffres.php
Normal file
@ -0,0 +1,763 @@
|
||||
<?
|
||||
|
||||
class WChiffes {
|
||||
|
||||
private static $tabChiffresEnLEttres = array( 0=>'zéro',
|
||||
1=>'un',
|
||||
2=>'deux',
|
||||
3=>'trois',
|
||||
4=>'quatre',
|
||||
5=>'cinq',
|
||||
6=>'six',
|
||||
7=>'sept',
|
||||
8=>'huit',
|
||||
9=>'neuf',
|
||||
10=>'dix',
|
||||
11=>'onze',
|
||||
12=>'douze',
|
||||
13=>'treize',
|
||||
14=>'quatorze',
|
||||
15=>'quinze',
|
||||
16=>'seize',
|
||||
17=>'dix sept',
|
||||
18=>'dix huit',
|
||||
19=>'dix neuf',
|
||||
20=>'vingt',
|
||||
21=>'vingt et un',
|
||||
22=>'vingt deux',
|
||||
23=>'vingt trois',
|
||||
24=>'vingt quatre',
|
||||
25=>'vingt cinq',
|
||||
26=>'vingt six',
|
||||
27=>'vingt sept',
|
||||
28=>'vingt huit',
|
||||
29=>'vingt neuf',
|
||||
30=>'trente',
|
||||
40=>'quarante',
|
||||
50=>'cinquante',
|
||||
60=>'soixante',
|
||||
70=>'soixante dix',
|
||||
80=>'quatre vingt',
|
||||
90=>'quatre vingt dix');
|
||||
|
||||
public function ChiffresEnLettres($chiffre) {
|
||||
return array_search($chiffre, self::$tabChiffresEnLEttres);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
define('NEL_SEPTANTE', 0x0001);
|
||||
define('NEL_HUITANTE', 0x0002);
|
||||
define('NEL_OCTANTE', 0x0004);
|
||||
define('NEL_NONANTE', 0x0008);
|
||||
define('NEL_BELGIQUE', NEL_SEPTANTE|NEL_NONANTE);
|
||||
define('NEL_VVF', NEL_SEPTANTE|NEL_HUITANTE|NEL_NONANTE);
|
||||
define('NEL_ARCHAIQUE', NEL_SEPTANTE|NEL_OCTANTE|NEL_NONANTE);
|
||||
define('NEL_SANS_MILLIARD', 0x0010);
|
||||
define('NEL_AVEC_ZILLIARD', 0x0020);
|
||||
define('NEL_TOUS_ZILLIONS', 0x0040);
|
||||
define('NEL_RECTIF_1990', 0x0100);
|
||||
define('NEL_ORDINAL', 0x0200);
|
||||
define('NEL_NIEME', 0x0400);
|
||||
|
||||
|
||||
# Le tableau associatif $NEL contient toutes les variables utilisées
|
||||
# de façon globale dans ce module. ATTENTION : ce nom est assez court,
|
||||
# et cela pourrait poser des problèmes de collision avec une autre
|
||||
# variable si plusieurs modules sont inclus dans le même programme.
|
||||
|
||||
$NEL = array(
|
||||
'1-99' => array(
|
||||
# 0-19
|
||||
'', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept',
|
||||
'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze',
|
||||
'quinze', 'seize', 'dix-sept', 'dix-huit', 'dix-neuf',
|
||||
# 20-29
|
||||
'vingt', 'vingt et un', 'vingt-deux', 'vingt-trois',
|
||||
'vingt-quatre', 'vingt-cinq', 'vingt-six',
|
||||
'vingt-sept', 'vingt-huit', 'vingt-neuf',
|
||||
# 30-39
|
||||
'trente', 'trente et un', 'trente-deux', 'trente-trois',
|
||||
'trente-quatre', 'trente-cinq', 'trente-six',
|
||||
'trente-sept', 'trente-huit', 'trente-neuf',
|
||||
# 40-49
|
||||
'quarante', 'quarante et un', 'quarante-deux', 'quarante-trois',
|
||||
'quarante-quatre', 'quarante-cinq', 'quarante-six',
|
||||
'quarante-sept', 'quarante-huit', 'quarante-neuf',
|
||||
# 50-59
|
||||
'cinquante', 'cinquante et un', 'cinquante-deux', 'cinquante-trois',
|
||||
'cinquante-quatre', 'cinquante-cinq', 'cinquante-six',
|
||||
'cinquante-sept', 'cinquante-huit', 'cinquante-neuf',
|
||||
# 60-69
|
||||
'soixante', 'soixante et un', 'soixante-deux', 'soixante-trois',
|
||||
'soixante-quatre', 'soixante-cinq', 'soixante-six',
|
||||
'soixante-sept', 'soixante-huit', 'soixante-neuf',
|
||||
# 70-79
|
||||
'septante', 'septante et un', 'septante-deux', 'septante-trois',
|
||||
'septante-quatre', 'septante-cinq', 'septante-six',
|
||||
'septante-sept', 'septante-huit', 'septante-neuf',
|
||||
# 80-89
|
||||
'huitante', 'huitante et un', 'huitante-deux', 'huitante-trois',
|
||||
'huitante-quatre', 'huitante-cinq', 'huitante-six',
|
||||
'huitante-sept', 'huitante-huit', 'huitante-neuf',
|
||||
# 90-99
|
||||
'nonante', 'nonante et un', 'nonante-deux', 'nonante-trois',
|
||||
'nonante-quatre', 'nonante-cinq', 'nonante-six',
|
||||
'nonante-sept', 'nonante-huit', 'nonante-neuf'
|
||||
),
|
||||
|
||||
'illi' => array('', 'm', 'b', 'tr', 'quatr', 'quint', 'sext'),
|
||||
'maxilli' => 0, # voir plus loin
|
||||
'de_maxillions' => '', # voir plus loin
|
||||
|
||||
'septante' => false, # valeurs possibles : (false|true)
|
||||
'huitante' => false, # valeurs possibles : (false|true|'octante')
|
||||
'nonante' => false, # valeurs possibles : (false|true)
|
||||
'zillions' => false, # valeurs possibles : (false|true)
|
||||
'zilliard' => 1, # valeurs possibles : (0|1|2)
|
||||
'rectif' => false, # valeurs possibles : (false|true)
|
||||
'ordinal' => false, # valeurs possibles : (false|true|'nieme')
|
||||
|
||||
'separateur' => ' '
|
||||
);
|
||||
|
||||
# Si le tableau $NEL['illi'] s'arrête à 'sext', alors les deux valeurs
|
||||
# suivantes sont respectivement '6' et ' de sextillions'.
|
||||
$NEL['maxilli'] = count($NEL['illi']) - 1;
|
||||
$NEL['de_maxillions'] = " de {$NEL['illi'][$NEL['maxilli']]}illions";
|
||||
|
||||
function enlettres_options($options, $separateur=NULL)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($options !== NULL) {
|
||||
$NEL['septante'] = ($options & NEL_SEPTANTE) ? true : false;
|
||||
$NEL['huitante'] =
|
||||
($options & NEL_OCTANTE) ? 'octante' :
|
||||
(($options & NEL_HUITANTE) ? true : false);
|
||||
$NEL['nonante'] = ($options & NEL_NONANTE) ? true : false;
|
||||
$NEL['zillions'] = ($options & NEL_TOUS_ZILLIONS) ? true : false;
|
||||
$NEL['zilliard'] =
|
||||
($options & NEL_AVEC_ZILLIARD) ? 2 :
|
||||
(($options & NEL_SANS_MILLIARD) ? 0 : 1);
|
||||
$NEL['rectif'] = ($options & NEL_RECTIF_1990) ? true : false;
|
||||
$NEL['ordinal'] =
|
||||
($options & NEL_NIEME) ? 'nieme' :
|
||||
(($options & NEL_ORDINAL) ? true : false);
|
||||
}
|
||||
|
||||
if ($separateur !== NULL) {
|
||||
$NEL['separateur'] = $separateur;
|
||||
}
|
||||
}
|
||||
|
||||
function enlettres_par3($par3)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($par3 == 0) return '';
|
||||
|
||||
$centaine = floor($par3 / 100);
|
||||
$par2 = $par3 % 100;
|
||||
$dizaine = floor($par2 / 10);
|
||||
|
||||
# On traite à part les particularités du français de référence
|
||||
# 'soixante-dix', 'quatre-vingts' et 'quatre-vingt-dix'.
|
||||
$nom_par2 = NULL;
|
||||
switch ($dizaine) {
|
||||
case 7:
|
||||
if ($NEL['septante'] === false) {
|
||||
if ($par2 == 71) $nom_par2 = 'soixante et onze';
|
||||
else $nom_par2 = 'soixante-' . $NEL['1-99'][$par2 - 60];
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if ($NEL['huitante'] === false) {
|
||||
if ($par2 == 80) $nom_par2 = 'quatre-vingts';
|
||||
else $nom_par2 = 'quatre-vingt-' . $NEL['1-99'][$par2 - 80];
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if ($NEL['nonante'] === false) {
|
||||
$nom_par2 = 'quatre-vingt-' . $NEL['1-99'][$par2 - 80];
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($nom_par2 === NULL) {
|
||||
$nom_par2 = $NEL['1-99'][$par2];
|
||||
if (($dizaine == 8) and ($NEL['huitante'] === 'octante')) {
|
||||
$nom_par2 = str_replace('huitante', 'octante', $nom_par2);
|
||||
}
|
||||
}
|
||||
|
||||
# Après les dizaines et les unités, il reste à voir les centaines
|
||||
switch ($centaine) {
|
||||
case 0: return $nom_par2;
|
||||
case 1: return rtrim("cent {$nom_par2}");
|
||||
}
|
||||
|
||||
# Assertion : $centaine = 2 .. 9
|
||||
$nom_centaine = $NEL['1-99'][$centaine];
|
||||
if ($par2 == 0) return "{$nom_centaine} cents";
|
||||
return "{$nom_centaine} cent {$nom_par2}";
|
||||
}
|
||||
|
||||
function enlettres_zilli($idx)
|
||||
{
|
||||
# Noms des 0ème à 9ème zillions
|
||||
static $petit = array(
|
||||
'n', 'm', 'b', 'tr', 'quatr', 'quint', 'sext', 'sept', 'oct', 'non'
|
||||
);
|
||||
# Composantes des 10ème à 999ème zillions
|
||||
static $unite = array(
|
||||
'<', 'un<', 'duo<', 'tre<sé',
|
||||
'quattuor<', 'quin<', 'se<xsé',
|
||||
'septe<mné', 'octo<', 'nove<mné'
|
||||
);
|
||||
static $dizaine = array(
|
||||
'', 'né>déci<', 'ms>viginti<', 'ns>triginta<',
|
||||
'ns>quadraginta<', 'ns>quinquaginta<', 'né>sexaginta<',
|
||||
'né>septuaginta<', 'mxs>octoginta<', 'é>nonaginta<'
|
||||
);
|
||||
static $centaine = array(
|
||||
'>', 'nxs>cent', 'né>ducent', 'ns>trécent',
|
||||
'ns>quadringent', 'ns>quingent', 'né>sescent',
|
||||
'né>septingent', 'mxs>octingent', 'é>nongent'
|
||||
);
|
||||
|
||||
# Règles d'assimilation aux préfixes latins, modifiées pour accentuer
|
||||
# un éventuel 'é' de fin de préfixe.
|
||||
# (1) Si on trouve une lettre deux fois entre < > on la garde.
|
||||
# S'il y a plusieurs lettres dans ce cas, on garde la première.
|
||||
# (2) Sinon on efface tout ce qui est entre < >.
|
||||
# (3) On remplace "treé" par "tré", "seé" par "sé", "septeé" par "septé"
|
||||
# et "noveé" par "nové".
|
||||
# (4) En cas de dizaine sans centaine, on supprime la voyelle en trop.
|
||||
# Par exemple "déciilli" devient "décilli" et "trigintailli" devient
|
||||
# "trigintilli".
|
||||
#
|
||||
# Il est à noter que ces règles PERL (en particulier la première qui
|
||||
# est la plus complexe) sont *très* fortement inspirées du programme
|
||||
# de Nicolas Graner. On pourrait même parler de plagiat s'il n'avait
|
||||
# pas été au courant que je reprenais son code.
|
||||
# Voir <http://www.graner.net/nicolas/nombres/nom.php>
|
||||
# et <http://www.graner.net/nicolas/nombres/nom-exp.php>
|
||||
#
|
||||
static $recherche = array(
|
||||
'/<[a-zé]*?([a-zé])[a-zé]*\1[a-zé]*>/', # (1)
|
||||
'/<[a-zé]*>/', # (2)
|
||||
'/eé/', # (3)
|
||||
'/[ai]illi/' # (4)
|
||||
);
|
||||
static $remplace = array(
|
||||
'\\1', # (1)
|
||||
'', # (2)
|
||||
'é', # (3)
|
||||
'illi' # (4)
|
||||
);
|
||||
|
||||
$nom = '';
|
||||
while ($idx > 0) {
|
||||
$p = $idx % 1000;
|
||||
$idx = floor($idx/1000);
|
||||
|
||||
if ($p < 10) {
|
||||
$nom = $petit[$p] . 'illi' . $nom;
|
||||
} else {
|
||||
$nom = $unite[$p % 10] . $dizaine[floor($p/10) % 10]
|
||||
. $centaine[floor($p/100)] . 'illi' . $nom;
|
||||
}
|
||||
}
|
||||
return preg_replace($recherche, $remplace, $nom);
|
||||
}
|
||||
|
||||
function enlettres_illions($idx)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($idx == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($NEL['zillions']) {
|
||||
return enlettres_zilli($idx) . 'ons';
|
||||
}
|
||||
|
||||
$suffixe = '';
|
||||
while ($idx > $NEL['maxilli']) {
|
||||
$idx -= $NEL['maxilli'];
|
||||
$suffixe .= $NEL['de_maxillions'];
|
||||
}
|
||||
return "{$NEL['illi'][$idx]}illions{$suffixe}";
|
||||
}
|
||||
|
||||
function enlettres_avec_illiards($idx)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($idx == 0) return false;
|
||||
switch ($NEL['zilliard']) {
|
||||
case 0: return false;
|
||||
case 2: return true;
|
||||
}
|
||||
return ($idx == 1);
|
||||
}
|
||||
|
||||
function enlettres($nombre, $options=NULL, $separateur=NULL)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($options !== NULL or $separateur !== NULL) {
|
||||
$NELsave = $NEL;
|
||||
enlettres_options($options, $separateur);
|
||||
$nom = enlettres($nombre);
|
||||
$NEL = $NELsave;
|
||||
return $nom;
|
||||
}
|
||||
|
||||
# On ne garde que les chiffres, puis on supprime les 0 du début
|
||||
$nombre = preg_replace('/[^0-9]/', '', $nombre);
|
||||
$nombre = ltrim($nombre, '0');
|
||||
|
||||
if ($nombre == '') {
|
||||
if ($NEL['ordinal'] === 'nieme') return 'zéroïème';
|
||||
else return 'zéro';
|
||||
}
|
||||
|
||||
$table_noms = array();
|
||||
for ($idx = 0; $nombre != ''; $idx++) {
|
||||
$par6 = (int)((strlen($nombre) < 6) ? $nombre : substr($nombre, -6));
|
||||
$nombre = substr($nombre, 0, -6);
|
||||
|
||||
if ($par6 == 0) continue;
|
||||
|
||||
$nom_par3_sup = enlettres_par3(floor($par6 / 1000));
|
||||
$nom_par3_inf = enlettres_par3($par6 % 1000);
|
||||
|
||||
$illions = enlettres_illions($idx);
|
||||
if (enlettres_avec_illiards($idx)) {
|
||||
if ($nom_par3_inf != '') {
|
||||
$table_noms[$illions] = $nom_par3_inf;
|
||||
}
|
||||
if ($nom_par3_sup != '') {
|
||||
$illiards = preg_replace('/illion/', 'illiard', $illions, 1);
|
||||
$table_noms[$illiards] = $nom_par3_sup;
|
||||
}
|
||||
} else {
|
||||
switch($nom_par3_sup) {
|
||||
case '':
|
||||
$nom_par6 = $nom_par3_inf;
|
||||
break;
|
||||
case 'un':
|
||||
$nom_par6 = rtrim("mille {$nom_par3_inf}");
|
||||
break;
|
||||
default:
|
||||
$nom_par3_sup = preg_replace('/(vingt|cent)s/', '\\1', $nom_par3_sup);
|
||||
$nom_par6 = rtrim("{$nom_par3_sup} mille {$nom_par3_inf}");
|
||||
break;
|
||||
}
|
||||
$table_noms[$illions] = $nom_par6;
|
||||
}
|
||||
}
|
||||
|
||||
$nom_enlettres = '';
|
||||
foreach ($table_noms as $nom => $nombre) {
|
||||
##
|
||||
# $nombre est compris entre 'un' et
|
||||
# 'neuf cent nonante-neuf mille neuf cent nonante-neuf'
|
||||
# (ou variante avec 'quatre-vingt-dix-neuf')
|
||||
##
|
||||
# $nom peut valoir '', 'millions', 'milliards', 'billions', ...
|
||||
# 'sextillions', 'sextilliards', 'millions de sextillions',
|
||||
# 'millions de sextilliards', etc.
|
||||
##
|
||||
|
||||
# Rectifications orthographiques de 1990
|
||||
if ($NEL['rectif']) {
|
||||
$nombre = str_replace(' ', '-', $nombre);
|
||||
}
|
||||
|
||||
# Nom (éventuel) et accord (éventuel) des substantifs
|
||||
$nom = rtrim("{$nombre} {$nom}");
|
||||
if ($nombre == 'un') {
|
||||
# Un seul million, milliard, etc., donc au singulier
|
||||
# noter la limite de 1 remplacement, pour ne supprimer que le premier 's'
|
||||
# dans 'billions de sextillions de sextillions'
|
||||
$nom = preg_replace('/(illion|illiard)s/', '\\1', $nom, 1);
|
||||
}
|
||||
|
||||
# Ajout d'un séparateur entre chaque partie
|
||||
if ($nom_enlettres == '') {
|
||||
$nom_enlettres = $nom;
|
||||
} else {
|
||||
$nom_enlettres = $nom . $NEL['separateur'] . $nom_enlettres;
|
||||
}
|
||||
}
|
||||
|
||||
if ($NEL['ordinal'] === false) {
|
||||
# Nombre cardinal : le traitement est fini
|
||||
return $nom_enlettres;
|
||||
}
|
||||
|
||||
# Aucun pluriel dans les ordinaux
|
||||
$nom_enlettres =
|
||||
preg_replace('/(cent|vingt|illion|illiard)s/', '\\1', $nom_enlettres);
|
||||
|
||||
if ($NEL['ordinal'] !== 'nieme') {
|
||||
# Nombre ordinal simple (sans '-ième')
|
||||
return $nom_enlettres;
|
||||
}
|
||||
|
||||
if ($nom_enlettres === 'un') {
|
||||
# Le féminin n'est pas traité ici. On fait la supposition
|
||||
# qu'il est plus facile de traiter ce cas à part plutôt
|
||||
# que de rajouter une option rien que pour ça.
|
||||
return 'premier';
|
||||
}
|
||||
|
||||
switch (substr($nom_enlettres, -1)) {
|
||||
case 'e':
|
||||
# quatre, onze à seize, trente à nonante, mille
|
||||
# exemple : quatre -> quatrième
|
||||
return substr($nom_enlettres, 0, -1) . 'ième';
|
||||
case 'f':
|
||||
# neuf -> neuvième
|
||||
return substr($nom_enlettres, 0, -1) . 'vième';
|
||||
case 'q':
|
||||
# cinq -> cinquième
|
||||
return $nom_enlettres . 'uième';
|
||||
}
|
||||
|
||||
# Tous les autres cas.
|
||||
# Exemples: deuxième, troisième, vingtième, trente et unième,
|
||||
# neuf centième, un millionième, quatre-vingt milliardième.
|
||||
return $nom_enlettres . 'ième';
|
||||
}
|
||||
|
||||
function enchiffres_petit($mot)
|
||||
{
|
||||
static $petit = array(
|
||||
# 1-16
|
||||
'un' => 1,
|
||||
'deux' => 2,
|
||||
'trois' => 3,
|
||||
'quatre' => 4,
|
||||
'cinq' => 5,
|
||||
'six' => 6,
|
||||
'sept' => 7,
|
||||
'huit' => 8,
|
||||
'neuf' => 9,
|
||||
'dix' => 10,
|
||||
'onze' => 11,
|
||||
'douze' => 12,
|
||||
'treize' => 13,
|
||||
'quatorze' => 14,
|
||||
'quinze' => 15,
|
||||
'seize' => 16,
|
||||
# 20-90
|
||||
'vingt' => 20,
|
||||
'vingts' => 20,
|
||||
'trente' => 30,
|
||||
'quarante' => 40,
|
||||
'cinquante' => 50,
|
||||
'soixante' => 60,
|
||||
'septante' => 70,
|
||||
'huitante' => 80,
|
||||
'octante' => 80,
|
||||
'nonante' => 90,
|
||||
# 100, 1000
|
||||
'cent' => 100,
|
||||
'cents' => 100,
|
||||
'mil' => 1000,
|
||||
'mille' => 1000
|
||||
);
|
||||
|
||||
if (! isset($petit[$mot]))
|
||||
return false;
|
||||
|
||||
return $petit[$mot];
|
||||
}
|
||||
|
||||
function enchiffres_zilli($mot)
|
||||
{
|
||||
# Noms des 0ème à 9ème zillions
|
||||
static $petits = array(
|
||||
'n', 'm', 'b', 'tr', 'quadr', 'quint', 'sext', 'sept', 'oct', 'non'
|
||||
);
|
||||
# Composantes des 10ème à 999ème zillions
|
||||
static $unites = array(
|
||||
'', 'un', 'duo', 'tre', 'quattuor', 'quin', 'se', 'septe', 'octo', 'nove'
|
||||
);
|
||||
static $dizaines = array(
|
||||
'', 'dec', 'vigint', 'trigint', 'quadragint',
|
||||
'quinquagint', 'sexagint', 'septuagint', 'octogint', 'nonagint'
|
||||
);
|
||||
static $centaines = array(
|
||||
'', 'cent', 'ducent', 'trecent', 'quadringent',
|
||||
'quingent', 'sescent', 'septingent', 'octingent', 'nongent'
|
||||
);
|
||||
# Expressions rationnelles pour extraire les composantes
|
||||
static $um =
|
||||
'(|un|duo|tre(?!c)|quattuor|quin|se(?!p)(?!sc)|septe|octo|nove)[mnsx]?';
|
||||
static $dm =
|
||||
'(|dec|(?:v|tr|quadr|quinqu|sex|septu|oct|non)[aio]gint)[ai]?';
|
||||
static $cm =
|
||||
'(|(?:|du|tre|ses)cent|(?:quadri|qui|septi|octi|no)ngent)';
|
||||
|
||||
$u = array_search($mot, $petits);
|
||||
if ($u !== false) {
|
||||
return '00' . $u;
|
||||
}
|
||||
|
||||
if (preg_match('/^'.$um.$dm.$cm.'$/', $mot, $resultat) < 1) {
|
||||
return false;
|
||||
}
|
||||
$u = array_search($resultat[1], $unites);
|
||||
$d = array_search($resultat[2], $dizaines);
|
||||
$c = array_search($resultat[3], $centaines);
|
||||
if ($u === false or $d === false or $c === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $c.$d.$u;
|
||||
}
|
||||
|
||||
function enchiffres_grand($mot)
|
||||
{
|
||||
# Quelques remplacements initiaux pour simplifier (les 'é' ont déjà
|
||||
# été tous transformés en 'e').
|
||||
# (1) Je supprime le 's' final de '-illions' ou '-illiards' pour ne
|
||||
# tester que '-illion' ou '-illiard'.
|
||||
# (2) Les deux orthographes étant possibles pour quadrillion ou
|
||||
# quatrillion, je teste les deux. Noter que j'aurais pu changer
|
||||
# 'quadr' en 'quatr' au lieu de l'inverse, mais alors cela aurait
|
||||
# aussi changé 'quadragintillion' en 'quatragintillion', ce qui
|
||||
# n'est pas franchement le but recherché.
|
||||
# (3) En latin, on trouve parfois 'quatuor' au lieu de 'quattuor'. De même,
|
||||
# avec google on trouve quelques 'quatuordecillions' au milieu des
|
||||
# 'quattuordecillions' (environ 1 sur 10).
|
||||
# (4) La règle de John Conway et Allan Wechsler préconisait le préfixe
|
||||
# 'quinqua' au lieu de 'quin' que j'ai choisi. Pour accepter les deux,
|
||||
# je remplace 'quinqua' par 'quin', sauf dans 'quinquaginta' (50)
|
||||
# et dans 'quinquadraginta' (45).
|
||||
static $recherche = array(
|
||||
'/s$/', # (1)
|
||||
'/quatr/', # (2)
|
||||
'/quatuor/', # (3)
|
||||
'/quinqua(?!(dra)?gint)/' # (4)
|
||||
);
|
||||
static $remplace = array(
|
||||
'', # (1)
|
||||
'quadr', # (2)
|
||||
'quattuor', # (3)
|
||||
'quin' # (4)
|
||||
);
|
||||
|
||||
$mot = preg_replace($recherche, $remplace, $mot);
|
||||
if ($mot == 'millier') return 1;
|
||||
if ($mot == 'millinillion') return 2000;
|
||||
|
||||
$prefixes = explode('illi', $mot);
|
||||
if (count($prefixes) < 2) {
|
||||
# Il faut au moins un 'illi' dans le nom
|
||||
return false;
|
||||
}
|
||||
switch (array_pop($prefixes)) {
|
||||
case 'on':
|
||||
# zillion : nombre pair de milliers
|
||||
$ard = 0;
|
||||
break;
|
||||
case 'ard':
|
||||
# zilliard : nombre impair de milliers
|
||||
$ard = 1;
|
||||
break;
|
||||
default:
|
||||
# Ce n'est ni un zillion, ni un zilliard
|
||||
return false;
|
||||
}
|
||||
|
||||
$nombre = '';
|
||||
foreach ($prefixes as $prefixe) {
|
||||
$par3 = enchiffres_zilli($prefixe);
|
||||
if ($par3 === false) return false;
|
||||
$nombre .= $par3;
|
||||
}
|
||||
if (strlen($nombre) > 3) {
|
||||
# On n'accepte que les nombres inférieurs au millinillion
|
||||
# pour limiter le temps de calcul
|
||||
return 0;
|
||||
}
|
||||
return 2*$nombre + $ard;
|
||||
}
|
||||
|
||||
class enchiffres_struct
|
||||
{
|
||||
var $valeur;
|
||||
var $discr;
|
||||
|
||||
function enchiffres_struct($mul, $val)
|
||||
{
|
||||
$this->valeur = $this->discr = $val;
|
||||
if ($mul != 0) {
|
||||
$this->valeur *= $mul;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enchiffres_ajouter_petit(&$table_petits, $petit)
|
||||
{
|
||||
$somme = 0;
|
||||
while (($elem = array_pop($table_petits)) !== NULL) {
|
||||
if ($elem->discr > $petit) {
|
||||
array_push($table_petits, $elem);
|
||||
break;
|
||||
}
|
||||
$somme += $elem->valeur;
|
||||
}
|
||||
$elem = new enchiffres_struct($somme, $petit);
|
||||
array_push($table_petits, $elem);
|
||||
}
|
||||
|
||||
function enchiffres_somme_petits($table_petits)
|
||||
{
|
||||
$somme = 0;
|
||||
foreach ($table_petits as $elem) {
|
||||
$somme += $elem->valeur;
|
||||
}
|
||||
return $somme;
|
||||
}
|
||||
|
||||
function enchiffres_ajouter_grand(&$table_grands, $mantisse, $exposant)
|
||||
{
|
||||
while ($mantisse > 0) {
|
||||
if (isset($table_grands[$exposant])) {
|
||||
$mantisse += $table_grands[$exposant];
|
||||
}
|
||||
$table_grands[$exposant] = $mantisse % 1000;
|
||||
$mantisse = floor($mantisse / 1000);
|
||||
$exposant++;
|
||||
}
|
||||
}
|
||||
|
||||
function enchiffres($nom)
|
||||
{
|
||||
$nom = preg_replace('/[éèÉÈ]/', 'e', $nom);
|
||||
$nom = strtolower($nom);
|
||||
$table_mots = preg_split('/[^a-z]+/', $nom);
|
||||
|
||||
$table_petits = array();
|
||||
$mantisse = $exposant = 0;
|
||||
$table_grands = array();
|
||||
|
||||
foreach ($table_mots as $mot) {
|
||||
$petit = enchiffres_petit($mot);
|
||||
if ($petit !== false) {
|
||||
if ($mantisse != 0) {
|
||||
enchiffres_ajouter_grand($table_grands, $mantisse, $exposant);
|
||||
$mantisse = $exposant = 0;
|
||||
}
|
||||
enchiffres_ajouter_petit($table_petits, $petit);
|
||||
continue;
|
||||
}
|
||||
|
||||
$grand = enchiffres_grand($mot);
|
||||
if ($grand === false) {
|
||||
# Ce n'est pas un nombre
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($grand == 0) {
|
||||
# Ce nombre était trop grand (millinillion et plus) : on annule le
|
||||
# tout pour limiter le temps de calcul.
|
||||
$mantisse = 0;
|
||||
$exposant = 0;
|
||||
$table_petits = array();
|
||||
} else {
|
||||
if (count($table_petits) > 0) {
|
||||
$mantisse = enchiffres_somme_petits($table_petits);
|
||||
$exposant = 0;
|
||||
$table_petits = array();
|
||||
}
|
||||
if ($mantisse != 0) {
|
||||
$exposant += $grand;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($table_petits) > 0) {
|
||||
$mantisse = enchiffres_somme_petits($table_petits);
|
||||
$exposant = 0;
|
||||
}
|
||||
if ($mantisse != 0) {
|
||||
enchiffres_ajouter_grand($table_grands, $mantisse, $exposant);
|
||||
}
|
||||
|
||||
$nombre = "";
|
||||
for ($exposant = 0; count($table_grands) > 0; $exposant++) {
|
||||
if (isset($table_grands[$exposant])) {
|
||||
$par3 = $table_grands[$exposant];
|
||||
unset($table_grands[$exposant]);
|
||||
} else {
|
||||
$par3 = 0;
|
||||
}
|
||||
$nombre = sprintf("%03d", $par3) . $nombre;
|
||||
}
|
||||
$nombre = ltrim($nombre, '0');
|
||||
if ($nombre === '') $nombre = '0';
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function enchiffres_aerer($nombre, $blanc=' ', $virgule=',', $tranche=3)
|
||||
{
|
||||
# Si c'est un nombre à virgule, on traite séparément les deux parties
|
||||
if ($virgule !== NULL) {
|
||||
$ent_dec = preg_split("/$virgule/", $nombre);
|
||||
if (count($ent_dec) >= 2) {
|
||||
$ent = enchiffres_aerer($ent_dec[0], $blanc, NULL, $tranche);
|
||||
$dec = enchiffres_aerer($ent_dec[1], $blanc, NULL, -$tranche);
|
||||
return $ent . $virgule . $dec;
|
||||
}
|
||||
}
|
||||
|
||||
# On ne garde que les chiffres
|
||||
$nombre = preg_replace('/[^0-9]/', '', $nombre);
|
||||
|
||||
# Il est plus logique d'avoir un nombre positif pour les entiers,
|
||||
# donc négatif pour la partie décimale, mais plus pratique de
|
||||
# faire le contraire pour les substr().
|
||||
$tranche = - (int)$tranche;
|
||||
|
||||
if ($tranche == 0) {
|
||||
# on voulait juste supprimer les caractères en trop, pas en rajouter
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
$nombre_aere = '';
|
||||
if ($tranche < 0) {
|
||||
# entier, ou partie entière d'un nombre décimal
|
||||
while ($nombre != '') {
|
||||
$par3 = substr($nombre, $tranche);
|
||||
$nombre = substr($nombre, 0, $tranche);
|
||||
if ($nombre_aere == '') {
|
||||
$nombre_aere = $par3;
|
||||
} else {
|
||||
$nombre_aere = $par3 . $blanc . $nombre_aere;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# partie décimale
|
||||
while ($nombre != '') {
|
||||
$par3 = substr($nombre, 0, $tranche);
|
||||
$nombre = substr($nombre, $tranche);
|
||||
if ($nombre_aere == '') {
|
||||
$nombre_aere = $par3;
|
||||
} else {
|
||||
$nombre_aere .= $blanc . $par3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $nombre_aere;
|
||||
}
|
||||
|
||||
*/
|
||||
?>
|
287
framework/common/curl.php
Normal file
@ -0,0 +1,287 @@
|
||||
<?
|
||||
|
||||
/** Parse une page Html et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function parse_response($this_response) {
|
||||
|
||||
|
||||
// Split response into header and body sections
|
||||
list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2);
|
||||
$response_header_lines = explode("\r\n", $response_headers);
|
||||
|
||||
// First line of headers is the HTTP response code
|
||||
$http_response_line = array_shift($response_header_lines);
|
||||
if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; }
|
||||
|
||||
// put the rest of the headers in an array
|
||||
$response_header_array = array();
|
||||
$nbRMID=0;
|
||||
foreach($response_header_lines as $header_line)
|
||||
{
|
||||
list($header,$value) = explode(': ', $header_line, 2);
|
||||
|
||||
if ($header=='Set-cookie' && substr($value,0,5)=='RMID=' && $nbRMID<5)//{
|
||||
$nbRMID++;
|
||||
// echo ("Je gicle le RMID n°$nbRMID\r\n");}
|
||||
else
|
||||
@$response_header_array[$header] .= $value."\n";
|
||||
}
|
||||
return array('code' => $response_code, 'header' => $response_header_array, 'body' => $response_body);
|
||||
}
|
||||
|
||||
/** Récupère une page HTML en fonction des paramètres :
|
||||
** $url Url distante de la page à récupérer
|
||||
** $strCookies Chaine de caractère contenant les cookies
|
||||
** $postData Tableau des données à passer en POST uniquement
|
||||
** $referer Referer à indiquer lors de l'appel de la page
|
||||
** $debug Activer le débogage (True/False)
|
||||
**
|
||||
** ... et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function getUrl($url, $strCookies='', $postData='', $referer='', $debug=false, $host='', $proxy='', $timeout=0, $nbRetry=0) {
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
if ($host=='')
|
||||
$this_header = array('Host: '. parse_url($url, PHP_URL_HOST));
|
||||
else
|
||||
$this_header = array('Host: '. $host);
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
if ($proxy<>'') curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
|
||||
|
||||
if (((int)$timeout)<>0) {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int)$timeout);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
|
||||
if (preg_match('/^https/i',$url))
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $referer);
|
||||
|
||||
// Add each cookie that has been returned in the response
|
||||
// If cookies need to be added/deleted or value changed, then add code here
|
||||
if ($strCookies!='') {
|
||||
//die('"'.$strCookies.'"');
|
||||
//echo $strCookies."\r\n";
|
||||
$cookies = explode("\n", $strCookies);
|
||||
// Create the basic header
|
||||
foreach($cookies as $this_cookie) {
|
||||
if (trim($this_cookie)<>'')
|
||||
array_push($this_header, 'Cookie: '.$this_cookie);
|
||||
}
|
||||
}
|
||||
|
||||
if ($postData!='') {
|
||||
if (is_array($postData))
|
||||
$post_data=$postData;
|
||||
|
||||
$o="";
|
||||
foreach ($post_data as $k=>$v)
|
||||
{
|
||||
$o.= "$k=".utf8_encode($v)."&";
|
||||
}
|
||||
$post_data=substr($o,0,-1);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
//if in_array('',$this_header
|
||||
/*array_push($this_header, "Content-type: application/x-www-form-urlencoded");
|
||||
array_push($this_header, "Content-Length: 44");*/
|
||||
}
|
||||
|
||||
/* curl_setopt($ch, CURLOPT_STDERR, LOG_PATH.'/curlerror.log');
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
*/
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
|
||||
//print_r($this_header);
|
||||
|
||||
if ($nbRetry==0) {
|
||||
$page=curl_exec($ch);
|
||||
if($page === false) {
|
||||
if (curl_errno($ch) == 28) //TIMEOUT
|
||||
$response=array('code' =>408, 'header' =>array('curl_errno'=>curl_errno($ch),'curl_error'=>curl_error($ch)), 'body' =>'Connexion impossible au site du partenaire/Timeout');
|
||||
else
|
||||
$response=array('code' =>400, 'header' =>array('curl_errno'=>curl_errno($ch),'curl_error'=>curl_error($ch)), 'body' =>'Erreur Curl : ' . curl_error($ch));
|
||||
} else
|
||||
$response = parse_response($page);
|
||||
} else {
|
||||
$numTry=0;
|
||||
while($numTry<=$nbRetry) {
|
||||
$page=curl_exec($ch);
|
||||
if($page === false) {
|
||||
if (curl_errno($ch) == 28) //TIMEOUT
|
||||
$response=array('code' =>408, 'header' =>array('curl_errno'=>curl_errno($ch),'curl_error'=>curl_error($ch)), 'body' =>'Connexion impossible au site du partenaire');
|
||||
else
|
||||
$response=array('code' =>400, 'header' =>array('curl_errno'=>curl_errno($ch),'curl_error'=>curl_error($ch)), 'body' =>'Erreur Curl : ' . curl_error($ch));
|
||||
} else {
|
||||
$response = parse_response($page);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($debug){
|
||||
$url2=str_replace('http://', '', $url);
|
||||
$url2=str_replace('/', '_', $url2);
|
||||
$url2=str_replace('?', '(param)', $url2);
|
||||
$url2=str_replace('&', '(et)', $url2);
|
||||
|
||||
|
||||
$fp=fopen('/tmp/curl-'. date('Ymd-His') .'-'. microtime_float(true) .'-'. $url2 . '.html', 'a');
|
||||
fwrite($fp, $url."\r\n");
|
||||
fwrite($fp, $page);
|
||||
fclose($fp);
|
||||
//echo strip_tags(html_entity_decode($response['body']), '<td>');
|
||||
}
|
||||
//print_r(curl_getinfo($ch));
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/** Recherche un texte dans une page HTML
|
||||
**
|
||||
**/
|
||||
function getTextInHtml($pageHtml, $strToFind, $strDeb, $strEnd, $include_strDeb=false, $include_strEnd=false, $ltrim=true, $rtrim=true, &$fin, $nbOcc=1) {
|
||||
$tabRet=array();
|
||||
$deb=$nbOccTrouve=0;
|
||||
while( is_int(($deb=strpos($pageHtml,$strToFind,$fin))) ) {
|
||||
$deb++;
|
||||
$deb2 = strpos($pageHtml,$strDeb, $deb);
|
||||
$fin = strpos($pageHtml,$strEnd, $deb2);
|
||||
if (!$include_strDeb)
|
||||
$deb2+=strlen($strDeb);
|
||||
$s_temp = substr($pageHtml, $deb2, ($fin-$deb2));
|
||||
|
||||
if ($ltrim) $s_temp=ltrim($s_temp);
|
||||
if ($rtrim) $s_temp=rtrim($s_temp);
|
||||
|
||||
if ($nbOcc==1) return $s_temp;
|
||||
//echo $s_temp."\r\n";
|
||||
//$a_temp = explode('" class="basic">', $s_temp);
|
||||
$tabUrl[$nbOccTrouve]=$s_temp;
|
||||
$nbOccTrouve++;
|
||||
|
||||
if ($nbOcc==$nbOccTrouve) {
|
||||
// echo "j'ai trouvé le nb demandé, je sort\r\n";
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return $tabUrl;
|
||||
/*<span class="mongrasvert">
|
||||
<li>Le type de voie a été modifié<br>
|
||||
<li>L'orthographe du mot directeur a été modifiée<br>
|
||||
<li>Le code postal a été forcé à partir du département et de la localité<br> </span>
|
||||
*/
|
||||
}
|
||||
|
||||
function getPdfInfo($f){
|
||||
$tabInfo=array( 'file'=>$f,
|
||||
'fileName'=>basename($f));
|
||||
$handle = @fopen($f, 'r');
|
||||
if ($handle) {
|
||||
//echo '1'.EOL;
|
||||
$i=$nbPages=$buffer=0;
|
||||
while (!feof($handle)) {
|
||||
$prev_buffer=$buffer;
|
||||
$buffer = fgets($handle, 4096);
|
||||
if ($i==0 && preg_match("/^\%PDF\-(.*)\s/U", $buffer, $matches))
|
||||
$tabInfo['version']=$matches[1];
|
||||
elseif (preg_match("/Type\s*\/Page[^s]/", $buffer) )
|
||||
++$nbPages;
|
||||
$i++;
|
||||
}
|
||||
//echo '2'.EOL;
|
||||
if (preg_match("/\%\%EOF$/", $prev_buffer) || preg_match("/\%\%EOF/", $prev_buffer) || preg_match("/\%\%EOF/", $buffer)) {
|
||||
//echo '3'.EOL;
|
||||
$tabInfo['pdfEOF']=true;
|
||||
} else {
|
||||
/*echo '4 prev:'.$prev_buffer.EOL;
|
||||
echo '4 last:'.$buffer.EOL;*/
|
||||
$tabInfo['debugBuffer']=$prev_buffer;
|
||||
return false;
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
//echo '5'.EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
$tabInfo['pdfSize']=filesize($f);
|
||||
$tabInfo['nbPages']=0+$nbPages;
|
||||
//$tabInfo['debugBuffer']=$prev_buffer;
|
||||
return $tabInfo;
|
||||
}
|
||||
|
||||
|
||||
function simpleWhois($domain, $tdl, $debug=false) {
|
||||
// Fonction de traitement
|
||||
// -----------------------------------------------
|
||||
// 0 => Info, le nom est pris
|
||||
// 1 => Info, le nom est libre
|
||||
// 2 => Info, le nom est en pending
|
||||
// 3 => Avertissement, trop de requêtes
|
||||
// 4 => Erreur, il faut spécifier une chaine à rechercher (regexp)
|
||||
// 5 => Erreur, la requête retournée était vide
|
||||
// -----------------------------------------------
|
||||
|
||||
// Informations spécifiques aux extensions
|
||||
$info = array(
|
||||
'fr' => array(
|
||||
'host' => 'whois.nic.fr',
|
||||
'regexp' => 'No[s]*entries[s]*found',
|
||||
'pending' => 'status[s]*:[s]*REDEMPTION'
|
||||
),
|
||||
'com' => array(
|
||||
'host' => 'whois.crsnic.net',
|
||||
'regexp' => 'No[s]*match[s]*for'
|
||||
),
|
||||
'net' => array(
|
||||
'host' => 'whois.crsnic.net',
|
||||
'regexp' => 'No[s]*match[s]*for'
|
||||
),
|
||||
);
|
||||
|
||||
// Initialisation de la sortie
|
||||
$output = '';
|
||||
// Initialisation de la requête
|
||||
$req = fsockopen($info[$tdl]['host'], 43, $errno, $errstr, 5); // le 5 permet de stopper la requete si aucune réponse au bout de 5 secondes
|
||||
// Récupération de la requête
|
||||
if($req){
|
||||
fputs($req, $domain.'.'.$tdl."rn");
|
||||
while(!feof($req)) $output .= fgets($req, 4096);
|
||||
fclose($req);
|
||||
}else unset($req);
|
||||
// mode debug
|
||||
if($debug) return $output;
|
||||
// Sortie vide
|
||||
if(empty($output)) return 5;
|
||||
// Trop de requêtes
|
||||
if(preg_match("/(Too[s]+many[s]+requests|Your[s]+connection[s]+limit[s]+exceeded|daily[s]+whois[s]+limit[s]+exceeded|Maximum[s]+queries|WHOIS[s]+LIMIT[s]+EXCEEDED|referral[s]+host[s]+not[s]+responding|Excessive[s]+querying)/i", $output)) return 3;
|
||||
// Pending
|
||||
if(isset($info[$tdl]['pending']) && !empty($info[$tdl]['pending']) && preg_match("/".$info[$tdl]['pending']."/i", $output)) return 2;
|
||||
// Info de recheche manquant
|
||||
if(!isset($info[$tdl]['regexp']) || empty($info[$tdl]['regexp'])) return 4;
|
||||
// Libre
|
||||
if(preg_match("/".$info[$tdl]['regexp']."/i", $output)) return 1;
|
||||
// Pris
|
||||
return 0;
|
||||
}
|
||||
|
||||
?>
|
204
framework/common/dates.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?
|
||||
|
||||
include_once('chiffres.php');
|
||||
|
||||
|
||||
/**
|
||||
* Classe de gestion des méthodes relatives à la date et à l'heure
|
||||
*
|
||||
* <p>détail de la classe</p>
|
||||
*
|
||||
* @name nom de la classe
|
||||
* @author Nom de l'auteur <adresse@Email.dom>
|
||||
* @link
|
||||
* @copyright Prénom Nom Année
|
||||
* @version 1.0.0
|
||||
* @package Nom du package
|
||||
*/
|
||||
|
||||
class WDate {
|
||||
|
||||
private static $tabMoisEnLettres = array( 1=>'Janvier',
|
||||
2=>'Février',
|
||||
3=>'Mars',
|
||||
4=>'Avril',
|
||||
5=>'Mai',
|
||||
6=>'Juin',
|
||||
7=>'Juillet',
|
||||
8=>'Août',
|
||||
9=>'Septembre',
|
||||
10=>'Octobre',
|
||||
11=>'Novembre',
|
||||
12=>'Décembre');
|
||||
|
||||
/** Retourne le numéro du mois donné au format texte (janvier, mars, etc...)
|
||||
* @param string Mois en toute lettres (janvier, mars, etc...)
|
||||
* @return string Mois en Chiffe (1, 3, 12) / false en cas d'erreur
|
||||
*/
|
||||
public function getNumMois($moisEnLettres) {
|
||||
foreach (self::$tabMoisEnLettres as $num=>$mois)
|
||||
$tabMoisSansAccents[$num]=strtr($mois, 'ééûÉÉÛ','eeueeu');
|
||||
return array_search(ucfirst(strtolower(strtr($moisEnLettres, 'ééûÉÉÛ','eeuEEU'))), $tabMoisSansAccents);
|
||||
}
|
||||
|
||||
/** Retourne le libellé nu numéro du mois passé en paramètre
|
||||
* @param int $moisEnChiffre
|
||||
* @return string Libellé du mois / false si le mois passé en paramètre est invalide
|
||||
*/
|
||||
public function getLibelleMois($moisEnChiffre) {
|
||||
if ($moisEnChiffre>0 && $moisEnChiffre<13)
|
||||
return self::$tabMoisEnLettres[$moisEnChiffre];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Retourne le nombre de mois entre 2 dates au format Ymd
|
||||
**
|
||||
** @param int $dateDeb Date de début au format Ymd
|
||||
** @param int $dateFin Date de fin (ultérieur à la date de début) au format Ymd
|
||||
** @return int Nombre de mois
|
||||
**/
|
||||
function nbMoisEntre($dateDeb, $dateFin=TODAY) {
|
||||
$dDeb=explode('-', Wdate::dateT('Ymd','Y-m-d', $dateDeb));
|
||||
$dFin=explode('-', Wdate::dateT('Ymd','Y-m-d', $dateFin));
|
||||
return ($dFin[0]*12+$dFin[1])-($dDeb[0]*12+$dDeb[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion de formats de dates selon les formats de dates définits en php
|
||||
* @param string Format de la date d'entrée
|
||||
* @param string Format de la date de sortie
|
||||
* @param string Date d'entrée
|
||||
* @return string Date formatée
|
||||
*/
|
||||
public function dateT($formatIN, $formatOUT, $date) {
|
||||
$M='';
|
||||
switch ($formatIN) {
|
||||
case 'd M Y': $tmp=explode(' ', $date); $d=str_replace('1er', '1', $tmp[0]); $m=self::getNumMois($tmp[1]); $Y=$tmp[2]; break;
|
||||
case 'dMY': $Y=substr($date,-4);
|
||||
if (substr($date,0,3)=='1er') { $d=1; $posM=3; }
|
||||
elseif (is_numeric(substr($date,1,1))) { $d=substr($date,0,2); $posM=2; }
|
||||
else { $d=substr($date,0,1); $posM=1; }
|
||||
$M=trim(substr($date, $posM, strlen($date)-4-$posM));
|
||||
//echo "$date:$posM:$M".EOL;
|
||||
$m=self::getNumMois($M);
|
||||
break;
|
||||
case 'Ymd': $d=substr($date,6,2); $m=substr($date,4,2); $Y=substr($date,0,4); break;
|
||||
case 'ymd': $d=substr($date,4,2); $m=substr($date,2,2); $Y=substr($date,0,2);
|
||||
if ($Y<50) $Y='20'.$Y; else $Y='19'.$Y; break;
|
||||
case 'Y-m-d': $d=substr($date,8,2); $m=substr($date,5,2); $Y=substr($date,0,4); break;
|
||||
case 'Y-m': $d=1; $m=substr($date,5,2); $Y=substr($date,0,4); break;
|
||||
case 'd/m/Y': $tmp=explode('/', $date); $d=$tmp[0]; $m=$tmp[1]; $Y=$tmp[2]; break;
|
||||
case 'd.m.Y': $tmp=explode('.', $date); $d=$tmp[0]; $m=$tmp[1]; $Y=$tmp[2]; break;
|
||||
case 'd/m/y': $tmp=explode('/', $date); $d=$tmp[0]; $m=$tmp[1];
|
||||
if ($tmp[2]<date('y')) $Y='20'.$tmp[2]; else $Y='19'.$tmp[2]; break;
|
||||
case 'd-m-Y': $tmp=explode('-', $date); $d=$tmp[0]; $m=$tmp[1]; $Y=$tmp[2]; break;
|
||||
case 'm/d/Y': $tmp=explode('/', $date); $d=$tmp[1]; $m=$tmp[0]; $Y=$tmp[2]; break;
|
||||
case 'dmY': $d=substr($date,0,2); $m=substr($date,2,2); $Y=substr($date,4,4); break;
|
||||
case 'dmy': $d=substr($date,0,2); $m=substr($date,2,2); $Y=substr($date,4,2);
|
||||
if ($Y<50) $Y='20'.$Y; else $Y='19'.$Y; break;
|
||||
default: return $date;
|
||||
}
|
||||
|
||||
if ($m*1>0 && $m*1<10) $m='0'.($m*1); if ($d*1>0 && $d*1<10) $d='0'.($d*1);
|
||||
|
||||
switch ($formatOUT) {
|
||||
case 'd/m/Y': return $d.'/'.$m.'/'.$Y; break;
|
||||
case 'm/Y': return $m.'/'.$Y; break;
|
||||
case 'd M Y': return $d.' '.self::$tabMoisEnLettres[$m*1].' '.$Y; break;
|
||||
case 'M Y': return self::$tabMoisEnLettres[$m*1].' '.$Y; break;
|
||||
case 'Y': return $Y; break;
|
||||
case 'm': return $m; break;
|
||||
case 'd': return $d; break;
|
||||
case 'Ym': return $Y.$m; break;
|
||||
case 'Ymd': return $Y.$m.$d; break;
|
||||
case 'Y-m-d': return $Y.'-'.$m.'-'.$d; break;
|
||||
case 'Y/m/d': return $Y.'/'.$m.'/'.$d; break;
|
||||
default: return $date;
|
||||
}
|
||||
}
|
||||
|
||||
/** Calcul de la date après application de la période textuelle (deux ans, six mois, quinze jours, etc...)
|
||||
* @todo Fonction ne fonctionnant qu'avec un chiffre en un seul mot du genre dix mais pas quatre vingt dix !!!
|
||||
* @param date $dateIN au format Ymd
|
||||
* @param string $period (ex : cinq mois, six ans, un jour, 3 mois)
|
||||
* @return date
|
||||
*/
|
||||
function period2Days($dateIN, $period) {
|
||||
$dateV=self::dateT('Ymd', 'Ymd', $dateIN);
|
||||
if ($dateV<>$dateIN) return NULL;
|
||||
$d=substr($dateIN,6,2);
|
||||
$m=substr($dateIN,4,2);
|
||||
$Y=substr($dateIN,0,4);
|
||||
$period=strtolower(trim(strtr($period, "-.,", ' ')));
|
||||
if ($period=='') return NULL;
|
||||
$tabP=explode(' ', $period);
|
||||
if ($tabP[0]*1>0) $chiffre=$tabP[0]*1*1;
|
||||
else $chiffre=WChiffes::ChiffresEnLettres($tabP[0]);
|
||||
switch (end($tabP)) {
|
||||
case 'mois': $dateOUT=date('Ymd', mktime(0, 0, 0, $m+$chiffre, $d, $Y)); break;
|
||||
case 'an':
|
||||
case 'ans': $dateOUT=date('Ymd', mktime(0, 0, 0, $m, $d, $Y+$chiffre)); break;
|
||||
case 'jour':
|
||||
case 'jours': $dateOUT=date('Ymd', mktime(0, 0, 0, $m, $d+$chiffre, $Y)); break;
|
||||
default: $dateOUT=NULL;
|
||||
}
|
||||
return $dateOUT;
|
||||
}
|
||||
|
||||
|
||||
/** le jour est il ferié
|
||||
* @param date $date Date au format SSAA-MM-JJ ou SSAAMMJJ
|
||||
* @param bool $weekend Considérer les WeekEnd comme feriés ? 1=Oui
|
||||
* @return bool
|
||||
**/
|
||||
function jourFerie($date, $weekend=false) {
|
||||
$date =str_replace('-','',strtr($date, '/.:','---'));
|
||||
$jour =self::dateT('Ymd', 'd', $date);
|
||||
$mois =self::dateT('Ymd', 'm', $date);
|
||||
$annee=self::dateT('Ymd', 'Y', $date);
|
||||
$ferie=false;
|
||||
|
||||
// Jours feriées fixes
|
||||
if($jour == 1 && $mois == 1) $ferie = true; // 1er janvier
|
||||
if($jour == 1 && $mois == 5) $ferie = true; // 1er mai
|
||||
if($jour == 8 && $mois == 5) $ferie = true; // 8 mai
|
||||
if($jour == 14 && $mois == 7) $ferie = true; // 14 juillet
|
||||
if($jour == 15 && $mois == 8) $ferie = true; // 15 aout
|
||||
if($jour == 1 && $mois == 11) $ferie = true; // 1 novembre
|
||||
if($jour == 11 && $mois == 11) $ferie = true; // 11 novembre
|
||||
if($jour == 25 && $mois == 12) $ferie = true; // 25 décembre
|
||||
|
||||
// fêtes religieuses mobiles
|
||||
$pak = @easter_date($annee);
|
||||
$jp = date("d", $pak);
|
||||
$mp = date("m", $pak);
|
||||
if($jp == $jour && $mp == $mois){ $ferie = true;} // Pâques
|
||||
$lpk = mktime(date("H", $pak), date("i", $pak), date("s", $pak), date("m", $pak), date("d", $pak) +1, date("Y", $pak) );
|
||||
$jp = date("d", $lpk);
|
||||
$mp = date("m", $lpk);
|
||||
if($jp == $jour && $mp == $mois){ $ferie = true; }// Lundi de Pâques
|
||||
$asc = mktime(date("H", $pak), date("i", $pak), date("s", $pak), date("m", $pak), date("d", $pak) + 39, date("Y", $pak) );
|
||||
$jp = date("d", $asc);
|
||||
$mp = date("m", $asc);
|
||||
if($jp == $jour && $mp == $mois){ $ferie = true;}//ascension
|
||||
$pe = mktime(date("H", $pak), date("i", $pak), date("s", $pak), date("m", $pak), date("d", $pak) + 49, date("Y", $pak) );
|
||||
$jp = date("d", $pe);
|
||||
$mp = date("m", $pe);
|
||||
if($jp == $jour && $mp == $mois) {$ferie = true;}// Pentecôte
|
||||
$lp = mktime(date("H", $asc), date("i", $pak), date("s", $pak), date("m", $pak), date("d", $pak) + 50, date("Y", $pak) );
|
||||
$jp = date("d", $lp);
|
||||
$mp = date("m", $lp);
|
||||
if($jp == $jour && $mp == $mois) {$ferie = true;}// lundi Pentecôte
|
||||
|
||||
// Samedis et Dimanches
|
||||
if ($weekend) {
|
||||
$jour_sem = date('N',mktime(0,0,0, $mois, $jour, $annee));
|
||||
if($jour_sem>5) $ferie = true;
|
||||
}
|
||||
|
||||
return $ferie;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
58
framework/common/ftp.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
function ftp_mget($ftp_url, $ftp_user, $ftp_pass, $ftp_dir, $local_dir, $debug=null) {
|
||||
$conn_id = @ftp_connect($ftp_url);
|
||||
if (!$conn_id) {
|
||||
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP ($ftp_url) !".EOL;
|
||||
return false;
|
||||
}
|
||||
|
||||
$login_result = @ftp_login($conn_id, $ftp_user, $ftp_pass);
|
||||
if (!$login_result) {
|
||||
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de s'authentifier sur le serveur FTP (user=$ftp_user)!".EOL;
|
||||
return false;
|
||||
}
|
||||
// Récupération du contenu d'un dossier
|
||||
$contents = ftp_nlist($conn_id, $ftp_dir);
|
||||
// print_r($contents);
|
||||
// print_r(ftp_rawlist($conn_id, $ftp_dir));
|
||||
$nbFic=0; // Nombre de fichiers récupérés
|
||||
if (is_array($contents))
|
||||
foreach($contents as $k => $server_file) {
|
||||
$tailleDist = ftp_size($conn_id, $server_file);
|
||||
$dateDist = ftp_mdtm($conn_id, $server_file);
|
||||
$tailleLoc=0;
|
||||
if ($dateDist != -1) {
|
||||
$tabFichiers[$server_file]['dateDispo']=date('Y-m-d H:i:s', $dateDist);
|
||||
// echo date ('Y/m/d - H:i:s') ." - Le fichier distant $server_file a été modifié le ".date("d/m/Y à H:i:s.",$dateDist)."\n";
|
||||
} else {
|
||||
$tabFichiers[$server_file]['dateDispo']=NULL;
|
||||
// echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de récupérer l'heure de modification du fichier distant $server_file !\n";
|
||||
}
|
||||
$tabFichiers[$server_file]['taille']=$tailleDist;
|
||||
if ($tailleDist != -1) {
|
||||
//echo date ('Y/m/d - H:i:s') ." - Taille du fichier distant $server_file est de $tailleDist octets\n";
|
||||
}
|
||||
if (file_exists($local_dir . $server_file)) {
|
||||
$dateLoc=filemtime($local_dir . $server_file);
|
||||
$tabFichiers[$server_file]['dateDownload']=date('Y-m-d H:i:s', $dateLoc);
|
||||
$tailleLoc=filesize($local_dir . $server_file);
|
||||
//echo date ('Y/m/d - H:i:s') ." - Taille du fichier local $server_file = $tailleLoc octets\n";
|
||||
}
|
||||
if ($tailleDist<>$tailleLoc) {
|
||||
if (ftp_get($conn_id, $local_dir. $server_file, $server_file, FTP_BINARY))
|
||||
//echo date ('Y/m/d - H:i:s')." - Fichier distant $server_file téléchargé avec succès".EOL;
|
||||
$nbFic++;
|
||||
else {
|
||||
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Fichier distant $server_file non téléchargé !".EOL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fermeture de la connexion
|
||||
ftp_close($conn_id);
|
||||
return $nbFic;
|
||||
}
|
||||
|
||||
?>
|
3
framework/common/mail.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
include_once(FWK_PATH.'mail/htmlMimeMail5.php');
|
||||
?>
|
229
framework/common/mysql.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
class WDB {
|
||||
|
||||
private $host;
|
||||
private $database;
|
||||
private $user;
|
||||
private $password;
|
||||
private $con_id; // Connection ID with MySQL
|
||||
private $result;
|
||||
|
||||
public function __construct($database='', $host='', $user='', $password='') {
|
||||
|
||||
if ($host=='') $this->host=MYSQL_HOST;
|
||||
else $this->host=$host;
|
||||
if ($user=='') $this->user=MYSQL_USER;
|
||||
else $this->user=$user;
|
||||
if ($password=='') $this->password=MYSQL_PASS;
|
||||
else $this->password=$password;
|
||||
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
|
||||
else $this->database=$database;
|
||||
|
||||
$this->con_id = mysql_pconnect($this->host, $this->user,
|
||||
$this->password);
|
||||
if (!($this->con_id === false)) {
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
}
|
||||
return mysql_query("SET NAMES 'latin1';", $this->con_id);
|
||||
}
|
||||
|
||||
public function setCharSet($charSet) {
|
||||
return (mysql_query("SET CHARACTER SET $charSet;", $this->con_id));
|
||||
}
|
||||
|
||||
private function setDB() {
|
||||
return (mysql_query("USE $this->database;", $this->con_id));
|
||||
}
|
||||
|
||||
/** INSERTION d'un tableau dans une table.
|
||||
** Les index doivent avoir les mêmes noms que les champs.
|
||||
** @param string Table
|
||||
** @param array Valeurs insérer
|
||||
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
|
||||
**/
|
||||
public function insert($table, $toAdd, $debug=false, $low_priority=false){
|
||||
$this->setDB();
|
||||
$fields = implode(array_keys($toAdd), '`,`');
|
||||
foreach (array_values($toAdd) as $key=>$array_values)
|
||||
$tmp[$key]=checkaddslashes($array_values);
|
||||
|
||||
$values = "'".implode(array_values($tmp), "','")."'"; # better
|
||||
$values = str_replace("'NULL'", 'NULL', $values);
|
||||
|
||||
if ($low_priority)
|
||||
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
else
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res = mysql_query($query, $this->con_id);
|
||||
if ($res!==false)
|
||||
{
|
||||
if (mysql_insert_id()>0)
|
||||
$res=mysql_insert_id();
|
||||
else
|
||||
$res=true;
|
||||
}
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false){
|
||||
$this->setDB();
|
||||
$fields = array_keys($update);
|
||||
$values = array_values($update);
|
||||
$i=0;
|
||||
if ($low_priority)
|
||||
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
|
||||
else
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
while(isset($fields[$i])){
|
||||
if($i>0) { $query.=', '; }
|
||||
$query.=' `'.$fields[$i]."`='".checkaddslashes($values[$i])."'";
|
||||
$i++;
|
||||
}
|
||||
$query = str_replace("'NULL'", 'NULL', $query);
|
||||
$query.=' WHERE '.$where;
|
||||
if ($limit>0) $query.=" LIMIT $limit";
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete($table, $where, $debug=false, $low_priority=false) {
|
||||
$this->setDB();
|
||||
if ($low_priority)
|
||||
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
else
|
||||
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
|
||||
$this->setDB();
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
$query="SELECT $fields FROM $table WHERE $where;";
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$this->result=mysql_query($query, $this->con_id);// or die(mysql_error());
|
||||
if (mysql_errno()) {
|
||||
$fpErr=fopen(LOG_PATH.'/sqlerror.log','a');
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.$query .EOL);
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.mysql_errno() .' - '. mysql_error().EOL);
|
||||
return false;
|
||||
}
|
||||
// echo ;
|
||||
if (!$huge) {
|
||||
$tab=array();
|
||||
while ($ligne = mysql_fetch_array($this->result, $assoc))
|
||||
$tab[]=$ligne;
|
||||
|
||||
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
|
||||
return $tab;
|
||||
} else {
|
||||
$nbRows=mysql_num_rows($this->result);
|
||||
if ($debug) $this->trace($query, $nbRows, $tdeb);
|
||||
return $nbRows;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch($assoc=MYSQL_BOTH) {
|
||||
return mysql_fetch_array($this->result, $assoc);
|
||||
}
|
||||
|
||||
public function trace($query, $res='', $tdeb=-1) {
|
||||
if (!$fp=fopen('mysql_insert.log', 'a'))
|
||||
return false;
|
||||
$errnum=mysql_errno($this->con_id);
|
||||
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
else $duree='N/D';
|
||||
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
|
||||
return false;
|
||||
if (!fclose($fp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Exécute la requête passé en paramètre **/
|
||||
public function query($query, $debug=false){
|
||||
$this->setDB();
|
||||
$this->result=mysql_query($query, $this->con_id);
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/** Retourne le nombre de records de la dernière requête de sélection **
|
||||
public function getNumRows() {
|
||||
return mysql_num_rows($this->con_id);
|
||||
}
|
||||
*/
|
||||
/** Retourne le libellé de la dernière erreur **/
|
||||
public function getLastErrorMsg() {
|
||||
return mysql_error($this->con_id);
|
||||
}
|
||||
/** Retourne le numéro de la dernière erreur **/
|
||||
public function getLastErrorNum() {
|
||||
return mysql_errno($this->con_id);
|
||||
}
|
||||
|
||||
/** Retourne le libellé et le numéro de la dernière erreur **/
|
||||
public function getLastError() {
|
||||
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
|
||||
}
|
||||
|
||||
/** Retourne le nombre de lignes modifiées par la dernière requête **/
|
||||
public function getAffectedRows() {
|
||||
return mysql_affected_rows($this->con_id);
|
||||
}
|
||||
|
||||
/** Génère le fichier CSV pour la requete SQL
|
||||
**
|
||||
** @param string $query
|
||||
** @param string $fileCsv
|
||||
** @return bool
|
||||
*/
|
||||
public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL) {
|
||||
$i=$c=0;
|
||||
$fp = fopen($fileCsv, 'w');
|
||||
if (!$fp) return false;
|
||||
|
||||
$res=$this->query($query);
|
||||
$nbLignes=mysql_num_rows($res);
|
||||
|
||||
while ($ligne=$this->fetch(MYSQL_ASSOC)) {
|
||||
if ($i==0) {
|
||||
$nbCols=count($ligne);
|
||||
foreach ($ligne as $libCol=>$col) {
|
||||
$c++;
|
||||
if ($c<$nbCols) fwrite($fp, str_replace($sep,' ', $libCol).$sep);
|
||||
else fwrite($fp, str_replace($sep,' ', $libCol));
|
||||
}
|
||||
fwrite($fp, $eol);
|
||||
}
|
||||
$c=0;
|
||||
foreach ($ligne as $libCol=>$col) {
|
||||
$c++;
|
||||
if ($c<$nbCols) fwrite($fp, str_replace($sep,' ', $col).$sep);
|
||||
else fwrite($fp, str_replace($sep,' ', $col));
|
||||
}
|
||||
fwrite($fp, $eol);
|
||||
$i++;
|
||||
}
|
||||
fclose($fp);
|
||||
return $nbLignes;//$this->getAffectedRows();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
215
framework/common/rss.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?php
|
||||
/*
|
||||
Atom and RSS Extractor and Displayer
|
||||
(c) 2007 Scriptol.com - Licence Mozilla 1.1.
|
||||
commonlib.php
|
||||
*/
|
||||
class atomRss {
|
||||
|
||||
public $codeErreurHttp=0;
|
||||
private $Common_Content = array();
|
||||
|
||||
function RSS_Tags($item, $type)
|
||||
{
|
||||
$y = array();
|
||||
$y["title"] = $item->getElementsByTagName("title")->item(0)->firstChild->data;
|
||||
$y["link"] = $item->getElementsByTagName("link")->item(0)->firstChild->data;
|
||||
$y["description"] = $item->getElementsByTagName("description")->item(0)->firstChild->data;
|
||||
|
||||
$tnl = $item->getElementsByTagName("pubDate");
|
||||
if($tnl->length == 0)
|
||||
{
|
||||
$tnl = $item->getElementsByTagName("lastBuildDate");
|
||||
}
|
||||
if($tnl->length != 0)
|
||||
{
|
||||
$tnl =$tnl->item(0)->firstChild->data;
|
||||
}
|
||||
else
|
||||
$tnl = false;
|
||||
|
||||
$y["updated"] = $tnl;
|
||||
$y["type"] = $type;
|
||||
|
||||
array_push($this->Common_Content, $y);
|
||||
}
|
||||
|
||||
|
||||
function RSS_Channel($channel)
|
||||
{
|
||||
$items = $channel->getElementsByTagName("item");
|
||||
|
||||
// Processing channel
|
||||
|
||||
$this->RSS_Tags($channel, 0); // get description of channel, type 0
|
||||
|
||||
// Processing articles
|
||||
|
||||
foreach($items as $item)
|
||||
{
|
||||
$this->RSS_Tags($item, 1); // get description of article, type 1
|
||||
}
|
||||
}
|
||||
|
||||
function RSS_Retrieve($url)
|
||||
{
|
||||
$doc = new DOMDocument();
|
||||
$ret = $doc->load($url);
|
||||
if ($ret===false) {
|
||||
$page=getUrl($url,'','','',false,'','',3);
|
||||
$this->codeErreurHttp=$page['code'];
|
||||
if ($this->codeErreurHttp==302) {
|
||||
$url=$page['header']['Location'];
|
||||
$ret = $doc->load($url);
|
||||
}
|
||||
}
|
||||
|
||||
$channels = $doc->getElementsByTagName("channel");
|
||||
|
||||
$this->Common_Content = array();
|
||||
|
||||
foreach($channels as $channel)
|
||||
{
|
||||
$this->RSS_Channel($channel);
|
||||
}
|
||||
|
||||
return ( count($this->Common_Content) > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Atom_Tags($item)
|
||||
{
|
||||
$y = array();
|
||||
$y["title"] = $item->getElementsByTagName("title")->item(0)->firstChild->data;
|
||||
$y["link"] = $item->getElementsByTagName("link")->item(0)->getAttribute("href");
|
||||
$y["description"] = $item->getElementsByTagName("summary")->item(0)->firstChild->data;
|
||||
$y["updated"] = $item->getElementsByTagName("updated")->item(0)->firstChild->data;
|
||||
$y["type"] = 1;
|
||||
|
||||
array_push($this->Common_Content, $y);
|
||||
}
|
||||
|
||||
function Atom_Feed($doc)
|
||||
{
|
||||
$entries = $doc->getElementsByTagName("entry");
|
||||
|
||||
if($entries->length == 0) return false;
|
||||
|
||||
// Processing feed
|
||||
|
||||
$y = array();
|
||||
$y["title"] = $doc->getElementsByTagName("title")->item(0)->firstChild->data;
|
||||
$y["link"] = $doc->getElementsByTagName("link")->item(0)->getAttribute("href");
|
||||
$y["description"] = $doc->getElementsByTagName("subtitle")->item(0)->firstChild->data;
|
||||
$y["updated"] = $doc->getElementsByTagName("updated")->item(0)->firstChild->data;
|
||||
$y["type"] = 0;
|
||||
|
||||
array_push($this->Common_Content, $y);
|
||||
|
||||
// Processing articles
|
||||
|
||||
foreach($entries as $entry)
|
||||
{
|
||||
$this->Atom_Tags($entry); // get description of article, type 1
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function Atom_Retrieve($url)
|
||||
{
|
||||
$doc = new DOMDocument();
|
||||
$doc->load($url);
|
||||
|
||||
$this->Common_Content = array();
|
||||
|
||||
return $this->Atom_Feed($doc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loadRss($url, $size=200, $chanopt=true, $descopt=true, $dateopt=true)
|
||||
{
|
||||
$opened = false;
|
||||
$page = "";
|
||||
|
||||
if($this->Atom_Retrieve($url) === false)
|
||||
{
|
||||
if($this->RSS_Retrieve($url) === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if($size > 0)
|
||||
{
|
||||
$size += 1; // add one for the channel
|
||||
$recents = array_slice($this->Common_Content, 0, $size);
|
||||
}
|
||||
//$tabFlux=array();
|
||||
return $recents;
|
||||
/*
|
||||
|
||||
foreach($recents as $article)
|
||||
{
|
||||
$type = $article["type"];
|
||||
|
||||
if($type == 0)
|
||||
{
|
||||
if($chanopt != true) continue;
|
||||
if($opened == true)
|
||||
{
|
||||
$page .="</ul>\n";
|
||||
$opened = false;
|
||||
}
|
||||
//$page .="<b>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if($opened == false && $chanopt == true)
|
||||
{
|
||||
$page .= "<ul>\n";
|
||||
$opened = true;
|
||||
}
|
||||
}
|
||||
$title = $article["title"];
|
||||
$link = $article["link"];
|
||||
$page .= "<".$Common_Style."><a href=\"$link\">$title</a>";
|
||||
|
||||
if($descopt != false)
|
||||
{
|
||||
$description = $article["description"];
|
||||
if($description != false)
|
||||
{
|
||||
$page .= "<br>$description";
|
||||
}
|
||||
}
|
||||
if($dateopt != false)
|
||||
{
|
||||
$updated = $article["updated"];
|
||||
if($updated != false)
|
||||
{
|
||||
$page .= "<br /><font $Common_Date_Font>$updated</font>";
|
||||
}
|
||||
}
|
||||
$page .= "</".$Common_Style.">\n";
|
||||
|
||||
/*
|
||||
if($type == 0)
|
||||
{
|
||||
$page .="<br />";
|
||||
}
|
||||
*
|
||||
}
|
||||
|
||||
if($opened == true)
|
||||
{
|
||||
$page .="</ul>\n";
|
||||
}
|
||||
return $page."\n";
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
424
framework/common/strings.php
Normal file
@ -0,0 +1,424 @@
|
||||
<?
|
||||
|
||||
define ('BEFORE', 0);
|
||||
define ('AFTER', 1);
|
||||
define ('BOTH', 2);
|
||||
define ('ALIGN_LEFT', 0);
|
||||
define ('ALIGN_RIGHT', 1);
|
||||
|
||||
|
||||
/**Initialisation d'une chaîne de caractère
|
||||
*
|
||||
* @param string $chaine Chaîne de caractère initiale
|
||||
* @param int $taille Taille de la chaîne de caractère à initialiser
|
||||
* @param string $caractere_pour_combler Caractère à utiliser pour combler la chaîne de caractère (espace par défaut)
|
||||
* @param string $align Aligner la chaîne de caractère à droite (right) ou à gauche (left, par défaut)
|
||||
* @return string
|
||||
*/
|
||||
function initstr($chaine, $taille, $caractere_pour_combler=' ', $align=ALIGN_LEFT) {
|
||||
if ($align==ALIGN_RIGHT) {
|
||||
$str2='';
|
||||
for ($i=0;$i<($taille-strlen($chaine));$i++)
|
||||
$str2.=$caractere_pour_combler;
|
||||
$str=$str2.$chaine;
|
||||
} else {
|
||||
if (strlen($chaine)>=$taille)
|
||||
return substr($chaine,0,$taille);
|
||||
$str=$chaine;
|
||||
for ($i=strlen($chaine);$i<$taille;$i++)
|
||||
$str = $str . $caractere_pour_combler;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajout d'anti-slashs s'il y a lieu en vu d'une insertion en BDD
|
||||
*
|
||||
* @param string $str Chaine de caractère
|
||||
* @return unknown
|
||||
*/
|
||||
|
||||
function checkaddslashes($str){
|
||||
return addslashes(preg_replace('/\\[^nrt\']/i', '\\', $str));
|
||||
}
|
||||
|
||||
function checkaddslashes2($str){
|
||||
if(strpos(str_replace("\'",''," $str"),"'")!=false)
|
||||
return addslashes($str);
|
||||
else
|
||||
return $str;
|
||||
}
|
||||
|
||||
function trimAccent ($strWithAccent) {
|
||||
$strWithAccent = htmlentities(strtolower($strWithAccent ));
|
||||
$strWithAccent = preg_replace("/&(.)(acute|cedil|circ|ring|tilde|uml|grave);/", "$1", $strWithAccent );
|
||||
$strWithAccent = preg_replace("/([^a-z0-9]+)/", " ", html_entity_decode($strWithAccent ));
|
||||
$strWithAccent = trim($strWithAccent , "-");
|
||||
return $strWithAccent;
|
||||
}
|
||||
|
||||
//function SRSaufVoyelle ($strIn, $mot1, $mot2) {
|
||||
function str_replace_except_voy($mot1, $mot2, $strIn, $rule=0) {
|
||||
$Voyelle=array('a','e','i','o','u','y', '1', '2', '3', '4');
|
||||
if ($mot1==$mot2) return $strIn;
|
||||
if (strpos($mot2,$mot1)===false)
|
||||
{
|
||||
//foreach ($Voyelle as $k => $voy)
|
||||
$posMot1=strpos($strIn, $mot1);
|
||||
while ($posMot1!==false) {
|
||||
$lettreAV=$strIn[$posMot1-1];
|
||||
$lettreAP=$strIn[$posMot1+strlen($mot1)];
|
||||
//echo "Lettre AV=$lettreAV<br/>";
|
||||
//echo "Lettre AP=$lettreAP<br/>";
|
||||
if ( ( $rule==0 && !in_array($lettreAV, $Voyelle) ) ||
|
||||
( $rule==1 && !in_array($lettreAP, $Voyelle) ) ||
|
||||
( $rule==2 && !in_array($lettreAV, $Voyelle) && !in_array($lettreAP, $Voyelle) ))
|
||||
$strIn=substr($strIn,0,$posMot1) . $mot2 . substr($strIn,$posMot1+strlen($mot1),strlen($strIn));
|
||||
//echo "Le Mot devient : $strIn<br/>";
|
||||
$posMot1=strpos($strIn, $mot1, $posMot1+strlen($mot1));
|
||||
}
|
||||
return $strIn;
|
||||
}
|
||||
//echo "Erreur : $mot2 contient $mot1 !<br>";
|
||||
return $strIn;
|
||||
}
|
||||
|
||||
/** Retourne le phonex d'un mot
|
||||
**/
|
||||
function phonex($strIn) {
|
||||
if ($strIn=='') return 0.0;
|
||||
$tabSonAIA=array('aina', 'eina', 'aima', 'eima');
|
||||
$tabSonAIE=array('ainr', 'eine', 'aime', 'eime');
|
||||
$tabSonAII=array('aini', 'eini', 'aimi', 'eimi');
|
||||
$tabSonAIO=array('aino', 'eino', 'aimo', 'eimo');
|
||||
$tabSonAIU=array('ainu', 'einu', 'aimu', 'eimu');
|
||||
$tabCarPhon=array('1', '2', '3', '4', '5', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'n', 'o', 'r', 's', 't', 'u', 'w', 'x', 'y', 'z');
|
||||
|
||||
/** On traite tout en minuscule **/
|
||||
$strIn=strtolower($strIn);
|
||||
/** On remplace les 'Y' par des 'I' **/
|
||||
$strIn=str_replace('y', 'i', $strIn);
|
||||
/** On supprime les accents **/
|
||||
$strIn=trimAccent($strIn);
|
||||
/** On retire les 'H' muets sauf ceux précédés par 'C' ou 'S' **/
|
||||
$strIn = preg_replace ('/(?<![CS])H/', '', $strIn);
|
||||
/** On remplace les 'PH' par des 'F' **/
|
||||
$strIn=str_replace('ph', 'f', $strIn);
|
||||
/** On remplace les 'G' par des 'K' devant AN AM AIN AIM **/
|
||||
$strIn=str_replace('gan', 'kan', $strIn);
|
||||
$strIn=str_replace('gain', 'kain', $strIn);
|
||||
$strIn=str_replace('gam', 'kam4', $strIn);
|
||||
$strIn=str_replace('gaim', 'kaim', $strIn);
|
||||
/** On remplace le son AI **/
|
||||
for ($i=0; $i>4; $i++) {
|
||||
$strIn=str_replace($tabSonAIA[$i], 'yna', $strIn);
|
||||
$strIn=str_replace($tabSonAIE[$i], 'yne', $strIn);
|
||||
$strIn=str_replace($tabSonAII[$i], 'yni', $strIn);
|
||||
$strIn=str_replace($tabSonAIO[$i], 'yno', $strIn);
|
||||
$strIn=str_replace($tabSonAIU[$i], 'ynu', $strIn);
|
||||
}
|
||||
/** Remplacement des groupes de 3 lettres **/
|
||||
$strIn=str_replace('eau', 'o', $strIn);
|
||||
$strIn=str_replace('oua', '2', $strIn);
|
||||
$strIn=str_replace('ein', '4', $strIn);
|
||||
$strIn=str_replace('ain', '4', $strIn);
|
||||
/** Remplacement du son 'é' **/
|
||||
$strIn=str_replace('ai', 'y', $strIn);
|
||||
$strIn=str_replace('ei', 'y', $strIn);
|
||||
$strIn=str_replace('er', 'yr', $strIn);
|
||||
$strIn=str_replace('ess', 'yss', $strIn);
|
||||
$strIn=str_replace('et', 'yt', $strIn);
|
||||
$strIn=str_replace('ez', 'yz', $strIn);
|
||||
/** Remplacement des groupes de 2 lettres sauf si voyelle ou son (1 à 4) AVANT **/
|
||||
$strIn=str_replace_except_voy('an', '1', $strIn, BEFORE);
|
||||
$strIn=str_replace_except_voy('am', '1', $strIn, BEFORE);
|
||||
$strIn=str_replace_except_voy('en', '1', $strIn, BEFORE);
|
||||
$strIn=str_replace_except_voy('em', '1', $strIn, BEFORE);
|
||||
$strIn=str_replace_except_voy('in', '4', $strIn, BEFORE);
|
||||
/** Remplacement du son 'SCH' **/
|
||||
$strIn=str_replace('sch', '5', $strIn);
|
||||
/** Remplacement du 'S' sauf si voyelle ou son (1 à 4) avant ou après **/
|
||||
$strIn=str_replace_except_voy('in', '4', $strIn, BOTH);
|
||||
/** Remplacement de groupe de 2 lettres diverses **/
|
||||
$strIn=str_replace('oe', 'e', $strIn);
|
||||
$strIn=str_replace('eu', 'e', $strIn);
|
||||
$strIn=str_replace('au', 'o', $strIn);
|
||||
$strIn=str_replace('oi', '2', $strIn);
|
||||
$strIn=str_replace('oy', '2', $strIn);
|
||||
$strIn=str_replace('ou', '3', $strIn);
|
||||
$strIn=str_replace('ch', '5', $strIn);
|
||||
$strIn=str_replace('sh', '5', $strIn);
|
||||
$strIn=str_replace('ss', 's', $strIn);
|
||||
$strIn=str_replace('sc', 's', $strIn);
|
||||
/** Remplacement du 'C' par 'S' s'il est suivi d'un 'E' ou d'un 'I' **/
|
||||
$strIn=str_replace('ce', 'se', $strIn);
|
||||
$strIn=str_replace('ci', 'si', $strIn);
|
||||
/** Remplacement divers **/
|
||||
$strIn=str_replace('c', 'k', $strIn);
|
||||
$strIn=str_replace('q', 'k', $strIn);
|
||||
$strIn=str_replace('qu', 'k', $strIn);
|
||||
|
||||
$strIn=str_replace('ga', 'ka', $strIn);
|
||||
$strIn=str_replace('go', 'ko', $strIn);
|
||||
$strIn=str_replace('gu', 'ku', $strIn);
|
||||
$strIn=str_replace('gy', 'ky', $strIn);
|
||||
$strIn=str_replace('g2', 'k2', $strIn);
|
||||
$strIn=str_replace('g1', 'k1', $strIn);
|
||||
$strIn=str_replace('g3', 'k3', $strIn);
|
||||
|
||||
$strIn=str_replace('a', 'o', $strIn);
|
||||
$strIn=str_replace('d', 't', $strIn);
|
||||
$strIn=str_replace('p', 't', $strIn);
|
||||
$strIn=str_replace('j', 'g', $strIn);
|
||||
$strIn=str_replace('b', 'f', $strIn);
|
||||
$strIn=str_replace('v', 'f', $strIn);
|
||||
$strIn=str_replace('m', 'n', $strIn);
|
||||
|
||||
/** Supression des lettres dupliquées **/
|
||||
$let=$strIn[0];
|
||||
$strIn2=$let;
|
||||
for ($i=1; $i<strlen($strIn); $i++)
|
||||
{ if ($strIn==$let)
|
||||
continue;
|
||||
else {
|
||||
$let=$strIn[$i];
|
||||
$strIn2.=$strIn[$i];
|
||||
}
|
||||
}
|
||||
$strIn=$strIn2;
|
||||
|
||||
/** Supression des terminaisons **/
|
||||
$strIn2=substr($strIn,-1);
|
||||
if ($strIn2=='t' || $strIn2=='k' || $strIn2=='s' || $strIn2=='z')
|
||||
$strIn=substr($strIn,0,-1);
|
||||
|
||||
/** Supression des caractères non autorisés **/
|
||||
$j=10;
|
||||
$sout=array();
|
||||
for ($i=0; $i<strlen($strIn); $i++)
|
||||
{
|
||||
if ($j<1) break;
|
||||
for ($k=0; $k<22; $k++)
|
||||
{
|
||||
if ($strIn[$i]==$tabCarPhon[$k])
|
||||
{
|
||||
$sout[$j]=$k;
|
||||
$j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
print_r($tabCarPhon);
|
||||
|
||||
/** Couversion en flottant **/
|
||||
$result=0.0;
|
||||
for ($j=10; $j>0; $j--)
|
||||
$result+=$sout[$j]*pow($j-1,10);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* CLASS soundex2
|
||||
* soundex2 French version
|
||||
* based on the algorithm described here : http://sqlpro.developpez.com/cours/soundex/ by Frédéric BROUARD
|
||||
*
|
||||
* author Johan Barbier <barbier_johan@hotmail.com>
|
||||
*/
|
||||
class csoundex2 {
|
||||
|
||||
/**
|
||||
* public sString
|
||||
* main string we work on
|
||||
*/
|
||||
var $sString = '';
|
||||
|
||||
/**
|
||||
* vowels replacement array
|
||||
*/
|
||||
var $aReplaceVoy1 = array (
|
||||
'E' => 'A',
|
||||
'I' => 'A',
|
||||
'O' => 'A',
|
||||
'U' => 'A'
|
||||
);
|
||||
|
||||
/**
|
||||
* consonnants replacement array
|
||||
*/
|
||||
var $aReplaceGrp1 = array (
|
||||
'GUI' => 'KI',
|
||||
'GUE' => 'KE',
|
||||
'GA' => 'KA',
|
||||
'GO' => 'KO',
|
||||
'GU' => 'K',
|
||||
'CA' => 'KA',
|
||||
'CO' => 'KO',
|
||||
'CU' => 'KU',
|
||||
'Q' => 'K',
|
||||
'CC' => 'K',
|
||||
'CK' => 'K'
|
||||
);
|
||||
|
||||
/**
|
||||
* other replacement array
|
||||
*/
|
||||
var $aReplaceGrp2 = array (
|
||||
'ASA' => 'AZA',
|
||||
'KN' => 'NN',
|
||||
'PF' => 'FF',
|
||||
'PH' => 'FF',
|
||||
'SCH' => 'SSS'
|
||||
);
|
||||
|
||||
/**
|
||||
* endings replacement array
|
||||
*/
|
||||
var $aEnd = array (
|
||||
'A',
|
||||
'T',
|
||||
'D',
|
||||
'S'
|
||||
);
|
||||
|
||||
/**
|
||||
* public function build
|
||||
* core function of the class, go through the whole process
|
||||
* @Param string sString : the string we want to check
|
||||
*/
|
||||
function build ($sString) {
|
||||
/**
|
||||
* let's check it's a real string...
|
||||
*/
|
||||
if (is_string ($sString) && !empty ($sString)) {
|
||||
$this -> sString = $sString;
|
||||
} else {
|
||||
trigger_error ('Parameter string must not be empty', E_USER_ERROR);
|
||||
}
|
||||
/**
|
||||
* remove starting and ending spaces
|
||||
*/
|
||||
$this -> sString = trim ($this -> sString);
|
||||
/**
|
||||
* remove special french characters
|
||||
*/
|
||||
$this -> trimAccent ();
|
||||
/**
|
||||
* string to upper case
|
||||
*/
|
||||
$this -> sString = strtoupper ($this -> sString );
|
||||
/**
|
||||
* let's remove every space in the string
|
||||
*/
|
||||
$this -> sString = str_replace (' ', '', $this -> sString);
|
||||
/**
|
||||
* let's remove every '-' in the string
|
||||
*/
|
||||
$this -> sString = str_replace ('-', '', $this -> sString);
|
||||
/**
|
||||
* let's process through the first replacement array
|
||||
*/
|
||||
$this -> arrReplace ($this -> aReplaceGrp1);
|
||||
/**
|
||||
* let's process through th vowels replacement
|
||||
*/
|
||||
$sChar = substr ($this -> sString, 0, 1);
|
||||
$this -> sString = substr ($this -> sString, 1, strlen ($this -> sString) - 1);
|
||||
$this -> arrReplace ($this -> aReplaceVoy1);
|
||||
$this -> sString = $sChar.$this -> sString;
|
||||
/**
|
||||
* let's process through the second replacement array
|
||||
*/
|
||||
$this -> arrReplace ($this -> aReplaceGrp2, true);
|
||||
/**
|
||||
* let's remove every 'H' but those prededed by a 'C' or an 'S'
|
||||
*/
|
||||
$this -> sString = preg_replace ('/(?<![CS])H/', '', $this -> sString);
|
||||
/**
|
||||
* let's remove every 'Y' but those preceded by an 'A'
|
||||
*/
|
||||
$this -> sString = preg_replace ('/(?<!A)Y/', '', $this -> sString);
|
||||
/**
|
||||
* remove endings in aEnd
|
||||
*/
|
||||
$length = strlen ($this -> sString) - 1;
|
||||
if (in_array ($this -> sString{$length}, $this -> aEnd)) {
|
||||
$this -> sString = substr ($this -> sString, 0, $length);
|
||||
}
|
||||
/**
|
||||
* let's remove every 'A', but the one at the beginning of the string, if any.
|
||||
*/
|
||||
$sChar = '';
|
||||
if ($this -> sString{0} === 'A') {
|
||||
$sChar = 'A';
|
||||
}
|
||||
$this -> sString = str_replace ('A', '', $this -> sString);
|
||||
$this -> sString = $sChar.$this -> sString;
|
||||
/**
|
||||
* let's have only 1 occurence of each letter
|
||||
*/
|
||||
$this -> sString = preg_replace( '/(.)\1/', '$1', $this -> sString );
|
||||
/**
|
||||
* let's have the final code : a 4 letters string
|
||||
*/
|
||||
$this -> getFinal ();
|
||||
}
|
||||
|
||||
/**
|
||||
* private function getFinal
|
||||
* gets the first 4 letters, pads the string with white space if the string length < 4
|
||||
*/
|
||||
function getFinal () {
|
||||
if (strlen ($this -> sString) < 4) {
|
||||
$this -> sString = str_pad ($this -> sString, 4, ' ', STR_PAD_RIGHT);
|
||||
} else {
|
||||
$this -> sString = substr ($this -> sString, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* private function trimAccent
|
||||
* remove every special French letters
|
||||
*/
|
||||
function trimAccent () {
|
||||
$this -> sString = htmlentities(strtolower($this -> sString ));
|
||||
$this -> sString = preg_replace("/&(.)(acute|cedil|circ|ring|tilde|uml|grave);/", "$1", $this -> sString );
|
||||
$this -> sString = preg_replace("/([^a-z0-9]+)/", "-", html_entity_decode($this -> sString ));
|
||||
$this -> sString = trim($this -> sString , "-");
|
||||
}
|
||||
|
||||
/**
|
||||
* private function arrReplace
|
||||
* replacement method, given an array
|
||||
* @Param array tab : the replacement array to be used
|
||||
* @Param bool pref : if false, just replace keys by values; if true, do the same but only with prefix
|
||||
*/
|
||||
function arrReplace (array $tab, $pref = false) {
|
||||
$fromRep = array_keys ($tab);
|
||||
$toRep = array_values ($tab);
|
||||
if (false === $pref) {
|
||||
$this -> sString = str_replace ($fromRep, $toRep, $this -> sString);
|
||||
} else {
|
||||
foreach ($fromRep as $clef => $val) {
|
||||
$length = strlen ($val);
|
||||
if (substr ($this -> sString, 0, $length) === $val) {
|
||||
$this -> sString = substr_replace ($this -> sString, $toRep[$clef], 0, $length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function soundex2($str) {
|
||||
$soundex2 = new csoundex2();
|
||||
|
||||
$soundex2 -> build ($str);
|
||||
return $soundex2 -> sString;
|
||||
}
|
||||
|
||||
function htm2txt($str) {
|
||||
return trim(strip_tags( str_replace(chr(160), ' ',
|
||||
str_replace('œ', 'oe',
|
||||
str_replace('’', '\'', html_entity_decode($str, ENT_QUOTES))))));
|
||||
}
|
||||
?>
|
111
framework/common/xml_parser.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
XML Parser Class
|
||||
by Eric Rosebrock
|
||||
http://www.phpfreaks.com
|
||||
|
||||
Class originated from: kris@h3x.com AT: http://www.devdump.com/phpxml.php
|
||||
|
||||
Usage:
|
||||
|
||||
<?php
|
||||
include 'clsParseXML.php';
|
||||
|
||||
$xmlparse = &new ParseXML;
|
||||
$xml = $xmlparse->GetXMLTree('/path/to/xmlfile.xml');
|
||||
|
||||
echo "<pre>";
|
||||
print_r($xml);
|
||||
echo "</pre>";
|
||||
?>
|
||||
|
||||
The path to the XML file may be a local file or a URL.
|
||||
Returns the elements of the XML file into an array with
|
||||
it's subelements as keys and subarrays.
|
||||
|
||||
*/
|
||||
|
||||
class ParseXML{
|
||||
function GetChildren($vals, &$i) {
|
||||
$children = array(); // Contains node data
|
||||
if (isset($vals[$i]['value'])){
|
||||
$children['VALUE'] = $vals[$i]['value'];
|
||||
}
|
||||
|
||||
while (++$i < count($vals)){
|
||||
switch ($vals[$i]['type']){
|
||||
|
||||
case 'cdata':
|
||||
if (isset($children['VALUE'])){
|
||||
$children['VALUE'] .= $vals[$i]['value'];
|
||||
} else {
|
||||
$children['VALUE'] = $vals[$i]['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'complete':
|
||||
if (isset($vals[$i]['attributes'])) {
|
||||
$children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
|
||||
$index = count($children[$vals[$i]['tag']])-1;
|
||||
|
||||
if (isset($vals[$i]['value'])){
|
||||
$children[$vals[$i]['tag']][$index]['VALUE'] = $vals[$i]['value'];
|
||||
} else {
|
||||
$children[$vals[$i]['tag']][$index]['VALUE'] = '';
|
||||
}
|
||||
} else {
|
||||
if (isset($vals[$i]['value'])){
|
||||
$children[$vals[$i]['tag']][]['VALUE'] = $vals[$i]['value'];
|
||||
} else {
|
||||
$children[$vals[$i]['tag']][]['VALUE'] = '';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'open':
|
||||
if (isset($vals[$i]['attributes'])) {
|
||||
$children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
|
||||
$index = count($children[$vals[$i]['tag']])-1;
|
||||
$children[$vals[$i]['tag']][$index] = array_merge($children[$vals[$i]['tag']][$index],$this->GetChildren($vals, $i));
|
||||
} else {
|
||||
$children[$vals[$i]['tag']][] = $this->GetChildren($vals, $i);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'close':
|
||||
return $children;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetXMLTree($xmlloc){
|
||||
if (file_exists($xmlloc)){
|
||||
$data = implode('', file($xmlloc));
|
||||
} else {
|
||||
$fp = fopen($xmlloc,'r');
|
||||
while(!feof($fp)){
|
||||
$data = $data . fread($fp, 1024);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$parser = xml_parser_create('ISO-8859-1');
|
||||
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
||||
xml_parse_into_struct($parser, $data, $vals, $index);
|
||||
xml_parser_free($parser);
|
||||
|
||||
$tree = array();
|
||||
$i = 0;
|
||||
|
||||
if (isset($vals[$i]['attributes'])) {
|
||||
$tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
|
||||
$index = count($tree[$vals[$i]['tag']])-1;
|
||||
$tree[$vals[$i]['tag']][$index] = array_merge($tree[$vals[$i]['tag']][$index], $this->GetChildren($vals, $i));
|
||||
} else {
|
||||
$tree[$vals[$i]['tag']][] = $this->GetChildren($vals, $i);
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
}
|
283
framework/fwk.php
Normal file
@ -0,0 +1,283 @@
|
||||
<?
|
||||
define('FWK_PATH', realpath(dirname(__FILE__)).'/');
|
||||
include_once(FWK_PATH.'common/mysql.php');
|
||||
include_once(FWK_PATH.'common/strings.php');
|
||||
//include_once(FWK_PATH.'common/dates.php');
|
||||
|
||||
define ('REP_TEMP', '/tmp/');
|
||||
// Environnement : DEV ou PRD
|
||||
define ('ENV', 'DEV');
|
||||
define ('EOL', "\n");
|
||||
|
||||
define ('MODE_CLI', 1);
|
||||
define ('MODE_WWW', 2);
|
||||
define ('MODE_WS', 3);
|
||||
|
||||
if (@$_SERVER['argc']>0) define('MODE_EXEC', MODE_CLI);
|
||||
else define('MODE_EXEC', MODE_WS);
|
||||
/** @todo Gérer la distinction du mode WWW du WS
|
||||
else define('MODE_EXEC', MODE_WWW);
|
||||
*/
|
||||
|
||||
/** TimeStamp Unix
|
||||
** Si $onlyMiliSec=true, retourne juste les milisec du timestamp
|
||||
**/
|
||||
function microtime_float($onlyMiliSec=false) {
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
if (!$onlyMiliSec)
|
||||
return ((float)$usec + (float)$sec);
|
||||
else
|
||||
return $usec;
|
||||
}
|
||||
|
||||
/** Fait une pause aléatoire entre 0 et 15 secondes par défaut
|
||||
**/
|
||||
function randsleep($min_sec=0, $max_sec=15) {
|
||||
sleep(rand($min_sec, $max_sec));
|
||||
}
|
||||
|
||||
/** Retourne la factorielle d'un nombre : 4! = 1*2*3*4 = 24
|
||||
**/
|
||||
function factorielle($nbr) {
|
||||
if($nbr === 0) // condition d'arret
|
||||
return 1;
|
||||
else
|
||||
return $nbr*factorielle($nbr-1);
|
||||
}
|
||||
|
||||
/** Vérification que la variable demandé respecte bien les règles passées en paramètres
|
||||
* @param mixed Variable à tester
|
||||
* @param int Longueur minimum en caractère de la variable
|
||||
* @param int Longueur mximum
|
||||
* @param char(1) Type de variable <b>A</b>:Alphanumérique / <b>N</b>:Numérique
|
||||
* @param mixed Message textuel d'erreur à afficher en cas d'erreur ou false
|
||||
* @return mixed true, false ou Message d'erreur passé en paramètre
|
||||
*/
|
||||
function valideData($variable, $taille_min, $taille_max, $type_variable, $erreur=false){
|
||||
if ( strlen((string)$variable) < $taille_min )
|
||||
return $erreur;
|
||||
|
||||
if ( strlen((string)$variable) > $taille_max )
|
||||
return $erreur;
|
||||
|
||||
if ( $type_variable == 'A' )
|
||||
if ( is_string($variable) == true )
|
||||
return true;
|
||||
else
|
||||
return $erreur;
|
||||
|
||||
elseif ( $type_variable == 'N')
|
||||
{
|
||||
for ($i=0; $i < strlen((string)$variable); $i++)
|
||||
{
|
||||
$car = substr((string)$variable,$i,1);
|
||||
if ($car<'0' || $car>'9')
|
||||
return $erreur;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return $erreur;
|
||||
}
|
||||
|
||||
function adapteOCtets($size) {
|
||||
$kb = 1024; // Kilobyte
|
||||
$mb = 1024 * $kb; // Megabyte
|
||||
$gb = 1024 * $mb; // Gigabyte
|
||||
$tb = 1024 * $gb; // Terabyte
|
||||
if($size==0) return '0';
|
||||
else if($size < $kb) return $size.'o';
|
||||
else if($size < $mb) return round($size/$kb,2).'ko';
|
||||
else if($size < $gb) return round($size/$mb,2).'Mo';
|
||||
else if($size < $tb) return round($size/$gb,2).'Go';
|
||||
else return round($size/$tb,2).'To';
|
||||
}
|
||||
|
||||
/**
|
||||
** Enregistrer une information dans la log
|
||||
**
|
||||
** @param string $debugLevel E=Error, W=Warning, N=Notice, I=Info, D=Debug
|
||||
** @param string $message Message d'erreur à inscrire dans la log
|
||||
** @param integer $line __LINE__
|
||||
** @param string $file __FILE__
|
||||
** @param string $function __FUNCTION__
|
||||
** @param string $class __CLASS___
|
||||
**/
|
||||
function debugLog($debugLevel, $message, $line, $file, $function, $class) {
|
||||
if (!file_exists(LOG_PATH.'/debug.log')) {
|
||||
$fp=fopen(LOG_PATH.'/debug.log', 'a');
|
||||
fwrite($fp, 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Memory;Message'.EOL);
|
||||
} else
|
||||
$fp=fopen(LOG_PATH.'/debug.log', 'a');
|
||||
|
||||
fwrite($fp, date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
|
||||
$_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.$line.';'. $file.';'. $function.';'. $class .';'.
|
||||
@gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . EOL);
|
||||
fclose($fp);
|
||||
|
||||
if ($debugLevel=='E'){
|
||||
if (!file_exists(LOG_PATH.'/debugError.log')) {
|
||||
$fp=fopen(LOG_PATH.'/debugError.log', 'a');
|
||||
fwrite($fp, 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Message'.EOL);
|
||||
} else
|
||||
$fp=fopen(LOG_PATH.'/debugError.log', 'a');
|
||||
fwrite($fp, date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
|
||||
$_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.$line.';'. $file.';'. $function.';'. $class .';'.
|
||||
@gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . EOL);
|
||||
fclose($fp);
|
||||
//die($message);
|
||||
}
|
||||
}
|
||||
|
||||
function prepareString($str) {
|
||||
$tabReplace=array();
|
||||
for($c=0;$c<32; $c++)
|
||||
$tabReplace[''.chr($c)]='';
|
||||
for($c=127;$c<256; $c++)
|
||||
$tabReplace[''.chr($c)]='';
|
||||
|
||||
return strtr(
|
||||
strtr(htmlentities(utf8_decode(strtr(strtr($str, 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝŸ…‘‹',
|
||||
"aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUYY.''"), array('œ'=>'oe'))), ENT_QUOTES, 'ISO-8859-1'),array('€'=>'€','’'=>'"')),
|
||||
$tabReplace);
|
||||
//return */
|
||||
//return utf8_encode($str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Déplacement d'un fichier. Retourne false en cas d'erreur.
|
||||
**
|
||||
** @param string $from
|
||||
** @param string $to
|
||||
** @return bool
|
||||
**/
|
||||
function move($from, $to) {
|
||||
return (copy($from, $to) and unlink($from));
|
||||
}
|
||||
|
||||
/** Converti une IP en nombre
|
||||
**
|
||||
** @param string $ip Adresse IP
|
||||
** @return integer
|
||||
**/
|
||||
function getIpNumber($ip) {
|
||||
$tab=explode('.', $ip);
|
||||
return (($tab[0]*256*256*256) + ($tab[1]*256*256) + ($tab[2]*256) + ($tab[3]));
|
||||
}
|
||||
|
||||
/** Vérifie si une IP est dans une plage du type 192.168.3.1-192.168.3.10
|
||||
**
|
||||
** @param string $plage_1 Plage IP de début
|
||||
** @param string $plage_2 Plage IP de fin
|
||||
** @param string $ip Adresse IP à tester
|
||||
** @return boolean
|
||||
**/
|
||||
function in_plage($plage_1,$plage_2,$ip){
|
||||
$ip2=getIpNumber($ip);
|
||||
if ($ip2>=getIpNumber($plage_1) && $ip2<=getIpNumber($plage_2))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Controle si une adresse IP est dans une liste des IP communiquées sous la forme 192.168.3.5-192.68.3.10;192.168.3.*;192.168.3.10
|
||||
**
|
||||
** @param string $strPlageIP La plage d'adresses IP
|
||||
** @param string $adresseIP L'adresse IP à tester
|
||||
** @return boolean
|
||||
**/
|
||||
function checkPlagesIp($strPlageIP, $adresseIP) {
|
||||
$connected=false;
|
||||
$tabIpAllowed=explode(';', trim($strPlageIP));
|
||||
if (count($tabIpAllowed)==1 && $tabIpAllowed[0]=='')
|
||||
$tabIpAllowed=array();
|
||||
|
||||
foreach ($tabIpAllowed as $ip) {
|
||||
$tabPlages=explode('-', $ip);
|
||||
// C'est une plage d'adresse '-'
|
||||
if (isset($tabPlages[1]))
|
||||
$connected=in_plage($tabPlages[0],$tabPlages[1],$adresseIP);
|
||||
else {
|
||||
// C'est une adresse avec ou sans masque '*'
|
||||
if (preg_match('/^'.str_replace('*','.*',str_replace('.','\.',$ip)).'$/', $adresseIP) )
|
||||
$connected=true;
|
||||
}
|
||||
if ($connected) break;
|
||||
}
|
||||
if (count($tabIpAllowed)==0) return false;
|
||||
elseif (!$connected) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param string $in
|
||||
* @param string $out
|
||||
* @desc compressing the file with the bzip2-extension
|
||||
*/
|
||||
function bzip2 ($in, $out)
|
||||
{
|
||||
if (!file_exists ($in) || !is_readable ($in))
|
||||
return false;
|
||||
if ((!file_exists ($out) && !is_writeable (dirname ($out)) || (file_exists($out) && !is_writable($out)) ))
|
||||
return false;
|
||||
|
||||
$in_file = fopen ($in, 'rb');
|
||||
$out_file = bzopen ($out.'.bz2', 'wb');
|
||||
|
||||
while (!feof ($in_file)) {
|
||||
$buffer = fgets ($in_file, 4096);
|
||||
bzwrite ($out_file, $buffer, 4096);
|
||||
}
|
||||
|
||||
fclose ($in_file);
|
||||
bzclose ($out_file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param string $in
|
||||
* @param string $out
|
||||
* @desc uncompressing the file with the bzip2-extension
|
||||
*/
|
||||
function bunzip2 ($in, $out)
|
||||
{
|
||||
if (!file_exists ($in) || !is_readable ($in))
|
||||
return false;
|
||||
if ((!file_exists ($out) && !is_writeable (dirname ($out)) || (file_exists($out) && !is_writable($out)) ))
|
||||
return false;
|
||||
|
||||
$in_file = bzopen ($in, "rb");
|
||||
$out_file = fopen ($out, "wb");
|
||||
|
||||
while ($buffer = bzread ($in_file, 4096)) {
|
||||
fwrite ($out_file, $buffer, 4096);
|
||||
}
|
||||
|
||||
bzclose ($in_file);
|
||||
fclose ($out_file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class DomDocument2 extends DOMDocument {
|
||||
|
||||
function getValueFromTag($tagName) {
|
||||
$items=$this->getElementsByTagName($tagName);
|
||||
foreach ($items as $item) {
|
||||
|
||||
return utf8_decode($item->nodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
878
framework/mail/RFC822.php
Normal file
@ -0,0 +1,878 @@
|
||||
<?php
|
||||
/**
|
||||
) o------------------------------------------------------------------------------o
|
||||
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
|
||||
* | If you use the code commercially (or if you don't want to be restricted by |
|
||||
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
|
||||
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
|
||||
* o------------------------------------------------------------------------------o
|
||||
*
|
||||
* © Copyright 2005 Richard Heyes
|
||||
*/
|
||||
|
||||
/**
|
||||
* RFC 822 Email address list validation Utility
|
||||
*
|
||||
* What is it?
|
||||
*
|
||||
* This class will take an address string, and parse it into it's consituent
|
||||
* parts, be that either addresses, groups, or combinations. Nested groups
|
||||
* are not supported. The structure it returns is pretty straight forward,
|
||||
* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
|
||||
* print_r() to view the structure.
|
||||
*
|
||||
* How do I use it?
|
||||
*
|
||||
* $address_string = 'My Group: "Richard Heyes" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
|
||||
* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', TRUE)
|
||||
* print_r($structure);
|
||||
*/
|
||||
|
||||
class Mail_RFC822
|
||||
{
|
||||
/**
|
||||
* The address being parsed by the RFC822 object.
|
||||
* @private string $address
|
||||
*/
|
||||
private $address = '';
|
||||
|
||||
/**
|
||||
* The default domain to use for unqualified addresses.
|
||||
* @private string $default_domain
|
||||
*/
|
||||
private $default_domain = 'localhost';
|
||||
|
||||
/**
|
||||
* Should we return a nested array showing groups, or flatten everything?
|
||||
* @private boolean $nestGroups
|
||||
*/
|
||||
private $nestGroups = true;
|
||||
|
||||
/**
|
||||
* Whether or not to validate atoms for non-ascii characters.
|
||||
* @private boolean $validate
|
||||
*/
|
||||
private $validate = true;
|
||||
|
||||
/**
|
||||
* The array of raw addresses built up as we parse.
|
||||
* @private array $addresses
|
||||
*/
|
||||
private $addresses = array();
|
||||
|
||||
/**
|
||||
* The final array of parsed address information that we build up.
|
||||
* @private array $structure
|
||||
*/
|
||||
private $structure = array();
|
||||
|
||||
/**
|
||||
* The current error message, if any.
|
||||
* @private string $error
|
||||
*/
|
||||
private $error = null;
|
||||
|
||||
/**
|
||||
* An internal counter/pointer.
|
||||
* @private integer $index
|
||||
*/
|
||||
private $index = null;
|
||||
|
||||
/**
|
||||
* The number of groups that have been found in the address list.
|
||||
* @private integer $num_groups
|
||||
* @access public
|
||||
*/
|
||||
private $num_groups = 0;
|
||||
|
||||
/**
|
||||
* A variable so that we can tell whether or not we're inside a
|
||||
* Mail_RFC822 object.
|
||||
* @private boolean $mailRFC822
|
||||
*/
|
||||
private $mailRFC822 = true;
|
||||
|
||||
/**
|
||||
* A limit after which processing stops
|
||||
* @private int $limit
|
||||
*/
|
||||
private $limit = null;
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the object. The address must either be set here or when
|
||||
* calling parseAddressList(). One or the other.
|
||||
*
|
||||
* @access public
|
||||
* @param string $address The address(es) to validate.
|
||||
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
|
||||
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return object Mail_RFC822 A new Mail_RFC822 object.
|
||||
*/
|
||||
function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
|
||||
{
|
||||
if (isset($address)) $this->address = $address;
|
||||
if (isset($default_domain)) $this->default_domain = $default_domain;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts the whole process. The address must either be set here
|
||||
* or when creating the object. One or the other.
|
||||
*
|
||||
* @access public
|
||||
* @param string $address The address(es) to validate.
|
||||
* @param string $default_domain Default domain/host etc.
|
||||
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return array A structured array of addresses.
|
||||
*/
|
||||
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
|
||||
{
|
||||
|
||||
if (!isset($this->mailRFC822)) {
|
||||
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
|
||||
return $obj->parseAddressList();
|
||||
}
|
||||
|
||||
if (isset($address)) $this->address = $address;
|
||||
if (isset($default_domain)) $this->default_domain = $default_domain;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
|
||||
$this->structure = array();
|
||||
$this->addresses = array();
|
||||
$this->error = null;
|
||||
$this->index = null;
|
||||
|
||||
while ($this->address = $this->_splitAddresses($this->address)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->address === false || isset($this->error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset timer since large amounts of addresses can take a long time to
|
||||
// get here
|
||||
set_time_limit(30);
|
||||
|
||||
// Loop through all the addresses
|
||||
for ($i = 0; $i < count($this->addresses); $i++){
|
||||
|
||||
if (($return = $this->_validateAddress($this->addresses[$i])) === false
|
||||
|| isset($this->error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->nestGroups) {
|
||||
$this->structure = array_merge($this->structure, $return);
|
||||
} else {
|
||||
$this->structure[] = $return;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an address into seperate addresses.
|
||||
*
|
||||
* @access private
|
||||
* @param string $address The addresses to split.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _splitAddresses($address)
|
||||
{
|
||||
|
||||
if (!empty($this->limit) AND count($this->addresses) == $this->limit) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->_isGroup($address) && !isset($this->error)) {
|
||||
$split_char = ';';
|
||||
$is_group = true;
|
||||
} elseif (!isset($this->error)) {
|
||||
$split_char = ',';
|
||||
$is_group = false;
|
||||
} elseif (isset($this->error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Split the string based on the above ten or so lines.
|
||||
$parts = explode($split_char, $address);
|
||||
$string = $this->_splitCheck($parts, $split_char);
|
||||
|
||||
// If a group...
|
||||
if ($is_group) {
|
||||
// If $string does not contain a colon outside of
|
||||
// brackets/quotes etc then something's fubar.
|
||||
|
||||
// First check there's a colon at all:
|
||||
if (strpos($string, ':') === false) {
|
||||
$this->error = 'Invalid address: ' . $string;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check it's outside of brackets/quotes:
|
||||
if (!$this->_splitCheck(explode(':', $string), ':'))
|
||||
return false;
|
||||
|
||||
// We must have a group at this point, so increase the counter:
|
||||
$this->num_groups++;
|
||||
}
|
||||
|
||||
// $string now contains the first full address/group.
|
||||
// Add to the addresses array.
|
||||
$this->addresses[] = array(
|
||||
'address' => trim($string),
|
||||
'group' => $is_group
|
||||
);
|
||||
|
||||
// Remove the now stored address from the initial line, the +1
|
||||
// is to account for the explode character.
|
||||
$address = trim(substr($address, strlen($string) + 1));
|
||||
|
||||
// If the next char is a comma and this was a group, then
|
||||
// there are more addresses, otherwise, if there are any more
|
||||
// chars, then there is another address.
|
||||
if ($is_group && substr($address, 0, 1) == ','){
|
||||
$address = trim(substr($address, 1));
|
||||
return $address;
|
||||
|
||||
} elseif (strlen($address) > 0) {
|
||||
return $address;
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If you got here then something's off
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a group at the start of the string.
|
||||
*
|
||||
* @access private
|
||||
* @param string $address The address to check.
|
||||
* @return boolean Whether or not there is a group at the start of the string.
|
||||
*/
|
||||
function _isGroup($address)
|
||||
{
|
||||
// First comma not in quotes, angles or escaped:
|
||||
$parts = explode(',', $address);
|
||||
$string = $this->_splitCheck($parts, ',');
|
||||
|
||||
// Now we have the first address, we can reliably check for a
|
||||
// group by searching for a colon that's not escaped or in
|
||||
// quotes or angle brackets.
|
||||
if (count($parts = explode(':', $string)) > 1) {
|
||||
$string2 = $this->_splitCheck($parts, ':');
|
||||
return ($string2 !== $string);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A common function that will check an exploded string.
|
||||
*
|
||||
* @access private
|
||||
* @param array $parts The exloded string.
|
||||
* @param string $char The char that was exploded on.
|
||||
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
|
||||
*/
|
||||
function _splitCheck($parts, $char)
|
||||
{
|
||||
$string = $parts[0];
|
||||
|
||||
for ($i = 0; $i < count($parts); $i++) {
|
||||
if ($this->_hasUnclosedQuotes($string)
|
||||
|| $this->_hasUnclosedBrackets($string, '<>')
|
||||
|| $this->_hasUnclosedBrackets($string, '[]')
|
||||
|| $this->_hasUnclosedBrackets($string, '()')
|
||||
|| substr($string, -1) == '\\') {
|
||||
if (isset($parts[$i + 1])) {
|
||||
$string = $string . $char . $parts[$i + 1];
|
||||
} else {
|
||||
$this->error = 'Invalid address spec. Unclosed bracket or quotes';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->index = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has an unclosed quotes or not.
|
||||
*
|
||||
* @access private
|
||||
* @param string $string The string to check.
|
||||
* @return boolean True if there are unclosed quotes inside the string, false otherwise.
|
||||
*/
|
||||
function _hasUnclosedQuotes($string)
|
||||
{
|
||||
$string = explode('"', $string);
|
||||
$string_cnt = count($string);
|
||||
|
||||
for ($i = 0; $i < (count($string) - 1); $i++)
|
||||
if (substr($string[$i], -1) == '\\')
|
||||
$string_cnt--;
|
||||
|
||||
return ($string_cnt % 2 === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has an unclosed brackets or not. IMPORTANT:
|
||||
* This function handles both angle brackets and square brackets;
|
||||
*
|
||||
* @access private
|
||||
* @param string $string The string to check.
|
||||
* @param string $chars The characters to check for.
|
||||
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
|
||||
*/
|
||||
function _hasUnclosedBrackets($string, $chars)
|
||||
{
|
||||
$num_angle_start = substr_count($string, $chars[0]);
|
||||
$num_angle_end = substr_count($string, $chars[1]);
|
||||
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
|
||||
|
||||
if ($num_angle_start < $num_angle_end) {
|
||||
$this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
|
||||
return false;
|
||||
} else {
|
||||
return ($num_angle_start > $num_angle_end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub function that is used only by hasUnclosedBrackets().
|
||||
*
|
||||
* @access private
|
||||
* @param string $string The string to check.
|
||||
* @param integer &$num The number of occurences.
|
||||
* @param string $char The character to count.
|
||||
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
|
||||
*/
|
||||
function _hasUnclosedBracketsSub($string, &$num, $char)
|
||||
{
|
||||
$parts = explode($char, $string);
|
||||
for ($i = 0; $i < count($parts); $i++){
|
||||
if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
|
||||
$num--;
|
||||
if (isset($parts[$i + 1]))
|
||||
$parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to begin checking the address.
|
||||
*
|
||||
* @access private
|
||||
* @param string $address The address to validate.
|
||||
* @return mixed False on failure, or a structured array of address information on success.
|
||||
*/
|
||||
function _validateAddress($address)
|
||||
{
|
||||
$is_group = false;
|
||||
|
||||
if ($address['group']) {
|
||||
$is_group = true;
|
||||
|
||||
// Get the group part of the name
|
||||
$parts = explode(':', $address['address']);
|
||||
$groupname = $this->_splitCheck($parts, ':');
|
||||
$structure = array();
|
||||
|
||||
// And validate the group part of the name.
|
||||
if (!$this->_validatePhrase($groupname)){
|
||||
$this->error = 'Group name did not validate.';
|
||||
return false;
|
||||
} else {
|
||||
// Don't include groups if we are not nesting
|
||||
// them. This avoids returning invalid addresses.
|
||||
if ($this->nestGroups) {
|
||||
$structure = new stdClass;
|
||||
$structure->groupname = $groupname;
|
||||
}
|
||||
}
|
||||
|
||||
$address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
|
||||
}
|
||||
|
||||
// If a group then split on comma and put into an array.
|
||||
// Otherwise, Just put the whole address in an array.
|
||||
if ($is_group) {
|
||||
while (strlen($address['address']) > 0) {
|
||||
$parts = explode(',', $address['address']);
|
||||
$addresses[] = $this->_splitCheck($parts, ',');
|
||||
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
|
||||
}
|
||||
} else {
|
||||
$addresses[] = $address['address'];
|
||||
}
|
||||
|
||||
// Check that $addresses is set, if address like this:
|
||||
// Groupname:;
|
||||
// Then errors were appearing.
|
||||
if (!isset($addresses)){
|
||||
$this->error = 'Empty group.';
|
||||
return false;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
$addresses[$i] = trim($addresses[$i]);
|
||||
}
|
||||
|
||||
// Validate each mailbox.
|
||||
// Format could be one of: name <geezer@domain.com>
|
||||
// geezer@domain.com
|
||||
// geezer
|
||||
// ... or any other format valid by RFC 822.
|
||||
array_walk($addresses, array($this, 'validateMailbox'));
|
||||
|
||||
// Nested format
|
||||
if ($this->nestGroups) {
|
||||
if ($is_group) {
|
||||
$structure->addresses = $addresses;
|
||||
} else {
|
||||
$structure = $addresses[0];
|
||||
}
|
||||
|
||||
// Flat format
|
||||
} else {
|
||||
if ($is_group) {
|
||||
$structure = array_merge($structure, $addresses);
|
||||
} else {
|
||||
$structure = $addresses;
|
||||
}
|
||||
}
|
||||
|
||||
return $structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a phrase.
|
||||
*
|
||||
* @access private
|
||||
* @param string $phrase The phrase to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _validatePhrase($phrase)
|
||||
{
|
||||
// Splits on one or more Tab or space.
|
||||
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$phrase_parts = array();
|
||||
while (count($parts) > 0){
|
||||
$phrase_parts[] = $this->_splitCheck($parts, ' ');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($phrase_parts); $i++) {
|
||||
// If quoted string:
|
||||
if (substr($phrase_parts[$i], 0, 1) == '"') {
|
||||
if (!$this->_validateQuotedString($phrase_parts[$i]))
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise it's an atom:
|
||||
if (!$this->_validateAtom($phrase_parts[$i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an atom which from rfc822 is:
|
||||
* atom = 1*<any CHAR except specials, SPACE and CTLs>
|
||||
*
|
||||
* If validation ($this->validate) has been turned off, then
|
||||
* validateAtom() doesn't actually check anything. This is so that you
|
||||
* can split a list of addresses up before encoding personal names
|
||||
* (umlauts, etc.), for example.
|
||||
*
|
||||
* @access private
|
||||
* @param string $atom The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _validateAtom($atom)
|
||||
{
|
||||
if (!$this->validate) {
|
||||
// Validation has been turned off; assume the atom is okay.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for any char from ASCII 0 - ASCII 127
|
||||
if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for specials:
|
||||
if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for control characters (ASCII 0-31):
|
||||
if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate quoted string, which is:
|
||||
* quoted-string = <"> *(qtext/quoted-pair) <">
|
||||
*
|
||||
* @access private
|
||||
* @param string $qstring The string to check
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _validateQuotedString($qstring)
|
||||
{
|
||||
// Leading and trailing "
|
||||
$qstring = substr($qstring, 1, -1);
|
||||
|
||||
// Perform check.
|
||||
return !(preg_match('/(.)[\x0D\\\\"]/', $qstring, $matches) && $matches[1] != '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a mailbox, which is:
|
||||
* mailbox = addr-spec ; simple address
|
||||
* / phrase route-addr ; name and route-addr
|
||||
*
|
||||
* @access public
|
||||
* @param string &$mailbox The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function validateMailbox(&$mailbox)
|
||||
{
|
||||
// A couple of defaults.
|
||||
$phrase = '';
|
||||
$comment = '';
|
||||
|
||||
// Catch any RFC822 comments and store them separately
|
||||
$_mailbox = $mailbox;
|
||||
while (strlen(trim($_mailbox)) > 0) {
|
||||
$parts = explode('(', $_mailbox);
|
||||
$before_comment = $this->_splitCheck($parts, '(');
|
||||
if ($before_comment != $_mailbox) {
|
||||
// First char should be a (
|
||||
$comment = substr(str_replace($before_comment, '', $_mailbox), 1);
|
||||
$parts = explode(')', $comment);
|
||||
$comment = $this->_splitCheck($parts, ')');
|
||||
$comments[] = $comment;
|
||||
|
||||
// +1 is for the trailing )
|
||||
$_mailbox = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for($i=0; $i<count(@$comments); $i++){
|
||||
$mailbox = str_replace('('.$comments[$i].')', '', $mailbox);
|
||||
}
|
||||
$mailbox = trim($mailbox);
|
||||
|
||||
// Check for name + route-addr
|
||||
if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
|
||||
$parts = explode('<', $mailbox);
|
||||
$name = $this->_splitCheck($parts, '<');
|
||||
|
||||
$phrase = trim($name);
|
||||
$route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
|
||||
|
||||
if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false)
|
||||
return false;
|
||||
|
||||
// Only got addr-spec
|
||||
} else {
|
||||
// First snip angle brackets if present.
|
||||
if (substr($mailbox,0,1) == '<' && substr($mailbox,-1) == '>')
|
||||
$addr_spec = substr($mailbox,1,-1);
|
||||
else
|
||||
$addr_spec = $mailbox;
|
||||
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Construct the object that will be returned.
|
||||
$mbox = new stdClass();
|
||||
|
||||
// Add the phrase (even if empty) and comments
|
||||
$mbox->personal = $phrase;
|
||||
$mbox->comment = isset($comments) ? $comments : array();
|
||||
|
||||
if (isset($route_addr)) {
|
||||
$mbox->mailbox = $route_addr['local_part'];
|
||||
$mbox->host = $route_addr['domain'];
|
||||
$route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
|
||||
} else {
|
||||
$mbox->mailbox = $addr_spec['local_part'];
|
||||
$mbox->host = $addr_spec['domain'];
|
||||
}
|
||||
|
||||
$mailbox = $mbox;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function validates a route-addr which is:
|
||||
* route-addr = "<" [route] addr-spec ">"
|
||||
*
|
||||
* Angle brackets have already been removed at the point of
|
||||
* getting to this function.
|
||||
*
|
||||
* @access private
|
||||
* @param string $route_addr The string to check.
|
||||
* @return mixed False on failure, or an array containing validated address/route information on success.
|
||||
*/
|
||||
function _validateRouteAddr($route_addr)
|
||||
{
|
||||
// Check for colon.
|
||||
if (strpos($route_addr, ':') !== false) {
|
||||
$parts = explode(':', $route_addr);
|
||||
$route = $this->_splitCheck($parts, ':');
|
||||
} else {
|
||||
$route = $route_addr;
|
||||
}
|
||||
|
||||
// If $route is same as $route_addr then the colon was in
|
||||
// quotes or brackets or, of course, non existent.
|
||||
if ($route === $route_addr){
|
||||
unset($route);
|
||||
$addr_spec = $route_addr;
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Validate route part.
|
||||
if (($route = $this->_validateRoute($route)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$addr_spec = substr($route_addr, strlen($route . ':'));
|
||||
|
||||
// Validate addr-spec part.
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($route)) {
|
||||
$return['adl'] = $route;
|
||||
} else {
|
||||
$return['adl'] = '';
|
||||
}
|
||||
|
||||
$return = array_merge($return, $addr_spec);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a route, which is:
|
||||
* route = 1#("@" domain) ":"
|
||||
*
|
||||
* @access private
|
||||
* @param string $route The string to check.
|
||||
* @return mixed False on failure, or the validated $route on success.
|
||||
*/
|
||||
function _validateRoute($route)
|
||||
{
|
||||
// Split on comma.
|
||||
$domains = explode(',', trim($route));
|
||||
|
||||
for ($i = 0; $i < count($domains); $i++) {
|
||||
$domains[$i] = str_replace('@', '', trim($domains[$i]));
|
||||
if (!$this->_validateDomain($domains[$i])) return false;
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain, though this is not quite what
|
||||
* you expect of a strict internet domain.
|
||||
*
|
||||
* domain = sub-domain *("." sub-domain)
|
||||
*
|
||||
* @access private
|
||||
* @param string $domain The string to check.
|
||||
* @return mixed False on failure, or the validated domain on success.
|
||||
*/
|
||||
function _validateDomain($domain)
|
||||
{
|
||||
// Note the different use of $subdomains and $sub_domains
|
||||
$subdomains = explode('.', $domain);
|
||||
|
||||
while (count($subdomains) > 0) {
|
||||
$sub_domains[] = $this->_splitCheck($subdomains, '.');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($subdomains);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($sub_domains); $i++) {
|
||||
if (!$this->_validateSubdomain(trim($sub_domains[$i])))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return input.
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a subdomain:
|
||||
* subdomain = domain-ref / domain-literal
|
||||
*
|
||||
* @access private
|
||||
* @param string $subdomain The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _validateSubdomain($subdomain)
|
||||
{
|
||||
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
|
||||
if (!$this->_validateDliteral($arr[1])) return false;
|
||||
} else {
|
||||
if (!$this->_validateAtom($subdomain)) return false;
|
||||
}
|
||||
|
||||
// Got here, so return successful.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain literal:
|
||||
* domain-literal = "[" *(dtext / quoted-pair) "]"
|
||||
*
|
||||
* @access private
|
||||
* @param string $dliteral The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function _validateDliteral($dliteral)
|
||||
{
|
||||
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an addr-spec.
|
||||
*
|
||||
* addr-spec = local-part "@" domain
|
||||
*
|
||||
* @access private
|
||||
* @param string $addr_spec The string to check.
|
||||
* @return mixed False on failure, or the validated addr-spec on success.
|
||||
*/
|
||||
function _validateAddrSpec($addr_spec)
|
||||
{
|
||||
$addr_spec = trim($addr_spec);
|
||||
|
||||
// Split on @ sign if there is one.
|
||||
if (strpos($addr_spec, '@') !== false) {
|
||||
$parts = explode('@', $addr_spec);
|
||||
$local_part = $this->_splitCheck($parts, '@');
|
||||
$domain = substr($addr_spec, strlen($local_part . '@'));
|
||||
|
||||
// No @ sign so assume the default domain.
|
||||
} else {
|
||||
$local_part = $addr_spec;
|
||||
$domain = $this->default_domain;
|
||||
}
|
||||
|
||||
if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
|
||||
if (($domain = $this->_validateDomain($domain)) === false) return false;
|
||||
|
||||
// Got here so return successful.
|
||||
return array('local_part' => $local_part, 'domain' => $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate the local part of an address:
|
||||
* local-part = word *("." word)
|
||||
*
|
||||
* @access private
|
||||
* @param string $local_part
|
||||
* @return mixed False on failure, or the validated local part on success.
|
||||
*/
|
||||
function _validateLocalPart($local_part)
|
||||
{
|
||||
$parts = explode('.', $local_part);
|
||||
|
||||
// Split the local_part into words.
|
||||
while (count($parts) > 0){
|
||||
$words[] = $this->_splitCheck($parts, '.');
|
||||
for ($i = 0; $i < $this->index + 1; $i++) {
|
||||
array_shift($parts);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate each word.
|
||||
for ($i = 0; $i < count($words); $i++) {
|
||||
if ($this->_validatePhrase(trim($words[$i])) === false) return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return the input.
|
||||
return $local_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an approximate count of how many addresses are
|
||||
* in the given string. This is APPROXIMATE as it only splits
|
||||
* based on a comma which has no preceding backslash. Could be
|
||||
* useful as large amounts of addresses will end up producing
|
||||
* *large* structures when used with parseAddressList().
|
||||
*
|
||||
* @param string $data Addresses to count
|
||||
* @return int Approximate count
|
||||
*/
|
||||
function approximateCount($data)
|
||||
{
|
||||
return count(preg_split('/(?<!\\\\),/', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a email validating function seperate to the rest
|
||||
* of the class. It simply validates whether an email is of
|
||||
* the common internet form: <user>@<domain>. This can be
|
||||
* sufficient for most people. Optional stricter mode can
|
||||
* be utilised which restricts mailbox characters allowed
|
||||
* to alphanumeric, full stop, hyphen and underscore.
|
||||
*
|
||||
* @param string $data Address to check
|
||||
* @param boolean $strict Optional stricter mode
|
||||
* @return mixed False if it fails, an indexed array
|
||||
* username/domain if it matches
|
||||
*/
|
||||
function isValidInetAddress($data, $strict = false)
|
||||
{
|
||||
$regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';
|
||||
if (preg_match($regex, trim($data), $matches)) {
|
||||
return array($matches[1], $matches[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
1111
framework/mail/htmlMimeMail5.php
Normal file
311
framework/mail/mimePart.php
Normal file
@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/**
|
||||
* o------------------------------------------------------------------------------o
|
||||
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
|
||||
* | If you use the code commercially (or if you don't want to be restricted by |
|
||||
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
|
||||
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
|
||||
* o------------------------------------------------------------------------------o
|
||||
*
|
||||
* © Copyright Richard Heyes
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Raw mime encoding class
|
||||
*
|
||||
* What is it?
|
||||
* This class enables you to manipulate and build
|
||||
* a mime email from the ground up.
|
||||
*
|
||||
* Why use this instead of mime.php?
|
||||
* mime.php is a userfriendly api to this class for
|
||||
* people who aren't interested in the internals of
|
||||
* mime mail. This class however allows full control
|
||||
* over the email.
|
||||
*
|
||||
* Eg.
|
||||
*
|
||||
* // Since multipart/mixed has no real body, (the body is
|
||||
* // the subpart), we set the body argument to blank.
|
||||
*
|
||||
* $params['content_type'] = 'multipart/mixed';
|
||||
* $email = new Mail_mimePart('', $params);
|
||||
*
|
||||
* // Here we add a text part to the multipart we have
|
||||
* // already. Assume $body contains plain text.
|
||||
*
|
||||
* $params['content_type'] = 'text/plain';
|
||||
* $params['encoding'] = '7bit';
|
||||
* $text = $email->addSubPart($body, $params);
|
||||
*
|
||||
* // Now add an attachment. Assume $attach is
|
||||
* the contents of the attachment
|
||||
*
|
||||
* $params['content_type'] = 'application/zip';
|
||||
* $params['encoding'] = 'base64';
|
||||
* $params['disposition'] = 'attachment';
|
||||
* $params['dfilename'] = 'example.zip';
|
||||
* $attach =& $email->addSubPart($body, $params);
|
||||
*
|
||||
* // Now build the email. Note that the encode
|
||||
* // function returns an associative array containing two
|
||||
* // elements, body and headers. You will need to add extra
|
||||
* // headers, (eg. Mime-Version) before sending.
|
||||
*
|
||||
* $email = $message->encode();
|
||||
* $email['headers'][] = 'Mime-Version: 1.0';
|
||||
*
|
||||
*
|
||||
* Further examples are available at http://www.phpguru.org
|
||||
*
|
||||
* TODO:
|
||||
* - Set encode() to return the $obj->encoded if encode()
|
||||
* has already been run. Unless a flag is passed to specifically
|
||||
* re-build the message.
|
||||
*
|
||||
* @author Richard Heyes <richard@phpguru.org>
|
||||
* @version $Revision: 1.3 $
|
||||
* @package Mail
|
||||
*/
|
||||
|
||||
class Mail_MIMEPart
|
||||
{
|
||||
/**
|
||||
* The encoding type of this part
|
||||
* @var string
|
||||
*/
|
||||
private $encoding;
|
||||
|
||||
/**
|
||||
* An array of subparts
|
||||
* @var array
|
||||
*/
|
||||
private $subparts;
|
||||
|
||||
/**
|
||||
* The output of this part after being built
|
||||
* @var string
|
||||
*/
|
||||
private $encoded;
|
||||
|
||||
/**
|
||||
* Headers for this part
|
||||
* @var array
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* The body of this part (not encoded)
|
||||
* @var string
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Sets up the object.
|
||||
*
|
||||
* @param $body - The body of the mime part if any.
|
||||
* @param $params - An associative array of parameters:
|
||||
* content_type - The content type for this part eg multipart/mixed
|
||||
* encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable
|
||||
* cid - Content ID to apply
|
||||
* disposition - Content disposition, inline or attachment
|
||||
* dfilename - Optional filename parameter for content disposition
|
||||
* description - Content description
|
||||
* charset - Character set to use
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($body = '', $params = array())
|
||||
{
|
||||
if (!defined('MAIL_MIMEPART_CRLF')) {
|
||||
define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", true);
|
||||
}
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'content_type':
|
||||
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
|
||||
break;
|
||||
|
||||
case 'encoding':
|
||||
$this->encoding = $value;
|
||||
$headers['Content-Transfer-Encoding'] = $value;
|
||||
break;
|
||||
|
||||
case 'cid':
|
||||
$headers['Content-ID'] = '<' . $value . '>';
|
||||
break;
|
||||
|
||||
case 'disposition':
|
||||
$headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : '');
|
||||
break;
|
||||
|
||||
case 'dfilename':
|
||||
if (isset($headers['Content-Disposition'])) {
|
||||
$headers['Content-Disposition'] .= '; filename="' . $value . '"';
|
||||
} else {
|
||||
$dfilename = $value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
$headers['Content-Description'] = $value;
|
||||
break;
|
||||
|
||||
case 'charset':
|
||||
if (isset($headers['Content-Type'])) {
|
||||
$headers['Content-Type'] .= '; charset="' . $value . '"';
|
||||
} else {
|
||||
$charset = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Default content-type
|
||||
if (!isset($headers['Content-Type'])) {
|
||||
$headers['Content-Type'] = 'text/plain';
|
||||
}
|
||||
|
||||
// Default encoding
|
||||
if (!isset($this->encoding)) {
|
||||
$this->encoding = '7bit';
|
||||
}
|
||||
|
||||
// Assign stuff to member variables
|
||||
$this->encoded = array();
|
||||
$this->headers = $headers;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes and returns the email. Also stores
|
||||
* it in the encoded member variable
|
||||
*
|
||||
* @return An associative array containing two elements,
|
||||
* body and headers. The headers element is itself
|
||||
* an indexed array.
|
||||
*/
|
||||
public function encode()
|
||||
{
|
||||
$encoded =& $this->encoded;
|
||||
|
||||
if (!empty($this->subparts)) {
|
||||
srand((double)microtime()*1000000);
|
||||
$boundary = '=_' . md5(uniqid(rand()) . microtime());
|
||||
$this->headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"';
|
||||
|
||||
// Add body parts to $subparts
|
||||
for ($i = 0; $i < count($this->subparts); $i++) {
|
||||
$headers = array();
|
||||
$tmp = $this->subparts[$i]->encode();
|
||||
foreach ($tmp['headers'] as $key => $value) {
|
||||
$headers[] = $key . ': ' . $value;
|
||||
}
|
||||
$subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'];
|
||||
}
|
||||
|
||||
$encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
|
||||
implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) .
|
||||
'--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
|
||||
} else {
|
||||
$encoded['body'] = $this->getEncodedData($this->body, $this->encoding) . MAIL_MIMEPART_CRLF;
|
||||
}
|
||||
|
||||
// Add headers to $encoded
|
||||
$encoded['headers'] =& $this->headers;
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a subpart to current mime part and returns
|
||||
* a reference to it
|
||||
*
|
||||
* @param $body The body of the subpart, if any.
|
||||
* @param $params The parameters for the subpart, same
|
||||
* as the $params argument for constructor.
|
||||
* @return A reference to the part you just added.
|
||||
*/
|
||||
public function addSubPart($body, $params)
|
||||
{
|
||||
$this->subparts[] = new Mail_MIMEPart($body, $params);
|
||||
|
||||
return $this->subparts[count($this->subparts) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns encoded data based upon encoding passed to it
|
||||
*
|
||||
* @param $data The data to encode.
|
||||
* @param $encoding The encoding type to use, 7bit, base64,
|
||||
* or quoted-printable.
|
||||
*/
|
||||
private function getEncodedData($data, $encoding)
|
||||
{
|
||||
switch ($encoding) {
|
||||
case '8bit':
|
||||
case '7bit':
|
||||
return $data;
|
||||
break;
|
||||
|
||||
case 'quoted-printable':
|
||||
return $this->quotedPrintableEncode($data);
|
||||
break;
|
||||
|
||||
case 'base64':
|
||||
return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF));
|
||||
break;
|
||||
|
||||
default:
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes data to quoted-printable standard.
|
||||
*
|
||||
* @param $input The data to encode
|
||||
* @param $line_max Optional max line length. Should
|
||||
* not be more than 76 chars
|
||||
*/
|
||||
private function quotedPrintableEncode($input , $line_max = 76)
|
||||
{
|
||||
$lines = preg_split("/\r?\n/", $input);
|
||||
$eol = MAIL_MIMEPART_CRLF;
|
||||
$escape = '=';
|
||||
$output = '';
|
||||
|
||||
while(list(, $line) = each($lines)){
|
||||
|
||||
$linlen = strlen($line);
|
||||
$newline = '';
|
||||
|
||||
for ($i = 0; $i < $linlen; $i++) {
|
||||
$char = substr($line, $i, 1);
|
||||
$dec = ord($char);
|
||||
|
||||
if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only
|
||||
$char = '=20';
|
||||
|
||||
} elseif($dec == 9) {
|
||||
; // Do nothing if a tab.
|
||||
} elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) {
|
||||
$char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
|
||||
}
|
||||
|
||||
if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted
|
||||
$output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
|
||||
$newline = '';
|
||||
}
|
||||
$newline .= $char;
|
||||
} // end of for
|
||||
$output .= $newline . $eol;
|
||||
}
|
||||
$output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf
|
||||
return $output;
|
||||
}
|
||||
} // End of class
|
||||
?>
|
103
framework/mail/sendMail.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?
|
||||
|
||||
function sendMail($from, $to, $subject, $text='', $html='', /*$priority='high', $tabImgFiles=array(), */$tabAttachedFiles=array())
|
||||
{
|
||||
//return true;
|
||||
$to=preg_split("/[\s,;]+/", $to);
|
||||
//die(print_r($to));
|
||||
|
||||
require_once('Mail.php');
|
||||
require_once('Mail/mime.php');
|
||||
|
||||
$headers=array( 'From'=>$from,
|
||||
'To'=>$to,
|
||||
'Subject'=>$subject,
|
||||
// 'Reply-To'=>$from,
|
||||
// 'Return-Path'=>$from,
|
||||
'Content-Transfer-Encoding'=>'8bit',
|
||||
'MIME-Version'=>'1.0',
|
||||
'Date'=>date('D, d M Y H:i:s O'),
|
||||
'Message-ID'=>'<'.md5(date('YmdHis')).'@mail.scores-decisions.com>',
|
||||
'X-Priority'=>3,
|
||||
'X-Mailer'=>'PHP v'.phpversion(),
|
||||
);
|
||||
/*
|
||||
# Boundry for marking the split & Multitype Headers
|
||||
$mime_boundary=md5(time());
|
||||
$headers .= ''.$eol;
|
||||
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
|
||||
$msg = "";
|
||||
*/
|
||||
$mime = new Mail_mime();
|
||||
$footer="";/*
|
||||
|
||||
_______________________________________________________________________
|
||||
Ce message et toutes les pièces jointes (ci-après le \"message\") sont établis a l'intention exclusive de ses destinataires.Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur par e-mail. Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. Les communications sur Internet n'étant pas sécurisées, SCORES & DECISIONS S.A.S. informe qu'elle ne peut accepter aucune responsabilite quant au contenu de ce message.
|
||||
This mail message and attachments (the \"message\") are solely intended for the addressees. It is confidential in nature . If you receive this message in error, please delete it and immediately notify the sender by e-mail. Any use other than its intended purpose, dissemination or disclosure, either whole or partial, is prohibited except if formal approval is granted. As communication on the Internet is not secure, SCORES & DECISIONS S.A.S. does not accept responsability for the content of this message.
|
||||
|
||||
|
||||
";*/
|
||||
|
||||
if ($text<>'') $mime->setTXTBody($text.$footer);
|
||||
if ($html<>'') $mime->setHTMLBody($html);
|
||||
|
||||
foreach ($tabAttachedFiles as $file)
|
||||
$mime->addAttachment($file);
|
||||
|
||||
//do not ever try to call these lines in reverse order
|
||||
$body = $mime->get();
|
||||
$headers = $mime->headers($headers);
|
||||
|
||||
$params=array( 'host'=>'smtpauth.online.net', // SMTP_HOST
|
||||
'port'=>25, //SMTP_PORT,
|
||||
);
|
||||
$params=array( 'host'=>SMTP_HOST,
|
||||
'port'=>SMTP_PORT,
|
||||
//'debug'=>true,
|
||||
//'persist'=>true,
|
||||
);
|
||||
|
||||
if (SMTP_USER=='' && SMTP_PASS=='')
|
||||
$params['auth'] = false;
|
||||
else {
|
||||
$params['username'] = SMTP_USER;
|
||||
$params['password'] = SMTP_PASS;
|
||||
}/*
|
||||
$params['auth'] = true;
|
||||
$params['username'] = 'buzuk@scores-decisions.com';
|
||||
$params['password'] = 'catsysyo92';
|
||||
*/
|
||||
|
||||
$nbEssais=0;
|
||||
while (1) {
|
||||
// Create the mail object using the Mail::factory method
|
||||
$mail_object = Mail::factory('smtp', $params);
|
||||
// Trying to send the mail
|
||||
$send = $mail_object->send($to, $headers, $body);
|
||||
$nbEssais++;
|
||||
if (PEAR::isError($send)) {
|
||||
/** @todo tester les différents codes erreur **/
|
||||
echo date('Y-m-d H:i:s'). " sendMail.php - essai #$nbEssais : ".$send->getMessage().EOL;
|
||||
if (preg_match('/too many connections|421/i', $send->getMessage()))
|
||||
sleep($nbEssais);
|
||||
else {
|
||||
$strTo=implode(';', $to);
|
||||
file_put_contents( LOG_PATH.'/sendMailError.log',
|
||||
date('Y-m-d H:i:s')."\t#$nbEssais\t$strTo\t".$send->getMessage().EOL,
|
||||
FILE_APPEND);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
/** Si nous sommes en mode CLI, alors on fait en sorte de ne pas atteindre
|
||||
la limite des 25 mails par minute (ramené à 100 / minute)
|
||||
**/
|
||||
if (MODE_EXEC==MODE_CLI) usleep(500000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
33
framework/mail/sendMailOld.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?
|
||||
|
||||
function sendMail($from, $to, $subject, $text='', $html='', $priority='high', $tabImgFiles=array(), $tabAttachedFiles=array())
|
||||
{
|
||||
|
||||
require_once("Mail.php");
|
||||
|
||||
$headers["From"] = $from;
|
||||
$headers["To"] = $to;
|
||||
$headers["Subject"] = $subject;
|
||||
|
||||
$body = $text;
|
||||
|
||||
$params["host"] = SMTP_HOST;
|
||||
$params["port"] = SMTP_PORT;
|
||||
if (SMTP_USER=='' && SMTP_PASS=='')
|
||||
$params["auth"] = false;
|
||||
else {
|
||||
$params["username"] = SMTP_USER;
|
||||
$params["password"] = SMTP_PASS;
|
||||
}
|
||||
|
||||
// Create the mail object using the Mail::factory method
|
||||
$mail_object = Mail::factory("smtp", $params);
|
||||
|
||||
$mail_object->send($to, $headers, $body);
|
||||
|
||||
if (PEAR::isError($mail_object))
|
||||
return $mail_object->getMessage();
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
369
framework/mail/smtp.php
Normal file
@ -0,0 +1,369 @@
|
||||
<?php
|
||||
/**
|
||||
) o------------------------------------------------------------------------------o
|
||||
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
|
||||
* | If you use the code commercially (or if you don't want to be restricted by |
|
||||
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
|
||||
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
|
||||
* o------------------------------------------------------------------------------o
|
||||
*
|
||||
* © Copyright 2005 Richard Heyes
|
||||
*/
|
||||
|
||||
define('SMTP_STATUS_NOT_CONNECTED', 1, true);
|
||||
define('SMTP_STATUS_CONNECTED', 2, true);
|
||||
|
||||
class smtp
|
||||
{
|
||||
private $authenticated;
|
||||
private $connection;
|
||||
private $recipients;
|
||||
private $headers;
|
||||
private $timeout;
|
||||
private $errors;
|
||||
private $status;
|
||||
private $body;
|
||||
private $from;
|
||||
private $host;
|
||||
private $port;
|
||||
private $helo;
|
||||
private $auth;
|
||||
private $user;
|
||||
private $pass;
|
||||
|
||||
/**
|
||||
* Constructor function. Arguments:
|
||||
* $params - An assoc array of parameters:
|
||||
*
|
||||
* host - The hostname of the smtp server Default: localhost
|
||||
* port - The port the smtp server runs on Default: 25
|
||||
* helo - What to send as the HELO command Default: localhost
|
||||
* (typically the hostname of the
|
||||
* machine this script runs on)
|
||||
* auth - Whether to use basic authentication Default: FALSE
|
||||
* user - Username for authentication Default: <blank>
|
||||
* pass - Password for authentication Default: <blank>
|
||||
* timeout - The timeout in seconds for the call Default: 5
|
||||
* to fsockopen()
|
||||
*/
|
||||
public function __construct($params = array())
|
||||
{
|
||||
|
||||
if(!defined('CRLF'))
|
||||
define('CRLF', "\r\n", TRUE);
|
||||
|
||||
$this->authenticated = FALSE;
|
||||
$this->timeout = 5;
|
||||
$this->status = SMTP_STATUS_NOT_CONNECTED;
|
||||
$this->host = 'smtp.free.fr';
|
||||
$this->port = 25;
|
||||
$this->helo = 'srvsd01';
|
||||
$this->auth = FALSE;
|
||||
$this->user = '';
|
||||
$this->pass = '';
|
||||
$this->errors = array();
|
||||
|
||||
foreach($params as $key => $value){
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect function. This will, when called
|
||||
* statically, create a new smtp object,
|
||||
* call the connect function (ie this function)
|
||||
* and return it. When not called statically,
|
||||
* it will connect to the server and send
|
||||
* the HELO command.
|
||||
*/
|
||||
public function connect($params = array())
|
||||
{
|
||||
if (!isset($this->status)) {
|
||||
$obj = new smtp($params);
|
||||
if($obj->connect()){
|
||||
$obj->status = SMTP_STATUS_CONNECTED;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
|
||||
} else {
|
||||
$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
|
||||
if (function_exists('socket_set_timeout')) {
|
||||
@socket_set_timeout($this->connection, 5, 0);
|
||||
}
|
||||
|
||||
$greeting = $this->get_data();
|
||||
if (is_resource($this->connection)) {
|
||||
return $this->auth ? $this->ehlo() : $this->helo();
|
||||
} else {
|
||||
$this->errors[] = 'Failed to connect to server: '.$errstr;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which handles sending the mail.
|
||||
* Arguments:
|
||||
* $params - Optional assoc array of parameters.
|
||||
* Can contain:
|
||||
* recipients - Indexed array of recipients
|
||||
* from - The from address. (used in MAIL FROM:),
|
||||
* this will be the return path
|
||||
* headers - Indexed array of headers, one header per array entry
|
||||
* body - The body of the email
|
||||
* It can also contain any of the parameters from the connect()
|
||||
* function
|
||||
*/
|
||||
public function send($params = array())
|
||||
{
|
||||
foreach ($params as $key => $value) {
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
if ($this->is_connected()) {
|
||||
|
||||
// Do we auth or not? Note the distinction between the auth variable and auth() function
|
||||
if ($this->auth AND !$this->authenticated) {
|
||||
if(!$this->auth())
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->mail($this->from);
|
||||
|
||||
if (is_array($this->recipients)) {
|
||||
foreach ($this->recipients as $value) {
|
||||
$this->rcpt($value);
|
||||
}
|
||||
} else {
|
||||
$this->rcpt($this->recipients);
|
||||
}
|
||||
|
||||
if (!$this->data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Transparency
|
||||
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF, $this->headers)));
|
||||
$body = str_replace(CRLF.'.', CRLF.'..', $this->body);
|
||||
$body = substr($body, 0, 1) == '.' ? '.'.$body : $body;
|
||||
|
||||
$this->send_data($headers);
|
||||
$this->send_data('');
|
||||
$this->send_data($body);
|
||||
$this->send_data('.');
|
||||
|
||||
$result = (substr(trim($this->get_data()), 0, 3) === '250');
|
||||
//$this->rset();
|
||||
return $result;
|
||||
} else {
|
||||
$this->errors[] = 'Not connected!';
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to implement HELO cmd
|
||||
*/
|
||||
private function helo()
|
||||
{
|
||||
if(is_resource($this->connection)
|
||||
AND $this->send_data('HELO '.$this->helo)
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = 'HELO command failed, output: ' . trim(substr(trim($error),3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to implement EHLO cmd
|
||||
*/
|
||||
private function ehlo()
|
||||
{
|
||||
if (is_resource($this->connection)
|
||||
AND $this->send_data('EHLO '.$this->helo)
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = 'EHLO command failed, output: ' . trim(substr(trim($error),3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to implement RSET cmd
|
||||
*/
|
||||
private function rset()
|
||||
{
|
||||
if (is_resource($this->connection)
|
||||
AND $this->send_data('RSET')
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = 'RSET command failed, output: ' . trim(substr(trim($error),3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to implement QUIT cmd
|
||||
*/
|
||||
private function quit()
|
||||
{
|
||||
if(is_resource($this->connection)
|
||||
AND $this->send_data('QUIT')
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '221' ){
|
||||
|
||||
fclose($this->connection);
|
||||
$this->status = SMTP_STATUS_NOT_CONNECTED;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = 'QUIT command failed, output: ' . trim(substr(trim($error),3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to implement AUTH cmd
|
||||
*/
|
||||
private function auth()
|
||||
{
|
||||
if (is_resource($this->connection)
|
||||
AND $this->send_data('AUTH LOGIN')
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '334'
|
||||
AND $this->send_data(base64_encode($this->user)) // Send username
|
||||
AND substr(trim($error = $this->get_data()),0,3) === '334'
|
||||
AND $this->send_data(base64_encode($this->pass)) // Send password
|
||||
AND substr(trim($error = $this->get_data()),0,3) === '235' ){
|
||||
|
||||
$this->authenticated = true;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = 'AUTH command failed: ' . trim(substr(trim($error),3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that handles the MAIL FROM: cmd
|
||||
*/
|
||||
private function mail($from)
|
||||
{
|
||||
if ($this->is_connected()
|
||||
AND $this->send_data('MAIL FROM:<'.$from.'>')
|
||||
AND substr(trim($this->get_data()), 0, 2) === '250' ) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that handles the RCPT TO: cmd
|
||||
*/
|
||||
private function rcpt($to)
|
||||
{
|
||||
if($this->is_connected()
|
||||
AND $this->send_data('RCPT TO:<'.$to.'>')
|
||||
AND substr(trim($error = $this->get_data()), 0, 2) === '25' ){
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = trim(substr(trim($error), 3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that sends the DATA cmd
|
||||
*/
|
||||
private function data()
|
||||
{
|
||||
if($this->is_connected()
|
||||
AND $this->send_data('DATA')
|
||||
AND substr(trim($error = $this->get_data()), 0, 3) === '354' ) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$this->errors[] = trim(substr(trim($error), 3));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to determine if this object
|
||||
* is connected to the server or not.
|
||||
*/
|
||||
private function is_connected()
|
||||
{
|
||||
return (is_resource($this->connection) AND ($this->status === SMTP_STATUS_CONNECTED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send a bit of data
|
||||
*/
|
||||
private function send_data($data)
|
||||
{
|
||||
if(is_resource($this->connection)){
|
||||
return fwrite($this->connection, $data.CRLF, strlen($data)+2);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get data.
|
||||
*/
|
||||
private function get_data()
|
||||
{
|
||||
$return = '';
|
||||
$line = '';
|
||||
$loops = 0;
|
||||
|
||||
if(is_resource($this->connection)){
|
||||
while((strpos($return, CRLF) === FALSE OR substr($line,3,1) !== ' ') AND $loops < 100){
|
||||
$line = fgets($this->connection, 512);
|
||||
$return .= $line;
|
||||
$loops++;
|
||||
}
|
||||
return $return;
|
||||
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a variable
|
||||
*/
|
||||
public function set($var, $value)
|
||||
{
|
||||
$this->$var = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the errors array
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
|
||||
} // End of class
|
||||
?>
|
215
framework/sphinx/recherche.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?
|
||||
|
||||
include_once(FWK_PATH.'common/strings.php');
|
||||
include_once(FWK_PATH.'sphinx/sphinxapi2.php');
|
||||
|
||||
function search($index, $findMe, $tabFiltres=array(), $deb=0, $nbRep=20, $max=200, $any=false) {
|
||||
$deb=$deb*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$max=$max*1;
|
||||
|
||||
debugLog('I',"Search Sphinx dans $index de $findMe ($deb, $nbRep, $max) avec ".implode(',',$tabFiltres),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$iDb=new WDB();
|
||||
/*
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
|
||||
$res = $cl->Query ( $q, $index );
|
||||
*/
|
||||
|
||||
//$any = false; // si false $index='xxx'
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer (SPHINX_HOST, SPHINX_PORT);
|
||||
$cl->SetConnectTimeout ( 1 );
|
||||
$cl->SetLimits ($deb, $nbRep, $max);//0, $nbRep*10);
|
||||
//$cl->SetSortMode(SPH_SORT_ATTR_DESC, 'actif');//siege');
|
||||
if (substr($index,0,4)=='etab')
|
||||
$cl->SetSortMode(SPH_SORT_EXTENDED, 'rang DESC, actif DESC, siege DESC');//, nic DESC
|
||||
|
||||
//$cl->SetWeights ( array ( 100, 1 ) );
|
||||
//$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($tabFiltres as $nomFiltre => $valFiltre)
|
||||
$cl->SetFilter($nomFiltre, array(0=>$valFiltre));
|
||||
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
//$cl->SetArrayResult ( true );
|
||||
|
||||
$res = $cl->Query ( $findMe, $index );
|
||||
|
||||
if ($res===false) {
|
||||
debugLog('I',"Search Sphinx : Pas de réponse pour $findMe avec ".implode(',',$tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>false,
|
||||
'nbRet'=>0,
|
||||
'nbTot'=>0,
|
||||
'duration'=>$res[time]);//return false;
|
||||
|
||||
} else { // Le moteur est opérationel
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
debugLog('I',"Search Sphinx : Warning pour $findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
/* print "Query '$findMe' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats :\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " - '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";*/
|
||||
debugLog('I',"'Search Sphinx dans $index de $findMe (Filtre=".implode(',',$tabFiltres)."), Deb=$deb, nbRep=$nbRep, max=$max, any=$any",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
// debugLog('I',"Search Sphinx dans $index ". print_r($tabFiltres, true));
|
||||
|
||||
$tabRet=array();
|
||||
if ( @is_array($res['matches'])) { // il y a des données à renvoyer
|
||||
if (substr($index,0,4)=='etab') { // Recherche par étab
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne
|
||||
$listeEtab=$iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif",
|
||||
"id=$doc LIMIT 0,1", true);
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
//'NafEtabLib'=>$etab['LibNafEt'],
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
//'NafEntLib'=>$etab['LibNafEt'],
|
||||
);
|
||||
}
|
||||
} else { // Recherche par dirigeant
|
||||
$findMe4=trim(substr($findMe,0,4));
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne dirigeant
|
||||
/*$listeEtab=$iDb->select('bodacc_dirigeants d, bodacc_detail b, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, d.rs, d.nom, d.prenom, d.nomUsage, ".
|
||||
"d.dateEffet, d.fonction, d.depart, e.actif",
|
||||
"d.id=$doc AND d.id=b.id AND b.siren=e.siren AND (d.nom LIKE '%$findMe4%' OR d.prenom LIKE '%$findMe4%' OR d.nomUsage LIKE '%$findMe4%' OR d.rs LIKE '%$findMe4%') LIMIT 0,1", true);
|
||||
if (count($listeEtab)==0)
|
||||
$listeEtab=$iDb->select('bodacc_dirigeants d, bodacc_detail b, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, d.rs, d.nom, d.prenom, d.nomUsage, ".
|
||||
"d.dateEffet, d.fonction, d.depart, e.actif",
|
||||
"d.id=$doc AND d.id=b.id AND b.siren=e.siren LIMIT 0,1", true);
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
'rs'=>$etab['rs'],
|
||||
'nomD'=>$etab['nom'],
|
||||
'prenom'=>$etab['prenom'],
|
||||
'nomUsage'=>$etab['nomUsage'],
|
||||
'dateEffet'=>$etab['dateEffet'],
|
||||
'fonction'=>$etab['fonction'],
|
||||
'depart'=>$etab['depart'],
|
||||
);
|
||||
}
|
||||
*/
|
||||
//print_r($tabRet);
|
||||
//die();
|
||||
$listeEtab=$iDb->select('rncs_dirigeants d, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, /*d.rs,*/ d.nom, d.prenom, /*d.nomUsage,*/ d.naissance_date, d.naissance_lieu, ".
|
||||
"d.fonction_lib, /*d.depart,*/ e.actif",
|
||||
"d.id=$doc AND d.siren=e.siren AND e.siege=1 ORDER BY e.actif DESC LIMIT 0,1", true);
|
||||
//die(print_r($listeEtab));
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
'rs'=>'',//$etab['rs'],
|
||||
'nomD'=>$etab['nom'],
|
||||
'prenom'=>$etab['prenom'],
|
||||
'nomUsage'=>'',//$etab['nomUsage'],
|
||||
'dateEffet'=>'',//$etab['dateEffet'],
|
||||
'fonction'=>$etab['fonction_lib'],
|
||||
'depart'=>0,//$etab['depart'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I','Search Sphinx : Retourne '. $res[total].'/'. $res[total_found] .' en '.$res[time] .'secondes',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>$tabRet,
|
||||
'nbRet'=>$res[total],
|
||||
'nbTot'=>$res[total_found],
|
||||
'duration'=>$res[time],
|
||||
);
|
||||
}
|
||||
?>
|
323
framework/sphinx/recherche2.php
Normal file
@ -0,0 +1,323 @@
|
||||
<?
|
||||
|
||||
include_once(FWK_PATH.'common/strings.php');
|
||||
include_once(FWK_PATH.'sphinx/sphinxapi2.php');
|
||||
|
||||
function search2($index, $findMe, $tabFiltres=array(), $deb=0, $nbRep=20, $max=200, $any=false) {
|
||||
$deb=$deb*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$max=$max*1;
|
||||
|
||||
debugLog('I',"Search Sphinx dans $index de $findMe ($deb, $nbRep, $max) avec ".implode(',',$tabFiltres),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$iDb=new WDB();
|
||||
/*
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
|
||||
$res = $cl->Query ( $q, $index );
|
||||
*/
|
||||
|
||||
//$any = false; // si false $index='xxx'
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer (SPHINX_HOST, SPHINX_PORT);
|
||||
$cl->SetConnectTimeout ( 1 );
|
||||
$cl->SetLimits ($deb, $nbRep, $max);//0, $nbRep*10);
|
||||
//$cl->SetSortMode(SPH_SORT_ATTR_DESC, 'actif');//siege');
|
||||
if (substr($index,0,4)=='etab')
|
||||
$cl->SetSortMode(SPH_SORT_EXTENDED, 'rang DESC, actif DESC, siege DESC');//, nic DESC
|
||||
|
||||
//$cl->SetWeights ( array ( 100, 1 ) );
|
||||
//$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($tabFiltres as $nomFiltre => $valFiltre)
|
||||
$cl->SetFilter($nomFiltre, array(0=>$valFiltre));
|
||||
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
//$cl->SetArrayResult ( true );
|
||||
|
||||
$res = $cl->Query ( $findMe, $index );
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($res,true)) ;
|
||||
if ($res===false) {
|
||||
debugLog('I',"Search Sphinx : Pas de réponse pour $findMe avec ".implode(',',$tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>false,
|
||||
'nbRet'=>0,
|
||||
'nbTot'=>0,
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'duration'=>$res[time]);//return false;
|
||||
|
||||
} else { // Le moteur est opérationel
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
debugLog('I',"Search Sphinx : Warning pour $findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
/* print "Query '$findMe' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats :\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " - '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";*/
|
||||
debugLog('I',"'Search Sphinx dans $index de $findMe (Filtre=".implode(',',$tabFiltres)."), Deb=$deb, nbRep=$nbRep, max=$max, any=$any",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
// debugLog('I',"Search Sphinx dans $index ". print_r($tabFiltres, true));
|
||||
|
||||
$tabRet=array();
|
||||
if ( @is_array($res['matches'])) { // il y a des données à renvoyer
|
||||
if (substr($index,0,4)=='etab') { // Recherche par étab
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne
|
||||
$listeEtab=$iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif",
|
||||
"id=$doc LIMIT 0,1", true);
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
//'NafEtabLib'=>$etab['LibNafEt'],
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
//'NafEntLib'=>$etab['LibNafEt'],
|
||||
);
|
||||
}
|
||||
} elseif ($index=='idx_histo') {
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) {
|
||||
$listeEtab=$iDb->select('histobodacc.bodacc_ocr',
|
||||
"'Histo' as Loc, id, nomFichier, annee1, bod, texte",
|
||||
"id=$doc");
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Fichier'=>$etab['nomFichier'],
|
||||
'Annee'=>$etab['annee1'],
|
||||
'Code'=>$etab['bod'],
|
||||
'Texte'=>$etab['texte'],
|
||||
);
|
||||
}
|
||||
} else { // Recherche par dirigeant
|
||||
$findMe4=trim(substr($findMe,0,4));
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne dirigeant
|
||||
/*$listeEtab=$iDb->select('bodacc_dirigeants d, bodacc_detail b, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, d.rs, d.nom, d.prenom, d.nomUsage, ".
|
||||
"d.dateEffet, d.fonction, d.depart, e.actif",
|
||||
"d.id=$doc AND d.id=b.id AND b.siren=e.siren AND (d.nom LIKE '%$findMe4%' OR d.prenom LIKE '%$findMe4%' OR d.nomUsage LIKE '%$findMe4%' OR d.rs LIKE '%$findMe4%') LIMIT 0,1", true);
|
||||
if (count($listeEtab)==0)
|
||||
$listeEtab=$iDb->select('bodacc_dirigeants d, bodacc_detail b, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, d.rs, d.nom, d.prenom, d.nomUsage, ".
|
||||
"d.dateEffet, d.fonction, d.depart, e.actif",
|
||||
"d.id=$doc AND d.id=b.id AND b.siren=e.siren LIMIT 0,1", true);
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
'rs'=>$etab['rs'],
|
||||
'nomD'=>$etab['nom'],
|
||||
'prenom'=>$etab['prenom'],
|
||||
'nomUsage'=>$etab['nomUsage'],
|
||||
'dateEffet'=>$etab['dateEffet'],
|
||||
'fonction'=>$etab['fonction'],
|
||||
'depart'=>$etab['depart'],
|
||||
);
|
||||
}
|
||||
*/
|
||||
//print_r($tabRet);
|
||||
//die();
|
||||
$listeEtab=$iDb->select('rncs_dirigeants d, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, /*d.rs,*/ d.nom, d.prenom, /*d.nomUsage,*/ d.naissance_date, d.naissance_lieu, ".
|
||||
"d.fonction_lib, /*d.depart,*/ e.actif",
|
||||
"d.id=$doc AND d.siren=e.siren AND e.siege=1 ORDER BY e.actif DESC LIMIT 0,1", true);
|
||||
//die(print_r($listeEtab));
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
'rs'=>'',//$etab['rs'],
|
||||
'nomD'=>$etab['nom'],
|
||||
'prenom'=>$etab['prenom'],
|
||||
'nomUsage'=>'',//$etab['nomUsage'],
|
||||
'dateEffet'=>'',//$etab['dateEffet'],
|
||||
'fonction'=>$etab['fonction_lib'],
|
||||
'depart'=>0,//$etab['depart'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I','Search Sphinx : Retourne '. $res[total].'/'. $res[total_found] .' en '.$res[time] .'secondes',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>$tabRet,
|
||||
'nbRet'=>$res[total],
|
||||
'nbTot'=>$res[total_found],
|
||||
'duration'=>$res[time],
|
||||
'words'=>$res['words'],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
<nafen>7020z<
|
||||
|
||||
*/
|
||||
function comptage($findMe, $tabFiltres=array(), $deb=0, $nbRep=20, $max=1000, $any=false, $fichierCsv=false) {
|
||||
$deb=$deb*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$max=$max*1;
|
||||
$index='comptage';
|
||||
$iDb=new WDB();
|
||||
/*
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
*/
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ('192.168.3.24', 3312);
|
||||
$cl->SetConnectTimeout(1);
|
||||
$cl->SetLimits ($deb, $nbRep, $max);
|
||||
// if (substr($index,0,4)=='etab')
|
||||
// $cl->SetSortMode(SPH_SORT_EXTENDED, 'rang DESC, actif DESC, siege DESC');//, nic DESC
|
||||
//$cl->SetWeights ( array ( 100, 1 ) );
|
||||
//$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($tabFiltres as $nomFiltre => $valFiltre)
|
||||
$cl->SetFilter($nomFiltre, $valFiltre);
|
||||
/*8.4.3. SetFilterRange
|
||||
Prototype: function SetFilterRange ( $attribute, $min, $max, $exclude=false )
|
||||
Adds new integer range filter. */
|
||||
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
//$cl->SetArrayResult ( true );
|
||||
|
||||
$res = $cl->Query ( $findMe, $index );
|
||||
if ($res===false) {
|
||||
// debugLog('I',"Search Sphinx : Pas de réponse pour $findMe avec ".implode(',',$tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>false,
|
||||
'nbRet'=>0,
|
||||
'nbTot'=>0,
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'durationCpt'=>$res[time],
|
||||
'durationExp'=>0);//return false;);//return false;
|
||||
|
||||
} else { // Le moteur est opérationel
|
||||
$tdeb=microtime(1);
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
//debugLog('I',"Search Sphinx : Warning pour $findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
|
||||
$tabRet=array();
|
||||
if ( @is_array($res['matches'])) { // il y a des données à renvoyer
|
||||
$tabIdDoc=array();
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) //{ // On balaye chaque ligne
|
||||
$tabIdDoc[]=$doc;
|
||||
$strDoc='('.implode(',',$tabIdDoc).')';
|
||||
$tabTmp=$iDb->select( 'etablissements_act',
|
||||
'id,ape_etab,ape_entrep,source,siren,nic,actif,siege,adr_cp,adr_dep,adr_com,tel,fax,cj,capital,age_entrep,age_etab,tca,tcaexp,teff_entrep,teff_etab,rang,dateCrea_etab,eff_entrep,eff_etab,nbEtab,bilType,bilAnnee,bilTca,bilCA,bilCAexp,bilRN',
|
||||
"id IN $strDoc", false, MYSQL_ASSOC);
|
||||
if ($fichierCsv) {
|
||||
$fp=fopen($fichierCsv, 'w');
|
||||
foreach ($tabTmp as $iTmp=>$tmp) {
|
||||
$tabRet[]=$tmp;
|
||||
fwrite($fp, implode("\t", $tmp).EOL);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array( 'results'=>$tabRet,
|
||||
'nbRet'=>$res[total],
|
||||
'nbTot'=>$res[total_found],
|
||||
'durationCpt'=>$res[time],
|
||||
'durationExp'=>round(microtime(1)-$tdeb,3),
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'words'=>$res['words'],
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
1063
framework/sphinx/sphinxapi.php
Normal file
1187
framework/sphinx/sphinxapi2.php
Normal file
1628
framework/sphinx/sphinxapi3.php
Normal file
187
framework/sphinx/test/index.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?
|
||||
if (!isset($_REQUEST['typeRecherche']) || ( $_REQUEST['typeRecherche']<>'exacte' &&
|
||||
$_REQUEST['typeRecherche']<>'approx') )
|
||||
$_REQUEST['typeRecherche']='exacte';
|
||||
|
||||
if (!isset($_REQUEST['nbRep']) || $_REQUEST['nbRep']<25 || $_REQUEST['nbRep']>200 )
|
||||
$_REQUEST['nbRep']=25;
|
||||
if (!isset($_REQUEST['nom'])) $_REQUEST['nom']='';
|
||||
if (!isset($_REQUEST['prenom'])) $_REQUEST['prenom']='';
|
||||
if (!isset($_REQUEST['codePostal'])) $_REQUEST['codePostal']='';
|
||||
?>
|
||||
<form action="./?action=rechercher" method="POST">
|
||||
<input type="hidden" name="submitted" value="1">
|
||||
<table>
|
||||
<tr><td><i>Informations sur la personne</i></td><td> </td></tr>
|
||||
<tr><td><b>NOM *</b></td><td><input type="text" name="nom" value="<?=$_REQUEST['nom']?>"></td></tr>
|
||||
<tr><td>Prénom *</td><td><input type="text" name="prenom" value="<?=$_REQUEST['prenom']?>"></td></tr>
|
||||
<tr><td>Département ou Code Postal de résidence *</td><td><input type="text" name="codePostal" value="<?=$_REQUEST['codePostal']?>"></td></tr>
|
||||
<tr><td>Civilité</td><td><input type="radio" name="civilite" value="Mlle"> Mlle
|
||||
<input type="radio" name="civilite" value="Mme"> Mme
|
||||
<input type="radio" name="civilite" value="M"> M</td></tr>
|
||||
<tr><td>Date de Naissance *</td><td><input type="text" name="naissJJ" size="3" maxlength="2"> / <input type="text" name="naissMM" size="3" maxlength="2"> / <input type="text" name="naissAA" size="5" maxlength="4"></td></tr>
|
||||
<tr><td>Ville de Naissance</td><td><input type="text" name="naissVille"></td></tr>
|
||||
<tr><td>Département de Naissance</td><td><input type="text" name="naissDept"></td></tr>
|
||||
<tr><td>Pays de Naissance</td><td><input type="text" name="naissPays"></td></tr>
|
||||
<tr><td>Adresse de résidence *</td><td><input type="text" name="adresse"></td></tr>
|
||||
<tr><td>Ville de résidence *</td><td><input type="text" name="adresseVille"></td></tr>
|
||||
<tr><td>Montant du crédit demandé *</td><td><input type="text" name="creditDemande"></td></tr>
|
||||
<tr><td>SIREN si entrepreneur individuel</td><td><input type="text" name="siren"></td></tr>
|
||||
<tr><td>RIB</td><td><input type="text" name="siren"></td></tr>
|
||||
<tr><td>Téléphone Domicile</td><td><input type="text" name="telephoneMaison"> <i>Liste rouge <input type="radio" name="listeRouge" value="Oui"> Oui <input type="radio" name="listeRouge" value="Non"> Non</td></tr>
|
||||
<tr><td>Téléphone Professionel</td><td><input type="text" name="telephonePro"></td></tr>
|
||||
<tr><td>Téléphone Portable</td><td><input type="text" name="telephonePort"></td></tr>
|
||||
<tr><td><i>Informations complémentaires</i></td><td> </td></tr>
|
||||
<tr><td>Nom de l'employeur</td><td><input type="text" name="employeurNom"></td></tr>
|
||||
<tr><td>Adresse de l'employeur</td><td><input type="text" name="employeurAdresse"></td></tr>
|
||||
<tr><td>Code Postal de l'employeur</td><td><input type="text" name="employeurCP"></td></tr>
|
||||
<tr><td>Ville de l'employeur</td><td><input type="text" name="employeurVille"></td></tr>
|
||||
<tr><td> </td><td> </td></tr>
|
||||
<tr><td>Type de recherche</td><td><input type="radio" <?if ($_REQUEST['typeRecherche']=='exacte') echo 'CHECKED';?> name="typeRecherche" value="exacte">Exacte <input type="radio" <?if ($_REQUEST['typeRecherche']=='approx') echo 'CHECKED';?> name="typeRecherche" value="approx">Approchante</td></tr>
|
||||
<tr><td>Nombre de résultats</td><td><select name="nbRep"><option value="25">25</option><option value="50">50</option><option value="100">100</option><option value="200">200</option></select></td></tr>
|
||||
</table>
|
||||
<input type="submit" value="Valider"> <input type="reset" value="RAZ">
|
||||
</form>
|
||||
<?php
|
||||
include_once('/var/www/includes/mysql.php');
|
||||
$con = mysql_pconnect('localhost', 'root', 'bzh4231*');
|
||||
if (!($con === false)) {
|
||||
if (mysql_select_db('npaipp', $con) === false)
|
||||
die('Could not select database: ' . mysql_error());
|
||||
}
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//die ( "usage: php -f test.php [--any] <word [word [word [...]]]> [--group <group>] [-p <port>] [-i <index>]\n" );
|
||||
|
||||
$q = $_REQUEST['nom'].' '.$_REQUEST['prenom'];
|
||||
$any = false; // si false $index='xxx'
|
||||
$port = 3312;
|
||||
if ($_REQUEST['typeRecherche']=='exacte')
|
||||
$index="annuaire_pp";
|
||||
else
|
||||
$index="annuaire_pp_shx";
|
||||
$nbRep=$_REQUEST['nbRep'];
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( "localhost", $port );
|
||||
$cl->SetLimits (0, $nbRep);
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
if ( isset($_REQUEST['codePostal']) && $_REQUEST['codePostal']<>'' ) {
|
||||
$tailleCP=strlen($_REQUEST['codePostal']);
|
||||
if ($tailleCP>1 && $tailleCP<4) $cl->SetFilter("departement", array(0=>$_REQUEST['codePostal']));
|
||||
elseif ($tailleCP==5) $cl->SetFilter("codepostal", array(0=>$_REQUEST['codePostal']));
|
||||
}
|
||||
if ( isset($_REQUEST['telephoneMaison']) && $_REQUEST['telephoneMaison']<>'' ) {
|
||||
$cl->SetFilter("tel", array(0=>$_REQUEST['telephoneMaison']));
|
||||
}
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.<br/>";
|
||||
print "<h3>Query stats</h3><ul>";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print "<li>'$word' found $info[hits] times in $info[docs] documents</li>";
|
||||
print "</ul>";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "<h3>Reponses :</h3><ul>";
|
||||
foreach ( $res["matches"] as $doc => $docinfo )
|
||||
{
|
||||
// print "<li>$n. doc_id=$doc, weight=$docinfo[weight]<br/>";
|
||||
// foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
// {
|
||||
$info=mysql_select('particuliers', 'Nom, Adresse, CodePostal, Ville, Tel, Fax', "id=$doc");
|
||||
$personne=$info[0];
|
||||
echo '<li><i>'. $n .'.</i> '. $personne['Nom'] .' ('. $docinfo[weight] .' %)<br/>';
|
||||
echo $personne['Adresse'] .'<br/>';
|
||||
echo $personne['CodePostal'] .' '. $personne['Ville'] .'<br/>';
|
||||
if ($personne['Tel']<>'') echo 'Tél : '.$personne['Tel'].'<br/>';
|
||||
if ($personne['Fax']<>'') echo 'Fax : '.$personne['Fax'].'<br/>';
|
||||
echo "</li>\n";
|
||||
$n++;
|
||||
|
||||
/* $value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "</li>";*/
|
||||
//$n++;
|
||||
}
|
||||
print "</ul>";
|
||||
}
|
||||
echo '<!--';
|
||||
print_r($res);
|
||||
echo '-->';
|
||||
|
||||
if ($_POST['submitted']) {
|
||||
print_r($_POST);
|
||||
|
||||
/* Actions à effectuer :
|
||||
|
||||
// 1. Vérification de l'existance du NOM, Prénom et Adresse dans Annuaire (/30 points)
|
||||
1.1. Si NOM+Prénom à l'adresse ==> OK 30 points
|
||||
1.2. Si NOM sans prénom à l'adresse ==> OK 25 points
|
||||
1.3. Si quelqu'un dans annuaire à l'adresse 10 points
|
||||
1.4. Si pas d'adresse 0 point
|
||||
|
||||
// Si 1.2 ==> 2
|
||||
// Si 1.3 ==> 2 + 3
|
||||
// Si 1.4 ==> 2 + 3 + 4
|
||||
|
||||
// 2. Vérifier si le prénom existe dans la table des prénoms (/ 3 points)
|
||||
2.1. Si le prénom existe OK 2 points
|
||||
2.2. Sinon valeur approchante 1 point
|
||||
2.3. Sinon ?????????? 0 point
|
||||
|
||||
// 3. Vérifier si le nom existe dans la table des noms (/ 3 points)
|
||||
1.1. Si le nom existe OK 2 points
|
||||
1.2. Sinon valeur approchante 1 point
|
||||
1.3. Sinon 0 point
|
||||
|
||||
// 4. Recherche de l'existance de l'adresse / ville (/ 5 points)
|
||||
2.1. Si adresse complète existe 5 points
|
||||
2.2. Si adresse sans n° 3 points
|
||||
2.3. Si approchant 2 points
|
||||
2.4. Si ville sans l'adresse 0 point
|
||||
|
||||
//10. Vérifier si le prénom est logique avec les l'age moyen des personnes portant ce prénom (/ 3 points)
|
||||
2.4.1. Si logique OK 2 points
|
||||
2.4.2. Si approchant 1 point
|
||||
2.4.3. Sinon 0 point
|
||||
|
||||
|
||||
3.3.1 Vérification dans le pages blanches
|
||||
|
||||
// 3. Si un téléphone est communiqué et qu'absence de liste rouge : (30 points)
|
||||
3.1. Vérifier la concordance NOM, Prénom, Adresse, Téléphonesi OK 30 point
|
||||
|
||||
Enregistrer chaque requête
|
||||
et les informations communqiuées par le client
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
157
framework/sphinx/test/test.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test.php 1103 2008-01-24 18:42:57Z shodan $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//////////////////////
|
||||
// parse command line
|
||||
//////////////////////
|
||||
|
||||
// for very old PHP versions, like at my home test server
|
||||
if ( is_array($argv) && !isset($_SERVER["argv"]) )
|
||||
$_SERVER["argv"] = $argv;
|
||||
unset ( $_SERVER["argv"][0] );
|
||||
|
||||
// build query
|
||||
if ( !is_array($_SERVER["argv"]) || empty($_SERVER["argv"]) )
|
||||
{
|
||||
print ( "Usage: php -f test.php [OPTIONS] query words\n\n" );
|
||||
print ( "Options are:\n" );
|
||||
print ( "-h, --host <HOST>\tconnect to searchd at host HOST\n" );
|
||||
print ( "-p, --port\t\tconnect to searchd at port PORT\n" );
|
||||
print ( "-i, --index <IDX>\tsearch through index(es) specified by IDX\n" );
|
||||
print ( "-s, --sortby <CLAUSE>\tsort matches by 'CLAUSE' in sort_extended mode\n" );
|
||||
print ( "-S, --sortexpr <EXPR>\tsort matches by 'EXPR' DESC in sort_expr mode\n" );
|
||||
print ( "-a, --any\t\tuse 'match any word' matching mode\n" );
|
||||
print ( "-b, --boolean\t\tuse 'boolean query' matching mode\n" );
|
||||
print ( "-e, --extended\t\tuse 'extended query' matching mode\n" );
|
||||
print ( "-ph,--phrase\t\tuse 'exact phrase' matching mode\n" );
|
||||
print ( "-f, --filter <ATTR>\tfilter by attribute 'ATTR' (default is 'group_id')\n" );
|
||||
print ( "-v, --value <VAL>\tadd VAL to allowed 'group_id' values list\n" );
|
||||
print ( "-g, --groupby <EXPR>\tgroup matches by 'EXPR'\n" );
|
||||
print ( "-gs,--groupsort <EXPR>\tsort groups by 'EXPR'\n" );
|
||||
print ( "-d, --distinct <ATTR>\tcount distinct values of 'ATTR''\n" );
|
||||
print ( "-l, --limit <COUNT>\tretrieve COUNT matches (default: 20)\n" );
|
||||
exit;
|
||||
}
|
||||
|
||||
$args = array();
|
||||
foreach ( $_SERVER["argv"] as $arg )
|
||||
$args[] = $arg;
|
||||
|
||||
$q = "";
|
||||
$mode = SPH_MATCH_ALL;
|
||||
$host = "localhost";
|
||||
$port = 3312;
|
||||
$index = "*";
|
||||
$groupby = "";
|
||||
$groupsort = "@group desc";
|
||||
$filter = "group_id";
|
||||
$filtervals = array();
|
||||
$distinct = "";
|
||||
$sortby = "";
|
||||
$limit = 20;
|
||||
$ranker = SPH_RANK_PROXIMITY_BM25;
|
||||
for ( $i=0; $i<count($args); $i++ )
|
||||
{
|
||||
$arg = $args[$i];
|
||||
|
||||
if ( $arg=="-h" || $arg=="--host" ) $host = $args[++$i];
|
||||
else if ( $arg=="-p" || $arg=="--port" ) $port = (int)$args[++$i];
|
||||
else if ( $arg=="-i" || $arg=="--index" ) $index = $args[++$i];
|
||||
else if ( $arg=="-s" || $arg=="--sortby" ) { $sortby = $args[++$i]; $sortexpr = ""; }
|
||||
else if ( $arg=="-S" || $arg=="--sortexpr" ) { $sortexpr = $args[++$i]; $sortby = ""; }
|
||||
else if ( $arg=="-a" || $arg=="--any" ) $mode = SPH_MATCH_ANY;
|
||||
else if ( $arg=="-b" || $arg=="--boolean" ) $mode = SPH_MATCH_BOOLEAN;
|
||||
else if ( $arg=="-e" || $arg=="--extended" ) $mode = SPH_MATCH_EXTENDED;
|
||||
else if ( $arg=="-e2" ) $mode = SPH_MATCH_EXTENDED2;
|
||||
else if ( $arg=="-ph"|| $arg=="--phrase" ) $mode = SPH_MATCH_PHRASE;
|
||||
else if ( $arg=="-f" || $arg=="--filter" ) $filter = $args[++$i];
|
||||
else if ( $arg=="-v" || $arg=="--value" ) $filtervals[] = $args[++$i];
|
||||
else if ( $arg=="-g" || $arg=="--groupby" ) $groupby = $args[++$i];
|
||||
else if ( $arg=="-gs"|| $arg=="--groupsort" ) $groupsort = $args[++$i];
|
||||
else if ( $arg=="-d" || $arg=="--distinct" ) $distinct = $args[++$i];
|
||||
else if ( $arg=="-l" || $arg=="--limit" ) $limit = (int)$args[++$i];
|
||||
else if ( $arg=="-r" )
|
||||
{
|
||||
$arg = strtolower($args[++$i]);
|
||||
if ( $arg=="bm25" ) $ranker = SPH_RANK_BM25;
|
||||
if ( $arg=="none" ) $ranker = SPH_RANK_NONE;
|
||||
if ( $arg=="wordcount" )$ranker = SPH_RANK_WORDCOUNT;
|
||||
}
|
||||
else
|
||||
$q .= $args[$i] . " ";
|
||||
}
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
$cl->SetRankingMode ( $ranker );
|
||||
$cl->SetArrayResult ( true );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats:\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "Matches:\n";
|
||||
foreach ( $res["matches"] as $docinfo )
|
||||
{
|
||||
print "$n. doc_id=$docinfo[id], weight=$docinfo[weight]";
|
||||
foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
{
|
||||
$value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype & SPH_ATTR_MULTI )
|
||||
{
|
||||
$value = "(" . join ( ",", $value ) .")";
|
||||
} else
|
||||
{
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
}
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "\n";
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test.php 1103 2008-01-24 18:42:57Z shodan $
|
||||
//
|
||||
|
||||
?>
|
53
framework/sphinx/test/test2.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test2.php 910 2007-11-16 11:43:46Z shodan $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
$docs = array
|
||||
(
|
||||
"this is my test text to be highlighted, and for the sake of the testing we need to pump its length somewhat",
|
||||
"another test text to be highlighted, below limit",
|
||||
"test number three, without phrase match",
|
||||
"final test, not only without phrase match, but also above limit and with swapped phrase text test as well",
|
||||
);
|
||||
$words = "test text";
|
||||
$index = "test1";
|
||||
$opts = array
|
||||
(
|
||||
"before_match" => "<b>",
|
||||
"after_match" => "</b>",
|
||||
"chunk_separator" => " ... ",
|
||||
"limit" => 60,
|
||||
"around" => 3,
|
||||
);
|
||||
|
||||
foreach ( array(0,1) as $exact )
|
||||
{
|
||||
$opts["exact_phrase"] = $exact;
|
||||
print "exact_phrase=$exact\n";
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
|
||||
if ( !$res )
|
||||
{
|
||||
die ( "ERROR: " . $cl->GetLastError() . ".\n" );
|
||||
} else
|
||||
{
|
||||
$n = 0;
|
||||
foreach ( $res as $entry )
|
||||
{
|
||||
$n++;
|
||||
print "n=$n, res=$entry\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test2.php 910 2007-11-16 11:43:46Z shodan $
|
||||
//
|
||||
|
||||
?>
|
44
framework/sphinx/test/test2_old.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test2.php,v 1.4 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
$docs = array
|
||||
(
|
||||
"this is my test text to be highlighted",
|
||||
"this is another test text to be highlighted",
|
||||
);
|
||||
$words = "test text";
|
||||
$index = "test1";
|
||||
$opts = array
|
||||
(
|
||||
"before_match" => "<b>",
|
||||
"after_match" => "</b>",
|
||||
"chunk_separator" => " ... ",
|
||||
"limit" => 400,
|
||||
"around" => 15
|
||||
);
|
||||
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
|
||||
if ( !$res )
|
||||
{
|
||||
die ( "ERROR: " . $cl->GetLastError() . ".\n" );
|
||||
} else
|
||||
{
|
||||
foreach ( $res as $entry )
|
||||
{
|
||||
$n++;
|
||||
print "n=$n, res=$entry\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test2.php,v 1.4 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
?>
|
108
framework/sphinx/test/test_old.php
Normal file
@ -0,0 +1,108 @@
|
||||
#!/usr/bin/php -q
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test.php,v 1.12 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//////////////////////
|
||||
// parse command line
|
||||
//////////////////////
|
||||
|
||||
// for very old PHP versions, like at my home test server
|
||||
if ( is_array($argv) && !isset($_SERVER["argv"]) )
|
||||
$_SERVER["argv"] = $argv;
|
||||
unset ( $_SERVER["argv"][0] );
|
||||
|
||||
// build query
|
||||
if ( !is_array($_SERVER["argv"]) || empty($_SERVER["argv"]) )
|
||||
die ( "usage: php -f test.php [--any] <word [word [word [...]]]> [--group <group>] [-p <port>] [-i <index>]\n" );
|
||||
|
||||
$args = array();
|
||||
foreach ( $_SERVER["argv"] as $arg )
|
||||
$args[] = $arg;
|
||||
|
||||
$q = "";
|
||||
$any = false;
|
||||
$groups = array();
|
||||
$port = 3312;
|
||||
$index = "*";
|
||||
for ( $i=0; $i<count($args); $i++ )
|
||||
{
|
||||
if ( $args[$i]=="--any" )
|
||||
{
|
||||
$any = true;
|
||||
} else if ( $args[$i]=="--group" )
|
||||
{
|
||||
$groups[] = (int)$args[++$i];
|
||||
} else if ( $args[$i]=="-p" )
|
||||
{
|
||||
$port = (int)$args[++$i];
|
||||
} else if ( $args[$i]=="-i" )
|
||||
{
|
||||
$index = $args[++$i];
|
||||
} else
|
||||
{
|
||||
$q .= $args[$i] . " ";
|
||||
}
|
||||
}
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( "localhost", $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
if ( count($groups) )
|
||||
$cl->SetFilter ( "group_id", $groups );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats:\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "Matches:\n";
|
||||
foreach ( $res["matches"] as $doc => $docinfo )
|
||||
{
|
||||
print "$n. doc_id=$doc, weight=$docinfo[weight]";
|
||||
foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
{
|
||||
$value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "\n";
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test.php,v 1.12 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
?>
|
166
html/boamp/concurrents.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
$t1=microtime_float();
|
||||
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iDb2=new WDB('sdv1');
|
||||
|
||||
session_start();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb2->select( 'utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
} else {
|
||||
|
||||
$tabLignes=$iDb->select(
|
||||
'boamp_lots',
|
||||
'id, idAnn, idLot, Boamp_Code, Boamp_Rubrique, Boamp_Date_Parution, siren, sirenValide, nic, nicValide, idSirenage, typeInfoLot, num, titre, `desc` as description, nom, adresse, cp, ville, pays, poste, tel, fax, email, web, montantTxt, montant, montantAnMin, montantAnMax, trancheCond, trancheFerme, dateAttrib, intitule, nomenclature, objets, cpv, cpvComp, volume, execution, livraison, coutEstime, coutEstimeMin, coutEstimeMax, dureeJours, dureeMois, dateDeb, dateFin, offreMoins, offrePlus, dateAttribLot, nbOffres, nbOffresLot, nbPart, nbPartEtr, primeEnv, primeAtt, primeAttrib, autreRens, autreInfo, sousTrait, sousTraitVal, eq, infructueux, sansSuite, infos, type, autre, idTxtUnique, dateInsert, dateUpdate',
|
||||
"(nom LIKE '%COFACE%' OR nom LIKE '%COMP%FRAN%ASSUR%CR%'
|
||||
OR nom LIKE '%ALTARES%'
|
||||
OR nom LIKE '%INFO%LEGAL%' OR nom LIKE '%INFOLEGAL%'
|
||||
OR nom LIKE '%TINUBU%'
|
||||
OR nom LIKE '%TELINO%'
|
||||
OR nom LIKE '%Explore%'
|
||||
OR nom LIKE '%EXTELIA%'
|
||||
OR nom LIKE '%G2Plus%'
|
||||
OR nom LIKE '%Gibmedia%'
|
||||
OR nom LIKE '%KAIROS%' OR nom LIKE '%histoire%adresse%'
|
||||
OR nom LIKE '%BVDEP%' OR nom LIKE '%VAN%DIJK%'
|
||||
OR nom LIKE '%SCORE%DECISION%'
|
||||
OR nom LIKE '%KOMPASS%'
|
||||
OR nom LIKE '%SOLVABILITE%' OR nom LIKE '%CREDITSAFE%' OR nom LIKE '%CREDIT%SAFE%'
|
||||
OR nom LIKE '%CEGEDIM%'
|
||||
OR nom LIKE '%INFOGREFFE%'
|
||||
OR nom LIKE '%EDD%' OR nom LIKE '%EUROP%DONNE%'
|
||||
OR nom LIKE '%QUESTEL%'
|
||||
OR nom LIKE '%TESSI%'
|
||||
OR nom LIKE '%JURISMEDIA%'
|
||||
OR nom LIKE '%POUEY%'
|
||||
OR nom LIKE '%INTERSUD%'
|
||||
OR nom LIKE '%ECHOS%'
|
||||
OR nom LIKE '%CARTEGIE%'
|
||||
OR (nom LIKE '%MARKETING%' AND nom NOT LIKE '%TOTAL%')
|
||||
OR nom LIKE '%MAXISOFT%'
|
||||
OR nom LIKE '%ACXIOM%'
|
||||
OR nom LIKE '%ALLIANZ%INFO%'
|
||||
OR nom LIKE '%Analyse%informatique%donn%'
|
||||
OR nom LIKE '%ASTEROP%'
|
||||
OR nom LIKE '%Banque%France%'
|
||||
OR nom LIKE '%Chambre%commerce%industrie%'
|
||||
OR nom LIKE '%Compagnie%generale%affactur%'
|
||||
OR nom LIKE '%COMPU%MARK%' OR nom LIKE '%COMPUMARK%'
|
||||
OR nom LIKE '%Euler%%Hermes%' OR nom LIKE '%SFAC%'
|
||||
OR nom LIKE '%EUROFACTOR%'
|
||||
OR nom LIKE '%GE%Capital%'
|
||||
OR nom LIKE '%carte%banc%'
|
||||
OR nom LIKE '%J%P%GUISSET%' OR nom LIKE '%JPG%'
|
||||
OR nom LIKE '%HBS%RESEARCH%'
|
||||
OR nom LIKE '%JM%Bruneau%'
|
||||
OR nom LIKE '%MEDIAPOST%'
|
||||
OR nom LIKE '%OPTIMA%'
|
||||
OR nom LIKE '%PAGE%JAUNE%'
|
||||
OR nom LIKE '%PROGICA%'
|
||||
OR nom LIKE '%SAFIG%'
|
||||
OR nom LIKE '%SOCIETE.COM%'
|
||||
OR nom LIKE '%SOGEC%' OR nom LIKE '%DATAMARK%'
|
||||
OR nom LIKE '%SOGESMA%'
|
||||
OR nom LIKE '%118000%'
|
||||
OR nom LIKE '%pH%Group%' ) AND siren NOT IN(775665359,348310061,471202341,380062604,189742117,731880258) ORDER BY Boamp_Date_Parution DESC LIMIT 0,50", false, MYSQL_ASSOC);
|
||||
?>
|
||||
<h3 align="center">Marché Attribués à des concurrents ?</h3>
|
||||
<table BgColor="#177AE9" cellspacing="1" cellpadding="2" border="0" align="center" BorderColor="#000020">
|
||||
<tr>
|
||||
<td><b><font color="Black">Edition</font></b></td>
|
||||
<td><b><font color="Black">Siren</font></b></td>
|
||||
<td><b><font color="Black">Raison Sociale</font></b></td>
|
||||
<td><b><font color="Black">Adresse</font></b></td>
|
||||
<td><b><font color="Black">Montant</font></b></td>
|
||||
<td><b><font color="Black">Marché/Lot</font></b></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($tabLignes as $ligne) {
|
||||
$tabBoamp=$iDb->select( 'boamp_detail d, boamp_lots l',
|
||||
'd.Boamp_Code, d.Boamp_Annee_Parution, d.Boamp_Num, d.Num_AnnoncePre, d.Num_Annonce',
|
||||
'l.id='.$ligne['id'].' AND l.idAnn=d.id', false, MYSQL_ASSOC);
|
||||
$tabBoamp=$tabBoamp[0];
|
||||
if ($tabBoamp['Boamp_Code']=='MAPA')
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution=MAPA&num_annonce='.$tabBoamp['Num_AnnoncePre'].'-'.$tabBoamp['Num_Annonce'].'&total=500&_s=0&indice=0&affichage_avis=officiel';
|
||||
else {
|
||||
$lettre = substr($tabBoamp['Boamp_Code'],-1);
|
||||
$annee = $tabBoamp['Boamp_Annee_Parution'];
|
||||
$num = sprintf("%04d",$tabBoamp['Boamp_Num']);
|
||||
$numPar=$lettre.$annee.$num;
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution='.$numPar.'&num_annonce='.$tabBoamp['Num_Annonce'].'&total=500&_s=0&indice=0';
|
||||
}
|
||||
?>
|
||||
<tr BgColor="#E2EEFC">
|
||||
<td><font color="Black"><a href="<?=$lienMapa?>" target="_blank"><?=$ligne['Boamp_Code'].'<br/>'.WDate::dateT('Y-m-d','d/m/Y',$ligne['Boamp_Date_Parution'])?></a></font></td>
|
||||
<td><font color="Black"><?=$ligne['siren']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['nom']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['adresse'].'<br/>'.$ligne['cp'].' '.$ligne['ville']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['montantTxt']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['titre'].'<br/>'.$ligne['num'].'<br/>'.$ligne['description'].'<br/>'.$ligne['autreRens'].'<br/>'.$ligne['autreInfo'].'<br/>'.$ligne['infos'].'<br/>'.$ligne['autre']?></font></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
die();
|
||||
// pays, poste, tel, fax, email, web, , montant
|
||||
|
||||
?>
|
||||
|
||||
<? if ($_SESSION['userId']<>282 && $_SESSION['userId']<>127 && $_SESSION['userId']<>1 && $_SESSION['userId']<>2) echo '<td><b><font color="Black">Login</font></b></td>'; ?><td><b><font color="Black">Total saisie</font></b></td></tr>
|
||||
<?
|
||||
foreach ($tabCol as $tabJour) {
|
||||
echo '<tr BgColor="#E2EEFC"><td>'.$tabJour['Jour'].'</td><td>'.$tabSource[$tabJour['source']].'</td>';
|
||||
if ($vueDetail)
|
||||
echo '<td>'.@$tabLogin[$tabJour['idSaisie']].' <i>('.@$tabJour['idSaisie'].')</i></td>';
|
||||
echo '<td>'.$tabJour['Nb'].'</td></tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?
|
||||
}
|
||||
?>
|
160
html/boamp/marchesInfo.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
$t1=microtime_float();
|
||||
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iDb2=new WDB('sdv1');
|
||||
|
||||
session_start();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb2->select( 'utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
} else {
|
||||
$strFiltres=" AND ( d.objet LIKE '%diffusion%'
|
||||
OR d.objet LIKE '%veille%'
|
||||
OR d.objet LIKE '%surveillance%'
|
||||
OR d.objet LIKE '%suivi%base%'
|
||||
OR d.objet LIKE '%suivi%fichier%'
|
||||
OR d.objet LIKE '%suivi%information%'
|
||||
OR d.objet LIKE '%suivi%client%'
|
||||
OR d.objet LIKE '%suivi%prospect%'
|
||||
OR d.objet LIKE '%suivi%fournisse%'
|
||||
OR d.objet LIKE '%suivi%tiers%'
|
||||
OR d.objet LIKE '%suivi%interlocuteur%'
|
||||
OR d.objet LIKE '%score%'
|
||||
OR d.objet LIKE '%scoring%'
|
||||
OR d.objet LIKE '%cotation%'
|
||||
OR d.objet LIKE '%valuation%'
|
||||
OR d.objet LIKE '%solvabil%'
|
||||
OR d.objet LIKE '%information%commercial%'
|
||||
OR d.objet LIKE '%renseignement%commercial%'
|
||||
OR d.objet LIKE '%information%legale%'
|
||||
OR d.objet LIKE '%information%juridique%'
|
||||
OR d.objet LIKE '%renseignement%juridique%'
|
||||
OR d.objet LIKE '%information%economique%'
|
||||
OR d.objet LIKE '%renseignement%economique%'
|
||||
OR d.objet LIKE '%surveillance%'
|
||||
OR d.objet LIKE '%base%adresse%'
|
||||
OR d.objet LIKE '%base%donnée%'
|
||||
OR d.objet LIKE '%fichier%'
|
||||
OR d.objet LIKE '%marketing%'
|
||||
OR d.objet LIKE '%enrichissement%'
|
||||
OR d.objet LIKE '%enrichir%'
|
||||
OR d.objet LIKE '%consultation%'
|
||||
OR d.objet LIKE '%extranet%'
|
||||
OR d.objet LIKE '%internet%'
|
||||
OR d.objet LIKE '%juridique%'
|
||||
OR d.objet LIKE '%gestion%'
|
||||
OR d.objet LIKE '%WALDEC%'
|
||||
OR d.objet LIKE '%SIREN%'
|
||||
OR d.objet LIKE '%SIRET%'
|
||||
OR d.objet LIKE '%Zones%Prioritaires%'
|
||||
OR d.objet LIKE '%Zones%Franches%'
|
||||
OR d.objet LIKE '%Intracommunautaire%'
|
||||
)";//objet LIKE '%%' R d.objet LIKE '%%' OR d.objet LIKE '%financier%' OR d.objet LIKE '%entreprise%' OR d.objet LIKE '%abonnement%' OR d.objet LIKE '%service en ligne%' OR d.objet LIKE '%fourniture%' OR d.objet LIKE '%mise a jour%' OR d.objet LIKE '%identification%')";
|
||||
|
||||
|
||||
|
||||
//$strFiltres=" AND ( d.objet LIKE '%diffusion%' OR d.objet LIKE '%veille%' OR d.objet LIKE '%suivi%' OR d.objet LIKE '%surveillance%' OR d.objet LIKE '%base adresse%' OR d.objet LIKE '%base de donnée%' OR d.objet LIKE '%fichier%' OR d.objet LIKE '%cotation%' OR d.objet LIKE '%solvabil%' OR d.objet LIKE '%score%' OR d.objet LIKE '%scoring%' OR d.objet LIKE '%client%' OR d.objet LIKE '%fournisseur%' OR d.objet LIKE '%tiers%' OR d.objet LIKE '%interlocuteur%' OR d.objet LIKE '%consultation%' OR d.objet LIKE '%extranet%' OR d.objet LIKE '%internet%' OR d.objet LIKE '%gestion%' OR d.objet LIKE '%juridique%' OR d.objet LIKE '%legale%' OR d.objet LIKE '%economique%' OR d.objet LIKE '%financier%' OR d.objet LIKE '%entreprise%' OR d.objet LIKE '%abonnement%' OR d.objet LIKE '%service en ligne%' OR d.objet LIKE '%fourniture%' OR d.objet LIKE '%mise a jour%' OR d.objet LIKE '%identification%')";
|
||||
|
||||
//$strFiltres=" AND ( d.objet LIKE '%diffusion%' OR d.objet LIKE '%veille%' OR d.objet LIKE '%suivi%' OR d.objet LIKE '%surveillance%' OR d.objet LIKE '%base adresse%' OR d.objet LIKE '%base de donnée%' OR d.objet LIKE '%fichier%' OR d.objet LIKE '%cotation%' OR d.objet LIKE '%solvabil%' OR d.objet LIKE '%score%' OR d.objet LIKE '%scoring%' OR d.objet LIKE '%consultation%' OR d.objet LIKE '%extranet%' OR d.objet LIKE '%internet%' OR d.objet LIKE '%juridique%' OR d.objet LIKE '%legale%' OR d.objet LIKE '%economique%' OR d.objet LIKE '%financier%' OR d.objet LIKE '%entreprise%' OR d.objet LIKE '%abonnement%' OR d.objet LIKE '%service en ligne%' OR d.objet LIKE '%fourniture%' OR d.objet LIKE '%mise a jour%' OR d.objet LIKE '%identification%')";
|
||||
|
||||
$tabLignes=$iDb->select(
|
||||
'boamp_detail_liens c, boamp_detail d',
|
||||
'd.id, d.objet, d.Boamp_Code, d.Boamp_Annee_Parution, d.Boamp_Num, d.Num_AnnoncePre, d.Num_Annonce, d.Boamp_Date_Parution, d.Boamp_Dept_Lib, d.Boamp_Rubrique_Lib, d.typeAdju, d.typeOrganisme, d.typeActivite, d.raisonSociale, d.titreAcheteur, d.destinataire, d.adresse, d.cp, d.ville, d.pays, d.dateInsert, d.dateUpdate',
|
||||
"d.Boamp_Code IN ('BOMP B','MAPA') AND d.Boamp_Rubrique_Lib LIKE '%concurrence%' AND d.Boamp_Annee_Parution>2009 AND d.id=c.id /*AND c.lienTable='boamp_classes' AND c.lienId IN(65,66,67,72,73,74,75,99,107)*/ AND c.lienTable='boamp_desc' AND c.lienId IN(1,21,24,79,111,122,140,154,187,225,234,271,307,315,319) $strFiltres GROUP BY d.id ORDER BY id DESC LIMIT 0,200", false, MYSQL_ASSOC);
|
||||
?>
|
||||
<h3 align="center">Marché Attribués à des concurrents ?</h3>
|
||||
<table BgColor="#177AE9" cellspacing="1" cellpadding="2" border="0" align="center" BorderColor="#000020">
|
||||
<tr>
|
||||
<td><b><font color="Black">Edition</font></b></td>
|
||||
<td><b><font color="Black">Organisme</font></b></td>
|
||||
<td><b><font color="Black">Département</font></b></td>
|
||||
<td><b><font color="Black">Raison Sociale</font></b></td>
|
||||
<td><b><font color="Black">Adresse</font></b></td>
|
||||
<td><b><font color="Black">Objet du marché</font></b></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($tabLignes as $ligne) {
|
||||
if ($ligne['Boamp_Code']=='MAPA')
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution=MAPA&num_annonce='.$ligne['Num_AnnoncePre'].'-'.$ligne['Num_Annonce'].'&total=500&_s=0&indice=0&affichage_avis=officiel';
|
||||
else {
|
||||
$lettre = substr($ligne['Boamp_Code'],-1);
|
||||
$annee = $ligne['Boamp_Annee_Parution'];
|
||||
$num = sprintf("%04d",$ligne['Boamp_Num']);
|
||||
$numPar=$lettre.$annee.$num;
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution='.$numPar.'&num_annonce='.$ligne['Num_Annonce'].'&total=500&_s=0&indice=0';
|
||||
}
|
||||
?>
|
||||
<tr BgColor="#E2EEFC">
|
||||
<td><font color="Black"><a href="<?=$lienMapa?>" target="_blank"><?=$ligne['Boamp_Code'].'<br/>'.WDate::dateT('Y-m-d','d/m/Y',$ligne['Boamp_Date_Parution'])?></a></font></td>
|
||||
<td><font color="Black"><?=$ligne['typeAdju'].'<br/>'.$ligne['typeOrganisme']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['Boamp_Dept_Lib']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['raisonSociale']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['destinataire'].'<br/>'.$ligne['adresse'].'<br/>'.$ligne['cp'].' '.$ligne['ville']?></font></td>
|
||||
<td><font color="Black"><?=$ligne['objet']?></font></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
die();
|
||||
// pays, poste, tel, fax, email, web, , montant
|
||||
|
||||
?>
|
||||
|
||||
<? if ($_SESSION['userId']<>282 && $_SESSION['userId']<>127 && $_SESSION['userId']<>1 && $_SESSION['userId']<>2) echo '<td><b><font color="Black">Login</font></b></td>'; ?><td><b><font color="Black">Total saisie</font></b></td></tr>
|
||||
<?
|
||||
foreach ($tabCol as $tabJour) {
|
||||
echo '<tr BgColor="#E2EEFC"><td>'.$tabJour['Jour'].'</td><td>'.$tabSource[$tabJour['source']].'</td>';
|
||||
if ($vueDetail)
|
||||
echo '<td>'.@$tabLogin[$tabJour['idSaisie']].' <i>('.@$tabJour['idSaisie'].')</i></td>';
|
||||
echo '<td>'.$tabJour['Nb'].'</td></tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?
|
||||
}
|
||||
?>
|
0
html/clients/index.php
Normal file
690
html/comptages/extraction.php
Normal file
@ -0,0 +1,690 @@
|
||||
<?
|
||||
error_reporting(0);
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
//include_once(FWK_PATH.'common/curl.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
include_once(INCLUDE_PATH.'partenaires/classMBilans.php');
|
||||
include_once(FWK_PATH.'mail/sendMail.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iInsee=new MInsee();
|
||||
$iBodacc=new MBodacc();
|
||||
|
||||
$strIni='codes séparés par des espaces, points, points-vigules ou sauts de lignes';
|
||||
$fields='id, source, source_id, triCode, autre_id, siren, nic, actif, siege, raisonSociale, enseigne, sigle, marques, adr_num, adr_btq, adr_typeVoie, adr_libVoie, adr_comp, adr_cp, adr_ville, adr_dep, adr_com, tel, fax, cj, capital, capitalDev, capitalSrc, ape_etab, ape_entrep';
|
||||
define('DIR_CSV', './export/');
|
||||
|
||||
session_start();
|
||||
$tabSirenPC=array();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb->select( 'sdv1.utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0", false);
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
} else {
|
||||
|
||||
if (isset($_REQUEST['newFile']) && $_REQUEST['newFile']==1 && @!$_REQUEST['uploaded']) {
|
||||
?>
|
||||
<h3>Enrichier un fichier CSV (séparateur virgule)</h3>
|
||||
<p>La première ligne du fichier doit contenir les noms de zones avec au moins une zone SIREN et une zone NIC</p>
|
||||
<form name="form1" method="post" action="" enctype="multipart/form-data">
|
||||
<input type="hidden" name="uploaded" value="1" />
|
||||
<!--<input type="hidden" name="max_file_size" value="2000000" />-->
|
||||
<input type="file" name="file">
|
||||
<input type="submit" name="Submit" value="Envoyer">
|
||||
</form>
|
||||
<?
|
||||
die();
|
||||
} elseif (isset($_REQUEST['newFile']) && $_REQUEST['newFile']==1 && @$_REQUEST['uploaded']==1 && isset($_FILES['file'])) {
|
||||
|
||||
switch ($_FILES['file']['error']) {
|
||||
case UPLOAD_ERR_INI_SIZE: // 1: Le fichier excède le poids autorisé par upload_max_filesize (php.ini)
|
||||
case UPLOAD_ERR_FORM_SIZE: // 2: Le fichier excède le poids autorisé par le champ MAX_FILE_SIZE
|
||||
die('Fichier trop volumineux !');
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL: // 3; Le fichier n'a été uploadé que partiellement
|
||||
die('Le fichier partiellement uploadé !');
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE: // 4; Aucun fichier n'a été uploadé
|
||||
die('Aucun fichier uploadé !');
|
||||
break;
|
||||
case UPLOAD_ERR_OK: // 0: Aucune erreur, le fichier a bien été uploadé
|
||||
break;
|
||||
}
|
||||
$dest_fichier = basename($_FILES['file']['name']);
|
||||
//print_r($_FILES['file']);
|
||||
if (!move_uploaded_file($_FILES['file']['tmp_name'], DIR_CSV . $dest_fichier))
|
||||
die('Impossible de déplacer le fichier téléchargé !');
|
||||
$csvFile=DIR_CSV . $dest_fichier;
|
||||
|
||||
$size=round(filesize($csvFile)/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($csvFile));
|
||||
$tabFich=file($csvFile);
|
||||
/** Recherche des champs SIREN / NIC **/
|
||||
$lib=explode(',', $tabFich[0]);
|
||||
$pos=array();
|
||||
foreach ($lib as $j=>$titre) {
|
||||
switch (strtoupper(strtr($titre, array('"'=>'', "'"=>'')))) {
|
||||
case 'SIREN': $pos['SIREN']=$j; break;
|
||||
case 'NIC': $pos['NIC']=$j; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
$nb=count($tabFich);
|
||||
echo "<p>$csvFile : $nb lignes, le $dateHeure ($size Ko)</p>";
|
||||
$strId=implode(', ', array_keys($pos));
|
||||
$strPo=implode(', ', $pos);
|
||||
echo "<p>Colonnes $strId trouvées en positions $strPo</p><br>";
|
||||
}
|
||||
|
||||
if (isset($_SESSION['csvFile']) && file_exists($_SESSION['csvFile']))
|
||||
$csvFile=$_SESSION['csvFile'];
|
||||
elseif (!isset($csvFile))
|
||||
$csvFile=$_REQUEST['csvFile'];
|
||||
|
||||
if (isset($_REQUEST['submited']) && $_REQUEST['submited']==1) {
|
||||
$hdeb=microtime(true);
|
||||
$tabFich=file($csvFile);
|
||||
|
||||
$pos=array();
|
||||
$csvFile2=str_replace('.csv', '-'.date('mdHi').'.csv', $csvFile);
|
||||
$fp = fopen($csvFile2, 'w');
|
||||
/*echo '<pre>';
|
||||
print_r($_REQUEST);
|
||||
echo '</pre>';
|
||||
die();*/
|
||||
foreach ($tabFich as $i=>$ligne) {
|
||||
$ligne=trim($ligne);
|
||||
$str['data']=$str['etab']=$str['identite']=$str['notice']=$str['rncs_entrep']=$str['rncs_etab']=$str['infos']='';
|
||||
if ($i==0) {
|
||||
$lib=explode(',', $ligne);
|
||||
foreach ($lib as $j=>$titre) {
|
||||
switch (strtoupper(strtr($titre, array('"'=>'', "'"=>'')))) {
|
||||
case 'SIREN': $pos['SIREN']=$j; break;
|
||||
case 'NIC': $pos['NIC']=$j; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (@count($_POST['data'])>0) $str['data']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['data']))),1);
|
||||
if (@count($_POST['etab'])>0) $str['etab']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['etab']))),1);
|
||||
if (@count($_POST['identite'])>0) $str['identite']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['identite']))),1);
|
||||
if (@count($_POST['notice'])>0) $str['notice']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['notice']))),1);
|
||||
if (@count($_POST['rncs_entrep'])>0)$str['rncs_entrep']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['rncs_entrep']))),1);
|
||||
if (@count($_POST['rncs_etab'])>0) $str['rncs_etab']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['rncs_etab']))),1);
|
||||
if (@count($_POST['infos'])>0) $str['infos']=substr(preg_replace('/,(.*) AS /Ui',',', ','.implode(',', array_keys($_POST['infos']))),1);
|
||||
if (@count($_POST['bilans'])>0) {
|
||||
$str['bilans']='';
|
||||
if (@$_POST['bilans']['anneeN']) $str['bilans'].='bilanNdate,bilanNduree,'.@$_POST['bilans']['postes'].',';
|
||||
if (@$_POST['bilans']['anneeN1']) $str['bilans'].='bilanN-1date,bilanN-1duree,'.@$_POST['bilans']['postes'].',';
|
||||
if (@$_POST['bilans']['anneeN2']) $str['bilans'].='bilanN-2date,bilanN-2duree,'.@$_POST['bilans']['postes'].',';
|
||||
}
|
||||
|
||||
if (@count($_POST['annonces'])>0) {
|
||||
$str['annonces']='';
|
||||
$tabTmp=explode(',', $_POST['annonces']['codeAnnonces']);
|
||||
foreach ($tabTmp as $codeEven)
|
||||
$str['annonces'].="even$codeEven,libelle$codeEven,dateEven$codeEven,dateParution$codeEven,";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$cel=explode(',', $ligne);
|
||||
$cel2=array();
|
||||
foreach ($cel as $idx=>$cell)
|
||||
$cel2[$idx]=preg_replace('/(^"|"$)/','', trim($cell));
|
||||
$cel=$cel2;
|
||||
|
||||
//if (@count($_POST['identite'])>0) {
|
||||
|
||||
if (@count($_POST['etab'])>0)
|
||||
$str['etab']=str_replace('on','',implode(',', $_POST['etab']));
|
||||
if (isset($pos['NIC']) && $cel[$pos['NIC']]*1>0) { $strNic='nic='.$cel[$pos['NIC']]; $nic=$cel[$pos['NIC']]; }
|
||||
else $strNic='nic>-1 AND actif>-1 AND siege=1 ORDER BY actif DESC, nicTmp DESC LIMIT 0,1';
|
||||
|
||||
$fieldId='nic as nicTmp,cj as cjTmp';
|
||||
if (@count($_POST['etab'])>0)
|
||||
$fieldId.=','.implode(',', array_keys($_POST['etab']));
|
||||
$whereId='siren='.$cel[$pos['SIREN']]." AND $strNic";
|
||||
|
||||
$ret=$iDb->select('jo.etablissements', $fieldId, $whereId, false, MYSQL_ASSOC);
|
||||
if (isset($ret[0]['nicTmp'])) {
|
||||
$nic=$nicSiege=$ret[0]['nicTmp'];
|
||||
$fJur=$ret[0]['cjTmp'];
|
||||
unset($ret[0]['nicTmp']);
|
||||
unset($ret[0]['cjTmp']);
|
||||
} else {
|
||||
$nic=$nicSiege='00000';
|
||||
$fJur='0000';
|
||||
}
|
||||
if (@count($_POST['etab'])>0 && isset($ret[0])) $str['etab']=implode(',', $ret[0]);
|
||||
if (mysql_errno()>0){
|
||||
echo "SELECT $fieldId FROM jo.etablissements WHERE $whereId".EOL;
|
||||
die( 'Erreur 1 '.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
if (@count($_POST['identite'])>0) {
|
||||
$str['identite']=str_replace('on','',implode(',', $_POST['identite']));
|
||||
$fieldId=implode(',', array_keys($_POST['identite']));
|
||||
$whereId='SIREN='.$cel[$pos['SIREN']].' AND NIC='.$nicSiege;
|
||||
|
||||
$ret=@$iDb->select('insee.identite', $fieldId, $whereId, false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['identite']=implode(',', $ret[0]);
|
||||
|
||||
if (mysql_errno()>0) {
|
||||
echo "SELECT $fieldId FROM insee.identite WHERE $whereId".EOL;
|
||||
die( 'Erreur A '.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
}
|
||||
|
||||
if (@count($_POST['data'])>0) {
|
||||
// Respecter l'ordre de remplissage du tableau pour cette rubrique
|
||||
$tabData=array();
|
||||
//$str['data']=str_replace('on','',implode(',', $_POST['data']));
|
||||
//die($_POST['data']['siretValide']);
|
||||
if (@$_POST['data']['siretValide']=='on') {
|
||||
if ($iInsee->valideSiren($cel[$pos['SIREN']], @$cel[$pos['NIC']]))
|
||||
$tabData['siretValide']=1;
|
||||
else
|
||||
$tabData['siretValide']=0;
|
||||
}
|
||||
|
||||
if (@$_POST['data']['nicSiege']=='on') {
|
||||
$tabData['nicSiege']=$nicSiege;
|
||||
}
|
||||
|
||||
if (@$_POST['data']['tva']=='on') {
|
||||
$accesDist=false;
|
||||
$iTva=@new MTva($cel[$pos['SIREN']], $accesDist);
|
||||
//$vatDefined=$iTva->vatDefined;
|
||||
$tabData['tva']=$iTva->vatNumber;
|
||||
}
|
||||
|
||||
if (/*@$_POST['data']['dateFermetureEn']=='on' || */@$_POST['data']['dateFermetureEt']=='on') {
|
||||
$ret=$iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$cel[$pos['SIREN']].' AND insNIC='.$nic." AND insEVE IN('FF','OF','400','410','420','425','430','435') ORDER BY insDATEVE DESC", false, MYSQL_ASSOC);
|
||||
if (mysql_errno()>0) die( 'Erreur B2 '.mysql_errno().' : '.mysql_error() );
|
||||
if (count($ret)==0) {
|
||||
$siret=''.sprintf("%09s", $cel[$pos['SIREN']]).''.sprintf("%05s", $nic);
|
||||
$ret=$iDb->select('insee.insee_even', 'insEVE, insDATEVE', "insSIRETPS=$siret AND insEVE IN('510','530') ORDER BY insDATEVE DESC", false, MYSQL_ASSOC);
|
||||
//die('insSIRETPS='.$sir2.''.$nic2." AND insEVE IN('510','530') ORDER BY insDATEVE DESC");
|
||||
}
|
||||
$tabData['dateFermetureEt']=@$ret[0]['insDATEVE'];
|
||||
$tabData['codeFermetureEt']=@$ret[0]['insEVE'];
|
||||
}
|
||||
|
||||
if (@$_POST['data']['dateFermetureEn']=='on') {
|
||||
$ret=@$iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$cel[$pos['SIREN']]." AND insEVE IN('FF','410','420','425') ORDER BY insDATEVE DESC", false, MYSQL_ASSOC);
|
||||
if (mysql_errno()>0) die( 'Erreur B3 '.mysql_errno().' : '.mysql_error() );
|
||||
$tabData['dateFermetureEn']=@$ret[0]['insDATEVE'];
|
||||
$tabData['codeFermetureEn']=@$ret[0]['insEVE'];
|
||||
}
|
||||
|
||||
if (@$_POST['data']['activite']=='on') {
|
||||
$tmp=@$iBodacc->getActiviteReelle($cel[$pos['SIREN']], $fJur);
|
||||
$tabData['activite']=@preg_replace('/ +/', ' ', strtr($tmp,array("\r"=>' ',"\n"=>' ',"\t"=>' ',','=>' ',';'=>' ','"'=>' ',"'"=>' ')));
|
||||
}
|
||||
|
||||
if (@$_POST['data']['indiScore']=='on') {
|
||||
$ret=@$iDb->select('jo.scores_surveillance', 'indiScore, encours, indiScoreDate, dateBilan, indiScorePre, encoursPre, indiScoreDatePre', 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (mysql_errno()>0) die( 'Erreur Bscore '.mysql_errno().' : '.mysql_error() );
|
||||
if (isset($ret[0]['indiScore'])) {
|
||||
$tabData['indiScore']=@$ret[0]['indiScore'];
|
||||
$tabData['encours']=@$ret[0]['encours'];
|
||||
$tabData['dateBilan']=@$ret[0]['dateBilan'];
|
||||
} else {
|
||||
$iDb->insert('scores_surveillance', array('siren'=>$cel[$pos['SIREN']]), false);
|
||||
$tabData['indiScore']='En cours';
|
||||
$tabData['encours']='En cours';
|
||||
$ret=@$iDb->select('jo.bilans', 'MAX(dateExercice) as dateBilan', 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
$tabData['dateBilan']=@$ret[0]['dateBilan'];
|
||||
if (mysql_errno()>0) die( 'Erreur Cscore Siren="'.$cel[$pos['SIREN']].'"'.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (@$_POST['data']['situationJuridique']=='on') {
|
||||
$tabTmp=array('P','A','D');
|
||||
$tabData['situationJuridique']='';
|
||||
foreach ($tabTmp as $sit) {
|
||||
$tmp=$iInsee->getAnnoncesLegales($cel[$pos['SIREN']], 0, $sit, false);
|
||||
if (count($tmp)>0) {
|
||||
$tmp=$tmp[0];
|
||||
$tabData['situationJuridique']=$sit;
|
||||
$tabData['situationParution']=@$tmp['DateParution'];
|
||||
$tabData['situationDernCode']=@$tmp[0]['CodeEven'];
|
||||
$tabData['situationDernEven']=@preg_replace('/ +/', ' ', strtr($tmp[0]['LibEven'],array("\r"=>' ',"\n"=>' ',"\t"=>' ',','=>' ',';'=>' ','"'=>' ',"'"=>' ')));
|
||||
//print_r($tmp);die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($tabData['situationJuridique']=='') {
|
||||
$rep=$iDb->select('rncs_entrep', 'actif, dateRad', "siren=".$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
$entrep=@$rep[0];
|
||||
if (isset($entrep['actif']) && $entrep['actif']*1==0)
|
||||
$tabData['situationJuridique']='R';
|
||||
$tabData['situationParution']=@$entrep['dateRad'];
|
||||
$tabData['situationDernCode']='';
|
||||
$tabData['situationDernEven']='';//@preg_replace('/ +/', ' ', strtr($tmp[0]['LibEven'],array("\r"=>' ',"\n"=>' ',"\t"=>' ',','=>' ',';'=>' ','"'=>' ',"'"=>' ')));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (@$_POST['data']['dirigeant1Nom']=='on' || @$_POST['data']['dirigeant2Nom']=='on') {
|
||||
$tmp=$iInsee->getDirigeants($cel[$pos['SIREN']], false);
|
||||
if (count($tmp)>0 && @$_POST['data']['dirigeant1Nom']=='on') {
|
||||
$dir=$tmp[0];
|
||||
$tabData['dirigeant1Nom']='';
|
||||
if ($dir['Societe']<>'') $tabData['dirigeant1Nom'].=$dir['Societe'].' repr. par ';
|
||||
$tabData['dirigeant1Nom'].=trim($dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom']);
|
||||
$tabData['dirigeant1Fonction']=$dir['Titre'];
|
||||
$tabData['dirigeant1DateNaiss']=$dir['NaissDate'];
|
||||
$tabData['dirigeant1LieuNaiss']=$dir['NaissVille'];
|
||||
}
|
||||
if (count($tmp)>1 && @$_POST['data']['dirigeant2Nom']=='on') {
|
||||
$dir=$tmp[1];
|
||||
$tabData['dirigeant2Nom']='';
|
||||
if ($dir['Societe']<>'') $tabData['dirigeant2Nom'].=$dir['Societe'].' repr. par ';
|
||||
$tabData['dirigeant2Nom'].=trim($dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom']);
|
||||
$tabData['dirigeant2Fonction']=$dir['Titre'];
|
||||
$tabData['dirigeant2DateNaiss']=$dir['NaissDate'];
|
||||
$tabData['dirigeant2LieuNaiss']=$dir['NaissVille'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (@$_POST['data']['latLon']=='on') {
|
||||
$tabData['latitude']=0;
|
||||
$tabData['longitude']=0;
|
||||
}
|
||||
$str['data']=implode(',', $tabData);
|
||||
}
|
||||
|
||||
if (@count($_POST['notice'])>0) {
|
||||
$str['notice']=str_replace('on','',implode(',', $_POST['notice']));
|
||||
$ret=@$iDb->select('insee.insee_notices', implode(',', array_keys($_POST['notice'])), 'insSIREN='.$cel[$pos['SIREN']].' AND insNIC='.$nicSiege, false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['notice']=implode(',', $ret[0]);
|
||||
|
||||
if (mysql_errno()>0) die( 'Erreur B '.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
|
||||
if (@count($_POST['rncs_entrep'])>0) {
|
||||
$str['rncs_entrep']=str_replace('on','',implode(',', $_POST['rncs_entrep']));
|
||||
$ret=$iDb->select('jo.rncs_entrep', implode(',', array_keys($_POST['rncs_entrep'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_entrep']=implode(',', $ret[0]);
|
||||
|
||||
if (mysql_errno()>0) die( 'Erreur C '.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
|
||||
if (@count($_POST['rncs_etab'])>0) {
|
||||
$str['rncs_etab']=str_replace('on','',implode(',', $_POST['rncs_etab']));
|
||||
$ret=$iDb->select('jo.rncs_etab', implode(',', array_keys($_POST['rncs_etab'])), 'siren='.$cel[$pos['SIREN']].' AND nic='.$nicSiege, false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_etab']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (@count($_POST['infos'])>0) {
|
||||
$str['infos']=str_replace('on','',implode(',', $_POST['infos']));
|
||||
$ret=$iDb->select('jo.infos_entrep', implode(',', array_keys($_POST['infos'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['infos']=implode(',', $ret[0]);
|
||||
|
||||
if (mysql_errno()>0) die( 'Erreur D '.mysql_errno().' : '.mysql_error() );
|
||||
}
|
||||
|
||||
if (@count($_POST['bilans'])>0 && @trim($_POST['bilans']['postes'])<>'') {
|
||||
$tabPostes=explode(',', @$_POST['bilans']['postes']);
|
||||
$mBil=new MBilans($cel[$pos['SIREN']]);
|
||||
$tabBilans=$mBil->listeBilans(false, 3);
|
||||
if (count($tabBilans)>0) {
|
||||
$tabBil=array();
|
||||
foreach ($tabBilans as $typeMil=>$bilan)
|
||||
$tabBil[]=$mBil->getBilan(substr($typeMil,1), substr($typeMil,0,1));
|
||||
$str['bilans']='';
|
||||
if (@$_POST['bilans']['anneeN']) {
|
||||
$tabBi=$tabBil[0];
|
||||
$str['bilans'].=$tabBi['DATE_CLOTURE'].','.$tabBi['DUREE_MOIS'].',';
|
||||
foreach ($tabPostes as $poste)
|
||||
$str['bilans'].=@$tabBi[$poste].',';
|
||||
}
|
||||
if (@$_POST['bilans']['anneeN1']) {
|
||||
$tabBi=$tabBil[1];
|
||||
$str['bilans'].=$tabBi['DATE_CLOTURE'].','.$tabBi['DUREE_MOIS'].',';
|
||||
foreach ($tabPostes as $poste)
|
||||
$str['bilans'].=@$tabBi[$poste].',';
|
||||
}
|
||||
if (@$_POST['bilans']['anneeN2']) {
|
||||
$tabBi=$tabBil[2];
|
||||
$str['bilans'].=$tabBi['DATE_CLOTURE'].','.$tabBi['DUREE_MOIS'].',';
|
||||
foreach ($tabPostes as $poste)
|
||||
$str['bilans'].=@$tabBi[$poste].',';
|
||||
}
|
||||
} else {
|
||||
$str['bilans']='';
|
||||
if (@$_POST['bilans']['anneeN']) $str['bilans'].='0,0,'.preg_replace('/[0-9A-Z]/i','',@$_POST['bilans']['postes']).',';
|
||||
if (@$_POST['bilans']['anneeN1']) $str['bilans'].='0,0,'.preg_replace('/[0-9A-Z]/i','',@$_POST['bilans']['postes']).',';
|
||||
if (@$_POST['bilans']['anneeN2']) $str['bilans'].='0,0,'.preg_replace('/[0-9A-Z]/i','',@$_POST['bilans']['postes']).',';
|
||||
}
|
||||
}
|
||||
|
||||
if (@count($_POST['annonces'])>0 && @trim($_POST['annonces']['codeAnnonces'])<>'') {
|
||||
$str['annonces']='';
|
||||
$tabDeja=array();
|
||||
$tabTmp=explode(',', $_POST['annonces']['codeAnnonces']);
|
||||
$tabEven=$iInsee->getAnnoncesLegales($cel[$pos['SIREN']],0,$tabTmp);
|
||||
// die(print_r($tabEven));
|
||||
foreach ($tabTmp as $even)
|
||||
foreach ($tabEven as $tabAnn)
|
||||
foreach ($tabAnn['evenements'] as $codEve)
|
||||
if ($even==$codEve['CodeEven'] && !in_array($even, $tabDeja)) {
|
||||
$tabDeja[]=$even;
|
||||
$dateEven=$tabAnn['dateJugement'];
|
||||
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['dateEffet'];
|
||||
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['DateParution'];
|
||||
$str['annonces'].="$even,".strtr($codEve['LibEven'],array(','=>' ',"'"=>' ','"'=>' ',';'=>' ')).','.$dateEven.','.$tabAnn['DateParution'].',';
|
||||
}
|
||||
} else {
|
||||
$str['annonces']='';
|
||||
$tabTmp=explode(',', $_POST['annonces']['codeAnnonces']);
|
||||
foreach ($tabTmp as $codeEven)
|
||||
$str['annonces'].=",,,,";
|
||||
}
|
||||
|
||||
}
|
||||
/*<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées Lambert 2</td></tr>*/
|
||||
fwrite($fp, "$ligne,". $str['data'].','.
|
||||
$str['etab'].','.
|
||||
$str['infos'].','.
|
||||
$str['identite'].'1,'.
|
||||
$str['notice'].','.
|
||||
$str['rncs_entrep'].','.
|
||||
$str['rncs_etab'].','.
|
||||
$str['bilans'].','.
|
||||
$str['annonces'].','.
|
||||
EOL);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$size=round(filesize($csvFile2)/1024,1);
|
||||
$hfin=microtime(true);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($csvFile2));
|
||||
$duree=round($hfin-$hdeb,1);
|
||||
|
||||
echo '<a href="'.$csvFile2.'">'.$csvFile2."</a> $i lignes, le $dateHeure ($size Ko) en $duree s.<br/>";
|
||||
?>
|
||||
<br/><a href="Javascript:history.back();">Retourner à la page précédente</a>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
<table border="0">
|
||||
<form action="extraction.php" method="POST">
|
||||
<input type="hidden" name="submited" value="1">
|
||||
<input type="hidden" name="csvFile" value="<?=$csvFile?>">
|
||||
|
||||
<tr><td valign="top">
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><input type="checkbox" name="data[siretValide]"> Vérifier la validité du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[nic>0 as SiretEnBase]"> Vérifier la présence en base du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[nicSiege]"> NIC du siège (si nic absent)</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[tva]"> Numéro de TVA (non validés)</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[dateFermetureEn]"> Date Fermeture de l'entreprise à l'Insee</td></tr>
|
||||
<input type="hidden" name="data[codeFermetureEn]">
|
||||
<tr><td><input type="checkbox" name="data[dateFermetureEt]"> Date Fermeture de l'établissement à l'Insee</td></tr>
|
||||
<input type="hidden" name="data[codeFermetureEt]">
|
||||
<tr><td><input type="checkbox" name="infos[isin]"> Code ISIN (société en bourse)</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[activite]"> Activitée Réelle (Bodacc)</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[situationJuridique]"> Situation Juridique (Rncs, Bodacc, JAL)</td></tr>
|
||||
<input type="hidden" name="data[situationParution]">
|
||||
<input type="hidden" name="data[situationDernCode]">
|
||||
<input type="hidden" name="data[situationDernEven]">
|
||||
<tr><td><input type="checkbox" name="data[dirigeant1Nom]"> Dirigeant n°1</td></tr>
|
||||
<input type="hidden" name="data[dirigeant1Fonction]">
|
||||
<input type="hidden" name="data[dirigeant1DateNaiss]">
|
||||
<input type="hidden" name="data[dirigeant1LieuNaiss]">
|
||||
<tr><td><input type="checkbox" name="data[dirigeant2Nom]"> Dirigeant n°2</td></tr>
|
||||
<input type="hidden" name="data[dirigeant2Fonction]">
|
||||
<input type="hidden" name="data[dirigeant2DateNaiss]">
|
||||
<input type="hidden" name="data[dirigeant2LieuNaiss]">
|
||||
<tr><td><input type="checkbox" name="data[indiScore]"> Note Indiscore©</td></tr>
|
||||
<input type="hidden" name="data[encours]">
|
||||
<input type="hidden" name="data[dateBilan]">
|
||||
<tr><td><input type="checkbox" name="infos[tel]"> Téléphone</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[fax]"> Fax</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[web]"> Site Web</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[mail]"> Adresse email de contact</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon]" disabled> Coordonnées GPS</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon2]" disabled> Coordonnées Lambert 2</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Identité</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[CONCAT(source,'-',source_id)AS idSd]"> Identifiant S&D</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[source]"> Source S&D</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[triCode]"> Code Tribunal</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[autre_id]"> Autre ID (N°RC / Waldec)</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[actif]"> ACTIF</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[siege]"> Siège ou Etablissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[raisonSociale]"> Raison Sociale</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[enseigne]"> Enseigne</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[sigle]"> Sigle</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[marques]"> Marques déposées</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_num]"> Adresse : Numéro dans la voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_btq]"> Adresse : Bis/Ter/etc..</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_typeVoie]"> Adresse : Type de voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_libVoie]"> Adresse : Libellé de le voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_comp]"> Adresse : Complément</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_cp]"> Adresse : Code Postal</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_ville]"> Adresse : Ville</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[adr_dep]"> Adresse : Département</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[CONCAT(if (adr_dep>100,round(adr_dep/10),adr_dep*1),adr_com)AS adr_codeCom]"> Adresse : Code Commune étab.</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[tel as telEtab]"> Téléphone</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[fax as faxEtab]"> Télécopie</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[cj]"> Forme Juridique</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[capital]"> Capital</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[capitalDev]"> Devise du capital</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[ape_etab]"> NAF de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="etab[ape_entrep]"> NAF de l'entreprise</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</td><td valign="top">
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Identité INSEE</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTIF as etActifInsee]"> Actif INSEE</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[NOM as nomInsee]"> Raison Sociale</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[NOM2 as nomInsee2]"> Raison Sociale (suite)</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[SIGLE as sigleInsee]"> Sigle</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ENSEIGNE as enseigneInsee]"> Enseigne</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_NUMVOIE as adrNumVoieInsee]"> Adresse : Numéro dans la voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_BTQ as adrBtqInsee]"> Adresse : Bis/Ter/etc...</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_TYPVOIE as adrTypeVoieInsee]"> Adresse : Type de voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_LIBVOIE as adrVoieInsee]"> Adresse : Libellé de la voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_COMP as adrCompInsee]"> Adresse : Complément</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_CP as adrCPInsee]"> Adresse : Code Postal</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_LIBCOM as adrVilleInsee]"> Adresse : Commune</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ADR_DISTSP as adrDistSPInsee]"> Adresse : Distribution spéciale</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CJ as CjInsee]"> Forme juridique de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[APE_ENT as nafEnInsee]"> NAF de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[APE_ETAB as nafEtInsee]"> NAF de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[APRM]"> APRM</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTIVNAT]"> ACTIVNAT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ORIGINE]"> Origine de création</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODET]"> MODET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLET]"> EXPLET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[LIEUACT]"> LIEUACT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTISURF]"> ACTISURF</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODEN]"> MODEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[PRODPART]"> PRODPART</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLEN]"> EXPLEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOREG]"> Mono-régionalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[REGIMP]"> Principle région d'implantation</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOACT]"> Mono-activité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[DCREN]"> Date de création de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[AUXILT]"> Auxiliarité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[SAISONAT]"> Saisonnalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CIVILITE]"> Civilité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[TCA]"> Tranche de Chiffre d'Affaire</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[TCAEXP]"> Tranche de Chiffre d'Affaire à l'export</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ENT]"> Effectif de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[DCRET]"> Date de création de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ET]"> Effectif de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CODEVOIE]"> Code voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[dateUpdate as dateMajInsee]"> Date de la dernière mise à jour Insee</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</td><td valign="top">
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Informations INSEE (notice 80)</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRPET]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDEPCOMEN]"> Code commune INSEE du siège</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRPEN]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insARRONET]"> Arrondissement de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insCTONET]"> Canton de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTCD]"> Tranche de commune détaillée</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insZEMET]"> ZEMET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDU]"> DU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTU]"> TU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insUU]"> UU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRECME]"> RECME</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANT]"> EAEANT</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPET]"> EAEAPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1T]"> EAESEC1T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2T]"> EAESEC2T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANN]"> EAEANN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPEN]"> EAEAPEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1N]"> insEAESEC1N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2N]"> insEAESEC2N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC3N]"> insEAESEC3N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC4N]"> insEAESEC4N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[dateNotice as dateMajNotice]"> Date de la dernière notice MAJ</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Postes Bilans</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="bilans[anneeN]"> Dernier Bilan</td></tr>
|
||||
<tr><td><input type="checkbox" name="bilans[anneeN1]"> Bilan N-1</td></tr>
|
||||
<tr><td><input type="checkbox" name="bilans[anneeN2]"> Bilan N-2</td></tr>
|
||||
<tr><td><input type="text" size="15" name="bilans[postes]"> Postes du bilans (séparés par des virgules)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Annonces</b></u></td></tr>
|
||||
<tr><td><input type="text" size="15" name="annonces[codeAnnonces]"> Code évènements S&D (séparés par des virgules)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</td><td valign="top">
|
||||
|
||||
<table border="2">
|
||||
<tr><td>
|
||||
<table border="0">
|
||||
<tr><td><u><b>Identité de l'entreprise RNCS</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[actif AS entActiveRncs]"> Entreprise active</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[numRC2]"> Numéro RC</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[raisonSociale AS raisonSocialeRncs]"> Raison Sociale</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[sigle AS sigleRncs]"> Sigle</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateNaiss]"> Date Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[lieuNaiss]"> Lieu de Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[nationalite]"> Nationalité PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[pays]"> Pays</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[naf AS nafEnRncs]"> NAF Entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[cj AS cjRncs]"> Forme Juridique</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateImma]"> Date Immatriculation</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateRad]"> Date de radiation</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[capitalType]"> Type de capital</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[flux AS dateMajEnRncs]"> Date MAJ entreprise RNCS</td></tr>
|
||||
<tr><td><u><b>Identité de l'établissement RNCS</b></u></td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[actif AS etActifRncs]"> Etablissement actif</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[siege AS siegeRncs]"> Etablissement siège</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[enseigne AS enseigneRncs]"> Enseigne de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[nomCommercial AS nomCommercialRncs]"> Nom Commercial de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrNumVoie AS adrNumVoieRncs]"> Adresse : Numéro</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrIndRep AS adrIndRepRncs]"> Adresse : Bis/Ter/etc...</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrLibVoie AS adrLibVoieRncs]"> Adresse : Libellé voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrTypeVoie AS adrTypeVoieRncs]"> Adresse : Type de la voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrVoie AS adrVoieRncs]"> Adresse : Libellé de la voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[cp AS cpRncs]"> Adresse : Code postal</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[commune AS villeRncs]"> Adresse : Ville</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[adrComp AS adrCompRncs]"> Adresse : Complément</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[naf AS nafEtRncs]"> NAF Etablissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[flux AS dateMajEtRncs]"> Date MAJ établissement RNCS</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<table border="0">
|
||||
<tr><td align="center"><input name="btSubmit" type="submit" onclick="this.value='...';this.disabled=true;" value="Extraire"> <input type="reset" onclick="btSubmit.value='Extraire';btSubmit.disabled=false;"></td></tr>
|
||||
</table>
|
||||
|
||||
<?
|
||||
}
|
||||
?>
|
621
html/comptages/index.php
Normal file
@ -0,0 +1,621 @@
|
||||
|
||||
<?
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
//error_reporting(0);
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
//include_once(FWK_PATH.'common/curl.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iBodacc=new MBodacc();
|
||||
|
||||
$strIni='codes séparés par des espaces, points, points-vigules ou sauts de lignes';
|
||||
$fields='id, source, source_id, triCode, autre_id, siren, nic, actif, siege, raisonSociale, enseigne, sigle, marques, adr_num, adr_btq, adr_typeVoie, adr_libVoie, adr_comp, adr_cp, adr_ville, adr_dep, tel, fax, cj, capital, capitalDev, capitalSrc, ape_etab, ape_entrep';
|
||||
define('DIR_CSV', './export/');
|
||||
|
||||
session_start();
|
||||
$tabSirenPC=array();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb->select( 'sdv1.utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
} else {
|
||||
|
||||
if (isset($_POST['submited']) && $_POST['submited']==1) {
|
||||
|
||||
$where='1';
|
||||
|
||||
if (isset($_POST['source']) && count($_POST['source'])>0)
|
||||
$where.=' AND source IN ('.implode(',', $_POST['source']).')';
|
||||
else
|
||||
$where.=' AND source IN (1,2,3,4,5,6,7,8,9,10)';
|
||||
|
||||
if (isset($_POST['actif']) && ($_POST['actif']==1 || $_POST['actif']*1==0) )
|
||||
$where.=' AND actif='.$_POST['actif']*1;
|
||||
else
|
||||
$where.=' AND actif IN(0,1) ';
|
||||
|
||||
if (isset($_POST['siege']) && ($_POST['siege']==1 || $_POST['siege']*1==0) )
|
||||
$where.=' AND siege='.$_POST['siege']*1;
|
||||
else
|
||||
$where.=' AND siege IN(0,1) ';
|
||||
|
||||
if (isset($_POST['dep']) && count($_POST['dep'])>0)
|
||||
$where.=' AND adr_dep IN ('.implode(',', $_POST['dep']).')';
|
||||
elseif (isset($_POST['reg']) && count($_POST['reg'])>0)
|
||||
$where.=' AND adr_dep IN (SELECT numdep FROM insee.departements WHERE codeRegionInsee IN ('.implode(',', $_POST['reg']).'))';
|
||||
//raisonSociale`, `enseigne`, `sigle`, `identite_pre`, `marques`, `adr_num`, `adr_btq`, `adr_typeVoie`, `adr_libVoie`, `adr_comp`, `adr_cp`, `adr_ville`, ``, `tel`, `fax`, `cj`, ``, ``, `capitalSrc`, `ape_etab`, `ape_entrep`, `rang` FROM `etablissements_old` WHERE 1
|
||||
elseif (isset($_POST['strCP']) && $_POST['strCP']<>"" && $_POST['strCP']<>$strIni) {
|
||||
die($_POST['strCP']);
|
||||
$where.=' AND adr_dep IN ('.implode(',', $_POST['dep']).')';
|
||||
/*
|
||||
" value="" cols="30" rows="3" onfocus="if (this.value=='<?=$strIni?>') this.value='';"><?=$strIni?></textarea></td>
|
||||
|
||||
<tr><td><b><u>Codes Communes Insee</u></b></td>
|
||||
<td><textarea name="strInsee*/
|
||||
} else
|
||||
$where.=' AND adr_dep BETWEEN 0 AND 999';
|
||||
|
||||
if (isset($_POST['capitalMin']) && $_POST['capitalMin']*1>0)
|
||||
$where.=' AND capital>='.$_POST['capitalMin']*1;
|
||||
|
||||
if (isset($_POST['capitalMax']) && $_POST['capitalMax']*1>0)
|
||||
$where.=' AND capital<='.$_POST['capitalMax']*1;
|
||||
|
||||
if (isset($_POST['capitalDev']) && trim($_POST['capitalDev'])<>'')
|
||||
$where.=" AND capitalDev IN ('','".$_POST['capitalDev']."')";
|
||||
|
||||
if (!isset($_POST['capitalMin']) && !isset($_POST['capitalMax']))
|
||||
$where.=' AND capital>=0';
|
||||
|
||||
if (isset($_POST['fj']) && count($_POST['fj'])>0)
|
||||
$where.=' AND cj IN ('.implode(',', $_POST['fj']).')';
|
||||
else
|
||||
$where.=' AND cj BETWEEN 0 AND 9999';
|
||||
|
||||
if (isset($_POST['nafEn']) && count($_POST['nafEn'])>0)
|
||||
$where.=" AND ape_entrep IN ('".implode("','", $_POST['nafEn'])."')";
|
||||
|
||||
if (isset($_POST['nafEt']) && count($_POST['nafEt'])>0)
|
||||
$where.=" AND ape_etab IN ('".implode("','", $_POST['nafEt'])."')";
|
||||
|
||||
if (isset($_POST['ageMin']) && $_POST['ageMin']*1>0)
|
||||
$where.=' AND age_entrep>='.$_POST['ageMin']*1;
|
||||
|
||||
if (isset($_POST['ageMax']) && $_POST['ageMax']*1>0)
|
||||
$where.=' AND age_entrep<='.$_POST['ageMax']*1;
|
||||
|
||||
if (!isset($_POST['ageMin']) && !isset($_POST['ageMax']))
|
||||
$where.=' AND age_entrep>=0';
|
||||
/*
|
||||
age_etab
|
||||
tcaexp
|
||||
*/
|
||||
|
||||
if (isset($_POST['teffen']) && count($_POST['teffen'])>0)
|
||||
$where.=' AND teff_entrep IN ('.implode(',', $_POST['teffen']).')';
|
||||
else
|
||||
$where.=' AND teff_entrep>=0 ';
|
||||
|
||||
if (isset($_POST['teffet']) && count($_POST['teffet'])>0)
|
||||
$where.=' AND teff_etab IN ('.implode(',', $_POST['teffet']).')';
|
||||
else
|
||||
$where.=' AND teff_etab>=0 ';
|
||||
|
||||
if (isset($_POST['tca']) && count($_POST['tca'])>0)
|
||||
$where.=' AND tca IN ('.implode(',', $_POST['tca']).')';
|
||||
else
|
||||
$where.=' AND tca>=0 ';
|
||||
|
||||
|
||||
|
||||
$_SESSION['where']=$where;
|
||||
$_SESSION['csvFile']=DIR_CSV. $_SESSION['userId'].'-'.md5($where) .'.csv';
|
||||
|
||||
/** [strCP] => codes séparés par des espaces, points, points-vigules ou sauts de lignes
|
||||
[strInsee] => codes séparés par des espaces, points, points-vigules ou sauts de lignes
|
||||
[triCode] => all
|
||||
**/
|
||||
|
||||
//echo '<pre>'.print_r($_POST).'</pre><br/>';
|
||||
|
||||
$ret=@$iDb->select('jo.etablissements_old', 'count(*) AS nb', $where, false, MYSQL_ASSOC);
|
||||
$sql_error=mysql_error();
|
||||
$nb=$ret['0']['nb'];
|
||||
?>
|
||||
<script>if (confirm('Votre sélection porte sur <?=$nb?> établissements.Voulez vous lancer extraires les informations ?\n<?=$sql_error?>?>')) window.location='./?choix=1&nb=<?=$nb?>';</script>
|
||||
<a href="" onclick=""
|
||||
<?
|
||||
} elseif (isset($_REQUEST['choix']) && isset($_REQUEST['nb']) && $_REQUEST['choix']==1) {
|
||||
|
||||
$nb=$_REQUEST['nb']*1+1;
|
||||
$tabFich=array();
|
||||
|
||||
if (file_exists($_SESSION['csvFile'])) $tabFich=file($_SESSION['csvFile']);
|
||||
|
||||
if (count($tabFich)<>$nb) {
|
||||
$sql="SELECT $fields FROM jo.etablissements_old WHERE ".$_SESSION['where'];
|
||||
echo "<code>$sql</code><br/>";
|
||||
$nbLignes=@$iDb->exportCSV($sql, $_SESSION['csvFile']);
|
||||
$nb=$nbLignes;
|
||||
}
|
||||
//echo '<b><a href="./'. $_SESSION['csvFile'] .'">'.$_SESSION['csvFile'].'</a></b><br/>';
|
||||
$size=round(filesize($_SESSION['csvFile'])/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($_SESSION['csvFile']));
|
||||
|
||||
echo "<a href=\"./". $_SESSION['csvFile'].'">'.$_SESSION['csvFile']."</a> $nb lignes, le $dateHeure ($size Ko) <a href=\"./extraction.php\">Enrichir</a><br/>";
|
||||
|
||||
$dh = opendir(DIR_CSV);
|
||||
while (false !== ($filename = readdir($dh))) {
|
||||
$tmp=explode('-', $filename);
|
||||
if ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && basename($_SESSION['csvFile'])<>$filename && $_SESSION['userId']==$tmp[0]) {
|
||||
//$tabFichier[] = $filename;
|
||||
$size=round(filesize(DIR_CSV.$filename)/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime(DIR_CSV.$filename));
|
||||
$nb=count(file(DIR_CSV.$filename));
|
||||
echo '<a href="'.DIR_CSV.$filename.'">'.DIR_CSV.$filename."</a> $nb lignes, le $dateHeure ($size Ko)
|
||||
<a href=\"./extraction.php?csvFile=".DIR_CSV.$filename.'">Enrichir</a><br/>';
|
||||
}
|
||||
}
|
||||
//sort($tabFichier);
|
||||
?>
|
||||
<br/><a href="./">Retourner au comptage</a>
|
||||
<?
|
||||
die();
|
||||
}/* elseif (isset($_REQUEST['choix']) && $_REQUEST['choix']==2) {
|
||||
if (file_exists($_SESSION['csvFile']))
|
||||
$csvFile=$_SESSION['csvFile'];
|
||||
else
|
||||
$csvFile=$_REQUEST['csvFile'];
|
||||
|
||||
?>
|
||||
<table border="0">
|
||||
<form action="extraction.php" method="POST">
|
||||
<!--<input type="hidden" name="choix" value="3">-->
|
||||
<input type="hidden" name="csvFile" value="<?=$csvFile?>">
|
||||
<tr><td><input type="checkbox" name="data[siretValide]"> Vérifier la validité du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[siretEnBase]"> Vérifier la présence en base du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[APRM]"> APRM</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTIVNAT]"> ACTIVNAT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ORIGINE]"> Origine de création</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODET]"> MODET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLET]"> EXPLET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[LIEUACT]"> LIEUACT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTISURF]"> ACTISURF</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODEN]"> MODEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[PRODPART]"> PRODPART</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLEN]"> EXPLEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOREG]"> Mono-régionalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[REGIMP]"> Principle région d'implantation</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOACT]"> Mono-activité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[DCREN]"> Date de création de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[AUXILT]"> Auxiliarité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[SAISONAT]"> Saisonnalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CIVILITE]"> Civilité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ENT]"> Effectif de l'entreprise</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="identite[DCRET]"> Date de création de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ET]"> Effectif de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CODEVOIE]"> Code voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[dateUpdate]"> Date de mise à jour Insee</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="notice[insRPET]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDEPCOMEN]"> Code commune INSEE du siège</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRPEN]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insARRONET]"> Arrondissement de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insCTONET]"> Canton de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTCD]"> Tranche de commune détaillée</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insZEMET]"> ZEMET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDU]"> DU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTU]"> TU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insUU]"> UU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRECME]"> RECME</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANT]"> EAEANT</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPET]"> EAEAPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1T]"> EAESEC1T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2T]"> EAESEC2T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANN]"> EAEANN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPEN]"> EAEAPEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1N]"> insEAESEC1N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2N]"> insEAESEC2N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC3N]"> insEAESEC3N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC4N]"> insEAESEC4N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[dateNotice]"> Date de la dernière notice MAJ</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="data[tva]"> Numéro de TVA</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[isin]"> Code ISIN</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[tel]"> Téléphone</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[fax]"> Fax</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[web]"> Site Web</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[mail]"> Adresse email</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées GPS</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées Lambert 2</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[actif]"> Entreprise active RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[actif]"> Etablissement actif RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[numRC2]"> Numéro RC</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[siege]"> Etablissement siège RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[raisonSociale]"> Raison Sociale RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[sigle]"> Sigle RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateNaiss]"> Date Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[lieuNaiss]"> Lieu de Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[nationalite]"> Nationalité PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[pays]"> Pays</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[naf]"> NAF Entreprise RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[naf]"> NAF Etablissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[cj]"> Forme Juridique RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateImma]"> Date Immatriculation RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateRad]"> Date de radiation RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[capitalType]"> Type de capital</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[flux]"> Date MAJ entreprise RNCS</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="rncs_etab[enseigne]"> Enseigne de l'établissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[nomCommercial]"> Nom Commerical de l'établissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[flux]"> Date MAJ établissement RNCS</td></tr>
|
||||
|
||||
<tr><td align="center"><input name="btSubmit" type="submit" onclick="this.value='...';this.disabled=true;" value="Extraire"> <input type="reset" onclick="btSubmit.value='Extraire';btSubmit.disabled=false;"></td></tr>
|
||||
|
||||
</table>
|
||||
<?
|
||||
die();
|
||||
} /*elseif (isset($_REQUEST['choix']) && $_REQUEST['choix']==3) {
|
||||
|
||||
$tabFich=array();
|
||||
if (file_exists($_SESSION['csvFile']))
|
||||
$csvFile=$_SESSION['csvFile'];
|
||||
else
|
||||
$csvFile=$_REQUEST['csvFile'];
|
||||
|
||||
$tabFich=file($csvFile);
|
||||
|
||||
$pos=array();
|
||||
$csvFile2=str_replace('.csv', '-'.date('mdHi').'.csv', $csvFile);
|
||||
$fp = fopen($csvFile2, 'a');
|
||||
|
||||
foreach ($tabFich as $i=>$ligne) {
|
||||
$ligne=trim($ligne);
|
||||
if ($i==0) {
|
||||
$lib=explode(',', $ligne);
|
||||
foreach ($lib as $j=>$titre) {
|
||||
switch (strtoupper($titre)) {
|
||||
case 'SIREN': $pos['SIREN']=$j; break;
|
||||
case 'NIC': $pos['NIC']=$j; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (count($_POST['identite'])>0) $str['identite']=implode(',', array_keys($_POST['identite']));
|
||||
if (count($_POST['notice'])>0) $str['notice']=implode(',', array_keys($_POST['notice']));
|
||||
if (count($_POST['rncs_entrep'])>0) $str['rncs_entrep']=implode(',', array_keys($_POST['rncs_entrep']));
|
||||
if (count($_POST['rncs_etab'])>0) $str['rncs_etab']=implode(',', array_keys($_POST['rncs_etab']));
|
||||
if (count($_POST['infos'])>0) $str['infos']=implode(',', array_keys($_POST['infos']));
|
||||
}
|
||||
else {
|
||||
$cel=explode(',', $ligne);
|
||||
if (count($_POST['identite'])>0) {
|
||||
$str['identite']=str_replace('on','',implode(',', $_POST['identite']));
|
||||
$ret=$iDb->select('insee.identite', implode(',', array_keys($_POST['identite'])), 'SIREN='.$cel[$pos['SIREN']].' AND NIC='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_entrep']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['notice'])>0) {
|
||||
$str['notice']=str_replace('on','',implode(',', $_POST['notice']));
|
||||
$ret=$iDb->select('insee.insee_notices', implode(',', array_keys($_POST['notice'])), 'insSIREN='.$cel[$pos['SIREN']].' AND insNIC='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['notice']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['rncs_entrep'])>0) {
|
||||
$str['rncs_entrep']=str_replace('on','',implode(',', $_POST['rncs_entrep']));
|
||||
$ret=$iDb->select('jo.rncs_entrep', implode(',', array_keys($_POST['rncs_entrep'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_entrep']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['rncs_etab'])>0) {
|
||||
$str['rncs_etab']=str_replace('on','',implode(',', $_POST['rncs_etab']));
|
||||
$ret=$iDb->select('jo.rncs_etab', implode(',', array_keys($_POST['rncs_etab'])), 'siren='.$cel[$pos['SIREN']].' AND nic='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_etab']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['infos'])>0) {
|
||||
$str['infos']=str_replace('on','',implode(',', $_POST['infos']));
|
||||
$ret=$iDb->select('jo.infos_entrep', implode(',', array_keys($_POST['infos'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['infos']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
}
|
||||
/*<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées Lambert 2</td></tr>
|
||||
fwrite($fp, "$ligne,". $str['identite'].','.
|
||||
$str['notice'].','.
|
||||
$str['rncs_entrep'].','.
|
||||
$str['rncs_etab'].','.
|
||||
EOL);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$size=round(filesize($csvFile2)/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($csvFile2));
|
||||
|
||||
echo '<a href="'.$csvFile2.'">'.$csvFile2."</a> $i lignes, le $dateHeure ($size Ko)<br/>";
|
||||
?>
|
||||
<br/><a href="Javascript:history.back();">Retourner à la page précédente</a>
|
||||
<?
|
||||
die();
|
||||
}*/
|
||||
|
||||
if (true) {
|
||||
?>
|
||||
<table border="0">
|
||||
<form action="" method="POST">
|
||||
<input type="hidden" name="submited" value="1">
|
||||
|
||||
<tr><td><b><u>Etablissements</u></b></td>
|
||||
<td>
|
||||
<select name="actif">
|
||||
<option value="2" selected>Actifs ou inactifs</option>
|
||||
<option value="1">Actifs uniquement</option>
|
||||
<option value="0">Inactifs</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Type d'Etablissements</u></b></td>
|
||||
<td>
|
||||
<select name="siege">
|
||||
<option value="2" selected>Tous les établissements</option>
|
||||
<option value="1">Uniquement les sièges</option>
|
||||
<option value="0">Uniquement les secondaires</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Départements</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="dep[]">
|
||||
<?
|
||||
$ret=$iDb->select('insee.departements', 'numdep, libdep', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['numdep']?>"><?=$dep['libdep']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Régions</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="reg[]">
|
||||
<?
|
||||
$ret=$iDb->select('insee.regions', 'REGION,NCCENR', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['REGION']?>"><?=$dep['NCCENR']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>Codes postaux</u></b></td>
|
||||
<td><textarea name="strCP" value="" cols="30" rows="3" onfocus="if (this.value=='<?=$strIni?>') this.value='';"><?=$strIni?></textarea></td>
|
||||
|
||||
<tr><td><b><u>Codes Communes Insee</u></b></td>
|
||||
<td><textarea name="strInsee" value="" cols="30" rows="3" onfocus="if (this.value=='<?=$strIni?>') this.value='';"><?=$strIni?></textarea></td>
|
||||
|
||||
<tr><td><b><u>Capital entre</u></b></td>
|
||||
<td><input type="text" name="capitalMin" value="0" size="10" maxlength="15">
|
||||
et <input type="text" name="capitalMax" value="" size="10" maxlength="15"> <select size="1" name="capitalDev">
|
||||
<option value="EUR" selected>EUROS</option>
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabDevises', 'devIso, devNom', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dev) {
|
||||
?>
|
||||
<option value="<?=$dev['devIso']?>"><?=$dev['devNom']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><b><u>Forme Juridique</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="fj[]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabFJur', 'code, libelle', 'code>999', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['code']?>"><?=$dep['code'].' '.$dep['libelle']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>NAF Entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="nafEn[]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabNaf5', 'codNaf5, libNaf5', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['codNaf5']?>"><?=$dep['codNaf5'].' '.$dep['libNaf5']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>NAF Etablissement</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="nafEt[]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabNaf5', 'codNaf5, libNaf5', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['codNaf5']?>"><?=$dep['codNaf5'].' '.$dep['libNaf5']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Age de l'entreprise entre</u></b></td>
|
||||
<td><input type="text" name="ageMin" value="0" size="10" maxlength="15">
|
||||
et <input type="text" name="ageMax" value="" size="10" maxlength="15">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><b><u>Chiffre d'Affaire de l'entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple name="tca[]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 500 000 à 1 M€</option>
|
||||
<option value="2" selected>de 1 à 2 M€</option>
|
||||
<option value="3" selected>de 2 à 5 M€</option>
|
||||
<option value="4" selected>de 5 à 10 M€</option>
|
||||
<option value="5" selected>de 10 à 20 M€</option>
|
||||
<option value="6" selected>de 20 à 50 M€</option>
|
||||
<option value="7" selected>de 50 à 100 M€</option>
|
||||
<option value="8" selected>de 100 à 200 M€</option>
|
||||
<option value="9" selected>plus de 200 M€</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Effectif de l'entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple name="teffen[]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 1 à 2 salarié(s)</option>
|
||||
<option value="2" selected>de 3 à 5 salariés</option>
|
||||
<option value="3" selected>de 6 à 9 salariés</option>
|
||||
<option value="11" selected>de 10 à 19 salariés</option>
|
||||
<option value="12" selected>de 20 à 49 salariés</option>
|
||||
<option value="21" selected>de 50 à 99 salariés</option>
|
||||
<option value="22" selected>de 100 à 199 salariés</option>
|
||||
<option value="31" selected>de 200 à 249 salariés</option>
|
||||
<option value="32" selected>de 250 à 499 salariés</option>
|
||||
<option value="41" selected>de 500 à 999 salariés</option>
|
||||
<option value="42" selected>de 1 000 à 1 999 salariés</option>
|
||||
<option value="51" selected>de 2 000 à 4 999 salariés</option>
|
||||
<option value="52" selected>de 5 000 à 9 999 salariés</option>
|
||||
<option value="53" selected>plus de 10 000 salariés</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Effectif de l'établissement</u></b></td>
|
||||
<td>
|
||||
<select multiple name="teffet[]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 1 à 2 salarié(s)</option>
|
||||
<option value="2" selected>de 3 à 5 salariés</option>
|
||||
<option value="3" selected>de 6 à 9 salariés</option>
|
||||
<option value="11" selected>de 10 à 19 salariés</option>
|
||||
<option value="12" selected>de 20 à 49 salariés</option>
|
||||
<option value="21" selected>de 50 à 99 salariés</option>
|
||||
<option value="22" selected>de 100 à 199 salariés</option>
|
||||
<option value="31" selected>de 200 à 249 salariés</option>
|
||||
<option value="32" selected>de 250 à 499 salariés</option>
|
||||
<option value="41" selected>de 500 à 999 salariés</option>
|
||||
<option value="42" selected>de 1 000 à 1 999 salariés</option>
|
||||
<option value="51" selected>de 2 000 à 4 999 salariés</option>
|
||||
<option value="52" selected>de 5 000 à 9 999 salariés</option>
|
||||
<option value="53" selected>plus de 10 000 salariés</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Sources</u></b></td>
|
||||
<td>
|
||||
<select multiple name="source[]">
|
||||
<option value="2" selected>INSEE : Sirene</option>
|
||||
<option value="3" selected>JO : Associations</option>
|
||||
<option value="1" selected>JO : Bodacc</option>
|
||||
<option value="5" selected>RNCS : Inpi</option>
|
||||
<option value="4" selected>TC : Greffes</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Tribunaux</u></b></td>
|
||||
<td>
|
||||
<select name="triCode">
|
||||
<option value="all">Tous les tribunaux</option>
|
||||
<?
|
||||
foreach($iBodacc->getListeTribunaux() as $t=>$tri) {
|
||||
?>
|
||||
<option value="<?=$t?>"><?=$tri['nom']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td> </td>
|
||||
<td align="center"><input name="btSubmit" type="submit" onclick="this.value='...';this.disabled=true;" value="Lancer le comptage"> <input type="reset" onclick="btSubmit.value='Lancer le comptage';btSubmit.disabled=false;"></td></tr>
|
||||
|
||||
</form>
|
||||
</table>
|
||||
<!--
|
||||
|
||||
|
||||
autre_id
|
||||
siren
|
||||
nic
|
||||
actif
|
||||
siege
|
||||
adr_cp
|
||||
adr_ville
|
||||
adr_dep
|
||||
tel
|
||||
fax
|
||||
cj
|
||||
capital
|
||||
capitalDev
|
||||
ape_etab
|
||||
ape_entrep
|
||||
-->
|
||||
<?
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
682
html/comptages/index2.php
Normal file
@ -0,0 +1,682 @@
|
||||
<?
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
//error_reporting(0);
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
//include_once(FWK_PATH.'common/curl.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
//include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
include_once(FWK_PATH.'sphinx/recherche2.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iBodacc=new MBodacc();
|
||||
|
||||
$strIni='codes séparés par des espaces, points, points-vigules ou sauts de lignes';
|
||||
//$fields='id, source, source_id, triCode, autre_id, siren, nic, actif, siege, raisonSociale, enseigne, sigle, marques, adr_num, adr_btq, adr_typeVoie, adr_libVoie, adr_comp, adr_cp, adr_ville, adr_dep, tel, fax, cj, capital, capitalDev, capitalSrc, ape_etab, ape_entrep';
|
||||
define('DIR_CSV', './export/');
|
||||
|
||||
session_start();
|
||||
$tabSirenPC=array();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb->select( 'sdv1.utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
} else {
|
||||
|
||||
if (isset($_POST['submited']) && isset($_POST['ciblage']) && $_POST['submited']==1) {
|
||||
$ciblage=$_POST['ciblage'];
|
||||
//print_r($ciblage);
|
||||
//die();
|
||||
$tabFiltres=array();
|
||||
$where='';
|
||||
$deb=0;
|
||||
$nbRep=4000;
|
||||
$maxRep=4000;
|
||||
$pertinence=true;
|
||||
/* sql_query = SELECT id,ape_etab,ape_entrep,source,siren,nic,actif,siege,adr_cp,adr_dep,adr_com,tel,fax,cj,capital,age_entrep,age_etab,tca,tcaexp,teff_entrep,teff_etab,rang,dateCrea_etab,eff_entrep,eff_etab,nbEtab,bilType,bilAnnee,bilTca,bilCA,bilCAexp,bilRN FROM etablissements_act;
|
||||
sql_attr_str2ordinal = bilType
|
||||
sql_attr_uint = adr_cp
|
||||
sql_attr_uint = adr_dep
|
||||
sql_attr_uint = adr_com
|
||||
sql_attr_uint = capital
|
||||
sql_attr_uint = rang
|
||||
sql_attr_uint = dateCrea_etab
|
||||
sql_attr_uint = eff_entrep
|
||||
sql_attr_uint = eff_etab
|
||||
sql_attr_uint = nbEtab
|
||||
sql_attr_uint = bilAnnee
|
||||
sql_attr_uint = bilTca
|
||||
sql_attr_uint = bilCA
|
||||
sql_attr_uint = bilCAexp
|
||||
sql_attr_uint = bilRN
|
||||
*/
|
||||
|
||||
|
||||
if (isset($ciblage['source']) && count($ciblage['source'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('source'=>$ciblage['source']));
|
||||
|
||||
if (isset($ciblage['tel']) && ($ciblage['tel']==1 || $ciblage['tel']*1==0) )
|
||||
$tabFiltres=array_merge($tabFiltres, array('tel'=>$ciblage['tel']));
|
||||
if (isset($ciblage['fax']) && ($ciblage['fax']==1 || $ciblage['fax']*1==0) )
|
||||
$tabFiltres=array_merge($tabFiltres, array('fax'=>$ciblage['fax']));
|
||||
|
||||
if (isset($ciblage['actif']) && ($ciblage['actif']==1 || $ciblage['actif']*1==0) )
|
||||
$tabFiltres=array_merge($tabFiltres, array('actif'=>$ciblage['actif']));
|
||||
|
||||
if (isset($ciblage['siege']) && ($ciblage['siege']==1 || $ciblage['siege']*1==0) )
|
||||
$tabFiltres=array_merge($tabFiltres, array('siege'=>$ciblage['siege']));
|
||||
|
||||
if (isset($ciblage['dep']) && count($ciblage['dep'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('dep'=>$ciblage['dep']));
|
||||
elseif (isset($ciblage['reg']) && count($ciblage['reg'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('reg'=>$ciblage['reg']));
|
||||
/* elseif (isset($_POST['strCP']) && $_POST['strCP']<>"" && $_POST['strCP']<>$strIni) {
|
||||
die($_POST['strCP']);
|
||||
$where.=' AND adr_dep IN ('.implode(',', $_POST['dep']).')';
|
||||
} else
|
||||
$where.=' AND adr_dep BETWEEN 0 AND 999';*/
|
||||
|
||||
/** @todo Faire des tranches de Capital
|
||||
if (isset($_POST['capitalMin']) && $_POST['capitalMin']*1>0)
|
||||
$where.=' AND capital>='.$_POST['capitalMin']*1;
|
||||
|
||||
if (isset($_POST['capitalMax']) && $_POST['capitalMax']*1>0)
|
||||
$where.=' AND capital<='.$_POST['capitalMax']*1;
|
||||
|
||||
if (isset($_POST['capitalDev']) && trim($_POST['capitalDev'])<>'')
|
||||
$where.=" AND capitalDev IN ('','".$_POST['capitalDev']."')";
|
||||
|
||||
if (!isset($_POST['capitalMin']) && !isset($_POST['capitalMax']))
|
||||
$where.=' AND capital>=0';
|
||||
*/
|
||||
|
||||
if (isset($ciblage['fj']) && count($ciblage['fj'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('fj'=>$ciblage['fj']));
|
||||
|
||||
if (isset($ciblage['ageMin']) && $ciblage['ageMin']*1>0 &&
|
||||
isset($ciblage['ageMax']) && $ciblage['ageMax']*1>0) {
|
||||
$tabFiltresTmp=array();
|
||||
for ($i=$ciblage['ageMin']; $i<=$ciblage['ageMax']; $i++)
|
||||
$tabFiltresTmp[]=$i;
|
||||
$tabFiltres=array_merge($tabFiltres, array('age_entrep'=>$tabFiltresTmp));
|
||||
}
|
||||
|
||||
if (isset($ciblage['teffen']) && count($ciblage['teffen'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('teff_entrep'=>$ciblage['teffen']));
|
||||
if (isset($ciblage['teffet']) && count($ciblage['teffet'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('teff_etab'=>$ciblage['teffet']));
|
||||
|
||||
if (isset($ciblage['tca']) && count($ciblage['tca'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('tca'=>$ciblage['tca']));
|
||||
if (isset($ciblage['tcaexp']) && count($ciblage['tcaexp'])>0)
|
||||
$tabFiltres=array_merge($tabFiltres, array('tcaexp'=>$ciblage['tcaexp']));
|
||||
|
||||
if (isset($ciblage['nafEn']) && count($ciblage['nafEn'])>0)
|
||||
$where.=' @ape_entrep '.implode('|', $ciblage['nafEn']).' ';
|
||||
|
||||
if (isset($ciblage['nafEt']) && count($ciblage['nafEt'])>0)
|
||||
$where.=' @ape_etab '.implode('|', $ciblage['nafEt']).' ';
|
||||
/*
|
||||
if (isset($_POST['nafEt']) && count($_POST['nafEt'])>0)
|
||||
$where.=" AND ape_etab IN ('".implode("','", $_POST['nafEt'])."')";
|
||||
*/
|
||||
|
||||
//$_SESSION['where']=$where;
|
||||
$_SESSION['csvFile']=DIR_CSV. $_SESSION['userId'].'-'.md5($where) .'.csv';
|
||||
|
||||
/** [strCP] => codes séparés par des espaces, points, points-vigules ou sauts de lignes
|
||||
[strInsee] => codes séparés par des espaces, points, points-vigules ou sauts de lignes
|
||||
[triCode] => all
|
||||
**/
|
||||
|
||||
//echo '<pre>'.print_r($_POST).'</pre><br/>';
|
||||
|
||||
$ret=comptage($where, $tabFiltres, $deb, $nbRep, $maxRep, $pertinence, $_SESSION['csvFile']);
|
||||
//print_r($ret);
|
||||
$liste=$ret['results'];
|
||||
$nb=$ret['nbTot'];
|
||||
$duree=$ret['duration'];
|
||||
$tabMots=$ret['words'];
|
||||
/*
|
||||
$ret=@$iDb->select('jo.etablissements_old', 'count(*) AS nb', $where, false, MYSQL_ASSOC);
|
||||
$sql_error=mysql_error();
|
||||
=$ret['0']['nb'];*/
|
||||
?>
|
||||
<script>if (confirm('Votre sélection porte sur <?=$nb?> établissements.Voulez vous lancer extraires les informations ?\n<?=$sql_error?>?>')) window.location='./?choix=1&nb=<?=$nb?>';</script>
|
||||
<a href="" onclick=""
|
||||
<?
|
||||
} elseif (isset($_REQUEST['choix']) && isset($_REQUEST['nb']) && $_REQUEST['choix']==1) {
|
||||
|
||||
$nb=$_REQUEST['nb']*1+1;
|
||||
$tabFich=array();
|
||||
|
||||
if (file_exists($_SESSION['csvFile'])) $tabFich=file($_SESSION['csvFile']);
|
||||
|
||||
if (count($tabFich)<>$nb) {
|
||||
$sql="SELECT $fields FROM jo.etablissements_old WHERE ".$_SESSION['where'];
|
||||
echo "<code>$sql</code><br/>";
|
||||
$nbLignes=@$iDb->exportCSV($sql, $_SESSION['csvFile']);
|
||||
$nb=$nbLignes;
|
||||
}
|
||||
//echo '<b><a href="./'. $_SESSION['csvFile'] .'">'.$_SESSION['csvFile'].'</a></b><br/>';
|
||||
$size=round(filesize($_SESSION['csvFile'])/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($_SESSION['csvFile']));
|
||||
|
||||
echo "<a href=\"./". $_SESSION['csvFile'].'">'.$_SESSION['csvFile']."</a> $nb lignes, le $dateHeure ($size Ko) <a href=\"./extraction.php\">Enrichir</a><br/>";
|
||||
|
||||
$dh = opendir(DIR_CSV);
|
||||
while (false !== ($filename = readdir($dh))) {
|
||||
$tmp=explode('-', $filename);
|
||||
if ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && basename($_SESSION['csvFile'])<>$filename && $_SESSION['userId']==$tmp[0]) {
|
||||
//$tabFichier[] = $filename;
|
||||
$size=round(filesize(DIR_CSV.$filename)/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime(DIR_CSV.$filename));
|
||||
$nb=count(file(DIR_CSV.$filename));
|
||||
echo '<a href="'.DIR_CSV.$filename.'">'.DIR_CSV.$filename."</a> $nb lignes, le $dateHeure ($size Ko)
|
||||
<a href=\"./extraction.php?csvFile=".DIR_CSV.$filename.'">Enrichir</a><br/>';
|
||||
}
|
||||
}
|
||||
//sort($tabFichier);
|
||||
?>
|
||||
<br/><a href="./">Retourner au comptage</a>
|
||||
<?
|
||||
die();
|
||||
}/* elseif (isset($_REQUEST['choix']) && $_REQUEST['choix']==2) {
|
||||
if (file_exists($_SESSION['csvFile']))
|
||||
$csvFile=$_SESSION['csvFile'];
|
||||
else
|
||||
$csvFile=$_REQUEST['csvFile'];
|
||||
|
||||
?>
|
||||
<table border="0">
|
||||
<form action="extraction.php" method="POST">
|
||||
<!--<input type="hidden" name="choix" value="3">-->
|
||||
<input type="hidden" name="csvFile" value="<?=$csvFile?>">
|
||||
<tr><td><input type="checkbox" name="data[siretValide]"> Vérifier la validité du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[siretEnBase]"> Vérifier la présence en base du siren/siret</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[APRM]"> APRM</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTIVNAT]"> ACTIVNAT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ORIGINE]"> Origine de création</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODET]"> MODET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLET]"> EXPLET</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[LIEUACT]"> LIEUACT</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[ACTISURF]"> ACTISURF</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MODEN]"> MODEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[PRODPART]"> PRODPART</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EXPLEN]"> EXPLEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOREG]"> Mono-régionalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[REGIMP]"> Principle région d'implantation</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[MONOACT]"> Mono-activité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[DCREN]"> Date de création de l'entreprise</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[AUXILT]"> Auxiliarité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[SAISONAT]"> Saisonnalité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CIVILITE]"> Civilité</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ENT]"> Effectif de l'entreprise</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="identite[DCRET]"> Date de création de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[EFF_ET]"> Effectif de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[CODEVOIE]"> Code voie</td></tr>
|
||||
<tr><td><input type="checkbox" name="identite[dateUpdate]"> Date de mise à jour Insee</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="notice[insRPET]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDEPCOMEN]"> Code commune INSEE du siège</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRPEN]"> RPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insARRONET]"> Arrondissement de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insCTONET]"> Canton de l'établissement</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTCD]"> Tranche de commune détaillée</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insZEMET]"> ZEMET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insDU]"> DU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insTU]"> TU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insUU]"> UU</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insRECME]"> RECME</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANT]"> EAEANT</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPET]"> EAEAPET</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1T]"> EAESEC1T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2T]"> EAESEC2T</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEANN]"> EAEANN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAEAPEN]"> EAEAPEN</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC1N]"> insEAESEC1N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC2N]"> insEAESEC2N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC3N]"> insEAESEC3N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[insEAESEC4N]"> insEAESEC4N</td></tr>
|
||||
<tr><td><input type="checkbox" name="notice[dateNotice]"> Date de la dernière notice MAJ</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="data[tva]"> Numéro de TVA</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[isin]"> Code ISIN</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[tel]"> Téléphone</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[fax]"> Fax</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[web]"> Site Web</td></tr>
|
||||
<tr><td><input type="checkbox" name="infos[mail]"> Adresse email</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées GPS</td></tr>
|
||||
<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées Lambert 2</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[actif]"> Entreprise active RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[actif]"> Etablissement actif RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[numRC2]"> Numéro RC</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[siege]"> Etablissement siège RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[raisonSociale]"> Raison Sociale RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[sigle]"> Sigle RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateNaiss]"> Date Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[lieuNaiss]"> Lieu de Naissance PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[nationalite]"> Nationalité PP</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[pays]"> Pays</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[naf]"> NAF Entreprise RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[naf]"> NAF Etablissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[cj]"> Forme Juridique RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateImma]"> Date Immatriculation RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[dateRad]"> Date de radiation RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[capitalType]"> Type de capital</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_entrep[flux]"> Date MAJ entreprise RNCS</td></tr>
|
||||
|
||||
<tr><td><input type="checkbox" name="rncs_etab[enseigne]"> Enseigne de l'établissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[nomCommercial]"> Nom Commerical de l'établissement RNCS</td></tr>
|
||||
<tr><td><input type="checkbox" name="rncs_etab[flux]"> Date MAJ établissement RNCS</td></tr>
|
||||
|
||||
<tr><td align="center"><input name="btSubmit" type="submit" onclick="this.value='...';this.disabled=true;" value="Extraire"> <input type="reset" onclick="btSubmit.value='Extraire';btSubmit.disabled=false;"></td></tr>
|
||||
|
||||
</table>
|
||||
<?
|
||||
die();
|
||||
} /*elseif (isset($_REQUEST['choix']) && $_REQUEST['choix']==3) {
|
||||
|
||||
$tabFich=array();
|
||||
if (file_exists($_SESSION['csvFile']))
|
||||
$csvFile=$_SESSION['csvFile'];
|
||||
else
|
||||
$csvFile=$_REQUEST['csvFile'];
|
||||
|
||||
$tabFich=file($csvFile);
|
||||
|
||||
$pos=array();
|
||||
$csvFile2=str_replace('.csv', '-'.date('mdHi').'.csv', $csvFile);
|
||||
$fp = fopen($csvFile2, 'a');
|
||||
|
||||
foreach ($tabFich as $i=>$ligne) {
|
||||
$ligne=trim($ligne);
|
||||
if ($i==0) {
|
||||
$lib=explode(',', $ligne);
|
||||
foreach ($lib as $j=>$titre) {
|
||||
switch (strtoupper($titre)) {
|
||||
case 'SIREN': $pos['SIREN']=$j; break;
|
||||
case 'NIC': $pos['NIC']=$j; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (count($_POST['identite'])>0) $str['identite']=implode(',', array_keys($_POST['identite']));
|
||||
if (count($_POST['notice'])>0) $str['notice']=implode(',', array_keys($_POST['notice']));
|
||||
if (count($_POST['rncs_entrep'])>0) $str['rncs_entrep']=implode(',', array_keys($_POST['rncs_entrep']));
|
||||
if (count($_POST['rncs_etab'])>0) $str['rncs_etab']=implode(',', array_keys($_POST['rncs_etab']));
|
||||
if (count($_POST['infos'])>0) $str['infos']=implode(',', array_keys($_POST['infos']));
|
||||
}
|
||||
else {
|
||||
$cel=explode(',', $ligne);
|
||||
if (count($_POST['identite'])>0) {
|
||||
$str['identite']=str_replace('on','',implode(',', $_POST['identite']));
|
||||
$ret=$iDb->select('insee.identite', implode(',', array_keys($_POST['identite'])), 'SIREN='.$cel[$pos['SIREN']].' AND NIC='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_entrep']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['notice'])>0) {
|
||||
$str['notice']=str_replace('on','',implode(',', $_POST['notice']));
|
||||
$ret=$iDb->select('insee.insee_notices', implode(',', array_keys($_POST['notice'])), 'insSIREN='.$cel[$pos['SIREN']].' AND insNIC='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['notice']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['rncs_entrep'])>0) {
|
||||
$str['rncs_entrep']=str_replace('on','',implode(',', $_POST['rncs_entrep']));
|
||||
$ret=$iDb->select('jo.rncs_entrep', implode(',', array_keys($_POST['rncs_entrep'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_entrep']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['rncs_etab'])>0) {
|
||||
$str['rncs_etab']=str_replace('on','',implode(',', $_POST['rncs_etab']));
|
||||
$ret=$iDb->select('jo.rncs_etab', implode(',', array_keys($_POST['rncs_etab'])), 'siren='.$cel[$pos['SIREN']].' AND nic='.$cel[$pos['NIC']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['rncs_etab']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if (count($_POST['infos'])>0) {
|
||||
$str['infos']=str_replace('on','',implode(',', $_POST['infos']));
|
||||
$ret=$iDb->select('jo.infos_entrep', implode(',', array_keys($_POST['infos'])), 'siren='.$cel[$pos['SIREN']], false, MYSQL_ASSOC);
|
||||
if (isset($ret[0])) $str['infos']=implode(',', $ret[0]);
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
}
|
||||
/*<tr><td><input type="checkbox" name="data[latLon]"> Coordonnées Lambert 2</td></tr>
|
||||
fwrite($fp, "$ligne,". $str['identite'].','.
|
||||
$str['notice'].','.
|
||||
$str['rncs_entrep'].','.
|
||||
$str['rncs_etab'].','.
|
||||
EOL);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$size=round(filesize($csvFile2)/1024);
|
||||
$dateHeure=date('d/m/Y H:i:s', filemtime($csvFile2));
|
||||
|
||||
echo '<a href="'.$csvFile2.'">'.$csvFile2."</a> $i lignes, le $dateHeure ($size Ko)<br/>";
|
||||
?>
|
||||
<br/><a href="Javascript:history.back();">Retourner à la page précédente</a>
|
||||
<?
|
||||
die();
|
||||
}*/
|
||||
|
||||
if (true) {
|
||||
?>
|
||||
<table border="0">
|
||||
<form action="" method="POST">
|
||||
<input type="hidden" name="submited" value="1">
|
||||
|
||||
<tr><td><b><u>Etablissements</u></b></td>
|
||||
<td>
|
||||
<select name="ciblage[actif]">
|
||||
<option value="2" selected>Actifs ou inactifs</option>
|
||||
<option value="1">Actifs uniquement</option>
|
||||
<option value="0">Inactifs</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Type d'Etablissements</u></b></td>
|
||||
<td>
|
||||
<select name="ciblage[siege]">
|
||||
<option value="2" selected>Tous les établissements</option>
|
||||
<option value="1">Uniquement les sièges</option>
|
||||
<option value="0">Uniquement les secondaires</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Présence du téléphone</u></b></td>
|
||||
<td>
|
||||
<select name="ciblage[tel]">
|
||||
<option value="2" selected>Avec ou sans téléphone</option>
|
||||
<option value="1">Uniquement avec téléphone</option>
|
||||
<option value="0">Uniquement sans téléphone</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>Présence du fax</u></b></td>
|
||||
<td>
|
||||
<select name="ciblage[fax]">
|
||||
<option value="2" selected>Avec ou sans fax</option>
|
||||
<option value="1">Uniquement avec fax</option>
|
||||
<option value="0">Uniquement sans fax</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Départements</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="ciblage[dep][]">
|
||||
<?
|
||||
$ret=$iDb->select('insee.departements', 'numdep, libdep', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['numdep']?>"><?=$dep['libdep']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Régions</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="ciblage[reg][]">
|
||||
<?
|
||||
$ret=$iDb->select('insee.regions', 'REGION,NCCENR', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['REGION']?>"><?=$dep['NCCENR']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>Codes postaux</u></b></td>
|
||||
<td><textarea name="ciblage[strCP]" value="" cols="30" rows="3" onfocus="if (this.value=='<?=$strIni?>') this.value='';"><?=$strIni?></textarea></td>
|
||||
|
||||
<tr><td><b><u>Codes Communes Insee</u></b></td>
|
||||
<td><textarea name="ciblage[strInsee]" value="" cols="30" rows="3" onfocus="if (this.value=='<?=$strIni?>') this.value='';"><?=$strIni?></textarea></td>
|
||||
|
||||
<tr><td><b><u>Capital entre</u></b></td>
|
||||
<td><input type="text" name="ciblage[capitalMin]" value="0" size="10" maxlength="15">
|
||||
et <input type="text" name="ciblage[capitalMax]" value="" size="10" maxlength="15"> <select size="1" name="ciblage[capitalDev]">
|
||||
<option value="EUR" selected>EUROS</option>
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabDevises', 'devIso, devNom', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dev) {
|
||||
?>
|
||||
<option value="<?=$dev['devIso']?>"><?=$dev['devNom']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><b><u>Forme Juridique</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="ciblage[fj][]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabFJur', 'code, libelle', 'code>999', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['code']?>"><?=$dep['code'].' '.$dep['libelle']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>NAF Entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="ciblage[nafEn][]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabNaf5', 'codNaf5, libNaf5', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['codNaf5']?>"><?=$dep['codNaf5'].' '.$dep['libNaf5']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>NAF Etablissement</u></b></td>
|
||||
<td>
|
||||
<select multiple size="5" name="ciblage[nafEt][]">
|
||||
<?
|
||||
$ret=$iDb->select('jo.tabNaf5', 'codNaf5, libNaf5', '1', false, MYSQL_ASSOC);
|
||||
foreach($ret as $dep) {
|
||||
?>
|
||||
<option value="<?=$dep['codNaf5']?>"><?=$dep['codNaf5'].' '.$dep['libNaf5']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Age de l'entreprise entre</u></b></td>
|
||||
<td><input type="text" name="ciblage[ageMin]" value="0" size="10" maxlength="15">
|
||||
et <input type="text" name="ciblage[ageMax]" value="" size="10" maxlength="15">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><b><u>Chiffre d'Affaire de l'entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple name="ciblage[tca][]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 500 000 à 1 M€</option>
|
||||
<option value="2" selected>de 1 à 2 M€</option>
|
||||
<option value="3" selected>de 2 à 5 M€</option>
|
||||
<option value="4" selected>de 5 à 10 M€</option>
|
||||
<option value="5" selected>de 10 à 20 M€</option>
|
||||
<option value="6" selected>de 20 à 50 M€</option>
|
||||
<option value="7" selected>de 50 à 100 M€</option>
|
||||
<option value="8" selected>de 100 à 200 M€</option>
|
||||
<option value="9" selected>plus de 200 M€</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>Part de Chiffre d'Affaire à l'export</u></b></td>
|
||||
<td>
|
||||
<select multiple name="ciblage[tcaexp][]">
|
||||
<option value="0" selected>0%</option>
|
||||
<option value="1" selected>moins de 5%</option>
|
||||
<option value="2" selected>de 5 à 25%</option>
|
||||
<option value="3" selected>de 25 à 50%</option>
|
||||
<option value="4" selected>plus de 50%</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b><u>Nombre d'établissements secondaires</u></b></td>
|
||||
<td>
|
||||
|
||||
<select multiple name="ciblage[nbEtab][]">
|
||||
<option value="0" selected>aucun</option>
|
||||
<option value="1" selected>1</option>
|
||||
<option value="2" selected>2</option>
|
||||
<option value="3" selected>3</option>
|
||||
<option value="4" selected>4</option>
|
||||
<option value="5" selected>5 à 9</option>
|
||||
<option value="6" selected>10 à 19</option>
|
||||
<option value="7" selected>20 à 49</option>
|
||||
<option value="8" selected>50 à 99</option>
|
||||
<option value="9" selected>100 ou +</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
sql_attr_uint =
|
||||
<tr><td><b><u>Effectif de l'entreprise</u></b></td>
|
||||
<td>
|
||||
<select multiple name="ciblage[teffen][]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 1 à 2 salarié(s)</option>
|
||||
<option value="2" selected>de 3 à 5 salariés</option>
|
||||
<option value="3" selected>de 6 à 9 salariés</option>
|
||||
<option value="11" selected>de 10 à 19 salariés</option>
|
||||
<option value="12" selected>de 20 à 49 salariés</option>
|
||||
<option value="21" selected>de 50 à 99 salariés</option>
|
||||
<option value="22" selected>de 100 à 199 salariés</option>
|
||||
<option value="31" selected>de 200 à 249 salariés</option>
|
||||
<option value="32" selected>de 250 à 499 salariés</option>
|
||||
<option value="41" selected>de 500 à 999 salariés</option>
|
||||
<option value="42" selected>de 1 000 à 1 999 salariés</option>
|
||||
<option value="51" selected>de 2 000 à 4 999 salariés</option>
|
||||
<option value="52" selected>de 5 000 à 9 999 salariés</option>
|
||||
<option value="53" selected>plus de 10 000 salariés</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Effectif de l'établissement</u></b></td>
|
||||
<td>
|
||||
<select multiple name="ciblage[teffet][]">
|
||||
<option value="0" selected>N/C</option>
|
||||
<option value="1" selected>de 1 à 2 salarié(s)</option>
|
||||
<option value="2" selected>de 3 à 5 salariés</option>
|
||||
<option value="3" selected>de 6 à 9 salariés</option>
|
||||
<option value="11" selected>de 10 à 19 salariés</option>
|
||||
<option value="12" selected>de 20 à 49 salariés</option>
|
||||
<option value="21" selected>de 50 à 99 salariés</option>
|
||||
<option value="22" selected>de 100 à 199 salariés</option>
|
||||
<option value="31" selected>de 200 à 249 salariés</option>
|
||||
<option value="32" selected>de 250 à 499 salariés</option>
|
||||
<option value="41" selected>de 500 à 999 salariés</option>
|
||||
<option value="42" selected>de 1 000 à 1 999 salariés</option>
|
||||
<option value="51" selected>de 2 000 à 4 999 salariés</option>
|
||||
<option value="52" selected>de 5 000 à 9 999 salariés</option>
|
||||
<option value="53" selected>plus de 10 000 salariés</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Sources</u></b></td>
|
||||
<td>
|
||||
<select multiple name="ciblage[source][]">
|
||||
<option value="2" selected>INSEE : Sirene</option>
|
||||
<option value="3" selected>JO : Associations</option>
|
||||
<option value="1" selected>JO : Bodacc</option>
|
||||
<option value="5" selected>RNCS : Inpi</option>
|
||||
<option value="4" selected>TC : Greffes</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><b><u>Tribunaux</u></b></td>
|
||||
<td>
|
||||
<select name="ciblage[triCode]">
|
||||
<option value="all">Tous les tribunaux</option>
|
||||
<?
|
||||
foreach($iBodacc->getListeTribunaux() as $t=>$tri) {
|
||||
?>
|
||||
<option value="<?=$t?>"><?=$tri['nom']?></option>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td> </td>
|
||||
<td align="center"><input name="btSubmit" type="submit" onclick="this.value='...';this.disabled=true;" value="Lancer le comptage"> <input type="reset" onclick="btSubmit.value='Lancer le comptage';btSubmit.disabled=false;"></td></tr>
|
||||
|
||||
</form>
|
||||
</table>
|
||||
<!--
|
||||
|
||||
|
||||
autre_id
|
||||
siren
|
||||
nic
|
||||
actif
|
||||
siege
|
||||
adr_cp
|
||||
adr_ville
|
||||
adr_dep
|
||||
tel
|
||||
fax
|
||||
cj
|
||||
capital
|
||||
capitalDev
|
||||
ape_etab
|
||||
ape_entrep
|
||||
-->
|
||||
<?
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
34
html/fichierclient/README
Normal file
@ -0,0 +1,34 @@
|
||||
Le module APC est utile à l'upload pour la barre de progression mais pas nécessaire.
|
||||
|
||||
Configuration APC
|
||||
|
||||
[apc]
|
||||
apc.enable_cli = Off
|
||||
apc.enabled = On
|
||||
apc.cache_by_default = Off // => Voir explication
|
||||
apc.file_update_protection = 2
|
||||
apc.filters =
|
||||
apc.ttl = 0
|
||||
apc.user_ttl = 0
|
||||
apc.gc_ttl = 3600
|
||||
apc.include_once_override = Off
|
||||
apc.max_file_size = 1M
|
||||
apc.mmap_file_mask =
|
||||
apc.num_files_hint = 1000
|
||||
apc.optimization = 0
|
||||
apc.report_autofilter = Off
|
||||
apc.shm_segments = 1
|
||||
apc.shm_size = 30
|
||||
apc.slam_defense = 0
|
||||
apc.stat = On
|
||||
apc.user_entries_hint = 100
|
||||
apc.write_lock = On
|
||||
apc.rfc1867 = On
|
||||
|
||||
Explication :
|
||||
"apc.cache_by_default = Off" désactive la mise en cache bien que le module est activé
|
||||
|
||||
Dans un .htaccess ou dans <Directory>
|
||||
php_flag apc.cache_by_default On
|
||||
|
||||
|
25
html/fichierclient/config/config.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
define('UPLOAD_DIR', realpath(dirname(__FILE__)).'/../files');
|
||||
|
||||
define('POST_MAX_SIZE', '50M');
|
||||
define('UPLOAD_MAX_FILESIZE', '40M');
|
||||
|
||||
define('FILE_EXT', 'csv');
|
||||
|
||||
// Paramètres de la base de données
|
||||
define ('MYSQL_HOST', '192.168.3.22');
|
||||
define ('MYSQL_DB', 'fichierclient');
|
||||
define ('MYSQL_USER', 'root');
|
||||
define ('MYSQL_PASS', 'bzh4231*');
|
||||
|
||||
// Configuration PHP
|
||||
$phpini_config = array(
|
||||
'post_max_size' => POST_MAX_SIZE,
|
||||
'upload_max_filesize' => UPLOAD_MAX_FILESIZE,
|
||||
'file_uploads' => 1,
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
25
html/fichierclient/css/jquery.checkbox.css
Normal file
@ -0,0 +1,25 @@
|
||||
.jquery-checkbox {display: inline; font-size: 20px; line-height: 20px; cursor: pointer; cursor: hand;}
|
||||
.jquery-checkbox .mark {display: inline;}
|
||||
|
||||
.jquery-checkbox img {vertical-align: middle; width: 60px; height: 20px;}
|
||||
.jquery-checkbox img{background: transparent url(../img/checkbox.png) no-repeat;}
|
||||
|
||||
.jquery-checkbox img{
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.jquery-checkbox-hover img{
|
||||
background-position: 0px -20px;
|
||||
}
|
||||
.jquery-checkbox-checked img{
|
||||
background-position: 0px -40px;
|
||||
}
|
||||
.jquery-checkbox-checked .jquery-checkbox-hover img {
|
||||
background-position: 0px -60px;
|
||||
}
|
||||
|
||||
.jquery-checkbox-disabled img{
|
||||
background-position: 0px -80px;
|
||||
}
|
||||
.jquery-checkbox-checked .jquery-checkbox-disabled img{
|
||||
background-position: 0px -100px;
|
||||
}
|
25
html/fichierclient/css/jquery.safari-checkbox.css
Normal file
@ -0,0 +1,25 @@
|
||||
.jquery-safari-checkbox {display: inline; font-size: 16px; line-height: 16px; cursor: pointer; cursor: hand;}
|
||||
.jquery-safari-checkbox .mark {display: inline;}
|
||||
|
||||
.jquery-safari-checkbox img {vertical-align: middle; width: 16px; height: 16px;}
|
||||
.jquery-safari-checkbox img{background: transparent url(../img/safari-checkbox.png) no-repeat;}
|
||||
|
||||
.jquery-safari-checkbox img{
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.jquery-safari-checkbox-hover img{
|
||||
background-position: -16px 0px;
|
||||
}
|
||||
.jquery-safari-checkbox-checked img{
|
||||
background-position: 0px -16px;
|
||||
}
|
||||
.jquery-safari-checkbox-checked .jquery-safari-checkbox-hover img {
|
||||
background-position: -16px -16px;
|
||||
}
|
||||
|
||||
.jquery-safari-checkbox-disabled img{
|
||||
background-position: 0px -32px;
|
||||
}
|
||||
.jquery-safari-checkbox-checked .jquery-safari-checkbox-disabled img{
|
||||
background-position: 0px -48px;
|
||||
}
|
5
html/fichierclient/css/style-ie.css
Normal file
@ -0,0 +1,5 @@
|
||||
.clearfix {
|
||||
zoom: 1; /* triggers hasLayout */
|
||||
} /* Only IE can see inside the conditional comment
|
||||
and read this CSS rule. Don't ever use a normal HTML
|
||||
comment inside the CC or it will close prematurely. */
|
39
html/fichierclient/css/style.css
Normal file
@ -0,0 +1,39 @@
|
||||
body {
|
||||
margin: 0; /* pour éviter les marges */
|
||||
text-align: center; /* pour corriger le bug de centrage IE */
|
||||
font:normal normal 0.8em Arial,Verdana,Sans-serif;
|
||||
}
|
||||
|
||||
#container {
|
||||
position:relative; /* on positionne le conteneur */
|
||||
width:960px;
|
||||
margin:0 auto;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
#upload { float:left; width:45%; margin:0 0 10px 0; padding:0; }
|
||||
#files { float:right; width:45%; margin:0 0 10px 0; padding:0; }
|
||||
#main { clear:both; width:100%; margin:10px auto 0 auto; }
|
||||
|
||||
#colonne {}
|
||||
#colonne ul { list-style-type:none; }
|
||||
#colonne ul li { float:left; display:inline; margin:5px; padding:8px; background-color:#F6A828; }
|
||||
#colonne ul li span.identifiant { display:inline; margin:0 5px; padding:5px; background-color:#EEEEEE; border:1px solid #DDDDDD; }
|
||||
|
||||
#identifiant { clear:both; }
|
||||
#identifiant ul { list-style-type:none; }
|
||||
#identifiant ul li { float:left; display:inline; }
|
||||
#identifiant .identifiant { margin:5px; padding:5px; background-color:#EEEEEE; border:1px solid #DDDDDD; }
|
||||
|
||||
#traitements ul { list-style-type:none; padding:0; }
|
||||
|
||||
.action_fichier { display:none; margin:0; padding:0; }
|
||||
.action_fichier ul {margin:0; padding:0; list-style-type:none; border:1px solid #DDDDDD; background-color:#EEEEEE; }
|
||||
|
||||
.clearfix:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
20468
html/fichierclient/files/20090728_extraction_des_tiers_mercure.csv
Normal file
BIN
html/fichierclient/img/progressbar.gif
Normal file
After Width: | Height: | Size: 120 B |
BIN
html/fichierclient/img/progressbg_black.gif
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
html/fichierclient/img/progressbg_green.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
html/fichierclient/img/progressbg_orange.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
html/fichierclient/img/progressbg_red.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
html/fichierclient/img/progressbg_yellow.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
5
html/fichierclient/includes/block.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
function block_header(){}
|
||||
|
||||
function block_footer(){}
|
1
html/fichierclient/includes/bootstrap.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
24
html/fichierclient/includes/include.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/FirePHPCore/FirePHP.class.php';
|
||||
// Démarrage de l'environnement
|
||||
ob_start();
|
||||
$firephp = FirePHP::getInstance(true);
|
||||
|
||||
// Gestionnaire de chemin
|
||||
require_once realpath(dirname(__FILE__)).'/path.php';
|
||||
|
||||
// Configuration
|
||||
require_once realpath(dirname(__FILE__)).'/../config/config.php';
|
||||
|
||||
//
|
||||
require_once realpath(dirname(__FILE__)).'/bootstrap.php';
|
||||
|
||||
// Connection mysql
|
||||
$link = mysql_connect (MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Problème technique');
|
||||
$db_selected = mysql_select_db(MYSQL_DB, $link);
|
||||
if (!$db_selected) { die ('Problème technique.'); }
|
||||
|
||||
// Charset
|
||||
$charset = mysql_client_encoding($link);
|
||||
$firephp->info("Charset de communication :".$charset);
|
||||
if( $charset=='latin1' ) mysql_query("SET NAMES utf8");
|
8
html/fichierclient/includes/module.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
function module_invoke_all(){}
|
||||
|
||||
function module_invoke(){}
|
||||
|
||||
function module_list(){}
|
||||
|
||||
|
151
html/fichierclient/includes/mysql.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
class WDB {
|
||||
|
||||
private $host;
|
||||
private $database;
|
||||
private $user;
|
||||
private $password;
|
||||
private $con_id; // Connection ID with MySQL
|
||||
private $result;
|
||||
|
||||
public function __construct($database='', $host='', $user='', $password='') {
|
||||
|
||||
if ($host=='') $this->host=MYSQL_HOST;
|
||||
else $this->host=$host;
|
||||
if ($user=='') $this->user=MYSQL_USER;
|
||||
else $this->user=$user;
|
||||
if ($password=='') $this->password=MYSQL_PASS;
|
||||
else $this->password=$password;
|
||||
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
|
||||
else $this->database=$database;
|
||||
|
||||
$this->con_id = mysql_pconnect($this->host, $this->user, $this->password);
|
||||
if (!($this->con_id === false)) {
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setCharSet($charSet) {
|
||||
return (mysql_query("SET CHARACTER SET $charSet;", $this->con_id));
|
||||
}
|
||||
|
||||
/** INSERTION d'un tableau dans une table.
|
||||
** Les index doivent avoir les mêmes noms que les champs.
|
||||
** @param string Table
|
||||
** @param array Valeurs insérer
|
||||
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
|
||||
**/
|
||||
public function insert($table, $toAdd, $debug=false){
|
||||
$fields = implode(array_keys($toAdd), '`,`');
|
||||
foreach (array_values($toAdd) as $key=>$array_values)
|
||||
$tmp[$key]=checkaddslashes($array_values);
|
||||
|
||||
$values = "'".implode(array_values($tmp), "','")."'"; # better
|
||||
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res = mysql_query($query, $this->con_id);
|
||||
if ($res!==false)
|
||||
{
|
||||
if (mysql_insert_id()>0)
|
||||
$res=mysql_insert_id();
|
||||
else
|
||||
$res=true;
|
||||
}
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function update($table, $update, $where, $debug=false){
|
||||
$fields = array_keys($update);
|
||||
$values = array_values($update);
|
||||
$i=0;
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
while(isset($fields[$i])){
|
||||
if($i>0) { $query.=', '; }
|
||||
$query.=' `'.$fields[$i]."`='".addslashes($values[$i])."'";
|
||||
$i++;
|
||||
}
|
||||
$query.=' WHERE '.$where.' LIMIT 1;';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete($table, $where, $debug=false) {
|
||||
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
$query="SELECT $fields FROM $table WHERE $where;";
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$this->result=mysql_query($query, $this->con_id);// or die(mysql_error());
|
||||
if (mysql_errno()) die(mysql_errno() .' : '. mysql_error());
|
||||
// echo $query;
|
||||
if (!$huge) {
|
||||
$tab=array();
|
||||
while ($ligne = mysql_fetch_array($this->result, $assoc))
|
||||
$tab[]=$ligne;
|
||||
|
||||
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
|
||||
return $tab;
|
||||
} else {
|
||||
$nbRows=mysql_num_rows($this->result);
|
||||
if ($debug) $this->trace($query, $nbRows, $tdeb);
|
||||
return $nbRows;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch($assoc=MYSQL_BOTH) {
|
||||
return mysql_fetch_array($this->result, $assoc);
|
||||
}
|
||||
|
||||
public function trace($query, $res='', $tdeb=-1) {
|
||||
if (!$fp=fopen('mysql_insert.log', 'a'))
|
||||
return false;
|
||||
$errnum=mysql_errno($this->con_id);
|
||||
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
else $duree='N/D';
|
||||
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
|
||||
return false;
|
||||
if (!fclose($fp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Exécute la requête passé en paramètre **/
|
||||
public function query($query, $debug=false){
|
||||
return mysql_query($query, $this->con_id);
|
||||
}
|
||||
|
||||
/** Retourne le libellé de la dernière erreur **/
|
||||
public function getLastErrorMsg() {
|
||||
return mysql_error($this->con_id);
|
||||
}
|
||||
/** Retourne le numéro de la dernière erreur **/
|
||||
public function getLastErrorNum() {
|
||||
return mysql_errno($this->con_id);
|
||||
}
|
||||
|
||||
/** Retourne le libellé et le numéro de la dernière erreur **/
|
||||
public function getLastError() {
|
||||
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
38
html/fichierclient/includes/path.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Return a component of the current path.
|
||||
*
|
||||
* When viewing a page at the path "admin/content/types", for example, arg(0)
|
||||
* would return "admin", arg(1) would return "content", and arg(2) would return
|
||||
* "types".
|
||||
*
|
||||
* @param $index
|
||||
* The index of the component, where each component is separated by a '/'
|
||||
* (forward-slash), and where the first component has an index of 0 (zero).
|
||||
*
|
||||
* @return
|
||||
* The component specified by $index, or NULL if the specified component was
|
||||
* not found.
|
||||
*/
|
||||
function arg($index = NULL, $path = NULL) {
|
||||
static $arguments;
|
||||
|
||||
if (!isset($path)) {
|
||||
$path = $_GET['q'];
|
||||
}
|
||||
if (!isset($arguments[$path])) {
|
||||
$arguments[$path] = explode('/', $path);
|
||||
}
|
||||
if (!isset($index)) {
|
||||
return $arguments[$path];
|
||||
}
|
||||
if (isset($arguments[$path][$index])) {
|
||||
return $arguments[$path][$index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
1
html/fichierclient/includes/theme.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
1
html/fichierclient/includes/view.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
58
html/fichierclient/index.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once 'includes/include.php';
|
||||
|
||||
$module = arg(0);
|
||||
$firephp->log($module, 'module');
|
||||
|
||||
//Inclusion des modules
|
||||
require_once realpath(dirname(__FILE__)).'/modules/fichier/functions.php';
|
||||
require_once realpath(dirname(__FILE__)).'/modules/upload/functions.php';
|
||||
//
|
||||
$head = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
|
||||
$head_title = 'Traitements fichiers';
|
||||
$styles_list = array(
|
||||
'<link rel="stylesheet" href="./css/jquery.checkbox.css" />',
|
||||
'<link rel="stylesheet" href="./css/jquery.safari-checkbox.css" />',
|
||||
'<link rel="stylesheet" href="./css/style.css" />',
|
||||
);
|
||||
$styles_ie_list = array(
|
||||
'<link rel="stylesheet" href="./css/style-ie.css" />',
|
||||
);
|
||||
|
||||
$scripts_list = array(
|
||||
'<script type="text/javascript" src="./js/jquery.js"></script>',
|
||||
'<script type="text/javascript" src="./js/jquery.progressbar.js"></script>',
|
||||
'<script type="text/javascript" src="./js/jquery-ui-1.7.2.custom.min.js"></script>',
|
||||
);
|
||||
$styles = join("\n", $styles_list);
|
||||
$styles_ie = join("\n", $styles_ie_list);
|
||||
$scripts = join("\n", $scripts_list);
|
||||
|
||||
switch($module)
|
||||
{
|
||||
default:
|
||||
case 'fichier':
|
||||
$uuid = uniqid();
|
||||
require_once realpath(dirname(__FILE__)).'/modules/fichier/fichier.php';
|
||||
break;
|
||||
case 'traitements';
|
||||
$firephp->info('Traitements');
|
||||
$uuid = uniqid();
|
||||
require_once realpath(dirname(__FILE__)).'/modules/fichier/fichier.php';
|
||||
require_once realpath(dirname(__FILE__)).'/modules/traitements/traitements.php';
|
||||
break;
|
||||
case 'comptage';
|
||||
$uuid = uniqid();
|
||||
require_once realpath(dirname(__FILE__)).'/modules/fichier/fichier.php';
|
||||
require_once realpath(dirname(__FILE__)).'/modules/comptage/comptage.php';
|
||||
break;
|
||||
case 'upload':
|
||||
require_once realpath(dirname(__FILE__)).'/modules/upload/upload.php';
|
||||
break;
|
||||
}
|
||||
|
||||
$block = $blocks[0];
|
||||
|
||||
//Chargement du template
|
||||
require_once 'themes/page.tpl.php';
|
||||
|
22
html/fichierclient/install.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
echo 'file_uploads = ' . ini_get('file_uploads') . '<br/>';
|
||||
echo 'upload_tmp_dir = ' . ini_get('upload_tmp_dir') . '<br/>';
|
||||
echo 'post_max_size = ' . ini_get('post_max_size') . '<br/>';
|
||||
echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size')) . '<br/>';
|
||||
echo 'upload_max_filesize = ' . return_bytes(ini_get('upload_max_filesize'));
|
||||
|
||||
function return_bytes($val) {
|
||||
$val = trim($val);
|
||||
$last = strtolower($val[strlen($val)-1]);
|
||||
switch($last) {
|
||||
// The 'G' modifier is available since PHP 5.1.0
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
case 'm':
|
||||
$val *= 1024;
|
||||
case 'k':
|
||||
$val *= 1024;
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
298
html/fichierclient/js/jquery-ui-1.7.2.custom.min.js
vendored
Normal file
19
html/fichierclient/js/jquery.js
vendored
Normal file
183
html/fichierclient/js/jquery.progressbar.js
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* jQuery Progress Bar plugin
|
||||
* Version 2.0 (06/22/2009)
|
||||
* @requires jQuery v1.2.1 or later
|
||||
*
|
||||
* Copyright (c) 2008 Gary Teo
|
||||
* http://t.wits.sg
|
||||
|
||||
USAGE:
|
||||
$(".someclass").progressBar();
|
||||
$("#progressbar").progressBar();
|
||||
$("#progressbar").progressBar(45); // percentage
|
||||
$("#progressbar").progressBar({showText: false }); // percentage with config
|
||||
$("#progressbar").progressBar(45, {showText: false }); // percentage with config
|
||||
*/
|
||||
(function($) {
|
||||
$.extend({
|
||||
progressBar: new function() {
|
||||
|
||||
this.defaults = {
|
||||
steps : 20, // steps taken to reach target
|
||||
step_duration : 20,
|
||||
max : 100, // Upon 100% i'd assume, but configurable
|
||||
showText : true, // show text with percentage in next to the progressbar? - default : true
|
||||
textFormat : 'percentage', // Or otherwise, set to 'fraction'
|
||||
width : 120, // Width of the progressbar - don't forget to adjust your image too!!! // Image to use in the progressbar. Can be a single image too: 'images/progressbg_green.gif'
|
||||
height : 12, // Height of the progressbar - don't forget to adjust your image too!!!
|
||||
callback : null, // Calls back with the config object that has the current percentage, target percentage, current image, etc
|
||||
boxImage : 'img/progressbar.gif', // boxImage : image around the progress bar
|
||||
barImage : {
|
||||
0: 'img/progressbg_red.gif',
|
||||
30: 'img/progressbg_orange.gif',
|
||||
70: 'img/progressbg_green.gif'
|
||||
},
|
||||
|
||||
|
||||
// Internal use
|
||||
running_value : 0,
|
||||
value : 0,
|
||||
image : null
|
||||
};
|
||||
|
||||
/* public methods */
|
||||
this.construct = function(arg1, arg2) {
|
||||
var argvalue = null;
|
||||
var argconfig = null;
|
||||
|
||||
if (arg1 != null) {
|
||||
if (!isNaN(arg1)) {
|
||||
argvalue = arg1;
|
||||
if (arg2 != null) {
|
||||
argconfig = arg2;
|
||||
}
|
||||
} else {
|
||||
argconfig = arg1;
|
||||
}
|
||||
}
|
||||
|
||||
return this.each(function(child) {
|
||||
var pb = this;
|
||||
var config = this.config;
|
||||
|
||||
if (argvalue != null && this.bar != null && this.config != null) {
|
||||
this.config.value = argvalue
|
||||
if (argconfig != null)
|
||||
pb.config = $.extend(this.config, argconfig);
|
||||
config = pb.config;
|
||||
} else {
|
||||
var $this = $(this);
|
||||
var config = $.extend({}, $.progressBar.defaults, argconfig);
|
||||
config.id = $this.attr('id') ? $this.attr('id') : Math.ceil(Math.random() * 100000); // random id, if none provided
|
||||
|
||||
if (argvalue == null)
|
||||
argvalue = $this.html().replace("%","") // parse percentage
|
||||
|
||||
config.value = argvalue;
|
||||
config.running_value = 0;
|
||||
config.image = getBarImage(config);
|
||||
|
||||
$this.html("");
|
||||
var bar = document.createElement('img');
|
||||
var text = document.createElement('span');
|
||||
var $bar = $(bar);
|
||||
var $text = $(text);
|
||||
pb.bar = $bar;
|
||||
|
||||
$bar.attr('id', config.id + "_pbImage");
|
||||
$text.attr('id', config.id + "_pbText");
|
||||
$text.html(getText(config));
|
||||
$bar.attr('title', getText(config));
|
||||
$bar.attr('alt', getText(config));
|
||||
$bar.attr('src', config.boxImage);
|
||||
$bar.attr('width', config.width);
|
||||
$bar.css("width", config.width + "px");
|
||||
$bar.css("height", config.height + "px");
|
||||
$bar.css("background-image", "url(" + config.image + ")");
|
||||
$bar.css("background-position", ((config.width * -1)) + 'px 50%');
|
||||
$bar.css("padding", "0");
|
||||
$bar.css("margin", "0");
|
||||
$this.append($bar);
|
||||
$this.append($text);
|
||||
}
|
||||
|
||||
function getPercentage(config) {
|
||||
return config.running_value * 100 / config.max;
|
||||
}
|
||||
|
||||
function getBarImage(config) {
|
||||
var image = config.barImage;
|
||||
if (typeof(config.barImage) == 'object') {
|
||||
for (var i in config.barImage) {
|
||||
if (config.running_value >= parseInt(i)) {
|
||||
image = config.barImage[i];
|
||||
} else { break; }
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
function getText(config) {
|
||||
if (config.showText) {
|
||||
if (config.textFormat == 'percentage') {
|
||||
return " " + Math.round(config.running_value) + "%";
|
||||
} else if (config.textFormat == 'fraction') {
|
||||
return " " + config.running_value + '/' + config.max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.increment = Math.round((config.value - config.running_value)/config.steps);
|
||||
if (config.increment < 0)
|
||||
config.increment *= -1;
|
||||
if (config.increment < 1)
|
||||
config.increment = 1;
|
||||
|
||||
var t = setInterval(function() {
|
||||
var pixels = config.width / 100; // Define how many pixels go into 1%
|
||||
var stop = false;
|
||||
|
||||
if (config.running_value > config.value) {
|
||||
if (config.running_value - config.increment < config.value) {
|
||||
config.running_value = config.value;
|
||||
} else {
|
||||
config.running_value -= config.increment;
|
||||
}
|
||||
}
|
||||
else if (config.running_value < config.value) {
|
||||
if (config.running_value + config.increment > config.value) {
|
||||
config.running_value = config.value;
|
||||
} else {
|
||||
config.running_value += config.increment;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.running_value == config.value)
|
||||
clearInterval(t);
|
||||
|
||||
var $bar = $("#" + config.id + "_pbImage");
|
||||
var $text = $("#" + config.id + "_pbText");
|
||||
var image = getBarImage(config);
|
||||
if (image != config.image) {
|
||||
$bar.css("background-image", "url(" + image + ")");
|
||||
config.image = image;
|
||||
}
|
||||
$bar.css("background-position", (((config.width * -1)) + (getPercentage(config) * pixels)) + 'px 50%');
|
||||
$bar.attr('title', getText(config));
|
||||
$text.html(getText(config));
|
||||
|
||||
if (config.callback != null && typeof(config.callback) == 'function')
|
||||
config.callback(config);
|
||||
|
||||
pb.config = config;
|
||||
}, config.step_duration);
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
$.fn.extend({
|
||||
progressBar: $.progressBar.construct
|
||||
});
|
||||
|
||||
})(jQuery);
|
0
html/fichierclient/js/scripts.js
Normal file
32
html/fichierclient/modules/comptage/comptage.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/functions.php';
|
||||
|
||||
$file = arg(1);
|
||||
$action = arg(2);
|
||||
|
||||
$comptage = new StdClass();
|
||||
|
||||
switch($action)
|
||||
{
|
||||
default:
|
||||
$html = '<h3>Informations fichier</h3>';
|
||||
$html.= '<p>Nom : '.$file.'</p>';
|
||||
$html.= '<p>Taille : '.formatSize(filesize(UPLOAD_DIR.'/'.$file)).'</p>';
|
||||
$html.= '<p>Nombre de lignes : '.fichier_nblignes($file).'</p>';
|
||||
$html.= '<p>Nombre de colonnes : '.count(fichier_colonne($file, '')).'</p>';
|
||||
|
||||
$html.= '<h3>Statistiques fichier</h3>';
|
||||
$html.= '<table>';
|
||||
$html.= '';
|
||||
$html.= '</table>';
|
||||
|
||||
$content = new StdClass();
|
||||
$content->module = 'comptage';
|
||||
$content->subject = 'Informations / Comptage - ' . $file;
|
||||
$content->content = $html;
|
||||
$content->delta = 0;
|
||||
$blocks[] = $content;
|
||||
|
||||
//Vérification après traitement
|
||||
break;
|
||||
}
|
42
html/fichierclient/modules/comptage/functions.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la taille plus l'unité arrondie
|
||||
*
|
||||
* @param mixed $bytes taille en octets
|
||||
* @param string $format formatage (http://www.php.net/manual/fr/function.sprintf.php)
|
||||
* @param string $lang indique la langue des unités de taille
|
||||
* @return string chaine de caractères formatées
|
||||
*/
|
||||
function formatSize($bytes, $format = '%.2f', $lang = 'en')
|
||||
{
|
||||
static $units = array(
|
||||
'fr' => array( 'o', 'Ko', 'Mo', 'Go', 'To' ),
|
||||
'en' => array( 'B', 'KB', 'MB', 'GB', 'TB')
|
||||
);
|
||||
|
||||
$translatedUnits = &$units[$lang];
|
||||
if(isset($translatedUnits) === false)
|
||||
{
|
||||
$translatedUnits = &$units['en'];
|
||||
}
|
||||
$b = (double)$bytes;
|
||||
/*On gére le cas des tailles de fichier négatives*/
|
||||
if($b > 0)
|
||||
{
|
||||
$e = (int)(log($b,1024));
|
||||
/**Si on a pas l'unité on retourne en To*/
|
||||
if(isset($translatedUnits[$e]) === false)
|
||||
{
|
||||
$e = 4;
|
||||
}
|
||||
$b = $b/pow(1024,$e);
|
||||
}
|
||||
else
|
||||
{
|
||||
$b = 0;
|
||||
$e = 0;
|
||||
}
|
||||
return sprintf($format.' %s',$b,$translatedUnits[$e]);
|
||||
}
|
19
html/fichierclient/modules/config/config.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
function return_bytes($val) {
|
||||
$val = trim($val);
|
||||
$last = strtolower($val[strlen($val)-1]);
|
||||
switch($last) {
|
||||
// The 'G' modifier is available since PHP 5.1.0
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
case 'm':
|
||||
$val *= 1024;
|
||||
case 'k':
|
||||
$val *= 1024;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
function config_check(){}
|
||||
|
||||
function config_set(){}
|
149
html/fichierclient/modules/fichier/fichier.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/functions.php';
|
||||
$view = arg(1);
|
||||
$file = arg(2);
|
||||
|
||||
$fichier = new StdClass();
|
||||
|
||||
$listefichier = fichier_liste(UPLOAD_DIR);
|
||||
|
||||
switch($view)
|
||||
{
|
||||
case 'open':
|
||||
|
||||
break;
|
||||
case 'delete':
|
||||
fichier_delete(UPLOAD_DIR.'/'.$file);
|
||||
fichier_bdddelete($file);
|
||||
header('Location: index.php');
|
||||
break;
|
||||
case 'colonne':
|
||||
|
||||
// Chargement des données du fichier
|
||||
$ligne_colonne = fichier_colonne($file, '');
|
||||
$colonne = array_merge( array( 'Numéro de la ligne') , $ligne_colonne );
|
||||
|
||||
$associations = fichier_get_associations($file);
|
||||
|
||||
if(arg(3)=='valider')
|
||||
{
|
||||
if($associations!=false && $associations!=''){
|
||||
$sql = "UPDATE fichiers SET associations_lock=1 WHERE nom='$file'";
|
||||
$result = mysql_query($sql);
|
||||
$message = 'Les associations de colonnes ont été enregistrées.';
|
||||
$disable = TRUE;
|
||||
}else{
|
||||
$message = 'Vous n\'avez pas associé d\'identifiant S&D avec les colonnes du fichier.';
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($disable))
|
||||
{
|
||||
$sql = "SELECT associations_lock FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['associations_lock']==TRUE){ $disable = TRUE;}
|
||||
}
|
||||
|
||||
$firephp->log($associations, 'associations');
|
||||
if($associations!==FALSE){ $champs = $associations; }
|
||||
if(!isset($champs))
|
||||
{
|
||||
$champs = array();
|
||||
foreach ($colonne as $c){
|
||||
$champs[]['colonne'] = $c;
|
||||
}
|
||||
}
|
||||
$firephp->log($champs, 'Champ');
|
||||
//Liste des identifiants Scores et Décisions
|
||||
$identifiant = array('Siren / Siret', 'Référence Client');
|
||||
|
||||
// Action
|
||||
$action = arg(3);
|
||||
if($action == 'assoc')
|
||||
{
|
||||
$col = $_REQUEST['col'];
|
||||
$id = $_REQUEST['id'];
|
||||
|
||||
$firephp->info('Enregistrement des associations');
|
||||
$firephp->log($col, 'colonne');
|
||||
$firephp->log($id, 'identifiant');
|
||||
|
||||
$champs[$col]['id'] = $identifiant[$id];
|
||||
|
||||
$sql = "SELECT associations FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$associations = serialize($champs);
|
||||
if(!$result){
|
||||
$sql = "INSERT INTO fichiers (nom, associations) VALUES ('$file', '$associations');";
|
||||
$insert = mysql_query($sql);
|
||||
}else{
|
||||
$sql = "UPDATE fichiers SET associations='$associations' WHERE nom='$file';";
|
||||
$insert = mysql_query($sql);
|
||||
}
|
||||
$firephp->log($sql, 'SQL');
|
||||
|
||||
if($insert===FALSE) echo "Erreur lors de l'enregistrement";
|
||||
exit;
|
||||
}
|
||||
|
||||
if($action == 'delete')
|
||||
{
|
||||
$sql = "UPDATE fichiers SET associations='', traitements='' WHERE nom='$file';";
|
||||
mysql_query($sql);
|
||||
header('Location: index.php?q='.$module.'/'.$view.'/'.$file);
|
||||
exit;
|
||||
}
|
||||
|
||||
$html = '<div id="message">'.$message.'</div>';
|
||||
$html.= '<ul>';
|
||||
$html.= '<li><a href="./index.php?'.$_SERVER['QUERY_STRING'].'/delete">Réinitialiser</a></li>';
|
||||
$html.= '<li><a href="./index.php?'.$_SERVER['QUERY_STRING'].'/valider">Valider les associations</a></li>';
|
||||
$html.= '</ul>';
|
||||
|
||||
$html.= '<div id="colonne">';
|
||||
$html.= '<span>Intitulé colonne du fichier</span>';
|
||||
$html.= '<ul>';
|
||||
$i=0;
|
||||
foreach($champs as $champ)
|
||||
{
|
||||
$html.='<li class="drop" id="'.$i.'">';
|
||||
$html.='<span>'.$champ['colonne'].'</span>';
|
||||
if(isset($champ['id']) && $champ['id']!='')
|
||||
{
|
||||
$html.= '<span class="identifiant">'.$champ['id'].'</span>';
|
||||
}
|
||||
$html.='</li>';
|
||||
$i++;
|
||||
}
|
||||
$html.= '</ul>';
|
||||
$html.= '</div>';
|
||||
|
||||
$html.='<div id="identifiant">';
|
||||
$html.='<span>Identifiant Scores et Décisions</span>';
|
||||
$html.= '<ul>';
|
||||
$i=0;
|
||||
foreach($identifiant as $id)
|
||||
{
|
||||
$use = false;
|
||||
foreach($champs as $champ) { if(isset($champ['id']) && $champ['id']==$id){ $use = true; } }
|
||||
if(!$use)
|
||||
{
|
||||
!isset($disable)? $class = 'class="identifiant drag"' : $class = 'class="identifiant"';
|
||||
$html.= '<li ><span '.$class.' id="'.$i.'">'.$id.'</span></li>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$html.= '</ul>';
|
||||
$html.= '</div>';
|
||||
|
||||
$content = new StdClass();
|
||||
$content->module = 'fichier';
|
||||
$content->delta = '';
|
||||
$content->subject = 'Identification des colonnes - '.$file;
|
||||
$content->content = $html;
|
||||
$blocks[] = $content;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
145
html/fichierclient/modules/fichier/functions.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Liste les fichiers dans le répertoire d'importation
|
||||
* @param string $directory
|
||||
* @return array
|
||||
*/
|
||||
function fichier_liste($directory)
|
||||
{
|
||||
$return = array();
|
||||
if (is_dir($directory))
|
||||
{
|
||||
if ($dh = opendir($directory))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if(filetype($directory.'/'.$file) == 'file')
|
||||
{
|
||||
$return[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lit un fichier CSV
|
||||
* @param string $file
|
||||
* @param string $separateur
|
||||
* @param boolean $first_line
|
||||
* @return array
|
||||
*/
|
||||
function fichier_read_csv($file, $separateur, $first_line = false)
|
||||
{
|
||||
if($separateur == ''){ $separateur = ';'; }
|
||||
if($fp = fopen(UPLOAD_DIR.'/'.$file,"r"))
|
||||
{
|
||||
$content = array();
|
||||
$ligne_num = 0;
|
||||
while ($ligne = fgetcsv($fp, '', $separateur)) {
|
||||
foreach($ligne as $elem) { $content[$ligne_num][] = $elem; }
|
||||
$ligne_num++;
|
||||
if($first_line) break;
|
||||
}
|
||||
fclose ($fp);
|
||||
} else {
|
||||
$content = false;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les colonnes d'un fichier CSV
|
||||
* @param string $file
|
||||
* @param string $separateur
|
||||
* @return array
|
||||
*/
|
||||
function fichier_colonne($file, $separateur)
|
||||
{
|
||||
$content = fichier_read_csv($file, $separateur, true);
|
||||
return $content[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime un fichier
|
||||
* @param string $path_to_file
|
||||
* @return boolean
|
||||
*/
|
||||
function fichier_delete($path_to_file)
|
||||
{
|
||||
if(file_exists($path_to_file)) return unlink($path_to_file);
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime la référence à un fichier dans la bdd
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function fichier_bdddelete($file)
|
||||
{
|
||||
$result = mysql_query("DELETE FROM fichiers WHERE nom='$file';");
|
||||
}
|
||||
|
||||
/**
|
||||
* Détermine le nombre de ligne dans le fichier
|
||||
* @param string $name
|
||||
* @return int ou boolean
|
||||
*/
|
||||
function fichier_nblignes($name)
|
||||
{
|
||||
$lines = file(UPLOAD_DIR.'/'.$name);
|
||||
if($lines != false) return count($lines);
|
||||
else return false;
|
||||
}
|
||||
|
||||
function fichier_informations($file)
|
||||
{
|
||||
$result = mysql_query("SELECT associations, traitements FROM fichiers WHERE nom='$file';");
|
||||
$return = FALSE;
|
||||
if($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['associations']!='' || $row['traitements']!='' ) $return = TRUE;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les associations correspondant au fichier
|
||||
* @param $name
|
||||
* @return unknown_type
|
||||
*/
|
||||
function fichier_get_associations($name)
|
||||
{
|
||||
$sql = "SELECT associations FROM fichiers WHERE nom='$name';";
|
||||
$result = mysql_query($sql);
|
||||
$return = FALSE;
|
||||
if($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['associations']!='') $return = unserialize($row['associations']);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les traitements correspondant au fichier
|
||||
* @param $name
|
||||
* @return unknown_type
|
||||
*/
|
||||
function fichier_get_traitements($name)
|
||||
{
|
||||
$sql = "SELECT traitements FROM fichiers WHERE nom='$name';";
|
||||
$result = mysql_query($sql);
|
||||
$return = FALSE;
|
||||
if($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['traitements']!='') $return = unserialize($row['traitements']);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
137
html/fichierclient/modules/traitements/traitements.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
//require_once realpath(dirname(__FILE__)).'/functions.php';
|
||||
|
||||
$file = arg(1);
|
||||
$action = arg(2);
|
||||
$firephp->log($action, 'action');
|
||||
|
||||
switch($action){
|
||||
case 'add':
|
||||
isset($_REQUEST['choices'])? $choix = $_REQUEST['choices'] : $choix = '';
|
||||
$sql = "SELECT traitements FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
if($choix!='') { $traitements = serialize($choix); } else { $traitements = ''; }
|
||||
if(!$result){
|
||||
$sql = "INSERT INTO fichiers (nom, traitements) VALUES ('$file', '$traitements');";
|
||||
$insert = mysql_query($sql);
|
||||
}else{
|
||||
$sql = "UPDATE fichiers SET traitements='$traitements' WHERE nom='$file';";
|
||||
$insert = mysql_query($sql);
|
||||
}
|
||||
|
||||
$firephp->log($sql, 'SQL');
|
||||
if($insert===FALSE) echo "Erreur lors de l'enregistrement";
|
||||
exit;
|
||||
break;
|
||||
case 'start':
|
||||
$firephp->info('Lancement des traitements');
|
||||
//Vérifier si les colonnes ont été identifiés
|
||||
$sql = "SELECT associations FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['associations']!=''){ $associations = true; }
|
||||
|
||||
$sql = "SELECT associations_lock FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$associations_lock = false;
|
||||
if($row['associations_lock']==true){ $associations_lock = true;}
|
||||
|
||||
//Vérifier qu'il y a au moins un traitement
|
||||
$sql = "SELECT traitements FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$traitements = false;
|
||||
if($row['traitements']!=''){ $traitements = true;}
|
||||
|
||||
$sql = "SELECT traitements_lock FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$traitements_lock = false;
|
||||
if($row['traitements_lock']==true){ $traitements_lock = true;}
|
||||
|
||||
//Message
|
||||
$html = '<p>';
|
||||
if(!$associations)
|
||||
{
|
||||
$html.= 'Erreur : Aucune identification de colonnes.<br/>';
|
||||
}
|
||||
if(!$associations_lock)
|
||||
{
|
||||
$html.= 'Les association n\'ont pas été validées, cliquez <a href="./index.php?q=fichier/colonne/'.$file.'">ici</a> pour valider les associations<br/>';
|
||||
}
|
||||
if(!$traitements)
|
||||
{
|
||||
$html.= 'Erreur : Aucun traitement sélectionné<br/>';
|
||||
}
|
||||
if(!$traitements_lock)
|
||||
{
|
||||
$html.= 'Les traitements n\'ont pas été validées, cliquez <a href="./index.php?q=traitements/'.$file.'">ici</a> pour valider les associations<br/>';
|
||||
}
|
||||
$html.= '</p>';
|
||||
//Définition du bloc
|
||||
$content = new StdClass();
|
||||
$content->module = 'traitements';
|
||||
$content->subject = 'Lancement des traitements - ' . $file;
|
||||
$content->content = $html;
|
||||
$content->delta = 0;
|
||||
$blocks[] = $content;
|
||||
|
||||
//Lancer le traitement en tache de fond jusqu'a ce que le fichier soit présent
|
||||
|
||||
|
||||
break;
|
||||
case 'valider':
|
||||
$traitements = fichier_get_traitements($file);
|
||||
if($traitements!=false && $traitements!=''){
|
||||
$sql = "UPDATE fichiers SET traitements_lock=1 WHERE nom='$file'";
|
||||
$result = mysql_query($sql);
|
||||
$message = 'Les traitements ont été enregistrés.';
|
||||
$disable = TRUE;
|
||||
}else{
|
||||
$message = 'Vous n\'avez selectionné aucun traitement.';
|
||||
}
|
||||
default :
|
||||
//Liste des traitements
|
||||
$traitements_list = array('Validation SIREN/SIRET', 'Vérification SIREN/SIRET dans la base S&D');
|
||||
$traitements = fichier_get_traitements($file);
|
||||
|
||||
if(!isset($disable))
|
||||
{
|
||||
$sql = "SELECT traitements_lock FROM fichiers WHERE nom='$file';";
|
||||
$result = mysql_query($sql);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
if($row['traitements_lock']==TRUE){ $disable = TRUE;}
|
||||
}
|
||||
|
||||
$html = '<div id="message"></div>';
|
||||
|
||||
$html.= '<ul>';
|
||||
$html.= '<li><a href="./index.php?'.$_SERVER['QUERY_STRING'].'/valider" title="">Valider les choix de traitements</a></li>';
|
||||
$html.= '<li><a href="./index.php?'.$_SERVER['QUERY_STRING'].'/start" title="">Lancer les traitements</a></li>';
|
||||
$html.= '</ul>';
|
||||
|
||||
$html.= '<div id="traitements">';
|
||||
$html.= '<p><i>( Sélectionner les traitements que vous souhaitez appliquer au fichier )</i></p>';
|
||||
$html.= '<ul>';
|
||||
|
||||
foreach($traitements_list as $t)
|
||||
{
|
||||
$checked = '';
|
||||
if($traitements!='' && in_array($t, $traitements)){$checked='checked';}
|
||||
$disabled='';
|
||||
if($disable===TRUE){$disabled='disabled';}
|
||||
$html.= '<li><input type="checkbox" name="choix_traitements[]" value="'.$t.'" '.$checked.' '.$disabled.'/><label>'.$t.'</label></li>';
|
||||
}
|
||||
$html.= '</ul>';
|
||||
$html.= '</div>';
|
||||
|
||||
$content = new StdClass();
|
||||
$content->module = 'traitements';
|
||||
$content->subject = 'Choix des traitements - ' . $file;
|
||||
$content->content = $html;
|
||||
$content->delta = 0;
|
||||
$blocks[] = $content;
|
||||
|
||||
break;
|
||||
}
|
121
html/fichierclient/modules/upload/functions.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Filtre les noms de fichier pour éliminer les caractères indésirables
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
function filtre_filename($filename){
|
||||
$filename = str_replace(' ', '_', $filename); // Replacer les espaces
|
||||
$filename = cleanstring($filename); // Supprimer les caractères illégaux
|
||||
$filename = strtolower($filename); //Supprimer les majuscules
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtre les extensions de fichiers autorisés
|
||||
* @param string $filename
|
||||
* @return boolean
|
||||
*/
|
||||
function filtre_extension($filename)
|
||||
{
|
||||
$extensions = explode(';', FILE_EXT);
|
||||
$ext = array_pop(explode('.',$filename));
|
||||
$valid = false;
|
||||
foreach($extensions as $extension){
|
||||
if($extension==$ext) { $valid = true; break; }
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up a string value.
|
||||
*
|
||||
* Resulting string contains only alphanumerics and separators.
|
||||
*
|
||||
* @param $string
|
||||
* A string to clean.
|
||||
* @param $clean_slash
|
||||
* Whether to clean slashes from the given string.
|
||||
* @return
|
||||
* The cleaned string.
|
||||
*/
|
||||
function cleanstring($string) {
|
||||
global $firephp;
|
||||
$transliterate = TRUE;
|
||||
$reduce_ascii = FALSE;
|
||||
$output = utf8_encode($string);
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
|
||||
// Reduce to the subset of ASCII96 letters and numbers
|
||||
if ($reduce_ascii) {
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$output = preg_replace($pattern, $separator, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le nombre de ligne d'un fichier
|
||||
* @param string $file
|
||||
* @return int ou false
|
||||
*/
|
||||
function nblignes($file)
|
||||
{
|
||||
$lines = file($file);
|
||||
if($lines != FALSE) return count($lines);
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le nombre de colonne d'un fichier csv
|
||||
* @param string $file
|
||||
* @param string $separateur
|
||||
* @return int
|
||||
*/
|
||||
function nbcolonne($file, $separateur = '')
|
||||
{
|
||||
$nbcolonne = 0;
|
||||
if($separateur == ''){ $separateur = ';'; }
|
||||
if($fp = fopen(UPLOAD_DIR.'/'.$file,"r"))
|
||||
{
|
||||
$ligne = fgetcsv($fp, '', $separateur);
|
||||
foreach($ligne as $elem) { $nbcolonne++; }
|
||||
fclose ($fp);
|
||||
}
|
||||
return $nbcolonne;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traite le fichier envoyé
|
||||
* @param string $tmp_name
|
||||
* @param string $name
|
||||
* @param string $new_name
|
||||
* @return void
|
||||
*/
|
||||
function upload($tmp_name, $name, $new_name)
|
||||
{
|
||||
//Gestion du fichier sur le système
|
||||
move_uploaded_file($tmp_name, UPLOAD_DIR.'/'.$name);
|
||||
copy(UPLOAD_DIR.'/'.$name, UPLOAD_DIR.'/'.$new_name);
|
||||
if(file_exists(UPLOAD_DIR.'/'.$name)) unlink(UPLOAD_DIR.'/'.$name);
|
||||
//Ecriture du nom fichier dans la bdd
|
||||
if(file_exists(UPLOAD_DIR.'/'.$new_name)){
|
||||
$lignes = nblignes(UPLOAD_DIR.'/'.$new_name);
|
||||
mysql_query('INSERT INTO fichiers (nom, nblignes) VALUES ('.$new_name.','.$lignes.');');
|
||||
}
|
||||
}
|
565
html/fichierclient/modules/upload/i18n-ascii.example.txt
Normal file
@ -0,0 +1,565 @@
|
||||
; global transliteration
|
||||
[default]
|
||||
À = "A"
|
||||
Á = "A"
|
||||
 = "A"
|
||||
à = "A"
|
||||
Ä = "Ae"
|
||||
Å = "A"
|
||||
Æ = "A"
|
||||
Ā = "A"
|
||||
Ą = "A"
|
||||
Ă = "A"
|
||||
Ç = "C"
|
||||
Ć = "C"
|
||||
Č = "C"
|
||||
Ĉ = "C"
|
||||
Ċ = "C"
|
||||
Ď = "D"
|
||||
Đ = "D"
|
||||
È = "E"
|
||||
É = "E"
|
||||
Ê = "E"
|
||||
Ë = "E"
|
||||
Ē = "E"
|
||||
Ę = "E"
|
||||
Ě = "E"
|
||||
Ĕ = "E"
|
||||
Ė = "E"
|
||||
Ĝ = "G"
|
||||
Ğ = "G"
|
||||
Ġ = "G"
|
||||
Ģ = "G"
|
||||
Ĥ = "H"
|
||||
Ħ = "H"
|
||||
Ì = "I"
|
||||
Í = "I"
|
||||
Î = "I"
|
||||
Ï = "I"
|
||||
Ī = "I"
|
||||
Ĩ = "I"
|
||||
Ĭ = "I"
|
||||
Į = "I"
|
||||
İ = "I"
|
||||
IJ = "IJ"
|
||||
Ĵ = "J"
|
||||
Ķ = "K"
|
||||
Ľ = "K"
|
||||
Ĺ = "K"
|
||||
Ļ = "K"
|
||||
Ŀ = "K"
|
||||
Ł = "L"
|
||||
Ñ = "N"
|
||||
Ń = "N"
|
||||
Ň = "N"
|
||||
Ņ = "N"
|
||||
Ŋ = "N"
|
||||
Ò = "O"
|
||||
Ó = "O"
|
||||
Ô = "O"
|
||||
Õ = "O"
|
||||
Ö = "Oe"
|
||||
Ø = "O"
|
||||
Ō = "O"
|
||||
Ő = "O"
|
||||
Ŏ = "O"
|
||||
Œ = "OE"
|
||||
Ŕ = "R"
|
||||
Ř = "R"
|
||||
Ŗ = "R"
|
||||
Ś = "S"
|
||||
Ş = "S"
|
||||
Ŝ = "S"
|
||||
Ș = "S"
|
||||
Š = "S"
|
||||
Ť = "T"
|
||||
Ţ = "T"
|
||||
Ŧ = "T"
|
||||
Ț = "T"
|
||||
Ù = "U"
|
||||
Ú = "U"
|
||||
Û = "U"
|
||||
Ü = "Ue"
|
||||
Ū = "U"
|
||||
Ů = "U"
|
||||
Ű = "U"
|
||||
Ŭ = "U"
|
||||
Ũ = "U"
|
||||
Ų = "U"
|
||||
Ŵ = "W"
|
||||
Ŷ = "Y"
|
||||
Ÿ = "Y"
|
||||
Ý = "Y"
|
||||
Ź = "Z"
|
||||
Ż = "Z"
|
||||
Ž = "Z"
|
||||
à = "a"
|
||||
á = "a"
|
||||
â = "a"
|
||||
ã = "a"
|
||||
ä = "ae"
|
||||
ā = "a"
|
||||
ą = "a"
|
||||
ă = "a"
|
||||
å = "a"
|
||||
æ = "ae"
|
||||
ç = "c"
|
||||
ć = "c"
|
||||
č = "c"
|
||||
ĉ = "c"
|
||||
ċ = "c"
|
||||
ď = "d"
|
||||
đ = "d"
|
||||
è = "e"
|
||||
é = "e"
|
||||
ê = "e"
|
||||
ë = "e"
|
||||
ē = "e"
|
||||
ę = "e"
|
||||
ě = "e"
|
||||
ĕ = "e"
|
||||
ė = "e"
|
||||
ƒ = "f"
|
||||
ĝ = "g"
|
||||
ğ = "g"
|
||||
ġ = "g"
|
||||
ģ = "g"
|
||||
ĥ = "h"
|
||||
ħ = "h"
|
||||
ì = "i"
|
||||
í = "i"
|
||||
î = "i"
|
||||
ï = "i"
|
||||
ī = "i"
|
||||
ĩ = "i"
|
||||
ĭ = "i"
|
||||
į = "i"
|
||||
ı = "i"
|
||||
ij = "ij"
|
||||
ĵ = "j"
|
||||
ķ = "k"
|
||||
ĸ = "k"
|
||||
ł = "l"
|
||||
ľ = "l"
|
||||
ĺ = "l"
|
||||
ļ = "l"
|
||||
ŀ = "l"
|
||||
ñ = "n"
|
||||
ń = "n"
|
||||
ň = "n"
|
||||
ņ = "n"
|
||||
ʼn = "n"
|
||||
ŋ = "n"
|
||||
ò = "o"
|
||||
ó = "o"
|
||||
ô = "o"
|
||||
õ = "o"
|
||||
ö = "oe"
|
||||
ø = "o"
|
||||
ō = "o"
|
||||
ő = "o"
|
||||
ŏ = "o"
|
||||
œ = "oe"
|
||||
ŕ = "r"
|
||||
ř = "r"
|
||||
ŗ = "r"
|
||||
ś = "s"
|
||||
š = "s"
|
||||
ş = "s"
|
||||
ť = "t"
|
||||
ţ = "t"
|
||||
ù = "u"
|
||||
ú = "u"
|
||||
û = "u"
|
||||
ü = "ue"
|
||||
ū = "u"
|
||||
ů = "u"
|
||||
ű = "u"
|
||||
ŭ = "u"
|
||||
ũ = "u"
|
||||
ų = "u"
|
||||
ŵ = "w"
|
||||
ÿ = "y"
|
||||
ý = "y"
|
||||
ŷ = "y"
|
||||
ż = "z"
|
||||
ź = "z"
|
||||
ž = "z"
|
||||
ß = "ss"
|
||||
ſ = "ss"
|
||||
Α = "A"
|
||||
Ά = "A"
|
||||
Ἀ = "A"
|
||||
Ἁ = "A"
|
||||
Ἂ = "A"
|
||||
Ἃ = "A"
|
||||
Ἄ = "A"
|
||||
Ἅ = "A"
|
||||
Ἆ = "A"
|
||||
Ἇ = "A"
|
||||
ᾈ = "A"
|
||||
ᾉ = "A"
|
||||
ᾊ = "A"
|
||||
ᾋ = "A"
|
||||
ᾌ = "A"
|
||||
ᾍ = "A"
|
||||
ᾎ = "A"
|
||||
ᾏ = "A"
|
||||
Ᾰ = "A"
|
||||
Ᾱ = "A"
|
||||
Ὰ = "A"
|
||||
Ά = "A"
|
||||
ᾼ = "A"
|
||||
Β = "B"
|
||||
Γ = "G"
|
||||
Δ = "D"
|
||||
Ε = "E"
|
||||
Έ = "E"
|
||||
Ἐ = "E"
|
||||
Ἑ = "E"
|
||||
Ἒ = "E"
|
||||
Ἓ = "E"
|
||||
Ἔ = "E"
|
||||
Ἕ = "E"
|
||||
Έ = "E"
|
||||
Ὲ = "E"
|
||||
Ζ = "Z"
|
||||
Η = "I"
|
||||
Ή = "I"
|
||||
Ἠ = "I"
|
||||
Ἡ = "I"
|
||||
Ἢ = "I"
|
||||
Ἣ = "I"
|
||||
Ἤ = "I"
|
||||
Ἥ = "I"
|
||||
Ἦ = "I"
|
||||
Ἧ = "I"
|
||||
ᾘ = "I"
|
||||
ᾙ = "I"
|
||||
ᾚ = "I"
|
||||
ᾛ = "I"
|
||||
ᾜ = "I"
|
||||
ᾝ = "I"
|
||||
ᾞ = "I"
|
||||
ᾟ = "I"
|
||||
Ὴ = "I"
|
||||
Ή = "I"
|
||||
ῌ = "I"
|
||||
Θ = "TH"
|
||||
Ι = "I"
|
||||
Ί = "I"
|
||||
Ϊ = "I"
|
||||
Ἰ = "I"
|
||||
Ἱ = "I"
|
||||
Ἲ = "I"
|
||||
Ἳ = "I"
|
||||
Ἴ = "I"
|
||||
Ἵ = "I"
|
||||
Ἶ = "I"
|
||||
Ἷ = "I"
|
||||
Ῐ = "I"
|
||||
Ῑ = "I"
|
||||
Ὶ = "I"
|
||||
Ί = "I"
|
||||
Κ = "K"
|
||||
Λ = "L"
|
||||
Μ = "M"
|
||||
Ν = "N"
|
||||
Ξ = "KS"
|
||||
Ο = "O"
|
||||
Ό = "O"
|
||||
Ὀ = "O"
|
||||
Ὁ = "O"
|
||||
Ὂ = "O"
|
||||
Ὃ = "O"
|
||||
Ὄ = "O"
|
||||
Ὅ = "O"
|
||||
Ὸ = "O"
|
||||
Ό = "O"
|
||||
Π = "P"
|
||||
Ρ = "R"
|
||||
Ῥ = "R"
|
||||
Σ = "S"
|
||||
Τ = "T"
|
||||
Υ = "Y"
|
||||
Ύ = "Y"
|
||||
Ϋ = "Y"
|
||||
Ὑ = "Y"
|
||||
Ὓ = "Y"
|
||||
Ὕ = "Y"
|
||||
Ὗ = "Y"
|
||||
Ῠ = "Y"
|
||||
Ῡ = "Y"
|
||||
Ὺ = "Y"
|
||||
Ύ = "Y"
|
||||
Φ = "F"
|
||||
Χ = "X"
|
||||
Ψ = "PS"
|
||||
Ω = "O"
|
||||
Ώ = "O"
|
||||
Ὠ = "O"
|
||||
Ὡ = "O"
|
||||
Ὢ = "O"
|
||||
Ὣ = "O"
|
||||
Ὤ = "O"
|
||||
Ὥ = "O"
|
||||
Ὦ = "O"
|
||||
Ὧ = "O"
|
||||
ᾨ = "O"
|
||||
ᾩ = "O"
|
||||
ᾪ = "O"
|
||||
ᾫ = "O"
|
||||
ᾬ = "O"
|
||||
ᾭ = "O"
|
||||
ᾮ = "O"
|
||||
ᾯ = "O"
|
||||
Ὼ = "O"
|
||||
Ώ = "O"
|
||||
ῼ = "O"
|
||||
α = "a"
|
||||
ά = "a"
|
||||
ἀ = "a"
|
||||
ἁ = "a"
|
||||
ἂ = "a"
|
||||
ἃ = "a"
|
||||
ἄ = "a"
|
||||
ἅ = "a"
|
||||
ἆ = "a"
|
||||
ἇ = "a"
|
||||
ᾀ = "a"
|
||||
ᾁ = "a"
|
||||
ᾂ = "a"
|
||||
ᾃ = "a"
|
||||
ᾄ = "a"
|
||||
ᾅ = "a"
|
||||
ᾆ = "a"
|
||||
ᾇ = "a"
|
||||
ὰ = "a"
|
||||
ά = "a"
|
||||
ᾰ = "a"
|
||||
ᾱ = "a"
|
||||
ᾲ = "a"
|
||||
ᾳ = "a"
|
||||
ᾴ = "a"
|
||||
ᾶ = "a"
|
||||
ᾷ = "a"
|
||||
β = "b"
|
||||
γ = "g"
|
||||
δ = "d"
|
||||
ε = "e"
|
||||
έ = "e"
|
||||
ἐ = "e"
|
||||
ἑ = "e"
|
||||
ἒ = "e"
|
||||
ἓ = "e"
|
||||
ἔ = "e"
|
||||
ἕ = "e"
|
||||
ὲ = "e"
|
||||
έ = "e"
|
||||
ζ = "z"
|
||||
η = "i"
|
||||
ή = "i"
|
||||
ἠ = "i"
|
||||
ἡ = "i"
|
||||
ἢ = "i"
|
||||
ἣ = "i"
|
||||
ἤ = "i"
|
||||
ἥ = "i"
|
||||
ἦ = "i"
|
||||
ἧ = "i"
|
||||
ᾐ = "i"
|
||||
ᾑ = "i"
|
||||
ᾒ = "i"
|
||||
ᾓ = "i"
|
||||
ᾔ = "i"
|
||||
ᾕ = "i"
|
||||
ᾖ = "i"
|
||||
ᾗ = "i"
|
||||
ὴ = "i"
|
||||
ή = "i"
|
||||
ῂ = "i"
|
||||
ῃ = "i"
|
||||
ῄ = "i"
|
||||
ῆ = "i"
|
||||
ῇ = "i"
|
||||
θ = "th"
|
||||
ι = "i"
|
||||
ί = "i"
|
||||
ϊ = "i"
|
||||
ΐ = "i"
|
||||
ἰ = "i"
|
||||
ἱ = "i"
|
||||
ἲ = "i"
|
||||
ἳ = "i"
|
||||
ἴ = "i"
|
||||
ἵ = "i"
|
||||
ἶ = "i"
|
||||
ἷ = "i"
|
||||
ὶ = "i"
|
||||
ί = "i"
|
||||
ῐ = "i"
|
||||
ῑ = "i"
|
||||
ῒ = "i"
|
||||
ΐ = "i"
|
||||
ῖ = "i"
|
||||
ῗ = "i"
|
||||
κ = "k"
|
||||
λ = "l"
|
||||
μ = "m"
|
||||
ν = "n"
|
||||
ξ = "ks"
|
||||
ο = "o"
|
||||
ό = "o"
|
||||
ὀ = "o"
|
||||
ὁ = "o"
|
||||
ὂ = "o"
|
||||
ὃ = "o"
|
||||
ὄ = "o"
|
||||
ὅ = "o"
|
||||
ὸ = "o"
|
||||
ό = "o"
|
||||
π = "p"
|
||||
ρ = "r"
|
||||
ῤ = "r"
|
||||
ῥ = "r"
|
||||
σ = "s"
|
||||
ς = "s"
|
||||
τ = "t"
|
||||
υ = "y"
|
||||
ύ = "y"
|
||||
ϋ = "y"
|
||||
ΰ = "y"
|
||||
ὐ = "y"
|
||||
ὑ = "y"
|
||||
ὒ = "y"
|
||||
ὓ = "y"
|
||||
ὔ = "y"
|
||||
ὕ = "y"
|
||||
ὖ = "y"
|
||||
ὗ = "y"
|
||||
ὺ = "y"
|
||||
ύ = "y"
|
||||
ῠ = "y"
|
||||
ῡ = "y"
|
||||
ῢ = "y"
|
||||
ΰ = "y"
|
||||
ῦ = "y"
|
||||
ῧ = "y"
|
||||
φ = "f"
|
||||
χ = "x"
|
||||
ψ = "ps"
|
||||
ω = "o"
|
||||
ώ = "o"
|
||||
ὠ = "o"
|
||||
ὡ = "o"
|
||||
ὢ = "o"
|
||||
ὣ = "o"
|
||||
ὤ = "o"
|
||||
ὥ = "o"
|
||||
ὦ = "o"
|
||||
ὧ = "o"
|
||||
ᾠ = "o"
|
||||
ᾡ = "o"
|
||||
ᾢ = "o"
|
||||
ᾣ = "o"
|
||||
ᾤ = "o"
|
||||
ᾥ = "o"
|
||||
ᾦ = "o"
|
||||
ᾧ = "o"
|
||||
ὼ = "o"
|
||||
ώ = "o"
|
||||
ῲ = "o"
|
||||
ῳ = "o"
|
||||
ῴ = "o"
|
||||
ῶ = "o"
|
||||
ῷ = "o"
|
||||
¨ = ""
|
||||
΅ = ""
|
||||
᾿ = ""
|
||||
῾ = ""
|
||||
῍ = ""
|
||||
῝ = ""
|
||||
῎ = ""
|
||||
῞ = ""
|
||||
῏ = ""
|
||||
῟ = ""
|
||||
῀ = ""
|
||||
῁ = ""
|
||||
΄ = ""
|
||||
΅ = ""
|
||||
` = ""
|
||||
῭ = ""
|
||||
ͺ = ""
|
||||
᾽ = ""
|
||||
А = "A"
|
||||
Б = "B"
|
||||
В = "V"
|
||||
Г = "G"
|
||||
Д = "D"
|
||||
Е = "E"
|
||||
Ё = "E"
|
||||
Ж = "ZH"
|
||||
З = "Z"
|
||||
И = "I"
|
||||
Й = "I"
|
||||
К = "K"
|
||||
Л = "L"
|
||||
М = "M"
|
||||
Н = "N"
|
||||
О = "O"
|
||||
П = "P"
|
||||
Р = "R"
|
||||
С = "S"
|
||||
Т = "T"
|
||||
У = "U"
|
||||
Ф = "F"
|
||||
Х = "KH"
|
||||
Ц = "TS"
|
||||
Ч = "CH"
|
||||
Ш = "SH"
|
||||
Щ = "SHCH"
|
||||
Ы = "Y"
|
||||
Э = "E"
|
||||
Ю = "YU"
|
||||
Я = "YA"
|
||||
а = "A"
|
||||
б = "B"
|
||||
в = "V"
|
||||
г = "G"
|
||||
д = "D"
|
||||
е = "E"
|
||||
ё = "E"
|
||||
ж = "ZH"
|
||||
з = "Z"
|
||||
и = "I"
|
||||
й = "I"
|
||||
к = "K"
|
||||
л = "L"
|
||||
м = "M"
|
||||
н = "N"
|
||||
о = "O"
|
||||
п = "P"
|
||||
р = "R"
|
||||
с = "S"
|
||||
т = "T"
|
||||
у = "U"
|
||||
ф = "F"
|
||||
х = "KH"
|
||||
ц = "TS"
|
||||
ч = "CH"
|
||||
ш = "SH"
|
||||
щ = "SHCH"
|
||||
ы = "Y"
|
||||
э = "E"
|
||||
ю = "YU"
|
||||
я = "YA"
|
||||
Ъ = ""
|
||||
ъ = ""
|
||||
Ь = ""
|
||||
ь = ""
|
||||
|
||||
ð = "d"
|
||||
Ð = "D"
|
||||
þ = "th"
|
||||
Þ = "TH"
|
||||
|
565
html/fichierclient/modules/upload/i18n-ascii.txt
Normal file
@ -0,0 +1,565 @@
|
||||
; global transliteration
|
||||
[default]
|
||||
À = "A"
|
||||
Á = "A"
|
||||
 = "A"
|
||||
à = "A"
|
||||
Ä = "Ae"
|
||||
Å = "A"
|
||||
Æ = "A"
|
||||
Ā = "A"
|
||||
Ą = "A"
|
||||
Ă = "A"
|
||||
Ç = "C"
|
||||
Ć = "C"
|
||||
Č = "C"
|
||||
Ĉ = "C"
|
||||
Ċ = "C"
|
||||
Ď = "D"
|
||||
Đ = "D"
|
||||
È = "E"
|
||||
É = "E"
|
||||
Ê = "E"
|
||||
Ë = "E"
|
||||
Ē = "E"
|
||||
Ę = "E"
|
||||
Ě = "E"
|
||||
Ĕ = "E"
|
||||
Ė = "E"
|
||||
Ĝ = "G"
|
||||
Ğ = "G"
|
||||
Ġ = "G"
|
||||
Ģ = "G"
|
||||
Ĥ = "H"
|
||||
Ħ = "H"
|
||||
Ì = "I"
|
||||
Í = "I"
|
||||
Î = "I"
|
||||
Ï = "I"
|
||||
Ī = "I"
|
||||
Ĩ = "I"
|
||||
Ĭ = "I"
|
||||
Į = "I"
|
||||
İ = "I"
|
||||
IJ = "IJ"
|
||||
Ĵ = "J"
|
||||
Ķ = "K"
|
||||
Ľ = "K"
|
||||
Ĺ = "K"
|
||||
Ļ = "K"
|
||||
Ŀ = "K"
|
||||
Ł = "L"
|
||||
Ñ = "N"
|
||||
Ń = "N"
|
||||
Ň = "N"
|
||||
Ņ = "N"
|
||||
Ŋ = "N"
|
||||
Ò = "O"
|
||||
Ó = "O"
|
||||
Ô = "O"
|
||||
Õ = "O"
|
||||
Ö = "Oe"
|
||||
Ø = "O"
|
||||
Ō = "O"
|
||||
Ő = "O"
|
||||
Ŏ = "O"
|
||||
Œ = "OE"
|
||||
Ŕ = "R"
|
||||
Ř = "R"
|
||||
Ŗ = "R"
|
||||
Ś = "S"
|
||||
Ş = "S"
|
||||
Ŝ = "S"
|
||||
Ș = "S"
|
||||
Š = "S"
|
||||
Ť = "T"
|
||||
Ţ = "T"
|
||||
Ŧ = "T"
|
||||
Ț = "T"
|
||||
Ù = "U"
|
||||
Ú = "U"
|
||||
Û = "U"
|
||||
Ü = "U"
|
||||
Ū = "U"
|
||||
Ů = "U"
|
||||
Ű = "U"
|
||||
Ŭ = "U"
|
||||
Ũ = "U"
|
||||
Ų = "U"
|
||||
Ŵ = "W"
|
||||
Ŷ = "Y"
|
||||
Ÿ = "Y"
|
||||
Ý = "Y"
|
||||
Ź = "Z"
|
||||
Ż = "Z"
|
||||
Ž = "Z"
|
||||
à = "a"
|
||||
á = "a"
|
||||
â = "a"
|
||||
ã = "a"
|
||||
ä = "ae"
|
||||
ā = "a"
|
||||
ą = "a"
|
||||
ă = "a"
|
||||
å = "a"
|
||||
æ = "ae"
|
||||
ç = "c"
|
||||
ć = "c"
|
||||
č = "c"
|
||||
ĉ = "c"
|
||||
ċ = "c"
|
||||
ď = "d"
|
||||
đ = "d"
|
||||
è = "e"
|
||||
é = "e"
|
||||
ê = "e"
|
||||
ë = "e"
|
||||
ē = "e"
|
||||
ę = "e"
|
||||
ě = "e"
|
||||
ĕ = "e"
|
||||
ė = "e"
|
||||
ƒ = "f"
|
||||
ĝ = "g"
|
||||
ğ = "g"
|
||||
ġ = "g"
|
||||
ģ = "g"
|
||||
ĥ = "h"
|
||||
ħ = "h"
|
||||
ì = "i"
|
||||
í = "i"
|
||||
î = "i"
|
||||
ï = "i"
|
||||
ī = "i"
|
||||
ĩ = "i"
|
||||
ĭ = "i"
|
||||
į = "i"
|
||||
ı = "i"
|
||||
ij = "ij"
|
||||
ĵ = "j"
|
||||
ķ = "k"
|
||||
ĸ = "k"
|
||||
ł = "l"
|
||||
ľ = "l"
|
||||
ĺ = "l"
|
||||
ļ = "l"
|
||||
ŀ = "l"
|
||||
ñ = "n"
|
||||
ń = "n"
|
||||
ň = "n"
|
||||
ņ = "n"
|
||||
ʼn = "n"
|
||||
ŋ = "n"
|
||||
ò = "o"
|
||||
ó = "o"
|
||||
ô = "o"
|
||||
õ = "o"
|
||||
ö = "oe"
|
||||
ø = "o"
|
||||
ō = "o"
|
||||
ő = "o"
|
||||
ŏ = "o"
|
||||
œ = "oe"
|
||||
ŕ = "r"
|
||||
ř = "r"
|
||||
ŗ = "r"
|
||||
ś = "s"
|
||||
š = "s"
|
||||
ş = "s"
|
||||
ť = "t"
|
||||
ţ = "t"
|
||||
ù = "u"
|
||||
ú = "u"
|
||||
û = "u"
|
||||
ü = "ue"
|
||||
ū = "u"
|
||||
ů = "u"
|
||||
ű = "u"
|
||||
ŭ = "u"
|
||||
ũ = "u"
|
||||
ų = "u"
|
||||
ŵ = "w"
|
||||
ÿ = "y"
|
||||
ý = "y"
|
||||
ŷ = "y"
|
||||
ż = "z"
|
||||
ź = "z"
|
||||
ž = "z"
|
||||
ß = "ss"
|
||||
ſ = "ss"
|
||||
Α = "A"
|
||||
Ά = "A"
|
||||
Ἀ = "A"
|
||||
Ἁ = "A"
|
||||
Ἂ = "A"
|
||||
Ἃ = "A"
|
||||
Ἄ = "A"
|
||||
Ἅ = "A"
|
||||
Ἆ = "A"
|
||||
Ἇ = "A"
|
||||
ᾈ = "A"
|
||||
ᾉ = "A"
|
||||
ᾊ = "A"
|
||||
ᾋ = "A"
|
||||
ᾌ = "A"
|
||||
ᾍ = "A"
|
||||
ᾎ = "A"
|
||||
ᾏ = "A"
|
||||
Ᾰ = "A"
|
||||
Ᾱ = "A"
|
||||
Ὰ = "A"
|
||||
Ά = "A"
|
||||
ᾼ = "A"
|
||||
Β = "B"
|
||||
Γ = "G"
|
||||
Δ = "D"
|
||||
Ε = "E"
|
||||
Έ = "E"
|
||||
Ἐ = "E"
|
||||
Ἑ = "E"
|
||||
Ἒ = "E"
|
||||
Ἓ = "E"
|
||||
Ἔ = "E"
|
||||
Ἕ = "E"
|
||||
Έ = "E"
|
||||
Ὲ = "E"
|
||||
Ζ = "Z"
|
||||
Η = "I"
|
||||
Ή = "I"
|
||||
Ἠ = "I"
|
||||
Ἡ = "I"
|
||||
Ἢ = "I"
|
||||
Ἣ = "I"
|
||||
Ἤ = "I"
|
||||
Ἥ = "I"
|
||||
Ἦ = "I"
|
||||
Ἧ = "I"
|
||||
ᾘ = "I"
|
||||
ᾙ = "I"
|
||||
ᾚ = "I"
|
||||
ᾛ = "I"
|
||||
ᾜ = "I"
|
||||
ᾝ = "I"
|
||||
ᾞ = "I"
|
||||
ᾟ = "I"
|
||||
Ὴ = "I"
|
||||
Ή = "I"
|
||||
ῌ = "I"
|
||||
Θ = "TH"
|
||||
Ι = "I"
|
||||
Ί = "I"
|
||||
Ϊ = "I"
|
||||
Ἰ = "I"
|
||||
Ἱ = "I"
|
||||
Ἲ = "I"
|
||||
Ἳ = "I"
|
||||
Ἴ = "I"
|
||||
Ἵ = "I"
|
||||
Ἶ = "I"
|
||||
Ἷ = "I"
|
||||
Ῐ = "I"
|
||||
Ῑ = "I"
|
||||
Ὶ = "I"
|
||||
Ί = "I"
|
||||
Κ = "K"
|
||||
Λ = "L"
|
||||
Μ = "M"
|
||||
Ν = "N"
|
||||
Ξ = "KS"
|
||||
Ο = "O"
|
||||
Ό = "O"
|
||||
Ὀ = "O"
|
||||
Ὁ = "O"
|
||||
Ὂ = "O"
|
||||
Ὃ = "O"
|
||||
Ὄ = "O"
|
||||
Ὅ = "O"
|
||||
Ὸ = "O"
|
||||
Ό = "O"
|
||||
Π = "P"
|
||||
Ρ = "R"
|
||||
Ῥ = "R"
|
||||
Σ = "S"
|
||||
Τ = "T"
|
||||
Υ = "Y"
|
||||
Ύ = "Y"
|
||||
Ϋ = "Y"
|
||||
Ὑ = "Y"
|
||||
Ὓ = "Y"
|
||||
Ὕ = "Y"
|
||||
Ὗ = "Y"
|
||||
Ῠ = "Y"
|
||||
Ῡ = "Y"
|
||||
Ὺ = "Y"
|
||||
Ύ = "Y"
|
||||
Φ = "F"
|
||||
Χ = "X"
|
||||
Ψ = "PS"
|
||||
Ω = "O"
|
||||
Ώ = "O"
|
||||
Ὠ = "O"
|
||||
Ὡ = "O"
|
||||
Ὢ = "O"
|
||||
Ὣ = "O"
|
||||
Ὤ = "O"
|
||||
Ὥ = "O"
|
||||
Ὦ = "O"
|
||||
Ὧ = "O"
|
||||
ᾨ = "O"
|
||||
ᾩ = "O"
|
||||
ᾪ = "O"
|
||||
ᾫ = "O"
|
||||
ᾬ = "O"
|
||||
ᾭ = "O"
|
||||
ᾮ = "O"
|
||||
ᾯ = "O"
|
||||
Ὼ = "O"
|
||||
Ώ = "O"
|
||||
ῼ = "O"
|
||||
α = "a"
|
||||
ά = "a"
|
||||
ἀ = "a"
|
||||
ἁ = "a"
|
||||
ἂ = "a"
|
||||
ἃ = "a"
|
||||
ἄ = "a"
|
||||
ἅ = "a"
|
||||
ἆ = "a"
|
||||
ἇ = "a"
|
||||
ᾀ = "a"
|
||||
ᾁ = "a"
|
||||
ᾂ = "a"
|
||||
ᾃ = "a"
|
||||
ᾄ = "a"
|
||||
ᾅ = "a"
|
||||
ᾆ = "a"
|
||||
ᾇ = "a"
|
||||
ὰ = "a"
|
||||
ά = "a"
|
||||
ᾰ = "a"
|
||||
ᾱ = "a"
|
||||
ᾲ = "a"
|
||||
ᾳ = "a"
|
||||
ᾴ = "a"
|
||||
ᾶ = "a"
|
||||
ᾷ = "a"
|
||||
β = "b"
|
||||
γ = "g"
|
||||
δ = "d"
|
||||
ε = "e"
|
||||
έ = "e"
|
||||
ἐ = "e"
|
||||
ἑ = "e"
|
||||
ἒ = "e"
|
||||
ἓ = "e"
|
||||
ἔ = "e"
|
||||
ἕ = "e"
|
||||
ὲ = "e"
|
||||
έ = "e"
|
||||
ζ = "z"
|
||||
η = "i"
|
||||
ή = "i"
|
||||
ἠ = "i"
|
||||
ἡ = "i"
|
||||
ἢ = "i"
|
||||
ἣ = "i"
|
||||
ἤ = "i"
|
||||
ἥ = "i"
|
||||
ἦ = "i"
|
||||
ἧ = "i"
|
||||
ᾐ = "i"
|
||||
ᾑ = "i"
|
||||
ᾒ = "i"
|
||||
ᾓ = "i"
|
||||
ᾔ = "i"
|
||||
ᾕ = "i"
|
||||
ᾖ = "i"
|
||||
ᾗ = "i"
|
||||
ὴ = "i"
|
||||
ή = "i"
|
||||
ῂ = "i"
|
||||
ῃ = "i"
|
||||
ῄ = "i"
|
||||
ῆ = "i"
|
||||
ῇ = "i"
|
||||
θ = "th"
|
||||
ι = "i"
|
||||
ί = "i"
|
||||
ϊ = "i"
|
||||
ΐ = "i"
|
||||
ἰ = "i"
|
||||
ἱ = "i"
|
||||
ἲ = "i"
|
||||
ἳ = "i"
|
||||
ἴ = "i"
|
||||
ἵ = "i"
|
||||
ἶ = "i"
|
||||
ἷ = "i"
|
||||
ὶ = "i"
|
||||
ί = "i"
|
||||
ῐ = "i"
|
||||
ῑ = "i"
|
||||
ῒ = "i"
|
||||
ΐ = "i"
|
||||
ῖ = "i"
|
||||
ῗ = "i"
|
||||
κ = "k"
|
||||
λ = "l"
|
||||
μ = "m"
|
||||
ν = "n"
|
||||
ξ = "ks"
|
||||
ο = "o"
|
||||
ό = "o"
|
||||
ὀ = "o"
|
||||
ὁ = "o"
|
||||
ὂ = "o"
|
||||
ὃ = "o"
|
||||
ὄ = "o"
|
||||
ὅ = "o"
|
||||
ὸ = "o"
|
||||
ό = "o"
|
||||
π = "p"
|
||||
ρ = "r"
|
||||
ῤ = "r"
|
||||
ῥ = "r"
|
||||
σ = "s"
|
||||
ς = "s"
|
||||
τ = "t"
|
||||
υ = "y"
|
||||
ύ = "y"
|
||||
ϋ = "y"
|
||||
ΰ = "y"
|
||||
ὐ = "y"
|
||||
ὑ = "y"
|
||||
ὒ = "y"
|
||||
ὓ = "y"
|
||||
ὔ = "y"
|
||||
ὕ = "y"
|
||||
ὖ = "y"
|
||||
ὗ = "y"
|
||||
ὺ = "y"
|
||||
ύ = "y"
|
||||
ῠ = "y"
|
||||
ῡ = "y"
|
||||
ῢ = "y"
|
||||
ΰ = "y"
|
||||
ῦ = "y"
|
||||
ῧ = "y"
|
||||
φ = "f"
|
||||
χ = "x"
|
||||
ψ = "ps"
|
||||
ω = "o"
|
||||
ώ = "o"
|
||||
ὠ = "o"
|
||||
ὡ = "o"
|
||||
ὢ = "o"
|
||||
ὣ = "o"
|
||||
ὤ = "o"
|
||||
ὥ = "o"
|
||||
ὦ = "o"
|
||||
ὧ = "o"
|
||||
ᾠ = "o"
|
||||
ᾡ = "o"
|
||||
ᾢ = "o"
|
||||
ᾣ = "o"
|
||||
ᾤ = "o"
|
||||
ᾥ = "o"
|
||||
ᾦ = "o"
|
||||
ᾧ = "o"
|
||||
ὼ = "o"
|
||||
ώ = "o"
|
||||
ῲ = "o"
|
||||
ῳ = "o"
|
||||
ῴ = "o"
|
||||
ῶ = "o"
|
||||
ῷ = "o"
|
||||
¨ = ""
|
||||
΅ = ""
|
||||
᾿ = ""
|
||||
῾ = ""
|
||||
῍ = ""
|
||||
῝ = ""
|
||||
῎ = ""
|
||||
῞ = ""
|
||||
῏ = ""
|
||||
῟ = ""
|
||||
῀ = ""
|
||||
῁ = ""
|
||||
΄ = ""
|
||||
΅ = ""
|
||||
` = ""
|
||||
῭ = ""
|
||||
ͺ = ""
|
||||
᾽ = ""
|
||||
А = "A"
|
||||
Б = "B"
|
||||
В = "V"
|
||||
Г = "G"
|
||||
Д = "D"
|
||||
Е = "E"
|
||||
Ё = "E"
|
||||
Ж = "ZH"
|
||||
З = "Z"
|
||||
И = "I"
|
||||
Й = "I"
|
||||
К = "K"
|
||||
Л = "L"
|
||||
М = "M"
|
||||
Н = "N"
|
||||
О = "O"
|
||||
П = "P"
|
||||
Р = "R"
|
||||
С = "S"
|
||||
Т = "T"
|
||||
У = "U"
|
||||
Ф = "F"
|
||||
Х = "KH"
|
||||
Ц = "TS"
|
||||
Ч = "CH"
|
||||
Ш = "SH"
|
||||
Щ = "SHCH"
|
||||
Ы = "Y"
|
||||
Э = "E"
|
||||
Ю = "YU"
|
||||
Я = "YA"
|
||||
а = "A"
|
||||
б = "B"
|
||||
в = "V"
|
||||
г = "G"
|
||||
д = "D"
|
||||
е = "E"
|
||||
ё = "E"
|
||||
ж = "ZH"
|
||||
з = "Z"
|
||||
и = "I"
|
||||
й = "I"
|
||||
к = "K"
|
||||
л = "L"
|
||||
м = "M"
|
||||
н = "N"
|
||||
о = "O"
|
||||
п = "P"
|
||||
р = "R"
|
||||
с = "S"
|
||||
т = "T"
|
||||
у = "U"
|
||||
ф = "F"
|
||||
х = "KH"
|
||||
ц = "TS"
|
||||
ч = "CH"
|
||||
ш = "SH"
|
||||
щ = "SHCH"
|
||||
ы = "Y"
|
||||
э = "E"
|
||||
ю = "YU"
|
||||
я = "YA"
|
||||
Ъ = ""
|
||||
ъ = ""
|
||||
Ь = ""
|
||||
ь = ""
|
||||
|
||||
ð = "d"
|
||||
Ð = "D"
|
||||
þ = "th"
|
||||
Þ = "TH"
|
||||
|
24
html/fichierclient/modules/upload/upload.js
Normal file
@ -0,0 +1,24 @@
|
||||
/* Upload */
|
||||
var holdTheInterval;
|
||||
|
||||
$('#upload_form').submit(function(){
|
||||
holdTheInterval = setInterval(updateInfo, 750);
|
||||
$("#progressbar").progressBar();
|
||||
});
|
||||
|
||||
function updateInfo()
|
||||
{
|
||||
$.getJSON(upload_url, function (data, textStatus){
|
||||
if(data == null)
|
||||
{
|
||||
clearInterval(holdTheInterval);
|
||||
$('#info').html('Fichier en cours d\'importation...');
|
||||
}else{
|
||||
$("#progressbar").progressBar(data.current*100/data.total);
|
||||
$('#info').html('Fichier en cours d\'importation : '+data.filename+' .');
|
||||
if (data.done == 1) {
|
||||
clearInterval(holdTheInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
42
html/fichierclient/modules/upload/upload.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/functions.php';
|
||||
|
||||
$upload = new StdClass();
|
||||
|
||||
$id = arg(1);
|
||||
if($id !== NULL)
|
||||
{
|
||||
if( function_exists('apc_fetch') ) $info = apc_fetch('upload_'.$id);
|
||||
$firephp->log($info, 'info');
|
||||
//Envoi au navigateur
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
// HTTP/1.1
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
// HTTP/1.0
|
||||
header("Pragma: no-cache");
|
||||
echo json_encode($info);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($_POST['APC_UPLOAD_PROGRESS']))
|
||||
{
|
||||
$firephp->log($_FILES, 'FILES');
|
||||
|
||||
$tmp_name = $_FILES['fichier']['tmp_name'];
|
||||
$name = $_FILES['fichier']['name'];
|
||||
|
||||
$new_name = filtre_filename($name);
|
||||
|
||||
if ( !filtre_extension($name) ){
|
||||
$upload->message = "Extension du fichier incorrect";
|
||||
}else{
|
||||
if (is_uploaded_file($tmp_name)) {
|
||||
$firephp->info("File ". $name ." uploaded successfully.");
|
||||
upload($tmp_name, $name, $new_name);
|
||||
//On renvoi sur la page d'accueil
|
||||
header('Location: ./index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
43
html/fichierclient/sql/fichierclient.sql
Normal file
@ -0,0 +1,43 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 3.2.1
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Serveur: localhost
|
||||
-- Généré le : Ven 11 Septembre 2009 à 09:13
|
||||
-- Version du serveur: 5.1.32
|
||||
-- Version de PHP: 5.2.9-1
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
|
||||
--
|
||||
-- Base de données: `fichierclient`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `fichiers`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `fichiers` (
|
||||
`nom` varchar(100) NOT NULL,
|
||||
`nblignes` int(11) NOT NULL,
|
||||
`nbcolonnes` int(11) NOT NULL,
|
||||
`associations` text NOT NULL,
|
||||
`associations_lock` tinyint(1) NOT NULL,
|
||||
`traitements` text NOT NULL,
|
||||
`traitements_lock` tinyint(1) NOT NULL,
|
||||
`outfile` varchar(100) NOT NULL,
|
||||
`status` int(11) NOT NULL,
|
||||
UNIQUE KEY `nom` (`nom`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
10
html/fichierclient/themes/block-frontpage.tpl.php
Normal file
@ -0,0 +1,10 @@
|
||||
<p>Importer ou sélectionner un fichier dans la liste pour commencer à utiliser l'interface.</p>
|
||||
|
||||
<h3>Supprimer le fichier</h3>
|
||||
<p>Toutes les données sauvegardées concernant le fichier sont supprimé de notre base de données ainsi que le fichier physique.</p>
|
||||
|
||||
<h3>Identifier les colonnes</h3>
|
||||
<p>Afin de réaliser les traitements un fichier, il faut tout d'abord.</p>
|
||||
|
||||
<h3>Lancer le traitement</h3>
|
||||
<p>Vérouille le fichier s'il ne l'est pas déjà et demande le lancement du traitement.</p>
|
8
html/fichierclient/themes/block.tpl.php
Normal file
@ -0,0 +1,8 @@
|
||||
<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">
|
||||
|
||||
<?php if (!empty($block->subject)): ?>
|
||||
<h2><?php print $block->subject ?></h2>
|
||||
<?php endif;?>
|
||||
|
||||
<div class="content"><?php print $block->content ?></div>
|
||||
</div>
|
141
html/fichierclient/themes/page.tpl.php
Normal file
@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<?php print $head ?>
|
||||
<title><?php print $head_title ?></title>
|
||||
<?php print $styles ?>
|
||||
<!--[if IE]><?php print $styles_ie ?><![endif]-->
|
||||
<?php print $scripts ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
var upload_url = './index.php?q=upload/<?=$uuid?>';
|
||||
var assoc_url = 'index.php?<?=$_SERVER['QUERY_STRING']?>/assoc';
|
||||
var traitements_url = 'index.php?<?=$_SERVER['QUERY_STRING']?>/add';
|
||||
|
||||
/* Upload */
|
||||
var holdTheInterval;
|
||||
|
||||
$('#upload_form').submit(function(){
|
||||
holdTheInterval = setInterval(updateInfo, 750);
|
||||
$("#progressbar").progressBar();
|
||||
});
|
||||
|
||||
function updateInfo()
|
||||
{
|
||||
$.getJSON(upload_url, function (data, textStatus){
|
||||
if(data == null)
|
||||
{
|
||||
clearInterval(holdTheInterval);
|
||||
$('#info').html('Fichier en cours d\'importation...');
|
||||
}else{
|
||||
$("#progressbar").progressBar(data.current*100/data.total);
|
||||
$('#info').html('Fichier en cours d\'importation : '+data.filename+' .');
|
||||
if (data.done == 1) {
|
||||
clearInterval(holdTheInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Action sur les fichiers */
|
||||
$('.fichier').each(function(){
|
||||
$(this).mouseover(function(){ $(this).children('.action_fichier').css('display', 'block'); });
|
||||
});
|
||||
|
||||
$('.action_fichier').each(function(){
|
||||
$(this).mouseout(function(){ $(this).css('display', 'none'); });
|
||||
});
|
||||
|
||||
$('#files').mouseout(function(){
|
||||
$(this).find('.action_fichier').css('display', 'none');
|
||||
});
|
||||
|
||||
/* Drag n Drop des listes */
|
||||
$('.drag').draggable({ revert: 'invalid', cursor: 'move' });
|
||||
|
||||
$('.drop').droppable({
|
||||
drop: function(event, ui)
|
||||
{
|
||||
var identifiant = $(ui.draggable).attr('id');
|
||||
var colonne = $(this).attr('id');
|
||||
/* Envoi des informations */
|
||||
$.post(assoc_url, { id: identifiant, col: colonne }, function(data){ $('#message').html(data); });
|
||||
/* Modification visuel */
|
||||
$(this).append('<span class="identifiant">'+$(ui.draggable).html()+'</span>');
|
||||
$(ui.draggable).remove();
|
||||
}
|
||||
});
|
||||
|
||||
/* Traitements */
|
||||
$('input[name=choix_traitements[]]:checkbox').click(function(){
|
||||
var choix = new Array();
|
||||
var cpt = 0;
|
||||
$('input[name=choix_traitements[]]:checkbox').each(function(){
|
||||
if($(this).attr('checked')==true){
|
||||
choix[cpt] = $(this).attr('value');
|
||||
cpt++;
|
||||
}
|
||||
});
|
||||
$.post(traitements_url, { 'choices[]': choix }, function(data){ $('#message').html(data); });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="upload">
|
||||
<h2>Charger un fichier</h2>
|
||||
<form id="upload_form" action="index.php?q=upload" method="post" enctype="multipart/form-data">
|
||||
<input name="APC_UPLOAD_PROGRESS" type="hidden" value="<?=$uuid?>" />
|
||||
<label>Sélection du fichier : </label><input type="file" id="file" name="fichier" />
|
||||
<input type="submit" name="submit" value="Envoyer" id="submit" />
|
||||
</form>
|
||||
<div id="progressbar">Taille maximum pour le fichier : <?=ini_get('upload_max_filesize');?></div>
|
||||
<div id="info"><?php if (isset($upload->message)) print $upload->message; ?></div>
|
||||
<p><a href="./index.php">Accueil</a></p>
|
||||
</div>
|
||||
|
||||
<div id="files">
|
||||
<h2>Liste des fichiers disponibles</h2>
|
||||
<?php
|
||||
foreach($listefichier as $fichier)
|
||||
{
|
||||
?>
|
||||
<span class="fichier"><?=$fichier?>
|
||||
<div class="action_fichier">
|
||||
<ul>
|
||||
<li><a href="./index.php?q=comptage/<?=$fichier?>">Informations / Comptage</a></li>
|
||||
<li><a href="./index.php?q=fichier/delete/<?=$fichier?>">Supprimer le fichier</a></li>
|
||||
<li><a href="./index.php?q=fichier/colonne/<?=$fichier?>">Identifier les colonnes</a></li>
|
||||
<li><a href="./index.php?q=traitements/<?=$fichier?>">Choix des traitements</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="main" class="clearfix">
|
||||
<?php
|
||||
if( isset($block) )
|
||||
{
|
||||
require_once realpath(dirname(__FILE__)).'/block.tpl.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once realpath(dirname(__FILE__)).'/block-frontpage.tpl.php';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div> <!-- // Container -->
|
||||
|
||||
</body>
|
||||
</html>
|
434
html/gestion/add.php
Normal file
@ -0,0 +1,434 @@
|
||||
<?php
|
||||
//die('Inopérant pour l\'instant');
|
||||
include('tables.php');
|
||||
require('qs_functions.php');
|
||||
|
||||
@session_start();
|
||||
$sessionPage='';
|
||||
|
||||
if (isset($_REQUEST['dbtable']) && $_REQUEST['dbtable']<>'')
|
||||
{
|
||||
$dbtable=$_REQUEST['dbtable'];
|
||||
if (array_key_exists($dbtable, $tablesDisp)) {
|
||||
$tmp=explode('.', $dbtable);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
$sessionPage=$database.'.'.$table;
|
||||
$_SESSION['dbtable'] = $sessionPage;
|
||||
}
|
||||
else die('Table inconnue !');
|
||||
}
|
||||
|
||||
if ($sessionPage=='') {
|
||||
$sessionPage=$dbtable=qssession('dbtable');
|
||||
$tmp=explode('.', $sessionPage);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
}
|
||||
|
||||
$fields_hidden=$fields_readOnly=$fields_nomChamps=array();
|
||||
$titre='Ajout de '.$table;
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_hidden']))
|
||||
$fields_hidden=$tablesInfo[$dbtable]['fields_hidden'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_readOnly']))
|
||||
$fields_readOnly=$tablesInfo[$dbtable]['fields_readOnly'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_nomChamps']))
|
||||
$fields_nomChamps=$tablesInfo[$dbtable]['fields_nomChamps'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['titres']['list']))
|
||||
$titre=$tablesInfo[$dbtable]['titres']['add'];
|
||||
|
||||
$nbLignesParPage = 30;
|
||||
|
||||
$host = "localhost:3306";
|
||||
$user = "root";
|
||||
$passwd = "bzh4231*";
|
||||
$link = @mysql_connect($host,$user,$passwd);
|
||||
@mysql_select_db($database);
|
||||
|
||||
$row = '';
|
||||
$err_string = '';
|
||||
$quotechar = '`';
|
||||
$quotedate = "'";
|
||||
$sql = '';
|
||||
$sql_ext = '';
|
||||
$insert_sql='';
|
||||
$value_sql='';
|
||||
|
||||
$parammaster = array();
|
||||
$fields = array();
|
||||
$fieldcons = array();
|
||||
$searchmode = array();
|
||||
$stdsearchopt = array();
|
||||
$isEditables = array();
|
||||
$formatdate = array();
|
||||
$seperatedate = array();
|
||||
$format = array();
|
||||
$champ = array();
|
||||
$SourceFileUpload = array();
|
||||
$DestFileUpload = array();
|
||||
$NewFieldUpload = array();
|
||||
|
||||
$result = mysql_query("SHOW COLUMNS FROM $table");
|
||||
if (!$result) {
|
||||
echo 'Impossible d\'exécuter la requête : ' . mysql_error();
|
||||
exit;
|
||||
}
|
||||
if (mysql_num_rows($result) > 0) {
|
||||
$sql .= "SELECT ";
|
||||
$i=0;
|
||||
$singleKey='';
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
$sql .= " $table.`".$row['Field'].'`,';
|
||||
$fields[$i]=$table.'.`'.$row['Field'].'`';
|
||||
$fieldcons[$i]=$table.'.`'.$row['Field'].'`';
|
||||
$parammaster[$i]='';
|
||||
$searchmode[$i]= 0;
|
||||
$stdsearchopt[$i]=0;
|
||||
$champ[$i]['nom']=$row['Field'];
|
||||
$SourceFileUpload[$i]=0;
|
||||
$DestFileUpload[$i]=0;
|
||||
$NewFieldUpload[$i]=0;
|
||||
|
||||
if (in_array($row['Field'], $fields_hidden))
|
||||
$champ[$i]['hidden']=true;
|
||||
else
|
||||
$champ[$i]['hidden']=false;
|
||||
// Le champ est il éditable ?
|
||||
$isEditables[$i] = true;
|
||||
if (in_array($row['Field'], $fields_readOnly))
|
||||
$isEditables[$i] = false;
|
||||
|
||||
$champ[$i]['type']=$row['Type'];
|
||||
$champ[$i]['null']=$row['Null'];
|
||||
$champ[$i]['key']=$row['Key'];
|
||||
if ($row['Key']=='PRI'){
|
||||
if ($singleKey=='') $singleKey=$row['Field'];
|
||||
else die('Ne gère pas les tables avec plusieurs clés primaires');
|
||||
}
|
||||
//elseif
|
||||
$champ[$i]['default']=$row['Default'];
|
||||
$champ[$i]['extra']=$row['Extra'];
|
||||
$champ[$i]['align']='Default'; // right, left
|
||||
$formatdate[$i] = '';
|
||||
$seperatedate[$i] = '';
|
||||
|
||||
if (preg_match('/(timestamp|date|datetime)(.*)/i', $row['Type'], $matches)) {
|
||||
$formatdate[$i] = 'dd/mm/yyyy';
|
||||
$seperatedate[$i] = '/';
|
||||
$format[$i] = 'date';
|
||||
} elseif (preg_match('/(tinyint|smallint|mediumint|int|bigint|integer)(.*)/i', $row['Type'], $matches)) {
|
||||
$tmp=explode(')',$matches[2]);
|
||||
$format[$i]='int';
|
||||
$long[$i]=str_replace('(','', $tmp[0]);
|
||||
} elseif (preg_match('/(float|double|real|decimal|numeric)(.*)/i', $row['Type'], $matches))
|
||||
$format[$i] = 'float';
|
||||
elseif (preg_match('/(char|varchar|text)(.*)/i', $row['Type'], $matches)) {
|
||||
$tmp=explode(')',$matches[2]);
|
||||
$format[$i]='char';
|
||||
$long[$i]=str_replace('(','', $tmp[0]);
|
||||
} elseif (preg_match('/(enum)(.*)/i', $row['Type'], $matches))
|
||||
$format[$i]='enum';
|
||||
else
|
||||
die ('Format "'.$row['Type'].'" inconnu');
|
||||
//enum('A','B','C')
|
||||
if (isset($fields_nomChamps[$row['Field']]) && $fields_nomChamps[$row['Field']]<>'')
|
||||
$champ[$i]['libelleColonne']=$fields_nomChamps[$row['Field']];
|
||||
else
|
||||
$champ[$i]['libelleColonne']=$row['Field'];
|
||||
//$fields_nomChamps
|
||||
$i++;/*Array
|
||||
(
|
||||
[Field] => numMand
|
||||
[Type] => mediumint(9)
|
||||
[Null] => NO
|
||||
[Key] => PRI
|
||||
[Default] =>
|
||||
[Extra] => auto_increment
|
||||
)
|
||||
1*/
|
||||
}
|
||||
$sql_select = substr($sql,0,-1) . "FROM $table $table\n";
|
||||
//die(print_r($champ));
|
||||
}
|
||||
|
||||
if (isset($_POST["act"])) {
|
||||
$qry_string = "";
|
||||
$insert_sql = "";
|
||||
$value_sql = "";
|
||||
$hidden_tag = "";
|
||||
$i = 0;
|
||||
$result = mysql_query($sql_select . " " . $sql_ext . " limit 0,1")
|
||||
or die("Invalid query : $sql_select $sql_ext limit 0,1\n" . mysql_error() );
|
||||
|
||||
while ($i < mysql_num_fields($result)) {
|
||||
$meta = mysql_fetch_field($result);
|
||||
$field_name = $meta->name;
|
||||
$field_type = $meta->type;
|
||||
$type_field = "";
|
||||
$type_field = returntype($field_type);
|
||||
if (qsvalidRequest("search_fd" .$i)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes(qsrequest("search_fd" . $i)));
|
||||
} else {
|
||||
$qry_string .= "&search_fd" .$i . "=" . urlencode(stripslashes(qsrequest("search_fd" . $i)));
|
||||
}
|
||||
$hidden_tag .= "<input type=\"hidden\" name=\"search_fd" .$i . "\" value=\"" . qsreplace_html_quote(stripslashes(qsrequest("search_fd" . $i))) . "\">\n";
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "multisearch_fd" . $i . "=" . urlencode(stripslashes(qsrequest("multisearch_fd" . $i)));
|
||||
} else {
|
||||
$qry_string .= "&multisearch_fd" .$i . "=" . urlencode(stripslashes(qsrequest("multisearch_fd" . $i)));
|
||||
}
|
||||
$hidden_tag .= "<input type=\"hidden\" name=\"multisearch_fd" .$i . "\" value=\"" . qsreplace_html_quote(stripslashes(qsrequest("multisearch_fd" . $i))) . "\">\n";
|
||||
}
|
||||
if (qsvalidRequest("add_fd" . $i)) {
|
||||
$idata = qsrequest("add_fd" . $i);
|
||||
if ($meta) {
|
||||
if ($type_field == "type_datetime") {
|
||||
if ($insert_sql == "") {
|
||||
$insert_sql .= $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= $quotedate . qsconvertdate2ansi($idata,$formatdate[$i],$seperatedate[$i]) . $quotedate;
|
||||
} else {
|
||||
$insert_sql .= "," . $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= "," . $quotedate . qsconvertdate2ansi($idata,$formatdate[$i],$seperatedate[$i]) .$quotedate;
|
||||
}
|
||||
} elseif ($type_field == "type_integer") {
|
||||
if (is_numeric($idata)) {
|
||||
if ($insert_sql == "") {
|
||||
$insert_sql .= $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= $idata;
|
||||
} else {
|
||||
$insert_sql .= "," . $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= "," . $idata;
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while adding<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Type mismatch.<br>";
|
||||
}
|
||||
} elseif ($type_field == "type_string") {
|
||||
if ($insert_sql == "") {
|
||||
$insert_sql .= $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= "'" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
} else {
|
||||
$insert_sql .= "," . $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= ",'" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
}
|
||||
} else {
|
||||
if ($insert_sql == "") {
|
||||
$insert_sql .= $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= "'" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
} else {
|
||||
$insert_sql .= "," . $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= ",'" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((strtolower($field_type) != "int identity")
|
||||
&& (strtolower($field_type) != "autoincrement")
|
||||
&& (strtolower($field_type) != "counter")) {
|
||||
if ($insert_sql == "") {
|
||||
$insert_sql .= $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= "null";
|
||||
} else {
|
||||
$insert_sql .= "," . $quotechar . $field_name . $quotechar;
|
||||
$value_sql .= ", null";
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql = '';
|
||||
$sql = "INSERT INTO " . $quotechar. $table . $quotechar;
|
||||
$sql .= " (" . $insert_sql . ")";
|
||||
$sql .= ' VALUES ';
|
||||
$sql .= " (" . $value_sql . ")";
|
||||
echo $sql;
|
||||
//die();
|
||||
#----get submit url page----
|
||||
$submiturl = "./liste.php";
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
if (!$result = @mysql_query($sql)){
|
||||
$err_string .= "<strong>Erreur : </strong> lors de l'ajout en base (<strong>" . mysql_errno() . "</strong>).<br/>";
|
||||
$err_string .= "Description : " . mysql_error();
|
||||
}
|
||||
|
||||
//Start update data of upload field
|
||||
$value_sql = "";
|
||||
$max_id = -1;
|
||||
$max_id = GetLastRecordID($table, $singleKey);
|
||||
$updateCond = "";
|
||||
$updateCond = $singleKey.'='. $max_id;
|
||||
if ($err_string == "") {
|
||||
if ($qry_string != "") {
|
||||
$URL= $submiturl . "&" . $qry_string;
|
||||
} else {
|
||||
$URL= $submiturl;
|
||||
}
|
||||
header ("Location: $URL");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title><?=htmlentities($titre)?></title>
|
||||
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
|
||||
<script src="../nonimg/validate.js"></script>
|
||||
<script language="javascript">
|
||||
function check(frm) {
|
||||
var szAlert = "Erreur(s) :\n";
|
||||
var nIndex = 0;
|
||||
<?php
|
||||
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'] && $isEditables[$i])
|
||||
{
|
||||
/* // On test si le champ peut être vide
|
||||
?>
|
||||
if (!RequiredField(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' ne peut être vide\n";
|
||||
}
|
||||
<?
|
||||
*/ // Si le champ est au format date, ajout du test de contrôle de la date en JavaScript
|
||||
if ($formatdate[$i]<>'') {
|
||||
?>
|
||||
if (frm.edit_fd<?=$i?>.value!="" && !isDate(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' n'est pas une date valide\n";
|
||||
}
|
||||
<?
|
||||
}
|
||||
|
||||
// Si le champ est de type int au sens large, ajout du test de contrôle de validité en JavaScript
|
||||
if ($format[$i]=='int') {
|
||||
?>
|
||||
if (frm.edit_fd<?=$i?>.value!="" && !NumberValidate(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' n'est pas un nombre\n";
|
||||
}
|
||||
<?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
if(nIndex > 0) {
|
||||
alert(szAlert) ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<center><strong><font size="5"><?=htmlentities($titre)?></font></strong></center><br>
|
||||
|
||||
<A NAME=top></A>
|
||||
|
||||
<script>
|
||||
function getURLParam(strParamName){
|
||||
var strReturn = "";
|
||||
var strHref = window.location.href;
|
||||
if ( strHref.indexOf("?") > -1 ){
|
||||
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
|
||||
var aQueryString = strQueryString.split("&");
|
||||
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
|
||||
if (
|
||||
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
|
||||
var aParam = aQueryString[iParam].split("=");
|
||||
strReturn = aParam[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<Form name="qs_add_form" method="post" action="./add.php" onSubmit="return check(this)">
|
||||
<script language='javascript' src='qwikcalendar.js'></script>
|
||||
<?php
|
||||
if (isset($hidden_tag)) print $hidden_tag;
|
||||
?>
|
||||
<Table Border="0" Cellpadding="2" Cellspacing="1" BgColor="#177AE9">
|
||||
|
||||
<?php
|
||||
$css_class = "\"TrOdd\"";
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="ThRows"><?=htmlentities($titre)?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($err_string != "") {
|
||||
print '<tr>';
|
||||
print '<td class="ThRows"><b><font color="red">Erreur :</font></b></td>';
|
||||
print '<td colspan="2" class=' . $css_class . ' align=Default>' . $err_string . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'])
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td class="ThRows"><?=htmlentities($field['libelleColonne'])?></td>
|
||||
<!--popUpCalendar(ctl, ctl2, format, frameOffSetLeft, frameOffSetTop)-->
|
||||
<?php
|
||||
$cellvalue = "";
|
||||
if ((!isset($_GET["add_fd".$i])) && (!isset($_POST["add_fd".$i]))) {
|
||||
if ($formatdate[$i]<>'')
|
||||
$itemvalue = qsconvertdate($row[$i],"dd/mm/yyyy");
|
||||
else
|
||||
$itemvalue = $row[$i];
|
||||
} else {
|
||||
$itemvalue = qsrequest("add_fd".$i);
|
||||
}
|
||||
if ($isEditables[$i]) {
|
||||
$cellvalue = '<input type="text" name="add_fd'.$i.'" value="' . qsreplace_html_quote(stripslashes($itemvalue)) . '">';
|
||||
if ($formatdate[$i]<>'') $cellvalue.='<a href="#add_fd'.$i.'"><a name="add_fd'.$i.'"><img src="../images/Calendar.gif" width="20" height="21" border=0 align="absmiddle" onClick="popUpCalendar(this, document.forms[0].add_fd'.$i.', \'dd/mm/yyyy\', 0, 0)"></a>';
|
||||
}
|
||||
else
|
||||
$cellvalue = htmlentities($itemvalue);
|
||||
|
||||
if ($cellvalue == '') {
|
||||
$cellvalue = ' ';
|
||||
}
|
||||
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
|
||||
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
#----get back url page----
|
||||
$backurl = "./liste.php?";
|
||||
?>
|
||||
<tr>
|
||||
<td class="ThRows"> </td>
|
||||
<td class="TrOdd" align=Default>
|
||||
<input type="hidden" name="act" value="n">
|
||||
<input type="button" name="QS_Back" value="Retour" OnClick="javascript:window.location='<?=$backurl?>'">
|
||||
<input type="submit" name="QS_Submit" value="Ajout">
|
||||
<input type="reset" name="QS_Reset" value="Réinitialisation">
|
||||
</td>
|
||||
</tr>
|
||||
</Table><br>
|
||||
</Form>
|
||||
<?php
|
||||
if (isset($result) && $result > 0) {mysql_free_result($result);}
|
||||
if ($link > 0) {mysql_close($link);}
|
||||
?>
|
||||
<A NAME=bottom></A>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
178
html/gestion/default.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?
|
||||
@session_start();
|
||||
$sessionPage='';
|
||||
|
||||
if (isset($_REQUEST['dbtable']) && $_REQUEST['dbtable']<>'')
|
||||
{
|
||||
$dbtable=$_REQUEST['dbtable'];
|
||||
if (array_key_exists($dbtable, $tablesDisp)) {
|
||||
$tmp=explode('.', $dbtable);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
$sessionPage=$database.'.'.$table;
|
||||
$_SESSION['dbtable'] = $sessionPage;
|
||||
}
|
||||
else die("Table '$dbtable' inconnue !");
|
||||
}
|
||||
|
||||
if ($sessionPage=='') {
|
||||
$sessionPage=$dbtable=qssession('dbtable');
|
||||
$tmp=explode('.', $sessionPage);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
}
|
||||
|
||||
$host = "192.168.3.22:3306";
|
||||
$user = "root";
|
||||
$passwd = "bzh4231*";
|
||||
$link = @mysql_connect($host,$user,$passwd);
|
||||
@mysql_select_db($database);
|
||||
|
||||
$fields_hidden=$fields_readOnly=$fields_nomChamps=$fields_links=$fields_libs=array();
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_hidden']))
|
||||
$fields_hidden=$tablesInfo[$dbtable]['fields_hidden'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_readOnly']))
|
||||
$fields_readOnly=$tablesInfo[$dbtable]['fields_readOnly'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_nomChamps']))
|
||||
$fields_nomChamps=$tablesInfo[$dbtable]['fields_nomChamps'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_links']))
|
||||
$fields_links=$tablesInfo[$dbtable]['fields_links'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['fields_libs']))
|
||||
$fields_libs=$tablesInfo[$dbtable]['fields_libs'];
|
||||
|
||||
if (isset($tablesInfo[$dbtable]['titres'][$page]))
|
||||
$titre=$tablesInfo[$dbtable]['titres'][$page];
|
||||
|
||||
$row = "";
|
||||
$err_string = "";
|
||||
$quotechar = "`";
|
||||
$quotedate = "'";
|
||||
$sql = "";
|
||||
$sql_ext = "";
|
||||
$sqlmaster = "";
|
||||
$sql_extmaster = "";
|
||||
$cellvalue = "";
|
||||
$istrdata = "";
|
||||
$icon = "";
|
||||
$ioldcon = "";
|
||||
$strkeyword = "";
|
||||
$sortstring = "";
|
||||
|
||||
$parammaster = array();
|
||||
$fields = array();
|
||||
$fieldcons = array();
|
||||
$searchmode = array();
|
||||
$stdsearchopt = array();
|
||||
$isEditables = array();
|
||||
$formatdate = array();
|
||||
$seperatedate = array();
|
||||
$format = array();
|
||||
$champ = array();
|
||||
$long =array();
|
||||
$formatEnum=array();
|
||||
$primary_keys=array();
|
||||
$arryitemvalue = array();
|
||||
$arryopt = array();
|
||||
$arryandoropt = array();
|
||||
|
||||
$result = mysql_query("SHOW COLUMNS FROM $table");
|
||||
if (!$result) {
|
||||
echo 'Impossible d\'exécuter la requête : ' . mysql_error();
|
||||
exit;
|
||||
}
|
||||
if (mysql_num_rows($result) > 0) {
|
||||
$sql .= "SELECT ";
|
||||
$i=0;
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
$sql .= " $table.`".$row['Field'].'`,';
|
||||
$fields[$i]=$table.'.`'.$row['Field'].'`';
|
||||
$fieldcons[$i]=$table.'.`'.$row['Field'].'`';
|
||||
$parammaster[$i]='';
|
||||
$arryitemvalue[$i]='';
|
||||
$arryopt[$i]='';
|
||||
$arryandoropt[$i]='';
|
||||
$searchmode[$i]= 0;
|
||||
$stdsearchopt[$i]=0;
|
||||
|
||||
$champ[$i]['nom']=$row['Field'];
|
||||
// Le champ est il caché ?
|
||||
if (in_array($row['Field'], $fields_hidden))
|
||||
$champ[$i]['hidden']=true;
|
||||
else
|
||||
$champ[$i]['hidden']=false;
|
||||
// Le champ est il éditable ?
|
||||
$isEditables[$i] = true;
|
||||
if (in_array($row['Field'], $fields_readOnly) || @$tablesInfo[$dbtable]['table_readOnly'])
|
||||
$isEditables[$i] = false;
|
||||
// Le champ comporte il un lien ?
|
||||
$champ[$i]['link'] = '';
|
||||
if (isset($fields_links[$row['Field']]) && $fields_links[$row['Field']]<>'')
|
||||
$champ[$i]['link']=$fields_links[$row['Field']];
|
||||
|
||||
$champ[$i]['libs'] = '';
|
||||
if (isset($fields_libs[$row['Field']]) && $fields_libs[$row['Field']]<>'')
|
||||
$champ[$i]['libs']=$fields_libs[$row['Field']];
|
||||
/* =>array( 'typeEven'=>array('table'=>'jo.tabEvenements',
|
||||
'key'=>'codEven',
|
||||
'lib'=>'libEven')),*/
|
||||
$champ[$i]['type']=$row['Type'];
|
||||
$champ[$i]['null']=$row['Null'];
|
||||
$champ[$i]['key']=$row['Key'];
|
||||
if ($row['Key']=='PRI') $primary_keys[$row['Field']]=$i;
|
||||
$champ[$i]['default']=$row['Default'];
|
||||
$champ[$i]['extra']=$row['Extra'];
|
||||
$champ[$i]['align']='Default'; // right, left
|
||||
$formatdate[$i] = '';
|
||||
$seperatedate[$i] = '';
|
||||
|
||||
if (preg_match('/(timestamp|date|datetime)(.*)/i', $row['Type'], $matches)) {
|
||||
$formatdate[$i] = 'dd/mm/yyyy';
|
||||
$seperatedate[$i] = '/';
|
||||
$format[$i] = 'date';
|
||||
} elseif (preg_match('/(tinyint|smallint|mediumint|int|bigint|integer)(.*)/i', $row['Type'], $matches)) {
|
||||
$tmp=explode(')',$matches[2]);
|
||||
$format[$i]='int';
|
||||
$long[$i]=trim(str_replace('(','', $tmp[0]));
|
||||
} elseif (preg_match('/(float|double|real|decimal|numeric)(.*)/i', $row['Type'], $matches))
|
||||
$format[$i] = 'float';
|
||||
elseif (preg_match('/(char|varchar)(.*)/i', $row['Type'], $matches)) {
|
||||
$tmp=explode(')',$matches[2]);
|
||||
$format[$i]='char';
|
||||
$long[$i]=trim(str_replace('(','', $tmp[0]));
|
||||
} elseif (preg_match('/(text|tinytext|mediumtext|longtext)(.*)/i', $row['Type'], $matches)) {
|
||||
$format[$i]='text';
|
||||
} elseif (preg_match('/(enum)(.*)/i', $row['Type'], $matches)) {
|
||||
$format[$i]='enum';
|
||||
$formatEnum[$i]=explode("','",str_replace(array("('", "')"), '', $matches[2]));
|
||||
} else
|
||||
die ('Format "'.$row['Type'].'" inconnu');
|
||||
//enum('A','B','C')
|
||||
if (isset($fields_nomChamps[$row['Field']]) && $fields_nomChamps[$row['Field']]<>'')
|
||||
$champ[$i]['libelleColonne']=$fields_nomChamps[$row['Field']];
|
||||
else
|
||||
$champ[$i]['libelleColonne']=$row['Field'];
|
||||
//$fields_nomChamps
|
||||
$i++;/*Array'fields_libs' =>array( 'typeEven'=>array('table'=>'jo.tabEvenements',
|
||||
'key'=>'codEven',
|
||||
'lib'=>'libEven')),
|
||||
(
|
||||
[Field] => numMand
|
||||
[Type] => mediumint(9)
|
||||
[Null] => NO
|
||||
[Key] => PRI
|
||||
[Default] =>
|
||||
[Extra] => auto_increment
|
||||
)
|
||||
1*/
|
||||
}
|
||||
$sql_select = substr($sql,0,-1) . " FROM $table $table\n";
|
||||
$sql = substr($sql,0,-1) . " FROM $table $table\n";
|
||||
//die(print_r($champ));
|
||||
|
||||
}
|
||||
?>
|
431
html/gestion/edit.php
Normal file
@ -0,0 +1,431 @@
|
||||
<?php
|
||||
|
||||
if (!isset($page))
|
||||
$page=str_replace('.php', '', basename(__FILE__));
|
||||
|
||||
include_once('tables.php');
|
||||
include_once('qs_functions.php');
|
||||
include_once('default.php');
|
||||
if (!isset($titre))
|
||||
$titre='Edition "'.$table.'"';
|
||||
|
||||
mysql_query('SET CHARACTER SET utf8;');
|
||||
$result = mysql_query($sql_select . " " . $sql_ext . " limit 0,1")
|
||||
or die("Invalid query : $sql_select $sql_ext limit 0,1\n" . mysql_error() );
|
||||
$qry_string = "";
|
||||
$value_sql = "";
|
||||
$currentrow_sql = "";
|
||||
$hidden_tag = "";
|
||||
$hiddenrow_tag = "";
|
||||
$i = 0;
|
||||
//$cleChoisie=false; // Initialisation de l'édition par une autre clé que la clé de début de table
|
||||
while ($i < mysql_num_fields($result)) {
|
||||
$meta = mysql_fetch_field($result);
|
||||
$field_name = $meta->name;
|
||||
$field_type = $meta->type;
|
||||
if (qsvalidRequest("search_fd" .$i)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . qsrequest("search_fd" . $i);
|
||||
} else {
|
||||
$qry_string .= "&search_fd" .$i . "=" . qsrequest("search_fd" . $i);
|
||||
}
|
||||
$hidden_tag .= "<input type=\"hidden\" name=\"search_fd" . $i . "\" value=\"" . qsrequest("search_fd" . $i) . "\">\n";
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "multisearch_fd" . $i . "=" . urlencode(stripslashes(qsrequest("multisearch_fd" . $i)));
|
||||
} else {
|
||||
$qry_string .= "&multisearch_fd" .$i . "=" . urlencode(stripslashes(qsrequest("multisearch_fd" . $i)));
|
||||
}
|
||||
$hidden_tag .= "<input type=\"hidden\" name=\"multisearch_fd" .$i . "\" value=\"" . qsreplace_html_quote(stripslashes(qsrequest("multisearch_fd" . $i))) . "\">\n";
|
||||
}
|
||||
$type_field = "";
|
||||
$type_field = returntype($field_type);
|
||||
$quotedata = "";
|
||||
switch ($type_field) {
|
||||
case "type_datetime": $quotedata = $quotedate; break;
|
||||
case "type_string": $quotedata = "'"; break;
|
||||
case "type_integer": $quotedata = ""; break;
|
||||
case "type_unknown": $quotedata = "'"; break;
|
||||
default: $quotedata = "'";
|
||||
}
|
||||
if ($meta) {
|
||||
if (qsrequest("currentrow_fd" .$i) != "") {
|
||||
if ($currentrow_sql == "") {
|
||||
$currentrow_sql = $fields[$i] . " = " . $quotedata . ereg_replace("'","''",stripslashes(qsrequest("currentrow_fd" . $i))) . $quotedata;
|
||||
} else {
|
||||
$currentrow_sql .= " and " .$fields[$i] . " = " . $quotedata . ereg_replace("'","''",stripslashes(qsrequest("currentrow_fd" . $i))) . $quotedata;
|
||||
}
|
||||
$hiddenrow_tag .= "<input type=\"hidden\" name=\"currentrow_fd" . $i . "\" value=\"" . qsreplace_html_quote(stripslashes(qsrequest("currentrow_fd" . $i))) . "\">\n";
|
||||
}
|
||||
elseif (qsrequest('uniqueKey') !='' && $champ[$i]['nom']==qsrequest('uniqueKey') ) {
|
||||
//elseif () //{.$tmp[2].'&='.$itemvalue;))
|
||||
//$cleChoisie=true;
|
||||
if ($currentrow_sql == '') {
|
||||
$currentrow_sql = qsrequest('uniqueKey') .'='. $quotedata . ereg_replace("'","''",stripslashes(qsrequest('value'))) . $quotedata;
|
||||
} else {
|
||||
$currentrow_sql .= ' AND '. qsrequest('uniqueKey') .'='. $quotedata . ereg_replace("'","''",stripslashes(qsrequest('value'))) . $quotedata;
|
||||
}
|
||||
$hiddenrow_tag .= '<input type="hidden" name="currentrow_fd'.$i.'" value="'. qsreplace_html_quote(stripslashes(qsrequest('value'))) . "\">\n";
|
||||
}
|
||||
if($isEditables[$i])
|
||||
{
|
||||
if ($type_field == "type_datetime") {
|
||||
if (qsvalidRequest("edit_fd" . $i)) {
|
||||
$idata = qsrequest("edit_fd" . $i);
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = " . $quotedate . qsconvertdate2ansi($idata,$formatdate[$i],$seperatedate[$i]) . $quotedate;
|
||||
}
|
||||
else if($isEditables[$i] != 2) {
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = null";
|
||||
}
|
||||
} elseif ($type_field == "type_integer") {
|
||||
if (qsvalidRequest("edit_fd" . $i)) {
|
||||
if (isset($champ[$i]['libs']['table'])) {
|
||||
$tmp=qsrequest("edit_fd" . $i);
|
||||
$idata =$tmp[0];
|
||||
} else
|
||||
$idata = qsrequest("edit_fd" . $i);
|
||||
if (is_numeric($idata)) {
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = " . $idata;
|
||||
} else {
|
||||
$err_string .= "<strong>Erreur :</strong> lors de l'enregistrement de la zone '<strong>" . $field_name . "</strong>'.<br/>";
|
||||
$err_string .= "Description : type de donnée incohérent.<br>";
|
||||
}
|
||||
}
|
||||
else if($isEditables[$i] != 2) {
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = null";
|
||||
}
|
||||
} elseif ($type_field == "type_string") {
|
||||
if (qsvalidRequest("edit_fd" . $i)) {
|
||||
if (isset($champ[$i]['libs']['table']))
|
||||
$idata = implode(';', qsrequest("edit_fd" . $i));
|
||||
else
|
||||
$idata = qsrequest("edit_fd" . $i);
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = '" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
}
|
||||
else if($isEditables[$i] != 2) {
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = null";
|
||||
}
|
||||
} else {
|
||||
if (qsvalidRequest("edit_fd" . $i)) {
|
||||
$idata = qsrequest("edit_fd" . $i);
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = '" . ereg_replace("'","''",stripslashes($idata)) . "'";
|
||||
}
|
||||
else if($isEditables[$i] != 2) {
|
||||
$value_sql .= "," . $quotechar . $field_name . $quotechar . " = null";
|
||||
}
|
||||
}
|
||||
}//if ($isEditables[$i])
|
||||
}//if ($meta)
|
||||
$i++;
|
||||
}
|
||||
if (isset($_POST["act"])) {
|
||||
//print_r($_POST);die();
|
||||
if (($err_string)=="") {
|
||||
if (($value_sql)!="") {
|
||||
if (substr($value_sql, 0, 1) == ",") {
|
||||
$value_sql = substr($value_sql, 1);
|
||||
}
|
||||
$sql = 'UPDATE ' . $quotechar . mysql_field_table($result,0) . $quotechar;
|
||||
$sql .= ' SET ' . $value_sql;
|
||||
$sql .= ' WHERE ';
|
||||
$sql .= $currentrow_sql;/*
|
||||
print_r($_POST);
|
||||
echo $sql;
|
||||
die();*/
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
if (!$result = @mysql_query($sql)){
|
||||
$err_string .= "<strong>Erreur : </strong> lors de l'enregistrement en base (<strong>" . mysql_errno() . "</strong>).<br/>";
|
||||
$err_string .= "Description : " . mysql_error();
|
||||
}
|
||||
}
|
||||
#----get submit url page----
|
||||
if (qsrequest('referer')<>'')//$_SERVER['HTTP_REFERER']))
|
||||
$submiturl=genereUrl(qsrequest('referer'));
|
||||
else
|
||||
$submiturl='./list.php';
|
||||
if ($err_string == "") {
|
||||
if ($qry_string != "") {
|
||||
$URL= $submiturl . "&" . $qry_string;
|
||||
} else {
|
||||
$URL= $submiturl;
|
||||
}
|
||||
header ("Location: $URL");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($result > 0) mysql_free_result($result);
|
||||
$sql = $sql_select;
|
||||
if ($currentrow_sql != "") {
|
||||
$sql .= " where ".$currentrow_sql ;
|
||||
}
|
||||
$result = mysql_query($sql) or die("Invalid query : $sql");
|
||||
$row = mysql_fetch_array($result);
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />-->
|
||||
<title><?=htmlentities($titre)?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
|
||||
<script src="../nonimg/validate.js"></script>
|
||||
|
||||
<SCRIPT language='javascript' src='../nonimg/calendar.js'></script>
|
||||
|
||||
<script language="javascript">
|
||||
function check(frm) {
|
||||
var szAlert = "Erreur(s) :\n";
|
||||
var nIndex = 0;
|
||||
<?php
|
||||
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'] && $isEditables[$i])
|
||||
{
|
||||
/* // On test si le champ peut être vide
|
||||
?>
|
||||
if (!RequiredField(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' ne peut être vide\n";
|
||||
}
|
||||
<?
|
||||
*/ // Si le champ est au format date, ajout du test de contrôle de la date en JavaScript
|
||||
if ($formatdate[$i]<>'') {
|
||||
?>
|
||||
if (frm.edit_fd<?=$i?>.value!="" && !isDate(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' n'est pas une date valide\n";
|
||||
}
|
||||
<?
|
||||
}
|
||||
|
||||
// Si le champ est de type int au sens large, ajout du test de contrôle de validité en JavaScript
|
||||
if ($format[$i]=='int') {
|
||||
?>
|
||||
if (frm.edit_fd<?=$i?>.value!="" && !NumberValidate(frm.edit_fd<?=$i?>.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'<?=htmlentities($field['libelleColonne'])?>' n'est pas un nombre\n";
|
||||
}
|
||||
<?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
if(nIndex > 0) {
|
||||
alert(szAlert) ;
|
||||
return false ;
|
||||
}
|
||||
<?php
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'] && $isEditables[$i] && isset($champ[$i]['libs']['table'])) {
|
||||
?>
|
||||
for(i=0;i<frm.edit_fd<?=$i?>.length;i++){
|
||||
frm.edit_fd<?=$i?>.options[i].selected = true;
|
||||
}
|
||||
frm.edit_fd<?=$i?>.name = "edit_fd<?=$i?>[]";
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
return true ;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<center><strong><font size="5"><?=htmlentities($titre)?></font></strong></center><br>
|
||||
|
||||
<a name="top"></a>
|
||||
|
||||
<script>
|
||||
function getURLParam(strParamName){
|
||||
var strReturn = "";
|
||||
var strHref = window.location.href;
|
||||
if ( strHref.indexOf("?") > -1 ){
|
||||
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
|
||||
var aQueryString = strQueryString.split("&");
|
||||
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
|
||||
if (
|
||||
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
|
||||
var aParam = aQueryString[iParam].split("=");
|
||||
strReturn = aParam[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<form name="qs_edit_form" method="post" action="./edit.php" onSubmit="return check(this)">
|
||||
|
||||
<?php
|
||||
print $hidden_tag;
|
||||
print $hiddenrow_tag;
|
||||
$css_class = '"TrOdd"';
|
||||
?>
|
||||
<table Border="0" Cellpadding="2" Cellspacing="1" BgColor="#177AE9">
|
||||
<tr>
|
||||
<td colspan="2" class="ThRows" align="center"><?=htmlentities($titre)?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($err_string != '') {
|
||||
print '<tr>';
|
||||
print '<td align="left" class="ThRows"><b><font color="red">Erreur :</font></b></td>';
|
||||
print '<td align="left" colspan="2" class=' . $css_class . '>' . $err_string . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'])
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" class="ThRows"><?=htmlentities($field['libelleColonne'])?></td>
|
||||
<?php
|
||||
$cellvalue = "";
|
||||
if ((!isset($_GET["edit_fd".$i])) && (!isset($_POST["edit_fd".$i]))) {
|
||||
if ($formatdate[$i]<>'')
|
||||
$itemvalue = qsconvertdate($row[$i],"dd/mm/yyyy");
|
||||
else
|
||||
$itemvalue = $row[$i];
|
||||
} else {
|
||||
$itemvalue = qsrequest("edit_fd".$i);
|
||||
}
|
||||
if ($isEditables[$i]) {
|
||||
$cellvalue = '<input type="text" name="edit_fd'.$i.'" value="' . qsreplace_html_quote(stripslashes($itemvalue)) . '"';
|
||||
if (isset($long[$i]) && $long[$i]>0) {
|
||||
$size=$long[$i]+1;
|
||||
if ($size>80) $size=80;
|
||||
$cellvalue.=' size="'.$size.'" maxlength="'.$long[$i].'">';
|
||||
} else
|
||||
$cellvalue.='>';
|
||||
if (isset($champ[$i]['libs']['table'])){
|
||||
$libs=$champ[$i]['libs'];
|
||||
if ($format[$i]=='int') {
|
||||
$multiple='';
|
||||
$testMutipe1="if (!Selectbox.hasOneOption(this.form.edit_fd$i)) { ";
|
||||
$testMutipe2=' } ';
|
||||
} else {
|
||||
$multiple='multiple';
|
||||
$testMutipe1='';
|
||||
$testMutipe2='';
|
||||
}
|
||||
//$cellvalue='<input type="text" name="edit_fd'.$i.'" value="'. htmlentities($itemvalue).'">';
|
||||
$cellvalue ='<table><tr><td valign="top"><i>Sélectionné(s) :</i><br/><select align="top" name="edit_fd'.$i.'" size="10" '.$multiple.
|
||||
' onDblClick="Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.',this.form.edit_fd'.$i.'out, true)">'.EOL;
|
||||
if ($itemvalue<>'') {//mysql_query('SET CHARACTER SET utf8;');
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key']." IN ('".str_replace(';',"','",$itemvalue)."')",
|
||||
'edit_fd'.$i, $libs['key'], $libs['lib'],$itemvalue);}
|
||||
$cellvalue.='</select></td><td align="center">'.EOL;
|
||||
// onDblClick="Selectbox.moveSelectedOptions(this.form.list1,this.form.list2,this.form.movesort.checked,this.form.movepattern1.value)">
|
||||
// onClick="Selectbox.moveSelectedOptions(this.form.list1,this.form.list2,this.form.movesort.checked,this.form.movepattern1.value)"><br><br>
|
||||
$cellvalue.='<input type="button" VALUE=">" onClick="Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.', this.form.edit_fd'.$i.'out, true)"><br/>'.EOL;
|
||||
if ($multiple<>'')
|
||||
$cellvalue.='<input type="button" VALUE=">>" onClick="Selectbox.moveAllOptions(this.form.edit_fd'.$i.', this.form.edit_fd'.$i.'out, true)"><br/>'.EOL;
|
||||
$cellvalue.='<br/><input type="button" VALUE="<" onClick="'.$testMutipe1.'Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.'out, this.form.edit_fd'.$i.', true)'.$testMutipe2.'"><br/>'.EOL;
|
||||
if ($multiple<>'')
|
||||
$cellvalue.='<input type="button" VALUE="<<" onClick="Selectbox.moveAllOptions(this.form.edit_fd'.$i.'out, this.form.edit_fd'.$i.', true)"><br/>'.EOL;
|
||||
|
||||
$cellvalue.='</td><td><i>Disponible(s) :</i><br/><select align="top" name="edit_fd'.$i.'out" SIZE="10" '.$multiple.
|
||||
'onDblClick="'.$testMutipe1.'Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.'out,this.form.edit_fd'.$i.', true)'.$testMutipe2.'">'.EOL;
|
||||
if ($itemvalue<>'')
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key']." NOT IN ('".str_replace(';',"','",$itemvalue)."')",
|
||||
'edit_fd'.$i.'out', $libs['key'], $libs['lib'],$itemvalue);
|
||||
else
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'],
|
||||
'edit_fd'.$i.'out', $libs['key'], $libs['lib'],$itemvalue);
|
||||
$cellvalue.='</select></td></tr></table>'.EOL;
|
||||
}
|
||||
elseif ($format[$i]=='date') $cellvalue.='<a href="#edit_fd'.$i.'"></a><a name="edit_fd'.$i.'"><img src="../images/Calendar.gif" onclick="popUpCalendar(this, document.forms[0].edit_fd'.$i.', \'dd/mm/yyyy\', 0, 0)" align="absmiddle" border="0" height="21" width="20"></a>';
|
||||
elseif ($format[$i]=='text') $cellvalue ='<textarea name="edit_fd'.$i.'" rows=4 cols=40>' . qsreplace_html_quote(stripslashes($itemvalue)) . '</textarea>';
|
||||
elseif ($format[$i]=='enum') {
|
||||
$cellvalue='';
|
||||
foreach ($formatEnum[$i] as $value) {
|
||||
$value=utf8_encode($value);
|
||||
$cellvalue.= '<input type="radio" name="edit_fd'.$i.'" value="'.$value. '" ';
|
||||
$cellvalue.= qscheckselected($value,$itemvalue,' checked="checked"') .'>'.$value.'<br/>';
|
||||
}
|
||||
}
|
||||
/*'fields_libs' =>array( 'typeEven'=>array('table'=>'jo.tabEvenements',
|
||||
'key'=>'codEven',
|
||||
'lib'=>'libEven')),*/
|
||||
if ($champ[$i]['link']<>'') { // Le champ comporte un lien vers une autre source de données
|
||||
$tmp=explode('.', $champ[$i]['link']);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
if (isset($tmp[2])) $cles = 'uniqueKey='.$tmp[2].'&value='.$itemvalue;
|
||||
else $cles = 'currentrow_fd'.$i.'='.$itemvalue;
|
||||
$cellvalue.= ' <a href="./edit.php?dbtable='.$database.'.'.$table.'&'.$cles.'&refererUrl='.urlencode($_SERVER['REQUEST_URI']).'">Lien</a>';
|
||||
}
|
||||
}
|
||||
else { // Le champ n'est pas éditable
|
||||
if ($champ[$i]['link']<>'') { // Le champ comporte un lien vers une autre source de données
|
||||
$tmp=explode('.', $champ[$i]['link']);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
if (isset($tmp[2])) $cles = 'uniqueKey='.$tmp[2].'&value='.$itemvalue;
|
||||
else $cles = 'currentrow_fd'.$i.'='.$itemvalue;
|
||||
$cellvalue = '<a href="./edit.php?dbtable='.$database.'.'.$table.'&'.$cles.'&refererUrl='.urlencode($_SERVER['REQUEST_URI']).'">'.$itemvalue.'</a>';
|
||||
}
|
||||
elseif (isset($champ[$i]['libs']['table'])) { // Le champ a une table liée
|
||||
$libs=$champ[$i]['libs'];
|
||||
//$cellvalue='<input type="text" name="edit_fd'.$i.'" value="'. htmlentities($itemvalue).'">';
|
||||
$cellvalue =str_replace(array("\n\r","\r\n","\n","\r"),"<br>",qsmysqlgen_listvisu('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key']." IN ('".str_replace(';',"','",$itemvalue)."')",
|
||||
'edit_fd'.$i, $libs['key'], $libs['lib'],$itemvalue));
|
||||
}
|
||||
else // On afiche laa valeur du champ
|
||||
$cellvalue = $itemvalue;
|
||||
}
|
||||
if ($cellvalue == '') {
|
||||
$cellvalue = ' ';
|
||||
}
|
||||
print '<td class=' . $css_class . ' align="left">' . $cellvalue . '</td>';
|
||||
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
#----get back url page----
|
||||
if (qsrequest('referer')<>'')//$_SERVER['HTTP_REFERER']))
|
||||
$backurl=genereUrl(qsrequest('referer'));
|
||||
elseif (qsrequest('refererUrl')<>'')//))
|
||||
$backurl=qsrequest('refererUrl');
|
||||
elseif ($_SERVER['HTTP_REFERER'])
|
||||
$backurl = $_SERVER['HTTP_REFERER'];
|
||||
else
|
||||
$backurl = "./list.php";
|
||||
//else $backurl=$_SERVER['HTTP_REFERER'];
|
||||
?>
|
||||
<tr>
|
||||
<td class="ThRows"> </td>
|
||||
<td class="TrOdd" align="center">
|
||||
<input type="hidden" name="act" value="n">
|
||||
<input type="hidden" name="referer" value="<?=qsrequest('referer')?>">
|
||||
<input type="button" name="QS_Back" value="Retour" OnClick="javascript:window.location='<?=$backurl?>'">
|
||||
<?php if (@!$tablesInfo[$dbtable]['table_readOnly']) { ?>
|
||||
<input type="submit" name="QS_Submit" value="Sauvegarde">
|
||||
<input type="reset" name="QS_Reset" value="Réinitialisation">
|
||||
<?php } elseif ($page=='view') { ?>
|
||||
<input type="button" name="QS_Edit" value="Edition" onclick="javascript:window.location='<?=str_replace('/view.php?', '/edit.php?', $_SERVER['REQUEST_URI'])?>'">
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
</Table><br>
|
||||
</Form>
|
||||
<?php
|
||||
if ($link > 0) {mysql_close($link);}
|
||||
?>
|
||||
<a name="bottom"></a>
|
||||
</center>
|
||||
</body>>
|
||||
</html>
|
34
html/gestion/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include('tables.php');
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<head>
|
||||
<!--<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Gestion des informations de la base de données</title>
|
||||
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
|
||||
</head>
|
||||
<body>
|
||||
<p align="center" class="fontheader"><strong>Gestion des informations de la base de données</strong></p>
|
||||
<table BgColor="#177AE9" cellspacing="1" cellpadding="2" width="420" border="0" align="center" BorderColor="#000020">
|
||||
<tr BgColor="#589FED">
|
||||
<td width="319" height="40"><font color="#006699"> </font></td>
|
||||
<td width="89" height="40" align="center" valign="middle" BgColor="#589FED" class="fontnormal"><strong><font color="#FFFFFF">List Page</font></strong></td>
|
||||
<td width="92" height="40" align="center" valign="middle" class="fontnormal"><font color="#FFFFFF"><strong>Control Panel</strong></font></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($tablesDisp as $table=>$libelle) {
|
||||
?>
|
||||
<tr BgColor="#E2EEFC">
|
||||
<td height="40" BgColor="#589FED" class="fontnormal"><font color="#FFFFFF"><strong> <?=htmlentities($libelle)?></strong></font></td>
|
||||
<td height="40" align="center" valign="middle"><a href="./list.php?clearsession=1&dbtable=<?=$table?>"><img src="../images/bt_list.gif" border="0"></td>
|
||||
<td height="40" align="center" valign="middle"><a href="<?/*mandataires_control_panel.html*/?>#"><img src="../images/bt_panel.gif" border="0"></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
729
html/gestion/list.php
Normal file
@ -0,0 +1,729 @@
|
||||
<?php
|
||||
//print_r($_POST);die();
|
||||
|
||||
if (!isset($page))
|
||||
$page=str_replace('.php', '', basename(__FILE__));
|
||||
|
||||
include_once('tables.php');
|
||||
require_once('qs_functions.php');
|
||||
require_once('default.php');
|
||||
echo "<!--\n_SESSION\n";
|
||||
print_r($_SESSION);
|
||||
echo "_SERVER\n";
|
||||
print_r($_SERVER);
|
||||
echo "_REQUEST\n";
|
||||
print_r($_REQUEST);
|
||||
echo "-->\n";
|
||||
|
||||
if (!isset($titre))
|
||||
$titre='Liste des '.$table;
|
||||
$nbLignesParPage = 30;
|
||||
mysql_query('SET CHARACTER SET utf8;');
|
||||
$query="$sql $sql_ext limit 0,1";
|
||||
//echo $query.'<br/>';
|
||||
|
||||
if(!$result = @mysql_query($query)){
|
||||
$err_string .= "<strong>Error:</strong>while connecting to database<br>" . mysql_error();
|
||||
}
|
||||
if ($err_string != "") {
|
||||
print "<Center><Table Border=\"0\" Cellspacing=\"1\" bgcolor=\"#CCCCCC\" >";
|
||||
print "<tr>";
|
||||
print "<td height=\"80\" align=\"Default\" bgcolor=\"#FFFFFF\">";
|
||||
print "<font color=\"#000099\" size=\"2\">";
|
||||
print $err_string;
|
||||
print "</font>";
|
||||
print "</td>";
|
||||
print "</tr>";
|
||||
print "</Table></Center>";
|
||||
exit;
|
||||
} //==end if $err_string != ""
|
||||
if (qsrequest("clearsession") == '1') {
|
||||
$_SESSION[$sessionPage."_page"] = '';
|
||||
$_SESSION[$sessionPage."_sortfield"] = '';
|
||||
$_SESSION[$sessionPage."_sortby"] = '';
|
||||
} //==end if clearsession
|
||||
$filter_string = '';
|
||||
$filter_stringmaster = '';
|
||||
$qry_string = '';
|
||||
$i = 0;
|
||||
$searchendkey ='';
|
||||
$searchstartkey = '';
|
||||
while ($i < mysql_num_fields($result)) {
|
||||
$meta = mysql_fetch_field($result);
|
||||
$field_name = $meta->name;
|
||||
$field_table = $meta->table;
|
||||
$field_type = $meta->type;
|
||||
$type_field = "";
|
||||
$type_field = returntype($field_type);
|
||||
if (($searchmode[$i])==0) { # 0 = Std, 1 = Advance
|
||||
if (($stdsearchopt[$i])==0) { //==0=Contain , 1 = Equal : for standard mode
|
||||
$searchstartkey = "%";
|
||||
$searchendkey = "%";
|
||||
} else {
|
||||
$searchstartkey = "";
|
||||
$searchendkey = "";
|
||||
}
|
||||
} else { //==end if searchmode = 0
|
||||
$searchstartkey= "";
|
||||
$searchendkey = "";
|
||||
} //==end if searchmode <> 0
|
||||
if (qsrequest("clearsession") == "1") {
|
||||
$_SESSION[$sessionPage."_search_fd" . $i] = "";
|
||||
$_SESSION[$sessionPage."_multisearch_fd" . $i] = "";
|
||||
$_SESSION[$sessionPage."_search_fd_" . $i] = "";
|
||||
} //==end if clearsession
|
||||
if (qsrequest("search_fd" . $i) != "") {
|
||||
$_SESSION[$sessionPage."_search_fd" . $i] = qsrequest("search_fd" . $i);
|
||||
}
|
||||
if (qsrequest("search_fd" . $i) != "") {
|
||||
$_SESSION[$sessionPage."_multisearch_fd" . $i] = qsrequest("multisearch_fd" . $i);
|
||||
}
|
||||
if (qsrequest("search_fd" . $i) != "") {
|
||||
$_SESSION[$sessionPage."_search_fd_" . $i] = qsrequest("search_fd_" . $i);
|
||||
}
|
||||
if ((qssession($sessionPage."_search_fd" . $i) != "") && (qssession($sessionPage."_search_fd" . $i) != "*")) {
|
||||
$idata = qssession($sessionPage."_search_fd" . $i);
|
||||
$icon = " AND ";
|
||||
$ioldcon = "";
|
||||
if (substr($idata, 0, 2) == "||") {
|
||||
$icon = " Or ";
|
||||
$ioldcon = "||";
|
||||
$iopt = substr($idata, 2, 2);
|
||||
$idata = substr($idata, 2);
|
||||
}else{
|
||||
$iopt = substr($idata, 0, 2);
|
||||
}
|
||||
$idata = str_replace("*", "%", $idata);
|
||||
$irealdata = $idata;
|
||||
$iopt = substr($idata, 0, 2);
|
||||
if (($iopt == "<=") || ($iopt == "=<")) {
|
||||
$iopt = "<=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif (($iopt == ">=") || ($iopt == "=>")) {
|
||||
$iopt = ">=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "==") {
|
||||
$iopt = "=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "<>") {
|
||||
$irealdata = substr($idata, 2);
|
||||
} else {
|
||||
$iopt = substr($idata, 0, 1);
|
||||
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
|
||||
$irealdata = substr($idata,1);
|
||||
} else {
|
||||
$iopt = "=";
|
||||
}
|
||||
}
|
||||
if (!strcasecmp($idata,"{current date and time}")) {
|
||||
$idata = time();
|
||||
} elseif (!strcasecmp($idata,"{current date}")) {
|
||||
$idata = time();
|
||||
} elseif (!strcasecmp($idata,"{current time}")) {
|
||||
$idata = time();
|
||||
}
|
||||
if ($meta) {
|
||||
if ($type_field == "type_datetime") {
|
||||
/** @todo ne gère pas les dates anglaises ainsi que les heures minutes sec **/
|
||||
$tmp=explode('/',$idata);//12/08/1977
|
||||
$idata=$tmp[2].'-'.$tmp[1].'-'.$tmp[0];
|
||||
$irealdata=$idata;
|
||||
if ((($timestamp = strtotime($irealdata)) !== -1)) {
|
||||
if (($iopt)=="="){
|
||||
$conditionstr = " = ";
|
||||
$istrdata = str_replace("=", "", $istrdata);
|
||||
} else {
|
||||
$conditionstr = $iopt;
|
||||
$istrdata = $irealdata;
|
||||
$searchstartkey = "";
|
||||
$searchendkey = "";
|
||||
}
|
||||
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
|
||||
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$searcharray = split(",",$multisearch);
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string = '(DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr . " ". $quotedate . $irealdata . $quotedate;
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " ". $quotedate . $irealdata . $quotedate;
|
||||
}
|
||||
$filter_string .= ")";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string .= ' AND (DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr .' '. $quotedate . $irealdata . $quotedate;
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
|
||||
}
|
||||
$filter_string .= ")";
|
||||
}
|
||||
} else {
|
||||
echo 'ici';
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string = 'DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr . " " . $quotedate . $irealdata . $quotedate;
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster = $parammaster[$i] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
|
||||
}
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string .= $icon .'DATE_FORMAT('. $fields[$i] .", '%Y-%m-%d')". $conditionstr . " " . $quotedate . $irealdata . $quotedate;
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster .= $icon . $parammaster[$i] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Invalid DateTime.<br>";
|
||||
}
|
||||
//==end $type_field == "type_datetime"
|
||||
} elseif ($type_field == "type_integer") {
|
||||
$irealdata = str_replace("%", "", $irealdata);
|
||||
if (is_numeric($irealdata)) {
|
||||
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
|
||||
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$searcharray = split(",",$multisearch);
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . $idata;
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string = "(" . $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
$filter_string .= ")";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . $idata;
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string .= " AND (" . $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
$filter_string .= ")";
|
||||
}
|
||||
} else {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . $idata;
|
||||
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster = $parammaster[$i] . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . $idata;
|
||||
$filter_string .= $icon . $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster .= $icon . $parammaster[$i] . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Type mismatch.<br>";
|
||||
}
|
||||
//==end $type_field == "type_integer"
|
||||
} elseif ($type_field == "type_string") {
|
||||
if (($iopt)=="="){
|
||||
$conditionstr = " LIKE ";
|
||||
$istrdata = str_replace("=", "", $istrdata);
|
||||
} else {
|
||||
$conditionstr = $iopt;
|
||||
$istrdata = $irealdata;
|
||||
$searchstartkey = "";
|
||||
$searchendkey = "";
|
||||
}
|
||||
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
|
||||
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$searcharray = split(",",$multisearch);
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string = "(" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
|
||||
}
|
||||
$filter_string .= ")";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
}
|
||||
$filter_string .= ")";
|
||||
}
|
||||
} else {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string = $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster = $parammaster[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
}
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string .= $icon . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster .= $icon . $parammaster[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
//==end $type_field == "type_string"
|
||||
} else {
|
||||
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
|
||||
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$searcharray = split(",",$multisearch);
|
||||
$irealdata = str_replace("%", "", $irealdata);
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string = "(" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
}
|
||||
$filter_string .= ")";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
|
||||
$filter_string .= " AND (" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
$j = 0;
|
||||
for ($j = 0; $j < count($searcharray); $j++) {
|
||||
$searchindex = $searcharray[$j];
|
||||
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
}
|
||||
$filter_string .= ")";
|
||||
}
|
||||
} else {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string = $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster = $parammaster[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
}
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
|
||||
$filter_string .= $icon . $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
if ($parammaster[$i] != ""){
|
||||
$filter_stringmaster .= $icon . $parammaster[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
} //==end $type_field == "type_unknown
|
||||
} //==end if ($meta)
|
||||
} //==end if search_fd(n) <> ""
|
||||
//==Begin Search between
|
||||
if (qssession($sessionPage."_search_fd_" . $i)) {
|
||||
$idata = qssession($sessionPage."_search_fd_" . $i);
|
||||
$idata = str_replace("*", "%", $idata);
|
||||
$irealdata = $idata;
|
||||
$iopt = substr($idata, 0, 2);
|
||||
if (($iopt == "<=") || ($iopt == "=<")) {
|
||||
$iopt = "<=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif (($iopt == ">=") || ($iopt == "=>")) {
|
||||
$iopt = ">=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "==") {
|
||||
$iopt = "=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "<>") {
|
||||
$irealdata = substr($idata, 2);
|
||||
} else {
|
||||
$iopt = substr($idata, 0, 1);
|
||||
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
|
||||
$irealdata = substr($idata,1);
|
||||
} else {
|
||||
$iopt = "=";
|
||||
}
|
||||
}
|
||||
if ($meta) {
|
||||
if ($type_field == "type_datetime") {
|
||||
if ((($timestamp = strtotime($irealdata)) !== -1)) {
|
||||
if (($iopt)=="="){
|
||||
$conditionstr = " = ";
|
||||
$istrdata = str_replace("=", "", $istrdata);
|
||||
} else {
|
||||
$conditionstr = $iopt;
|
||||
$istrdata = $irealdata;
|
||||
$searchstartkey = "";
|
||||
$searchendkey = "";
|
||||
}
|
||||
}
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
|
||||
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate .$searchstartkey . $irealdata . $searchendkey . $quotedate;
|
||||
} else {
|
||||
$qry_string .= "&search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
|
||||
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
|
||||
}
|
||||
//==end $type_field == "type_datetime"
|
||||
} elseif ($type_field == "type_integer") {
|
||||
$irealdata = str_replace("%", "", $irealdata);
|
||||
if (is_numeric($irealdata)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd_" . $i . "=" . $iopt . $irealdata;
|
||||
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
} else {
|
||||
$qry_string .= "&search_fd_" . $i . "=" . $iopt . $irealdata;
|
||||
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Type mismatch.<br>";
|
||||
}
|
||||
} //==end $type_field == "type_integer"
|
||||
} //==end if ($meta)
|
||||
} //==end if search_fd_(n) <> "" for between search
|
||||
$i++;
|
||||
} //==end while loop field index
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
if ($filter_string != "") {
|
||||
$filter_string = "(" . $filter_string . ")";
|
||||
if (strpos(strtoupper($sql), "WHERE")) {
|
||||
$sql .= " AND " . $filter_string;
|
||||
}else{
|
||||
$sql .= " WHERE " . $filter_string;
|
||||
}
|
||||
}
|
||||
$n = 0;
|
||||
if (qssession($sessionPage."_page") != "") {
|
||||
$parampage = explode("||", qssession($sessionPage."_page"));
|
||||
$n = count($parampage);
|
||||
}
|
||||
$current_page = 1;
|
||||
if ($n > 0) {
|
||||
if ($parampage[0] != "") {
|
||||
$current_page = $parampage[0];
|
||||
}
|
||||
if ($parampage[1] != "") {
|
||||
$nbLignesParPage = $parampage[1];
|
||||
}
|
||||
}
|
||||
if (qsrequest("page")<>"") {
|
||||
$current_page = qsrequest("page");
|
||||
}
|
||||
if (qsrequest("page_size")<>"") {
|
||||
if(qsrequest("page_size") != $nbLignesParPage) {
|
||||
$current_page = 1;
|
||||
}
|
||||
$nbLignesParPage = qsrequest("page_size");
|
||||
}
|
||||
|
||||
$sessionPage=$database.'_'.$table;
|
||||
|
||||
$_SESSION[$sessionPage."_page"] = $current_page . "||" . $nbLignesParPage;
|
||||
if (qsrequest("sortfield") != "") {
|
||||
$_SESSION[$sessionPage."_sortfield"] = qsrequest("sortfield");
|
||||
}
|
||||
if (qsrequest("sortby") != "") {
|
||||
$_SESSION[$sessionPage."_sortby"] = qsrequest("sortby");
|
||||
}
|
||||
if (qssession($sessionPage."_sortfield")) {
|
||||
//print_r($_SESSION);die();
|
||||
$sql = $sql . " ORDER BY " . stripslashes(qssession($sessionPage."_sortfield")) . " " . stripslashes(qssession($sessionPage."_sortby"));
|
||||
$sortstring = "&sortfield=" . qssession($sessionPage."_sortfield") . "&sortby=" . qssession($sessionPage."_sortby");
|
||||
} else {
|
||||
$sql = $sql . " " . $sql_ext;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<head>
|
||||
<!--<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />-->
|
||||
<title><?=htmlentities($titre)?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
|
||||
</head>
|
||||
<body>
|
||||
<SCRIPT language=JavaScript>
|
||||
function cell_over(cell, classname) {
|
||||
if (document.all || document.getElementById) {
|
||||
cell.classBackup = cell.className;
|
||||
cell.className = classname;
|
||||
}
|
||||
}
|
||||
function cell_out(cell)
|
||||
{
|
||||
if (document.all || document.getElementById) {
|
||||
cell.className = cell.classBackup;
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
|
||||
<Center>
|
||||
<center><strong><font size="5"><?=htmlentities($titre)?></font></strong></center><br>
|
||||
<a name="top"></a>
|
||||
<?php
|
||||
echo '<!--'.EOL.'$sql="'.$sql.'"-->'.EOL;
|
||||
$sql_count=preg_replace('/^SELECT (.*) FROM /', 'SELECT COUNT(*) FROM ', $sql);
|
||||
//echo '$sql_count="'.$sql_count.'"<br/>';
|
||||
$result = mysql_query($sql_count)
|
||||
or die("Invalid query : $sql_count\n" . mysql_error() );
|
||||
$row = mysql_fetch_row($result);
|
||||
$num_rows = $row[0];
|
||||
//die($num_rows);
|
||||
|
||||
$page_count = ceil($num_rows/$nbLignesParPage);
|
||||
if ($current_page > $page_count) { $current_page = 1; }
|
||||
if ($current_page < 1) { $current_page = 1; }
|
||||
if ($page_count < 1) { $page_count = 1; }
|
||||
if ($filter_string !=""){
|
||||
echo '<b>Recherche : </b>';
|
||||
foreach ($fields as $k=>$searchFd) {
|
||||
if (qsrequest('search_fd'.$k))
|
||||
echo htmlentities($champ[$k]['libelleColonne']).' = '.qsrequest('search_fd'.$k).', ';
|
||||
}
|
||||
print '<h4>Nombre d\'enregistrements correspondants à votre recherche : '.$num_rows.'</h4>';//.$filter_string;
|
||||
// echo '<br/>';
|
||||
}
|
||||
|
||||
if ($qry_string != "") {
|
||||
$navqry_string = "&" . $qry_string;
|
||||
} else {
|
||||
$navqry_string = "";
|
||||
}
|
||||
$limDeb=($current_page-1)*$nbLignesParPage;
|
||||
$sql_select_limit=$sql . " LIMIT $limDeb,$nbLignesParPage";
|
||||
$result = mysql_query($sql_select_limit)
|
||||
or die("Invalid query $sql_select_limit<br/>\n" . mysql_error() );
|
||||
?>
|
||||
<table height="30" border="0" align="center" cellpadding="0" cellspacing="0">
|
||||
<tr align="center" valign="middle">
|
||||
<td width="35" align="center"><A HREF="index.php"><img src="../images/bt_controlpanel.gif" border="0" align="absmiddle" title="Retour à la gestion"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<td width="35" align="center"><A HREF="mandataires_control_panel.html"><img src="../images/bt_controlpanelgroup.gif" border="0" align="absmiddle" title="Retour au panneau de contrôle"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<form action="list.php" method="post" name="QSSelectPage">
|
||||
<td width="35" align="center"><A HREF="list.php?clearsession=1"><img src="../images/bt_qsshowall.gif" border="0" align="absmiddle" title="Supprimer le(s) filtre(s)"></a></td><td width="8"></td>
|
||||
<td width="35" align="center"><A HREF="search.php?<?=$qry_string?>"><img src="../images/bt_qssearch.gif" border="0" align="absmiddle" title="Rechercher"></a></td><td width="8"></td>
|
||||
<td width="35" align="center"><A HREF="add.php?<?=$qry_string?>"><img src="../images/bt_qsadd_new.gif" border="0" align="absmiddle" title="Ajouter"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<?php
|
||||
if ($current_page > 1) {
|
||||
print '<td width="35" align="center"><a href="list.php?page=1"><img src="../images/bt_qsfirst.gif" border="0" align="absmiddle" title="Première page"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><a href="list.php?page='.($current_page-1).'"><img src="../images/bt_qsback.gif" border="0" align="absmiddle" title="Page précédente"></a></td><td width="8"></td>';
|
||||
} else {
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsfirst_inact.gif" border="0" align="absmiddle" title="Première page"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsback_inact.gif" border="0" align="absmiddle" title="Page précédente"></a></td><td width="8"></td>';
|
||||
|
||||
}
|
||||
print "<td width=\"35\" align=\"center\"><select name=\"page\" onChange=\"window.location='list.php?page=' + this.value; \">";
|
||||
for ($i=1; $i<=$page_count; $i++) {
|
||||
$iDeb=$current_page-10;
|
||||
$iFin=$current_page+10;
|
||||
if ($i==1 || ($i>$iDeb && $i<$iFin)) {
|
||||
?>
|
||||
<option value="<?=$i?>" <?if($i==$current_page) echo 'selected';?>><?=$i?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
print '</select></td><td width="8"></td>';
|
||||
if ($current_page < $page_count) {
|
||||
print '<td width="35" align="center"><a href="list.php?page='.($current_page+1).'"><img src="../images/bt_qsnext.gif" border="0" align="absmiddle" title="Page suivante"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><a href="list.php?page='.$page_count.'"><img src="../images/bt_qslast.gif" border="0" align="absmiddle" title="Dernière page"></a></td><td width="8"></td>';
|
||||
} else {
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsnext_inact.gif" border="0" align="absmiddle" title="Page suivante"></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><img src="../images/bt_qslast_inact.gif" border="0" align="absmiddle" title="Dernière page"></td><td width="8"></td>';
|
||||
}
|
||||
?>
|
||||
<td width="35" align="center"><a href="#bottom"><img src="../images/bt_qsbottom.gif" border="0" align="absmiddle" title="Atteindre le bas de la page"></a></td><td width="8"></td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
<?php
|
||||
if ($num_rows > 0) {
|
||||
?>
|
||||
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#177AE9">
|
||||
<tr>
|
||||
<td class="ThRows"> </td>
|
||||
<?php
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'])
|
||||
{
|
||||
$nextsortasc = qssortasc(qssession($sessionPage."_sortfield"), $fields[$i], qssession($sessionPage."_sortby"), "Tri croissant");
|
||||
$nextsortdesc = qssortdesc(qssession($sessionPage."_sortfield"), $fields[$i], qssession($sessionPage."_sortby"), "Tri décroissant");
|
||||
?>
|
||||
<td class="ThRows" NOWRAP ><a href="list.php?sortfield=<?php print urlencode(stripslashes($fields[$i]));?>&sortby=ASC<?php print $navqry_string; ?>"><?php print $nextsortasc; ?></a>
|
||||
<?=htmlentities($field['libelleColonne'])?>
|
||||
<a href="list.php?sortfield=<?php print urlencode(stripslashes($fields[$i]));?>&sortby=DESC<?php print $navqry_string; ?>"><?php print $nextsortdesc; ?></a></td>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
// Bouton SUPPRIMER
|
||||
if (isset($tablesInfo[$dbtable]['table_readOnly']) && !$tablesInfo[$dbtable]['table_readOnly'])
|
||||
echo '<td class="ThRows" >Delete</td>';
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$rowcount = 0;
|
||||
/*$current_row = ($current_page - 1)*$nbLignesParPage+1;
|
||||
if (($num_rows >= $limDeb) && ($current_row < $limDeb+$nbLignesParPage)) {
|
||||
mysql_data_seek($result, $current_row);
|
||||
}*/
|
||||
while (($row = mysql_fetch_array($result)) && ($rowcount < $nbLignesParPage)) {
|
||||
|
||||
if (($rowcount%2) == 0) {
|
||||
$css_class = 'TrOdd';
|
||||
} else {
|
||||
$css_class = 'TrRows';
|
||||
}
|
||||
|
||||
// Début de la ligne
|
||||
print '<tr class="'.$css_class.'" onmouseover="cell_over(this, \'TrHover\')" onmouseout="cell_out(this)">';
|
||||
$cellvalue = '<img src="../images/bt_edit.gif" border="0" title="Détail" onerror="this.onerror=null;this.src=\'../images/qs_nopicture.gif\';">';
|
||||
|
||||
// Bouton EDITER
|
||||
print '<td align="center">';
|
||||
// On génère l'URL d'accès à la visu en récupérant les ckés primaires de la table !
|
||||
$strKeys='';
|
||||
foreach ($primary_keys as $nomKey=>$numKey) {
|
||||
$strKeys.='currentrow_fd'.$numKey.'='.urlencode($row[$numKey]).'&';
|
||||
}
|
||||
print '<a name="row'.$rowcount.'" href="./view.php?'.$strKeys.'referer=list.'.$current_page.'.'.$rowcount.'">'.$cellvalue.'</a>';
|
||||
print '</td>';
|
||||
|
||||
// Boucle sur les zones
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'])
|
||||
{
|
||||
$align=$field['align'];
|
||||
if ($formatdate[$i]<>'')
|
||||
$cellvalue = qsconvertdate($row[$i],"dd/mm/yyyy");
|
||||
else
|
||||
$cellvalue = $row[$i];
|
||||
if ($cellvalue != "") {
|
||||
if (isset($champ[$i]['libs']['table'])){
|
||||
$libs=$champ[$i]['libs'];
|
||||
$tmp=str_replace(';',',',"'$cellvalue'");
|
||||
if (substr($tmp,-1)==',') $tmp=substr($tmp,0, -1);
|
||||
$cellvalue =str_replace(array("\n\r","\r\n","\n","\r"),"<br>",qsmysqlgen_listvisu('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key'].' IN ('.$tmp.')',
|
||||
'edit_fd'.$i, $libs['key'], $libs['lib'],$cellvalue));
|
||||
}
|
||||
else
|
||||
$cellvalue = str_replace(array("\n\r","\r\n","\n","\r"),"<br>",$cellvalue);
|
||||
}
|
||||
else {
|
||||
$cellvalue = " ";
|
||||
}
|
||||
print "<td align=$align>";
|
||||
print $cellvalue;
|
||||
print "</td>";
|
||||
}
|
||||
}
|
||||
|
||||
// Bouton SUPPRIMER
|
||||
if (isset($tablesInfo[$dbtable]['table_readOnly']) && !$tablesInfo[$dbtable]['table_readOnly'])
|
||||
{
|
||||
$cellvalue = "<img src=\"" . "../images/bt_delete.gif" . "\" border=\"0\" title=\"Delete\" onerror=\"this.onerror=null;this.src='../images/qs_nopicture.gif';\" >";
|
||||
if ($cellvalue != "") {
|
||||
$cellvalue = str_replace(array("\n\r","\r\n","\n","\r"),"<br>",$cellvalue);
|
||||
}
|
||||
else {
|
||||
$cellvalue = " ";
|
||||
}
|
||||
print "<td align=Center >";
|
||||
print "<a href=\"" . "./supprime.php?" . ""."currentrow_fd0=" . urlencode($row[0]) . "" . "\" >" . $cellvalue . "</a>";
|
||||
print "</td>";
|
||||
}
|
||||
print "</tr>";
|
||||
$rowcount = $rowcount + 1;
|
||||
|
||||
|
||||
//$cellvalue = "" . number_format($row[8],0,".",",") . "";
|
||||
// print "<td align=Right >";
|
||||
// $cellvalue = "" . qsconvertdate($row[21],"mm/dd/yyyy") . "";
|
||||
}//end while
|
||||
?>
|
||||
</Table><br>
|
||||
<?
|
||||
}else{
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($filter_string != ""){
|
||||
?><Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
|
||||
<tr>
|
||||
<td height="80" align="Default" bgcolor="#FFFFFF">
|
||||
<font color="#000099" size="2">Pas de réponse pour cette recherche !</font>
|
||||
</td>
|
||||
</tr>
|
||||
</Table><br>
|
||||
|
||||
<?php
|
||||
}else{
|
||||
?><Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
|
||||
<tr>
|
||||
<td height="80" align="Default" bgcolor="#FFFFFF">
|
||||
<font color="#000099" size="2">Aucune donnée n'est présente en base !</font>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</Table><br>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ($qry_string != "") {
|
||||
$navqry_string = "&" . $qry_string;
|
||||
} else {
|
||||
$navqry_string = "";
|
||||
}
|
||||
?>
|
||||
<table height="30" border="0" align="center" cellpadding="0" cellspacing="0">
|
||||
<tr align="center" valign="middle">
|
||||
<td width="35" align="center"><A HREF="index.php"><img src="../images/bt_controlpanel.gif" border="0" align="absmiddle" title="Retour à la gestion"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<td width="35" align="center"><A HREF="mandataires_control_panel.html"><img src="../images/bt_controlpanelgroup.gif" border="0" align="absmiddle" title="Retour au panneau de contrôle"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<form action="list.php" method="post" name="QSSelectPage">
|
||||
<td width="35" align="center"><A HREF="list.php?clearsession=1"><img src="../images/bt_qsshowall.gif" border="0" align="absmiddle" title="Supprimer le(s) filtre(s)"></a></td><td width="8"></td>
|
||||
<td width="35" align="center"><A HREF="search.php?<?=$qry_string?>"><img src="../images/bt_qssearch.gif" border="0" align="absmiddle" title="Rechercher"></a></td><td width="8"></td>
|
||||
<td width="35" align="center"><A HREF="add.php?<?=$qry_string?>"><img src="../images/bt_qsadd_new.gif" border="0" align="absmiddle" title="Ajouter"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
|
||||
<?php
|
||||
if ($current_page > 1) {
|
||||
print '<td width="35" align="center"><a href="list.php?page=1"><img src="../images/bt_qsfirst.gif" border="0" align="absmiddle" title="Première page"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><a href="list.php?page='.($current_page-1).'"><img src="../images/bt_qsback.gif" border="0" align="absmiddle" title="Page précédente"></a></td><td width="8"></td>';
|
||||
} else {
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsfirst_inact.gif" border="0" align="absmiddle" title="Première page"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsback_inact.gif" border="0" align="absmiddle" title="Page précédente"></a></td><td width="8"></td>';
|
||||
|
||||
}
|
||||
print "<td width=\"35\" align=\"center\"><select name=\"page\" onChange=\"window.location='list.php?page=' + this.value; \">";
|
||||
for ($i=1; $i<=$page_count; $i++) {
|
||||
$iDeb=$current_page-10;
|
||||
$iFin=$current_page+10;
|
||||
if ($i==1 || ($i>$iDeb && $i<$iFin)) {
|
||||
?>
|
||||
<option value="<?=$i?>" <?if($i==$current_page) echo 'selected';?>><?=$i?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
print '</select></td><td width="8"></td>';
|
||||
if ($current_page < $page_count) {
|
||||
print '<td width="35" align="center"><a href="list.php?page='.($current_page+1).'"><img src="../images/bt_qsnext.gif" border="0" align="absmiddle" title="Page suivante"></a></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><a href="list.php?page='.$page_count.'"><img src="../images/bt_qslast.gif" border="0" align="absmiddle" title="Dernière page"></a></td><td width="8"></td>';
|
||||
} else {
|
||||
print '<td width="35" align="center"><img src="../images/bt_qsnext_inact.gif" border="0" align="absmiddle" title="Page suivante"></td><td width="8"></td>';
|
||||
print '<td width="35" align="center"><img src="../images/bt_qslast_inact.gif" border="0" align="absmiddle" title="Dernière page"></td><td width="8"></td>';
|
||||
}
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
if ($link > 0) {mysql_close($link);}
|
||||
?>
|
||||
<td width="35" align="center"><a href="#top"><img src="../images/bt_qstop.gif" border="0" align="absmiddle" title="Atteindre le haut de la page"></a></td><td width="8"></td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<a name="bottom"></a>
|
||||
</center>
|
||||
</body>>
|
||||
</html>
|
779
html/gestion/qs_functions.php
Normal file
@ -0,0 +1,779 @@
|
||||
<?php
|
||||
function qsconvertdate2ansi ($strdate,$formatdate,$param)
|
||||
{
|
||||
if (trim($strdate) == "") { return ""; }
|
||||
$basedate = strtotime($strdate);
|
||||
$stddate = "yyyy-mm-dd hh:nn:ss";
|
||||
$strdate = $strdate . " ";
|
||||
$formatdate = $formatdate . " ";
|
||||
$today = getdate();
|
||||
$y = "";
|
||||
$m = "";
|
||||
$d = "";
|
||||
if (substr_count(strtolower($formatdate),"h") > 0 ) {
|
||||
$h = date("H", $basedate);
|
||||
}else{
|
||||
$h = "00";
|
||||
}
|
||||
if (substr_count(strtolower($formatdate),"n") > 0 ) {
|
||||
$min = date("i", $basedate);
|
||||
}else{
|
||||
$min = "00";
|
||||
}
|
||||
if (substr_count(strtolower($formatdate),"s") > 0 ) {
|
||||
$s = date("s", $basedate);
|
||||
}else {
|
||||
$s = "00";
|
||||
}
|
||||
$array_month[0][0] = "Jan";
|
||||
$array_month[0][1] = "Janvier";
|
||||
$array_month[1][0] = "Fév";
|
||||
$array_month[1][1] = "Février";
|
||||
$array_month[2][0] = "Mar";
|
||||
$array_month[2][1] = "Mars";
|
||||
$array_month[3][0] = "Avr";
|
||||
$array_month[3][1] = "Avril";
|
||||
$array_month[4][0] = "Mai";
|
||||
$array_month[4][1] = "Mai";
|
||||
$array_month[5][0] = "Jun";
|
||||
$array_month[5][1] = "Juin";
|
||||
$array_month[6][0] = "Jul";
|
||||
$array_month[6][1] = "Juillet";
|
||||
$array_month[7][0] = "Aou";
|
||||
$array_month[7][1] = "Août";
|
||||
$array_month[8][0] = "Sep";
|
||||
$array_month[8][1] = "Septembre";
|
||||
$array_month[9][0] = "Oct";
|
||||
$array_month[9][1] = "Octobre";
|
||||
$array_month[10][0] = "Nov";
|
||||
$array_month[10][1] = "Novembre";
|
||||
$array_month[11][0] = "Déc";
|
||||
$array_month[11][1] = "Décembre";
|
||||
$temp = split(" ",trim($formatdate));
|
||||
$temp2 = split(" ",trim($strdate));
|
||||
for($i=0;$i<count($temp);$i++) {
|
||||
if(substr_count($temp[$i],$param) > 0 ){
|
||||
$formatdate = $temp[$i];
|
||||
$strdate = $temp2[$i];
|
||||
}
|
||||
}
|
||||
$array_format = split($param, $formatdate);
|
||||
$array_date =split($param, $strdate);
|
||||
for ($i =0 ; $i < count($array_format); $i++){
|
||||
$iformat = strtolower(trim($array_format[$i]));
|
||||
$idata = strtolower(trim($array_date[$i]));
|
||||
if (substr_count($iformat,"yyyy") > 0){
|
||||
$y = $idata ;
|
||||
}elseif (substr_count($iformat,"yy") > 0){
|
||||
$y = substr($today["year"],0,2) . $idata;
|
||||
}elseif (substr_count($iformat,"mmmm") > 0) {
|
||||
for($j=0 ;$j < 11 ;$j++) {
|
||||
if ($idata == strtolower(trim($array_month[$j][1]))) {
|
||||
$m = $j+1;
|
||||
}
|
||||
}
|
||||
}elseif (substr_count($iformat,"mmm") > 0 ) {
|
||||
for($j=0 ; $j < 11; $j++) {
|
||||
if ($idata == strtolower(trim($array_month[$j][0]))) {
|
||||
$m = $j+1;
|
||||
}
|
||||
}
|
||||
}elseif (substr_count($iformat,"m") > 0 ) {
|
||||
$m = $idata;
|
||||
}elseif (substr_count($iformat,"d") > 0 ) {
|
||||
$d = $idata;
|
||||
}
|
||||
}
|
||||
if ($y == "" ){
|
||||
$y = $today["year"];
|
||||
}
|
||||
if ($m == "" ){
|
||||
$m = $today["mon"];
|
||||
}
|
||||
if ((int)($m)<10){
|
||||
$m = "0" . (int)($m);
|
||||
}
|
||||
if ($d == "" ){
|
||||
$d = $today["mday"];
|
||||
}
|
||||
if ((int)($d)<10) {
|
||||
$d = "0" . (int)($d);
|
||||
}
|
||||
$newformatdate = $stddate;
|
||||
$newformatdate=ereg_replace("yyyy","$y" ,$newformatdate);
|
||||
$newformatdate=ereg_replace("mm","$m" ,$newformatdate);
|
||||
$newformatdate=ereg_replace("dd","$d" ,$newformatdate);
|
||||
$newformatdate=ereg_replace("hh","$h" ,$newformatdate);
|
||||
$newformatdate=ereg_replace("nn","$min" ,$newformatdate);
|
||||
$newformatdate=ereg_replace("ss","$s" ,$newformatdate);
|
||||
return $newformatdate;
|
||||
}
|
||||
|
||||
function replaceSymbol($str){
|
||||
$newStr =eregi_replace(":","",$str);
|
||||
$newStr =eregi_replace("-","",$newStr);
|
||||
$newStr =eregi_replace("/","",$newStr);
|
||||
$newStr =eregi_replace(",","",$newStr);
|
||||
return $newStr;
|
||||
}
|
||||
function TimeStamp_to_string($dt){
|
||||
$dt = replaceSymbol((string)($dt)) ;
|
||||
$yr=strval(substr($dt,0,4));
|
||||
$mo=strval(substr($dt,4,2));
|
||||
$da=strval(substr($dt,6,2));
|
||||
$hr=strval(substr($dt,8,2));
|
||||
$mi=strval(substr($dt,10,2));
|
||||
$se=strval(substr($dt,12,2));
|
||||
$strTimeStamp = $da."/".$mo."/".$yr;
|
||||
return $strTimeStamp;
|
||||
}
|
||||
function qsconvertdate($sdate,$formatdate) {
|
||||
if ($sdate == "") {return "";}
|
||||
$basedate = @strtotime($sdate);
|
||||
if($basedate==-1)
|
||||
{
|
||||
$newformatdate = TimeStamp_to_string($sdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
$shour = (int)(@date("H", $basedate));
|
||||
$sminute = (int)(@date("i", $basedate));
|
||||
$ssec = (int)(@date("s", $basedate));
|
||||
//------- get hour -------
|
||||
if ((substr_count($formatdate,"h") > 0 )&&(substr_count($formatdate,"t"))){
|
||||
$shour = (int)(date("H", $basedate));
|
||||
if($shour==12){
|
||||
$h = $shour;
|
||||
$hh = $h;
|
||||
$t = "PM";
|
||||
}else if($shour==00){
|
||||
$h = 00;
|
||||
$hh = $h;
|
||||
$t = "AM";
|
||||
}else if($shour>12){
|
||||
$h = $shour - 12;
|
||||
$hh = $h;
|
||||
$t = "PM";
|
||||
}else{
|
||||
$h = $shour;
|
||||
$hh = $h;
|
||||
$t = "AM";
|
||||
}
|
||||
}elseif (substr_count($formatdate,"H") > 0 ){
|
||||
$h = $shour;
|
||||
$hh = $h;
|
||||
$t = "";
|
||||
}else{
|
||||
$h = "";
|
||||
$hh = "";
|
||||
$t = "";
|
||||
}
|
||||
if ($hh < 10 ){
|
||||
$hh = "0" . $hh;
|
||||
}
|
||||
//------- get minute -------
|
||||
if (substr_count($formatdate,"n") > 0){
|
||||
$n = $sminute;
|
||||
$nn = $n;
|
||||
}else{
|
||||
$n = "";
|
||||
$nn = "";
|
||||
}
|
||||
if($nn < 10 ) {
|
||||
$nn = "0" . $nn;
|
||||
}
|
||||
//------- get second -------
|
||||
if (substr_count($formatdate,"s") > 0 ) {
|
||||
$s = $ssec;
|
||||
$ss = $s;
|
||||
}else{
|
||||
$s = "";
|
||||
$ss = "";
|
||||
}
|
||||
if($ss < 10 ) {
|
||||
$ss = "0" . $ss;
|
||||
}
|
||||
$temp = split(" ",$sdate);
|
||||
for($i=0;$i<count($temp);$i++) {
|
||||
if(substr_count($temp[$i],"-") > 0 ){
|
||||
$sdate = $temp[$i];
|
||||
}
|
||||
}
|
||||
$temp = split('[- ]', $sdate);
|
||||
$month = $temp[1];
|
||||
$day = $temp[2];
|
||||
$year = $temp[0];
|
||||
if (($year == "0000") || ($month == "00") || ($day == "00")) {return "";}
|
||||
$strdate = $year . "/" . $month . "/" . $day;
|
||||
$array_date = split("/" , $strdate);
|
||||
//------- get year -------
|
||||
$yyyy = $array_date[0];
|
||||
$yy = substr($array_date[0],2,2);
|
||||
//------- get month -------
|
||||
$array_month[0][0] = "Jan";
|
||||
$array_month[0][1] = "Janvier";
|
||||
$array_month[1][0] = "Fév";
|
||||
$array_month[1][1] = "Février";
|
||||
$array_month[2][0] = "Mar";
|
||||
$array_month[2][1] = "Mars";
|
||||
$array_month[3][0] = "Avr";
|
||||
$array_month[3][1] = "Avril";
|
||||
$array_month[4][0] = "Mai";
|
||||
$array_month[4][1] = "Mai";
|
||||
$array_month[5][0] = "Jun";
|
||||
$array_month[5][1] = "Juin";
|
||||
$array_month[6][0] = "Jul";
|
||||
$array_month[6][1] = "Juillet";
|
||||
$array_month[7][0] = "Aou";
|
||||
$array_month[7][1] = "Août";
|
||||
$array_month[8][0] = "Sep";
|
||||
$array_month[8][1] = "Septembre";
|
||||
$array_month[9][0] = "Oct";
|
||||
$array_month[9][1] = "Octobre";
|
||||
$array_month[10][0] = "Nov";
|
||||
$array_month[10][1] = "Novembre";
|
||||
$array_month[11][0] = "Déc";
|
||||
$array_month[11][1] = "Décembre";
|
||||
/* $array_month[0][0] = "Jan";
|
||||
$array_month[0][1] = "January";
|
||||
$array_month[1][0] = "Feb";
|
||||
$array_month[1][1] = "February";
|
||||
$array_month[2][0] = "Mar";
|
||||
$array_month[2][1] = "March";
|
||||
$array_month[3][0] = "Apr";
|
||||
$array_month[3][1] = "April";
|
||||
$array_month[4][0] = "May";
|
||||
$array_month[4][1] = "May";
|
||||
$array_month[5][0] = "Jun";
|
||||
$array_month[5][1] = "June";
|
||||
$array_month[6][0] = "Jul";
|
||||
$array_month[6][1] = "July";
|
||||
$array_month[7][0] = "Aug";
|
||||
$array_month[7][1] = "August";
|
||||
$array_month[8][0] = "Sep";
|
||||
$array_month[8][1] = "September";
|
||||
$array_month[9][0] = "Oct";
|
||||
$array_month[9][1] = "October";
|
||||
$array_month[10][0] = "Nov";
|
||||
$array_month[10][1] = "November";
|
||||
$array_month[11][0] = "Dec";
|
||||
$array_month[11][1] = "December";*/
|
||||
$mmmm = $array_month[(int)($array_date[1] )-1][1];
|
||||
$mmm = $array_month[(int)($array_date[1] )-1][0];
|
||||
$mm = $array_date[1];
|
||||
$m = (int)($array_date[1]);
|
||||
//------- get day -------
|
||||
$dd = $array_date[2];
|
||||
$d = (int)($array_date[2]);
|
||||
$formatdate = strtolower($formatdate);
|
||||
$newformatdate = $formatdate;
|
||||
//-------- convert year ----------
|
||||
if (substr_count($newformatdate ,"yyyy") > 0) {
|
||||
$newformatdate = ereg_replace ("yyyy" ,"$yyyy" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "yyy") > 0) {
|
||||
$newformatdate = ereg_replace ("yyy" ,"$yyyy" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "yy") > 0) {
|
||||
$newformatdate = ereg_replace ("yy" ,"$yy" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "y") > 0) {
|
||||
$newformatdate = ereg_replace ("y" ,"$yy" ,$newformatdate);
|
||||
}
|
||||
//-------- convert month ----------
|
||||
if (substr_count($newformatdate ,"mmmm") > 0) {
|
||||
$newformatdate = ereg_replace ("mmmm" ,"$mmmm" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "mmm") > 0) {
|
||||
$newformatdate = ereg_replace ("mmm" ,"$mmm" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "mm") > 0) {
|
||||
$newformatdate = ereg_replace ("mm" ,"$mm" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "m") > 0) {
|
||||
$newformatdate = eregi_replace ("m" ,"$m" ,$newformatdate);
|
||||
}
|
||||
// -------- convert day ------------
|
||||
if (substr_count($newformatdate, "dd") > 0) {
|
||||
$newformatdate = ereg_replace ("dd" ,"$dd" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "d") > 0 ) {
|
||||
$newformatdate = ereg_replace ("d" ,"$d" ,$newformatdate);
|
||||
}
|
||||
// -------- convert hour ------------
|
||||
if (substr_count($newformatdate, "hh") > 0) {
|
||||
$newformatdate = ereg_replace ("hh" ,"$hh" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "h") > 0 ) {
|
||||
$newformatdate = ereg_replace ("h" ,"$h" ,$newformatdate);
|
||||
}
|
||||
// -------- convert minute ------------
|
||||
if (substr_count($newformatdate, "nn") > 0 ) {
|
||||
$newformatdate = ereg_replace ("nn" ,"$nn" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "n") > 0 ) {
|
||||
$newformatdate = ereg_replace ("n" ,"$n" ,$newformatdate);
|
||||
}
|
||||
// -------- convert second ------------
|
||||
if (substr_count($newformatdate, "ss") > 0 ) {
|
||||
$newformatdate = ereg_replace ("ss" ,"$ss" ,$newformatdate);
|
||||
}elseif (substr_count($newformatdate, "s") > 0 ) {
|
||||
$newformatdate = ereg_replace ("s" ,"$s" ,$newformatdate);
|
||||
}
|
||||
if (substr_count($newformatdate, "t") > 0 ) {
|
||||
$newformatdate = ereg_replace ("t" ,"$t" ,$newformatdate);
|
||||
}
|
||||
}
|
||||
return $newformatdate ;
|
||||
}
|
||||
|
||||
function qs_string_to_timestamp($str)
|
||||
{
|
||||
$l=strlen($str);
|
||||
switch ($l) {
|
||||
case 4:
|
||||
$tm=qs_year_to_timestamp($str);
|
||||
break;
|
||||
case 8:
|
||||
$tm=qs_time_to_timestamp($str);
|
||||
break;
|
||||
case 10:
|
||||
$tm=qs_date_to_timestamp($str);
|
||||
break;
|
||||
case 14:
|
||||
$tm=qs_timestamp_to_timestamp($str);
|
||||
break;
|
||||
case 19:
|
||||
$tm=qs_datetime_to_timestamp($str);
|
||||
break;
|
||||
case 23:
|
||||
$tm=qs_datetime_to_timestamp($str);
|
||||
break;
|
||||
default:
|
||||
$tm=mktime(24,0,0,1,1,1970);
|
||||
}
|
||||
return $tm;
|
||||
}
|
||||
|
||||
function qs_timestamp_to_timestamp($dt)
|
||||
{
|
||||
$yr=strval(substr($dt,0,4));
|
||||
$mo=strval(substr($dt,4,2));
|
||||
$da=strval(substr($dt,6,2));
|
||||
$hr=strval(substr($dt,8,2));
|
||||
$mi=strval(substr($dt,10,2));
|
||||
$se=strval(substr($dt,12,2));
|
||||
return mktime($hr,$mi,$se,$mo,$da,$yr);
|
||||
}
|
||||
|
||||
function qs_datetime_to_timestamp($dt)
|
||||
{
|
||||
$yr=strval(substr($dt,0,4));
|
||||
$mo=strval(substr($dt,5,2));
|
||||
$da=strval(substr($dt,8,2));
|
||||
$hr=strval(substr($dt,11,2));
|
||||
$mi=strval(substr($dt,14,2));
|
||||
$se=strval(substr($dt,17,2));
|
||||
return @mktime($hr,$mi,$se,$mo,$da,$yr);
|
||||
}
|
||||
|
||||
function qs_date_to_timestamp($dt)
|
||||
{
|
||||
$yr=strval(substr($dt,0,4));
|
||||
$mo=strval(substr($dt,5,2));
|
||||
$da=strval(substr($dt,8,2));
|
||||
$hr=0;
|
||||
$mi=0;
|
||||
$se=0;
|
||||
return mktime($hr,$mi,$se,$mo,$da,$yr);
|
||||
}
|
||||
|
||||
function qs_time_to_timestamp($dt)
|
||||
{
|
||||
$yr=1970;
|
||||
$mo=1;
|
||||
$da=1;
|
||||
$hr=strval(substr($dt,0,2));
|
||||
$mi=strval(substr($dt,3,2));
|
||||
$se=strval(substr($dt,6,2));
|
||||
return mktime($hr,$mi,$se,$mo,$da,$yr);
|
||||
}
|
||||
|
||||
function qs_year_to_timestamp($dt)
|
||||
{
|
||||
$yr=strval(substr($dt,0,4));
|
||||
$mo=1;
|
||||
$da=1;
|
||||
$hr=0;
|
||||
$mi=0;
|
||||
$se=0;
|
||||
return mktime($hr,$mi,$se,$mo,$da,$yr);
|
||||
}
|
||||
|
||||
function qs_datetime_to_string ($dt)
|
||||
{
|
||||
if (@date("H:i:s",$dt) == "00:00:00"){
|
||||
$str = date("n/j/Y",$dt);
|
||||
}else{
|
||||
$str = @date("n/j/Y g:i:s",$dt);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
function qsvalid_timestamp($dt)
|
||||
{
|
||||
if (strlen($dt) == 14) {
|
||||
$retval = is_numeric($dt);
|
||||
}else{
|
||||
$retval = false;
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsvalidrequest ($paramval)
|
||||
{
|
||||
return (((isset($_GET[$paramval])) || (isset($_POST[$paramval]))) && (qsrequest($paramval)!=""));
|
||||
}
|
||||
|
||||
function qsrequest ($paramval)
|
||||
{
|
||||
if (isset($_GET[$paramval])) {
|
||||
$retval = $_GET[$paramval];
|
||||
}elseif (isset($_POST[$paramval])) {
|
||||
$retval = $_POST[$paramval];
|
||||
}else{
|
||||
$retval = "";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsservervars($paramval)
|
||||
{
|
||||
if (isset($_SERVER[$paramval])) {
|
||||
$retval = $_SERVER[$paramval];
|
||||
}else{
|
||||
$retval = "";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qssession($paramval)
|
||||
{
|
||||
if (isset($_SESSION[$paramval])) {
|
||||
$retval = $_SESSION[$paramval];
|
||||
} else {
|
||||
$retval = "";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function arrayvalue($paramval,$search_array)
|
||||
{
|
||||
if (array_key_exists($paramval,$search_array)) {
|
||||
$retval = $search_array[$paramval];
|
||||
} else {
|
||||
$retval = "";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsodbc_fetch_array($res,$row_num)
|
||||
{
|
||||
$row = array();
|
||||
$result = array();
|
||||
if ($row_num > 0) {
|
||||
$result = odbc_fetch_row($res,$row_num);
|
||||
} else {
|
||||
$result = odbc_fetch_row($res);
|
||||
}
|
||||
if ($result) {
|
||||
$nf = odbc_num_fields($res);
|
||||
for($i=0; $i < $nf; $i++) {
|
||||
$field_value = odbc_result($res, $i + 1);
|
||||
$row[$i] = $field_value;
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
function qsodbc_num_rows($res)
|
||||
{
|
||||
$rowcount = odbc_num_rows($res);
|
||||
if ($rowcount < 0) {
|
||||
$rowcount = 0;
|
||||
while($temp = odbc_fetch_into($res,$idata)){
|
||||
$rowcount++;
|
||||
}
|
||||
}
|
||||
return $rowcount;
|
||||
}
|
||||
|
||||
function qscheckselected($paramval, $itemval, $defaultval)
|
||||
{
|
||||
//$itemval=htmlentities($itemval);
|
||||
|
||||
//echo "paramval='$paramval', itemval='$itemval', defaultval='$defaultval'<br/>";
|
||||
if (trim(strtoupper($paramval)) == trim(strtoupper($itemval))) {
|
||||
$retval = $defaultval;
|
||||
}elseif ((strtoupper($paramval)=="0") && (trim(strtoupper($itemval))=="FALSE") ) {
|
||||
$retval = $defaultval;
|
||||
}elseif ((strtoupper($paramval)=="1") && (trim(strtoupper($itemval))=="TRUE") ) {
|
||||
$retval = $defaultval;
|
||||
}else{
|
||||
$retval = "";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsmysqlgen_radio_button($sql,$objname,$field1,$field2,$itemval)
|
||||
{
|
||||
$result = mysql_query($sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = '';
|
||||
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
||||
$cellstr .= '<input type="radio" name="';
|
||||
$cellstr .= $objname .'" value="'. $row[$field1] .'"';
|
||||
$cellstr .= qscheckselected($row[$field1],$itemval,'checked="checked"') . '>';
|
||||
$cellstr .= htmlentities($row[$field2]) . '<br/>';
|
||||
}
|
||||
mysql_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsmysqlgen_listbox($sql,$objname,$field1,$field2,$itemval)
|
||||
{
|
||||
$result = mysql_query($sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = '';
|
||||
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
||||
$cellstr .= '<option value="' . $row[$field1] . '"';
|
||||
$cellstr .= qscheckselected($row[$field1],$itemval,' selected') . '>';
|
||||
$cellstr .= $row[$field2] . '</option>'.EOL;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsmysqlgen_listvisu($sql,$objname,$field1,$field2,$itemval)
|
||||
{
|
||||
$result = mysql_query($sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = '';
|
||||
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
||||
$cellstr .= $row[$field2] .' ('. $row[$field1] . ')'.EOL;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsmysqlgen_listbox2($sql,$objname,$field1,$field2,$itemval, $format)
|
||||
{
|
||||
$result = mysql_query($sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = "";
|
||||
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
||||
$cellstr .= "<option value=\"" . qsconvertdate($row[$field1], "yyyy/mm/dd") . "\"";
|
||||
$cellstr .= qscheckselected(qsconvertdate($row[$field1], "yyyy/mm/dd"),$itemval," selected") . ">";
|
||||
$cellstr .= qsconvertdate($row[$field2], $format) . "</option>";
|
||||
}
|
||||
mysql_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsodbcgen_radio_button($conn,$sql,$objname,$field1,$field2,$itemval)
|
||||
{
|
||||
$result = odbc_exec($conn,$sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = "";
|
||||
while (odbc_fetch_row($result)) {
|
||||
$cellstr .= "<input type=\"radio\" name=\"";
|
||||
$cellstr .= $objname . "\" value=\"" . odbc_result($result,$field1) . "\"";
|
||||
$cellstr .= qscheckselected(odbc_result($result,$field1),$itemval,"checked = \"checked\"") . ">";
|
||||
$cellstr .= odbc_result($result,$field2) . "<br>";
|
||||
}
|
||||
odbc_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsodbcgen_listbox($conn,$sql,$field1,$field2,$itemval)
|
||||
{
|
||||
$result = odbc_exec($conn,$sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = "";
|
||||
while (odbc_fetch_row($result)) {
|
||||
$cellstr .= "<option value=\"" . odbc_result($result,$field1) . "\"";
|
||||
$cellstr .= qscheckselected(odbc_result($result,$field1),$itemval,"Selected") . ">";
|
||||
$cellstr .= odbc_result($result,$field2) . "</option>";
|
||||
}
|
||||
odbc_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsodbcgen_listbox2($conn,$sql,$field1,$field2,$itemval,$format)
|
||||
{
|
||||
$result = odbc_exec($conn,$sql) or die("Invalid query : '$sql'");
|
||||
$cellstr = "";
|
||||
while (odbc_fetch_row($result)) {
|
||||
$cellstr .= "<option value=\"" . qsconvertdate(odbc_result($result,$field1), "yyyy/mm/dd") . "\"";
|
||||
$cellstr .= qscheckselected(qsconvertdate(odbc_result($result,$field1), "yyyy/mm/dd"),$itemval,"Selected") . ">";
|
||||
$cellstr .= qsconvertdate(odbc_result($result,$field2), $format) . "</option>";
|
||||
}
|
||||
odbc_free_result($result);
|
||||
return $cellstr;
|
||||
}
|
||||
|
||||
function qsreplace_html_quote($itemval)
|
||||
{
|
||||
$retval = htmlspecialchars($itemval, ENT_QUOTES);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsreplace_quote($itemval)
|
||||
{
|
||||
$retval = addslashes($itemval);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsreplace_backslashes($itemval)
|
||||
{
|
||||
$retval = str_replace("\\","\\\\",$itemval);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsreplacecomma($itemval)
|
||||
{
|
||||
$retval = str_replace(",","",$itemval);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function qsdestroysession()
|
||||
{
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
function qscheckselectedstatic ( $itemval,$paramval)
|
||||
{
|
||||
if ((isset($paramval)) && ($itemval == $paramval)) {
|
||||
$select = "SELECTED";
|
||||
} else {
|
||||
$select;
|
||||
}
|
||||
return $select;
|
||||
}
|
||||
|
||||
function qschecktypevalue($itemvalue, $datatype, $quotedate)
|
||||
{
|
||||
$itemvalue =eregi_replace("'","''",$itemvalue);
|
||||
if ($datatype == 0) {
|
||||
return "'" . $itemvalue . "'";
|
||||
}
|
||||
elseif ($datatype == 1) {
|
||||
return qsreplacecomma($itemvalue);
|
||||
}
|
||||
elseif ($datatype == 2) {
|
||||
return $quotedate . $itemvalue . $quotedate;
|
||||
}
|
||||
else{
|
||||
return "'" . $itemvalue . "'";
|
||||
}
|
||||
if ($itemvalue == "") {return "null";}
|
||||
}
|
||||
|
||||
function qssortasc($value1, $value2, $value3, $value4){
|
||||
if ($value1 == $value2) {
|
||||
if ($value3 != "") {
|
||||
if (strtoupper($value3) == "ASC") {
|
||||
$nextsortasc = "<img src=\"../images/sort_asc2.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}else{
|
||||
$nextsortasc = "<img src=\"../images/sort_asc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
}else{
|
||||
$nextsortasc = "<img src=\"../images/sort_asc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
}else{
|
||||
$nextsortasc = "<img src=\"../images/sort_asc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
return $nextsortasc;
|
||||
}
|
||||
|
||||
function qssortdesc($value1, $value2, $value3, $value4){
|
||||
if ($value1 == $value2) {
|
||||
if ($value3 != "") {
|
||||
if (strtoupper($value3) == "ASC") {
|
||||
$nextsortdesc = "<img src=\"../images/sort_desc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}else{
|
||||
$nextsortdesc = "<img src=\"../images/sort_desc2.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
}else{
|
||||
$nextsortdesc = "<img src=\"../images/sort_desc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
}else{
|
||||
$nextsortdesc = "<img src=\"../images/sort_desc1.gif\" title=\"".$value4."\" border=\"0\">";
|
||||
}
|
||||
return $nextsortdesc;
|
||||
}
|
||||
|
||||
function returntype($field_type){
|
||||
if ((strtolower($field_type) == "datetime")
|
||||
||(strtolower($field_type) == "smalldatetime")
|
||||
||(strtolower($field_type) == "date")
|
||||
||(strtolower($field_type) == "time")
|
||||
||(strtolower($field_type) == "year")
|
||||
||(strtolower($field_type) == "timestamp")) {
|
||||
return "type_datetime";
|
||||
} elseif (((strtolower($field_type) == "integer")
|
||||
||(strtolower($field_type) == "int")
|
||||
||(strtolower($field_type) == "smallint")
|
||||
||(strtolower($field_type) == "tinyint")
|
||||
||(strtolower($field_type) == "longint")
|
||||
||(strtolower($field_type) == "counter")
|
||||
||(strtolower($field_type) == "autoincrement")
|
||||
||(strtolower($field_type) == "float")
|
||||
||(strtolower($field_type) == "real")
|
||||
||(strtolower($field_type) == "money")
|
||||
||(strtolower($field_type) == "smallmoney")
|
||||
||(strtolower($field_type) == "short")
|
||||
||(strtolower($field_type) == "long")
|
||||
||(strtolower($field_type) == "double")
|
||||
||(strtolower($field_type) == "currency")
|
||||
||(strtolower($field_type) == "bit")
|
||||
||(strtolower($field_type) == "decimal")
|
||||
||(strtolower($field_type) == "number")
|
||||
||(strtolower($field_type) == "numeric"))) {
|
||||
return "type_integer";
|
||||
} elseif ((strtolower($field_type) == "blob")
|
||||
||(strtolower($field_type) == "mediumblob")
|
||||
||(strtolower($field_type) == "longblob")
|
||||
||(strtolower($field_type) == "varchar")
|
||||
||(strtolower($field_type) == "char")
|
||||
||(strtolower($field_type) == "text")
|
||||
||(strtolower($field_type) == "tinytext")
|
||||
||(strtolower($field_type) == "mediumtext")
|
||||
||(strtolower($field_type) == "string")
|
||||
||(strtolower($field_type) == "longtext")
|
||||
||(strtolower($field_type) == "longchar")
|
||||
||(strtolower($field_type) == "nvarchar")
|
||||
||(strtolower($field_type) == "nchar")
|
||||
||(strtolower($field_type) == "ntext")) {
|
||||
return "type_string";
|
||||
} else {
|
||||
return "type_unknown";
|
||||
}
|
||||
}
|
||||
|
||||
function replacecharxml($svalue){
|
||||
if ($svalue != "") {$svalue = str_replace("\"", """, $svalue);}
|
||||
if ($svalue != "") {$svalue = str_replace("&", "&", $svalue);}
|
||||
if ($svalue != "") {$svalue = str_replace("<", "<", $svalue);}
|
||||
if ($svalue != "") {$svalue = str_replace(">", ">", $svalue);}
|
||||
if ($svalue != "") {$svalue = str_replace("'", "'", $svalue);}
|
||||
if ($svalue != "") {$svalue = str_replace("`", "‘", $svalue);}
|
||||
return $svalue;
|
||||
}
|
||||
|
||||
function GetLastRecordID($Table, $Column)
|
||||
{
|
||||
$Sql = "SELECT MAX(" . $Column . ") AS MaxRecord FROM " . $Table;
|
||||
$MaxRecord = -1;
|
||||
$result = mysql_query($Sql) or die("Invalid query : '$Sql'");
|
||||
$MaxRecord = mysql_result($result, 0 , "MaxRecord");
|
||||
return $MaxRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param unknown_type $string
|
||||
*/
|
||||
function genereUrl($string) {
|
||||
$tmp=explode('.', $string);
|
||||
return './'.$tmp[0].'.php?page='.$tmp[1].'#row'.$tmp[2];
|
||||
}
|
||||
|
||||
?>
|
524
html/gestion/search.php
Normal file
@ -0,0 +1,524 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!isset($page))
|
||||
$page=str_replace('.php', '', basename(__FILE__));
|
||||
|
||||
include_once('tables.php');
|
||||
include_once('qs_functions.php');
|
||||
include_once('default.php');
|
||||
if (!isset($titre))
|
||||
$titre='Recherche "'.$table.'"';
|
||||
|
||||
mysql_query('SET CHARACTER SET utf8;');
|
||||
|
||||
$result = mysql_query("$sql $sql_ext limit 0,1")
|
||||
or die('Invalid query');
|
||||
|
||||
if (isset($_POST['act'])) {
|
||||
$_SESSION[$sessionPage."_page"] = '';
|
||||
$filter_string = "";
|
||||
$qry_string = "";
|
||||
$i = 0;
|
||||
while ($i < mysql_num_fields($result)) {
|
||||
$meta = mysql_fetch_field($result);
|
||||
$field_name = $meta->name;
|
||||
$field_type = $meta->type;
|
||||
//get field type
|
||||
$type_field = "";
|
||||
$type_field = returntype($field_type);
|
||||
//clear session
|
||||
$_SESSION[$sessionPage.'_search_fd'] = '';
|
||||
$_SESSION[$sessionPage.'_multisearch_fd'] = '';
|
||||
$_SESSION[$sessionPage.'_search_fd_'.$i] = '';
|
||||
if ((qsrequest("search_fd" . $i) != "") && (qsrequest("search_fd" . $i) != "*")) {
|
||||
$idata = qsrequest("search_fd" . $i);
|
||||
if (strlen($idata) > 1) {
|
||||
if ($idata[strlen($idata) - 1] == "*") {
|
||||
$idata = substr($idata, 0, strlen($idata) - 1);
|
||||
}
|
||||
}
|
||||
$idata = str_replace("*", "%", $idata);
|
||||
$irealdata = $idata;
|
||||
if (qsrequest("search_optfd".$i) != "") {
|
||||
$idata = qsrequest("search_optfd". $i) . $idata ;
|
||||
}
|
||||
$iopt = substr($idata, 0, 2);
|
||||
if (($iopt == "<=") || ($iopt == "=<")) {
|
||||
$iopt = "<=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif (($iopt == ">=") || ($iopt == "=>")) {
|
||||
$iopt = ">=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "==") {
|
||||
$iopt = "=";
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "<>") {
|
||||
$irealdata = substr($idata, 2);
|
||||
} elseif ($iopt == "^^") {
|
||||
$iopt = "*";
|
||||
$idata = $iopt . $irealdata . $iopt; // Contain
|
||||
} elseif ($iopt == "^*") {
|
||||
$iopt = "*";
|
||||
$idata = $irealdata . $iopt; // Start With
|
||||
} elseif ($iopt == "*^") {
|
||||
$iopt = "*";
|
||||
$idata = $iopt . $irealdata ; // End With
|
||||
} else {
|
||||
$iopt = substr($idata, 0, 1);
|
||||
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
|
||||
$irealdata = substr($idata,1);
|
||||
} else {
|
||||
$iopt = "=";
|
||||
}
|
||||
}
|
||||
if (qsrequest("andor_optfd".$i) != "") {
|
||||
$idata = qsrequest("andor_optfd". $i) . $idata ;
|
||||
}
|
||||
if (!strcasecmp($idata,"{current date and time}")) {
|
||||
$idata = time();
|
||||
} elseif (!strcasecmp($idata,"{current date}")) {
|
||||
$idata = time();
|
||||
} elseif (!strcasecmp($idata,"{current time}")) {
|
||||
$idata = time();
|
||||
}
|
||||
if ($meta) {
|
||||
if ($type_field == "type_datetime") {
|
||||
if ((($timestamp = strtotime($irealdata)) !== -1)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" ./*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string = $field_name . " like '%" . $idata . "%'";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" ./*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string .= " and " . $field_name . " like '%" . $idata . "%'";
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Invalid DateTime.<br>";
|
||||
}
|
||||
} elseif ($type_field == "type_integer") {
|
||||
if (is_numeric($irealdata)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . $idata;
|
||||
$filter_string = $field_name . " " . $iopt . " " . $irealdata;
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . $idata;
|
||||
$filter_string .= " and " . $field_name . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Type mismatch.<br>";
|
||||
}
|
||||
} elseif ($type_field == "type_string") {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" ./*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string = $field_name . " like '" . $irealdata . "%'";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . /*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string .= " and " . $field_name . " like '" . $irealdata . "%'";
|
||||
}
|
||||
} else {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd" . $i . "=" . /*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string = $field_name . " = '" . $irealdata . "'";
|
||||
} else {
|
||||
$qry_string .= "&search_fd" . $i . "=" . /*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string .= " and " . $field_name . " = '" . $irealdata . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (qsrequest("multisearch_fd" . $i) != "") {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
|
||||
} else {
|
||||
$qry_string = $qry_string . "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
|
||||
}
|
||||
}
|
||||
//begin search between see variable 'search_fd_(n)'
|
||||
if (qsrequest("search_fd_" . $i) != "") {
|
||||
$idata = qsrequest("search_fd_" . $i);
|
||||
if (strlen($idata) > 1) {
|
||||
if ($idata[strlen($idata) - 1] == "*") {
|
||||
$idata = substr($idata, 0, strlen($idata) - 1);
|
||||
}
|
||||
}
|
||||
$idata = str_replace("*", "%", $idata);
|
||||
$irealdata = $idata;
|
||||
if (qsrequest("search_optfd_".$i) != "") {
|
||||
$idata = qsrequest("search_optfd_". $i) . $idata ;
|
||||
}
|
||||
if ($meta) {
|
||||
if ($type_field == "type_datetime") {
|
||||
if ((($timestamp = strtotime($irealdata)) !== -1)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd_" . $i . "=" ./*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string = $field_name . " like '%" . $idata . "%'";
|
||||
} else {
|
||||
$qry_string .= "&search_fd_" . $i . "=" ./*urlencode(*/stripslashes($idata)/*)*/;
|
||||
$filter_string .= " and " . $field_name . " like '%" . $idata . "%'";
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Invalid DateTime.<br>";
|
||||
}
|
||||
} elseif ($type_field == "type_integer") {
|
||||
if (is_numeric($irealdata)) {
|
||||
if ($qry_string == "") {
|
||||
$qry_string = "search_fd_" . $i . "=" . $idata;
|
||||
$filter_string = $field_name . " " . $iopt . " " . $irealdata;
|
||||
} else {
|
||||
$qry_string .= "&search_fd_" . $i . "=" . $idata;
|
||||
$filter_string .= " and " . $field_name . " " . $iopt . " " . $irealdata;
|
||||
}
|
||||
} else {
|
||||
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
|
||||
$err_string .= "Description: Type mismatch.<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
if (qsrequest("search_sort") <> "") {
|
||||
$sortstring = qsrequest("search_sort");
|
||||
}
|
||||
if (qsrequest("page_size") <> "") {
|
||||
$page_size = qsrequest("page_size");
|
||||
}
|
||||
#----get submit url page----
|
||||
$submiturl = "./list.php?";
|
||||
if ($err_string == "") {
|
||||
if ($qry_string != "") {
|
||||
$URL= $submiturl . "&" . $qry_string;
|
||||
} else {
|
||||
$URL= $submiturl;
|
||||
}
|
||||
header ("Location: $URL");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sortstring = "";
|
||||
if (qssession("sortfield") != "") {
|
||||
$sortstring = "&sortfield=" . urlencode(stripslashes(qssession("sortfield"))) . "&sortby=" . urlencode(stripslashes(qssession("sortby")));
|
||||
}
|
||||
if (qssession("page_size") != "") {
|
||||
$page_size = urlencode(stripslashes(qssession("page_size")));
|
||||
}
|
||||
$i=0;
|
||||
while ($i < mysql_num_fields($result)) {
|
||||
$strkeyword = "";
|
||||
$iopt = "";
|
||||
$idata = "";
|
||||
if ((!isset($_GET["search_fd".$i])) && (!isset($_POST["search_fd".$i]))) {
|
||||
$arryitemvalue[$i] = "";
|
||||
$arryopt[$i]="";
|
||||
} else {
|
||||
# Check value for advance search
|
||||
$idata = qsrequest("search_fd" . $i);
|
||||
$icon = "";
|
||||
if (substr($idata, 0, 2) == "||") {
|
||||
$icon = "||";
|
||||
$idata = substr($idata, 2);
|
||||
}
|
||||
$iopt = substr($idata, 0, 2); // Get 2 of left keyword
|
||||
if (($iopt == "<=") || ($iopt == "=<")){
|
||||
$iopt = "<=";
|
||||
$strkeyword = substr($idata, 2);
|
||||
}elseif (($iopt == ">=") || ($iopt == "=>")){
|
||||
$iopt = ">=";
|
||||
$strkeyword = substr($idata, 2);
|
||||
}elseif ($iopt == "==" ){
|
||||
$iopt = "==";
|
||||
$strkeyword = substr($idata, 2);
|
||||
}elseif ($iopt == "<>"){
|
||||
$strkeyword = substr($idata, 2);
|
||||
} else {
|
||||
$startstrdata = substr($idata,0,1) ;
|
||||
$endstrdata = $idata[strlen($idata) - 1];
|
||||
if (($startstrdata != "%" ) && ($endstrdata != "%")){
|
||||
if (($startstrdata == "<") || ($startstrdata == ">") || ($startstrdata == "=")) {
|
||||
if ($startstrdata == "<") {
|
||||
$strkeyword = str_replace("<","", $idata) ;
|
||||
$iopt = "<";
|
||||
}elseif($startstrdata == ">") {
|
||||
$strkeyword = str_replace(">","", $idata) ;
|
||||
$iopt = ">";
|
||||
} else {
|
||||
$strkeyword = str_replace("=","", $idata) ;
|
||||
$iopt = "=";
|
||||
}
|
||||
}else {
|
||||
$arryitemvalue[$i] = $idata;
|
||||
$strkeyword = $idata;
|
||||
}
|
||||
}else {
|
||||
if (($startstrdata == "%" ) && ($endstrdata == "%")) { # Contain Case
|
||||
$startstrdata = str_replace("%","", $idata) ;
|
||||
$strkeyword = substr($idata,1, (strlen($idata)-2));
|
||||
$iopt = "^^" ;
|
||||
}elseif (($startstrdata != "%" ) && ($endstrdata == "%")) { # Start With Case xx*
|
||||
$strkeyword = substr($idata,0, (strlen($idata)-1));
|
||||
$iopt = "^*";
|
||||
}elseif (($startstrdata == "%" ) && ($endstrdata != "%")) { # End With Case *xx
|
||||
$strkeyword = substr($idata,1, (strlen($idata)));
|
||||
$iopt = "*^";
|
||||
}
|
||||
}// end eheck one charator
|
||||
}//end of check 2 first character
|
||||
$arryitemvalue[$i] = $strkeyword;
|
||||
$arryopt[$i] = $iopt;
|
||||
$arryandoropt[$i] = $icon;
|
||||
}
|
||||
$i += 1;
|
||||
}// end while
|
||||
if ($result > 0) {mysql_free_result($result);}
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />-->
|
||||
<title><?=htmlentities($titre)?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
|
||||
<script language="javascript">
|
||||
function Trim(s){
|
||||
var temp = " ";
|
||||
var i = 0;
|
||||
while ((temp == " ") && (i <= s.length)) {
|
||||
temp = s.charAt(i);
|
||||
i++;
|
||||
}
|
||||
s = s.substring(i - 1, s.length);
|
||||
return(s);
|
||||
}
|
||||
function check(frm) {
|
||||
var szAlert = "Invalid\n";
|
||||
var nIndex = 0;
|
||||
/* if (!NumberValidate(frm.search_fd0.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'Num Mand' invalid numeric format\n";
|
||||
}
|
||||
if (!NumberValidate(frm.search_fd8.value)) {
|
||||
nIndex++;
|
||||
szAlert += "- " +"'Adr Num' invalid numeric format\n";
|
||||
}*/
|
||||
if(nIndex > 0) {
|
||||
alert(szAlert) ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
</script>
|
||||
<script src="../nonimg/validate.js"></script>
|
||||
<script language='javascript' src='../nonimg/calendar.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<Center>
|
||||
<center><strong><font size="5"><?=htmlentities($titre)?></font></strong></center><br>
|
||||
|
||||
<a name="top"></a>
|
||||
<form name="qs_search_form" method="post" action="./search.php" onSubmit="return check(this)">
|
||||
<script>
|
||||
function getURLParam(strParamName){
|
||||
var strReturn = "";
|
||||
var strHref = window.location.href;
|
||||
if ( strHref.indexOf("?") > -1 ){
|
||||
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
|
||||
var aQueryString = strQueryString.split("&");
|
||||
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
|
||||
if (
|
||||
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
|
||||
var aParam = aQueryString[iParam].split("=");
|
||||
strReturn = aParam[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
$css_class = '"TrOdd"';
|
||||
?>
|
||||
<table Border="0" Cellpadding="2" Cellspacing="1" BgColor="#177AE9">
|
||||
<tr>
|
||||
<td colspan="2" class="ThRows" align="center"><?=htmlentities($titre)?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($err_string != '') {
|
||||
print '<tr>';
|
||||
print '<td align="left" class="ThRows"><b><font color="red">Erreur :</font></b></td>';
|
||||
print '<td align="left" colspan="2" class=' . $css_class . '>' . $err_string . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
foreach ($champ as $i=>$field) {
|
||||
if (!$field['hidden'])
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" class="ThRows"><?=htmlentities($field['libelleColonne'])?></td>
|
||||
<?php
|
||||
$cellvalue = '';
|
||||
if ((!isset($_GET['search_fd'.$i])) && (!isset($_POST['search_fd'.$i]))) {
|
||||
$itemvalue = '';
|
||||
} else {
|
||||
$itemvalue = $arryitemvalue[$i];
|
||||
}
|
||||
if ($format[$i]=='enum') {
|
||||
$cellvalue='';
|
||||
foreach ($formatEnum[$i] as $value) {
|
||||
/*
|
||||
$cellvalue.= '<input type="radio" name="edit_fd'.$i.'" value="'.$value. '" ';
|
||||
$cellvalue.= qscheckselected($value,$itemvalue,' checked="checked"') .'>'.$value.'<br/>'; */
|
||||
$value=utf8_encode($value);
|
||||
$cellvalue.= '<input type="radio" name="search_fd'.$i.'" value="'.$value.'" ';
|
||||
$cellvalue.= qscheckselected($value, $itemvalue,' checked="checked"') .'>'.$value.'<br/>';
|
||||
}
|
||||
$cellvalue.='<input type="hidden" name="multisearch_fd'.$i.'" value="">';
|
||||
}
|
||||
elseif ($format[$i]=='date') $cellvalue.='<input type="text" name="search_fd'.$i.'" value="'. qsreplace_html_quote(stripslashes($itemvalue)) . '"><input type="hidden" name="multisearch_fd'.$i.'" value=""><a href="#search_fd'.$i.'"></a><a name="search_fd'.$i.'"><img src="../images/Calendar.gif" onclick="popUpCalendar(this, document.forms[0].search_fd'.$i.', \'dd/mm/yyyy\', 0, 0)" align="absmiddle" border="0" height="21" width="20"></a>';
|
||||
elseif (isset($champ[$i]['libs']['table'])) { /** @todo Aujourd'hui, on ne peut faire une multiple sélection car la recherche ne les prendra pas en compte **/
|
||||
$libs=$champ[$i]['libs'];
|
||||
$cellvalue='<select align="top" name="search_fd'.$i.'"><option/>'.EOL;// SIZE="10" multiple
|
||||
|
||||
$cellvalue.=qsmysqlgen_listbox( 'SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' ORDER BY '.$libs['lib'].' ASC',
|
||||
'search_fd'.$i, $libs['key'], $libs['lib'],$itemvalue);
|
||||
$cellvalue.='</select>'.EOL;
|
||||
} else
|
||||
$cellvalue = '<input type="text" name="search_fd'.$i.'" value="'. qsreplace_html_quote(stripslashes($itemvalue)) . '"><input type="hidden" name="multisearch_fd'.$i.'" value="">';
|
||||
if ($cellvalue == '') {
|
||||
$cellvalue = ' ';
|
||||
}
|
||||
print '<td class='.$css_class.' align=Default>'.$cellvalue.'</td>';
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
/*
|
||||
$cellvalue = "";
|
||||
if ((!isset($_GET["edit_fd".$i])) && (!isset($_POST["edit_fd".$i]))) {
|
||||
if ($formatdate[$i]<>'')
|
||||
$itemvalue = qsconvertdate($row[$i],"dd/mm/yyyy");
|
||||
else
|
||||
$itemvalue = $row[$i];
|
||||
} else {
|
||||
$itemvalue = qsrequest("edit_fd".$i);
|
||||
}
|
||||
if ($isEditables[$i]) {
|
||||
$cellvalue = '<input type="text" name="edit_fd'.$i.'" value="' . qsreplace_html_quote(stripslashes($itemvalue)) . '"';
|
||||
if (isset($long[$i]) && $long[$i]>0) {
|
||||
$size=$long[$i]+1;
|
||||
if ($size>80) $size=80;
|
||||
$cellvalue.=' size="'.$size.'" maxlength="'.$long[$i].'">';
|
||||
} else
|
||||
$cellvalue.='>';
|
||||
if (isset($champ[$i]['libs']['table'])){
|
||||
$libs=$champ[$i]['libs'];
|
||||
if ($format[$i]=='int') {
|
||||
$multiple='';
|
||||
$testMutipe1="if (!Selectbox.hasOneOption(this.form.edit_fd$i)) { ";
|
||||
$testMutipe2=' } ';
|
||||
} else {
|
||||
$multiple='multiple';
|
||||
$testMutipe1='';
|
||||
$testMutipe2='';
|
||||
}
|
||||
//$cellvalue='<input type="text" name="edit_fd'.$i.'" value="'. htmlentities($itemvalue).'">';
|
||||
$cellvalue ='<table><tr><td valign="top"><i>Sélectionné(s) :</i><br/><select align="top" name="edit_fd'.$i.'" size="10" '.$multiple.
|
||||
' onDblClick="Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.',this.form.edit_fd'.$i.'out, true)">'.EOL;
|
||||
if ($itemvalue<>'') {//mysql_query('SET CHARACTER SET utf8;');
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key'].' IN ('.str_replace(';',',',$itemvalue).')',
|
||||
'edit_fd'.$i, $libs['key'], $libs['lib'],$itemvalue);}
|
||||
$cellvalue.='</select></td><td align="center">'.EOL;
|
||||
// onDblClick="Selectbox.moveSelectedOptions(this.form.list1,this.form.list2,this.form.movesort.checked,this.form.movepattern1.value)">
|
||||
// onClick="Selectbox.moveSelectedOptions(this.form.list1,this.form.list2,this.form.movesort.checked,this.form.movepattern1.value)"><br><br>
|
||||
$cellvalue.='<input type="button" VALUE=">" onClick="Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.', this.form.edit_fd'.$i.'out, true)"><br/>'.EOL;
|
||||
if ($multiple<>'')
|
||||
$cellvalue.='<input type="button" VALUE=">>" onClick="Selectbox.moveAllOptions(this.form.edit_fd'.$i.', this.form.edit_fd'.$i.'out, true)"><br/>'.EOL;
|
||||
$cellvalue.='<br/><input type="button" VALUE="<" onClick="'.$testMutipe1.'Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.'out, this.form.edit_fd'.$i.', true)'.$testMutipe2.'"><br/>'.EOL;
|
||||
if ($multiple<>'')
|
||||
$cellvalue.='<input type="button" VALUE="<<" onClick="Selectbox.moveAllOptions(this.form.edit_fd'.$i.'out, this.form.edit_fd'.$i.', true)"><br/>'.EOL;
|
||||
|
||||
$cellvalue.='</td><td><i>Disponible(s) :</i><br/><select align="top" name="edit_fd'.$i.'out" SIZE="10" '.$multiple.
|
||||
'onDblClick="'.$testMutipe1.'Selectbox.moveSelectedOptions(this.form.edit_fd'.$i.'out,this.form.edit_fd'.$i.', true)'.$testMutipe2.'">'.EOL;
|
||||
if ($itemvalue<>'')
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key'].' NOT IN ('.str_replace(';',',',$itemvalue).')',
|
||||
'edit_fd'.$i.'out', $libs['key'], $libs['lib'],$itemvalue);
|
||||
else
|
||||
$cellvalue.=qsmysqlgen_listbox('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'],
|
||||
'edit_fd'.$i.'out', $libs['key'], $libs['lib'],$itemvalue);
|
||||
$cellvalue.='</select></td></tr></table>'.EOL;
|
||||
}
|
||||
elseif ($format[$i]=='date') $cellvalue.='<a href="#edit_fd'.$i.'"></a><a name="edit_fd'.$i.'"><img src="../images/Calendar.gif" onclick="popUpCalendar(this, document.forms[0].edit_fd'.$i.', \'dd/mm/yyyy\', 0, 0)" align="absmiddle" border="0" height="21" width="20"></a>';
|
||||
elseif ($format[$i]=='text') $cellvalue ='<textarea name="edit_fd'.$i.'" rows=4 cols=40>' . qsreplace_html_quote(stripslashes($itemvalue)) . '</textarea>';
|
||||
elseif ($format[$i]=='enum') {
|
||||
$cellvalue='';
|
||||
foreach ($formatEnum[$i] as $value) {
|
||||
$value=utf8_encode($value);
|
||||
$cellvalue.= '<input type="radio" name="edit_fd'.$i.'" value="'.$value. '" ';
|
||||
$cellvalue.= qscheckselected($value,$itemvalue,' checked="checked"') .'>'.$value.'<br/>';
|
||||
}
|
||||
}
|
||||
if ($champ[$i]['link']<>'') { // Le champ comporte un lien vers une autre source de données
|
||||
$tmp=explode('.', $champ[$i]['link']);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
if (isset($tmp[2])) $cles = 'uniqueKey='.$tmp[2].'&value='.$itemvalue;
|
||||
else $cles = 'currentrow_fd'.$i.'='.$itemvalue;
|
||||
$cellvalue.= ' <a href="./edit.php?dbtable='.$database.'.'.$table.'&'.$cles.'&refererUrl='.urlencode($_SERVER['REQUEST_URI']).'">Lien</a>';
|
||||
}
|
||||
}
|
||||
else { // Le champ n'est pas éditable
|
||||
if ($champ[$i]['link']<>'') { // Le champ comporte un lien vers une autre source de données
|
||||
$tmp=explode('.', $champ[$i]['link']);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
if (isset($tmp[2])) $cles = 'uniqueKey='.$tmp[2].'&value='.$itemvalue;
|
||||
else $cles = 'currentrow_fd'.$i.'='.$itemvalue;
|
||||
$cellvalue = '<a href="./edit.php?dbtable='.$database.'.'.$table.'&'.$cles.'&refererUrl='.urlencode($_SERVER['REQUEST_URI']).'">'.$itemvalue.'</a>';
|
||||
}
|
||||
elseif (isset($champ[$i]['libs']['table'])) { // Le champ a une table liée
|
||||
$libs=$champ[$i]['libs'];
|
||||
//$cellvalue='<input type="text" name="edit_fd'.$i.'" value="'. htmlentities($itemvalue).'">';
|
||||
$cellvalue =str_replace(array("\n\r","\r\n","\n","\r"),"<br>",qsmysqlgen_listvisu('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key'].' IN ('.str_replace(';',',',$itemvalue).')',
|
||||
'edit_fd'.$i, $libs['key'], $libs['lib'],$itemvalue));
|
||||
}
|
||||
else // On afiche laa valeur du champ
|
||||
$cellvalue = $itemvalue;
|
||||
}
|
||||
if ($cellvalue == '') {
|
||||
$cellvalue = ' ';
|
||||
}
|
||||
print '<td class=' . $css_class . ' align="left">' . $cellvalue . '</td></tr>';
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#----get back url page----
|
||||
$backurl = "./liste.php?";
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="ThRows" align=Center>
|
||||
<input type="hidden" name="act" value="n">
|
||||
<input type="button" name="QS_Back" value="Retour" OnClick="javascript:window.location='<?php print $backurl; ?>'">
|
||||
<input type="submit" name="QS_Submit" value="Recherche">
|
||||
<input type="button" name="QS_Clear" value="RAZ" OnClick="location='./search.php'">
|
||||
</td>
|
||||
</tr>
|
||||
</Table><br>
|
||||
</Form>
|
||||
<?php
|
||||
if ($link > 0) {mysql_close($link);}
|
||||
?>
|
||||
<A NAME=bottom></A>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
371
html/gestion/tables.php
Normal file
@ -0,0 +1,371 @@
|
||||
<?
|
||||
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
$t1=microtime_float();
|
||||
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
||||
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$iDb2=new WDB('sdv1');
|
||||
|
||||
session_start();
|
||||
$tabSirenPC=array();
|
||||
|
||||
$authorized = false;
|
||||
|
||||
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
|
||||
$_SESSION['auth'] = null;
|
||||
session_destroy();
|
||||
echo "logging out...";
|
||||
}
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
|
||||
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
|
||||
$tabTmp=$iDb2->select( 'utilisateurs',
|
||||
'id, email',
|
||||
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
|
||||
$_SESSION['userId']=$tabTmp[0][0];
|
||||
$_SESSION['userMail']=$tabTmp[0][1];
|
||||
|
||||
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
|
||||
$authorized = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
//if (isset($_GET["login"]) && (! $authorized)) {
|
||||
header('WWW-Authenticate: Basic Realm="Login please"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
$_SESSION['auth'] = true;
|
||||
print('Login now or forever hold your clicks...');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
|
||||
die();
|
||||
}
|
||||
|
||||
$tablesDisp=array(
|
||||
'jo.annonces' =>'Gestion des Jugements en Collecte',
|
||||
'jo.asso' =>'Gestion des Annonces JO Associations',
|
||||
'jo.tabMandataires' =>'Gestion des Mandataires',
|
||||
'jo.tabJAL' =>'Gestion des Journaux d\'annonces légales',
|
||||
'jo.tribunaux' =>'Gestion des Tribunaux et Préfectures',
|
||||
'jo.chargements' =>'Gestion des chargements Bodacc',
|
||||
'jo.communes' =>'Gestion des communes',
|
||||
'jo.rp' =>'Gestion des rétablissements',
|
||||
'jo.tabEvenements' =>'Gestion des évènements',
|
||||
'jo.bodacc_detail' =>'Annonces Bodacc',
|
||||
'jo.bodacc' =>'Texte des annonces Bodacc',
|
||||
'jo.conventions' =>'Conventions collectives par NAF',
|
||||
'sdv1.clients' =>'Gestion des clients Extranet',
|
||||
'sdv1.utilisateurs' =>'Gestion des utilisateurs Extranet',
|
||||
'jo.asso_themes' =>'Gestion des thèmes du JO Association',
|
||||
'presse.pqr_rss' =>'Gestion des flux RSS',
|
||||
'jo.etablissements_old' =>'Comptage des établissements',
|
||||
'sdv1.fedaso' =>'Fedaso : Actes en saisie',
|
||||
'sdv1.capitalActions' =>'Fedaso : Entreprises',
|
||||
'sdv1.fedDirigeants' =>'Fedaso : Dirigeants',
|
||||
'sdv1.fedLiens' =>'Fedaso : Liens',
|
||||
'sdv1.fedRib' =>'Fedaso : RIBs',
|
||||
);
|
||||
|
||||
$tablesInfo=array(
|
||||
'jo.annonces' =>array( 'fields_hidden'=>array( 'pageSoc', 'pagePou', 'inter1type','inter1id','inter2type','inter2id','inter3type','inter3id'),
|
||||
//'fields_links' =>array( ''=>'sdv1.utilisateurs',
|
||||
'fields_libs' =>array('idSaisie'=>array('table'=>'sdv1.utilisateurs',
|
||||
'key'=>'id',
|
||||
'lib'=>'Nom'),
|
||||
'tribunal'=>array('table'=>'jo.tribunaux',
|
||||
'key'=>'triCode',
|
||||
'lib'=>'triNom'),
|
||||
'typeEven'=>array('table'=>'jo.tabEvenements',
|
||||
'key'=>'codEven',
|
||||
'lib'=>'libEven'),
|
||||
),
|
||||
'table_readOnly'=>true,
|
||||
'fields_nomChamps'=>array( 'codEven'=>'Code', 'libEven'=>'Libellé de l\'évènement'),
|
||||
'titres'=>array( 'edit'=>'Détail d\'une annonce',
|
||||
'del'=>'Suppression d\'une annonce',
|
||||
'list'=>'Liste des annonces',
|
||||
),
|
||||
),
|
||||
'jo.tabMandataires' =>array( 'fields_hidden'=>array('numMand', 'remarques'),
|
||||
'fields_readOnly'=>array('dateMAJ'),
|
||||
'fields_nomChamps'=>array( 'NomMand'=>'NOM', 'PrenomMand'=>'Prénom', 'sigleMand'=>'Sigle', 'GenreRepr'=>'Genre',
|
||||
'NomRepr'=>'Repr.', 'PrenomRepr'=>'Prénom', 'Type'=>'Type', 'adrNum'=>'N°',
|
||||
'adrIndRep'=>'B/T/Q', 'adrTypeVoie'=>'Type voie', 'adrLibVoie'=>'Libdellé voie',
|
||||
'adrComp'=>'Adresse (suite)', 'tel'=>'Tél','fax'=>'Fax', 'email'=>'Mail', 'web'=>'Web',
|
||||
'siret'=>'Siret','adrCp'=>'Code Postal', 'adrVille'=>'Ville' ,'dateMAJ'=>'Mise à jour'),
|
||||
'titres'=>array( 'edit'=>'Edition d\'un mandataire',
|
||||
'add'=>'Ajout d\'un mandataire',
|
||||
'del'=>'Suppression d\'un mandataire',
|
||||
'list'=>'Liste des mandataires',
|
||||
'view'=>'Visualisation d\'un mandataire',
|
||||
),
|
||||
),
|
||||
'jo.tribunaux' =>array( //'fields_hidden'=>array('numMand', 'remarques'),
|
||||
'fields_readOnly'=>array('triId', 'dateUpdate', 'triCode', 'triType'),
|
||||
//'fields_links' =>array( 'triIdSup'=>'jo.tribunaux'),
|
||||
'fields_libs' =>array( 'triIdSup'=>array('table'=>'jo.tribunaux',
|
||||
'key'=>'triId',
|
||||
'lib'=>'triNom'),
|
||||
),
|
||||
'fields_nomChamps'=>array( 'triId'=>'id Tribunal', 'triIdSup'=>'Tribunal supérieur', 'triNom'=>'Nom',
|
||||
'triCode'=>'Identifiant BODACC du tribunal', 'triType'=>'Type de Tribunal',
|
||||
'triCP'=>'Code Postal', 'triTel'=>'Téléphone', 'triFax'=>'Télécopie',
|
||||
'triWeb'=>'Site Internet', 'triMail'=>'Adresse @mail', 'triSiret'=>'SIRET',
|
||||
'triAdrNum'=>'N°', 'triAdrIndRep'=>'B/T/Q', 'triAdrTypeVoie'=>'Type voie',
|
||||
'triAdrVoie'=>'Libdellé voie', 'triAdrComp'=>'Adresse (suite)',
|
||||
'triVille'=>'Ville', 'triStatut'=>'Statut du tribunal', 'triDateCessation'=>'Date de cessation',
|
||||
'triCommentaire'=>'Commentaire', 'dateUpdate'=>'Dernière mise à jour'),
|
||||
'titres'=>array( 'edit'=>'Edition d\'un tribunal',
|
||||
'list'=>'Liste des tribunaux',
|
||||
'view'=>'Visualisation d\'un tribunal',
|
||||
'search'=>'Recherche d\'un tribunal',
|
||||
),
|
||||
),
|
||||
'jo.tabEvenements' =>array( 'table_readOnly'=>true,
|
||||
'fields_nomChamps'=>array( 'codEven'=>'Code', 'libEven'=>'Libellé de l\'évènement'),
|
||||
//'fields_notlisted'=>array('infoEven'),
|
||||
'titres'=>array( 'edit'=>'Détail d\'un évènement',
|
||||
'add'=>'Ajout d\'un évènement',
|
||||
'del'=>'Suppression d\'un évènement',
|
||||
'list'=>'Liste des évènements',
|
||||
),
|
||||
),
|
||||
'jo.chargements' =>array( 'fields_readOnly'=>array( 'NomFichier','Bodacc_Date_Parution_Texte','Bodacc_Code','Bodacc_Annee_Parution','Bodacc_Num','Num_Annonce_Deb','Num_Annonce_Fin','dateInsert', 'dateUpdate'),
|
||||
'fields_nomChamps'=>array( 'NomFichier'=>'Fichier TLS', 'Bodacc_Date_Parution'=>'Date de parution', 'Bodacc_Date_Parution_Texte'=>'Date de parution (texte)',
|
||||
'DateDispo'=>'Date de disponibilité du fichier', 'dateDownload'=>'Date de téléchargement',
|
||||
'taille'=>'Taille du fichier (octets)', 'Bodacc_Code'=>'Code Bodacc', 'Bodacc_Annee_Parution'=>'Année de parution',
|
||||
'Bodacc_Num'=>'N° du Bodacc', 'Num_Annonce_Deb'=>'N° première annonce', 'Num_Annonce_Fin'=>'N° dernière annonce',
|
||||
'annomalieVerifiee'=>'Rectification anomalie', 'dateInsert'=>'Date création enreg.', 'dateUpdate'=>'Date mise à jour enreg',
|
||||
),
|
||||
'titres'=>array( 'edit'=>'Détail d\'un chargement Bodacc',
|
||||
'add'=>'Ajout d\'un évènement',
|
||||
'del'=>'Suppression d\'un évènement',
|
||||
'list'=>'Liste des chargements Bodacc en base',
|
||||
),
|
||||
),
|
||||
'jo.bodacc_detail' =>array( 'fields_hidden'=>array( 'adresse', 'adresseSiege', 'publication', 'Mandataire', 'mandAdresse', 'ReprCreanciers',
|
||||
'administrateur', 'oppositions'),
|
||||
'fields_readOnly' =>array( 'id', 'dateInsert', 'dateUpdate'),
|
||||
'fields_links' =>array( 'id'=>'jo.bodacc', 'Tribunal_Code'=>'jo.tribunaux.triCode'),
|
||||
'fields_libs' =>array( 'typeEven'=>array('table'=>'jo.tabEvenements',
|
||||
'key'=>'codEven',
|
||||
'lib'=>'libEven'),
|
||||
),
|
||||
|
||||
'fields_nomChamps'=>array(
|
||||
'siren'=>'SIREN','sirenValide'=>'SIREN correct','Bodacc_Num'=>'N° du Bodacc',
|
||||
'Bodacc_Date_Parution'=>'Date de parution','Num_Annonce'=>'N° d\'annonce','Tribunal_Code'=>'Code du tribunal',
|
||||
'Rubrique_Bodacc'=>'Rubrique au Bodacc','Rubrique'=>'Rubrique','typeAnnonce'=>'Type d\'annonce',
|
||||
'corrNum_Annonce'=>'Si correction, N° de l\'annonce', 'corrBodacc_Date_Parution'=>'Si correction, Date de parution',
|
||||
'corrPage'=>'Si correction, Page', 'corrNumParution'=>'Si correction, N° de parution',
|
||||
'corrTexteRectificatif'=>'Si correction, texte rectificatif', 'RC'=>'Numéro de registre du commerce',
|
||||
'raisonSociale'=>'Raison Sociale', 'nomCommercial'=>'Nom Commercial', 'enseigne'=>'Enseigne', 'nationalite'=>'Nationalité',
|
||||
'FJ'=>'Forme Juridique Bodacc', 'Capital'=>'Montant du Capital', 'CapitalDev'=>'Devise du capital',
|
||||
'adrNum'=>'Adresse : N°', 'adrIndRep'=>'Adresse : Bis/Ter/Qua', 'adrTypVoie'=>'Adresse : Type de voie',
|
||||
'adrLibVoie'=>'Adresse : Libellé dans la voie', 'adrComp1'=>'Adresse : Complément d\adresse',
|
||||
'adrComp2'=>'Adresse : Complément d\adresse (suite)', 'codePostal'=>'Code postal', 'ville'=>'Ville',
|
||||
'adrSiegeNum'=>'Adresse : N°', 'adrSiegeIndRep'=>'Adresse : Bis/Ter/Qua', 'adrSiegeTypVoie'=>'Adresse : Type de voie',
|
||||
'adrSiegeLibVoie'=>'Adresse : Libellé dans la voie', 'adrSiegeComp1'=>'Adresse : Complément d\adresse',
|
||||
'adrSiegeComp2'=>'Adresse : Complément d\adresse (suite)', 'codePostalSiege'=>'Code postal', 'villeSiege'=>'Ville',
|
||||
'administration'=>'Administration', 'activite'=>'Activité déclarée au Bodacc', 'typeEven'=>'Type d\'évènement',
|
||||
'commentaires'=>'Commentaire', 'dateEffet'=>'Date d\'effet', 'publicationNom'=>'Nom de la publication',
|
||||
'publicationDate'=>'Date de publication', 'fusion'=>'Fusion', 'dateDebutActivite'=>'Date de début d\'activité',
|
||||
'dateCessationActivite'=>'Date de cessation d\'activité', 'dateCessationPaiement'=>'Date de cessation des paiements',
|
||||
'dateJugement'=>'Date de jugement', 'Numero'=>'Numéro de la procédure', 'VenteMt'=>'Montant de la vente',
|
||||
'VenteDev'=>'Devise', 'bienAcqui'=>'Bien acqui',
|
||||
'mandNom'=>'Mandataire : Nom', 'mandRepr'=>'Mandataire : Représentant', 'mandAdrNum'=>'Mandataire : Adresse N°',
|
||||
'mandAdrIndRep'=>'Mandataire : Adresse B/T/Q', 'mandAdrTypVoie'=>'Mandataire : Adresse Type Voie',
|
||||
'mandAdrLibVoie'=>'Mandataire : Adresse Libellé Voie', 'mandAdrComp'=>'Mandataire : Adresse (suite)',
|
||||
'mandCP'=>'Mandataire : Adresse CP', 'mandVille'=>'Mandataire : Adresse Ville',
|
||||
'JugeCommissaire'=>'Juge commissaire',
|
||||
'jugeCommissaireSuppleant'=>'Juge commissaire suppléant',
|
||||
'creaNom'=>'Repr. Créanciers :Nom', 'creaRepr'=>'Repr. Créanciers :Représentant', 'creaAdrNum'=>'Repr. Créanciers :Adresse N°',
|
||||
'creaAdrIndRep'=>'Repr. Créanciers :Adresse B/T/Q', 'creaAdrTypVoie'=>'Repr. Créanciers :Adresse Type Voie',
|
||||
'creaAdrLibVoie'=>'Repr. Créanciers :Adresse Libellé Voie', 'creaAdrComp'=>'Repr. Créanciers :Adresse (suite)',
|
||||
'creaCP'=>'Repr. Créanciers :Adresse CP', 'creaVille'=>'Repr. Créanciers :Adresse Ville',
|
||||
'admNom'=>'Administrateur : Nom', 'admRepr'=>'Administrateur : Représentant', 'admAdrNum'=>'Administrateur : Adresse N°',
|
||||
'admAdrIndRep'=>'Administrateur : Adresse B/T/Q', 'admAdrTypVoie'=>'Administrateur : Adresse Type Voie',
|
||||
'admAdrLibVoie'=>'Administrateur : Adresse Libellé Voie', 'admAdrComp'=>'Administrateur : Adresse (suite)',
|
||||
'admCP'=>'Administrateur : Adresse CP', 'admVille'=>'Administrateur : Adresse Ville',
|
||||
'oppoNom'=>'Opposition : Nom', 'oppoRepr'=>'Opposition : Représentant', 'oppoAdrNum'=>'Opposition : Adresse N°',
|
||||
'oppoAdrIndRep'=>'Opposition : Adresse B/T/Q', 'oppoAdrTypVoie'=>'Opposition : Adresse Type Voie',
|
||||
'oppoAdrLibVoie'=>'Opposition : Adresse Libellé Voie', 'oppoAdrComp'=>'Opposition : Adresse (suite)',
|
||||
'oppoCP'=>'Opposition : Adresse CP', 'oppoVille'=>'Opposition : Adresse Ville',
|
||||
'perimetre'=>'Périmètre', 'dateFinDepotCreances'=>'Date de fin dépot des créances',
|
||||
'dateFinObservation'=>'Date de fin période observation',
|
||||
),
|
||||
'titres'=>array( 'edit'=>'Edition d\'une annonce Bodacc',
|
||||
'view'=>'Visualisation d\'une annonce Bodacc',
|
||||
//'del'=>'Suppression d\'un évènement',
|
||||
'list'=>'Liste des annonces Bodacc',
|
||||
),
|
||||
),
|
||||
'jo.bodacc' =>array( 'table_readOnly'=>true,
|
||||
'fields_hidden'=>array('balises'),
|
||||
'fields_links' =>array( 'id'=>'jo.bodacc'),
|
||||
'fields_nomChamps'=>array(
|
||||
'Bodacc_NOJO'=>'Numéro de l\'annonce au Bodacc',
|
||||
'Bodacc_Num'=>'N° du Bodacc',
|
||||
'Bodacc_Date_Parution'=>'Date de parution',
|
||||
'Num_Annonce'=>'N° d\'annonce',
|
||||
'Tribunal_Code'=>'Code du tribunal',
|
||||
'Tribunal_Dept'=>'Département du tribunal',
|
||||
'Rubrique_Bodacc'=>'Rubrique au Bodacc',
|
||||
'Bodacc_Code'=>'Code Bodacc',
|
||||
'Bodacc_Annee_Parution'=>'Année de parution',
|
||||
'typeAnnonce'=>'Type d\'annonce',
|
||||
'corrNum_Annonce'=>'Si correction, N° de l\'annonce',
|
||||
'corrBodacc_Date_Parution'=>'Si correction, Date de parution',
|
||||
'corrPage'=>'Si correction, Page',
|
||||
'corrNumParution'=>'Si correction, N° de parution',
|
||||
'corrTexteRectificatif'=>'Si correction, texte rectificatif',
|
||||
'annonce'=>'Annonce',
|
||||
'dateInsert'=>'Date d\'insertion en base'
|
||||
),
|
||||
'titres'=>array( 'edit'=>'Edition d\'une annonce Bodacc',
|
||||
'view'=>'Visualisation d\'une annonce Bodacc',
|
||||
//'del'=>'Suppression d\'un évènement',
|
||||
'list'=>'Liste des annonces Bodacc',
|
||||
),
|
||||
),
|
||||
//
|
||||
'jo.conventions' =>array( 'fields_hidden'=>array('editeurCC'),
|
||||
'fields_readOnly'=>array('naf'),
|
||||
//'fields_links' =>array( 'triIdSup'=>'jo.tribunaux'),
|
||||
'fields_libs' =>array( 'naf'=>array('table'=>'jo.tabNaf',
|
||||
'key'=>'codNaf700',
|
||||
'lib'=>'libNaf700'),
|
||||
),
|
||||
'fields_nomChamps'=>array( 'naf'=>'Code NAF', 'idCC'=>'Code Conv. Coll.', 'nomCC'=>'Nom de la convention',
|
||||
'infoCC'=>'Remarques', 'nbPageCC'=>'Nombre de Pages',
|
||||
'isbnCC'=>'ISBN', 'dateEditionCC'=>'Date d\édition',
|
||||
),
|
||||
'titres'=>array( 'edit'=>'Edition d\'une convention',
|
||||
'list'=>'Liste des conventions',
|
||||
'view'=>'Visualisation d\'une convention',
|
||||
'search'=>'Recherche d\'une convention',
|
||||
),
|
||||
),
|
||||
'jo.etablissements_old' =>array('table_readOnly'=>true,
|
||||
'titres'=>array( 'list'=>'Liste des établissements',
|
||||
'view'=>'Visualisation d\'un établissement',
|
||||
'search'=>'Recherche d\'un établissement',
|
||||
),
|
||||
),
|
||||
'sdv1.fedaso' =>array('table_readOnly'=>true,
|
||||
'fields_nomChamps'=>array( 'siren'=>'SIREN', 'page'=>'Page', 'params'=>'Ref', 'dateEnvoi'=>'envoi', 'typeActesLus'=>'actes', 'nbDataD'=>'nb DIR', 'nbDataL'=>'nb LIENS', 'nbDataA'=>'nb ACT',
|
||||
'nbDataP'=>'nb PAR', 'nbDataF'=>'nb FUS', 'nbDataE'=>'nb E',
|
||||
'nbDataS'=>'nb SIC', 'nbDataR'=>'nb RIBs','dateRetour'=>'retour',
|
||||
),
|
||||
'titres'=>array( 'list'=>'Liste des actes en saisie',
|
||||
'view'=>'Visualisation d\'un acte en saisie',
|
||||
'search'=>'Recherche d\'un acte',
|
||||
),
|
||||
),
|
||||
'sdv1.capitalActions' =>array('table_readOnly'=>true,
|
||||
'titres'=>array( 'list'=>'Liste des entreprises Fedaso',
|
||||
),
|
||||
),
|
||||
'sdv1.fedDirigeants' =>array('table_readOnly'=>true,
|
||||
'titres'=>array( 'list'=>'Liste des Dirigeants Fedaso',
|
||||
),
|
||||
),
|
||||
'sdv1.fedLiens' =>array('table_readOnly'=>true,
|
||||
'titres'=>array( 'list'=>'Liste des Liens Fedaso',
|
||||
),
|
||||
),
|
||||
'sdv1.fedRib' =>array('table_readOnly'=>true,
|
||||
'titres'=>array( 'list'=>'Liste des RIBs Fedaso',
|
||||
),
|
||||
),
|
||||
'sdv1.clients' =>array( //'fields_hidden'=>array('editeurCC'),
|
||||
//'fields_readOnly'=>array('naf'),
|
||||
/* //'fields_links' =>array( 'triIdSup'=>'jo.tribunaux'),
|
||||
'fields_libs' =>array( 'naf'=>array('table'=>'jo.tabNaf',
|
||||
'key'=>'codNaf700',
|
||||
'lib'=>'libNaf700'),
|
||||
),*/
|
||||
'fields_nomChamps'=>array( 'nom' => 'NOM du Compte Client',
|
||||
'actif' => 'Compte client actif',
|
||||
'test' => 'Compte de test ',
|
||||
'racineLogin' => 'Racine pour les login du client',
|
||||
'siren' => 'SIREN du client',
|
||||
'nic' => 'NIC du client',
|
||||
'tva' => 'N° de TVA du client',
|
||||
'fact_detail' => 'Facturation détaillée',
|
||||
'fac_dest' => 'Nom du destinataire de la facture',
|
||||
'fac_adr1' => 'Dest. facture : Adresse',
|
||||
'fac_adr2' => 'Dest. facture : Complément d\'adresse',
|
||||
'fac_adr3' => 'Dest. facture : Code Postal / Ville',
|
||||
'fac_email' => 'Dest. facture : @mail',
|
||||
'fac_tel' => 'Dest. facture : Téléphone',
|
||||
'fact_rib' => 'RIB S&D joint à la facture',
|
||||
'liv_dest' => 'Nom du responsable chez le client',
|
||||
'liv_adr1' => 'Responsable : Adresse',
|
||||
'liv_adr2' => 'Responsable : Complément d\'adresse',
|
||||
'liv_adr3' => 'Responsable : Code Postal / Ville',
|
||||
'liv_email' => 'Responsable : @mail',
|
||||
'liv_tel' => 'Responsable : Téléphone',
|
||||
'droits' => 'Droits',
|
||||
'filtres_ip' => 'Adresses IP autorisées',
|
||||
'dateInsert' => 'Date insertion',
|
||||
'dateUpdate' => 'Date de mise à jour',
|
||||
'respComSD' => 'Responsable commercial S&D',
|
||||
'typeContrat' => 'Type de contrat',
|
||||
'dateSignature' => 'Date de signature',
|
||||
'typeAcces' => 'Type d\'accès',
|
||||
'accesPieces' => 'Accès aux pièces officielles',
|
||||
'accesKbis' => 'Accès aux K-Bis',
|
||||
'accesInvestigations' => 'Accès aux investigations',
|
||||
'miseSousSurveillance' => 'Accès à la mise sous surveillance',
|
||||
'forfaitExtranetPeriode'=> 'Périodicité de la facturation',
|
||||
'forfaitExtranetMontant'=> 'Montant forfaitaire accès Extranet',
|
||||
'reconductionAuto' => 'Reconduction automatique',
|
||||
'remarque' => 'Remarque',
|
||||
'forfaitPiecesNb' => 'Forfait pièce officielles : Nombre de pièces',
|
||||
'forfaitPiecesMt' => 'Forfait pièce officielles : Montant',
|
||||
'forfaitPiecesDep' => 'Forfait pièce officielles : Prix de la pièce en cas de dépassement',
|
||||
'forfaitInvestigNb' => 'Forfait investigations : Nombre de demandes',
|
||||
'forfaitInvestigMt' => 'Forfait investigations : Montant',
|
||||
'forfaitInvestigDep' => 'Forfait investigations : Prix de la demandes en cas de dépassement',
|
||||
),
|
||||
'titres'=>array( 'edit'=>'Edition d\'un client',
|
||||
'list'=>'Liste des clients',
|
||||
'view'=>'Visualisation d\'un client',
|
||||
'search'=>'Recherche d\'un client',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/* $fields_links=array( 'triIdSup'=>'Tribunaux.TriId',
|
||||
*/
|
||||
//$table='Tribunaux';
|
||||
//$tableTitreListe='Liste des Tribunaux';
|
||||
//$fields_hidden=array('TriId');
|
||||
//$fields_nomColonnes=array( 'dateMAJ'=>'Mise à jour');
|
||||
/*
|
||||
Caractéristiques :
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
- Champ ne peut être vide
|
||||
-
|
||||
*/
|
||||
|
||||
//die(print_r($tablesInfo));
|
||||
|
||||
?>
|
37
html/gestion/view.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
@session_start();
|
||||
$sessionPage='';
|
||||
if (!isset($page))
|
||||
$page=str_replace('.php', '', basename(__FILE__));
|
||||
|
||||
include_once('tables.php');
|
||||
include_once('qs_functions.php');
|
||||
|
||||
if (isset($_REQUEST['dbtable']) && $_REQUEST['dbtable']<>'')
|
||||
{
|
||||
$dbtable=$_REQUEST['dbtable'];
|
||||
if (array_key_exists($dbtable, $tablesDisp)) {
|
||||
$tmp=explode('.', $dbtable);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
$sessionPage=$database.'.'.$table;
|
||||
$_SESSION['dbtable'] = $sessionPage;
|
||||
}
|
||||
else die("Table '$dbtable' inconnue !");
|
||||
}
|
||||
if ($sessionPage=='') {
|
||||
$sessionPage=$dbtable=qssession('dbtable');
|
||||
$tmp=explode('.', $sessionPage);
|
||||
$database = $tmp[0];
|
||||
$table = $tmp[1];
|
||||
}
|
||||
|
||||
$tablesInfo[$dbtable]['table_readOnly']=true;
|
||||
|
||||
include_once('default.php');
|
||||
|
||||
if (!isset($titre))
|
||||
$titre='Visualisation "'.$table.'"';
|
||||
|
||||
include('./edit.php');
|
||||
?>
|
76
html/guichets/index.php
Normal file
@ -0,0 +1,76 @@
|
||||
<? if (!isset($_POST['submited']) || !$_POST['submited']) { ?>
|
||||
<form action="./" method="POST">
|
||||
<input type="hidden" name="submited" value="true">
|
||||
Code Banque <input type="text" name="banque" maxlength="5" size="7" value=""><br/>
|
||||
Code Guichet <input type="text" name="guichet" maxlength="5" size="7" value=""><br/>
|
||||
<input type="submit">
|
||||
</form>
|
||||
<? } else {
|
||||
|
||||
//error_reporting(0);
|
||||
|
||||
/**
|
||||
* Inclusion du fichier de configuration des includes Métiers de S&D
|
||||
*/
|
||||
include '/var/www/includes/config.php';
|
||||
|
||||
/**
|
||||
* Inclusion du Framework
|
||||
*/
|
||||
if( !defined('FWK_PATH') )
|
||||
include '/var/www/framework/fwk.php';
|
||||
|
||||
include_once(INCLUDE_PATH.'partenaires/classMBanques.php');
|
||||
include_once(FWK_PATH.'common/dates.php');
|
||||
include_once(FWK_PATH.'mail/sendMail.php');
|
||||
|
||||
$iBanque=new MBanques();
|
||||
$guichet=$iBanque->getInfoGuichet($_POST['banque'],$_POST['guichet']);
|
||||
?>
|
||||
<table border="1">
|
||||
<tr><td>Code Etablissement (Banque/Guichet)</td><td><?=$guichet['bdfFibCodeEtab'].' '.$guichet['bdfFibCodeGuichet'];?></td></tr>
|
||||
<tr><td>Nom de l'organisme</td><td><?=$guichet['bdfFibDenom40'].' ('.$guichet['bdfFibDenom10'].')'?></td></tr>
|
||||
<tr><td>Situation de l'organisme</td><td><?switch ($guichet['bdfFibCodeSituation']) {
|
||||
case 1: echo 'Organisme ouvert';
|
||||
break;
|
||||
case 2: echo 'Organisme transféré';
|
||||
if ($guichet['bdfFibCodeEtabAbsorb']>0)
|
||||
echo ' vers '.$guichet['bdfFibCodeEtabAbsorb'];
|
||||
break;
|
||||
case 3: echo 'Organisme fermé';
|
||||
if ($guichet['bdfFibDateFinDiffus']<>'0000-00-00')
|
||||
echo ' le '.$guichet['bdfFibDateFinDiffus'];
|
||||
break;
|
||||
}?></td></tr>
|
||||
<tr><td>Nom de l'établissement</td><td><?=$guichet['guichetDenom40'].' '.$guichet['guichetDenom20']?></td></tr>
|
||||
<tr><td>Libellé RIB</td><td><?=$guichet['bdfFibLibelleRIB']?></td></tr>
|
||||
<tr><td>Situation du guichet</td><td><?switch ($guichet['guichetCodeSituation']) {
|
||||
case 1: echo 'Guichet ouvert';
|
||||
break;
|
||||
case 2: echo 'Guichet transféré';
|
||||
if ($guichet['bdfFibCodeEtab']+$guichet['bdfFibCodeGuichet']>0)
|
||||
echo ' vers '.$guichet['bdfFibCodeEtabCible'].' '.$guichet['bdfFibCodeGuichetRepr'];
|
||||
break;
|
||||
case 3: echo 'Guichet fermé';
|
||||
if ($guichet['bdfFibDateFermeture']<>'0000-00-00')
|
||||
echo ' le '.$guichet['bdfFibDateFermeture'];
|
||||
break;
|
||||
}?></td></tr>
|
||||
<tr><td>Adresse</td><td><?= $guichet['guichetAdresse1'].'<br/>'.
|
||||
$guichet['guichetAdresse2'].'<br/>'.
|
||||
$guichet['guichetAdresse3'].'<br/>'.
|
||||
$guichet['guichetCP'].' '.$guichet['guichetVille']?></td></tr>
|
||||
<tr><td>Tél</td><td><?=$guichet['Tel']?></td></tr>
|
||||
<tr><td>Fax</td><td><?=$guichet['Fax']?></td></tr>
|
||||
<tr><td>SWIFT</td><td><?=$guichet['bdfFibAdresseSWIFT']?></td></tr>
|
||||
<tr><td>Guichet ouvert le </td><td><?=$guichet['bdfFibDateOuverture']?></td></tr>
|
||||
<tr><td>Guichet fermé le </td><td><?=$guichet['bdfFibDateFermeture']?></td></tr>
|
||||
<tr><td>Nature de guichet</td><td><?=$iBanque->tabNatureGuichet[$guichet['bdfFibNatureGuichet']]?></td></tr>
|
||||
<tr><td>Activité</td><td><?=$iBanque->tabActivite[$guichet['bdfFibCodeActivite']]?></td></tr>
|
||||
<tr><td>Organe représentatif</td><td><?=$iBanque->tabOrgane[$guichet['bdfFibCodeOrganeRepr']]?></td></tr>
|
||||
<tr><td>Date d'agrément</td><td><?=$guichet['bdfFibDateAgrement']?></td></tr>
|
||||
<tr><td>Retrait d'agrément le</td><td><?=$guichet['bdfFibDateRetraitAgr']?></td></tr>
|
||||
|
||||
</table>
|
||||
<pre><?print_r($guichet)?></pre>
|
||||
<? } ?>
|
BIN
html/images/Calendar.gif
Normal file
After Width: | Height: | Size: 132 B |
BIN
html/images/alerte.gif
Normal file
After Width: | Height: | Size: 391 B |
BIN
html/images/bbt_data.gif
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
html/images/bbt_data_over.gif
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
html/images/bbt_navigator.gif
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
html/images/bbt_navigator_over.gif
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
html/images/bbt_search.gif
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
html/images/bbt_search_over.gif
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
html/images/bt_add.gif
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
html/images/bt_controlpanel.gif
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
html/images/bt_controlpanelgroup.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
html/images/bt_copy.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |