Modification du système de cache : Mise en cache par bloc et par fonctions

This commit is contained in:
Michael RICOIS 2009-06-19 13:37:38 +00:00
commit c96b1ff53d
1784 changed files with 163759 additions and 0 deletions

109
README Normal file
View File

@ -0,0 +1,109 @@
Plugins Firefox :
-----------------
Faire un plugins firefox qui recherche les numéros siren sur une page
Pages :
-------
Liasse : revoir l'affichage, en particulier celui des nombres
Moncompte :
Créer un droit international
Pour la recherche international si pas les droits, alors pas d'affichage des prix et des commandes
Passer la page annonces avec un nouveau style
HOOKS
-----
Les fonctions du core doivent être les suivantes
hook_menu() => Déclaration d'un élément de menu
hook_perm() => Déclaration de permission ou de non permission
hook_block() => Déclaration d'un bloc de contenu
hook_config() => Configuration
Référencement du nom du module
Actif, Inactif
Déclaration du bloc de contenu
Gestion des includes
---------------------
Le fichier prepend définit l'include path en prenant celui définit en dur dans le php.ini
et rajoute le répertoire framework et includes.
Pour inclure les fichiers dans l'un de ces répertoires, il n'est pas nécessaire de spécifier tous le chemin.
Notes Graydon :
---------------
Traitement du HTML
Traitement du document WORD
Affichage des documents après commande... Affichage (XML, HTML) - Téléchargement (DOC)
Batch pour le traitement des commandes
Traduction des termes utilisés
Ajax pour la commande de rapport
Intégrer la géolocalisation
Intersud
********
* TODO *
********
* Inclusion de CSS et JS différents sur chaques pages
Minify et Compression
Mode développement qui utilise les librairies sans compression
* Passer l'extranet en UTF-8
* Modifier le menu pour utilisé jquery
* Création d'un script d'installation en PHP
- Vérification des applications nécessaires à l'extranet et test de leur fonctionnement
- Prise compte des différents environnement DEV ou PROD
- Prise compte des emplacements de stockage des fichiers
* Modification du chemin de stockage pour les fichiers
- Evite d'avoir à créer des liens symboliques
- Ajouter une variable dans le fichier de config pour définir l'emplacement de stockage des fichiers
* Supprimer les répertoires, ils doivent être crée en lien symbolique (attention au fichier dans les URLs)
www/credisafe => /var/www/data/creditsafe
www/img/logos => /var/www/data/logos
www/infogreffe => /var/www/data/infogreffe
www/pdf => /var/www/data/pdf
File and Filename convention
----------------------------
camelCase variable
Database convention
-------------------
Structure du site ....
------------------------
/var/www/extranet
www => contient les fichiers du site
css => tous les fichiers css
img => images générales du site
js => tous les fichiers javascripts
misc => Script divers
modules => modules du sites (méthodes, présentation contenu, fournisseurs, )
pages => Toutes les pages du sites
includes => fonctions nécessaires au site mais qui ne peuvent être incluses dans le framework
batch => Contient des batchs lancé par cron
config => fichiers de config (mots de pass,...), en dehors du www donc protégé
framework => contient le framework (fonctions complexes, librairies)
log => contient les logs
cache => contient les fichiers de cache (à intégrer dans la bdd ???)
includes : bootstrap, menu, module, session, mail, cache, common, file, database, theme, watchdog
modules : block, menu, syslog, system, user
Structure du dossier de DATA
----------------------------
DATA - Organiser les données en fonctions des fournisseurs et autres ???
data/pdf
data/xml

145
batch/getActes.php Normal file
View File

@ -0,0 +1,145 @@
#!/usr/bin/php -q
<?php
define ('ACTES_IGNUM_LOCAL_DIR','/var/www/extranet/www/pdf/scan/');
define ('ACTES_IG_LOCAL_DIR', '/var/www/extranet/www/pdf/');
define ('ACTES_IGNUM_FTP_URL', 'ftp2.scores-decisions.com');
define ('ACTES_IGNUM_FTP_USER', 'mpc2500');
define ('ACTES_IGNUM_FTP_PASS', 'passmpc78');
require_once realpath(dirname(__FILE__) . '/../framework/fwk.php');
require_once realpath(dirname(__FILE__) . '/../config/config.inc');
require_once realpath(dirname(__FILE__) . '/mysql.php');
define('INCLUDE_PATH', realpath(dirname(__FILE__).'/../includes/') );
include_once(FWK_PATH.'/common/ftp.php');
$tempsMinEntreRequetes=5;
$tempsMaxEntreRequetes=30;
set_time_limit(0);
$eol="\n";
$lastJO=$dateDebut=$dateFin=$verif=false;
$strInfoProg='Usage : '.basename($argv[0]). " [OPTION]
Vérifie les actes numérisés reçus en provenance des Greffes.
Sans aucun paramètre, récupération des actes.
";/*Sinon:
-d:JJ/MM/AAAA Date de début de publication
-f:JJ/MM/AAAA Date de fin de publication
-l Dernier JO Association uniquement (*)
-n:X Intervalle MIN en secondes entre les requêtes sur le site des JO (défaut=$tempsMinEntreRequetes)
-i:X \" MAX \" \" \" \" \" \" \" \" \" \" (défaut=$tempsMaxEntreRequetes)
-v Vérifier que toutes les annonces du JO sont en base !
";*/
$argv=$_SERVER['argv'];
if ($_SERVER['argc']==1) $lastJO=true;
else {
for ($i=1; isset($argv[$i]); $i++) {
if (substr($argv[$i],0,1)=='-') {
switch (substr($argv[$i],1,1)) {
case 'd':
$dateDebut=substr($argv[$i],3,10);
$dateDeb=dateT('d/m/Y', 'Ymd', $dateDebut);
break;
case 'n':
$tempsMinEntreRequetes=trim(substr($argv[$i],3))*1;
if ($tempsMinEntreRequetes<0) $tempsMinEntreRequetes=0;
break;
case '-':
die($strInfoProg);
break;
default: die('Option '. $argv[$i] . " inconnue !\n");
}
}
}
}
$con = mysql_pconnect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
if (!($con === false)) {
if (mysql_select_db(MYSQL_DB, $con) === false)
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . $eol;
}
else
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error(). $eol;
$tabCommandes=mysql_select('commandes', 'idCommande, idUser, login, emailCommande, siren, refDocument, dateCommande', 'dateReception=0', false, MYSQL_ASSOC);
$nbCommandes=count($tabCommandes);
$tabTmp=array();
foreach ($tabCommandes as $commande) {
$tabTmp['g'.$commande['idCommande']]=$commande;
}
$tabCommandes=$tabTmp;
unset($tabTmp);
echo date('Y/m/d - H:i:s') ." - Il y a $nbCommandes actes en attente de réception courrier ou numérisation !$eol";
//print_r($tabCommandes);
//die();
/**
** Connexion au site FTP
**/
echo date('Y/m/d - H:i:s') ." - Récupération des fichiers numérisés en attente de traitement...".EOL;
$ret=ftp_mget(ACTES_IGNUM_FTP_URL, ACTES_IGNUM_FTP_USER, ACTES_IGNUM_FTP_PASS, '*.pdf', ACTES_IGNUM_LOCAL_DIR, false);
if ($ret===false)
die (date ('Y/m/d - H:i:s')." - ERREUR : Récupération des actes numérisés impossible !".EOL);
else
echo date ('Y/m/d - H:i:s')." - FIN de la récupération des flux Hugin en FTP ($ret fichiers récupérés).".EOL;
/**
** Connexion au site FTP
**/
echo date('Y/m/d - H:i:s') ." - Traitement des actes non encore traités !".EOL;
$tabFichiers=array();
$dh = opendir(ACTES_IGNUM_LOCAL_DIR);
while (false !== ($filename = readdir($dh))) {
if ($filename<>'.' && $filename<>'..' && strtolower(substr($filename, -4))=='.pdf')
$tabFichiers[] = $filename;
}
rsort($tabFichiers);
$tabActes=array();
foreach ($tabFichiers as $k => $nomFichier) {
if (strtolower(substr($nomFichier,0,1))=='g') {
echo date ('Y/m/d - H:i:s')." - Fichier $nomFichier disponible pour traitement.".EOL;
$numFichier=str_replace('.pdf','', $nomFichier);
$tabActes[] = $nomFichier;
if (isset($tabCommandes[$numFichier]) && is_array($tabCommandes[$numFichier])) {
$commande=$tabCommandes[$numFichier];
echo date ('Y/m/d - H:i:s')." - Le fichier $nomFichier correspond à la commande ".$commande['refDocument'].' de '.$commande['login'].'.'.EOL;
$numFichierSuiv=str_replace('.pdf','', $tabFichiers[$k+1]);
if (strpos($numFichierSuiv, $numFichier) === false) {
/** Le fichier $nomFichier est une commande livrée en un seul fichier **/
$siren=$commande['siren'];
$ref=$commande['refDocument'];
$nomCible="acte-$siren-$ref.pdf";
if (file_exists(ACTES_IG_LOCAL_DIR.$nomCible))
echo date ('Y/m/d - H:i:s')." - La commande $nomCible est déjà mise à disposition !".EOL;
else {
if (rename(ACTES_IGNUM_LOCAL_DIR.$nomFichier, ACTES_IG_LOCAL_DIR.$nomCible)) {
echo date ('Y/m/d - H:i:s')." - La commande $nomCible a été mise à disposition.".EOL;
if (trim($commande['emailCommande'])<>'') {
$subject="Actes ou Statuts disponible pour $siren";
$message ="Le document commandé pour le siren $siren est disponible en téléchargement sur le site de Scores & Décisions à l'adresse suivante :\r\n\r\n";
$message.="http://extranet.scores-decisions.com/pdf/$nomCible\r\n";
$headers = 'From: infoslegales@scores-decisions.com' . "\r\n" .
'Reply-To: infoslegales@scores-decisions.com';
if (mail($commande['emailCommande'], $subject, $message, $headers))
echo date ('Y/m/d - H:i:s').' - Un email a été envoyé à '.$commande['emailCommande']." pour la commande $nomCible.".EOL;
else
echo date ('Y/m/d - H:i:s').' - ERREUR : Impossible d\'envoyer l\'email à '.$commande['emailCommande']." pour la commande $nomCible.".EOL;
}
mysql_update('commandes', array('dateReception'=>date('YmdHis')),'idCommande='.$commande['idCommande']);
//print_r($tabCommandes[$numFichier]);
}
else print 'Impossible de déplacer '.ACTES_IGNUM_LOCAL_DIR.$nomFichier.' en '.ACTES_IG_LOCAL_DIR.$nomCible.' !'.EOL;
}
}
else
// On traitera plus tard le multi fichier !
echo date ('Y/m/d - H:i:s')." - @TODO : La commande $numFichier est en plusieur fichiers !".EOL;
// die();
}
}
}
?>

210
batch/graydon.php Normal file
View File

@ -0,0 +1,210 @@
#!/usr/bin/php -q
<?php
$version = '0.2';
$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];
if($argc > 1){
foreach($argv as $value){
switch($value){
case 'availability':
$availability = FALSE;
break;
case 'matchidentifiers':
$matchidentifiers = FALSE;
break;
case 'matchmethods':
$matchmethods = FALSE;
break;
case 'commandes':
$checkCommandes = FALSE;
break;
case 'all':
$checkCommandes = TRUE;
$matchidentifiers = TRUE;
$matchmethods = TRUE;
$checkCommandes = FALSE;
break;
default:
break;
}
}
}else{
print $argv[0]." version : ".$version."\n\n";
print "Lancer le script ".$argv[0]." sans paramètres permet de charger toutes les méthodes graydon et vérifier les commandes\n\n";
print "Les services disponibles sont :\n";
print "\t-Disponibilité des pays graydon (availability).\n";
print "\t-Types d'identifiant disponible par pays (matchidentifiers).\n";
print "\t-Méthodes de recherche (matchmethods).\n";
print "\t-Vérification des commandes (commandes).\n";
exit;
}
require_once '../config/prepend.php';
//Inclure la base de données
require_once 'dbbootstrap.php';
//Inclure la config graydon
require_once 'graydon/graydonws.php';
setDbConn('graydon');
if($availability == TRUE){
//Country Availability
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
try
{
$result = $graydon->getCountryAvailability($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
foreach($result->CountryAvailablity->CountryAndProduct as $item){
$availability = array();
$count = count($item->Products->Product);
if ($count>1){
$availability = $item->Products->Product;
}elseif($count==1){
$availability[] = $item->Products->Product;
}
//Enregistrement pour chaque pays de la disponibilité des services
$countryavailability = new Countryavailability();
$countryavailability->country = $item->Country;
$countryavailability->availability = serialize($availability);
$countryavailability->replace();
}
}catch( SoapFault $fault ){}
}
if($matchidentifiers == TRUE){
//matchidentifiers
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
try
{
$result = $graydon->getCompanyMatchIdentifiers($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
$tabIdentifiers = array();
$count = count($item->CompanyIdentifier);
if ($count>1){
$tabIdentifiers = $item->CompanyIdentifier;
}elseif($count==1){
$tabIdentifiers[] = $item->CompanyIdentifier;
}
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $item->Country;
$matchidentifiers->identifiers = serialize($tabIdentifiers);
$matchidentifiers->replace();
}
}catch( SoapFault $fault ){
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
$firephp->log($text,'texterror');
require_once 'graydon/graydon_error.php';
if(graydon_error($code, $text)!=FALSE){
if($code=='CWS0112'){
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $pays;
$matchidentifiers->identifiers = serialize(false);
$matchidentifiers->replace();
}
}else{
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
}
}
if($matchmethods == TRUE){
//matchmethods
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
try
{
$result = $graydon->getCompanyMatchMethods($request);
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){
$methods = array();
$count = count($item->MatchMethods->MatchMethod);
if ($count>1){
$methods = $item->MatchMethods->MatchMethod;
}elseif($count==1){
$methods[] = $item->MatchMethods->MatchMethod;
}
//Stockage du résultat de la méthode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $item->Country;
$matchmethods->methods = serialize($methods);
$matchmethods->replace();
}
}catch( SoapFault $fault ){
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
$firephp->log($text,'texterror');
require_once 'graydon/error.php';
if(graydon_error($code, $text)!=FALSE){
if($code=='CWS0112'){
//Stockage du résultat de la méthode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $pays;
$matchmethods->methods = serialize('false');
$matchmethods->replace();
}
}else{
graydon_processSoapFault($graydon,$fault,'');
}
}
}
if($checkCommandes == TRUE){
//Vérification des commandes
$q = Doctrine_Query::create()
->select('*')
->from('Commandes');
$tabCommandes = $q->Execute();
//Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted')
foreach($tabCommandes as $commande){
//Si servicespeed = immediate alors on ne gère pas
if($commande->servicespeed != 'Immediate'){
switch($commande->orderstate){
case 'Delivered': //Délivré, on a été la chercher
//On ne fait rien
break;
case 'Completed': //Commande prête à télécharger
break;
case 'InError': //Problème dans la commande
break;
case 'Notified':
break;
case 'Initialised': //Commande prise en compte
case 'Assigned': //Assigné chez graydon
case '': // Pas d'état, commande pas encore vérifier
case 'default':
$q = Doctrine_Query::create()
->update('Commandes')
->set('orderstate', $orderstate)
->where('reference = ?', array($commande->reference));
$q->execute();
break;
}
}
}
}
?>

76
batch/mysql.php Normal file
View File

@ -0,0 +1,76 @@
<?
//error_reporting(E_ALL);
function mysql_trace($query, $res='') {
if (!$fp=fopen('mysql_insert.log', 'a'))
return false;
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $res : $query\n"))
return false;
if (!fclose($fp))
return false;
return true;
}
/** Retourne la dernière valeur de l'auto-incrément ou 0 si pas d'auto-incrément
** Penser à bien tester la valeur !== false
**/
function mysql_insert($table, $toAdd, $debug=false){
$fields = implode(array_keys($toAdd), '`,`');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=addslashes($array_values);
$values = "'".implode(array_values($tmp), "','")."'"; # better
$values = str_replace("'NULL'", 'NULL', $values);
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
$res = mysql_query($query);// OR die(mysql_error());
if ($res!==false)
{
if (mysql_insert_id()>0)
$res=mysql_insert_id();
else
$res=true;
}
if ($debug) mysql_trace($query, $res);
return $res;
//-- Example of usage
//$tToAdd = array('id'=>3, 'name'=>'Yo', 'salary' => 5000);
//insertIntoDB('myTable', $tToAdd)
}
function mysql_update($table, $update, $where, $debug=false){
$fields = array_keys($update);
$values = array_values($update);
$i=0;
$query='UPDATE `'.$table.'` SET ';
while($fields[$i]){
if($i>0){$query.=', ';}
$query.=' `'.$fields[$i]."`='".addslashes($values[$i])."'";
$i++;
}
$query = str_replace("'NULL'", 'NULL', $query);
$query.=' WHERE '.$where.' LIMIT 1;';
if ($debug) mysql_trace($query, mysql_errno());
mysql_query($query);// or die(mysql_error());
return true;
//Example
// mysql_update('myTable', $anarray, "type = 'main'")
}
function mysql_select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH) {
$query="SELECT $fields FROM $table WHERE $where;";
// if ($debug) mysql_trace($query, count($tab));
$result=mysql_query($query) or die(mysql_error());
$tab=array();
while ($ligne = mysql_fetch_array($result, $assoc))
$tab[]=$ligne;
mysql_free_result($result);
if ($debug) mysql_trace($query, count($tab));
// echo $query;
return $tab;
}
?>

21
config/append.php Normal file
View File

@ -0,0 +1,21 @@
<?php
die();
if( LOG_BENCH != 'NONE' )
{
$timer->setMarker('Fin du script (append.php)');
$mem=memory_get_usage();
$memko=$mem/1024;
if ( LOG_BENCH == 'FILE' || LOG_BENCH == 'BOTH' ) {
$strInfo=DATETIME_LOG.';'.$mem.';'.$_SERVER["PHP_SELF"].';'.$_SERVER['QUERY_STRING']."\n";
$f = fopen( LOG_PATH.'memory.log', 'a+' );
fwrite($f, $strInfo);
fclose($f);
}
if ( LOG_BENCH == 'WEB' || LOG_BENCH == 'BOTH' ) {
echo '<br/><hr><br/>Mémoire utilisée par le script "'. $_SERVER['PHP_SELF'].'" = '.$mem . " octets ($memko ko)";
echo "<br/>Temps d'exécution de la page :<br/>";
$timer->display();
}
}
?>

View File

@ -0,0 +1,51 @@
<?
/** Environnement du site **/
define ('ENVIRONNEMENT', 'DEV'); // PRD REC DEV
define ('EMAIL_SUPPORTDEV', 'mricois@scores-decisions.com');
define ('ERROR_SOAP', 'Une erreur est survenue lors de votre requête...<br/>Un message à été envoyé à l\'administrateur de l\'extranet.<br/>Nous vous remercions de bien vouloir renouveler votre demande ultérieurement');
/** Log des requêtes MySQL ? **/
define ('LOG_MYSQL', 'ALL'); // NONE ou ALL
/** Log des performances des pages PHP (mémoire et temps d'exécution **/
define ('LOG_BENCH', 'BOTH'); // NONE, WEB, FILE, BOTH
/** Paramètres de la base de données **/
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'sdv1');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', 'bj10sx');
define ('PATH_SITE', realpath(dirname(__FILE__) . '/../'));
define ('PATH_WWW', PATH_SITE.'/www/');
/** Paramètres de stockage **/
define ('PATH_DATA', '/sites/data');
define ('PATH_LOGS', PATH_DATA.'/log/');
define ('PATH_PDF', PATH_DATA.'/pdf/');
define ('PATH_LOGOS', PATH_WWW.'/img/logos/');
define ('EXTRANET_URL', 'http://extranet.sd.com/');
define ('IPARI_URL', 'http://tville.scores-decisions.com:8080/ipari/');
define ('SITEINST_URL1', 'http://extranet.sd.com/localauth/');
define ('SITEINST_URL2', 'http://extranet.sd.com/localauth/');
/** Celeste **/
define ('WEBSERVICE_URL', 'http://78.31.45.206/ws2/');
define ('WEBSERVICE_URI', 'http://78.31.45.206/');
/** INFOGREFFE **/
define ('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
define ('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
define ('INFOGREFFE_WS_USER', '85000109');
define ('INFOGREFFE_WS_PASS', '166');
/** Paramètres de la base de données **/
define ('FTPACTES_HOST', 'ftp2.scores-decisions.com');
define ('FTPACTES_USER', 'inpi');
define ('FTPACTES_PASS', 'coface');
define('INFOGREFFE_WS_REF', 'ref');
?>

View File

@ -0,0 +1,56 @@
<?
/** Environnement du site **/
define ('ENVIRONNEMENT', 'DEV'); // PRD REC DEV
define ('EMAIL_SUPPORTDEV', 'mricois@scores-decisions.com');
define('ERROR_SOAP', 'Une erreur est survenue lors de votre requête...<br/>Un message à été envoyé à l\'administrateur de l\'extranet.<br/>Nous vous remercions de bien vouloir renouveler votre demande ultérieurement');
/** Log des requêtes MySQL ? **/
define ('LOG_MYSQL', 'ALL'); // NONE ou ALL
/** Log des performances des pages PHP (mémoire et temps d'exécution **/
define ('LOG_BENCH', 'BOTH'); // NONE, WEB, FILE, BOTH
/** Paramètres de la base de données **/
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'extranet');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', '');
define ('PATH_SITE', realpath(dirname(__FILE__) . '/../'));
define ('PATH_WWW', PATH_SITE.'/www/');
/** Paramètres de stockage **/
define ('PATH_DATA', realpath('d:/www/data'));
define ('PATH_LOGS', PATH_DATA.'/log/');
define ('PATH_PDF', PATH_DATA.'/pdf/');
define ('PATH_LOGOS', PATH_WWW.'/img/logos/');
define ('EXTRANET_URL', 'http://extranet.devlocal.com/');
define ('IPARI_URL', 'http://tville.scores-decisions.com:8080/ipari/');
define ('SITEINST_URL1', 'http://extranet.devlocal.com/localauth/');
define ('SITEINST_URL2', 'http://extranet.devlocal.com/localauth/');
/** Celeste **/
define ('WEBSERVICE_URL', 'http://78.31.45.206/ws/');
define ('WEBSERVICE_URI', 'http://78.31.45.206/');
/** INFOGREFFE **/
//define('INFOGREFFE_WS_URL', 'https://wv2rcte.experian.fr/WSContextInfogreffe/INFOGREFFE');
//define('INFOGREFFE_WS_URI', 'https://wv2rcte.experian.fr/');
//define('INFOGREFFE_WS_USER', '85009006');
//define('INFOGREFFE_WS_PASS', '17628');
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
define('INFOGREFFE_WS_USER', '85000109');
define('INFOGREFFE_WS_PASS', '166');
/** Paramètres de la base de données **/
define ('FTPACTES_HOST', 'ftp2.scores-decisions.com');
define ('FTPACTES_USER', 'inpi');
define ('FTPACTES_PASS', 'coface');
define('INFOGREFFE_WS_REF', 'ref');
?>

View File

@ -0,0 +1,55 @@
<?
/** Environnement du site **/
define ('ENVIRONNEMENT', 'PRD'); // PRD REC DEV
define ('EMAIL_SUPPORTDEV', 'supportdev@scores-decisions.com');
define ('ERROR_SOAP', 'Une erreur est survenue lors de votre requête...<br/>Un message à été envoyé à l\'administrateur de l\'extranet.<br/>Nous vous remercions de bien vouloir renouveler votre demande ultérieurement');
/** Log des requêtes MySQL ? **/
define ('LOG_MYSQL', 'ALL'); // NONE ou ALL
/** Log des performances des pages PHP (mémoire et temps d'exécution **/
define ('LOG_BENCH', 'BOTH'); // NONE, WEB, FILE, BOTH
/** Paramètres de la base de données **/
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'sdv1');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', 'Cs03dfCN');
define ('PATH_SITE', realpath(dirname(__FILE__) . '/../'));
define ('PATH_WWW', PATH_SITE.'/www/');
/** Paramètres de stockage **/
define ('PATH_DATA', '/var/www/data');
define ('PATH_LOGS', PATH_DATA.'/log/');
define ('PATH_PDF', PATH_DATA.'/pdf/');
define ('PATH_LOGOS', PATH_WWW.'/img/logos/');
define ('EXTRANET_URL', 'http://extranet.scores-decisions.com/');
define ('IPARI_URL', 'http://tville.scores-decisions.com:8080/ipari/');
define ('SITEINST_URL1', 'http://www.scores-decisions.com/');
define ('SITEINST_URL2', 'http://www.scores-decisions.com/');
/** Celeste **/
define ('WEBSERVICE_URL', 'http://78.31.45.206/ws/');
define ('WEBSERVICE_URI', 'http://78.31.45.206/');
/** INFOGREFFE **/
//define('INFOGREFFE_WS_URL', 'https://wv2rcte.experian.fr/WSContextInfogreffe/INFOGREFFE');
//define('INFOGREFFE_WS_URI', 'https://wv2rcte.experian.fr/');
//define('INFOGREFFE_WS_USER', '85009006');
//define('INFOGREFFE_WS_PASS', '17628');
define ('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
define ('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
define ('INFOGREFFE_WS_USER', '85000109');
define ('INFOGREFFE_WS_PASS', '166');
/** Paramètres de la base de données **/
define ('FTPACTES_HOST', 'ftp2.scores-decisions.com');
define ('FTPACTES_USER', 'inpi');
define ('FTPACTES_PASS', 'coface');
define('INFOGREFFE_WS_REF', 'ref');
?>

55
config/config.inc Normal file
View File

@ -0,0 +1,55 @@
<?
/** Environnement du site **/
define ('ENVIRONNEMENT', 'DEV'); // PRD REC DEV
define ('EMAIL_SUPPORTDEV', 'mricois@scores-decisions.com');
define ('ERROR_SOAP', 'Une erreur est survenue lors de votre requête...<br/>Un message à été envoyé à l\'administrateur de l\'extranet.<br/>Nous vous remercions de bien vouloir renouveler votre demande ultérieurement');
/** Log des requêtes MySQL ? **/
define ('LOG_MYSQL', 'ALL'); // NONE ou ALL
/** Log des performances des pages PHP (mémoire et temps d'exécution **/
define ('LOG_BENCH', 'BOTH'); // NONE, WEB, FILE, BOTH
/** Paramètres de la base de données **/
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'sdv1');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', '');
define ('PATH_SITE', realpath(dirname(__FILE__) . '/../'));
define ('PATH_WWW', PATH_SITE.'/www/');
/** Paramètres de stockage **/
define ('PATH_DATA', realpath('d:/www/data'));
define ('PATH_LOGS', PATH_DATA.'/log/');
define ('PATH_PDF', PATH_DATA.'/pdf/');
define ('PATH_LOGOS', PATH_WWW.'/img/logos/');
define ('EXTRANET_URL', 'http://extranet.devlocal.com/');
define ('IPARI_URL', 'http://tville.scores-decisions.com:8080/ipari/');
define ('SITEINST_URL1', 'http://extranet.devlocal.com/localauth/');
define ('SITEINST_URL2', 'http://extranet.devlocal.com/localauth/');
/** Celeste **/
define ('WEBSERVICE_URL', 'http://78.31.45.206/ws2/');
define ('WEBSERVICE_URI', 'http://78.31.45.206/');
/** INFOGREFFE **/
//define('INFOGREFFE_WS_URL', 'https://wv2rcte.experian.fr/WSContextInfogreffe/INFOGREFFE');
//define('INFOGREFFE_WS_URI', 'https://wv2rcte.experian.fr/');
//define('INFOGREFFE_WS_USER', '85009006');
//define('INFOGREFFE_WS_PASS', '17628');
define ('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
define ('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
define ('INFOGREFFE_WS_USER', '85000109');
define ('INFOGREFFE_WS_PASS', '166');
/** Paramètres de la base de données **/
define ('FTPACTES_HOST', 'ftp2.scores-decisions.com');
define ('FTPACTES_USER', 'inpi');
define ('FTPACTES_PASS', 'coface');
define('INFOGREFFE_WS_REF', 'ref');
?>

149
config/prepend.php Normal file
View File

@ -0,0 +1,149 @@
<?php
/*
* Remplacement du php_value include_path dans le .htaccess
* Attention à bien placer l'include_path dans le php.ini
* Pour windows/wamp : include_path = ".;c:\wamp\bin\php\php-X.X.X\PEAR"
* Pour serveur linux : include_path = ".:/usr/share/php"
*/
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR .
realpath(dirname(__FILE__) . '/../framework/') . PATH_SEPARATOR .
realpath(dirname(__FILE__) . '/../includes/')
);
/**
* Fonction globale récupérant le microtime de la machine en format float.
* @return float Valeur courante du microtime() de la machine en format décimal
*/
function getmicrotime(){
list($usec, $sec) = explode (' ', microtime());
return ( (float)$sec + (float)$usec );
}
/** On ne prend l'heure qu'une seule fois par script PHP et on initialise des constantes.
*
* DATETIME YmdHis
* DATETIME_LOG Y-m-d H:i:s Date du jour pour les insertions en BDD
* NOW His Heure d'exécution du script
* NOW_FORMAT H:i:s Heure d'exécution du script
* TODAY Ymd Année, Mois, Jour d'exécution du script
* TODAY_FORMAT Y-m-d
* TODAY_AFF d/m/Y
*/
define ('DATETIME', date('YmdHis'));
define ('DATETIME_LOG', substr(DATETIME,0,4).'-'.substr(DATETIME, 4,2).'-'.substr(DATETIME, 6,2).' '.substr(DATETIME,8,2).'-'.substr(DATETIME,10,2).'-'.substr(DATETIME,12,2) );
define ('TODAY', substr(DATETIME,0,8));
define ('NOW', substr(DATETIME,8,6));
define ('TODAY_FORMAT', substr(DATETIME,0,4).'-'.substr(DATETIME,4,2).'-'.substr(DATETIME,6,2));
define ('TODAY_AFF', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
define ('NOW_FORMAT', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
/**
* Les librairies suivantes sont chargées automatiquement car tous les scripts les utilisent !
*/
if( !defined('ROOT_PATH') )
{
define ('ROOT_PATH', realpath(dirname(__FILE__) . '/../') );
define ('WWW_PATH', realpath(ROOT_PATH.'/www/') );
define ('LOG_PATH', realpath(ROOT_PATH.'/log/') );
define ('INCLUDE_PATH', realpath(ROOT_PATH.'/includes/') );
include_once realpath(INCLUDE_PATH.'/phplib/db_mysql.inc');
include_once realpath(INCLUDE_PATH.'/auth/sessions.inc');
//include_once realpath(INCLUDE_PATH.'/auth/sessions.local.inc');
include_once realpath(ROOT_PATH.'/config/config.inc');
}
//Debuggage
require_once 'FirePHPCore/FirePHP.class.php';
ob_start();
$firephp = FirePHP::getInstance(true);
//Définition des options de configuration suivant le serveur
if(ENVIRONNEMENT == 'PRD')
{
$firephp->setEnabled(false);
ini_set('error_reporting', 0);
}
elseif(ENVIRONNEMENT == 'DEV')
{
$firephp->setEnabled(true); //Debuggage activé par defaut
//ini_set('error_reporting', E_ALL ^ E_NOTICE);
}
if ( LOG_BENCH != 'NONE' ){
include_once ('Benchmark/Timer.php');
}else{
class Benchmark_Timer
{
function start() {}
function setMarker() {}
function stop() {}
function getProfiling() {}
function display() {}
}
}
/* @todo: A enlever pour la prod
$timer = new Benchmark_Timer();
$timer->start();
$timer->setMarker('Debut du script (prepend.php)');
*/
/** Instance de la connexion à la base de données
* Cette instance est utilisée par tous les scripts pour accéder à la base de données
*/
class DB extends DB_MySQL
{
function DB() {
$this->Host = MYSQL_HOST;
$this->Database = MYSQL_DB;
$this->User = MYSQL_USER;
$this->Password = MYSQL_PASS;
}
function getRow() {
$ret= $this->Record;
for( $i= 0; $i<count($this->Record); $i++ ) { if( !isset($ret[$i]) ) break; unset($ret[$i]); }
return $ret;
}
function query($q) {
if ( LOG_MYSQL != 'NONE' ) $time_start=getmicrotime();
$ret=DB_MySQL::query($q);
if ( LOG_MYSQL == 'NONE' ) return $ret;
$time_end= getmicrotime();
$time_total= $time_end-$time_start;
$time_total= substr((string)$time_total,0,10);
$now= date('Y/m/d H:i:s', $time_start);
if ($ret<1)
$mysqlerror = mysql_errno() .' : '. mysql_error();
else
$mysqlerror = '';
$sqlAction=strtoupper(substr(trim($q),0,6));
if ( LOG_MYSQL=='SELECT' && $sqlAction=='SELECT' )
$logOption='_select';
elseif ( LOG_MYSQL=='UPDATE' && ( $sqlAction=='UPDATE' || $sqlAction=='INSERT' || $sqlAction=='DELETE' ) )
$logOption='_update';
else
$logOption='';
$fh=@fopen( LOG_PATH . 'db_mysql'.$logOption.'.log', 'a+');
if ($fh) {
@fwrite($fh, "$now\t$time_total\t" . MYSQL_HOST ."\t". MYSQL_USER ."\t". MYSQL_DB ."\t$mysqlerror\t$q\r\n");
@fclose($fh);
}
$mySqlErrTab=explode(' : ', $mysqlerror);
$mySqlErrno=(int)$mySqlErrTab[0];
if ( $mySqlErrno > 0 && $mySqlErrno !=1062 ) {
// mail_admin( 'Erreur MySQL '.$mySqlErrno, $mysqlerror ."\n\n". $q );
}
return $ret;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,261 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
*
* This file is part of FirePHP (http://www.firephp.org/).
*
* Software License Agreement (New BSD License)
*
* Copyright (c) 2006-2009, Christoph Dorn
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Christoph Dorn nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK *****
*
* @copyright Copyright (C) 2007-2009 Christoph Dorn
* @author Christoph Dorn <christoph@christophdorn.com>
* @license http://www.opensource.org/licenses/bsd-license.php
* @package FirePHP
*/
require_once dirname(__FILE__).'/FirePHP.class.php';
/**
* Sends the given data to the FirePHP Firefox Extension.
* The data can be displayed in the Firebug Console or in the
* "Server" request tab.
*
* @see http://www.firephp.org/Wiki/Reference/Fb
* @param mixed $Object
* @return true
* @throws Exception
*/
function fb()
{
$instance = FirePHP::getInstance(true);
$args = func_get_args();
return call_user_func_array(array($instance,'fb'),$args);
}
class FB
{
/**
* Enable and disable logging to Firebug
*
* @see FirePHP->setEnabled()
* @param boolean $Enabled TRUE to enable, FALSE to disable
* @return void
*/
public static function setEnabled($Enabled) {
$instance = FirePHP::getInstance(true);
$instance->setEnabled($Enabled);
}
/**
* Check if logging is enabled
*
* @see FirePHP->getEnabled()
* @return boolean TRUE if enabled
*/
public static function getEnabled() {
$instance = FirePHP::getInstance(true);
return $instance->getEnabled();
}
/**
* Specify a filter to be used when encoding an object
*
* Filters are used to exclude object members.
*
* @see FirePHP->setObjectFilter()
* @param string $Class The class name of the object
* @param array $Filter An array or members to exclude
* @return void
*/
public static function setObjectFilter($Class, $Filter) {
$instance = FirePHP::getInstance(true);
$instance->setObjectFilter($Class, $Filter);
}
/**
* Set some options for the library
*
* @see FirePHP->setOptions()
* @param array $Options The options to be set
* @return void
*/
public static function setOptions($Options) {
$instance = FirePHP::getInstance(true);
$instance->setOptions($Options);
}
/**
* Get options for the library
*
* @see FirePHP->getOptions()
* @return array The options
*/
public static function getOptions() {
$instance = FirePHP::getInstance(true);
return $instance->getOptions();
}
/**
* Log object to firebug
*
* @see http://www.firephp.org/Wiki/Reference/Fb
* @param mixed $Object
* @return true
* @throws Exception
*/
public static function send()
{
$instance = FirePHP::getInstance(true);
$args = func_get_args();
return call_user_func_array(array($instance,'fb'),$args);
}
/**
* Start a group for following messages
*
* Options:
* Collapsed: [true|false]
* Color: [#RRGGBB|ColorName]
*
* @param string $Name
* @param array $Options OPTIONAL Instructions on how to log the group
* @return true
*/
public static function group($Name, $Options=null) {
$instance = FirePHP::getInstance(true);
return $instance->group($Name, $Options);
}
/**
* Ends a group you have started before
*
* @return true
* @throws Exception
*/
public static function groupEnd() {
return self::send(null, null, FirePHP::GROUP_END);
}
/**
* Log object with label to firebug console
*
* @see FirePHP::LOG
* @param mixes $Object
* @param string $Label
* @return true
* @throws Exception
*/
public static function log($Object, $Label=null) {
return self::send($Object, $Label, FirePHP::LOG);
}
/**
* Log object with label to firebug console
*
* @see FirePHP::INFO
* @param mixes $Object
* @param string $Label
* @return true
* @throws Exception
*/
public static function info($Object, $Label=null) {
return self::send($Object, $Label, FirePHP::INFO);
}
/**
* Log object with label to firebug console
*
* @see FirePHP::WARN
* @param mixes $Object
* @param string $Label
* @return true
* @throws Exception
*/
public static function warn($Object, $Label=null) {
return self::send($Object, $Label, FirePHP::WARN);
}
/**
* Log object with label to firebug console
*
* @see FirePHP::ERROR
* @param mixes $Object
* @param string $Label
* @return true
* @throws Exception
*/
public static function error($Object, $Label=null) {
return self::send($Object, $Label, FirePHP::ERROR);
}
/**
* Dumps key and variable to firebug server panel
*
* @see FirePHP::DUMP
* @param string $Key
* @param mixed $Variable
* @return true
* @throws Exception
*/
public static function dump($Key, $Variable) {
return self::send($Variable, $Key, FirePHP::DUMP);
}
/**
* Log a trace in the firebug console
*
* @see FirePHP::TRACE
* @param string $Label
* @return true
* @throws Exception
*/
public static function trace($Label) {
return self::send($Label, FirePHP::TRACE);
}
/**
* Log a table in the firebug console
*
* @see FirePHP::TABLE
* @param string $Label
* @param string $Table
* @return true
* @throws Exception
*/
public static function table($Label, $Table) {
return self::send($Table, $Label, FirePHP::TABLE);
}
}

View File

@ -0,0 +1,39 @@
<?
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',
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);
}
}
?>

173
framework/common/curl.php Normal file
View File

@ -0,0 +1,173 @@
<?
//include_once('/var/www/default/_includes/timer.php');
/** 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, $acceptRedir=0) {
$ch = curl_init();
if ($host=='') {
$tabTmp = parse_url($url);
$hostUrl = $tabTmp['host'];
$this_header = array('Host: '. $hostUrl);
} 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_RETURNTRANSFER, 1);
if ($acceptRedir>0) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $acceptRedir);
}
$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_HTTPHEADER, $this_header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//print_r($this_header);
$page=curl_exec($ch);
if($page === false) {
if (curl_errno($ch) == 28) //TIMEOUT
$response=array('code' =>408, 'header' =>array(), 'body' =>'Connexion impossible au site du partenaire');
else
$response=array('code' =>400, 'header' =>array(), 'body' =>'Erreur Curl : ' . curl_error($ch));
} else {
$response = parse_response($page);
}
if ($debug){
$url2=str_replace('http://', '', $url);
$url2=str_replace('/', '_', $url2);
$url2=str_replace('?', '(param)', $url2);
$url2=str_replace('&', '(et)', $url2);
$fp=fopen('insee/'. 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>
*/
}
?>

124
framework/common/dates.php Normal file
View File

@ -0,0 +1,124 @@
<?
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, 'ééû','eeu');
return array_search(ucfirst(strtolower(strtr($moisEnLettres, 'ééû','eeu'))), $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;
}
/**
* 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=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=substr($date, $posM, strlen($date)-4-$posM);
$m=self::getNumMois($M);
break;
case 'Ymd': $d=substr($date,6,2); $m=substr($date,4,2); $Y=substr($date,0,4); break;
case 'Y-m-d': $d=substr($date,8,2); $m=substr($date,5,2); $Y=substr($date,0,4); break;
case 'd/m/Y': $d=substr($date,0,2); $m=substr($date,3,2); $Y=substr($date,6,4); 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 'M Y': return $this->tabMoisEnLettres[$m].' '.$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)
* @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=trim(strtr($period, "-.,", ' '));
if ($period=='') return NULL;
$tabP=explode(' ', $period);
$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;
}
}
?>

56
framework/common/ftp.php Normal file
View File

@ -0,0 +1,56 @@
<?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);
$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);
if ($debug<>null) 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;
if ($debug<>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) {
if ($debug<>null) 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);
if ($debug<>null) 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)) {
if ($debug<>null) 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;
}
?>

151
framework/common/mysql.php Normal file
View 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).')';
}
}
?>

View File

@ -0,0 +1,419 @@
<?
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 ($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;
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
<?
$tabINDREP=array('B'=>'bis',
'T'=>'ter',
'Q'=>'quater',
'C'=>'quinquies',
' '=>'',
''=>'');
switch($_SESSION['user']) {
case 'MHZ': $myEmail='mheitz@scores-decisions.com'; break;
case 'JMY': $myEmail='jmartory@scores-decisions.com'; break;
case 'YLN': $myEmail='buzuk@scores-decisions.com'; break;
}
?>

View File

@ -0,0 +1,177 @@
<?
//include_once(realpath(dirname(__FILE__) . '/timer.php'));
/** 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, $err_num, $err_msg) {
// 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]; }
if ($response_code==100) {
list($response_headers, $response_body) = explode("\r\n\r\n", $response_body, 2);
$response_header_lines = explode("\r\n", $response_headers);
$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";
}
/* if ($response_code==100) {
print_r($response_headers);
// print_r($response_header_lines);
}*/
return array('code' => $response_code, 'header' => $response_header_array, 'body' => $response_body, 'err_num'=>$err_num, 'err_msg'=>$err_msg);
}
/** 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) {
$ch = curl_init();
if ($host=='')
$this_header = array('Host: '. HOST_INSEE);
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);
if (((int)$timeout)<>0) curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
$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)."&";
$o.= "$k=".$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: ".strlen($post_data));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
//print_r($this_header);
$page=curl_exec($ch);
$response = parse_response($page, curl_errno($ch), curl_error($ch));
if ($debug){
$url2=str_replace('http://', '', $url);
$url2=str_replace('/', '_', $url2);
$url2=str_replace('?', '(param)', $url2);
$url2=str_replace('&', '(et)', $url2);
$fp=fopen('insee/'. 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>
*/
}
?>

View File

@ -0,0 +1,820 @@
<?php
/***********************************************************************************************************/
/* CLASSE D'AFFICHAGE ET D'ENVOI D'UN FORMULAIRE */
/* */
/* Auteur : Bernard Martin-Rabaud */
/* Email : bernard@ediweb.org */
/* */
/* Cette classe permet de : */
/* - créer un formulaire */
/* - le contrôler et l'afficher pour confirmation */
/* - et retourner son contenu */
/***********************************************************************************************************/
define("_SEPA_AFFICHE_MULTIPLE", ", ");
define("_SEPA_VALEUR_MULTIPLE", "###");
$erreur_message = array("min" => "caractères minimum",
"max" => "caractères maximum",
"texte" => "texte non valide",
"alphanum" => "texte alphanumérique non valide",
"num" => "valeur numérique non valide",
"num-strict" => "valeur numérique non valide",
"tel" => "numéro de téléphone non valide",
"email" => "e-mail non valide",
"url" => "url non valide",
"date" => "date non valide",
"datej" => "jour non valide",
"datem" => "mois non valide",
"datem" => "année non valide",
"option" => "aucune option n'a été sélectionnée",
"vide" => "champ obligatoire");
class ClasseForm {
var $titre;
var $montrer_titre;
var $champs;
var $taille_std;
var $pivot_siecle;
var $mode_retour;
var $confirme;
var $mode;
var $champ_cour;
var $log;
var $name;
var $closeButton;
function ClasseForm($titre=null, $confirme=false, $autocomplete="on", $nom='formulaire', $closeButton=false) {
$this->titre = $titre;
$this->montrer_titre = true;
$this->champs = array();
$this->taille_std = null;
$this->pivot_siecle = 20;
$this->mode_retour = "noms & valeurs";
$this->confirme = $confirme;
if ($autocomplete==false || $autocomplete=="off" || $autocomplete==null)
$this->autocomplete = 'off';
else
$this->autocomplete = 'on';
$this->name=$nom;
$this->mode = null;
$this->champ_cour = 0;
$this->log = null;
$this->closeButton=$closeButton;
}
function afficher() {
$resultat = null;
echo $this->javascriptSubmit();
if (!isset($_POST) || !$_POST || ($_POST["classeform_acces"] == "annuler")) $this->mode = null;
else {
$this->affecterValeursChamps($_POST);
$succes = $this->controler();
if ($succes) $this->mode = $_POST["classeform_acces"];
else $this->mode = "erreur";
}
switch ($this->mode) {
case "confirme" :
echo $this->afficherTexte();
echo $this->afficherForm(true);
break;
case "modif" :
echo $this->afficherForm();
break;
case "envoi" :
$resultat = $this->retournerTableauValeurs($this->mode_retour);
//print_r($resultat);
if ($this->log) $this->enregistrerLog($this->retournerTableauValeurs("valeurs", $resultat));
break;
default :
echo $this->afficherForm();
}
return $resultat;
}
function ajoutChamp($label, $nom, $type, $format=null, $oblig=true, $min=null, $max=null, $defVal='') {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, $type, $format, $oblig, $min, $max, $defVal);
}
function ajoutChampText($label, $nom, $format=null, $oblig=true, $min=null, $max=null, $defVal='', $ajaxQuery='') {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "text", $format, $oblig, $min, $max, $defVal, $ajaxQuery);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 256);
}
function ajoutChampHidden($nom) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp('', $nom, "hidden");
}
function ajoutChampPassword($label, $nom, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "password", "", true, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 100);
}
function ajoutChampTextarea($label, $nom, $format=null, $oblig=true, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "textarea", $format, $oblig, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 3);
}
function ajoutChampFile($label, $nom, $oblig=true, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "file", "fichier", $oblig, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 256);
}
function ajoutChampSelect($label, $nom, $oblig=true, $taille=null, $multiple=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "select", "", $oblig, null, null);
if ($taille) $this->champs[$this->champ_cour]->valCtlLimites($taille, null);
if ($multiple) $this->champs[$this->champ_cour]->valMultiple();
}
function ajoutChampRadio($label, $nom, $oblig=true, $fin_ligne=null) {
$this->champ_cour = sizeof($this->champs);
$args = func_get_args();
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "radio", "", $oblig);
if ($fin_ligne) $this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
if (sizeof($args) > 4) $this->champs[$this->champ_cour]->valOptions(array_slice($args, 4));
}
function ajoutChampCheckbox($label, $nom, $oblig=true, $fin_ligne=null) {
$this->champ_cour = sizeof($this->champs);
$args = func_get_args();
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "checkbox", "", $oblig);
if ($fin_ligne) $this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
if (sizeof($args) > 4) $this->champs[$this->champ_cour]->valOptions(array_slice($args, 4));
}
function ajoutTexte($texte) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($texte, "", "", "", false);
}
function cacherTitre() {
$this->montrer_titre = false;
}
function valTailleStd($taille) {
$this->taille_std = $taille;
}
function valPivotSiecle($pivot) {
$this->pivot_siecle = $pivot;
}
function valModeRetour($mode) {
$this->mode_retour = $mode;
}
function valLog($log) {
$this->log = $log;
}
function valChampFormat($format, $min=null, $max=null) {
$this->champs[$this->champ_cour]->valFormat($format, $min, $max);
}
function valChampLimites($min, $max=null) {
$this->champs[$this->champ_cour]->valLimites($min, $max);
}
function valChampCtlLimites($min, $max=null) {
$this->champs[$this->champ_cour]->valCtlLimites($min, $max);
}
function valChampMultiple() {
$this->champs[$this->champ_cour]->valMultiple();
}
function valChampOptions() {
if ((func_num_args() == 1) && is_array(func_get_arg(0))) $args = func_get_arg(0);
else $args = func_get_args();
$this->champs[$this->champ_cour]->valOptions($args);
}
function valChampDescro($descro) {
$this->champs[$this->champ_cour]->valDescro($descro);
}
function valChampFinLigne($fin_ligne) {
$this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
}
function valChampOption1Vide($option_vide) {
$this->champs[$this->champ_cour]->valOption1Vide($option_vide);
}
function afficherForm($cache=false) {
$html = "<form method='post' action='javascript:location.href' name='$this->name' 'id='$this->name' autocomplete='$this->autocomplete'>\n";
$html .= "<fieldset>\n";
$html .= "<table class='form-table' cellspacing='0' cellpadding='2' border='0'>\n";
if ($this->titre && $this->montrer_titre && !$cache)
$html .= "<caption class='form-caption'>$this->titre" . (($this->mode == "erreur") ? " <span class='erreur'>(erreurs)</span>" : "") . "</caption>\n";
else if (($this->mode == "erreur"))
$html .= "<caption class='form-caption'><span class='erreur'>(erreurs)</span></caption>\n";
for ($i=0;$i<sizeof($this->champs);$i++) {
if ($cache) $html .= $this->champs[$i]->afficherFormCache();
else $html .= $this->champs[$i]->afficherForm();
}
if ($valeurs) $html .= $this->afficherBoutonsForm();
else $html .= $this->afficherBoutonsForm();
if ($this->existeChampFacultatif())
$html .= "<tr><td class='form-info-obligatoire' colspan='2'>&nbsp;</td></tr>";
$html .= "</fieldset></table></form>\n";
return $html;
}
function afficherBoutonsForm() {
if (($this->mode == null) || ($this->mode == "erreur")) {
if ($this->confirme)
$html = "<tr><td><input type='hidden' name='classeform_acces' value='confirme' /></td>";
else $html = "<tr><td><input type='hidden' name='classeform_acces' value='envoi' /></td>";
}
else $html = "<tr><td><input type='hidden' name='classeform_acces' /></td>";
$html .= "<td><input class='form-bouton' type='button' value='Envoyer' onClick='soumettre(\"envoi\")'/>";
if ($this->confirme) {
if ($this->mode == "confirme") {
$html .= " <input class='form-bouton' type='button' value='Modifier'";
$html .= " onClick='soumettre(\"modif\")'; />";
}
else {
$html .= " <input class='form-bouton' type='button' value='Voir avant envoi'";
$html .= " onClick='soumettre(\"confirme\")'; />";
}
}
$html .= " <input class='form-bouton' type='reset' value='Rétablir' onClick='soumettre(\"annuler\")' />\n";
if ($this->closeButton)
$html .= " <input class='form-bouton' type='button' value='Annuler & Fermer' onClick='soumettre(\"fermer\")' />\n";
$html .= "</td></tr>";
return $html;
}
function afficherTexte() {
$html = "<table class='form-table' cellspacing='0' cellpadding='2' border='0'>\n";
if ($this->titre) $html .= "<caption class='form-caption'>$this->titre</caption>\n";
for ($i=0;$i<sizeof($this->champs);$i++)
$html .= $this->champs[$i]->afficherTexte();
$html .= "</table>\n";
return $html;
}
function javascriptSubmit() {
$html = "<script language='JavaScript'>\n";
$html .= "<!-- \n";
$html .= "function soumettre(acces) {\n";
$html .= " if (acces=='fermer') self.close();\n";
$html .= " else {\n";
$html .= " with (document.forms[0]) {\n";
$html .= " classeform_acces.value=acces; action=location.href; submit();\n";
$html .= " }\n";
$html .= " }\n";
$html .= "}\n";
$html .= "// -->\n";
$html .= "</script>\n";
return $html;
}
function controler() {
$succes = true;
for ($i=0;$i<sizeof($this->champs);$i++) {
$this->champs[$i]->valeur_db=$this->champs[$i]->valeur;
if ( $this->champs[$i]->aControler() && ($this->champs[$i]->controler($this->pivot_siecle) == false) ) {
$succes = false;
}
}
return $succes;
}
function affecterValeursChamps($valeurs) {
$valeurs = convertirPost($valeurs);
for ($i=0;$i<sizeof($this->champs);$i++)
$this->champs[$i]->affecterValeur($valeurs);
}
function retournerTableauValeurs($mode_retour) {
$retour = array();
for ($i=0;$i<sizeof($this->champs);$i++)
{// echo "------------------------------------\r\n$i : \r\n";
//print_r($this->champs);
//print_r($this->champs[$i]);
//echo "\r\n\r\n";
$this->champs[$i]->retournerTableauValeurs(&$retour, $mode_retour);}
return $retour;
}
function envoyerMail() {
$mail = new ClasseMail($this->titre);
$mail->contenu = $this->champs;
return $mail->envoyer($this->cible);
}
function existeChampFacultatif() {
$ok = false;
for ($i=0;$i<sizeof($this->champs);$i++) {
if ($this->champs[$i]->type && !$this->champs[$i]->valObligatoire()) {
$ok = true;
break;
}
}
return $ok;
}
function enregistrerLog($valeurs, $resultat) {
if ($f = fopen($this->log, "a")) {
$texte = ($resultat ? "" : "ECHEC ") . "[ " . date("d/mY H:i:s") . " ] - ";
$texte .= $this->titre ? "$this->titre - " : "";
$texte .= $valeurs;
fputs($f, $texte);
fclose($f);
}
}
}
class ClasseFormChamp {
var $label;
var $nom;
var $type;
var $format;
var $oblig;
var $taille_max;
var $taille_min;
var $valeur;
var $options;
var $descro;
var $multiple;
var $fonction;
var $ctl_taille1;
var $ctl_taille2;
var $fin_ligne;
var $erreur;
var $valeur_defaut;
var $valeur_db;
var $ajaxQuey;
function ClasseFormChamp($label, $nom, $type=null, $format=null, $oblig=true, $min=null, $max=null, $valDef='', $ajaxQuery='') {
$this->label = $label;
$this->nom = $nom;
$this->type = $type;
$this->format = $format;
$this->taille_min = $min;
$this->taille_max = $max;
$this->oblig = $oblig;
if (($type == "select") || ($type == "checkbox") || ($type == "radio")) {
$this->valeur = array();
$this->options = array();
}
else {
$this->valeur = null;
$this->options = null;
}
$this->descro = null;
if ($type == "checkbox") $this->multiple = true;
else $this->multiple = false;
$this->fonction = null;
$this->ctl_taille1 = null;
$this->ctl_taille2 = null;
$this->fin_ligne = null;
$this->erreur = null;
$this->valeur_defaut = $valDef;
$this->ajaxQuey = $ajaxQuery;
// $this->valeur_db=$this->valeur;
}
function valObligatoire() {
if ($this->oblig) return true;
else return false;
}
function valFormat($format, $long_min=null, $long_max=null) {
if ($this->type == "text") {
$this->format = $format;
if ($long_min) $this->taille_min = $long_min;
if ($long_max) $this->taille_max = $long_max;
}
}
function valLimites($min, $max) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->taille_min = $min;
$this->taille_max = $max;
}
}
function valCtlLimites($taille1, $taille2) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "select") || ($this->type == "file")) {
$this->ctl_taille1 = $taille1;
if ($taille2 && ($this->type != "select")) $this->ctl_taille2 = $taille2;
}
}
function valFonction($fonction) {
$this->fonction = $fonction;
}
function valDescro($descro) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->descro = $descro;
}
}
function valMultiple() {
if ($this->type == "select") $this->multiple = true;
}
function valFinLigne($fin_ligne) {
if (($this->type == "radio") || ($this->type == "checkbox")) $this->fin_ligne = $fin_ligne;
}
function valOptions($options) {
if ($this->champAOptions()) {
if (is_array($options)) {
foreach ($options as $option) {
if (preg_match("/^s[e|é]lection\s?=\s?(.+)$/", $option, $regs))
$this->options[] = new ClasseFormOption($regs[1], true);
else $this->options[] = new ClasseFormOption($option);
}
}
else {
if (preg_match("/^s[e|é]lection\s?=\s?(.+)$/", $options, $regs))
$this->options[] = new ClasseFormOption($regs[1], true);
else $this->options[] = new ClasseFormOption($options);
}
}
}
function ValOption1Vide($option_vide) {
if ($this->type == "select") $this->fin_ligne = $option_vide;
}
function afficherForm() {
if (!$this->type) $html = "<tr><td class='form-label' colspan='2'>$this->label</td></tr>";
else {
if (!is_null($this->erreur))
$html = "<tr><td class='form-label-erreur'> > $this->label (<font size='-2'>$this->erreur</font>)</td>";
else if ($this->oblig) $html = "<tr><td class='form-label-obligatoire'>$this->label</td>";
else $html .= "<tr><td class='form-label-facultatif'>$this->label</td>";
$html .= "<td class='form-td'>";
switch ($this->type) {
case "text" : $html .= $this->afficherFormTexte();
break;
case "password" : $html .= $this->afficherFormPassword();
break;
case "textarea" : $html .= $this->afficherFormTextarea();
break;
case "select" : $html .= $this->afficherFormSelect();
break;
case "radio" : $html .= $this->afficherFormRadio();
break;
case "checkbox" : $html .= $this->afficherFormCheckbox();
break;
case "file" : $html .= $this->afficherFormFile();
break;
case "hidden" : $html .= $this->afficherFormCache();
break;
}
$html .= "</td></tr>\n";
}
return $html;
}
function afficherFormCache() {
$html = "<input type='hidden' name='$this->nom' id='$this->nom'";
if (is_array($this->valeur)) {
$chaine = implode(_SEPA_VALEUR_MULTIPLE, $this->valeur);
$html .= " value=\"" . $chaine . "\" />\n";
}
else $html .= " value=\"" . $this->valeur . "\" />\n";
return $html;
}
function afficherTexte() {
$html = "<tr><td class='form-label'>$this->label</td><td class='form-td'>";
if (is_array($this->valeur)) {
$chaine = implode(_SEPA_AFFICHE_MULTIPLE, $this->valeur);
$html .= $chaine;
}
else $html .= $this->valeur;
$html .= "</td></tr>\n";
return $html;
}
function champAOptions() {
if (($this->type == "select") || ($this->type == "checkbox") || ($this->type == "radio")) return true;
else return false;
}
function controler($pivot=null) {
global $erreur_message;
//$this->valeur_db=$this->valeur;
if ($this->type) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->controlerChampTexte($pivot);
if (is_null($this->erreur)) return true;
else return false;
}
else if (($this->type == "select") || ($this->type == "radio")) {
if (!$this->valeur || (sizeof($this->valeur) == 0)) {
$this->erreur = $erreur_message["option"];
return false;
}
else return true;
}
else return true;
}
else return true;
}
function aControler() {
if ($this->type && $this->oblig) return true;
else return false;
//return true;
}
function retournerTableauValeurs(&$tableau, $mode_retour) {
if (is_array($this->valeur)) {$valeur = implode(_SEPA_VALEUR_MULTIPLE, $this->valeur);
print_r($this->valeur);
die('Cas non géré dans inc_classeform.php');
}
else $valeur = $this->valeur_db;
switch ($mode_retour) {
case "noms & valeurs" :
$tableau[$this->nom] = $valeur;
break;
case "labels & valeurs" :
$tableau[$this->label] = $valeur;
break;
case "valeurs" :
$tableau[] = $valeur;
}
//echo '$this->nom='.$this->nom.', $valeur='.$valeur."\r\n";
}
function affecterValeur($valeurs) {
$valeur = $valeurs[$this->nom];
if ($this->champAOptions()) {
if (strpos($valeur, _SEPA_VALEUR_MULTIPLE) !== false)
$this->valeur = explode(_SEPA_VALEUR_MULTIPLE, $valeur);
else $this->valeur = $valeur;
for ($i=0;$i<sizeof($this->options);$i++)
$this->options[$i]->selectionnerSiValeur($this->valeur);
}
else $this->valeur = $valeur;
}
function controlerChampTexte($pivot) {
global $erreur_message;
if (trim($this->valeur) == "") $this->erreur = $erreur_message["vide"];
else {
$this->erreur = champTexteConforme($this->valeur, $this->taille_min, $this->taille_max);
if (is_null($this->erreur) && $this->format) {
switch ($this->format) {
case "alphanum" :
if (!controlerAlphanum($this->valeur)) $this->erreur = $erreur_message["alphanum"];
break;
case "num" :
if (!controlerNum($this->valeur)) $this->erreur = $erreur_message["num"];
break;
case "num-strict" :
if (!controlerNum($this->valeur, true)) $this->erreur = $erreur_message["num"];
break;
case "tel" :
if (!controlerTel($this->valeur)) $this->erreur = $erreur_message["tel"];
break;
case "email" :
if (!controlerEmail($this->valeur)) $this->erreur = $erreur_message["email"];
break;
case "date" :
if (!controlerDate($this->valeur, $pivot)) $this->erreur = $erreur_message["date"];
$tmp=explode('/', $this->valeur);
if ($tmp[0]*1<10) $date_j='0'.$tmp[0]*1; else $date_j=''.$tmp[0]*1;
if ($date_j*1 < 1 || $date_j>31) $this->erreur = $erreur_message["datej"];
if ($tmp[1]*1<10) $date_m='0'.$tmp[1]*1; else $date_m=''.$tmp[1]*1;
if ($date_m*1 < 1 || $date_m>12) $this->erreur = $erreur_message["datem"];
$date_a=''.$tmp[2]*1;
if ($date_a*1 < 1890 || $date_a>date('Y')) $this->erreur = $erreur_message["datea"];
$this->valeur_db=$date_a.'-'.$date_m.'-'.$date_j;
break;
case "url" :
if (!controlerUrl($this->valeur)) $this->erreur = $erreur_message["url"];
break;
}
}
}
}
function afficherFormTexte() {
$html .= "<input class='form-input' type='text' name='$this->nom' size='$this->ctl_taille1' ";
if ($this->ctl_taille2) $html .= " maxlength='$this->ctl_taille2'";
if ($this->valeur) $html .= ' value="' . $this->valeur . '" />';
else if ($this->valeur_defaut) $html .= ' value="' . $this->valeur_defaut . '" />';
else if ($this->descro) { $html .= ' value="' . htmlentities(stripslashes($this->descro), ENT_QUOTES) . '"';
$html .= " onFocus='this.value=\"\"' />";
}
elseif ($this->ajaxQuey) $html .= " id='$this->nom' onkeyup=\"loadData('$this->nom');\" />
<ul id='zoneResultats_$this->nom' style='visibility: hidden;'></ul>";
else $html .= ' value="" />';
return $html;
}
function afficherFormPassword() {
$html .= "<input class='form-input' type='password' name='$this->nom' size='$this->ctl_taille1'";
if ($this->ctl_taille2) $html .= " maxlength='$this->ctl_taille2'";
if ($this->valeur) $html .= ' value="' . $this->valeur . '" />';
else if ($this->descro) {
$html .= ' value="' . htmlentities(stripslashes($this->descro), ENT_QUOTES) . '"';
$html .= " onFocus='this.value=\"\"' />";
}
else $html .= " value='' />";
return $html;
}
function afficherFormTextarea() {
$html .= "<textarea class='form-input' name='$this->nom' cols='$this->ctl_taille1'";
if ($this->ctl_taille2) $html .= " rows='$this->ctl_taille2'";
else if ($this->taille_max) {
$rows = ceil($this->taille_max / $taille_std);
$html .= " rows='$rows'";
}
else $html .= " rows='3'";
if ((trim($this->valeur) == "") || $this->descro) $html .= " onFocus='this.value=\"\"'>";
else $html .= ">";
if (trim($this->valeur)) $html .= $this->valeur;
else if ($this->descro) $html .= htmlentities(stripslashes($this->descro), ENT_QUOTES);
$html .= "</textarea>";
return $html;
}
function afficherFormSelect() {
$html = "<select name='$this->nom" . ($this->multiple ? "[]'" : "'");
if ($this->fin_ligne && $this->multiple)
$html .= " size='" . (($this->ctl_taille1 >= 2) ? $this->ctl_taille1 : 2 ) . "'";
else $html .= " size='" . ($this->ctl_taille1 ? $this->ctl_taille1 : 1) . "'";
$html .= $this->multiple ? " multiple>\n" : ">\n";
if ($this->fin_ligne) {
$html .= "<option class='form-option-entete' value=''>$this->fin_ligne</option>\n";
}
for ($i=0;$i<sizeof($this->options);$i++)
$html .= $this->options[$i]->afficherFormSelect();
$html .= "</select>\n";
return $html;
}
function afficherFormRadio() {
for ($i=0;$i<sizeof($this->options);$i++) {
$html .= $this->options[$i]->afficherFormCase("radio", $this->nom, $this->oblig);
$html .= $this->fin_ligne ? "<br />" : "&nbsp;";
}
return $html;
}
function afficherFormCheckbox() {
for ($i=0;$i<sizeof($this->options);$i++) {
$html .= $this->options[$i]->afficherFormCase("checkbox", "$this->nom[]", $this->oblig);
$html .= $this->fin_ligne ? "<br />" : "&nbsp;";
}
return $html;
}
function afficherFormFile() {
$html .= "<input class='form-input' type='file' name='$this->nom' size='$this->ctl_taille1'";
if ($this->taille_max) $html .= " maxlength='$this->ctl_taille2'";
if ($this->descro) $html .= " value='$this->descro' onChange='this.value=\"\"' />";
else $html .= " value='' />";
return $html;
}
}
class ClasseFormOption {
var $valeur;
var $selection;
function ClasseFormOption($val, $selec=false) {
$this->valeur = htmlspecialchars(stripslashes($val), ENT_QUOTES);
$this->selection = $selec;
}
function afficherFormSelect() {
echo "<!--Valeur du select='$this->valeur'-->";
if (strpos($this->valeur,':')>0) {
$tab=explode(':', $this->valeur);
$html = '<option value="'.$tab[0] .'"' . ($this->selection ? ' selected>' : '>');
$html .= $tab[1]."</option>\n";
}
else {
$html = '<option value="'. $this->valeur .'"' . ($this->selection ? ' selected>' : '>');
$html .= "$this->valeur</option>\n";
}
return $html;
}
function afficherFormCase($type, $nom, $oblig) {
$html = "<input type='$type' name='$nom' value=\"$this->valeur\"";
$html .= ($this->selection) ? " checked />" : " />";
if ($oblig) $html .= "<span class='form-input-obligatoire'>" . $this->valeur . "<span>";
else $html .= "<span class='form-input-facultatif'>" . $this->valeur . "<span>";
return $html;
}
function selectionnerSiValeur($valeurs) {
if (is_array($valeurs)) {
if (in_array($this->valeur, $valeurs)) $this->selection = true;
else $this->selection = false;
}
else if ($this->valeur == $valeurs) $this->selection = true;
else $this->selection = false;
}
}
function controlerEmail($valeur) {
if (preg_match("/^[\w|-]+(\.[\w|-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/", $valeur)) return true;
else return false;
}
function controlerDate($valeur, $pivot) {
if (preg_match("/^(\d{1,2})[\/|\-|\.](\d{1,2})[\/|\-|\.](\d\d)(\d\d)?$/", $valeur, $regs)) {
$jour = ($regs[1] < 10) ? "0".$regs[1] : $regs[1];
$mois = ($regs[2] < 10) ? "0".$regs[2] : $regs[2];
if ($regs[4]) $an = $regs[3] . $regs[4];
else {
if ($pivot) {
if ($regs[3] <= $pivot) $an = $regs[3] + 2000;
else $an = $regs[3] + 1900;
}
else $an = $regs[3] + 2000;
}
if (checkdate($mois, $jour, $an)) return true;
else return false;
}
else return false;
}
function controlerUrl($valeur) {
if (ereg("^((http|ftp):\/\/)?([0-9a-z_]+[\.\-])+[0-9a-z]+(\/[0-9a-z_]+)*(\/[0-9a-z_]+\.[0-9a-z]+)?$", $valeur)) return true;
else return false;
}
function controlerAlphanum($valeur) {
//if (preg_match("/^[\w|\d|\s|'|\"|\\|,|\.|\-|&|#|;]+$/", $valeur)) return true;
//else return false;
return true;
}
function controlerNum($valeur, $strict=false) {
if ($strict) {
if (ereg("^[0-9]+$", $valeur)) return true;
else return false;
}
else if (preg_match("/^[\d|\s|\-|\+|E|e|,|\.]+$/", $valeur)) return true;
else return false;
}
function controlerTel($valeur) {
if (preg_match("/^[\d|\s|\-|\.|\(|\)]+$/", $valeur)) return true;
else return false;
}
function champTexteConforme($valeur, $min, $max) {
global $erreur_message;
if ($min && (strlen($valeur) < $min)) return $min . " " . $erreur_message["min"];
else if ($max && (strlen($valeur) > $max)) return $max . " " . $erreur_message["max"];
else if (preg_match('/(.)\1{4,}/', $valeur)) return $erreur_message["texte"];
else return null;
}
function convertirPost($post) {
$result = array();
foreach ($post as $cle => $valeur) {
if (is_array($valeur)) {
for ($i=0;$i<sizeof($valeur);$i++)
$result[$cle][] = stripslashes($valeur[$i]);//htmlspecialchars(, ENT_QUOTES);
}
else $result[$cle] =stripslashes($valeur);// htmlspecialchars(stripslashes(), ENT_QUOTES);
}
return $result;
}
?>

View File

@ -0,0 +1,764 @@
<?php
/***********************************************************************************************************/
/* CLASSE D'AFFICHAGE ET D'ENVOI D'UN FORMULAIRE */
/* */
/* Auteur : Bernard Martin-Rabaud */
/* Email : bernard@ediweb.org */
/* */
/* Cette classe permet de : */
/* - créer un formulaire */
/* - le contrôler et l'afficher pour confirmation */
/* - et retourner son contenu */
/***********************************************************************************************************/
define("_SEPA_AFFICHE_MULTIPLE", ", ");
define("_SEPA_VALEUR_MULTIPLE", "###");
$erreur_message = array("min" => "caractères minimum",
"max" => "caractères maximum",
"texte" => "texte non valide",
"alphanum" => "texte alphanumérique non valide",
"num" => "valeur numérique non valide",
"num-strict" => "valeur numérique non valide",
"tel" => "numéro de téléphone non valide",
"email" => "e-mail non valide",
"url" => "url non valide",
"date" => "date non valide",
"option" => "aucune option n'a été sélectionnée",
"vide" => "champ obligatoire");
class ClasseForm {
var $titre;
var $montrer_titre;
var $champs;
var $taille_std;
var $pivot_siecle;
var $mode_retour;
var $confirme;
var $mode;
var $champ_cour;
var $log;
function ClasseForm($titre=null, $confirme=false) {
$this->titre = $titre;
$this->montrer_titre = true;
$this->champs = array();
$this->taille_std = null;
$this->pivot_siecle = 20;
$this->mode_retour = "noms & valeurs";
$this->confirme = $confirme;
$this->mode = null;
$this->champ_cour = 0;
$this->log = null;
}
function afficher() {
$resultat = null;
echo $this->javascriptSubmit();
if (!isset($_POST) || !$_POST || ($_POST["classeform_acces"] == "annuler")) $this->mode = null;
else {
$this->affecterValeursChamps($_POST);
$succes = $this->controler();
if ($succes) $this->mode = $_POST["classeform_acces"];
else $this->mode = "erreur";
}
switch ($this->mode) {
case "confirme" :
echo $this->afficherTexte();
echo $this->afficherForm(true);
break;
case "modif" :
echo $this->afficherForm();
break;
case "envoi" :
$resultat = $this->retournerTableauValeurs($this->mode_retour);
if ($this->log) $this->enregistrerLog($this->retournerTableauValeurs("valeurs", $resultat));
break;
default :
echo $this->afficherForm();
}
return $resultat;
}
function ajoutChamp($label, $nom, $type, $format=null, $oblig=true, $min=null, $max=null, $defVal='') {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, $type, $format, $oblig, $min, $max, $defVal);
}
function ajoutChampText($label, $nom, $format=null, $oblig=true, $min=null, $max=null, $defVal='') {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "text", $format, $oblig, $min, $max, $defVal);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 256);
}
function ajoutChampPassword($label, $nom, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "password", "", true, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 100);
}
function ajoutChampTextarea($label, $nom, $format=null, $oblig=true, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "textarea", $format, $oblig, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 3);
}
function ajoutChampFile($label, $nom, $oblig=true, $min=null, $max=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "file", "fichier", $oblig, $min, $max);
$this->champs[$this->champ_cour]->valCtlLimites($this->taille_std, 256);
}
function ajoutChampSelect($label, $nom, $oblig=true, $taille=null, $multiple=null) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "select", "", $oblig, null, null);
if ($taille) $this->champs[$this->champ_cour]->valCtlLimites($taille, null);
if ($multiple) $this->champs[$this->champ_cour]->valMultiple();
}
function ajoutChampRadio($label, $nom, $oblig=true, $fin_ligne=null) {
$this->champ_cour = sizeof($this->champs);
$args = func_get_args();
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "radio", "", $oblig);
if ($fin_ligne) $this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
if (sizeof($args) > 4) $this->champs[$this->champ_cour]->valOptions(array_slice($args, 4));
}
function ajoutChampCheckbox($label, $nom, $oblig=true, $fin_ligne=null) {
$this->champ_cour = sizeof($this->champs);
$args = func_get_args();
$this->champs[$this->champ_cour] = new ClasseFormChamp($label, $nom, "checkbox", "", $oblig);
if ($fin_ligne) $this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
if (sizeof($args) > 4) $this->champs[$this->champ_cour]->valOptions(array_slice($args, 4));
}
function ajoutTexte($texte) {
$this->champ_cour = sizeof($this->champs);
$this->champs[$this->champ_cour] = new ClasseFormChamp($texte, "", "", "", false);
}
function cacherTitre() {
$this->montrer_titre = false;
}
function valTailleStd($taille) {
$this->taille_std = $taille;
}
function valPivotSiecle($pivot) {
$this->pivot_siecle = $pivot;
}
function valModeRetour($mode) {
$this->mode_retour = $mode;
}
function valLog($log) {
$this->log = $log;
}
function valChampFormat($format, $min=null, $max=null) {
$this->champs[$this->champ_cour]->valFormat($format, $min, $max);
}
function valChampLimites($min, $max=null) {
$this->champs[$this->champ_cour]->valLimites($min, $max);
}
function valChampCtlLimites($min, $max=null) {
$this->champs[$this->champ_cour]->valCtlLimites($min, $max);
}
function valChampMultiple() {
$this->champs[$this->champ_cour]->valMultiple();
}
function valChampOptions() {
if ((func_num_args() == 1) && is_array(func_get_arg(0))) $args = func_get_arg(0);
else $args = func_get_args();
$this->champs[$this->champ_cour]->valOptions($args);
}
function valChampDescro($descro) {
$this->champs[$this->champ_cour]->valDescro($descro);
}
function valChampFinLigne($fin_ligne) {
$this->champs[$this->champ_cour]->valFinLigne($fin_ligne);
}
function valChampOption1Vide($option_vide) {
$this->champs[$this->champ_cour]->valOption1Vide($option_vide);
}
function afficherForm($cache=false) {
$html = "<form method='post' action='javascript:location.href'>\n";
$html .= "<table class='form-table' cellspacing='0' cellpadding='2' border='0'>\n";
if ($this->titre && $this->montrer_titre && !$cache)
$html .= "<caption class='form-caption'>$this->titre" . (($this->mode == "erreur") ? " <span class='erreur'>(erreurs)</span>" : "") . "</caption>\n";
else if (($this->mode == "erreur"))
$html .= "<caption class='form-caption'><span class='erreur'>(erreurs)</span></caption>\n";
for ($i=0;$i<sizeof($this->champs);$i++) {
if ($cache) $html .= $this->champs[$i]->afficherFormCache();
else $html .= $this->champs[$i]->afficherForm();
}
if ($valeurs) $html .= $this->afficherBoutonsForm();
else $html .= $this->afficherBoutonsForm();
if ($this->existeChampFacultatif())
$html .= "<tr><td class='form-info-obligatoire' colspan='2'>&nbsp;</td></tr>";
$html .= "</table></form>\n";
return $html;
}
function afficherBoutonsForm() {
if (($this->mode == null) || ($this->mode == "erreur")) {
if ($this->confirme)
$html = "<tr><td><input type='hidden' name='classeform_acces' value='confirme' /></td>";
else $html = "<tr><td><input type='hidden' name='classeform_acces' value='envoi' /></td>";
}
else $html = "<tr><td><input type='hidden' name='classeform_acces' /></td>";
$html .= "<td><input class='form-bouton' type='button' value='Envoyer' onClick='soumettre(\"envoi\")'/>";
if ($this->confirme) {
if ($this->mode == "confirme") {
$html .= " <input class='form-bouton' type='button' value='Modifier'";
$html .= " onClick='soumettre(\"modif\")'; />";
}
else {
$html .= " <input class='form-bouton' type='button' value='Voir avant envoi'";
$html .= " onClick='soumettre(\"confirme\")'; />";
}
}
$html .= " <input class='form-bouton' type='reset' value='Annuler' onClick='soumettre(\"annuler\")' /></td></tr>\n";
return $html;
}
function afficherTexte() {
$html = "<table class='form-table' cellspacing='0' cellpadding='2' border='0'>\n";
if ($this->titre) $html .= "<caption class='form-caption'>$this->titre</caption>\n";
for ($i=0;$i<sizeof($this->champs);$i++)
$html .= $this->champs[$i]->afficherTexte();
$html .= "</table>\n";
return $html;
}
function javascriptSubmit() {
$html = "<script language='JavaScript'>\n";
$html .= "<!-- \n";
$html .= "function soumettre(acces) { with (document.forms[0]) {";
$html .= "classeform_acces.value=acces; action=location.href; submit();";
$html .= "} }\n";
$html .= "// -->\n";
$html .= "</script>\n";
return $html;
}
function controler() {
$succes = true;
for ($i=0;$i<sizeof($this->champs);$i++) {
if ($this->champs[$i]->aControler() && ($this->champs[$i]->controler($this->pivot_siecle) == false)) {
$succes = false;
}
}
return $succes;
}
function affecterValeursChamps($valeurs) {
$valeurs = convertirPost($valeurs);
for ($i=0;$i<sizeof($this->champs);$i++)
$this->champs[$i]->affecterValeur($valeurs);
}
function retournerTableauValeurs($mode_retour) {
$retour = array();
for ($i=0;$i<sizeof($this->champs);$i++)
{ //echo "------------------------------------\r\n$i : \r\n";
//print_r($this->champs);
// print_r($this->champs[$i]);
//echo "\r\n\r\n";
$this->champs[$i]->retournerTableauValeurs(&$retour, $mode_retour);}
return $retour;
}
function envoyerMail() {
$mail = new ClasseMail($this->titre);
$mail->contenu = $this->champs;
return $mail->envoyer($this->cible);
}
function existeChampFacultatif() {
$ok = false;
for ($i=0;$i<sizeof($this->champs);$i++) {
if ($this->champs[$i]->type && !$this->champs[$i]->valObligatoire()) {
$ok = true;
break;
}
}
return $ok;
}
function enregistrerLog($valeurs, $resultat) {
if ($f = fopen($this->log, "a")) {
$texte = ($resultat ? "" : "ECHEC ") . "[ " . date("d/mY H:i:s") . " ] - ";
$texte .= $this->titre ? "$this->titre - " : "";
$texte .= $valeurs;
fputs($f, $texte);
fclose($f);
}
}
}
class ClasseFormChamp {
var $label;
var $nom;
var $type;
var $format;
var $oblig;
var $taille_max;
var $taille_min;
var $valeur;
var $options;
var $descro;
var $multiple;
var $fonction;
var $ctl_taille1;
var $ctl_taille2;
var $fin_ligne;
var $erreur;
var $valeur_defaut;
var $valeur_db;
function ClasseFormChamp($label, $nom, $type=null, $format=null, $oblig=true, $min=null, $max=null, $valDef='') {
$this->label = $label;
$this->nom = $nom;
$this->type = $type;
$this->format = $format;
$this->taille_min = $min;
$this->taille_max = $max;
$this->oblig = $oblig;
if (($type == "select") || ($type == "checkbox") || ($type == "radio")) {
$this->valeur = array();
$this->options = array();
}
else {
$this->valeur = null;
$this->options = null;
}
$this->descro = null;
if ($type == "checkbox") $this->multiple = true;
else $this->multiple = false;
$this->fonction = null;
$this->ctl_taille1 = null;
$this->ctl_taille2 = null;
$this->fin_ligne = null;
$this->erreur = null;
$this->valeur_defaut = $valDef;
}
function valObligatoire() {
if ($this->oblig) return true;
else return false;
}
function valFormat($format, $long_min=null, $long_max=null) {
if ($this->type == "text") {
$this->format = $format;
if ($long_min) $this->taille_min = $long_min;
if ($long_max) $this->taille_max = $long_max;
}
}
function valLimites($min, $max) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->taille_min = $min;
$this->taille_max = $max;
}
}
function valCtlLimites($taille1, $taille2) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "select") || ($this->type == "file")) {
$this->ctl_taille1 = $taille1;
if ($taille2 && ($this->type != "select")) $this->ctl_taille2 = $taille2;
}
}
function valFonction($fonction) {
$this->fonction = $fonction;
}
function valDescro($descro) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->descro = $descro;
}
}
function valMultiple() {
if ($this->type == "select") $this->multiple = true;
}
function valFinLigne($fin_ligne) {
if (($this->type == "radio") || ($this->type == "checkbox")) $this->fin_ligne = $fin_ligne;
}
function valOptions($options) {
if ($this->champAOptions()) {
if (is_array($options)) {
foreach ($options as $option) {
if (preg_match("/^s[e|é]lection\s?=\s?(.+)$/", $option, $regs))
$this->options[] = new ClasseFormOption($regs[1], true);
else $this->options[] = new ClasseFormOption($option);
}
}
else {
if (preg_match("/^s[e|é]lection\s?=\s?(.+)$/", $options, $regs))
$this->options[] = new ClasseFormOption($regs[1], true);
else $this->options[] = new ClasseFormOption($options);
}
}
}
function ValOption1Vide($option_vide) {
if ($this->type == "select") $this->fin_ligne = $option_vide;
}
function afficherForm() {
if (!$this->type) $html = "<tr><td class='form-label' colspan='2'>$this->label</td></tr>";
else {
if (!is_null($this->erreur))
$html = "<tr><td class='form-label-erreur'> > $this->label (<font size='-2'>$this->erreur</font>)</td>";
else if ($this->oblig) $html = "<tr><td class='form-label-obligatoire'>$this->label</td>";
else $html .= "<tr><td class='form-label-facultatif'>$this->label</td>";
$html .= "<td class='form-td'>";
switch ($this->type) {
case "text" : $html .= $this->afficherFormTexte();
break;
case "password" : $html .= $this->afficherFormPassword();
break;
case "textarea" : $html .= $this->afficherFormTextarea();
break;
case "select" : $html .= $this->afficherFormSelect();
break;
case "radio" : $html .= $this->afficherFormRadio();
break;
case "checkbox" : $html .= $this->afficherFormCheckbox();
break;
case "file" : $html .= $this->afficherFormFile();
}
$html .= "</td></tr>\n";
}
return $html;
}
function afficherFormCache() {
$html = "<input type='hidden' name='$this->nom'";
if (is_array($this->valeur)) {
$chaine = implode(_SEPA_VALEUR_MULTIPLE, $this->valeur);
$html .= " value='" . $chaine . "' />\n";
}
else $html .= " value='" . $this->valeur . "' />\n";
return $html;
}
function afficherTexte() {
$html = "<tr><td class='form-label'>$this->label</td><td class='form-td'>";
if (is_array($this->valeur)) {
$chaine = implode(_SEPA_AFFICHE_MULTIPLE, $this->valeur);
$html .= $chaine;
}
else $html .= $this->valeur;
$html .= "</td></tr>\n";
return $html;
}
function champAOptions() {
if (($this->type == "select") || ($this->type == "checkbox") || ($this->type == "radio")) return true;
else return false;
}
function controler($pivot=null) {
global $erreur_message;
$this->valeur_db=$this->valeur;
if ($this->type) {
if (($this->type == "text") || ($this->type == "password") || ($this->type == "textarea") || ($this->type == "file")) {
$this->controlerChampTexte($pivot);
if (is_null($this->erreur)) return true;
else return false;
}
else if (($this->type == "select") || ($this->type == "radio")) {
if (!$this->valeur || (sizeof($this->valeur) == 0)) {
$this->erreur = $erreur_message["option"];
return false;
}
else return true;
}
else return true;
}
else return true;
}
function aControler() {
if ($this->type && $this->oblig) return true;
else return false;
}
function retournerTableauValeurs(&$tableau, $mode_retour) {
if (is_array($this->valeur)) {$valeur = implode(_SEPA_VALEUR_MULTIPLE, $this->valeur);
print_r($this->valeur);
die('Cas non géré dans inc_classeform.php');
}
else $valeur = $this->valeur_db;
switch ($mode_retour) {
case "noms & valeurs" :
$tableau[$this->nom] = $valeur;
break;
case "labels & valeurs" :
$tableau[$this->label] = $valeur;
break;
case "valeurs" :
$tableau[] = $valeur;
}
}
function affecterValeur($valeurs) {
$valeur = $valeurs[$this->nom];
if ($this->champAOptions()) {
if (strpos($valeur, _SEPA_VALEUR_MULTIPLE) !== false)
$this->valeur = explode(_SEPA_VALEUR_MULTIPLE, $valeur);
else $this->valeur = $valeur;
for ($i=0;$i<sizeof($this->options);$i++)
$this->options[$i]->selectionnerSiValeur($this->valeur);
}
else $this->valeur = $valeur;
}
function controlerChampTexte($pivot) {
global $erreur_message;
if (trim($this->valeur) == "") $this->erreur = $erreur_message["vide"];
else {
$this->erreur = champTexteConforme($this->valeur, $this->taille_min, $this->taille_max);
if (is_null($this->erreur) && $this->format) {
switch ($this->format) {
case "alphanum" :
if (!controlerAlphanum($this->valeur)) $this->erreur = $erreur_message["alphanum"];
break;
case "num" :
if (!controlerNum($this->valeur)) $this->erreur = $erreur_message["num"];
break;
case "num-strict" :
if (!controlerNum($this->valeur, true)) $this->erreur = $erreur_message["num"];
break;
case "tel" :
if (!controlerTel($this->valeur)) $this->erreur = $erreur_message["tel"];
break;
case "email" :
if (!controlerEmail($this->valeur)) $this->erreur = $erreur_message["email"];
break;
case "date" :
if (!controlerDate($this->valeur, $pivot)) $this->erreur = $erreur_message["date"];
else $this->valeur_db=substr($this->valeur,6,4).'-'.substr($this->valeur,3,2).'-'.substr($this->valeur,0,2);
break;
case "url" :
if (!controlerUrl($this->valeur)) $this->erreur = $erreur_message["url"];
break;
}
}
}
}
function afficherFormTexte() {
$html .= "<input class='form-input' type='text' name='$this->nom' size='$this->ctl_taille1' ";
if ($this->ctl_taille2) $html .= " maxlength='$this->ctl_taille2'";
if ($this->valeur) $html .= " value='" . $this->valeur . "' />";
else if ($this->valeur_defaut) $html .= " value='" . $this->valeur_defaut . "' />";
else if ($this->descro) { $html .= " value='" . htmlentities(stripslashes($this->descro), ENT_QUOTES) . "'";
$html .= " onFocus='this.value=\"\"' />";
}
else $html .= " value='' />";
return $html;
}
function afficherFormPassword() {
$html .= "<input class='form-input' type='password' name='$this->nom' size='$this->ctl_taille1'";
if ($this->ctl_taille2) $html .= " maxlength='$this->ctl_taille2'";
if ($this->valeur) $html .= " value='" . $this->valeur . "' />";
else if ($this->descro) {
$html .= " value='" . htmlentities(stripslashes($this->descro), ENT_QUOTES) . "'";
$html .= " onFocus='this.value=\"\"' />";
}
else $html .= " value='' />";
return $html;
}
function afficherFormTextarea() {
$html .= "<textarea class='form-input' name='$this->nom' cols='$this->ctl_taille1'";
if ($this->ctl_taille2) $html .= " rows='$this->ctl_taille2'";
else if ($this->taille_max) {
$rows = ceil($this->taille_max / $taille_std);
$html .= " rows='$rows'";
}
else $html .= " rows='3'";
if ((trim($this->valeur) == "") || $this->descro) $html .= " onFocus='this.value=\"\"'>";
else $html .= ">";
if (trim($this->valeur)) $html .= $this->valeur;
else if ($this->descro) $html .= htmlentities(stripslashes($this->descro), ENT_QUOTES);
$html .= "</textarea>";
return $html;
}
function afficherFormSelect() {
$html = "<select name='$this->nom" . ($this->multiple ? "[]'" : "'");
if ($this->fin_ligne && $this->multiple)
$html .= " size='" . (($this->ctl_taille1 >= 2) ? $this->ctl_taille1 : 2 ) . "'";
else $html .= " size='" . ($this->ctl_taille1 ? $this->ctl_taille1 : 1) . "'";
$html .= $this->multiple ? " multiple>\n" : ">\n";
if ($this->fin_ligne) {
$html .= "<option class='form-option-entete' value=''>$this->fin_ligne</option>\n";
}
for ($i=0;$i<sizeof($this->options);$i++)
$html .= $this->options[$i]->afficherFormSelect();
$html .= "</select>\n";
return $html;
}
function afficherFormRadio() {
for ($i=0;$i<sizeof($this->options);$i++) {
$html .= $this->options[$i]->afficherFormCase("radio", $this->nom, $this->oblig);
$html .= $this->fin_ligne ? "<br />" : "&nbsp;";
}
return $html;
}
function afficherFormCheckbox() {
for ($i=0;$i<sizeof($this->options);$i++) {
$html .= $this->options[$i]->afficherFormCase("checkbox", "$this->nom[]", $this->oblig);
$html .= $this->fin_ligne ? "<br />" : "&nbsp;";
}
return $html;
}
function afficherFormFile() {
$html .= "<input class='form-input' type='file' name='$this->nom' size='$this->ctl_taille1'";
if ($this->taille_max) $html .= " maxlength='$this->ctl_taille2'";
if ($this->descro) $html .= " value='$this->descro' onChange='this.value=\"\"' />";
else $html .= " value='' />";
return $html;
}
}
class ClasseFormOption {
var $valeur;
var $selection;
function ClasseFormOption($val, $selec=false) {
$this->valeur = htmlspecialchars(stripslashes($val), ENT_QUOTES);
$this->selection = $selec;
}
function afficherFormSelect() {
$html = "<option value='$this->valeur'" . ($this->selection ? " selected>" : ">");
$html .= "$this->valeur</option>\n";
return $html;
}
function afficherFormCase($type, $nom, $oblig) {
$html = "<input type='$type' name='$nom' value='$this->valeur'";
$html .= ($this->selection) ? " checked />" : " />";
if ($oblig) $html .= "<span class='form-input-obligatoire'>" . $this->valeur . "<span>";
else $html .= "<span class='form-input-facultatif'>" . $this->valeur . "<span>";
return $html;
}
function selectionnerSiValeur($valeurs) {
if (is_array($valeurs)) {
if (in_array($this->valeur, $valeurs)) $this->selection = true;
else $this->selection = false;
}
else if ($this->valeur == $valeurs) $this->selection = true;
else $this->selection = false;
}
}
function controlerEmail($valeur) {
if (preg_match("/^[\w|-]+(\.[\w|-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/", $valeur)) return true;
else return false;
}
function controlerDate($valeur, $pivot) {
if (preg_match("/^(\d{1,2})[\/|\-|\.](\d{1,2})[\/|\-|\.](\d\d)(\d\d)?$/", $valeur, $regs)) {
$jour = ($regs[1] < 10) ? "0".$regs[1] : $regs[1];
$mois = ($regs[2] < 10) ? "0".$regs[2] : $regs[2];
if ($regs[4]) $an = $regs[3] . $regs[4];
else {
if ($pivot) {
if ($regs[3] <= $pivot) $an = $regs[3] + 2000;
else $an = $regs[3] + 1900;
}
else $an = $regs[3] + 2000;
}
if (checkdate($mois, $jour, $an)) return true;
else return false;
}
else return false;
}
function controlerUrl($valeur) {
if (ereg("^((http|ftp):\/\/)?([0-9a-z_]+[\.\-])+[0-9a-z]+(\/[0-9a-z_]+)*(\/[0-9a-z_]+\.[0-9a-z]+)?$", $valeur)) return true;
else return false;
}
function controlerAlphanum($valeur) {
if (preg_match("/^[\w|\d|\s|'|\"|\\|,|\.|\-|&|#|;]+$/", $valeur)) return true;
else return false;
}
function controlerNum($valeur, $strict=false) {
if ($strict) {
if (ereg("^[0-9]+$", $valeur)) return true;
else return false;
}
else if (preg_match("/^[\d|\s|\-|\+|E|e|,|\.]+$/", $valeur)) return true;
else return false;
}
function controlerTel($valeur) {
if (preg_match("/^[\d|\s|\-|\.|\(|\)]+$/", $valeur)) return true;
else return false;
}
function champTexteConforme($valeur, $min, $max) {
global $erreur_message;
if ($min && (strlen($valeur) < $min)) return $min . " " . $erreur_message["min"];
else if ($max && (strlen($valeur) > $max)) return $max . " " . $erreur_message["max"];
else if (preg_match('/(.)\1{4,}/', $valeur)) return $erreur_message["texte"];
else return null;
}
function convertirPost($post) {
$result = array();
foreach ($post as $cle => $valeur) {
if (is_array($valeur)) {
for ($i=0;$i<sizeof($valeur);$i++)
$result[$cle][] = htmlspecialchars(stripslashes($valeur[$i]), ENT_QUOTES);
}
else $result[$cle] = htmlspecialchars(stripslashes($valeur), ENT_QUOTES);
}
return $result;
}
?>

View File

@ -0,0 +1,302 @@
<?php
class ICotation {
var $reTrtAuto;
var $tabBilan;
var $tabNotation;
var $tabLibActivite;
var $tabActivite;
var $tabR;
function ICotation ($tabBilan, $retraitementAutomatique=true) {
$this->reTrtAuto = $retraitementAutomatique;
$this->tabBilan = $tabBilan;
include ('paramCotation.inc');
}
function calculProvisionsPourRisque () {
if ( !$this->reTrtAuto )
return $this->tabBilan['DP'] + $this->tabBilan['DQ'] - $this->tabBilan['X04'];
else
return (1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']);
}
function calculEBE () {
return $this->tabBilan['FC'] + $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FOB']
+ $this->tabBilan['FM'] + $this->tabBilan['FN'] - $this->tabBilan['FC'] + $this->tabBilan['FC']
- ( $this->tabBilan['FS'] + $this->tabBilan['FT'] + $this->tabBilan['FU'] + $this->tabBilan['FV'] )
- ( $this->tabBilan['FW'] - $this->tabBilan['HP'] - $this->tabBilan['HQ'] - $this->tabBilan['HP2'] - $this->tabBilan['HQ2'] )
- $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) + ( $this->tabBilan['FO'] - $this->tabBilan['FOB'] ) ;
}
function calculChiffreAffaires () {
return $this->tabBilan['FC']
+ $this->tabBilan['FF']
+ $this->tabBilan['FI']
+ $this->tabBilan['FO']
- $this->tabBilan['FOB'] ;
}
function calculMargeCommerciale () {
return $this->tabBilan['FC'] - ( $this->tabBilan['FS'] + $this->tabBilan['FT'] ) ;
}
function calculProduction () {
return $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FM'] + $this->tabBilan['FN'] ;
}
function calculValeurAjoutee () {
return $this->calculMargeCommerciale() + $this->calculProduction()
- ( $this->tabBilan['FU'] + $this->tabBilan['FV'] + $this->tabBilan['FW'] ) ;
}
function calculEBEnonCASA () {
return $this->calculValeurAjoutee() + $this->tabBilan['FO'] - $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) ;
}
function calculFondsPropresNetsCorriges() {
return $this->tabBilan['DA'] + $this->tabBilan['DC'] + $this->tabBilan['DB'] + $this->tabBilan['DD'] + $this->tabBilan['DE'] + $this->tabBilan['DF'] + $this->tabBilan['DG'] + $this->tabBilan['DK'] - (1/3*$this->tabBilan['X01'])
+ $this->tabBilan['DH'] + $this->tabBilan['DI'] + $this->tabBilan['DJ']
- $this->tabBilan['CL'] - $this->tabBilan['AB'] + $this->tabBilan['AC'] - $this->tabBilan['AA'] - $this->tabBilan['CB'] + $this->tabBilan['CC'] - $this->tabBilan['X02'] - $this->tabBilan['CM'] - $this->tabBilan['CN']
+ $this->tabBilan['DM'] + $this->tabBilan['DN']
- $this->tabBilan['X03'] + $this->calculProvisionsPourRisque() - $this->tabBilan['RAD'] ;
}
function calculDettesFinancieresBancairesBrutes () {
return $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2']
+ $this->tabBilan['DT'] - $this->tabBilan['CM3'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
+ (3/4*$this->tabBilan['YQ']) + (2/3*$this->tabBilan['YR'])
+ (3/4*$this->tabBilan['YQ2']) + (2/3*$this->tabBilan['YR2'])
+ $this->tabBilan['DV'] - $this->tabBilan['EI'] - $this->tabBilan['DVI1'] - $this->tabBilan['CM2']
+ $this->tabBilan['YS'] + $this->tabBilan['X08']
+ $this->tabBilan['EH'] + $this->tabBilan['VI1'] - ( $this->tabBilan['X20'] + $this->tabBilan['X21'] ) ;
}
function noteCapitalisation () {
if ( !$this->reTrtAuto ) {
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + $this->tabBilan['X04'] ;
$dettesFiscalesSociales = $this->tabBilan['DY'] - $this->tabBilan['DYA'];
} else {
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + 2/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']));
$dettesFiscalesSociales = $this->tabBilan['DY'] + 1/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ'])) - $this->tabBilan['DYA'] ;
}
$numerateur = $this->calculFondsPropresNetsCorriges();
$denominateur = $numerateur + $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
+ $this->tabBilan['DV'] - $this->tabBilan['DVI1'] - $this->tabBilan['EI'] + $this->tabBilan['DT'] - $this->tabBilan['CM3'] + 3/4*$this->tabBilan['YQ'] + 2/3*$this->tabBilan['YR']
+ 3/4*$this->tabBilan['YQ2'] + 2/3*$this->tabBilan['YR2']
+ $this->tabBilan['DW'] + $this->tabBilan['DX'] + $dettesFiscalesSociales
+ $autresDettesExploit + $this->tabBilan['DZ'] + $this->tabBilan['DIA'] + $this->tabBilan['ED'] + $this->tabBilan['EAB'] + $this->tabBilan['DYA']
+ $this->tabBilan['EH'] + $this->tabBilan['YS'] + $this->tabBilan['VI1'];
// + $this->tabBilan['X08']
// - $this->tabBilan['X20'] + $this->tabBilan['YS'] - $this->tabBilan['X08'];
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur* 100,'DENOMINATEUR'=>$denominateur,'NOTE'=>($numerateur* 100)/$denominateur);
}
function noteLevierEndettement () {
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
$denominateur = $this->calculFondsPropresNetsCorriges();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteCapaciteRemboursement () {
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
$denominateur = $this->calculEBE();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteCouvChargesFi () {
$numerateur = $this->calculEBE();
$denominateur = $this->tabBilan['GR'] + ( 1/4*$this->tabBilan['HP'] + 1/3*$this->tabBilan['HQ'] )
+ ( 1/4*$this->tabBilan['HP2'] + 1/3*$this->tabBilan['HQ2'] )
+ $this->tabBilan['GS']
+ $this->tabBilan['GT']
- $this->tabBilan['GJ']
- $this->tabBilan['GK']
- $this->tabBilan['GL']
- $this->tabBilan['GN']
- $this->tabBilan['GO']
- $this->tabBilan['GH']
+ $this->tabBilan['GI'] ;
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteTresorerie () {
$numerateur = $this->tabBilan['CD'] - $this->tabBilan['CE'] + $this->tabBilan['CF'] - $this->tabBilan['CG']
- $this->tabBilan['EH'] - ( $this->tabBilan['YS'] + $this->tabBilan['X08'] ) ;
$denominateur = $this->calculChiffreAffaires();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*360/$denominateur);
}
function noteMargeExploitation () {
$numerateur = $this->calculEBE();
$denominateur = $this->calculChiffreAffaires();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*100/$denominateur);
}
function getSecteurActivite($naf) {
$nbSecteurs=count($this->tabActivite);
while (strlen($naf) > 1)
{
for ($i=1; $i<$nbSecteurs; $i++)
{
for ($j=0; isset($this->tabActivite[$i][$j]); $j++)
{
if ($this->tabActivite[$i][$j]==$naf)
// echo 'NAF '.$naf.' TROUVÉ !<br>';
return $i;
}
}
// echo 'NAF '.$naf.' non trouvé !<br>';
$naf=substr($naf,0,strlen($naf)-1);
}
return 17; // Secteur d'activité par défaut si non trouvé
}
function getBorne($note, $borne, $secteur) {
// print_array($this->tabR[$borne][$secteur],0);
for ($j=0; $j<10; $j++)
{
$tabMinMax=explode(':',$this->tabR[$borne][$secteur][$j]);
if ($tabMinMax[0]!='') $min=$tabMinMax[0];
else $min=-1E99;
if ($tabMinMax[1]!='') $max=$tabMinMax[1];
else $max=1E99;
if ( ( $note>$min && $note<=$max ) )
{
// echo "TROUVE ++++ $note > ".$tabMinMax[0]." et $note <= ". $tabMinMax[1].'<br/>';
if ($j==0) return 3;
elseif ($j<4) return $j+4;
else return $j*2+1;
}
// echo "NOK $note < ".$tabMinMax[0]." ou $note > ". $tabMinMax[1].'<br/>';
}
return 3; // On retourne la plus basse note par défaut
}
function getNoteBorne($note, $borne, $secteur, $numerateur, $denominateur) {
$noteBorneBrute=$this->getBorne($note, $borne, $secteur);
switch($borne)
{
case 1:
if ($numerateur<0) return 3;
else return $noteBorneBrute;
break;
case 2:
if ($numerateur==0) return 19;
else return $noteBorneBrute;
break;
case 3:
if ($numerateur==0 && $denominateur>0) return 19;
elseif ($denominateur<0) return 3;
else return $noteBorneBrute;
break;
case 4:
if ($note<0) return 19;
else return $noteBorneBrute;
break;
default:
return $noteBorneBrute;
break;
}
}
function getNotationFin ($coteMoy) {
if( $coteMoy > 18.5 )
return 'A';
elseif( $coteMoy > 16 )
return 'B+';
elseif( $coteMoy > 14 )
return 'B';
elseif( $coteMoy > 12.5 )
return 'C+';
elseif( $coteMoy > 11 )
return 'C';
elseif( $coteMoy > 10 )
return 'C-';
elseif( $coteMoy > 9 )
return 'D+';
elseif( $coteMoy > 8 )
return 'D';
elseif( $coteMoy > 7 )
return 'D-';
elseif( $coteMoy > 6 )
return 'E+';
elseif( $coteMoy > 4.5 )
return 'E';
elseif( $coteMoy > 3 )
return 'E-';
else
return 'E--';
}
function getInfosNotation ($notation, $csv=false) {
if ($csv) {
$str =$this->tabNotation[$notation][1].';'.
$this->tabNotation[$notation][2].';'.
$this->tabNotation[$notation][3].';'.
$this->tabNotation[$notation][4].';';
return $str;
} else {
$str ='Notation : '. $this->tabNotation[$notation][0]."\r\n";
$str.='Equivalence BDF : '. $this->tabNotation[$notation][1]."\r\n";
$str.='Grades Moody\'s : '. $this->tabNotation[$notation][2]."\r\n";
$str.='Grades S&P : '. $this->tabNotation[$notation][3]."\r\n";
$str.='Probabilité de défaillance : '. $this->tabNotation[$notation][4]." %\r\n";
return $str;
}
}
}

View File

@ -0,0 +1,418 @@
<?
/** 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='') {
$ch = curl_init();
if ($host=='')
$this_header = array('Host: '. HOST_INSEE);
else
$this_header = array('Host: '. $host);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
//curl_setopt($ch, CURLOPT_PROXY, '10.142.10.254:80');
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
$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_HTTPHEADER, $this_header);
//print_r($this_header);
$page=curl_exec($ch);
$response = parse_response($page);
if ($debug){
$url2=str_replace('http://', '', $url);
$url2=str_replace('/', '_', $url2);
$url2=str_replace('?', '(param)', $url2);
$url2=str_replace('&', '(et)', $url2);
$fp=fopen('/var/www/_includes/partenaires/insee/'. 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;
}
/**Verification de la validité des données pour la demande*/
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;
}
/** Test de la validité du siren demandé */
function valideSiren($siren, $nic='', $erreur=false) {
$lenSIREN=strlen($siren);
if (!valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
return $erreur;
else
{
if (!isset($nic) || trim($nic)=='')
{
$somme=0;
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
$somme+=(integer)substr($siren,$i,1);
for ($i=1; $i<=7; $i+=2)
{ // Traitement PAIR
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
$som_tmp=0;
for($j=0;$j<strlen($var_tmp);$j++)
$som_tmp+=(integer)substr($var_tmp,$j,1);
$somme+=$som_tmp;
}
if ((integer)($somme/10)!=($somme/10))
{ // Le Siren est faux
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
return $erreur;
}
} else {
if (!valideData($nic,1,5,'N')) // Nic de format incorrect.
return $erreur;
$SIRET=$siren.$nic;
$somme=0;
for ($i=0; $i<=12; $i+=2)
{ // Traitement PAIR
$var_tmp=(string)(2*((integer)substr($SIRET,$i,1)));
$som_tmp=0;
for($j=0;$j<strlen($var_tmp);$j++)
$som_tmp+=(integer)substr($var_tmp,$j,1);
$somme+=$som_tmp;
}
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
$somme+=(integer)substr($SIRET,$i,1);
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
return $erreur;
}
}
return true;
}
function rechercheTelephone($raisonSociale='', $adresse='', $localite='', $departement='', $activite='') {
$response1=getUrl(SITE_PJ.'pj.cgi?', '', '', '', true, HOST_PJ);
//print_r($response1['header']['Set-cookie']);
$pageHtml=$response1['body'];
$SESSION_ID=getTextInHtml($pageHtml, '<input type="hidden" name="SESSION_ID" value="', ' value="', '">');
$VID=getTextInHtml($pageHtml, '<input type="hidden" name="VID" value="', ' value="', '">');
$e_cookie=getTextInHtml($pageHtml, '<noscript><img ALT="" src="http://e.pagesjaunes.fr/m/web/', 'src="', '" BORDER=0 width=1 height=1></noscript>');
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji_PJ.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_open.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/alerte.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'sitecrm/popup.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.swf?clickTAG=http://sbx.pagesjaunes.fr/RealMedia/ads/click_lx.ads/www.pagesjaunes.fr/GENERAL/GENERAL/PJ/1238513556/Top/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.html/61633130323433353434346339306330?', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/anim_HP_v2-04-2006.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_webcam.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_photo.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_trafic.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/Edito_webcams/new_04-2006.jpg', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response=getUrl('http://e.pagesjaunes.fr/js/m.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
$response2=getUrl($e_cookie, $response1['header']['Set-cookie'], '', SITE_PJ, true, HOST_PJ);
$cookies=$response1['header']['Set-cookie'] . $response2['header']['Set-Cookie'];
$input_image=$VALID_ARR=$NUM_RUE=$NEW_DEPARTEMENT=$OBJ_GEO='';
// Requête d'interrogation
$postData=array(
'ACTIVITE_VALIDATED_ASCII'=>'',
'ID_THEME_SDE'=>'',
'LISTE_RUB_AVEC_THEME'=>'',
'input_image'=>$input_image,
'FRM_ACTIVITE'=>$activite,
'FRM_NOM'=>$raisonSociale,
'FRM_ADRESSE'=>$adresse,
'FRM_LOCALITE'=>$localite,
'FRM_DEPARTEMENT'=>$departement,
'JF_INSCRIPTIONS_REQ.x'=>'25',
'JF_INSCRIPTIONS_REQ.y'=>'4',
'faire'=>'decode_input_image',
'DEFAULT_ACTION'=>'jf_inscriptions_req',
'SESSION_ID'=>$SESSION_ID,
'VID'=>$VID,
'INFO_VILLE'=>'non',
'CODE_LOC_INFO_VILLE'=>'00000000',
'IV_ACTIVATION'=>'oui',
'lang'=>'FR',
'pays'=>'FR',
'srv'=>'PJ',
'TYPE_RECHERCHE'=>'ZZZ');
//print_r($postData);//die();
sleep(1);
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
$pageHtml=$response['body'];
if (count($tabNT=getTabListeNonTrouve($pageHtml))>0)
{
// Pas de réponses pour ces critères
// Il faut élargir la recherche !
$tabNTk=array_keys($tabNT);
$input_image=$tabNT[0];
$DEFAULT_ACTION='inscriptions_req';
$NEW_DEPARTEMENT=getTextInHtml($pageHtml, '<input type="hidden" name="NEW_DEPARTEMENT" value="', 'value="', '">');
$OBJ_GEO=getTextInHtml($pageHtml, '<input type=hidden name=OBJ_GEO value="', 'value="', '">');
}
elseif (count($tabGU=getTabListeGU($pageHtml))>0)
{
// Plusieurs Adresses possibles pour l'adresse donnée
// print_r($tabGU);
$input_image=getBonneAdresse($adresse, $tabGU);
$DEFAULT_ACTION='jf_inscriptions_req';
$VALID_ARR=getTextInHtml($pageHtml, '<input type=hidden name=VALID_ARR value="', 'value="', '">');
$NUM_RUE=getTextInHtml($pageHtml, '<input type=hidden name=NUM_RUE value="', 'value="', '">');
}
if ($input_image<>'') {
$CODE_LOC_INFO_VILLE=getTextInHtml($pageHtml, '<input type="hidden" name="CODE_LOC_INFO_VILLE" value="', 'value="', '">');
$postData=array(
'GEO_DEP'=>'', // New
'faire'=>'decode_input_image',
'DEFAULT_ACTION'=>$DEFAULT_ACTION,
'input_image'=>$input_image,// diff
'SESSION_ID'=>$SESSION_ID,
'VID'=>$VID,
'INFO_VILLE'=>'oui', // non dans la recherche préc.
'CODE_LOC_INFO_VILLE'=>$CODE_LOC_INFO_VILLE, // diff
'IV_ACTIVATION'=>'oui',
'lang'=>'FR',
'pays'=>'FR',
'srv'=>'PJ',
'TYPE_RECHERCHE'=>'CLOC', // ZZZ
'SAV_ADRESSE'=>$adresse, //
'SAV_LOCALITE'=>$localite, // New
'SAV_DEPARTEMENT'=>$departement, //
'FRM_NOM'=>$raisonSociale,
'FRM_ADRESSE'=>$adresse,
'FRM_LOCALITE'=>$localite,
'FRM_DEPARTEMENT'=>$departement,
'FRM_TYPE_PUB'=>'TOUS',
'RP_FORM'=>'',
'VALID_LOC'=>$CODE_LOC_INFO_VILLE,
'VALID_ARR'=>$VALID_ARR,
'NUM_RUE'=>$NUM_RUE,
'test_flash'=>'',
'ESPLUS'=>'',
'NEW_DEPARTEMENT'=>$NEW_DEPARTEMENT,
'OBJ_GEO'=>$OBJ_GEO,
);
print_r($postData);
sleep(1);
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
$pageHtml=$response['body'];
}
$nbReponses=trim(getTextInHtml($pageHtml, '<tr><td align="left" class=txtrequetetotal valign=middle nowrap><b>', '<b>', 'r&eacute;ponse(s)</b></td>'));
$tabRep=getTabResponses($pageHtml);
if (count($tabRep)==$nbReponses)
return $tabRep;
else
return false;
}
function getTabResponses($pageHtml) {
$tabRepTmp=explode ('class=fdinscr', $pageHtml);
$tabRep=array();
foreach($tabRepTmp as $key => $value)
{
if ($key>0) {
$raisonSociale=getTextInHtml($value, 'class=fdrsinscr', '<b>', '</b>');
$ligneAdresse=html_entity_decode(getTextInHtml($value, '<td align="left" class=txtinscr ><b>', '<b>', '|'));
$tabligneAdresse=explode('<br>', $ligneAdresse);
$ligneAdresse1=strip_tags($tabligneAdresse[0]);
$ligneAdresse2=strip_tags($tabligneAdresse[1]);
$dispoPlan =(bool)(strpos($value, '<b>Plan</b>'));
$dispoIti =(bool)(strpos($value, '<b>Itin&eacute;raire</b>'));
$dispoPhoto =(bool)(strpos($value, '<b>Photo</b>'));
$dispoWeb =(bool)(strpos($value, '<b>Site</b></a>&nbsp;&nbsp;&nbsp;'));
$lienWeb=getTextInHtml($value, '<a target="_blank" href="http://www.pagesjaunes.fr/CGI/MOD?', 'href="', '" ');
$page=getUrl($lienWeb, '', '', '', true);
$lienWeb=$page['header']['Location'];
/*echo "Enreg n°$key : RS='$raisonSociale'\r\n";
echo "Enreg n°$key : Adresse1='$ligneAdresse1'\r\n";
echo "Enreg n°$key : Adresse2='$ligneAdresse2'\r\n";
echo "Enreg n°$key : Plan ?='$dispoPlan'\r\n";
echo "Enreg n°$key : Itineraire ?='$dispoIti'\r\n";
echo "Enreg n°$key : Photo ?='$dispoPhoto'\r\n";
echo "Enreg n°$key : Web ?='$dispoWeb'\r\n";
echo "Enreg n°$key : Site WEB='$lienWeb'\r\n\r\n";*/
array_push($tabRep, array( 'raisonSociale' =>$raisonSociale,
'AdresseLigne1' =>$ligneAdresse1,
'AdresseLigne2' =>$ligneAdresse2,
'Dispo_Plan' =>$dispoPlan,
'Dispo_Iti' =>$dispoIti,
'Dispo_Photo' =>$dispoPhoto,
'Dispo_Web' =>$dispoWeb,
'LienWeb' =>$lienWeb));
}
}
return $tabRep;
}
function getBonneAdresse($adresse, $tabGU) {
// tableau de mots à vérifier
$words = array_keys($tabGU);
// aucune distance de trouvée pour le moment
$shortest = -1;
// boucle sur les des mots pour trouver le plus près
foreach ($words as $word) {
// calcule la distance avec le mot mis en entrée,
// et le mot courant
$lev = levenshtein($adresse, $word);
// cherche une correspondance exacte
if ($lev == 0) {
// le mot le plus près est celui-ci (correspondance exacte)
$closest = $word;
$shortest = 0;
// on sort de la boucle ; nous avons trouvé une correspondance exacte
break;
}
// Si la distance est plus petite que la prochaine distance trouvée
// OU, si le prochain mot le plus près n'a pas encore été trouvé
if ($lev <= $shortest || $shortest < 0) {
// définission du mot le plus près ainsi que la distance
$closest = $word;
$shortest = $lev;
}
}
/*
echo "Mot entré : $adresse\n";
if ($shortest == 0) {
echo "Correspondance exacte trouvée : $closest\n";
} else {
echo "Vous voulez dire : $closest ?\n";
}*/
return $tabGU[$closest];
}
?>

View File

@ -0,0 +1,548 @@
<?
class Insee {
}
function getDataEtablissement($pageHtml)
{
global $libelleErreur;
$responseSiege=$pageHtml;
$tabRet=array();
// On recherche si on est sur un établissement siège ou secondaire
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
if ($pos>0)
$tabRet['typeEtablissement']='secondaire';
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
if ($pos>0)
$tabRet['typeEtablissement']='siège';
// Recherche Dernière MAJ / Activité
$pos=strpos($responseSiege, '<font face="Arial" size="2">(dernière mise à jour :');
if ($pos>0) {
$tabRet['dateMAJ']=substr($responseSiege, $pos+51, 10);
$tabRet['dateAbsActivite']='';
$tabRet['active']='O';
} else {
$tabRet['active']='N';
$tabRet['dateMAJ']='';
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence&nbsp;d\'activité notée&nbsp;le&nbsp;:&nbsp;');
if ($pos>0) $tabRet['dateAbsActivite']=substr($responseSiege, $pos+78, 10);
else {
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence&nbsp;d\'activité');
if ($pos>0) $tabRet['dateAbsActivite']='';
}
}
$pos=strpos($responseSiege, ' size="-1"> <B>n°&nbsp;SIRET&nbsp;:</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
$tabRet['siret']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+97, 32)));
$pos=strpos($responseSiege, 'size="-1"> <B>Date&nbsp;de&nbsp;création&nbsp;:</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
if ($pos>0) {
$posFin=strpos($responseSiege, '</font>', $pos+109);
$tabRet['dateCreation']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+109, $posFin-($pos+109))));
}
else $tabRet['dateCreation']='';
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$len=127;
if ($pos==0){
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$len=122;
if ($pos==0){
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$len=126;
$libelleErreur='Informations INSEE non diffusables';
}
}
if ($libelleErreur=='') {
//LARGE*DOMINIQUE MICHEL/ <BR>GERANT SARL BIMAGIQUE &nbsp;</font>
$posFin=strpos($responseSiege, '</font>', $pos+$len);
$raisonSocialeStr=trim(substr($responseSiege, $pos+$len, $posFin-($pos+$len)));
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
$tabRet['raisonSociale']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
$tabRet['Enseigne']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
$pos=strpos($responseSiege, ' size="-1"> <B>Activité&nbsp;principale&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$tabRet['NafCode']=substr($responseSiege, $pos+120, 4);
$tabRet['NafLib']=trim(substr($responseSiege, $pos+137, 70));
$pos=strpos($responseSiege, ' size="-1"> <B>Adresse&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$posFin=strpos($responseSiege, '</font>', $pos+103);
$AdresseStr=substr($responseSiege, $pos+103, $posFin-($pos+103));
$AdresseTabLigne=explode('<BR>', $AdresseStr);//'
$tabRet['AdresseLigne1']=str_replace('&nbsp;', '/', $AdresseTabLigne[0]);
$tabRet['AdresseLigne2']=str_replace('&nbsp;', '/', $AdresseTabLigne[1]);
$tabRet['AdresseLigne3']=str_replace('&nbsp;', '/', $AdresseTabLigne[2]);
/*
$AdresseNum=$AdresseTabLigne1[0];
$AdresseVoi=$AdresseTabLigne1[1];
$AdresseRue=$AdresseTabLigne1[2];
$AdresseCP=$AdresseTabLigne2[0];
$AdresseVille=$AdresseTabLigne2[1];
*/
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise&nbsp;est&nbsp;connue&nbsp;au&nbsp;répertoire&nbsp;comme&nbsp;');
if ($pos>0) {
$posFin=strpos($responseSiege, '</b>', $pos+106);
$tabRet['etatJuridique']=html_entity_decode(substr($responseSiege, $pos+106, $posFin-($pos+106)));
$tabRet['dateEtatJuridique']='';
} else {
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise&nbsp;est&nbsp;cessée&nbsp;le&nbsp;:&nbsp;');
$tabRet['dateEtatJuridique']=substr($responseSiege, $pos+86, 10);
$tabRet['etatJuridique']='cessée';
}
//echo 'GetDataEtab="'.$libelleErreur."\"\r\n";
return $tabRet;
}
}
function getDataEntreprise($pageHtml)
{
global $libelleErreur;
$responseEntreprise=$pageHtml;
$tabRet=array();
if ($libelleErreur=='') {
$pos=strpos($responseEntreprise, 'size="-1"> <B>Date&nbsp;de&nbsp;création&nbsp;:</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
if ($pos>0)
$tabRet['dateCreationEntrep']=substr($responseEntreprise, $pos+109, 10);
else
$tabRet['dateCreationEntrep']='';
// Raison sociale et Sigle
$pos=strpos($responseEntreprise, ' size="-1"> <B>Raison sociale et Sigle&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$posFin=strpos($responseEntreprise, '</font>', $pos+123);
$raisonSocialeStr=trim(substr($responseEntreprise, $pos+123, $posFin-($pos+123)));
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
$tabRet['raisonSocialeEntrep']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
$tabRet['sigle']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
// Activité prinicpale Entrep
$pos=strpos($responseEntreprise, ' size="-1"> <B>Activité&nbsp;principale&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$tabRet['NafCodeEntrep']=substr($responseEntreprise, $pos+120, 4);
$tabRet['NafLibEntrep']=trim(substr($responseEntreprise, $pos+137, 70));
// Forme Juridique
$pos=strpos($responseEntreprise, ' size="-1"> <B>Forme&nbsp;juridique&nbsp;:</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
$tabRet['FJCodeEntrep']=substr($responseEntreprise, $pos+116, 4);
$tabRet['FJLibEntrep']=trim(substr($responseEntreprise, $pos+133, 70));
// Nb Etab Actifs
$pos=strpos($responseEntreprise, ' size="-1"> <B>Nb&nbsp;établissements&nbsp;actifs&nbsp;:</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
$posFin=strpos($responseEntreprise, '</font>', $pos+118);
$tabRet['nbEtabActifs']=trim(str_replace(' ', '', html_entity_decode(substr($responseEntreprise, $pos+118, $posFin-($pos+118)))));
}
return $tabRet;
}
/*
* parseHtml.php
* Author: Carlos Costa Jordao
* Email: carlosjordao@yahoo.com
*
* My notation of variables:
* i_ = integer, ex: i_count
* a_ = array, a_html
* b_ = boolean,
* s_ = string
*
* What it does:
* - parses a html string and get the tags
* - exceptions: html tags like <br> <hr> </a>, etc
* - At the end, the array will look like this:
* ["IMG"][0]["SRC"] = "xxx"
* ["IMG"][1]["SRC"] = "xxx"
* ["IMG"][1]["ALT"] = "xxx"
* ["A"][0]["HREF"] = "xxx"
*
*/
function parseHtml( $s_str )
{
$i_indicatorL = 0;
$i_indicatorR = 0;
$s_tagOption = '';
$i_arrayCounter = 0;
$a_html = array();
// Search for a tag in string
while( is_int(($i_indicatorL=strpos($s_str,'<',$i_indicatorR))) ) {
// Get everything into tag...
$i_indicatorL++;
$i_indicatorR = strpos($s_str,'>', $i_indicatorL);
$s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR-$i_indicatorL) );
$a_tag = explode( ' ', $s_temp );
// Here we get the tag's name
list( ,$s_tagName,, ) = each($a_tag);
$s_tagName = strtoupper($s_tagName);
// Well, I am not interesting in <br>, </font> or anything else like that...
// So, this is false for tags without options.
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) && $s_tagOption[1];
if( $b_boolOptions ) {
// Without this, we will mess up the array
$i_arrayCounter = (int)count($a_html[$s_tagName]);
// get the tag options, like src="htt://". Here, s_tagTokOption is 'src' and s_tagTokValue is '"http://"'
do {
$s_tagTokOption = strtoupper(strtok($s_tagOption[1], "="));
$s_tagTokValue = trim(strtok("="));
$a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] =
$s_tagTokValue;
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) &&
$s_tagOption[1];
} while( $b_boolOptions );
}
}
return $a_html;
}
function getDataEntrepriseRNCS($pageHtml) {
global $libelleErreur;
$tabRet=array();
// Liste et liens vers les Bilans
$tabRet['tabListeBilans']=getTabListeBilans($pageHtml);
$tabRet['raisonSociale']=getTextInHtml($pageHtml, '<td align="left" valign="top"><span class="boldred"><br>', '<br>', '</span>');
$tabRet['RCS']=getTextInHtml($pageHtml, '<span class="textarial">RCS ', 'RCS ', '</span>', true);
$tabRet['activite']=getTextInHtml($pageHtml, '<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Activit&eacute;</td>', 'class="basictext">', '</td>');
$tabRet['adresseSiege']=getTextInHtml($pageHtml, '<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Si&egrave;ge
social</td>', 'class="basictext">', '</td>');
print_r($tabRet);
die();
// Capital social
// Chiffre d'affaires
// Date CA
// Effectif
// Forme Juridique
// Nationalité
// Activité
// Siège social
/*
<tr>
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Si&egrave;ge
social</td>
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td align="left" valign="top" bgcolor="#EBF0F5" class="basictext">75 Avenue la Grande Armee<br>
75116 PARIS 16 </td>
</tr>
</table>
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
<br>
</div>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Renseignements
juridiques</span></td>
<td>&nbsp;</td>
</tr>
</table>
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
<tr align="left" valign="top">
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Forme
juridique</td>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="385" bgcolor="#EBF0F5" class="basictext">SA à conseil d'administration</td>
</tr>
<tr align="left" valign="top">
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Capital social</td>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="385" bgcolor="#EBF0F5" class="basictext">171.285.000,00
EURO</td>
</tr>
<tr align="left" valign="top">
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Nationalit&eacute;</td>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td bgcolor="#EBF0F5" class="basictext">France</td>
</tr>
</table>
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
<br>
</div>
<div align="center">
<table width="588" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="210" align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Chiffres
cl&eacute;s</span></td>
<td width="378" align="left" valign="top" class="smalltext">au 31-12-2004</td>
</tr>
</table>
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
<tr>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Chiffre
d'affaires</td>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">18.049.000.000
EU</td>
</tr>
<tr>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Effectif</td>
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">De 5150 à 5720</td>
</tr>
</table>
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
<br>
<br>
</div>
</div>
<table width="600" border="0" cellspacing="2" cellpadding="0">*/
return $tabRet;
}
function getDataEcoCoface($pageHtml) {
global $libelleErreur;
$tabRet=array();
// SIREN
$pos=strpos($pageHtml, '<b><font class="nota">La forme juridique ou la date de création trop récente de l\'entreprise ne nous permettant pas d\'obtenir suffisamment d\'informations, nous vous offrons ce produit.</font></b>');
if ($pos>0) {
$tabRet['infoEco']='OUI';
$tabRet['societeInactive']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Société inactive</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$strCapital=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Capital &nbsp (', '(', '</tr><tr>');
$tabTmp=explode('</td>', $strCapital);
$tabRet['capital_source']=str_replace(')', '', $tabTmp[0]);
$tabTmp=explode('&nbsp', $tabTmp[1]);
$tabRet['capital_montant']=str_replace(chr(160), '', trim(strip_tags($tabTmp[0])));
$tabRet['capital_devise']=trim(strip_tags($tabTmp[1]));
$tabRet['dateCreation']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Date de création</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['formeJuridique']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Forme juridique</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['cotationBourse']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Cotation en bourse</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['effectifSociete']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Effectif société</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['activite']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Activité</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['sigle']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Sigle</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
$tabRet['enseigne']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Enseigne</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
// Dirigeants
$strDir=@getTextInHtml($pageHtml, '<td class="tabtot">IDENTITE</td>', '<td>&nbsp;</td>', '</table>');
$tabDir=explode('</tr>', $strDir);
$nbDir=1;
foreach ($tabDir as $key => $dir)
{
$tabTmp=explode('<td bgcolor="#FFF3DE" class="tabval" > ', $dir);
$typeDir=trim(strip_tags($tabTmp[0]));
$nomDir=trim(strip_tags($tabTmp[1]));
if ($typeDir<>'' && $typeDir<>'Date de création' && $typeDir<>'Forme juridique' && $typeDir<>'Cotation en bourse'
&& $typeDir<>'Effectif société' && $typeDir<>'Société inactive' && $typeDir<>'Activité'
&& $typeDir<>'Sigle' && $typeDir<>'Enseigne'
&& substr($typeDir, 0, 8) <>'Capital ' )
{
//$tabDir['Produits'].=$produit.'/';
//$produit=str_replace(' ','_',$produit);
$tabRet['Dirigeant'.$nbDir.'Type']=trim($typeDir);
$tabTmp=explode('&nbsp', $nomDir);
$tabRet['Dirigeant'.$nbDir.'Genre']=trim($tabTmp[0]);
$tabRet['Dirigeant'.$nbDir.'Prenom']=trim($tabTmp[1]);
$tabRet['Dirigeant'.$nbDir.'Nom']=trim($tabTmp[2]);
$nbDir++;
}
}
$tabRet['NbDirigeants']=$nbDir-1;
// Liens Financiers
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">LIENS FINANCIERS</td>', '<td>&nbsp;</td>', '</table>');
if (strpos($strTmp, 'Néant')>0)
$tabRet['LiensFinanciers']='Néant';
else
$tabRet['LiensFinanciers']='Présence liens';
// ELEMENTS FINANCIERS
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">ELEMENTS FINANCIERS</td>', '<td>&nbsp;</td>', '</table>');
if (strpos($strTmp, 'Néant')>0)
$tabRet['ElementsFinanciers']='Néant';
else
$tabRet['ElementsFinanciers']='Présence El.Fi.';
}
else
$tabRet['infoEco']='NON';
//echo $pageHtml;
//print_r($tabRet);
//die();
return $tabRet;
}
function getDataEntrepriseCoface($pageHtml) {
global $libelleErreur;
$tabRet=array();
// SIREN
$tabRet['siren']=@getTextInHtml($pageHtml, 'portail/entreprise_identite/identite.asp?nsiren=', '?nsiren=', '&IMPRESSION=OUI');
//$tabRet['siren']=@getTextInHtml($pageHtml, '<a href="http://www.coface.fr" target="_blank">&nbsp;Qui sommes nous&nbsp;</a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=18452&metier=ALL&geo=ALL&idnav=168d25840396c5f38f4
$tabRet['nscrl']=@getTextInHtml($pageHtml, 'Plan du site&nbsp;</a>-<a href="http://www.coface.fr" target="_blank">&nbsp;Qui sommes nous&nbsp;</a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=', '?nscrl=', '&metier=ALL&geo=ALL&idnav=');
// Raison Sociale, Adresse et lien vers Géoloc
$strRS_Adr=@getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>', '</b></td>');
$tabRS_Adr=explode('<br>', $strRS_Adr);
$tabRet['raisonSociale']=trim($tabRS_Adr[0]);
$tabRS_Adr1=explode('&nbsp;', $tabRS_Adr[1]);
$tabRet['AdresseLigne1']=trim($tabRS_Adr1[0]);
$tabRet['AdresseLigne2']=trim($tabRS_Adr1[1]);
$tabRS_Adr1=explode('&nbsp;', $tabRS_Adr[2]);
$tabRet['codePostal']=trim($tabRS_Adr1[0]);
$tabRet['ville']=trim($tabRS_Adr1[1]);
$tabRet['UrlGeoLoc']=@getTextInHtml($pageHtml, '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><a href="javascript:;" onClick="MM_openBrWindow(\'', 'onClick="MM_openBrWindow(\'', '\',\'Planfax');
// Téléphone / Fax
$strTelFax=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Téléphone<br>', '<td bgcolor="#FFF3DE" class="tabval" valign="top">', '</td>');
$tabTelFax=explode('<br>', $strTelFax);
$tabRet['tel']=trim($tabTelFax[0]);
$tabRet['fax']=trim($tabTelFax[1]);
// Adresse Internet / Email
$strInet=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Adresse internet <br>', '<td bgcolor="#FFF3DE" class="tabval"><a class="tabval" HREF="', '</a></td>');
$tabInet=explode('<br>', $strInet);
$tabRet['web']=trim( @getTextInHtml($tabInet[0], ' target="_new">', '>', '</a>') );
$tabRet['mail']=trim( @getTextInHtml($tabInet[1], ' href="mailto:', ':', '">') );
// Bourse
$strBourse=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"> <b>'."\r\n".' Code Sicovam<br>', '<td bgcolor="#FFF3DE" class="tabval">', '</td>');
$tabBourse=explode('<br>', $strBourse);
$tabRet['bourse_isin']=trim($tabBourse[0]);
$tabRet['bourse_marche']=trim($tabBourse[1]);
$tabRet['bourse_ville']=trim($tabBourse[2]);
// Activité
$tabRet['activite']=trim(str_replace('&nbsp;', ' ', @getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libellé code activité </b></td>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">', '</td>')));
// Produits disponibles
$strDispos=@getTextInHtml($pageHtml, '<table border="0" cellpadding="0" cellspacing="0" width="98%"><tr><td class="normal"><b>Produits disponibles</b></td></tr><tr><td bgcolor="#E1D0B6"><img src="../images/vide.gif" border="0" height="1"><br></td></tr><tr><td><img src="../images/vide.gif" border="0" height="5"><br></td></tr></table>', '<table border="0" cellpadding="5" cellspacing="0" width="100%">', '</table>');
$tabDispos=explode('<td align="left" width="25%"', $strDispos);
$tabRet['Produits']='';
foreach ($tabDispos as $key => $produit)
{
$produit=trim(str_replace('>', '', str_replace('nowrap>', '', strip_tags($produit))));
if ($produit<>'' && $produit<>'&nbsp;') {
$tabRet['Produits'].=$produit.'/';
$produit=str_replace(' ','_',$produit);
$tabRet['Produit_'.$produit]='Oui';
}
}
// print_r($tabRet);
// die();
return $tabRet;
}
function getTabListeBilans($pageHtml) {
$tabUrl=array();
$deb=$fin=0;
while( is_int(($deb=strpos($pageHtml,'<a href="http://www.societe.com/cgi-bin/bilan?bil=',$fin))) ) {
$deb=$deb+9;
$fin = strpos($pageHtml,'</a>', $deb);
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
//echo $s_temp."\r\n";
$a_temp = explode('" class="basic">', $s_temp);
$tabUrl[$a_temp[1]]=$a_temp[0];
}
return $tabUrl;
}
function getTabListeGU($pageHtml) {
$tabGU=array();
$deb=$fin=0;
/* <tr><td><img alt="" src="b.gi onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localit&eacute;</td></tr>
<tr><td><img src="b.gif" alt="" border=0></td><td align="left" onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l&#39;adresse</td></tr>
*/
while( is_int(($deb=strpos($pageHtml,'<td onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class="txt9px" href="javascript:ChoixGeo(\'',$fin))) ) {
$deb=$deb+122;
$fin = strpos($pageHtml,'</td></tr>', $deb);
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
//echo $s_temp."\r\n";
$a_temp = explode('\')">', $s_temp);
$tabGU[$a_temp[1]]=$a_temp[0];
}
return $tabGU;
}
function getTabListeNonTrouve($pageHtml) {
$tabGU=array();
$deb=$fin=0;
/* onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localit&eacute;</td></tr>
onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l&#39;adresse</td></tr>
*/
while( is_int(($deb=strpos($pageHtml,'onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo(\'',$fin))) ) {
$deb=$deb+116;
$fin = strpos($pageHtml,'</td></tr>', $deb);
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
//echo $s_temp."\r\n";
$a_temp = explode('\')">', $s_temp);
$tabGU[$a_temp[1]]=$a_temp[0];
}
return $tabGU;
}
/** 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>
*/
}
?>

View File

@ -0,0 +1,89 @@
<?
//include('fonctions.php');
//include('insee.class.php');
define('HOST_NORMAD', 'www.normad.fr');
define('SITE_NORMAD', 'http://'. HOST_NORMAD .'/');
//$normad2=new Normad('SCI BRYGE', 'Kervegant', '', '', '', '29', 'SCAER');
class Normad {
/** Normalise l'adresse postale donnée en paramètre. Seule la ligne 1 qui devrait comporter la Raison Sociale ou le nom de l'expéditeur reste inchangée !
** @param $adrL1 Obligatoirement le Nom ou la Raison Sociale du destinataire
** @param $adrL2 Normalisation = Appart.,Bâtiment...
** @param $adrL3 Normalisation = Résidence,Cité...
** @param $adrL4 Normalisation = Num./Bis/Type voie/Nom voie
** @param $adrL5 Normalisation = BP,TSA,Lieu-dit...
** @param $codPos Code Postal (ou département)
** @param $ville Ville (orthographe correcte si possible si pas de CP)
** @return array
**/
function Normad ($adrL1, $adrL2, $adrL3, $adrL4, $adrL5, $codPos, $ville) {
$adrL1 =substr(trim($adrL1) , 0, 40);
$adrL2 =substr(trim($adrL2) , 0, 40);
$adrL3 =substr(trim($adrL3) , 0, 40);
$adrL4 =substr(trim($adrL4) , 0, 40);
$adrL5 =substr(trim($adrL5) , 0, 40);
$codPos=substr(trim($codPos), 0, 5);
$ville =substr(trim($ville) , 0, 33);
$postData=array( 'ad1'=>$adrL2, //htmlentities($adrL2),
'ad2'=>$adrL3, //htmlentities($adrL3),
'ad3'=>$adrL4, //htmlentities($adrL4),
'ad4'=>$adrL5, //htmlentities($adrL5),
'cod'=>$codPos,
'loc'=>htmlentities($ville),
'hiddenField'=>'GEN',);
$tabHtml=getUrl(SITE_NORMAD.'traiter_adresse.php', '', $postData, SITE_NORMAD.'validez.php', true, HOST_NORMAD);
$page=$tabHtml['body'];
$posInHtml=0;
$tabRet=array();
$retour=trim(str_replace(chr(173), '', getTextInHtml($page, '<td colspan=2><font face="Arial" size="2" color="#3F5A80"><b>', '<b>', '</b></font>', false, true, true, true, $posInHtml)));
$retour=explode('[*', $retour);
$tabRet['retour_code']=str_replace(']','',$retour[1]);
$tabRet['retour_libelle']=trim($retour[0]);
$tabRet['retour_messages']=getTextInHtml($page, '<li>', 'i>', '<br>', false, false, true, true, $posInHtml, 0);
// Récupération des Lignes d'adresse
$tabRet['ligne1']=$adrL1;
$tabRet['ligne2']=getTextInHtml($page, '<td class="gris2"><span class=grasnoir>Adresse en sortie :</span>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['ligne3']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 2 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['ligne4']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet ', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['ligne5']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 4 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['CP']=getTextInHtml($page, '<td class=pet align=right nowrap> CP : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['ville']=getTextInHtml($page, '<td class=pet align=right nowrap> Localité : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
$tabRet['ligne6']=$tabRet['CP'] .' '. $tabRet['ville'];
// Découpage de la rue
$tabRet['voie_num']=getTextInHtml($page, '<span class=pet>Numéro ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
$tabRet['voie_btq']=getTextInHtml($page, '<span class=pet>Bis/Ter/Quater/...', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
$tabRet['voie_type']=getTextInHtml($page, '<span class=pet>Type', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
$tabRet['voie_denom']=getTextInHtml($page, '<span class=pet>Dénomination', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
$tabRet['voie_motDir']=getTextInHtml($page, 'directeur :</span> ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
$tabRet['voie_matric']=getTextInHtml($page, '<span class=pet>Matricule voie :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
$tabRet['code_insee_commune']=getTextInHtml($page, '<span class=pet>Code INSEE commune :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
print_r($tabRet);
//echo "$voie_num\r\n$voie_btq\r\n$voie_type\r\n$voie_denom\r\n$voie_motDir\r\n$voie_matric\r\n$code_insee_commune\r\n";
}
/*
<td class="gris2" valign=top><span class=grasnoir>Détails :</span><br>
00441644 <br>
28074 <br>
<br>
<br>
</td>
</tr>
</table>
<hr size=1>
</td>
</tr>
<tr>
<td colspan=3><p class="gris2" align="justify">&nbsp; </p>
<p class="mongrasvert" align="right"> R&eacute;f&eacute;rentiels
d'avril 2006 </p>
*/
} ?>

View File

@ -0,0 +1,170 @@
<?PHP
$this->tabNotation['A+']=array('Exceptionnel', 'A3++', 'Aaa' ,'AAA' ,'0.001');
$this->tabNotation['A'] =array('Excellent', 'A3+', 'Aa1 Aa2 Aa3' ,'AA+ AA AA-' ,'0.01');
$this->tabNotation['B+']=array('Très bon', '3++', 'A1' ,'A+' ,'0.02');
$this->tabNotation['B'] =array('Bon', '3+', 'A2 A3' ,'A A-' ,'0.04');
$this->tabNotation['C+']=array('Assez bon', '3', 'Baa1' ,'BBB+' ,'0.15');
$this->tabNotation['C'] =array('Acceptable', '3', 'Baa2' ,'BBB' ,'0.30');
$this->tabNotation['C-']=array('Moyen', '3', 'Baa3' ,'BBB-' ,'0.60');
$this->tabNotation['D+']=array('Passable', '4+', 'Ba1' ,'BB+' ,'0.90');
$this->tabNotation['D'] =array('Médiocre', '4', 'Ba2' ,'BB' ,'1.25');
$this->tabNotation['D-']=array('Très médiocre', '4', 'Ba3' ,'BB-' ,'1.60');
$this->tabNotation['E+']=array('Mauvais (sous surveillance)', '5', 'B1 B2 B3', 'B+ B B-', '5.00');
$this->tabNotation['E'] =array('Très mauvais (sensible, sans incident)', '6', 'Caa', 'CCC', '14.00');
$this->tabNotation['E-']=array('Très mauvais (sensible avec incidents)', '8', 'Ca C', 'CC C', '17.00');
$this->tabNotation['F'] =array('En défaut, hors procédures judiciaires (douteux)', '8 9', 'D', 'D', 'Défaut');
$this->tabNotation['Z'] =array('En défaut, avec procédures judiciaires ou contentieuses (douteux)', 'P', '', '', 'Défaut');
$this->tabLibActivite[0]='';
$this->tabLibActivite[15]='Industries Alimentaires : Collecte Appro';
$this->tabLibActivite[3]='Industries Alimentaires : Collecte et 1ère transformation';
$this->tabLibActivite[5]='Industries Alimentaires : Eaux de vie et Champagne';
$this->tabLibActivite[2]='Industries Alimentaires : Autres activités';
$this->tabLibActivite[6]='Industries extractives / Production Distribution : Énergie Eau';
$this->tabLibActivite[7]='Construction - BTP';
$this->tabLibActivite[1]='Industries Manufacturières';
$this->tabLibActivite[8]='Négoce';
$this->tabLibActivite[4]='Commerce de Gros';
$this->tabLibActivite[9]='Commerce Distribution';
$this->tabLibActivite[10]='Grande Distribution';
$this->tabLibActivite[12]='Transports';
$this->tabLibActivite[13]='Media Technologie de l\'information';
$this->tabLibActivite[14]='Services';
$this->tabLibActivite[11]='Hôtellerie et Loisirs / Activités immobilières';
$this->tabLibActivite[16]='Banques. Assurances. Activités financières';
$this->tabLibActivite[17]='Agriculture. Sylviculture. Pêche. Aquaculture';
$this->tabActivite[15]=array('512A');
$this->tabActivite[3]=array('151A','151C','152','153E','155','157','159G','159J','159N','159Q');
$this->tabActivite[5]=array('159A','159F');
$this->tabActivite[2]=array('151E','151F','153A','153C','153F','154','156','158','159B','159D','159L','159S','159T');
$this->tabActivite[6]=array('11','10','12','13','14','401','402','403','410');
$this->tabActivite[7]=array('451','452','453','454','455');
$this->tabActivite[1]=array('251','252','241','242','243','245','246','247','261','262','263','264','265','266','267','268','244','297','300','311','312','313','314','315','316','321','322','323','17','18','19','20','21','271','272','273','274','275','281','282','283','284','285','286','287','291','292','293','294','295','296','341','342','343','353','351','352','354','355','223','331','332','333','334','335','361','362','363','364','365','366','231','232','233','222','371','372');
$this->tabActivite[8]=array();
$this->tabActivite[4]=array('511A','511N','511P','512C','512E','512G','512J','513','511C','515A','515C','511E','511G','511J','511L','511R','511T','511U','514','515E','515F','515H','515J','515L','515N','515Q','516','517');
$this->tabActivite[9]=array('501','502','503','504','505','521A','521B','521C','521J','522','523','524A','524C','524E','524F','524H','524J','524L','524N','524R','524T','524U','524V','524W','524X','524Y','524Z','525','526');
$this->tabActivite[10]=array('521D','521E','521F','521H','524P');
$this->tabActivite[12]=array('621','622','623','611','612','602','603','631','632','634','634B','634C','634A','641');
$this->tabActivite[13]=array('221','722','721','723','724','725','726','924','642','922','921');
$this->tabActivite[14]=array('703','712E','711','712A','713','714','712C','741A','741C','741E','741G','742','743','741J','744','745','746','747','748','900','633','801','802','803','804','851','852','853','930','911','912','913','527','950');
$this->tabActivite[11]=array('923','925','926','927','551','552','553','554','555','702');
$this->tabActivite[16]=array('651','660','672','652E','652A','652C','652F','671');
$this->tabActivite[17]=array('751','990','752','990','701');
$this->tabR[1][0]=array();
$this->tabR[1][1]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
$this->tabR[1][2]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[1][3]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[1][4]=array('0:8.7','8.7:12.8','12.8:15','15:17.7','17.7:20.6','20.6:23','23:25','25:26.7','26.7:28.3','28.3:100');
$this->tabR[1][5]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[1][6]=array('0:20.5','20.5:26.7','26.7:30','30:34.1','34.1:38.4','38.4:42','42:45','45:47.6','47.6:49.9','49.9:100');
$this->tabR[1][7]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
$this->tabR[1][8]=array('0:3.7','3.7:7.8','7.8:10','10:12.7','12.7:15.6','15.6:18','18:20','20:21.7','21.7:23.3','23.3:100');
$this->tabR[1][9]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
$this->tabR[1][10]=array('0:5.7','5.7:9.8','9.8:12','12:14.7','14.7:17.6','17.6:20','20:22','22:23.7','23.7:25.3','25.3:100');
$this->tabR[1][11]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[1][12]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
$this->tabR[1][13]=array('0:23.7','23.7:27.8','27.8:30','30:32.7','32.7:35.6','35.6:38','38:40','40:41.7','41.7:43.3','43.3:100');
$this->tabR[1][14]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[1][15]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
$this->tabR[1][16]=array('0:6.8','6.8:8.9','8.9:10','10:11.4','11.4:12.8','12.8:14','14:15','15:15.9','15.9:16.6','16.6:100');
$this->tabR[1][17]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
$this->tabR[2][0]=array();
$this->tabR[2][1]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1,5','1.2:1.4','1.0:1.2','0.9:1.0','0.8:0,9','0.7:0,8','0:0.7');
$this->tabR[2][2]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
$this->tabR[2][3]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
$this->tabR[2][4]=array('3.0:','2.7:3.0','2.5:2.7','2.3:2.5','2.0:2.3','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
$this->tabR[2][5]=array('2.6:','2.4:2.6','2.2:2.4','2.0:2.2','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','1.0:1.1','0:1');
$this->tabR[2][6]=array('1.7:','1.6:1.7','1.5:1.6','1.4:1.5','1.2:1.4','1.1:1.2','1.0:1.1','0.9:1.0','0.8:0.9','0:0.8');
$this->tabR[2][7]=array('1.5:','1.4:1.5','1.3:1.4','1.1:1.3','1.0:1.2','0.9:1.0','0.8:0.9','0.7:0.8','0.6:0.7','0:0.6');
$this->tabR[2][8]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
$this->tabR[2][9]=array('3:','2.7:3','2.5:2.7','2.3:2.5','2:2.3','1.7:2','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
$this->tabR[2][10]=array('3.8:','3.3:3.8','3.0:3.3','2.6:3.0','2.2:2.6','1.8:2.2','1.5:1.8','1.2:1.5','1.0:1.2','0:1');
$this->tabR[2][11]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
$this->tabR[2][12]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
$this->tabR[2][13]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
$this->tabR[2][14]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
$this->tabR[2][15]=array('2.2:','1.9:2.2','1.7:1.9','1.5:1.7','1.2:1.5','1.0:1.2','0.8:1.0','0.7:0.8','0.5:0.7','0:0.5');
$this->tabR[2][16]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
$this->tabR[2][17]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1:1.2','0.9:1','0.7:0.9','0:0.7');
$this->tabR[3][0]=array();
$this->tabR[3][1]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
$this->tabR[3][2]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][3]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][4]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][5]=array('8.6:','7.9:8.6','7.5:7.9','6.9:7.5','6.2:6.9','5.6:6.2','5:5.6','4.5:5','4:4.5','0:4');
$this->tabR[3][6]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
$this->tabR[3][7]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
$this->tabR[3][8]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
$this->tabR[3][9]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][10]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][11]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[3][12]=array('5.9:','5.4:5.9','5:5.4','4.5:5','3.9:4.5','3.4:3.9','3:3.4','2.6:3','2.3:2.6','0:2.3');
$this->tabR[3][13]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
$this->tabR[3][14]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
$this->tabR[3][15]=array('6.9:','6.3:6.9','6.0:6.3','5.5:6.0','5.0:5.5','4.5:5.0','4.0:4.5','3.6:4.0','3.2:3.6','0:3.2');
$this->tabR[3][16]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
$this->tabR[3][17]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
$this->tabR[4][0]=array();
$this->tabR[4][1]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][2]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][3]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][4]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][5]=array('0:1.36','1.36:1.44','1.44:1.5','1.5:1.58','1.58:1.71','1.71:1.85','1.85:2','2:2.16','2.16:2.33','2.33:');
$this->tabR[4][6]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][7]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][8]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
$this->tabR[4][9]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][10]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][11]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][12]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[4][13]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
$this->tabR[4][14]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
$this->tabR[4][15]=array('0:2.9','2.9:3.4','3.4:3.7','3.7:4.3','4.3:5.2','5.2:6.2','6.2:7.5','7.5:9.1','9.1:10.9','10.9:');
$this->tabR[4][16]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
$this->tabR[4][17]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
$this->tabR[5][0]=array();
$this->tabR[5][1]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
$this->tabR[5][2]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
$this->tabR[5][3]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
$this->tabR[5][4]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
$this->tabR[5][5]=array('-999:-420','-420:-384','-384:-360','-360:-324','-324:-276','-276:-228','-228:-180','-180:-132','-132:-84','-84:');
$this->tabR[5][6]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
$this->tabR[5][7]=array('-99:-30','-30:-24','-24:-20','-20:-14','-14:-6','-6:2','2:10','10:18','18:26','26:');
$this->tabR[5][8]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
$this->tabR[5][9]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
$this->tabR[5][10]=array('-99:-5','-5:-2','-2:0','0:3','3:7','7:11','11:15','15:19','19:23','23:');
$this->tabR[5][11]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
$this->tabR[5][12]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
$this->tabR[5][13]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
$this->tabR[5][14]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
$this->tabR[5][15]=array('-99:-38.3','-38.3:-36.3','-36.3:-35.0','-35:-33','-33.0:-30','-30:-27.7','-27.7:-25.0','-25.0:-22.3','-22.3:-19.7','-19.7:');
$this->tabR[5][16]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
$this->tabR[5][17]=array(':-58.3','-58.3:53.3','-53.3:-50','-50:-45','-45:-38.3','-38.3:-31.7','-31.7:-25','-25:-18.3','-18.3:-11.7','-11.7:');
$this->tabR[6][0]=array();
$this->tabR[6][1]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
$this->tabR[6][2]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
$this->tabR[6][3]=array('0:1.5','1.5:2.1','2.1:2.5','2.5:3.1','3.1:3.9','3.9:4.7','4.7:5.5','5.5:6.3','6.3:7.1','7.1:');
$this->tabR[6][4]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
$this->tabR[6][5]=array('0:6.7','6.7:7.5','7.5:8','8:8.8','8.8:9.9','9.9:10.9','10.9:12','12:13.1','13.1:14.1','14.1:');
$this->tabR[6][6]=array('0:7.7','7.7:8.5','8.5:9','9:9.8','9.8:10.9','10.9:11.9','11.9:13','13:14.1','14.1:15.1','15.1:');
$this->tabR[6][7]=array('0:3','3:3.6','3.6:4','4:4.6','4.6:5.4','5.4:6.2','6.2:7','7:7.8','7.8:8.6','8.6:');
$this->tabR[6][8]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
$this->tabR[6][9]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
$this->tabR[6][10]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
$this->tabR[6][11]=array('0:8.3','8.3:9.3','9.3:10','10:11','11:12.3','12.3:13.7','13.7:15','15:16.3','16.3:17.7','17.7:');
$this->tabR[6][12]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
$this->tabR[6][13]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
$this->tabR[6][14]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
$this->tabR[6][15]=array('0:2','2:2.3','2.3:2.5','2.5:2.8','2.8:3.2','3.2:3.6','3.6:4.0','4.0:4.4','4.4:4.8','4.8:');
$this->tabR[6][16]=array('0:1.7','1.7:1.9','1.9:2','2:2.2','2.2:2.5','2.5:2.7','2.7:3','3:3.3','3.3:3.5','3.5:');
$this->tabR[6][17]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
?>

View File

@ -0,0 +1,9 @@
<?
class Rncs {
function Rncs () {}
}
?>

View File

View File

@ -0,0 +1,195 @@
<?php
//script will fetch an email identified by $msgid, and parse the its parts into an
//array $partsarray
//structure of array:
//$partsarray[<name of part>][<attachment/text>]
//if attachment- subarray is [filename][binary data]
//if text- subarray is [type of text(HTML/PLAIN)][text string]
//i.e.
//$partsarray[3.1][attachment][filename]=filename of attachment in part 3.1
//$partsarray[3.1][attachment][binary]=binary data of attachment in part 3.1
//$partsarray[2][text][type]=type of text in part 2
//$partsarray[2][text][string]=decoded text string in part 2
//$partsarray[not multipart][text][string]=decoded text string in message that isn't multipart
function parsepart($p,$i){
global $link,$msgid,$partsarray;
//where to write file attachments to:
$filestore = '[full/path/to/attachment/store/(chmod777)]';
//fetch part
$part=imap_fetchbody($link,$msgid,$i);
//if type is not text
if ($p->type!=0){
//DECODE PART
//decode if base64
if ($p->encoding==3)$part=base64_decode($part);
//decode if quoted printable
if ($p->encoding==4)$part=quoted_printable_decode($part);
//no need to decode binary or 8bit!
//get filename of attachment if present
$filename='';
// if there are any dparameters present in this part
if (count($p->dparameters)>0){
foreach ($p->dparameters as $dparam){
if ((strtoupper($dparam->attribute)=='NAME') ||(strtoupper($dparam->attribute)=='FILENAME')) $filename=$dparam->value;
}
}
//if no filename found
if ($filename==''){
// if there are any parameters present in this part
if (count($p->parameters)>0){
foreach ($p->parameters as $param){
if ((strtoupper($param->attribute)=='NAME') ||(strtoupper($param->attribute)=='FILENAME')) $filename=$param->value;
}
}
}
//write to disk and set partsarray variable
if ($filename!=''){
$partsarray[$i][attachment] = array('filename'=>$filename,'binary'=>$part);
$fp=fopen($filestore.$filename,"w+");
fwrite($fp,$part);
fclose($fp);
}
//end if type!=0
}
//if part is text
else if($p->type==0){
//decode text
//if QUOTED-PRINTABLE
if ($p->encoding==4) $part=quoted_printable_decode($part);
//if base 64
if ($p->encoding==3) $part=base64_decode($part);
//OPTIONAL PROCESSING e.g. nl2br for plain text
//if plain text
if (strtoupper($p->subtype)=='PLAIN')1;
//if HTML
else if (strtoupper($p->subtype)=='HTML')1;
$partsarray[$i][text] = array('type'=>$p->subtype,'string'=>$part);
}
//if subparts... recurse into function and parse them too!
if (count($p->parts)>0){
foreach ($p->parts as $pno=>$parr){
parsepart($parr,($i.'.'.($pno+1)));
}
}
return;
}
//require('./constantes.php');
$imap_server='{imap.online.net}';
$imap_account='buzuk@lenaour.org';//'scores-decisions.com';
$imap_password='bzh4231*';//catsysyo92';
if (!$mbox = imap_open($imap_server, $imap_account, $imap_password)) die("Connexion IMAP impossible : ". imap_last_error());
$list = imap_list($mbox, $imap_server, "*");
if(is_array($list)) {
reset($list);
foreach ($list as $val) {
echo imap_utf7_decode($val) . "<br />\n";
}
} else {
echo "imap_list a échoué : " . imap_last_error() . "\n";
}
echo "<p><h1>Entetes de mail dans INBOX</h1>\n";
$headers = imap_headers ($mbox);
if ($headers == false) {
echo "Erreur !\n";
} else {
while (list ($key,$val) = each ($headers)) {
echo $val."<br>\n";
}
}
$check = imap_mailboxmsginfo($mbox);
if($check) {
echo "Date: " . $check->Date ."<br />\n" ;
echo "Pilote: " . $check->Driver ."<br />\n" ;
echo "Mailbox: " . $check->Mailbox ."<br />\n" ;
echo "Messages: ". $check->Nmsgs ."<br />\n" ;
echo "Récent: " . $check->Recent ."<br />\n" ;
echo "Non lus: " . $check->Unread ."<br />\n" ;
echo "Effacés: " . $check->Deleted ."<br />\n" ;
echo "Taille: " . $check->Size ."<br />\n" ;
} else {
echo "imap_check() a échoué: ".imap_last_error(). "<br />\n";
}
$imap_obj = imap_check($mbox);
$imap_sorted = imap_sort($mbox, SORTARRIVAL, 0);
$MN=$imap_obj->Nmsgs;
echo '<br>Nombre de messages '.$MN.'<br/>';
$overview = imap_fetch_overview($mbox,"1:$MN",0);
$k=0;
$partsarray=array();
while( list($key,$val) = each($overview))
{
if (strpos($val->from, 'rapports@neoveille.fr')!==false) {
$unsorted[$k]=$val;//->uid;
/*$unsorted[$k]["subject"]=imap_utf8($val->subject); // Le sujet du message
$unsorted[$k]['from']=$val->from;
$unsorted[$k]['to']=$val->to;
$unsorted[$k]['date']=$val->date;// Date d'expédition
$unsorted[$k]['message_id - Identification du message
references - est une référence sur l'id de ce message
in_reply_to - est une réponse à cet identifiant de message
size - taille en octets
uid - UID du message dans la boîte aux lettres
msgno - numéro de séquence du message dans la boîte
recent - Ce message est récent
flagged - Ce message est marqué
answered - Ce message a donné lieu à une réponse
deleted - Ce message est marqué pour l'effacement
seen - Ce message est déjà lu
draft - Ce message est un brouillon
*/
$s=imap_fetchstructure($mbox,$val->message_id);
/*if (count($s->parts)>0){
foreach ($s->parts as $partno=>$partarr){
//parse parts of email
parsepart($partarr,$partno+1);
}
}
else { //for not multipart messages
//get body of message
//decode if quoted-printable
if ($s->encoding==4) $text=quoted_printable_decode($text);
//OPTIONAL PROCESSING
if (strtoupper($s->subtype)=='PLAIN') $text=$text;
if (strtoupper($s->subtype)=='HTML') $text=$text;
$partsarray['not multipart'][text]=array('type'=>$s->subtype,'string'=>$text);
}*/
$full_bodacc=imap_body($mbox,$val->msgno).'[FIN]';
$k++;
}
}
//usort ($unsorted, create_function('$a,$b','setlocale(LC_ALL,$locale);return strcoll($a["subject"],$b["subject"]);'));
$Bodacc=explode("-------------------------------------------------- \r\n--------------------------------------------------", $full_bodacc);
echo '<pre>';
/*var_dump($imap_obj);
print_r($imap_obj);
print_r($imap_sorted);
print_r($unsorted);
print_r($partsarray);*/
print_r($Bodacc);
echo '</pre>';
imap_close($mbox);
?>

View File

@ -0,0 +1,76 @@
<?
//error_reporting(E_ALL);
function mysql_trace($query, $res='') {
if (!$fp=fopen('mysql_insert.log', 'a'))
return false;
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $res : $query\n"))
return false;
if (!fclose($fp))
return false;
return true;
}
/** Retourne la dernière valeur de l'auto-incrément ou 0 si pas d'auto-incrément
** Penser à bien tester la valeur !== false
**/
function mysql_insert($table, $toAdd, $debug=false){
$fields = implode(array_keys($toAdd), '`,`');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=addslashes($array_values);
$values = "'".implode(array_values($tmp), "','")."'"; # better
$values = str_replace("'NULL'", 'NULL', $values);
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
$res = mysql_query($query);// OR die(mysql_error());
if ($res!==false)
{
if (mysql_insert_id()>0)
$res=mysql_insert_id();
else
$res=true;
}
if ($debug) mysql_trace($query, $res);
return $res;
//-- Example of usage
//$tToAdd = array('id'=>3, 'name'=>'Yo', 'salary' => 5000);
//insertIntoDB('myTable', $tToAdd)
}
function mysql_update($table, $update, $where, $debug=false){
$fields = array_keys($update);
$values = array_values($update);
$i=0;
$query='UPDATE `'.$table.'` SET ';
while($fields[$i]){
if($i>0){$query.=', ';}
$query.=' `'.$fields[$i]."`='".addslashes($values[$i])."'";
$i++;
}
$query = str_replace("'NULL'", 'NULL', $query);
$query.=' WHERE '.$where.' LIMIT 1;';
if ($debug) mysql_trace($query, mysql_errno());
mysql_query($query);// or die(mysql_error());
return true;
//Example
// mysql_update('myTable', $anarray, "type = 'main'")
}
function mysql_select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH) {
$query="SELECT $fields FROM $table WHERE $where;";
// if ($debug) mysql_trace($query, count($tab));
$result=mysql_query($query) or die(mysql_error());
$tab=array();
while ($ligne = mysql_fetch_array($result, $assoc))
$tab[]=$ligne;
mysql_free_result($result);
if ($debug) mysql_trace($query, count($tab));
// echo $query;
return $tab;
}
?>

View File

@ -0,0 +1,404 @@
<?
define('HOST_INSEE', 'avis-situation-sirene.insee.fr');
define('SITE_INSEE', 'http://'. HOST_INSEE .'/');
define('HOST_PJ', 'www.pagesjaunes.fr');
define('SITE_PJ', 'http://'. HOST_PJ .'/');
define('SITE_SOCIETE', 'http://www.societe.com/');
include('/var/www/_includes/includes/insee.class.php');
//include('includes/normad.class.php');
include('/var/www/_includes/includes/fonctions.php');
/* v0.1 Extraction d'informations INSEE en ligne de commande.
Usage: <?=$argv[0]?> <extract type> <fileIn> <fileInFmt> <fileOut> <fileOutFmt>
Where <extract type> is :
id siren.tm.fr : Fiche d'identite INSEE (établissement+entreprise)
lst siren.tm.fr : Liste des etablissements du SIREN (+infos entreprise)
rncs societe.com : Informations du RNCS
pj pagesjaunes.fr : Données des pages jaunes
coface cofacerating.fr : Coface
Where <fileInFmt> is :
csv Fichier IN au format CSV (; ou ,) SIREN;NIC;REF
plat Fichier IN au format plat (blancs significatifs) SIREN_____NIC__REF______________
Where <fileOutFmt> is : csv / todo
Le fichier en entrée doit être au format <fileInFmt> et contenir le SIREN en première colonne.
*/
$insee=&new Insee();
function getInfosSirene($sirenLu, $nicLu='') {
$tabRet=array();
$invalide=false;
if (valideSiren($sirenLu)==false) {
$libelleErreur='SIREN invalide';
$invalide=true;
}
if ( $nicLu<>'' && valideSiren($sirenLu, $nicLu)==false) {
$libelleErreur='SIRET invalide';
$invalide=true;
}
if ($invalide==true)
{
$siret=$sirenLu.$nicLu;
$str=date('d/m/Y à H:i:s') .';'. $libelleErreur .';'. $siret .';;;;;;;;;;;;;;;;;;;;;;;';
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
fwrite($fp, $str."\r\n");
fclose($fp);
$num=$key+1;
flush();
} else { // La demande est valide on va à l'INSEE
/** Paramètre de requête "option" à l'insee :
** 1: Fiche du siège + Données entreprises
** 2: Tous les établissements de l'entreprise
** 3: Un établissement particulier
** 4: Département
**/
if ($nicLu<>'') $option=3;
else $option=1;
$libelleErreur='Erreur SCRIPT Inconnue';
$tabInfoEtab=array();
$tabInfoEntrep=array();
/** Etape de connexion au site de l'INSEE pour simuler correctement un utilisateur WEB
**/
$response1=getUrl(SITE_INSEE);
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'SIRENET_Script/Accueil/script_page_accueil.asp');
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
if ($nicLu=='') //Faire une boucle de recherche de tous les établissement et y inclure le reste du traitement
{
// Requête d'interrogation
$postData=array(
'siren'=>$sirenLu,
'option'=>2,
'nic'=>'',
'dep'=>'',
'listeDep'=>'');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
$action='nouveau';
$referer=SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false';
$nbRepTot=$pageCour=$nbTotPage=$nbRepParPage=$numEtab=0;
$tabInfoEtab=array();
while(true)
{
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action='.$action, $response1["header"]["Set-Cookie"], '', $referer);
if ($responseQ['code']==302)
{
//$libelleErreur='Erreur INSEE inconnue 1';
// Siren Invalide ou autre erreur non répertoriée !
$header=$responseQ['header'];
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
{
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur',true);
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
if ($pos>0){
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
} else
$libelleErreur='Erreur INSEE inconnue';
}
// On déroule les URLs d'appels liste des établissements
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
//sleep(1);
// Frames réponse niveau Etab
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
$responseListe=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_bas.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
$responseListe=$responseListe['body'];
$pos=strpos($responseListe, 'Nombre total de réponses&nbsp;:&nbsp;'."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
if ($pos>0) {
$posFin=strpos($responseListe, '</b></font>', $pos+73);
$nbRepTot=trim(substr($responseListe, $pos+73, $posFin-($pos+73)));
}
$pos=strpos($responseListe, '&nbsp;-&nbsp;Affichage de la page&nbsp;'."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
if ($pos>0) {
$posFin=strpos($responseListe, '&nbsp;-&nbsp;</b></font>', $pos+75);
$strPages=trim(substr($responseListe, $pos+75, $posFin-($pos+75)));
$tabPages=explode('&nbsp;/&nbsp;', $strPages);
$pageCour=$tabPages[0];
$nbTotPage=$tabPages[1];
}
$pos=strpos($responseListe, '&nbsp;-&nbsp;</b></font>'."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
if ($pos>0) {
$posFin=strpos($responseListe, '</b></font>', $pos+60);
$nbRepParPage=trim(substr($responseListe, $pos+60, $posFin-($pos+60)));
}
/* TODO = Récupérer les infos étab + entrep pour chaque ligne du tableau !!!*
*/
if ($libelleErreur=='Erreur SCRIPT Inconnue')
$libelleErreur='';
for ($i=1;$i<11; $i++)
{
if ($numEtab==$nbRepTot)
break; // Il n'y a pas plus d'établissement à récupérer ! On sort...
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=detail&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp');
if ($responseQ['code']==302)
{
// Siren Invalide ou autre erreur non répertoriée !
$header=$responseQ['header'];
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i)
{
// On déroule les URLs d'appels fiche siège
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
//sleep(1);
// Frames réponse niveau Etab
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i, true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i);
$responseEtab=$responseEtab['body'];
// Récupération de la fiche entreprise INSEE
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
$responseEntreprise=$responseEntreprise['body'];
$tabInfoEntrep=getDataEntreprise($responseEntreprise);
}
elseif (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i)
{
// On déroule les URLs d'appels établissement
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
//sleep(1);
// Frames réponse niveau Etab
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i, true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i);
$responseEtab=$responseEtab['body'];
}
$tabInfoEtab=getDataEtablissement($responseEtab);
$tabRet[]=array_merge($tabInfoEtab, $tabInfoEntrep);
if ($libelleErreur<>'' && $tabInfoEtab['siret'] =='') $siret=$sirenLu . $nicLu;
else $siret=$tabInfoEtab['siret'];
$str= date('d/m/Y à H:i:s') .';'.
$libelleErreur .';'.
// Siège
$siret .';'.
$tabInfoEtab['active'] .';'.
$tabInfoEtab['dateAbsActivite'] .';'.
$tabInfoEtab['typeEtablissement'] .';'.
$tabInfoEtab['dateMAJ'] .';'.
$tabInfoEtab['dateCreation'] .';'.
$tabInfoEtab['raisonSociale'] .';'.
$tabInfoEtab['Enseigne'] .';'.
$tabInfoEtab['NafCode'] .';'.
$tabInfoEtab['NafLib'] .';'.
$tabInfoEtab['AdresseLigne1'] .';'.
$tabInfoEtab['AdresseLigne2'] .';'.
$tabInfoEtab['AdresseLigne3'] .';'.
$tabInfoEtab['etatJuridique'] .';'.
$tabInfoEtab['dateEtatJuridique'] .';'.
// Entreprise
$tabInfoEntrep['dateCreationEntrep'] .';'.
$tabInfoEntrep['raisonSocialeEntrep'] .';'.
$tabInfoEntrep['sigle'] .';'.
$tabInfoEntrep['NafCodeEntrep'] .';'.
$tabInfoEntrep['NafLibEntrep'] .';'.
$tabInfoEntrep['FJCodeEntrep'] .';'.
$tabInfoEntrep['FJLibEntrep'] .';'.
$tabInfoEntrep['nbEtabActifs'] .';';
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
fwrite($fp, $str."\r\n");
fclose($fp);
$numEtab++;
$num=$key+1;
$typeEtablissement=$tabInfoEtab['typeEtablissement'];
// echo "Question $num/$nbLignes : Demande=$sirenLu$nicLu Etablissement $numEtab/$nbRepTot $typeEtablissement=$siret $libelleErreur\r\n";
flush();
sleep(1);
}//end for
}//end if
if ($pageCour==$nbTotPage) {
// On sort de la boucle de passage à la page de liste suivante car il n'y a plus d'autres pages
break;
} else {
$action='listeplus';
$referer=SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp';
}
}
} //Fin While
// die('Boucle');
} /* Fin de la boucle option 'lst' */ else
{
// Requête d'interrogation
$postData=array('siren'=>$sirenLu,
'option'=>$option,
'nic'=>$nicLu,
'dep'=>'',
'listeDep'=>'');
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=nouveau', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
if ($responseQ['code']==302)
{
//$libelleErreur='Erreur INSEE inconnue 1';
// Siren Invalide ou autre erreur non répertoriée !
$header=$responseQ['header'];
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
{
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur',true);
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
if ($pos>0){
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
} else
$libelleErreur='Erreur INSEE inconnue';
}
else
{ if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege')
// L'établissement demandé est un siège !
$option=1;
if ($option==3)
{
// On déroule les URLs d'appels établissement
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
//sleep(1);
// Frames réponse niveau Etab
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
$responseEtab=$responseEtab['body'];
// On recherche si on est bien sur un fiche établissement
$pos=strpos($responseEtab, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
if ($pos<1)
$libelleErreur='Erreur SCRIPT Fiche Etablissement non trouvée';
else
$libelleErreur='';
$responseSiege=$responseEtab;
}
else
{
// On déroule les URLs d'appels Sièges
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
//sleep(1);
// Frames réponse niveau sièges
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseSiege=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
$responseSiege=$responseSiege['body'];//strip_tags(html_entity_decode(), '<td>');
// On recherche si on est bien sur un fiche siège
$pos=strpos($responseSiege, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
if ($pos<1)
$libelleErreur='Erreur SCRIPT Fiche Siège non trouvée';
else
$libelleErreur='';
}
// Niveau entreprise
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=entreprise');
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', true);
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
$responseEntreprise=$responseEntreprise['body'];
$pos=strpos($responseEntreprise, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Entreprise</B>');
if ($pos<1) {
$libelleErreur='Erreur SCRIPT Fiche Entreprise non trouvée';
}
/** Recherche des données établissement
**/
$tabInfoEtab=getDataEtablissement($responseSiege);
/** Recherche des données entreprise
**/
$tabInfoEntrep=getDataEntreprise($responseEntreprise);
}
}
if ($libelleErreur<>'' && $tabInfoEtab['siret'] =='') $siret=$sirenLu . $nicLu;
else $siret=$tabInfoEtab['siret'];
$str= date('d/m/Y à H:i:s') .';'.
$libelleErreur .';'.
// Siège
$siret .';'.
$tabInfoEtab['active'] .';'.
$tabInfoEtab['dateAbsActivite'] .';'.
$tabInfoEtab['typeEtablissement'] .';'.
$tabInfoEtab['dateMAJ'] .';'.
$tabInfoEtab['dateCreation'] .';'.
$tabInfoEtab['raisonSociale'] .';'.
$tabInfoEtab['Enseigne'] .';'.
$tabInfoEtab['NafCode'] .';'.
$tabInfoEtab['NafLib'] .';'.
$tabInfoEtab['AdresseLigne1'] .';'.
$tabInfoEtab['AdresseLigne2'] .';'.
$tabInfoEtab['AdresseLigne3'] .';'.
$tabInfoEtab['etatJuridique'] .';'.
$tabInfoEtab['dateEtatJuridique'] .';'.
// Entreprise
$tabInfoEntrep['dateCreationEntrep'] .';'.
$tabInfoEntrep['raisonSocialeEntrep'] .';'.
$tabInfoEntrep['sigle'] .';'.
$tabInfoEntrep['NafCodeEntrep'] .';'.
$tabInfoEntrep['NafLibEntrep'] .';'.
$tabInfoEntrep['FJCodeEntrep'] .';'.
$tabInfoEntrep['FJLibEntrep'] .';'.
$tabInfoEntrep['nbEtabActifs'] .';'.
//echo $str.'<br/>';
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
fwrite($fp, $str."\r\n");
fclose($fp);
$num=$key+1;
$typeEtablissement=$tabInfoEtab['typeEtablissement'];
// echo "Ligne $num/$nbLignes : Question=$sirenLu$nicLu Retour $typeEtablissement=$siret $libelleErreur (PJ=$nbPJ)\r\n";
//echo $str."<br/>";
flush();
$tabRet=array(0=>array_merge($tabInfoEntrep, $tabInfoEtab));
}
}
return $tabRet;
}
?>

View File

@ -0,0 +1,54 @@
http://avis-situation-sirene.insee.fr/REPERTOIRE/Reponse/Liste_principal.asp
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Fri, 03 Nov 2006 00:40:09 GMT
Content-Length: 1173
Content-Type: text/html
Expires: Thu, 02 Nov 2006 00:40:09 GMT
Cache-control: private
<HTML>
<HEAD>
<TITLE>Le répertoire SIRENE</TITLE>
<STYLE>
A { text-decoration: none;}
</STYLE>
</HEAD>
<BODY vlink="#0000FF" alink="#0000FF" >
<table valign="top">
<tr>
<td valign="top">
<font face="Arial" size="2">&nbsp;Nombre total de réponses&nbsp;:&nbsp;
<font face="Arial" size="2"><b></b></font>
<font face="Arial" size="2">&nbsp;-&nbsp;Affichage de la page&nbsp;
<font face="Arial" size="2"><b>&nbsp;/&nbsp;&nbsp;-&nbsp;</b></font>
<font face="Arial" size="2"><b></b></font>
<font face="Arial" size="2">&nbsp;réponses affichées dans cette page&nbsp;
</td>
</tr>
</table>
<table cols=2 width="100%">
<tr>
<td>&nbsp;</td>
<td align=right>
Page précédente/suivante :<a href="/REPERTOIRE/Reponse/question.asp?action=listemoins" target="_top"><img src="/IMAGES/reponse/fleche_precedent.gif" width="20" height="20" border="0" alt="Page précédente"></a>&nbsp;&nbsp;<a href="/REPERTOIRE/Reponse/question.asp?action=listeplus" target="_top"><img src="/IMAGES/reponse/fleche_suivant.gif" width="20" height="20" border="0" alt="Page suivante"></a>
</td>
</tr>
</table>
</BODY>
</HTML>

View File

@ -0,0 +1,174 @@
<?
define ('BEFORE', 0);
define ('AFTER', 1);
define ('BOTH', 2);
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;
}
?>

View File

@ -0,0 +1,527 @@
codeZone;valeur;NBEntreprises;NbProCol;Pourcentage;Risque;Points
GLOBALE;TOTAL;6447249;43572;0.006758231;0.006758231;0
insAPEN31;DB;18973;612;0.032256364;4.729218896;-3.729218896
insAPEN31;FA;367665;9644;0.0262304;3.845731092;-2.845731092
insAPEN31;DJ;32346;786;0.024299759;3.562673018;-2.562673018
insAPEN31;DM;5682;132;0.023231257;3.406016148;-2.406016148
insAPEN31;DC;2430;55;0.022633745;3.318412852;-2.318412852
insAPEN31;DE;36701;740;0.020162938;2.956159228;-1.956159228
insAPEN31;DH;5546;111;0.020014425;2.934385137;-1.934385137
insAPEN31;DD;11292;225;0.019925611;2.92136384;-1.92136384
insAPEN31;DK;17243;334;0.019370179;2.839930026;-1.839930026
insAPEN31;HA;242687;4586;0.018896768;2.770521585;-1.770521585
insAPEN31;IA;111075;1916;0.017249606;2.529025356;-1.529025356
insAPEN31;DL;20515;323;0.015744577;2.308367769;-1.308367769
insAPEN31;GA;693458;10740;0.0154876;2.270691423;-1.270691423
insAPEN31;DI;9391;138;0.014694921;2.154473946;-1.154473946
insAPEN31;DA;69613;995;0.014293307;2.095591997;-1.095591997
insAPEN31;DG;4389;61;0.013898382;2.037690661;-1.037690661
insAPEN31;DN;33557;435;0.012963018;1.900553633;-0.900553633
insAPEN31;ZZ;16576;119;0.007179054;1.052546337;-0.052546337
insAPEN31;CB;2833;17;0.006000706;0.879784584;0.120215416
insAPEN31;GG;9721;52;0.005349244;0.784271442;0.215728558
insAPEN31;MA;70612;373;0.005282388;0.774469502;0.225530498
insAPEN31;FF;4750;25;0.005263158;0.77165007;0.22834993
insAPEN31;CA;195;1;0.005128205;0.751864171;0.248135829
insAPEN31;HH;3757;16;0.004258717;0.62438547;0.37561453
insAPEN31;JA;72234;289;0.004000886;0.586583954;0.413416046
insAPEN31;OA;611504;2075;0.003393273;0.497499673;0.502500327
insAPEN31;KA;2657556;7102;0.00267238;0.391807048;0.608192952
insAPEN31;BA;14187;37;0.002608021;0.382371184;0.617628816
insAPEN31;OO;2450;6;0.00244898;0.359053502;0.640946498
insAPEN31;II;1476;3;0.00203252;0.297994946;0.702005054
insAPEN31;KK;22395;40;0.001786113;0.261868298;0.738131702
insAPEN31;AA;777002;1339;0.00172329;0.252657643;0.747342357
insAPEN31;EA;5687;7;0.001230877;0.180463266;0.819536734
insAPEN31;NA;432746;238;0.000549976;0.080633943;0.919366057
insAPEN31;BB;81;;0;0;1
insAPEN31;DF;149;;0;0;1
insAPEN31;EE;79;;0;0;1
insAPEN31;JJ;596;;0;0;1
insAPEN31;LA;56364;;0;0;1
insAPEN31;LL;79;;0;0;1
insAPEN31;MM;343;;0;0;1
insAPEN31;NN;772;;0;0;1
insAPEN31;PA;32;;0;0;1
insAPEN31;QA;510;;0;0;1
insMONOACT;1;57315;535;0.00933438;1.368546272;-0.368546272
insMONOACT;2;6175850;41794;0.006767328;0.992181671;0.007818329
insMONOACT;0;214084;1243;0.005806132;0.851257436;0.148742564
insSAISONAT;0;6422146;43477;0.006769855;0.99255229;0.00744771
insSAISONAT;1;25103;95;0.003784408;0.554845387;0.445154613
insDEPET;93;99100;1332;0.013440969;1.988829034;-0.988829034
insDEPET;77;87496;937;0.010709061;1.58459497;-0.58459497
insDEPET;94;94293;975;0.01034011;1.530002158;-0.530002158
insDEPET;57;67886;694;0.010223021;1.51267675;-0.51267675
insDEPET;95;72827;735;0.010092411;1.493350666;-0.493350666
insDEPET;13;198603;1935;0.009743055;1.441657335;-0.441657335
insDEPET;59;165430;1504;0.009091459;1.345242092;-0.345242092
insDEPET;91;75252;675;0.008969861;1.327249612;-0.327249612
insDEPET;06;158986;1366;0.008591951;1.271331178;-0.271331178
insDEPET;62;87566;730;0.008336569;1.23354282;-0.23354282
insDEPET;54;50761;411;0.008096767;1.198059904;-0.198059904
insDEPET;90;9792;79;0.00806781;1.193775242;-0.193775242
insDEPET;42;68973;550;0.007974135;1.179914273;-0.179914273
insDEPET;60;52888;420;0.00794131;1.175057253;-0.175057253
insDEPET;92;147353;1169;0.00793333;1.173876504;-0.173876504
insDEPET;68;61653;481;0.007801729;1.154403789;-0.154403789
insDEPET;72;43306;332;0.007666374;1.134375644;-0.134375644
insDEPET;31;116009;868;0.007482178;1.107120578;-0.107120578
insDEPET;02;39818;295;0.00740871;1.096249618;-0.096249618
insDEPET;78;101841;754;0.007403698;1.095508047;-0.095508047
insDEPET;67;93946;692;0.007365934;1.089920151;-0.089920151
insDEPET;28;34301;252;0.007346725;1.087077834;-0.087077834
insDEPET;33;152528;1107;0.007257684;1.07390268;-0.07390268
insDEPET;84;67613;488;0.007217547;1.067963714;-0.067963714
insDEPET;83;126540;909;0.007183499;1.062925765;-0.062925765
insDEPET;66;58946;419;0.007108201;1.051784011;-0.051784011
insDEPET;18;27790;193;0.006944944;1.027627324;-0.027627324
insDEPET;69;174961;1214;0.006938689;1.026701782;-0.026701782
insDEPET;88;34443;238;0.006909967;1.022451853;-0.022451853
insDEPET;30;76395;525;0.006872177;1.0168602;-0.0168602
insDEPET;08;23202;157;0.006766658;1.001246731;-0.001246731
insDEPET;87;34338;231;0.006727241;0.995414275;0.004585725
insDEPET;76;86118;579;0.006723333;0.994836039;0.005163961
insDEPET;26;53631;358;0.006675244;0.987720376;0.012279624
insDEPET;34;133650;876;0.006554433;0.969844315;0.030155685
insDEPET;2A;17005;111;0.006527492;0.965857872;0.034142128
insDEPET;25;44175;286;0.00647425;0.95797981;0.04202019
insDEPET;38;119307;770;0.006453938;0.954974293;0.045025707
insDEPET;41;28978;186;0.006418662;0.949754625;0.050245375
insDEPET;45;49561;318;0.006416335;0.949410303;0.050589697
insDEPET;2B;19519;124;0.006352784;0.940006815;0.059993185
insDEPET;70;21399;132;0.006168513;0.912740526;0.087259474
insDEPET;37;49723;305;0.006133982;0.907631159;0.092368841
insDEPET;55;17276;105;0.006077796;0.899317376;0.100682624
insDEPET;27;45311;273;0.006025027;0.891509307;0.108490693
insDEPET;39;26947;162;0.006011801;0.889552272;0.110447728
insDEPET;80;42871;257;0.005994728;0.887026083;0.112973917
insDEPET;47;40592;242;0.005961766;0.882148698;0.117851302
insDEPET;82;27230;159;0.005839148;0.864005216;0.135994784
insDEPET;36;23734;137;0.00577231;0.854115317;0.145884683
insDEPET;63;65589;373;0.005686929;0.841481754;0.158518246
insDEPET;89;33216;188;0.005659923;0.837485697;0.162514303
insDEPET;52;16860;94;0.005575326;0.824968117;0.175031883
insDEPET;24;51134;284;0.005554034;0.821817631;0.178182369
insDEPET;58;22345;123;0.005504587;0.814501022;0.185498978
insDEPET;17;75422;415;0.005502373;0.814173445;0.185826555
insDEPET;71;55680;306;0.00549569;0.813184479;0.186815521
insDEPET;03;34938;192;0.005495449;0.813148882;0.186851118
insDEPET;21;53379;290;0.005432848;0.803885963;0.196114037
insDEPET;49;68055;368;0.005407391;0.800119144;0.199880856
insDEPET;11;55513;300;0.00540414;0.799638025;0.200361975
insDEPET;86;38412;205;0.005336874;0.789684879;0.210315121
insDEPET;51;65810;346;0.00525756;0.777948932;0.222051068
insDEPET;56;72609;378;0.005205966;0.770314771;0.229685229
insDEPET;07;33636;169;0.005024379;0.74344568;0.25655432
insDEPET;44;106703;532;0.004985802;0.73773754;0.26226246
insDEPET;01;51685;255;0.004933733;0.730033082;0.269966918
insDEPET;10;30663;149;0.004859277;0.71901592;0.28098408
insDEPET;14;64428;310;0.004811573;0.711957263;0.288042737
insDEPET;19;30160;144;0.004774536;0.706477014;0.293522986
insDEPET;16;39889;190;0.004763218;0.704802333;0.295197667
insDEPET;73;71454;339;0.004744311;0.702004723;0.297995277
insDEPET;81;40986;194;0.004733324;0.700378935;0.299621065
insDEPET;35;90680;422;0.004653727;0.688601272;0.311398728
insDEPET;29;86330;400;0.004633384;0.685591038;0.314408962
insDEPET;61;32758;149;0.004548507;0.673032089;0.326967911
insDEPET;74;93707;423;0.00451407;0.667936558;0.332063442
insDEPET;09;17626;79;0.004482015;0.663193417;0.336806583
insDEPET;79;37656;162;0.004302103;0.636572261;0.363427739
insDEPET;64;83756;359;0.00428626;0.634227986;0.365772014
insDEPET;23;16174;68;0.004204278;0.622097355;0.377902645
insDEPET;50;52775;219;0.004149692;0.614020335;0.385979665
insDEPET;04;22787;90;0.00394962;0.58441619;0.41558381
insDEPET;40;49541;192;0.003875578;0.573460278;0.426539722
insDEPET;43;27370;105;0.003836317;0.567650968;0.432349032
insDEPET;22;64491;244;0.003783474;0.559831842;0.440168158
insDEPET;85;64417;243;0.003772296;0.558177928;0.441822072
insDEPET;46;26030;95;0.003649635;0.54002805;0.45997195
insDEPET;53;32932;120;0.003643872;0.539175339;0.460824661
insDEPET;99;40894;134;0.003276764;0.484855233;0.515144767
insDEPET;65;34146;104;0.003045745;0.450671801;0.549328199
insDEPET;32;32543;96;0.002949943;0.436496261;0.563503739
insDEPET;15;22199;62;0.002792919;0.413261701;0.586738299
insDEPET;05;25212;70;0.002776456;0.410825718;0.589174282
insDEPET;48;12747;34;0.002667294;0.394673359;0.605326641
insDEPET;98;775;2;0.002580645;0.381852092;0.618147908
insDEPET;12;41281;104;0.002519319;0.372777775;0.627222225
insDEPCOMEN;75120;23391;422;0.018041127;2.669503799;-1.669503799
insDEPCOMEN;75110;28336;491;0.017327781;2.56395164;-1.56395164
insDEPCOMEN;75102;19124;292;0.015268772;2.259284889;-1.259284889
insDEPCOMEN;75103;14002;144;0.010284245;1.521735947;-0.521735947
insDEPCOMEN;75112;23538;238;0.010111309;1.496147047;-0.496147047
insDEPCOMEN;75119;18558;185;0.009968747;1.475052368;-0.475052368
insDEPCOMEN;75109;30187;288;0.009540531;1.411690247;-0.411690247
insDEPCOMEN;75111;32950;296;0.008983308;1.329239301;-0.329239301
insDEPCOMEN;75101;16952;132;0.007786692;1.15217877;-0.15217877
insDEPCOMEN;75118;26179;197;0.007525116;1.113473932;-0.113473932
insDEPCOMEN;75114;21520;154;0.007156134;1.058876561;-0.058876561
insDEPCOMEN;75108;66310;446;0.006725984;0.995228288;0.004771712
insDEPCOMEN;75117;41679;278;0.006670026;0.986948262;0.013051738
insDEPCOMEN;75115;36833;223;0.006054353;0.895848666;0.104151334
insDEPCOMEN;75113;19497;113;0.005795763;0.857585705;0.142414295
insDEPCOMEN;75104;10380;51;0.004913295;0.72700886;0.27299114
insDEPCOMEN;75105;14528;71;0.004887115;0.723135028;0.276864972
insDEPCOMEN;75116;48424;220;0.004543202;0.672247044;0.327752956
insDEPCOMEN;75106;16345;72;0.004405017;0.651800145;0.348199855
insDEPCOMEN;75107;18645;59;0.003164387;0.468227056;0.531772944
insDEPCOMEN,3;974;61141;402;0.006574966;0.972882512;0.027117488
insDEPCOMEN,3;972;42850;261;0.006091015;0.901273418;0.098726582
insDEPCOMEN,3;971;63190;307;0.004858364;0.718880828;0.281119172
insDEPCOMEN,3;973;13285;63;0.00474219;0.701690944;0.298309056
insCJ,2;54;1046180;26431;0.025264295;3.738299821;-2.738299821
insCJ,2;55;116455;1676;0.014391825;2.129525393;-1.129525393
insCJ,2;13;332350;4569;0.013747555;2.034194255;-1.034194255
insCJ,2;56;6079;81;0.01332456;1.971604606;-0.971604606
insCJ,2;57;68076;864;0.012691698;1.8779614;-0.8779614
insCJ,2;12;437093;5064;0.011585635;1.714299878;-0.714299878
insCJ,2;11;197912;2096;0.010590566;1.567061711;-0.567061711
insCJ,2;82;5102;51;0.00999608;1.479097048;-0.479097048
insCJ,2;31;11814;115;0.009734214;1.440349288;-0.440349288
insCJ,2;53;1525;13;0.00852459;1.261364073;-0.261364073
insCJ,2;52;38818;186;0.004791592;0.709000819;0.290999181
insCJ,2;51;517;1;0.001934236;0.286204465;0.713795535
insCJ,2;92;417094;658;0.001577582;0.233431198;0.766568802
insCJ,2;62;10141;12;0.001183315;0.175092447;0.824907553
insCJ,2;17;40919;39;0.000953102;0.141028389;0.858971611
insCJ,2;16;558658;471;0.000843092;0.124750367;0.875249633
insCJ,2;65;1134849;828;0.000729612;0.107959088;0.892040912
insCJ,2;32;26976;19;0.00070433;0.104218063;0.895781937
insCJ,2;29;24080;14;0.000581395;0.086027738;0.913972262
insCJ,2;84;8634;5;0.000579106;0.085688967;0.914311033
insCJ,2;63;20101;6;0.000298493;0.044167268;0.955832732
insCJ,2;19;511880;129;0.000252012;0.037289666;0.962710334
insCJ,2;15;577704;133;0.000230222;0.034065378;0.965934622
insCJ,2;18;497265;107;0.000215177;0.03183925;0.96816075
insCJ,2;22;29402;3;0.000102034;0.015097719;0.984902281
insCJ,2;21;24477;1;4.08547E-05;0.006045173;0.993954827
insCJ,2;10;1;0;0;0;1
insCJ,2;14;6117;0;0;0;1
insCJ,2;23;7434;0;0;0;1
insCJ,2;27;527;0;0;0;1
insCJ,2;41;874;0;0;0;1
insCJ,2;61;17;0;0;0;1
insCJ,2;64;178;0;0;0;1
insCJ,2;69;2;0;0;0;1
insCJ,2;71;2984;0;0;0;1
insCJ,2;72;36821;0;0;0;1
insCJ,2;73;91862;0;0;0;1
insCJ,2;74;2566;0;0;0;1
insCJ,2;81;1202;0;0;0;1
insCJ,2;83;4849;0;0;0;1
insCJ,2;91;145682;0;0;0;1
insCJ,2;93;461;0;0;0;1
insCJ,2;99;1571;0;0;0;1
ageDirigeant;0;4092989;11244;0.002747137;0.406487512;0.593512488
ageDirigeant;1;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;2;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;3;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;4;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;5;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;6;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;7;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;8;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;9;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;10;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;11;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;12;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;13;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;14;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;15;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;16;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;17;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;18;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;19;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;20;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;21;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;22;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;23;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;24;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;25;7915;339;0.042830069;6.337467242;-5.337467242
ageDirigeant;26;51311;1744;0.033988813;5.029246825;-4.029246825
ageDirigeant;27;51311;1744;0.033988813;5.029246825;-4.029246825
ageDirigeant;28;51311;1744;0.033988813;5.029246825;-4.029246825
ageDirigeant;29;51311;1744;0.033988813;5.029246825;-4.029246825
ageDirigeant;30;132700;3421;0.025779955;3.814600838;-2.814600838
ageDirigeant;31;132700;3421;0.025779955;3.814600838;-2.814600838
ageDirigeant;32;132700;3421;0.025779955;3.814600838;-2.814600838
ageDirigeant;33;132700;3421;0.025779955;3.814600838;-2.814600838
ageDirigeant;34;132700;3421;0.025779955;3.814600838;-2.814600838
ageDirigeant;35;246272;4538;0.01842678;2.726568435;-1.726568435
ageDirigeant;36;246272;4538;0.01842678;2.726568435;-1.726568435
ageDirigeant;37;246272;4538;0.01842678;2.726568435;-1.726568435
ageDirigeant;38;246272;4538;0.01842678;2.726568435;-1.726568435
ageDirigeant;39;246272;4538;0.01842678;2.726568435;-1.726568435
ageDirigeant;40;339245;5421;0.015979602;2.364465057;-1.364465057
ageDirigeant;41;339245;5421;0.015979602;2.364465057;-1.364465057
ageDirigeant;42;339245;5421;0.015979602;2.364465057;-1.364465057
ageDirigeant;43;339245;5421;0.015979602;2.364465057;-1.364465057
ageDirigeant;44;339245;5421;0.015979602;2.364465057;-1.364465057
ageDirigeant;45;367968;5217;0.014177863;2.097865945;-1.097865945
ageDirigeant;46;367968;5217;0.014177863;2.097865945;-1.097865945
ageDirigeant;47;367968;5217;0.014177863;2.097865945;-1.097865945
ageDirigeant;48;367968;5217;0.014177863;2.097865945;-1.097865945
ageDirigeant;49;367968;5217;0.014177863;2.097865945;-1.097865945
ageDirigeant;50;375026;4591;0.012241818;1.811393744;-0.811393744
ageDirigeant;51;375026;4591;0.012241818;1.811393744;-0.811393744
ageDirigeant;52;375026;4591;0.012241818;1.811393744;-0.811393744
ageDirigeant;53;375026;4591;0.012241818;1.811393744;-0.811393744
ageDirigeant;54;375026;4591;0.012241818;1.811393744;-0.811393744
ageDirigeant;55;377653;3778;0.010003892;1.480253045;-0.480253045
ageDirigeant;56;377653;3778;0.010003892;1.480253045;-0.480253045
ageDirigeant;57;377653;3778;0.010003892;1.480253045;-0.480253045
ageDirigeant;58;377653;3778;0.010003892;1.480253045;-0.480253045
ageDirigeant;59;377653;3778;0.010003892;1.480253045;-0.480253045
ageDirigeant;60;232451;2003;0.00861687;1.275018479;-0.275018479
ageDirigeant;61;232451;2003;0.00861687;1.275018479;-0.275018479
ageDirigeant;62;232451;2003;0.00861687;1.275018479;-0.275018479
ageDirigeant;63;232451;2003;0.00861687;1.275018479;-0.275018479
ageDirigeant;64;232451;2003;0.00861687;1.275018479;-0.275018479
ageDirigeant;65;100941;680;0.006736609;0.996800526;0.003199474
ageDirigeant;66;100941;680;0.006736609;0.996800526;0.003199474
ageDirigeant;67;100941;680;0.006736609;0.996800526;0.003199474
ageDirigeant;68;100941;680;0.006736609;0.996800526;0.003199474
ageDirigeant;69;100941;680;0.006736609;0.996800526;0.003199474
ageDirigeant;70;55612;320;0.005754154;0.85142895;0.14857105
ageDirigeant;71;55612;320;0.005754154;0.85142895;0.14857105
ageDirigeant;72;55612;320;0.005754154;0.85142895;0.14857105
ageDirigeant;73;55612;320;0.005754154;0.85142895;0.14857105
ageDirigeant;74;55612;320;0.005754154;0.85142895;0.14857105
ageDirigeant;75;33744;164;0.004860123;0.719141306;0.280858694
ageDirigeant;76;33744;164;0.004860123;0.719141306;0.280858694
ageDirigeant;77;33744;164;0.004860123;0.719141306;0.280858694
ageDirigeant;78;33744;164;0.004860123;0.719141306;0.280858694
ageDirigeant;79;33744;164;0.004860123;0.719141306;0.280858694
ageDirigeant;80;19900;73;0.003668342;0.542796117;0.457203883
ageDirigeant;81;19900;73;0.003668342;0.542796117;0.457203883
ageDirigeant;82;19900;73;0.003668342;0.542796117;0.457203883
ageDirigeant;83;19900;73;0.003668342;0.542796117;0.457203883
ageDirigeant;84;19900;73;0.003668342;0.542796117;0.457203883
ageDirigeant;*;13522;39;0.002884189;0.426766798;0.573233202
ageEntreprise;0;398545;3931;0,009863378;1,45812286;-0.45812286
ageEntreprise;1;363230;5849;0.016102745;2.380500904;-1.380500904
ageEntreprise;2;336945;5474;0.016245975;2.401674887;-1.401674887
ageEntreprise;3;320242;4323;0.013499166;1.995608689;-0.995608689
ageEntreprise;4;311256;3186;0.010235947;1.513200512;-0.513200512
ageEntreprise;5;286481;2597;0.009065174;1.340122706;-0.340122706
ageEntreprise;6;271422;2131;0.007851243;1.16066488;-0.16066488
ageEntreprise;7;249689;1696;0.00679245;1.004141411;-0.004141411
ageEntreprise;8;299828;1471;0.004906146;0.725285383;0.274714617
ageEntreprise;9;251098;1368;0.005448072;0.805399367;0.194600633
ageEntreprise;10;224326;1088;0.004850084;0.716997635;0.283002365
ageEntreprise;11;225543;1016;0.004504684;0.665936463;0.334063537
ageEntreprise;12;219141;911;0.004157141;0.614558427;0.385441573
ageEntreprise;13;227433;890;0.00391324;0.578502136;0.421497864
ageEntreprise;14;228796;849;0.003710729;0.548564505;0.451435495
ageEntreprise;15;203213;738;0.003631657;0.536875165;0.463124835
ageEntreprise;16;195413;723;0.003699856;0.546957126;0.453042874
ageEntreprise;17;156467;621;0.003968888;0.586728635;0.413271365
ageEntreprise;18;136150;578;0.004245318;0.627593783;0.372406217
ageEntreprise;19;120966;421;0.003480317;0.514502176;0.485497824
ageEntreprise;20;110350;344;0.003117354;0.460844645;0.539155355
ageEntreprise;21;108829;314;0.00288526;0.426533798;0.573466202
ageEntreprise;22;92057;306;0.003324028;0.49139762;0.50860238
ageEntreprise;23;94394;225;0.002383626;0.3523762;0.6476238
ageEntreprise;24;61811;133;0.002151721;0.318093146;0.681906854
ageEntreprise;25;86450;215;0.002486987;0.367656207;0.632343793
ageEntreprise;26;79203;222;0.002802924;0.414361868;0.585638132
ageEntreprise;27;41020;131;0.003193564;0.472110957;0.527889043
ageEntreprise;28;37137;119;0.003204351;0.473705671;0.526294329
ageEntreprise;29;30627;110;0.003591602;0.530953718;0.469046282
ageEntreprise;30;27785;106;0.003815008;0.563980261;0.436019739
ageEntreprise;31;27100;87;0.003210332;0.474589802;0.525410198
ageEntreprise;32;26851;86;0.00320286;0.47348522;0.52651478
ageEntreprise;33;21279;48;0.002255745;0.3334713;0.6665287
ageEntreprise;34;17287;42;0.002429571;0.359168382;0.640831618
ageEntreprise;35;20082;45;0.002240813;0.331263809;0.668736191
ageEntreprise;36;24005;33;0.001374714;0.203226655;0.796773345
ageEntreprise;37;10981;36;0.00327839;0.484650929;0.515349071
ageEntreprise;38;14152;43;0.00303844;0.449178619;0.550821381
ageEntreprise;39;17017;67;0.003937239;0.582049933;0.417950067
ageEntreprise;40;31055;102;0.003284495;0.485553488;0.514446512
ageEntreprise;41;15175;43;0.002833608;0.418897912;0.581102088
ageEntreprise;42;6992;15;0.002145309;0.3171453;0.6828547
ageEntreprise;43;6310;14;0.0022187;0.327994919;0.672005081
ageEntreprise;44;7244;15;0.002070679;0.306112636;0.693887364
ageEntreprise;45;5863;13;0.002217295;0.32778713;0.67221287
ageEntreprise;46;7647;52;0.006800052;1.005265304;-0.005265304
ageEntreprise;47;9466;55;0.005810268;0.858943563;0.141056437
ageEntreprise;48;6119;35;0.005719889;0.845582587;0.154417413
ageEntreprise;49;6031;41;0.006798209;1.004992841;-0.004992841
ageEntreprise;50;4954;22;0.004440856;0.656500587;0.343499413
ageEntreprise;51;12623;11;0.000871425;0.128824523;0.871175477
ageEntreprise;*;353169;621;0.001758365;0.259942604;0.740057396
insTEFEN;11;122483;2586;0.021113134;3.12406207;-2.12406207
insTEFEN;2;348140;6830;0.019618544;2.902911041;-1.902911041
insTEFEN;3;178988;3509;0.019604666;2.900857541;-1.900857541
insTEFEN;12;77324;1239;0.016023486;2.370958447;-1.370958447
insTEFEN;1;946071;14717;0.015555915;2.301773089;-1.301773089
insTEFEN;21;22652;290;0.012802402;1.894342023;-0.894342023
insTEFEN;22;11018;103;0.009348339;1.383252313;-0.383252313
insTEFEN;31;2325;13;0.005591398;0.827346328;0.172653672
insTEFEN;0;4729670;14264;0.003015855;0.446249188;0.553750812
insTEFEN;32;4541;13;0.002862806;0.423602777;0.576397223
insTEFEN;41;2251;6;0.002665482;0.394405265;0.605594735
insTEFEN;51;492;1;0.00203252;0.300747375;0.699252625
insTEFEN;42;1121;1;0.000892061;0.131996172;0.868003828
insTEFEN;52;172;0;0;0;1
insTEFEN;53;1;0;0;0;1
insNBTOA;13;445;8;0.017977528;2.660093638;-1.660093638
insNBTOA;2;199031;2816;0.01414855;2.093528483;-1.093528483
insNBTOA;3;38973;413;0.01059708;1.56802565;-0.56802565
insNBTOA;1;3755472;38870;0.01035023;1.531499858;-0.531499858
insNBTOA;8;1595;15;0.009404389;1.391545849;-0.391545849
insNBTOA;11;743;6;0.00807537;1.194894013;-0.194894013
insNBTOA;4;14851;119;0.008012928;1.185654658;-0.185654658
insNBTOA;7;2443;19;0.007777323;1.150792658;-0.150792658
insNBTOA;20-25;949;7;0.007376185;1.091437261;-0.091437261
insNBTOA;10;869;6;0.006904488;1.021641256;-0.021641256
insNBTOA;5;7090;46;0.006488011;0.960016163;0.039983837
insNBTOA;6;3905;24;0.006145967;0.909404611;0.090595389
insNBTOA;9;1144;6;0.005244755;0.776054416;0.223945584
insNBTOA;14;412;2;0.004854369;0.718289848;0.281710152
insNBTOA;75-99;225;1;0.004444444;0.657634261;0.342365739
insNBTOA;35-49;639;2;0.00312989;0.463122719;0.536877281
insNBTOA;50-74;424;1;0.002358491;0.348980445;0.651019555
insNBTOA;15-19;1445;3;0.002076125;0.307199395;0.692800605
insNBTOA;12;626;1;0.001597444;0.236370142;0.763629858
insNBTOA;26-34;793;1;0.001261034;0.186592319;0.813407681
insNBTOA;0;2414681;1206;0.000499445;0.073901711;0.926098289
insNBTOA;100-;494;0;0;0;1
insTCA;2;21622;409;0.018915919;2.798369096;-1.798369096
insTCA;3;28973;507;0.017499051;2.588761516;-1.588761516
insTCA;1;20023;348;0.017380013;2.571151383;-1.571151383
insTCA;4;15955;207;0.012973989;1.919336348;-0.919336348
insTCA;5;10403;89;0.008555224;1.265636407;-0.265636407
insTCA;6;7600;51;0.006710526;0.992736831;0.007263169
insTCA;0;6337365;41952;0.006619786;0.979312956;0.020687044
insTCA;7;2667;7;0.002624672;0.388286754;0.611713246
insTCA;9;1314;2;0.00152207;0.225170857;0.774829143
insTCA;8;1327;0;0;0;1
insTCAEXPOR;3;5258;109;0.020730316;3.066785966;-2.066785966
insTCAEXPOR;2;12013;215;0.017897278;2.647674141;-1.647674141
insTCAEXPOR;1;10029;173;0.017249975;2.551913931;-1.551913931
insTCAEXPOR;4;5589;88;0.015745214;2.329303684;-1.329303684
insTCAEXPOR;0;6414360;42987;0.006701682;0.991428405;0.008571595
insSEXE;M;2233981;9893;0.004428417;0.655262754;0.344737246
insSEXE;F;923849;2714;0.002937710;0.434686146;0.565313854
insSEXE;*;3289419;30965;0.009413516;1.392896465;-0.392896465
insRECME;0;6445782;43572;0.006759769;1.000227591;-0.000227591
insRECME;1;1467;0;0.000000000;0;1
insMONOREG;1;78856;935;0.011857056;1.754461392;-0.754461392
insMONOREG;2;6170828;41393;0.006707852;0.992545468;0.007454532
insMONOREG;0;197565;1244;0.006296662;0.931702627;0.068297373
insRPET;11;1205539;10949;0.009082245;1.343874119;-0.343874119
insRPET;31;252996;2234;0.008830179;1.306576712;-0.306576712
insRPET;41;170366;1448;0.008499348;1.25762463;-0.25762463
insRPET;93;599741;4858;0.008100163;1.198558318;-0.198558318
insRPET;42;155599;1173;0.007538609;1.1154667;-0.1154667
insRPET;22;135577;972;0.007169358;1.060829637;-0.060829637
insRPET;4;60943;402;0.006596328;0.976040016;0.023959984
insRPET;24;214087;1391;0.006497359;0.961395827;0.038604173
insRPET;23;131429;852;0.006482588;0.959210205;0.040789795
insRPET;43;102313;659;0.006441019;0.953059456;0.046940544
insRPET;94;36450;234;0.006419753;0.949912765;0.050087235
insRPET;91;337251;2154;0.006386934;0.945056671;0.054943329
insRPET;82;667354;4078;0.0061107;0.904183032;0.095816968
insRPET;2;42948;261;0.006077117;0.899213798;0.100786202
insRPET;72;377551;2184;0.005784649;0.855938198;0.144061802
insRPET;26;164649;907;0.005508688;0.81510506;0.18489494
insRPET;74;80672;443;0.005491372;0.812542903;0.187457097
insRPET;21;136535;746;0.0054638;0.808463155;0.191536845
insRPET;54;191379;972;0.005078927;0.751514532;0.248485468
insRPET;73;335852;1699;0.005058776;0.748532806;0.251467194
insRPET;52;315413;1595;0.005056862;0.748249607;0.251750393
insRPET;83;150096;732;0.004876879;0.721618007;0.278381993
insRPET;1;63134;307;0.004862673;0.719516021;0.280483979
insRPET;3;13275;63;0.004745763;0.702217129;0.297782871
insRPET;53;314133;1445;0.004599962;0.680643473;0.319356527
insRPET;25;149961;678;0.004521176;0.668985593;0.331014407
insRPET;99;41208;134;0.003251796;0.481159052;0.518840948
insRPET;98;775;2;0.002580645;0.381850789;0.618149211
insSINGT;43;23550;425;0.018046709;2.670330198;-1.670330198
insSINGT;2;76142;1237;0.016245961;2.403877696;-1.403877696
insSINGT;1;3885595;40481;0.010418224;1.541560768;-0.541560768
insSINGT;40;13737;119;0.008662736;1.281805149;-0.281805149
insSINGT;31;35843;96;0.002678347;0.396308903;0.603691097
insSINGT;33;3315;8;0.002413273;0.357086476;0.642913524
insSINGT;52;6565;10;0.001523229;0.225388741;0.774611259
insSINGT;10;96382;127;0.001317673;0.194973117;0.805026883
insSINGT;60;216663;228;0.001052326;0.155710193;0.844289807
insSINGT;90;577496;260;0.00045022;0.066617958;0.933382042
insSINGT;70;1298907;576;0.00044345;0.065616245;0.934383755
insSINGT;34;24032;1;4.16112E-05;0.006157112;0.993842888
insSINGT;80;149852;4;2.6693E-05;0.003949703;0.996050297
insSINGT;0;1;;0;0;1
insSINGT;30;5741;0;0;0;1
insSINGT;42;33428;0;0;0;1
insORDIN;1;3412206;41477;0.012155479;1.798618445;-0.798618445
insORDIN;0;3035043;2095;0.00069027;0.102137713;0.897862287
insMODET;3;2787;130;0.046645138;6.901974209;-5.901974209
insMODET;1;991;19;0.019172553;2.836918732;-1.836918732
insMODET;2;3347;45;0.013444876;1.989407496;-0.989407496
insMODET;0;6440124;43378;0.006735585;0.996649019;0.003350981
insAUXILT;1;26364;474;0.017979062;2.66032066;-1.66032066
insAUXILT;0;6420872;43098;0.006712172;0.993184774;0.006815226
insAUXILT;*;13;0;0;0;1
insTCD;73;83653;867;0.010364243;1.533573253;-0.533573253
insTCD;44;207816;2036;0.009797128;1.449658615;-0.449658615
insTCD;52;189137;1814;0.009590931;1.419148149;-0.419148149
insTCD;43;241634;2262;0.009361265;1.385164989;-0.385164989
insTCD;62;114691;1056;0.009207348;1.362390251;-0.362390251
insTCD;41;193192;1687;0.008732246;1.292090379;-0.292090379
insTCD;51;286358;2499;0.008726838;1.291290286;-0.291290286
insTCD;72;161502;1371;0.008489059;1.256106603;-0.256106603
insTCD;80;520175;4329;0.008322199;1.231416755;-0.231416755
insTCD;42;173427;1427;0.008228246;1.21751469;-0.21751469
insTCD;61;258193;2063;0.007990147;1.182283729;-0.182283729
insTCD;31;307323;2413;0.007851674;1.161794206;-0.161794206
insTCD;32;256048;1919;0.007494688;1.108971884;-0.108971884
insTCD;71;137763;984;0.007142702;1.056889189;-0.056889189
insTCD;22;291665;2073;0.007107469;1.051675929;-0.051675929
insTCD;21;317427;2113;0.006656649;0.984969043;0.015030957
insTCD;18;197044;1301;0.006602586;0.976969555;0.023030445
insTCD;17;257376;1549;0.006018432;0.890533619;0.109466381
insTCD;15;199766;1128;0.005646607;0.83551543;0.16448457
insTCD;16;172805;968;0.00560169;0.828869199;0.171130801
insTCD;14;249738;1244;0.00498122;0.737059757;0.262940243
insTCD;0;120431;578;0.004799429;0.71016047;0.28983953
insTCD;13;342501;1623;0.004738672;0.701170482;0.298829518
insTCD;12;272656;1158;0.00424711;0.628435122;0.371564878
insTCD;11;245321;1022;0.00416597;0.616429079;0.383570921
insTCD;8;125432;481;0.003834747;0.567418744;0.432581256
insTCD;7;149718;535;0.003573385;0.528745536;0.471254464
insTCD;6;81869;265;0.003236878;0.478953484;0.521046516
insTCD;4;81356;256;0.003146664;0.465604668;0.534395332
insTCD;5;84330;243;0.002881537;0.426374401;0.573625599
insTCD;3;74476;200;0.002685429;0.397356756;0.602643244
insTCD;2;43091;94;0.00218143;0.322781198;0.677218802
insTCD;1;9335;14;0.001499732;0.221911936;0.778088064
insNATURE;91;238972;6564;0.027467653;4.064325692;-3.064325692
insNATURE;20;144873;3353;0.023144409;3.424625203;-2.424625203
insNATURE;22;10828;119;0.010990026;1.626168944;-0.626168944
insNATURE;93;160570;1367;0.008513421;1.259711389;-0.259711389
insNATURE;21;185819;1501;0.008077753;1.195246614;-0.195246614
insNATURE;92;83924;635;0.00756637;1.119578368;-0.119578368
insNATURE;99;5621113;30028;0.005342003;0.790443877;0.209556123
insNATURE;23;1135;5;0.004405286;0.651840126;0.348159874
insNATURE;*;15;0;0;0;1
insORIGINE;3;296615;3962;0.013357382;1.976461277;-0.976461277
insORIGINE;7;112298;1480;0.01317922;1.950098922;-0.950098922
insORIGINE;2;907819;9870;0.010872211;1.608736195;-0.608736195
insORIGINE;5;54475;462;0.008480955;1.254907414;-0.254907414
insORIGINE;6;1914;11;0.005747126;0.85038913;0.14961087
insORIGINE;1;4776418;27127;0.005679361;0.840361968;0.159638032
insORIGINE;8;90133;230;0.002551785;0.377581718;0.622418282
insORIGINE;0;173492;370;0.002132663;0.315565284;0.684434716
insORIGINE;4;34085;60;0.001760305;0.260468315;0.739531685
insTU;8;1084479;9960;0.009184134;1.358955201;-0.358955201
insTU;7;1259040;10827;0.008599409;1.272434856;-0.272434856
insTU;5;399066;3189;0.007991159;1.182433539;-0.182433539
insTU;6;378843;2890;0.00762849;1.128770171;-0.128770171
insTU;4;410877;2959;0.007201669;1.065614405;-0.065614405
insTU;3;331773;2090;0.006299488;0.93212079;0.06787921
insTU;2;343704;2076;0.006040081;0.893736945;0.106263055
insTU;1;375638;2186;0.005819433;0.861088098;0.138911902
insTU;0;1863829;7395;0.003967639;0.587082401;0.412917599
1 codeZone valeur NBEntreprises NbProCol Pourcentage Risque Points
2 GLOBALE TOTAL 6447249 43572 0.006758231 0.006758231 0
3 insAPEN31 DB 18973 612 0.032256364 4.729218896 -3.729218896
4 insAPEN31 FA 367665 9644 0.0262304 3.845731092 -2.845731092
5 insAPEN31 DJ 32346 786 0.024299759 3.562673018 -2.562673018
6 insAPEN31 DM 5682 132 0.023231257 3.406016148 -2.406016148
7 insAPEN31 DC 2430 55 0.022633745 3.318412852 -2.318412852
8 insAPEN31 DE 36701 740 0.020162938 2.956159228 -1.956159228
9 insAPEN31 DH 5546 111 0.020014425 2.934385137 -1.934385137
10 insAPEN31 DD 11292 225 0.019925611 2.92136384 -1.92136384
11 insAPEN31 DK 17243 334 0.019370179 2.839930026 -1.839930026
12 insAPEN31 HA 242687 4586 0.018896768 2.770521585 -1.770521585
13 insAPEN31 IA 111075 1916 0.017249606 2.529025356 -1.529025356
14 insAPEN31 DL 20515 323 0.015744577 2.308367769 -1.308367769
15 insAPEN31 GA 693458 10740 0.0154876 2.270691423 -1.270691423
16 insAPEN31 DI 9391 138 0.014694921 2.154473946 -1.154473946
17 insAPEN31 DA 69613 995 0.014293307 2.095591997 -1.095591997
18 insAPEN31 DG 4389 61 0.013898382 2.037690661 -1.037690661
19 insAPEN31 DN 33557 435 0.012963018 1.900553633 -0.900553633
20 insAPEN31 ZZ 16576 119 0.007179054 1.052546337 -0.052546337
21 insAPEN31 CB 2833 17 0.006000706 0.879784584 0.120215416
22 insAPEN31 GG 9721 52 0.005349244 0.784271442 0.215728558
23 insAPEN31 MA 70612 373 0.005282388 0.774469502 0.225530498
24 insAPEN31 FF 4750 25 0.005263158 0.77165007 0.22834993
25 insAPEN31 CA 195 1 0.005128205 0.751864171 0.248135829
26 insAPEN31 HH 3757 16 0.004258717 0.62438547 0.37561453
27 insAPEN31 JA 72234 289 0.004000886 0.586583954 0.413416046
28 insAPEN31 OA 611504 2075 0.003393273 0.497499673 0.502500327
29 insAPEN31 KA 2657556 7102 0.00267238 0.391807048 0.608192952
30 insAPEN31 BA 14187 37 0.002608021 0.382371184 0.617628816
31 insAPEN31 OO 2450 6 0.00244898 0.359053502 0.640946498
32 insAPEN31 II 1476 3 0.00203252 0.297994946 0.702005054
33 insAPEN31 KK 22395 40 0.001786113 0.261868298 0.738131702
34 insAPEN31 AA 777002 1339 0.00172329 0.252657643 0.747342357
35 insAPEN31 EA 5687 7 0.001230877 0.180463266 0.819536734
36 insAPEN31 NA 432746 238 0.000549976 0.080633943 0.919366057
37 insAPEN31 BB 81 0 0 1
38 insAPEN31 DF 149 0 0 1
39 insAPEN31 EE 79 0 0 1
40 insAPEN31 JJ 596 0 0 1
41 insAPEN31 LA 56364 0 0 1
42 insAPEN31 LL 79 0 0 1
43 insAPEN31 MM 343 0 0 1
44 insAPEN31 NN 772 0 0 1
45 insAPEN31 PA 32 0 0 1
46 insAPEN31 QA 510 0 0 1
47 insMONOACT 1 57315 535 0.00933438 1.368546272 -0.368546272
48 insMONOACT 2 6175850 41794 0.006767328 0.992181671 0.007818329
49 insMONOACT 0 214084 1243 0.005806132 0.851257436 0.148742564
50 insSAISONAT 0 6422146 43477 0.006769855 0.99255229 0.00744771
51 insSAISONAT 1 25103 95 0.003784408 0.554845387 0.445154613
52 insDEPET 93 99100 1332 0.013440969 1.988829034 -0.988829034
53 insDEPET 77 87496 937 0.010709061 1.58459497 -0.58459497
54 insDEPET 94 94293 975 0.01034011 1.530002158 -0.530002158
55 insDEPET 57 67886 694 0.010223021 1.51267675 -0.51267675
56 insDEPET 95 72827 735 0.010092411 1.493350666 -0.493350666
57 insDEPET 13 198603 1935 0.009743055 1.441657335 -0.441657335
58 insDEPET 59 165430 1504 0.009091459 1.345242092 -0.345242092
59 insDEPET 91 75252 675 0.008969861 1.327249612 -0.327249612
60 insDEPET 06 158986 1366 0.008591951 1.271331178 -0.271331178
61 insDEPET 62 87566 730 0.008336569 1.23354282 -0.23354282
62 insDEPET 54 50761 411 0.008096767 1.198059904 -0.198059904
63 insDEPET 90 9792 79 0.00806781 1.193775242 -0.193775242
64 insDEPET 42 68973 550 0.007974135 1.179914273 -0.179914273
65 insDEPET 60 52888 420 0.00794131 1.175057253 -0.175057253
66 insDEPET 92 147353 1169 0.00793333 1.173876504 -0.173876504
67 insDEPET 68 61653 481 0.007801729 1.154403789 -0.154403789
68 insDEPET 72 43306 332 0.007666374 1.134375644 -0.134375644
69 insDEPET 31 116009 868 0.007482178 1.107120578 -0.107120578
70 insDEPET 02 39818 295 0.00740871 1.096249618 -0.096249618
71 insDEPET 78 101841 754 0.007403698 1.095508047 -0.095508047
72 insDEPET 67 93946 692 0.007365934 1.089920151 -0.089920151
73 insDEPET 28 34301 252 0.007346725 1.087077834 -0.087077834
74 insDEPET 33 152528 1107 0.007257684 1.07390268 -0.07390268
75 insDEPET 84 67613 488 0.007217547 1.067963714 -0.067963714
76 insDEPET 83 126540 909 0.007183499 1.062925765 -0.062925765
77 insDEPET 66 58946 419 0.007108201 1.051784011 -0.051784011
78 insDEPET 18 27790 193 0.006944944 1.027627324 -0.027627324
79 insDEPET 69 174961 1214 0.006938689 1.026701782 -0.026701782
80 insDEPET 88 34443 238 0.006909967 1.022451853 -0.022451853
81 insDEPET 30 76395 525 0.006872177 1.0168602 -0.0168602
82 insDEPET 08 23202 157 0.006766658 1.001246731 -0.001246731
83 insDEPET 87 34338 231 0.006727241 0.995414275 0.004585725
84 insDEPET 76 86118 579 0.006723333 0.994836039 0.005163961
85 insDEPET 26 53631 358 0.006675244 0.987720376 0.012279624
86 insDEPET 34 133650 876 0.006554433 0.969844315 0.030155685
87 insDEPET 2A 17005 111 0.006527492 0.965857872 0.034142128
88 insDEPET 25 44175 286 0.00647425 0.95797981 0.04202019
89 insDEPET 38 119307 770 0.006453938 0.954974293 0.045025707
90 insDEPET 41 28978 186 0.006418662 0.949754625 0.050245375
91 insDEPET 45 49561 318 0.006416335 0.949410303 0.050589697
92 insDEPET 2B 19519 124 0.006352784 0.940006815 0.059993185
93 insDEPET 70 21399 132 0.006168513 0.912740526 0.087259474
94 insDEPET 37 49723 305 0.006133982 0.907631159 0.092368841
95 insDEPET 55 17276 105 0.006077796 0.899317376 0.100682624
96 insDEPET 27 45311 273 0.006025027 0.891509307 0.108490693
97 insDEPET 39 26947 162 0.006011801 0.889552272 0.110447728
98 insDEPET 80 42871 257 0.005994728 0.887026083 0.112973917
99 insDEPET 47 40592 242 0.005961766 0.882148698 0.117851302
100 insDEPET 82 27230 159 0.005839148 0.864005216 0.135994784
101 insDEPET 36 23734 137 0.00577231 0.854115317 0.145884683
102 insDEPET 63 65589 373 0.005686929 0.841481754 0.158518246
103 insDEPET 89 33216 188 0.005659923 0.837485697 0.162514303
104 insDEPET 52 16860 94 0.005575326 0.824968117 0.175031883
105 insDEPET 24 51134 284 0.005554034 0.821817631 0.178182369
106 insDEPET 58 22345 123 0.005504587 0.814501022 0.185498978
107 insDEPET 17 75422 415 0.005502373 0.814173445 0.185826555
108 insDEPET 71 55680 306 0.00549569 0.813184479 0.186815521
109 insDEPET 03 34938 192 0.005495449 0.813148882 0.186851118
110 insDEPET 21 53379 290 0.005432848 0.803885963 0.196114037
111 insDEPET 49 68055 368 0.005407391 0.800119144 0.199880856
112 insDEPET 11 55513 300 0.00540414 0.799638025 0.200361975
113 insDEPET 86 38412 205 0.005336874 0.789684879 0.210315121
114 insDEPET 51 65810 346 0.00525756 0.777948932 0.222051068
115 insDEPET 56 72609 378 0.005205966 0.770314771 0.229685229
116 insDEPET 07 33636 169 0.005024379 0.74344568 0.25655432
117 insDEPET 44 106703 532 0.004985802 0.73773754 0.26226246
118 insDEPET 01 51685 255 0.004933733 0.730033082 0.269966918
119 insDEPET 10 30663 149 0.004859277 0.71901592 0.28098408
120 insDEPET 14 64428 310 0.004811573 0.711957263 0.288042737
121 insDEPET 19 30160 144 0.004774536 0.706477014 0.293522986
122 insDEPET 16 39889 190 0.004763218 0.704802333 0.295197667
123 insDEPET 73 71454 339 0.004744311 0.702004723 0.297995277
124 insDEPET 81 40986 194 0.004733324 0.700378935 0.299621065
125 insDEPET 35 90680 422 0.004653727 0.688601272 0.311398728
126 insDEPET 29 86330 400 0.004633384 0.685591038 0.314408962
127 insDEPET 61 32758 149 0.004548507 0.673032089 0.326967911
128 insDEPET 74 93707 423 0.00451407 0.667936558 0.332063442
129 insDEPET 09 17626 79 0.004482015 0.663193417 0.336806583
130 insDEPET 79 37656 162 0.004302103 0.636572261 0.363427739
131 insDEPET 64 83756 359 0.00428626 0.634227986 0.365772014
132 insDEPET 23 16174 68 0.004204278 0.622097355 0.377902645
133 insDEPET 50 52775 219 0.004149692 0.614020335 0.385979665
134 insDEPET 04 22787 90 0.00394962 0.58441619 0.41558381
135 insDEPET 40 49541 192 0.003875578 0.573460278 0.426539722
136 insDEPET 43 27370 105 0.003836317 0.567650968 0.432349032
137 insDEPET 22 64491 244 0.003783474 0.559831842 0.440168158
138 insDEPET 85 64417 243 0.003772296 0.558177928 0.441822072
139 insDEPET 46 26030 95 0.003649635 0.54002805 0.45997195
140 insDEPET 53 32932 120 0.003643872 0.539175339 0.460824661
141 insDEPET 99 40894 134 0.003276764 0.484855233 0.515144767
142 insDEPET 65 34146 104 0.003045745 0.450671801 0.549328199
143 insDEPET 32 32543 96 0.002949943 0.436496261 0.563503739
144 insDEPET 15 22199 62 0.002792919 0.413261701 0.586738299
145 insDEPET 05 25212 70 0.002776456 0.410825718 0.589174282
146 insDEPET 48 12747 34 0.002667294 0.394673359 0.605326641
147 insDEPET 98 775 2 0.002580645 0.381852092 0.618147908
148 insDEPET 12 41281 104 0.002519319 0.372777775 0.627222225
149 insDEPCOMEN 75120 23391 422 0.018041127 2.669503799 -1.669503799
150 insDEPCOMEN 75110 28336 491 0.017327781 2.56395164 -1.56395164
151 insDEPCOMEN 75102 19124 292 0.015268772 2.259284889 -1.259284889
152 insDEPCOMEN 75103 14002 144 0.010284245 1.521735947 -0.521735947
153 insDEPCOMEN 75112 23538 238 0.010111309 1.496147047 -0.496147047
154 insDEPCOMEN 75119 18558 185 0.009968747 1.475052368 -0.475052368
155 insDEPCOMEN 75109 30187 288 0.009540531 1.411690247 -0.411690247
156 insDEPCOMEN 75111 32950 296 0.008983308 1.329239301 -0.329239301
157 insDEPCOMEN 75101 16952 132 0.007786692 1.15217877 -0.15217877
158 insDEPCOMEN 75118 26179 197 0.007525116 1.113473932 -0.113473932
159 insDEPCOMEN 75114 21520 154 0.007156134 1.058876561 -0.058876561
160 insDEPCOMEN 75108 66310 446 0.006725984 0.995228288 0.004771712
161 insDEPCOMEN 75117 41679 278 0.006670026 0.986948262 0.013051738
162 insDEPCOMEN 75115 36833 223 0.006054353 0.895848666 0.104151334
163 insDEPCOMEN 75113 19497 113 0.005795763 0.857585705 0.142414295
164 insDEPCOMEN 75104 10380 51 0.004913295 0.72700886 0.27299114
165 insDEPCOMEN 75105 14528 71 0.004887115 0.723135028 0.276864972
166 insDEPCOMEN 75116 48424 220 0.004543202 0.672247044 0.327752956
167 insDEPCOMEN 75106 16345 72 0.004405017 0.651800145 0.348199855
168 insDEPCOMEN 75107 18645 59 0.003164387 0.468227056 0.531772944
169 insDEPCOMEN,3 974 61141 402 0.006574966 0.972882512 0.027117488
170 insDEPCOMEN,3 972 42850 261 0.006091015 0.901273418 0.098726582
171 insDEPCOMEN,3 971 63190 307 0.004858364 0.718880828 0.281119172
172 insDEPCOMEN,3 973 13285 63 0.00474219 0.701690944 0.298309056
173 insCJ,2 54 1046180 26431 0.025264295 3.738299821 -2.738299821
174 insCJ,2 55 116455 1676 0.014391825 2.129525393 -1.129525393
175 insCJ,2 13 332350 4569 0.013747555 2.034194255 -1.034194255
176 insCJ,2 56 6079 81 0.01332456 1.971604606 -0.971604606
177 insCJ,2 57 68076 864 0.012691698 1.8779614 -0.8779614
178 insCJ,2 12 437093 5064 0.011585635 1.714299878 -0.714299878
179 insCJ,2 11 197912 2096 0.010590566 1.567061711 -0.567061711
180 insCJ,2 82 5102 51 0.00999608 1.479097048 -0.479097048
181 insCJ,2 31 11814 115 0.009734214 1.440349288 -0.440349288
182 insCJ,2 53 1525 13 0.00852459 1.261364073 -0.261364073
183 insCJ,2 52 38818 186 0.004791592 0.709000819 0.290999181
184 insCJ,2 51 517 1 0.001934236 0.286204465 0.713795535
185 insCJ,2 92 417094 658 0.001577582 0.233431198 0.766568802
186 insCJ,2 62 10141 12 0.001183315 0.175092447 0.824907553
187 insCJ,2 17 40919 39 0.000953102 0.141028389 0.858971611
188 insCJ,2 16 558658 471 0.000843092 0.124750367 0.875249633
189 insCJ,2 65 1134849 828 0.000729612 0.107959088 0.892040912
190 insCJ,2 32 26976 19 0.00070433 0.104218063 0.895781937
191 insCJ,2 29 24080 14 0.000581395 0.086027738 0.913972262
192 insCJ,2 84 8634 5 0.000579106 0.085688967 0.914311033
193 insCJ,2 63 20101 6 0.000298493 0.044167268 0.955832732
194 insCJ,2 19 511880 129 0.000252012 0.037289666 0.962710334
195 insCJ,2 15 577704 133 0.000230222 0.034065378 0.965934622
196 insCJ,2 18 497265 107 0.000215177 0.03183925 0.96816075
197 insCJ,2 22 29402 3 0.000102034 0.015097719 0.984902281
198 insCJ,2 21 24477 1 4.08547E-05 0.006045173 0.993954827
199 insCJ,2 10 1 0 0 0 1
200 insCJ,2 14 6117 0 0 0 1
201 insCJ,2 23 7434 0 0 0 1
202 insCJ,2 27 527 0 0 0 1
203 insCJ,2 41 874 0 0 0 1
204 insCJ,2 61 17 0 0 0 1
205 insCJ,2 64 178 0 0 0 1
206 insCJ,2 69 2 0 0 0 1
207 insCJ,2 71 2984 0 0 0 1
208 insCJ,2 72 36821 0 0 0 1
209 insCJ,2 73 91862 0 0 0 1
210 insCJ,2 74 2566 0 0 0 1
211 insCJ,2 81 1202 0 0 0 1
212 insCJ,2 83 4849 0 0 0 1
213 insCJ,2 91 145682 0 0 0 1
214 insCJ,2 93 461 0 0 0 1
215 insCJ,2 99 1571 0 0 0 1
216 ageDirigeant 0 4092989 11244 0.002747137 0.406487512 0.593512488
217 ageDirigeant 1 7915 339 0.042830069 6.337467242 -5.337467242
218 ageDirigeant 2 7915 339 0.042830069 6.337467242 -5.337467242
219 ageDirigeant 3 7915 339 0.042830069 6.337467242 -5.337467242
220 ageDirigeant 4 7915 339 0.042830069 6.337467242 -5.337467242
221 ageDirigeant 5 7915 339 0.042830069 6.337467242 -5.337467242
222 ageDirigeant 6 7915 339 0.042830069 6.337467242 -5.337467242
223 ageDirigeant 7 7915 339 0.042830069 6.337467242 -5.337467242
224 ageDirigeant 8 7915 339 0.042830069 6.337467242 -5.337467242
225 ageDirigeant 9 7915 339 0.042830069 6.337467242 -5.337467242
226 ageDirigeant 10 7915 339 0.042830069 6.337467242 -5.337467242
227 ageDirigeant 11 7915 339 0.042830069 6.337467242 -5.337467242
228 ageDirigeant 12 7915 339 0.042830069 6.337467242 -5.337467242
229 ageDirigeant 13 7915 339 0.042830069 6.337467242 -5.337467242
230 ageDirigeant 14 7915 339 0.042830069 6.337467242 -5.337467242
231 ageDirigeant 15 7915 339 0.042830069 6.337467242 -5.337467242
232 ageDirigeant 16 7915 339 0.042830069 6.337467242 -5.337467242
233 ageDirigeant 17 7915 339 0.042830069 6.337467242 -5.337467242
234 ageDirigeant 18 7915 339 0.042830069 6.337467242 -5.337467242
235 ageDirigeant 19 7915 339 0.042830069 6.337467242 -5.337467242
236 ageDirigeant 20 7915 339 0.042830069 6.337467242 -5.337467242
237 ageDirigeant 21 7915 339 0.042830069 6.337467242 -5.337467242
238 ageDirigeant 22 7915 339 0.042830069 6.337467242 -5.337467242
239 ageDirigeant 23 7915 339 0.042830069 6.337467242 -5.337467242
240 ageDirigeant 24 7915 339 0.042830069 6.337467242 -5.337467242
241 ageDirigeant 25 7915 339 0.042830069 6.337467242 -5.337467242
242 ageDirigeant 26 51311 1744 0.033988813 5.029246825 -4.029246825
243 ageDirigeant 27 51311 1744 0.033988813 5.029246825 -4.029246825
244 ageDirigeant 28 51311 1744 0.033988813 5.029246825 -4.029246825
245 ageDirigeant 29 51311 1744 0.033988813 5.029246825 -4.029246825
246 ageDirigeant 30 132700 3421 0.025779955 3.814600838 -2.814600838
247 ageDirigeant 31 132700 3421 0.025779955 3.814600838 -2.814600838
248 ageDirigeant 32 132700 3421 0.025779955 3.814600838 -2.814600838
249 ageDirigeant 33 132700 3421 0.025779955 3.814600838 -2.814600838
250 ageDirigeant 34 132700 3421 0.025779955 3.814600838 -2.814600838
251 ageDirigeant 35 246272 4538 0.01842678 2.726568435 -1.726568435
252 ageDirigeant 36 246272 4538 0.01842678 2.726568435 -1.726568435
253 ageDirigeant 37 246272 4538 0.01842678 2.726568435 -1.726568435
254 ageDirigeant 38 246272 4538 0.01842678 2.726568435 -1.726568435
255 ageDirigeant 39 246272 4538 0.01842678 2.726568435 -1.726568435
256 ageDirigeant 40 339245 5421 0.015979602 2.364465057 -1.364465057
257 ageDirigeant 41 339245 5421 0.015979602 2.364465057 -1.364465057
258 ageDirigeant 42 339245 5421 0.015979602 2.364465057 -1.364465057
259 ageDirigeant 43 339245 5421 0.015979602 2.364465057 -1.364465057
260 ageDirigeant 44 339245 5421 0.015979602 2.364465057 -1.364465057
261 ageDirigeant 45 367968 5217 0.014177863 2.097865945 -1.097865945
262 ageDirigeant 46 367968 5217 0.014177863 2.097865945 -1.097865945
263 ageDirigeant 47 367968 5217 0.014177863 2.097865945 -1.097865945
264 ageDirigeant 48 367968 5217 0.014177863 2.097865945 -1.097865945
265 ageDirigeant 49 367968 5217 0.014177863 2.097865945 -1.097865945
266 ageDirigeant 50 375026 4591 0.012241818 1.811393744 -0.811393744
267 ageDirigeant 51 375026 4591 0.012241818 1.811393744 -0.811393744
268 ageDirigeant 52 375026 4591 0.012241818 1.811393744 -0.811393744
269 ageDirigeant 53 375026 4591 0.012241818 1.811393744 -0.811393744
270 ageDirigeant 54 375026 4591 0.012241818 1.811393744 -0.811393744
271 ageDirigeant 55 377653 3778 0.010003892 1.480253045 -0.480253045
272 ageDirigeant 56 377653 3778 0.010003892 1.480253045 -0.480253045
273 ageDirigeant 57 377653 3778 0.010003892 1.480253045 -0.480253045
274 ageDirigeant 58 377653 3778 0.010003892 1.480253045 -0.480253045
275 ageDirigeant 59 377653 3778 0.010003892 1.480253045 -0.480253045
276 ageDirigeant 60 232451 2003 0.00861687 1.275018479 -0.275018479
277 ageDirigeant 61 232451 2003 0.00861687 1.275018479 -0.275018479
278 ageDirigeant 62 232451 2003 0.00861687 1.275018479 -0.275018479
279 ageDirigeant 63 232451 2003 0.00861687 1.275018479 -0.275018479
280 ageDirigeant 64 232451 2003 0.00861687 1.275018479 -0.275018479
281 ageDirigeant 65 100941 680 0.006736609 0.996800526 0.003199474
282 ageDirigeant 66 100941 680 0.006736609 0.996800526 0.003199474
283 ageDirigeant 67 100941 680 0.006736609 0.996800526 0.003199474
284 ageDirigeant 68 100941 680 0.006736609 0.996800526 0.003199474
285 ageDirigeant 69 100941 680 0.006736609 0.996800526 0.003199474
286 ageDirigeant 70 55612 320 0.005754154 0.85142895 0.14857105
287 ageDirigeant 71 55612 320 0.005754154 0.85142895 0.14857105
288 ageDirigeant 72 55612 320 0.005754154 0.85142895 0.14857105
289 ageDirigeant 73 55612 320 0.005754154 0.85142895 0.14857105
290 ageDirigeant 74 55612 320 0.005754154 0.85142895 0.14857105
291 ageDirigeant 75 33744 164 0.004860123 0.719141306 0.280858694
292 ageDirigeant 76 33744 164 0.004860123 0.719141306 0.280858694
293 ageDirigeant 77 33744 164 0.004860123 0.719141306 0.280858694
294 ageDirigeant 78 33744 164 0.004860123 0.719141306 0.280858694
295 ageDirigeant 79 33744 164 0.004860123 0.719141306 0.280858694
296 ageDirigeant 80 19900 73 0.003668342 0.542796117 0.457203883
297 ageDirigeant 81 19900 73 0.003668342 0.542796117 0.457203883
298 ageDirigeant 82 19900 73 0.003668342 0.542796117 0.457203883
299 ageDirigeant 83 19900 73 0.003668342 0.542796117 0.457203883
300 ageDirigeant 84 19900 73 0.003668342 0.542796117 0.457203883
301 ageDirigeant * 13522 39 0.002884189 0.426766798 0.573233202
302 ageEntreprise 0 398545 3931 0,009863378 1,45812286 -0.45812286
303 ageEntreprise 1 363230 5849 0.016102745 2.380500904 -1.380500904
304 ageEntreprise 2 336945 5474 0.016245975 2.401674887 -1.401674887
305 ageEntreprise 3 320242 4323 0.013499166 1.995608689 -0.995608689
306 ageEntreprise 4 311256 3186 0.010235947 1.513200512 -0.513200512
307 ageEntreprise 5 286481 2597 0.009065174 1.340122706 -0.340122706
308 ageEntreprise 6 271422 2131 0.007851243 1.16066488 -0.16066488
309 ageEntreprise 7 249689 1696 0.00679245 1.004141411 -0.004141411
310 ageEntreprise 8 299828 1471 0.004906146 0.725285383 0.274714617
311 ageEntreprise 9 251098 1368 0.005448072 0.805399367 0.194600633
312 ageEntreprise 10 224326 1088 0.004850084 0.716997635 0.283002365
313 ageEntreprise 11 225543 1016 0.004504684 0.665936463 0.334063537
314 ageEntreprise 12 219141 911 0.004157141 0.614558427 0.385441573
315 ageEntreprise 13 227433 890 0.00391324 0.578502136 0.421497864
316 ageEntreprise 14 228796 849 0.003710729 0.548564505 0.451435495
317 ageEntreprise 15 203213 738 0.003631657 0.536875165 0.463124835
318 ageEntreprise 16 195413 723 0.003699856 0.546957126 0.453042874
319 ageEntreprise 17 156467 621 0.003968888 0.586728635 0.413271365
320 ageEntreprise 18 136150 578 0.004245318 0.627593783 0.372406217
321 ageEntreprise 19 120966 421 0.003480317 0.514502176 0.485497824
322 ageEntreprise 20 110350 344 0.003117354 0.460844645 0.539155355
323 ageEntreprise 21 108829 314 0.00288526 0.426533798 0.573466202
324 ageEntreprise 22 92057 306 0.003324028 0.49139762 0.50860238
325 ageEntreprise 23 94394 225 0.002383626 0.3523762 0.6476238
326 ageEntreprise 24 61811 133 0.002151721 0.318093146 0.681906854
327 ageEntreprise 25 86450 215 0.002486987 0.367656207 0.632343793
328 ageEntreprise 26 79203 222 0.002802924 0.414361868 0.585638132
329 ageEntreprise 27 41020 131 0.003193564 0.472110957 0.527889043
330 ageEntreprise 28 37137 119 0.003204351 0.473705671 0.526294329
331 ageEntreprise 29 30627 110 0.003591602 0.530953718 0.469046282
332 ageEntreprise 30 27785 106 0.003815008 0.563980261 0.436019739
333 ageEntreprise 31 27100 87 0.003210332 0.474589802 0.525410198
334 ageEntreprise 32 26851 86 0.00320286 0.47348522 0.52651478
335 ageEntreprise 33 21279 48 0.002255745 0.3334713 0.6665287
336 ageEntreprise 34 17287 42 0.002429571 0.359168382 0.640831618
337 ageEntreprise 35 20082 45 0.002240813 0.331263809 0.668736191
338 ageEntreprise 36 24005 33 0.001374714 0.203226655 0.796773345
339 ageEntreprise 37 10981 36 0.00327839 0.484650929 0.515349071
340 ageEntreprise 38 14152 43 0.00303844 0.449178619 0.550821381
341 ageEntreprise 39 17017 67 0.003937239 0.582049933 0.417950067
342 ageEntreprise 40 31055 102 0.003284495 0.485553488 0.514446512
343 ageEntreprise 41 15175 43 0.002833608 0.418897912 0.581102088
344 ageEntreprise 42 6992 15 0.002145309 0.3171453 0.6828547
345 ageEntreprise 43 6310 14 0.0022187 0.327994919 0.672005081
346 ageEntreprise 44 7244 15 0.002070679 0.306112636 0.693887364
347 ageEntreprise 45 5863 13 0.002217295 0.32778713 0.67221287
348 ageEntreprise 46 7647 52 0.006800052 1.005265304 -0.005265304
349 ageEntreprise 47 9466 55 0.005810268 0.858943563 0.141056437
350 ageEntreprise 48 6119 35 0.005719889 0.845582587 0.154417413
351 ageEntreprise 49 6031 41 0.006798209 1.004992841 -0.004992841
352 ageEntreprise 50 4954 22 0.004440856 0.656500587 0.343499413
353 ageEntreprise 51 12623 11 0.000871425 0.128824523 0.871175477
354 ageEntreprise * 353169 621 0.001758365 0.259942604 0.740057396
355 insTEFEN 11 122483 2586 0.021113134 3.12406207 -2.12406207
356 insTEFEN 2 348140 6830 0.019618544 2.902911041 -1.902911041
357 insTEFEN 3 178988 3509 0.019604666 2.900857541 -1.900857541
358 insTEFEN 12 77324 1239 0.016023486 2.370958447 -1.370958447
359 insTEFEN 1 946071 14717 0.015555915 2.301773089 -1.301773089
360 insTEFEN 21 22652 290 0.012802402 1.894342023 -0.894342023
361 insTEFEN 22 11018 103 0.009348339 1.383252313 -0.383252313
362 insTEFEN 31 2325 13 0.005591398 0.827346328 0.172653672
363 insTEFEN 0 4729670 14264 0.003015855 0.446249188 0.553750812
364 insTEFEN 32 4541 13 0.002862806 0.423602777 0.576397223
365 insTEFEN 41 2251 6 0.002665482 0.394405265 0.605594735
366 insTEFEN 51 492 1 0.00203252 0.300747375 0.699252625
367 insTEFEN 42 1121 1 0.000892061 0.131996172 0.868003828
368 insTEFEN 52 172 0 0 0 1
369 insTEFEN 53 1 0 0 0 1
370 insNBTOA 13 445 8 0.017977528 2.660093638 -1.660093638
371 insNBTOA 2 199031 2816 0.01414855 2.093528483 -1.093528483
372 insNBTOA 3 38973 413 0.01059708 1.56802565 -0.56802565
373 insNBTOA 1 3755472 38870 0.01035023 1.531499858 -0.531499858
374 insNBTOA 8 1595 15 0.009404389 1.391545849 -0.391545849
375 insNBTOA 11 743 6 0.00807537 1.194894013 -0.194894013
376 insNBTOA 4 14851 119 0.008012928 1.185654658 -0.185654658
377 insNBTOA 7 2443 19 0.007777323 1.150792658 -0.150792658
378 insNBTOA 20-25 949 7 0.007376185 1.091437261 -0.091437261
379 insNBTOA 10 869 6 0.006904488 1.021641256 -0.021641256
380 insNBTOA 5 7090 46 0.006488011 0.960016163 0.039983837
381 insNBTOA 6 3905 24 0.006145967 0.909404611 0.090595389
382 insNBTOA 9 1144 6 0.005244755 0.776054416 0.223945584
383 insNBTOA 14 412 2 0.004854369 0.718289848 0.281710152
384 insNBTOA 75-99 225 1 0.004444444 0.657634261 0.342365739
385 insNBTOA 35-49 639 2 0.00312989 0.463122719 0.536877281
386 insNBTOA 50-74 424 1 0.002358491 0.348980445 0.651019555
387 insNBTOA 15-19 1445 3 0.002076125 0.307199395 0.692800605
388 insNBTOA 12 626 1 0.001597444 0.236370142 0.763629858
389 insNBTOA 26-34 793 1 0.001261034 0.186592319 0.813407681
390 insNBTOA 0 2414681 1206 0.000499445 0.073901711 0.926098289
391 insNBTOA 100- 494 0 0 0 1
392 insTCA 2 21622 409 0.018915919 2.798369096 -1.798369096
393 insTCA 3 28973 507 0.017499051 2.588761516 -1.588761516
394 insTCA 1 20023 348 0.017380013 2.571151383 -1.571151383
395 insTCA 4 15955 207 0.012973989 1.919336348 -0.919336348
396 insTCA 5 10403 89 0.008555224 1.265636407 -0.265636407
397 insTCA 6 7600 51 0.006710526 0.992736831 0.007263169
398 insTCA 0 6337365 41952 0.006619786 0.979312956 0.020687044
399 insTCA 7 2667 7 0.002624672 0.388286754 0.611713246
400 insTCA 9 1314 2 0.00152207 0.225170857 0.774829143
401 insTCA 8 1327 0 0 0 1
402 insTCAEXPOR 3 5258 109 0.020730316 3.066785966 -2.066785966
403 insTCAEXPOR 2 12013 215 0.017897278 2.647674141 -1.647674141
404 insTCAEXPOR 1 10029 173 0.017249975 2.551913931 -1.551913931
405 insTCAEXPOR 4 5589 88 0.015745214 2.329303684 -1.329303684
406 insTCAEXPOR 0 6414360 42987 0.006701682 0.991428405 0.008571595
407 insSEXE M 2233981 9893 0.004428417 0.655262754 0.344737246
408 insSEXE F 923849 2714 0.002937710 0.434686146 0.565313854
409 insSEXE * 3289419 30965 0.009413516 1.392896465 -0.392896465
410 insRECME 0 6445782 43572 0.006759769 1.000227591 -0.000227591
411 insRECME 1 1467 0 0.000000000 0 1
412 insMONOREG 1 78856 935 0.011857056 1.754461392 -0.754461392
413 insMONOREG 2 6170828 41393 0.006707852 0.992545468 0.007454532
414 insMONOREG 0 197565 1244 0.006296662 0.931702627 0.068297373
415 insRPET 11 1205539 10949 0.009082245 1.343874119 -0.343874119
416 insRPET 31 252996 2234 0.008830179 1.306576712 -0.306576712
417 insRPET 41 170366 1448 0.008499348 1.25762463 -0.25762463
418 insRPET 93 599741 4858 0.008100163 1.198558318 -0.198558318
419 insRPET 42 155599 1173 0.007538609 1.1154667 -0.1154667
420 insRPET 22 135577 972 0.007169358 1.060829637 -0.060829637
421 insRPET 4 60943 402 0.006596328 0.976040016 0.023959984
422 insRPET 24 214087 1391 0.006497359 0.961395827 0.038604173
423 insRPET 23 131429 852 0.006482588 0.959210205 0.040789795
424 insRPET 43 102313 659 0.006441019 0.953059456 0.046940544
425 insRPET 94 36450 234 0.006419753 0.949912765 0.050087235
426 insRPET 91 337251 2154 0.006386934 0.945056671 0.054943329
427 insRPET 82 667354 4078 0.0061107 0.904183032 0.095816968
428 insRPET 2 42948 261 0.006077117 0.899213798 0.100786202
429 insRPET 72 377551 2184 0.005784649 0.855938198 0.144061802
430 insRPET 26 164649 907 0.005508688 0.81510506 0.18489494
431 insRPET 74 80672 443 0.005491372 0.812542903 0.187457097
432 insRPET 21 136535 746 0.0054638 0.808463155 0.191536845
433 insRPET 54 191379 972 0.005078927 0.751514532 0.248485468
434 insRPET 73 335852 1699 0.005058776 0.748532806 0.251467194
435 insRPET 52 315413 1595 0.005056862 0.748249607 0.251750393
436 insRPET 83 150096 732 0.004876879 0.721618007 0.278381993
437 insRPET 1 63134 307 0.004862673 0.719516021 0.280483979
438 insRPET 3 13275 63 0.004745763 0.702217129 0.297782871
439 insRPET 53 314133 1445 0.004599962 0.680643473 0.319356527
440 insRPET 25 149961 678 0.004521176 0.668985593 0.331014407
441 insRPET 99 41208 134 0.003251796 0.481159052 0.518840948
442 insRPET 98 775 2 0.002580645 0.381850789 0.618149211
443 insSINGT 43 23550 425 0.018046709 2.670330198 -1.670330198
444 insSINGT 2 76142 1237 0.016245961 2.403877696 -1.403877696
445 insSINGT 1 3885595 40481 0.010418224 1.541560768 -0.541560768
446 insSINGT 40 13737 119 0.008662736 1.281805149 -0.281805149
447 insSINGT 31 35843 96 0.002678347 0.396308903 0.603691097
448 insSINGT 33 3315 8 0.002413273 0.357086476 0.642913524
449 insSINGT 52 6565 10 0.001523229 0.225388741 0.774611259
450 insSINGT 10 96382 127 0.001317673 0.194973117 0.805026883
451 insSINGT 60 216663 228 0.001052326 0.155710193 0.844289807
452 insSINGT 90 577496 260 0.00045022 0.066617958 0.933382042
453 insSINGT 70 1298907 576 0.00044345 0.065616245 0.934383755
454 insSINGT 34 24032 1 4.16112E-05 0.006157112 0.993842888
455 insSINGT 80 149852 4 2.6693E-05 0.003949703 0.996050297
456 insSINGT 0 1 0 0 1
457 insSINGT 30 5741 0 0 0 1
458 insSINGT 42 33428 0 0 0 1
459 insORDIN 1 3412206 41477 0.012155479 1.798618445 -0.798618445
460 insORDIN 0 3035043 2095 0.00069027 0.102137713 0.897862287
461 insMODET 3 2787 130 0.046645138 6.901974209 -5.901974209
462 insMODET 1 991 19 0.019172553 2.836918732 -1.836918732
463 insMODET 2 3347 45 0.013444876 1.989407496 -0.989407496
464 insMODET 0 6440124 43378 0.006735585 0.996649019 0.003350981
465 insAUXILT 1 26364 474 0.017979062 2.66032066 -1.66032066
466 insAUXILT 0 6420872 43098 0.006712172 0.993184774 0.006815226
467 insAUXILT * 13 0 0 0 1
468 insTCD 73 83653 867 0.010364243 1.533573253 -0.533573253
469 insTCD 44 207816 2036 0.009797128 1.449658615 -0.449658615
470 insTCD 52 189137 1814 0.009590931 1.419148149 -0.419148149
471 insTCD 43 241634 2262 0.009361265 1.385164989 -0.385164989
472 insTCD 62 114691 1056 0.009207348 1.362390251 -0.362390251
473 insTCD 41 193192 1687 0.008732246 1.292090379 -0.292090379
474 insTCD 51 286358 2499 0.008726838 1.291290286 -0.291290286
475 insTCD 72 161502 1371 0.008489059 1.256106603 -0.256106603
476 insTCD 80 520175 4329 0.008322199 1.231416755 -0.231416755
477 insTCD 42 173427 1427 0.008228246 1.21751469 -0.21751469
478 insTCD 61 258193 2063 0.007990147 1.182283729 -0.182283729
479 insTCD 31 307323 2413 0.007851674 1.161794206 -0.161794206
480 insTCD 32 256048 1919 0.007494688 1.108971884 -0.108971884
481 insTCD 71 137763 984 0.007142702 1.056889189 -0.056889189
482 insTCD 22 291665 2073 0.007107469 1.051675929 -0.051675929
483 insTCD 21 317427 2113 0.006656649 0.984969043 0.015030957
484 insTCD 18 197044 1301 0.006602586 0.976969555 0.023030445
485 insTCD 17 257376 1549 0.006018432 0.890533619 0.109466381
486 insTCD 15 199766 1128 0.005646607 0.83551543 0.16448457
487 insTCD 16 172805 968 0.00560169 0.828869199 0.171130801
488 insTCD 14 249738 1244 0.00498122 0.737059757 0.262940243
489 insTCD 0 120431 578 0.004799429 0.71016047 0.28983953
490 insTCD 13 342501 1623 0.004738672 0.701170482 0.298829518
491 insTCD 12 272656 1158 0.00424711 0.628435122 0.371564878
492 insTCD 11 245321 1022 0.00416597 0.616429079 0.383570921
493 insTCD 8 125432 481 0.003834747 0.567418744 0.432581256
494 insTCD 7 149718 535 0.003573385 0.528745536 0.471254464
495 insTCD 6 81869 265 0.003236878 0.478953484 0.521046516
496 insTCD 4 81356 256 0.003146664 0.465604668 0.534395332
497 insTCD 5 84330 243 0.002881537 0.426374401 0.573625599
498 insTCD 3 74476 200 0.002685429 0.397356756 0.602643244
499 insTCD 2 43091 94 0.00218143 0.322781198 0.677218802
500 insTCD 1 9335 14 0.001499732 0.221911936 0.778088064
501 insNATURE 91 238972 6564 0.027467653 4.064325692 -3.064325692
502 insNATURE 20 144873 3353 0.023144409 3.424625203 -2.424625203
503 insNATURE 22 10828 119 0.010990026 1.626168944 -0.626168944
504 insNATURE 93 160570 1367 0.008513421 1.259711389 -0.259711389
505 insNATURE 21 185819 1501 0.008077753 1.195246614 -0.195246614
506 insNATURE 92 83924 635 0.00756637 1.119578368 -0.119578368
507 insNATURE 99 5621113 30028 0.005342003 0.790443877 0.209556123
508 insNATURE 23 1135 5 0.004405286 0.651840126 0.348159874
509 insNATURE * 15 0 0 0 1
510 insORIGINE 3 296615 3962 0.013357382 1.976461277 -0.976461277
511 insORIGINE 7 112298 1480 0.01317922 1.950098922 -0.950098922
512 insORIGINE 2 907819 9870 0.010872211 1.608736195 -0.608736195
513 insORIGINE 5 54475 462 0.008480955 1.254907414 -0.254907414
514 insORIGINE 6 1914 11 0.005747126 0.85038913 0.14961087
515 insORIGINE 1 4776418 27127 0.005679361 0.840361968 0.159638032
516 insORIGINE 8 90133 230 0.002551785 0.377581718 0.622418282
517 insORIGINE 0 173492 370 0.002132663 0.315565284 0.684434716
518 insORIGINE 4 34085 60 0.001760305 0.260468315 0.739531685
519 insTU 8 1084479 9960 0.009184134 1.358955201 -0.358955201
520 insTU 7 1259040 10827 0.008599409 1.272434856 -0.272434856
521 insTU 5 399066 3189 0.007991159 1.182433539 -0.182433539
522 insTU 6 378843 2890 0.00762849 1.128770171 -0.128770171
523 insTU 4 410877 2959 0.007201669 1.065614405 -0.065614405
524 insTU 3 331773 2090 0.006299488 0.93212079 0.06787921
525 insTU 2 343704 2076 0.006040081 0.893736945 0.106263055
526 insTU 1 375638 2186 0.005819433 0.861088098 0.138911902
527 insTU 0 1863829 7395 0.003967639 0.587082401 0.412917599

View File

@ -0,0 +1,194 @@
<?php
/**
* 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 soundex2 {
/**
* 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 {
$this -> sString = '';
//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 ($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);
}
}
}
}
}
?>

View File

@ -0,0 +1,374 @@
<?
define ('BEFORE', 0);
define ('AFTER', 1);
define ('BOTH', 2);
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 ($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;
}
?>

View File

@ -0,0 +1,73 @@
<?
/** 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 entre 0 et 15 secondes par défaut
**/
function randsleep($min_sec=0, $max_sec=15) {
sleep(rand($min_sec, $max_sec));
}
/**************Fonctions de dates/heures ****/
global $tabMois;
$tabMois=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');
function getLibelleMois($numMois) {
global $tabMois;
if ($numMois>0 && $numMois<13)
return $tabMois[$numMois];
else
return false;
}
function getNumMois($strMois) {
global $tabMois;
$mois=array_search(ucfirst(strtolower($strMois)), $tabMois);
return $mois;
}
function dateT($formatIN, $formatOUT, $date) {
switch ($formatIN) {
case 'd M Y': $tmp=explode(' ', $date); $d=$tmp[0]; $m=getNumMois($tmp[1]); $Y=$tmp[2]; break;
case 'Ymd': $d=substr($date,6,2); $m=substr($date,4,2); $Y=substr($date,0,4); break;
case 'Y-m-d': $d=substr($date,8,2); $m=substr($date,5,2); $Y=substr($date,0,4); break;
case 'd/m/Y': $d=substr($date,0,2); $m=substr($date,3,2); $Y=substr($date,6,4); 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 '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;
}
}
?>

View File

@ -0,0 +1,54 @@
<?
/** Test de la validité du siren demandé */
function valideSiren($siren, $nic='', $erreur=false) {
$lenSIREN=strlen($siren);
if (!valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
return $erreur;
else
{
if (!isset($nic) || trim($nic)=='')
{
$somme=0;
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
$somme+=(integer)substr($siren,$i,1);
for ($i=1; $i<=7; $i+=2)
{ // Traitement PAIR
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
$som_tmp=0;
for($j=0;$j<strlen($var_tmp);$j++)
$som_tmp+=(integer)substr($var_tmp,$j,1);
$somme+=$som_tmp;
}
if ((integer)($somme/10)!=($somme/10))
{ // Le Siren est faux
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
return $erreur;
}
} else {
if (!valideData($nic,1,5,'N')) // Nic de format incorrect.
return $erreur;
$SIRET=$siren.$nic;
$somme=0;
for ($i=0; $i<=12; $i+=2)
{ // Traitement PAIR
$var_tmp=(string)(2*((integer)substr($SIRET,$i,1)));
$som_tmp=0;
for($j=0;$j<strlen($var_tmp);$j++)
$som_tmp+=(integer)substr($var_tmp,$j,1);
$somme+=$som_tmp;
}
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
$somme+=(integer)substr($SIRET,$i,1);
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
return $erreur;
}
}
return true;
}
?>

101
framework/fwk.php Normal file
View File

@ -0,0 +1,101 @@
<?
//define('FWK_PATH', 'C:\\wamp\\www\\framework\\');
define('FWK_PATH', realpath(dirname(__FILE__) . '/'));
include_once(realpath(FWK_PATH.'/common/mysql.php'));
include_once(realpath(FWK_PATH.'/common/strings.php') );
define ('REP_TEMP', '/tmp/');
// Environnement : DEV ou PRD
define ('ENV', 'DEV');
define ('EOL', "\n");
/** 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));
}
/** 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(realpath(dirname(__FILE__) . '/../debug.log'))) {
$fp=fopen(realpath(dirname(__FILE__) . '/../debug.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(realpath(dirname(__FILE__) . '/../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 .';'. $message . EOL);
fclose($fp);
if ($debugLevel=='E') die($message);
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,393 @@
<?php
/*~ class.pop3.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 2.3 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers) |
'---------------------------------------------------------------------------'
/**
* POP Before SMTP Authentication Class
* Version 2.3
*
* Author: Richard Davey (rich@corephp.co.uk)
* Modifications: Andy Prevost
* License: LGPL, see PHPMailer License
*
* Specifically for PHPMailer to allow POP before SMTP authentication.
* Does not yet work with APOP - if you have an APOP account, contact me
* and we can test changes to this script.
*
* This class is based on the structure of the SMTP class by Chris Ryan
*
* This class is rfc 1939 compliant and implements all the commands
* required for POP3 connection, authentication and disconnection.
*
* @package PHPMailer
* @author Richard Davey
*/
class POP3 {
/**
* Default POP3 port
* @var int
*/
public $POP3_PORT = 110;
/**
* Default Timeout
* @var int
*/
public $POP3_TIMEOUT = 30;
/**
* POP3 Carriage Return + Line Feed
* @var string
*/
public $CRLF = "\r\n";
/**
* Displaying Debug warnings? (0 = now, 1+ = yes)
* @var int
*/
public $do_debug = 2;
/**
* POP3 Mail Server
* @var string
*/
public $host;
/**
* POP3 Port
* @var int
*/
public $port;
/**
* POP3 Timeout Value
* @var int
*/
public $tval;
/**
* POP3 Username
* @var string
*/
public $username;
/**
* POP3 Password
* @var string
*/
public $password;
/**#@+
* @access private
*/
private $pop_conn;
private $connected;
private $error; // Error log array
/**#@-*/
/**
* Constructor, sets the initial values
* @access public
* @return POP3
*/
public function __construct() {
$this->pop_conn = 0;
$this->connected = false;
$this->error = null;
}
/**
* Combination of public events - connect, login, disconnect
* @access public
* @param string $host
* @param integer $port
* @param integer $tval
* @param string $username
* @param string $password
*/
public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
$this->host = $host;
// If no port value is passed, retrieve it
if ($port == false) {
$this->port = $this->POP3_PORT;
} else {
$this->port = $port;
}
// If no port value is passed, retrieve it
if ($tval == false) {
$this->tval = $this->POP3_TIMEOUT;
} else {
$this->tval = $tval;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Refresh the error log
$this->error = null;
// Connect
$result = $this->Connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->Login($this->username, $this->password);
if ($login_result) {
$this->Disconnect();
return true;
}
}
// We need to disconnect regardless if the login succeeded
$this->Disconnect();
return false;
}
/**
* Connect to the POP3 server
* @access public
* @param string $host
* @param integer $port
* @param integer $tval
* @return boolean
*/
public function Connect ($host, $port = false, $tval = 30) {
// Are we already connected?
if ($this->connected) {
return true;
}
/*
On Windows this will raise a PHP Warning error if the hostname doesn't exist.
Rather than supress it with @fsockopen, let's capture it cleanly instead
*/
set_error_handler(array(&$this, 'catchWarning'));
// Connect to the POP3 server
$this->pop_conn = fsockopen($host, // POP3 Host
$port, // Port #
$errno, // Error Number
$errstr, // Error Message
$tval); // Timeout (seconds)
// Restore the error handler
restore_error_handler();
// Does the Error Log now contain anything?
if ($this->error && $this->do_debug >= 1) {
$this->displayErrors();
}
// Did we connect?
if ($this->pop_conn == false) {
// It would appear not...
$this->error = array(
'error' => "Failed to connect to server $host on port $port",
'errno' => $errno,
'errstr' => $errstr
);
if ($this->do_debug >= 1) {
$this->displayErrors();
}
return false;
}
// Increase the stream time-out
// Check for PHP 4.3.0 or later
if (version_compare(phpversion(), '5.0.0', 'ge')) {
stream_set_timeout($this->pop_conn, $tval, 0);
} else {
// Does not work on Windows
if (substr(PHP_OS, 0, 3) !== 'WIN') {
socket_set_timeout($this->pop_conn, $tval, 0);
}
}
// Get the POP3 server response
$pop3_response = $this->getResponse();
// Check for the +OK
if ($this->checkResponse($pop3_response)) {
// The connection is established and the POP3 server is talking
$this->connected = true;
return true;
}
}
/**
* Login to the POP3 server (does not support APOP yet)
* @access public
* @param string $username
* @param string $password
* @return boolean
*/
public function Login ($username = '', $password = '') {
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
if ($this->do_debug >= 1) {
$this->displayErrors();
}
}
if (empty($username)) {
$username = $this->username;
}
if (empty($password)) {
$password = $this->password;
}
$pop_username = "USER $username" . $this->CRLF;
$pop_password = "PASS $password" . $this->CRLF;
// Send the Username
$this->sendString($pop_username);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
// Send the Password
$this->sendString($pop_password);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* Disconnect from the POP3 server
* @access public
*/
public function Disconnect () {
$this->sendString('QUIT');
fclose($this->pop_conn);
}
/////////////////////////////////////////////////
// Private Methods
/////////////////////////////////////////////////
/**
* Get the socket response back.
* $size is the maximum number of bytes to retrieve
* @access private
* @param integer $size
* @return string
*/
private function getResponse ($size = 128) {
$pop3_response = fgets($this->pop_conn, $size);
return $pop3_response;
}
/**
* Send a string down the open socket connection to the POP3 server
* @access private
* @param string $string
* @return integer
*/
private function sendString ($string) {
$bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
return $bytes_sent;
}
/**
* Checks the POP3 server response for +OK or -ERR
* @access private
* @param string $string
* @return boolean
*/
private function checkResponse ($string) {
if (substr($string, 0, 3) !== '+OK') {
$this->error = array(
'error' => "Server reported an error: $string",
'errno' => 0,
'errstr' => ''
);
if ($this->do_debug >= 1) {
$this->displayErrors();
}
return false;
} else {
return true;
}
}
/**
* If debug is enabled, display the error message array
* @access private
*/
private function displayErrors () {
echo '<pre>';
foreach ($this->error as $single_error) {
print_r($single_error);
}
echo '</pre>';
}
/**
* Takes over from PHP for the socket warning handler
* @access private
* @param integer $errno
* @param string $errstr
* @param string $errfile
* @param integer $errline
*/
private function catchWarning ($errno, $errstr, $errfile, $errline) {
$this->error[] = array(
'error' => "Connecting to the POP3 server raised a PHP warning: ",
'errno' => $errno,
'errstr' => $errstr
);
}
// End of class
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Arabic Version
* by : bahjat al mostafa <bahjat983@hotmail.com> */
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = ' íÌÈ Ãä ÊÖÚ Úáì ÇáÃŞá ' .
'ÚäæÇä ÈÑíÏ ÅáßÊÑæäí ãÓÊŞÈá æÇÍÏ';
$PHPMAILER_LANG["mailer_not_supported"] = ' ãÑÓá ÇáÈÑíÏ ÛíÑ ãÏÚæã :';
$PHPMAILER_LANG["execute"] = 'áÇ íãßä ÊäİíĞ : ';
$PHPMAILER_LANG["instantiate"] = 'áã íÓÊØÚ ÊåíÆÉ ÊÇÈÚ ÇáÈÑíÏ';
$PHPMAILER_LANG["authenticate"] = 'ÎØà STMP : áã íãáß ÇáÕáÇÍíÉ';
$PHPMAILER_LANG["from_failed"] = 'ÇáÚäæÇä ÇáãÑÓá ÇáÊÇáí İÔá : ';
$PHPMAILER_LANG["recipients_failed"] = 'ÎØÃ STMP : ' .
'åÄáÇÁ ÇáãÓÊŞÈáæä İÔáæÇ : ';
$PHPMAILER_LANG["data_not_accepted"] = 'ÎØà STMP : ÇáãÚØíÇÊ áã ÊŞÈá .';
$PHPMAILER_LANG["connect_host"] = 'ÎØà STMP : ÇáÇÊÕÇá ÈãÓÊÖíİ STMP áã íÊã';
$PHPMAILER_LANG["file_access"] = 'áÇ íãßä ÇáæÕæá áãáİ : ';
$PHPMAILER_LANG["file_open"] = 'ÎØà ãáİ : áã íãßä İÊÍ ãáİ :';
$PHPMAILER_LANG["encoding"] = 'ÊÔİíÑ ÛíÑ ãÚÑæİ : ';
$PHPMAILER_LANG["signing"] = 'ÎØÃ ÊÓÌíá : ';
?>

View File

@ -0,0 +1,23 @@
<?php
/**
* PHPMailer language file.
* Portuguese Version
* By Paulo Henrique Garcia - paulo@controllerweb.com.br
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Você deve fornecer pelo menos um endereço de destinatário de email.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer não suportado.';
$PHPMAILER_LANG["execute"] = 'Não foi possível executar: ';
$PHPMAILER_LANG["instantiate"] = 'Não foi possível instanciar a função mail.';
$PHPMAILER_LANG["authenticate"] = 'Erro de SMTP: Não foi possível autenticar.';
$PHPMAILER_LANG["from_failed"] = 'Os endereços de rementente a seguir falharam: ';
$PHPMAILER_LANG["recipients_failed"] = 'Erro de SMTP: Os endereços de destinatário a seguir falharam: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Erro de SMTP: Dados não aceitos.';
$PHPMAILER_LANG["connect_host"] = 'Erro de SMTP: Não foi possível conectar com o servidor SMTP.';
$PHPMAILER_LANG["file_access"] = 'Não foi possível acessar o arquivo: ';
$PHPMAILER_LANG["file_open"] = 'Erro de Arquivo: Não foi possível abrir o arquivo: ';
$PHPMAILER_LANG["encoding"] = 'Codificação desconhecida: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,24 @@
<?php
/**
* PHPMailer language file.
* Catalan Version
* By Ivan: web AT microstudi DOT com
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'S\'ha de proveir almenys una adreça d\'email com a destinatari.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer no està suportat';
$PHPMAILER_LANG["execute"] = 'No es pot executar: ';
$PHPMAILER_LANG["instantiate"] = 'No s\'ha pogut crear una instància de la funció Mail.';
$PHPMAILER_LANG["authenticate"] = 'Error SMTP: No s\'hapogut autenticar.';
$PHPMAILER_LANG["from_failed"] = 'La(s) següent(s) adreces de remitent han fallat: ';
$PHPMAILER_LANG["recipients_failed"] = 'Error SMTP: Els següents destinataris han fallat: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Error SMTP: Dades no acceptades.';
$PHPMAILER_LANG["connect_host"] = 'Error SMTP: No es pot connectar al servidor SMTP.';
$PHPMAILER_LANG["file_access"] = 'No es pot accedir a l\'arxiu: ';
$PHPMAILER_LANG["file_open"] = 'Error d\'Arxiu: No es pot obrir l\'arxiu: ';
$PHPMAILER_LANG["encoding"] = 'Codificació desconeguda: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,26 @@
<?php
/**
* PHPMailer language file.
* Czech Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Musíte zadat alespoò jednu ' .
'emailovou adresu pøíjemce.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailový klient není podporován.';
$PHPMAILER_LANG["execute"] = 'Nelze provést: ';
$PHPMAILER_LANG["instantiate"] = 'Nelze vytvoøit instanci emailové funkce.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Chyba autentikace.';
$PHPMAILER_LANG["from_failed"] = 'Následující adresa From je nesprávná: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: Adresy pøíjemcù ' .
'nejsou správné ' .
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data nebyla pøijata';
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Nelze navázat spojení se ' .
' SMTP serverem.';
$PHPMAILER_LANG["file_access"] = 'Soubor nenalezen: ';
$PHPMAILER_LANG["file_open"] = 'File Error: Nelze otevøít soubor pro ètení: ';
$PHPMAILER_LANG["encoding"] = 'Neznámé kódování: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,26 @@
<?php
/**
* PHPMailer language file.
* German Version
* Thanks to Yann-Patrick Schlame for the latest update!
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Bitte geben Sie mindestens eine ' .
'Empf&auml;nger Emailadresse an.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer wird nicht unterst&uuml;tzt.';
$PHPMAILER_LANG["execute"] = 'Konnte folgenden Befehl nicht ausf&uuml;hren: ';
$PHPMAILER_LANG["instantiate"] = 'Mail Funktion konnte nicht initialisiert werden.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Fehler: Authentifizierung fehlgeschlagen.';
$PHPMAILER_LANG["from_failed"] = 'Die folgende Absenderadresse ist nicht korrekt: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Fehler: Die folgenden ' .
'Empf&auml;nger sind nicht korrekt: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Fehler: Daten werden nicht akzeptiert.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Fehler: Konnte keine Verbindung zum SMTP-Host herstellen.';
$PHPMAILER_LANG["file_access"] = 'Zugriff auf folgende Datei fehlgeschlagen: ';
$PHPMAILER_LANG["file_open"] = 'Datei Fehler: konnte folgende Datei nicht &ouml;ffnen: ';
$PHPMAILER_LANG["encoding"] = 'Unbekanntes Encoding-Format: ';
$PHPMAILER_LANG["signing"] = 'Fehler beim Signieren: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Danish Version
* Author: Mikael Stokkebro <info@stokkebro.dk> */
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Du skal indtaste mindst en ' .
'modtagers emailadresse.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer understøttes ikke.';
$PHPMAILER_LANG["execute"] = 'Kunne ikke køre: ';
$PHPMAILER_LANG["instantiate"] = 'Kunne ikke initialisere email funktionen.';
$PHPMAILER_LANG["authenticate"] = 'SMTP fejl: Kunne ikke logge på.';
$PHPMAILER_LANG["from_failed"] = 'Følgende afsenderadresse er forkert: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP fejl: Følgende' .
'modtagere er forkerte: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fejl: Data kunne ikke accepteres.';
$PHPMAILER_LANG["connect_host"] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.';
$PHPMAILER_LANG["file_access"] = 'Ingen adgang til fil: ';
$PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke åbne filen: ';
$PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* English Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
'recipient email address.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
$PHPMAILER_LANG["execute"] = 'Could not execute: ';
$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
'recipients failed: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Versión en español
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Debe proveer al menos una ' .
'dirección de email como destinatario.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer no está soportado.';
$PHPMAILER_LANG["execute"] = 'No puedo ejecutar: ';
$PHPMAILER_LANG["instantiate"] = 'No pude crear una instancia de la función Mail.';
$PHPMAILER_LANG["authenticate"] = 'Error SMTP: No se pudo autentificar.';
$PHPMAILER_LANG["from_failed"] = 'La(s) siguiente(s) direcciones de remitente fallaron: ';
$PHPMAILER_LANG["recipients_failed"] = 'Error SMTP: Los siguientes ' .
'destinatarios fallaron: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Error SMTP: Datos no aceptados.';
$PHPMAILER_LANG["connect_host"] = 'Error SMTP: No puedo conectar al servidor SMTP.';
$PHPMAILER_LANG["file_access"] = 'No puedo acceder al archivo: ';
$PHPMAILER_LANG["file_open"] = 'Error de Archivo: No puede abrir el archivo: ';
$PHPMAILER_LANG["encoding"] = 'Codificación desconocida: ';
$PHPMAILER_LANG["signing"] = 'Error al firmar: ';
?>

View File

@ -0,0 +1,24 @@
<?php
/**
* PHPMailer language file.
* Estonian Version
* By Indrek P&auml;ri
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Te peate m&auml;&auml;rama v&auml;hemalt &uuml;he saaja e-posti aadressi.';
$PHPMAILER_LANG["mailer_not_supported"] = ' maileri tugi puudub.';
$PHPMAILER_LANG["execute"] = 'Tegevus eba&otilde;nnestus: ';
$PHPMAILER_LANG["instantiate"] = 'mail funktiooni k&auml;ivitamine eba&otilde;nnestus.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Viga: Autoriseerimise viga.';
$PHPMAILER_LANG["from_failed"] = 'J&auml;rgnev saatja e-posti aadress on vigane: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Viga: J&auml;rgnevate saajate e-posti aadressid on vigased: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Viga: Vigased andmed.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Viga: Ei &otilde;nnestunud luua &uuml;hendust SMTP serveriga.';
$PHPMAILER_LANG["file_access"] = 'Pole piisavalt &otilde;iguseid j&auml;rgneva faili avamiseks: ';
$PHPMAILER_LANG["file_open"] = 'Faili Viga: Faili avamine eba&otilde;nnestus: ';
$PHPMAILER_LANG["encoding"] = 'Tundmatu Unknown kodeering: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Finnish Version
* By Jyry Kuukanen
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Aseta v&auml;hint&auml;&auml;n yksi vastaanottajan ' .
's&auml;hk&ouml;postiosoite.';
$PHPMAILER_LANG["mailer_not_supported"] = 'postiv&auml;litintyyppi&auml; ei tueta.';
$PHPMAILER_LANG["execute"] = 'Suoritus ep&auml;onnistui: ';
$PHPMAILER_LANG["instantiate"] = 'mail-funktion luonti ep&auml;onnistui.';
$PHPMAILER_LANG["authenticate"] = 'SMTP-virhe: k&auml;ytt&auml;j&auml;tunnistus ep&auml;onnistui.';
$PHPMAILER_LANG["from_failed"] = 'Seuraava l&auml;hett&auml;j&auml;n osoite on virheellinen: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP-virhe: seuraava vastaanottaja osoite on virheellinen.';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP-virhe: data on virheellinen.';
$PHPMAILER_LANG["connect_host"] = 'SMTP-virhe: yhteys palvelimeen ei onnistu.';
$PHPMAILER_LANG["file_access"] = 'Seuraavaan tiedostoon ei ole oikeuksia: ';
$PHPMAILER_LANG["file_open"] = 'Tiedostovirhe: Ei voida avata tiedostoa: ';
$PHPMAILER_LANG["encoding"] = 'Tuntematon koodaustyyppi: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,27 @@
<?php
/**
* PHPMailer language file.
* Faroese Version [language of the Faroe Islands, a Danish dominion]
* This file created: 11-06-2004
* Supplied by Dávur Sørensen [www.profo-webdesign.dk]
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Tú skal uppgeva minst ' .
'móttakara-emailadressu(r).';
$PHPMAILER_LANG["mailer_not_supported"] = ' er ikki supporterað.';
$PHPMAILER_LANG["execute"] = 'Kundi ikki útføra: ';
$PHPMAILER_LANG["instantiate"] = 'Kuni ikki instantiera mail funktión.';
$PHPMAILER_LANG["authenticate"] = 'SMTP feilur: Kundi ikki góðkenna.';
$PHPMAILER_LANG["from_failed"] = 'fylgjandi Frá/From adressa miseydnaðist: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Feilur: Fylgjandi ' .
'móttakarar miseydnaðust: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP feilur: Data ikki góðkent.';
$PHPMAILER_LANG["connect_host"] = 'SMTP feilur: Kundi ikki knýta samband við SMTP vert.';
$PHPMAILER_LANG["file_access"] = 'Kundi ikki tilganga fílu: ';
$PHPMAILER_LANG["file_open"] = 'Fílu feilur: Kundi ikki opna fílu: ';
$PHPMAILER_LANG["encoding"] = 'Ókend encoding: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* French Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Vous devez fournir au moins une ' .
'adresse de destinataire.';
$PHPMAILER_LANG["mailer_not_supported"] = ' client de messagerie non supporté.';
$PHPMAILER_LANG["execute"] = 'Impossible de lancer l\'exécution : ';
$PHPMAILER_LANG["instantiate"] = 'Impossible d\'instancier la fonction mail.';
$PHPMAILER_LANG["authenticate"] = 'Erreur SMTP : Echec de l\'authentification.';
$PHPMAILER_LANG["from_failed"] = 'L\'adresse d\'expéditeur suivante a échouée : ';
$PHPMAILER_LANG["recipients_failed"] = 'Erreur SMTP : Les destinataires ' .
'suivants sont en erreur : ';
$PHPMAILER_LANG["data_not_accepted"] = 'Erreur SMTP : Données incorrects.';
$PHPMAILER_LANG["connect_host"] = 'Erreur SMTP : Impossible de se connecter au serveur SMTP.';
$PHPMAILER_LANG["file_access"] = 'Impossible d\'accéder au fichier : ';
$PHPMAILER_LANG["file_open"] = 'Erreur Fichier : ouverture impossible : ';
$PHPMAILER_LANG["encoding"] = 'Encodage inconnu : ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Hungarian Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Meg kell adnod legalább egy ' .
'címzett email címet.';
$PHPMAILER_LANG["mailer_not_supported"] = ' levelezõ nem támogatott.';
$PHPMAILER_LANG["execute"] = 'Nem tudtam végrehajtani: ';
$PHPMAILER_LANG["instantiate"] = 'Nem sikerült példányosítani a mail funkciót.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Hiba: Sikertelen autentikáció.';
$PHPMAILER_LANG["from_failed"] = 'Az alábbi Feladó cím hibás: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Hiba: Az alábbi ' .
'címzettek hibásak: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Hiba: Nem elfogadható adat.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Hiba: Nem tudtam csatlakozni az SMTP host-hoz.';
$PHPMAILER_LANG["file_access"] = 'Nem sikerült elérni a következõ fájlt: ';
$PHPMAILER_LANG["file_open"] = 'Fájl Hiba: Nem sikerült megnyitni a következõ fájlt: ';
$PHPMAILER_LANG["encoding"] = 'Ismeretlen kódolás: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,29 @@
<?php
/**
* PHPMailer language file.
* Italian version
* @package PHPMailer
* @author Ilias Bartolini <brain79@inwind.it>*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Deve essere fornito almeno un'.
' indirizzo ricevente';
$PHPMAILER_LANG["mailer_not_supported"] = 'Mailer non supportato';
$PHPMAILER_LANG["execute"] = "Impossibile eseguire l'operazione: ";
$PHPMAILER_LANG["instantiate"] = 'Impossibile istanziare la funzione mail';
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Impossibile autenticarsi.';
$PHPMAILER_LANG["from_failed"] = 'I seguenti indirizzi mittenti hanno'.
' generato errore: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: I seguenti indirizzi'.
'destinatari hanno generato errore: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data non accettati dal'.
'server.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Impossibile connettersi'.
' all\'host SMTP.';
$PHPMAILER_LANG["file_access"] = 'Impossibile accedere al file: ';
$PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il file: ';
$PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

Binary file not shown.

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Dutch Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Er moet tenmiste &eacute;&eacute;n ' .
'ontvanger emailadres opgegeven worden.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer wordt niet ondersteund.';
$PHPMAILER_LANG["execute"] = 'Kon niet uitvoeren: ';
$PHPMAILER_LANG["instantiate"] = 'Kon mail functie niet initialiseren.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Fout: authenticatie mislukt.';
$PHPMAILER_LANG["from_failed"] = 'De volgende afzender adressen zijn mislukt: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Fout: De volgende ' .
'ontvangers zijn mislukt: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Fout: Data niet geaccepteerd.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Fout: Kon niet verbinden met SMTP host.';
$PHPMAILER_LANG["file_access"] = 'Kreeg geen toegang tot bestand: ';
$PHPMAILER_LANG["file_open"] = 'Bestandsfout: Kon bestand niet openen: ';
$PHPMAILER_LANG["encoding"] = 'Onbekende codering: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Norwegian Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Du må ha med minst en' .
'mottager adresse.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer er ikke supportert.';
$PHPMAILER_LANG["execute"] = 'Kunne ikke utføre: ';
$PHPMAILER_LANG["instantiate"] = 'Kunne ikke instantiate mail funksjonen.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Feil: Kunne ikke authentisere.';
$PHPMAILER_LANG["from_failed"] = 'Følgende Fra feilet: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Feil: Følgende' .
'mottagere feilet: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Feil: Data ble ikke akseptert.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Feil: Kunne ikke koble til SMTP host.';
$PHPMAILER_LANG["file_access"] = 'Kunne ikke få tilgang til filen: ';
$PHPMAILER_LANG["file_open"] = 'Fil feil: Kunne ikke åpne filen: ';
$PHPMAILER_LANG["encoding"] = 'Ukjent encoding: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Polish Version, encoding: windows-1250
* translated from english lang file ver. 1.72
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Nale¿y podaæ prawid³owy adres email Odbiorcy.';
$PHPMAILER_LANG["mailer_not_supported"] = 'Wybrana metoda wysy³ki wiadomoœci nie jest obs³ugiwana.';
$PHPMAILER_LANG["execute"] = 'Nie mo¿na uruchomiæ: ';
$PHPMAILER_LANG["instantiate"] = 'Nie mo¿na wywo³aæ funkcji mail(). SprawdŸ konfiguracjê serwera.';
$PHPMAILER_LANG["authenticate"] = 'B³¹d SMTP: Nie mo¿na przeprowadziæ autentykacji.';
$PHPMAILER_LANG["from_failed"] = 'Nastêpuj¹cy adres Nadawcy jest jest nieprawid³owy: ';
$PHPMAILER_LANG["recipients_failed"] = 'B³¹d SMTP: Nastêpuj¹cy ' .
'odbiorcy s¹ nieprawid³owi: ';
$PHPMAILER_LANG["data_not_accepted"] = 'B³¹d SMTP: Dane nie zosta³y przyjête.';
$PHPMAILER_LANG["connect_host"] = 'B³¹d SMTP: Nie mo¿na po³¹czyæ siê z wybranym hostem.';
$PHPMAILER_LANG["file_access"] = 'Brak dostêpu do pliku: ';
$PHPMAILER_LANG["file_open"] = 'Nie mo¿na otworzyæ pliku: ';
$PHPMAILER_LANG["encoding"] = 'Nieznany sposób kodowania znaków: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,24 @@
<?php
/**
* PHPMailer language file.
* Romanian Version
* @package PHPMailer
* @author Catalin Constantin <catalin@dazoot.ro> */
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer nu este suportat.';
$PHPMAILER_LANG["execute"] = 'Nu pot executa: ';
$PHPMAILER_LANG["instantiate"] = 'Nu am putut instantia functia mail.';
$PHPMAILER_LANG["authenticate"] = 'Eroare SMTP: Nu a functionat autentificarea.';
$PHPMAILER_LANG["from_failed"] = 'Urmatoarele adrese From au dat eroare: ';
$PHPMAILER_LANG["recipients_failed"] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.';
$PHPMAILER_LANG["connect_host"] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.';
$PHPMAILER_LANG["file_access"] = 'Nu pot accesa fisierul: ';
$PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fisierul: ';
$PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,24 @@
<?php
/**
* PHPMailer language file.
* Russian Version by Alexey Chumakov <alex@chumakov.ru> */
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Ïîæàëóéñòà, ââåäèòå õîòÿ áû îäèí àäğåñ e-mail ' .
'ïîëó÷àòåëÿ.';
$PHPMAILER_LANG["mailer_not_supported"] = ' - ïî÷òîâûé ñåğâåğ íå ïîääåğæèâàåòñÿ.';
$PHPMAILER_LANG["execute"] = 'Íåâîçìîæíî âûïîëíèòü êîìàíäó: ';
$PHPMAILER_LANG["instantiate"] = 'Íåâîçìîæíî çàïóñòèòü ôóíêöèş mail.';
$PHPMAILER_LANG["authenticate"] = 'Îøèáêà SMTP: îøèáêà àâòîğèçàöèè.';
$PHPMAILER_LANG["from_failed"] = 'Íåâåğíûé àäğåñ îòïğàâèòåëÿ: ';
$PHPMAILER_LANG["recipients_failed"] = 'Îøèáêà SMTP: îòïğàâêà ïî ñëåäóşùèì ' .
'àäğåñàì ïîëó÷àòåëåé íå óäàëàñü: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Îøèáêà SMTP: äàííûå íå ïğèíÿòû.';
$PHPMAILER_LANG["connect_host"] = 'Îøèáêà SMTP: íå óäàåòñÿ ïîäêëş÷èòüñÿ ê ñåğâåğó SMTP.';
$PHPMAILER_LANG["file_access"] = 'Íåò äîñòóïà ê ôàéëó: ';
$PHPMAILER_LANG["file_open"] = 'Ôàéëîâàÿ îøèáêà: íå óäàåòñÿ îòêğûòü ôàéë: ';
$PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé âèä êîäèğîâêè: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* PHPMailer language file.
* Swedish Version
* Author: Johan Linnér <johan@linner.biz> */
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'Du måste ange minst en ' .
'mottagares e-postadress.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer stöds inte.';
$PHPMAILER_LANG["execute"] = 'Kunde inte köra: ';
$PHPMAILER_LANG["instantiate"] = 'Kunde inte initiera e-postfunktion.';
$PHPMAILER_LANG["authenticate"] = 'SMTP fel: Kunde inte autentisera.';
$PHPMAILER_LANG["from_failed"] = 'Följande avsändaradress är felaktig: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP fel: Följande ' .
'mottagare är felaktig: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fel: Data accepterades inte.';
$PHPMAILER_LANG["connect_host"] = 'SMTP fel: Kunde inte ansluta till SMTP-server.';
$PHPMAILER_LANG["file_access"] = 'Ingen åtkomst till fil: ';
$PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte öppna fil: ';
$PHPMAILER_LANG["encoding"] = 'Okänt encode-format: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

View File

@ -0,0 +1,26 @@
<?php
/**
* PHPMailer dil dosyası.
* Türkçe Versiyonu
* İZYAZILIM - Elçin Özel - Can Yılmaz - Mehmet Benlioğlu
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'En az bir tane mail adresi belirtmek zorundasınız ' .
'alıcının email adresi.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailler desteklenmemektedir.';
$PHPMAILER_LANG["execute"] = 'Çalıştırılamıyor: ';
$PHPMAILER_LANG["instantiate"] = 'Örnek mail fonksiyonu yaratılamadı.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Hatası: Doğrulanamıyor.';
$PHPMAILER_LANG["from_failed"] = 'Başarısız olan gönderici adresi: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Hatası: ' .
'alıcılara ulaşmadı: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Hatası: Veri kabul edilmedi.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Hatası: SMTP hosta bağlanılamıyor.';
$PHPMAILER_LANG["file_access"] = 'Dosyaya erişilemiyor: ';
$PHPMAILER_LANG["file_open"] = 'Dosya Hatası: Dosya açılamıyor: ';
$PHPMAILER_LANG["encoding"] = 'Bilinmeyen şifreleme: ';
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
?>

1035
includes/Doctrine.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,203 @@
<?php
/*
* $Id: Access.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Provides array access and property overload interface for Doctrine subclasses
*
* @package Doctrine
* @subpackage Access
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess
{
/**
* Set an entire aray to the data
*
* @param array $array An array of key => value pairs
* @return Doctrine_Access
*/
public function setArray(array $array)
{
foreach ($array as $k => $v) {
$this->set($k, $v);
}
return $this;
}
/**
* Set key and value to data
*
* @see set, offsetSet
* @param $name
* @param $value
* @return void
*/
public function __set($name, $value)
{
$this->set($name, $value);
}
/**
* Get key from data
*
* @see get, offsetGet
* @param mixed $name
* @return mixed
*/
public function __get($name)
{
return $this->get($name);
}
/**
* Check if key exists in data
*
* @param string $name
* @return boolean whether or not this object contains $name
*/
public function __isset($name)
{
return $this->contains($name);
}
/**
* Remove key from data
*
* @param string $name
* @return void
*/
public function __unset($name)
{
return $this->remove($name);
}
/**
* Check if an offset axists
*
* @param mixed $offset
* @return boolean Whether or not this object contains $offset
*/
public function offsetExists($offset)
{
return $this->contains($offset);
}
/**
* An alias of get()
*
* @see get, __get
* @param mixed $offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
* Sets $offset to $value
*
* @see set, __set
* @param mixed $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value)
{
if ( ! isset($offset)) {
$this->add($value);
} else {
$this->set($offset, $value);
}
}
/**
* Unset a given offset
*
* @see set, offsetSet, __set
* @param mixed $offset
*/
public function offsetUnset($offset)
{
return $this->remove($offset);
}
/**
* Remove the element with the specified offset
*
* @param mixed $offset The offset to remove
* @return boolean True if removed otherwise false
*/
public function remove($offset)
{
throw new Doctrine_Exception('Remove is not supported for ' . get_class($this));
}
/**
* Return the element with the specified offset
*
* @param mixed $offset The offset to return
* @return mixed
*/
public function get($offset)
{
throw new Doctrine_Exception('Get is not supported for ' . get_class($this));
}
/**
* Set the offset to the value
*
* @param mixed $offset The offset to set
* @param mixed $value The value to set the offset to
*
*/
public function set($offset, $value)
{
throw new Doctrine_Exception('Set is not supported for ' . get_class($this));
}
/**
* Check if the specified offset exists
*
* @param mixed $offset The offset to check
* @return boolean True if exists otherwise false
*/
public function contains($offset)
{
throw new Doctrine_Exception('Contains is not supported for ' . get_class($this));
}
/**
* Add the value
*
* @param mixed $value The value to add
* @return void
*/
public function add($value)
{
throw new Doctrine_Exception('Add is not supported for ' . get_class($this));
}
}

View File

@ -0,0 +1,108 @@
<?php
/*
* $Id: Adapter.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
*
* Doctrine_Adapter
*
* @package Doctrine
* @subpackage Adapter
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Adapter
{
/**
* Adapter constant
*/
const ATTR_AUTOCOMMIT = 0;
const ATTR_CASE = 8;
const ATTR_CLIENT_VERSION = 5;
const ATTR_CONNECTION_STATUS = 7;
const ATTR_CURSOR = 10;
const ATTR_CURSOR_NAME = 9;
const ATTR_DRIVER_NAME = 16;
const ATTR_ERRMODE = 3;
const ATTR_FETCH_CATALOG_NAMES = 15;
const ATTR_FETCH_TABLE_NAMES = 14;
const ATTR_MAX_COLUMN_LEN = 18;
const ATTR_ORACLE_NULLS = 11;
const ATTR_PERSISTENT = 12;
const ATTR_PREFETCH = 1;
const ATTR_SERVER_INFO = 6;
const ATTR_SERVER_VERSION = 4;
const ATTR_STATEMENT_CLASS = 13;
const ATTR_STRINGIFY_FETCHES = 17;
const ATTR_TIMEOUT = 2;
const CASE_LOWER = 2;
const CASE_NATURAL = 0;
const CASE_UPPER = 1;
const CURSOR_FWDONLY = 0;
const CURSOR_SCROLL = 1;
const ERR_ALREADY_EXISTS = NULL;
const ERR_CANT_MAP = NULL;
const ERR_CONSTRAINT = NULL;
const ERR_DISCONNECTED = NULL;
const ERR_MISMATCH = NULL;
const ERR_NO_PERM = NULL;
const ERR_NONE = '00000';
const ERR_NOT_FOUND = NULL;
const ERR_NOT_IMPLEMENTED = NULL;
const ERR_SYNTAX = NULL;
const ERR_TRUNCATED = NULL;
const ERRMODE_EXCEPTION = 2;
const ERRMODE_SILENT = 0;
const ERRMODE_WARNING = 1;
const FETCH_ASSOC = 2;
const FETCH_BOTH = 4;
const FETCH_BOUND = 6;
const FETCH_CLASS = 8;
const FETCH_CLASSTYPE = 262144;
const FETCH_COLUMN = 7;
const FETCH_FUNC = 10;
const FETCH_GROUP = 65536;
const FETCH_INTO = 9;
const FETCH_LAZY = 1;
const FETCH_NAMED = 11;
const FETCH_NUM = 3;
const FETCH_OBJ = 5;
const FETCH_ORI_ABS = 4;
const FETCH_ORI_FIRST = 2;
const FETCH_ORI_LAST = 3;
const FETCH_ORI_NEXT = 0;
const FETCH_ORI_PRIOR = 1;
const FETCH_ORI_REL = 5;
const FETCH_SERIALIZE = 524288;
const FETCH_UNIQUE = 196608;
const NULL_EMPTY_STRING = 1;
const NULL_NATURAL = 0;
const NULL_TO_STRING = NULL;
const PARAM_BOOL = 5;
const PARAM_INPUT_OUTPUT = -2147483648;
const PARAM_INT = 1;
const PARAM_LOB = 3;
const PARAM_NULL = 0;
const PARAM_STMT = 4;
const PARAM_STR = 2;
}

View File

@ -0,0 +1,325 @@
<?php
/*
* $Id: Mock.php 1080 2007-02-10 18:17:08Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* IBM DB2 Adapter. This class was ported from the Zend Framework
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1080 $
*/
class Doctrine_Adapter_Db2 extends Doctrine_Adapter
{
/**
* User-provided configuration.
*
* Basic keys are:
*
* username => (string) Connect to the database as this username.
* password => (string) Password associated with the username.
* host => (string) What host to connect to (default 127.0.0.1)
* dbname => (string) The name of the database to user
* protocol => (string) Protocol to use, defaults to "TCPIP"
* port => (integer) Port number to use for TCP/IP if protocol is "TCPIP"
* persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect)
*
* @var array
*/
protected $_config = array(
'dbname' => null,
'username' => null,
'password' => null,
'host' => 'localhost',
'port' => '50000',
'protocol' => 'TCPIP',
'persistent' => false
);
/**
* Stores the execution mode
*
* Possible values DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF
*
* @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
*/
protected $_executeMode = DB2_AUTOCOMMIT_ON;
/**
* Table name of the last accessed table for an insert operation
* This is a DB2-Adapter-specific member variable with the utmost
* probability you might not find it in other adapters...
*
* @var string
*/
protected $_lastInsertTable = null;
/**
* $config is an array of key/value pairs containing configuration
* options. These options are common to most adapters:
*
* dbname => (string) The name of the database to user
* username => (string) Connect to the database as this username.
* password => (string) Password associated with the username.
* host => (string) What host to connect to, defaults to localhost
* port => (string) The port of the database, defaults to 50000
* persistent => (boolean) Whether to use a persistent connection or not, defaults to false
* protocol => (string) The network protocol, defaults to TCPIP
* options => (array) Other database options such as autocommit, case, and cursor options
*
* @param array $config An array of configuration keys.
*/
public function __construct(array $config)
{
if ( ! isset($config['password'])) {
throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'password' for login credentials.");
}
if ( ! isset($config['username'])) {
throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'username' for login credentials.");
}
if ( ! isset($config['dbname'])) {
throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance.");
}
// keep the config
$this->_config = array_merge($this->_config, (array) $config);
}
/**
* Creates the connection resource
*
* @return void
*/
protected function _connect()
{
if (is_resource($this->_connection)) {
// connection already exists
return;
}
if ( ! extension_loaded('ibm_db2')) {
throw new Doctrine_Adapter_Exception('The IBM DB2 extension is required for this adapter but not loaded');
}
if ($this->_config['persistent']) {
// use persistent connection
$conn_func_name = 'db2_pconnect';
} else {
// use "normal" connection
$conn_func_name = 'db2_connect';
}
if ( ! isset($this->_config['options'])) {
// config options were not set, so set it to an empty array
$this->_config['options'] = array();
}
if ( ! isset($this->_config['options']['autocommit'])) {
// set execution mode
$this->_config['options']['autocommit'] = &$this->_executeMode;
}
if ($this->_config['host'] !== 'localhost') {
// if the host isn't localhost, use extended connection params
$dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .
';DATABASE=' . $this->_config['dbname'] .
';HOSTNAME=' . $this->_config['host'] .
';PORT=' . $this->_config['port'] .
';PROTOCOL=' . $this->_config['protocol'] .
';UID=' . $this->_config['username'] .
';PWD=' . $this->_config['password'] .';';
$this->_connection = $conn_func_name(
$dbname,
null,
null,
$this->_config['options']
);
} else {
// host is localhost, so use standard connection params
$this->_connection = $conn_func_name(
$this->_config['dbname'],
$this->_config['username'],
$this->_config['password'],
$this->_config['options']
);
}
// check the connection
if ( ! $this->_connection) {
throw new Doctrine_Adapter_Exception(db2_conn_errormsg(), db2_conn_error());
}
}
/**
* Close the connection resource
*
* @return void
*/
public function closeConnection()
{
db2_close($this->_connection);
$this->_connection = null;
}
/**
* Prepare a sql statement and return it
*
* @param string $sql The SQL statement with placeholders.
* @return Doctrine_Statement_Db2
*/
public function prepare($sql)
{
$this->_connect();
$stmt = new Doctrine_Statement_Db2($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
}
/**
* Get the current execution mode
*
* @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
*/
public function _getExecuteMode()
{
return $this->_executeMode;
}
/**
* Set the current execution mode
*
* @param integer $mode
* @return void
*/
public function _setExecuteMode($mode)
{
switch ($mode) {
case DB2_AUTOCOMMIT_OFF:
case DB2_AUTOCOMMIT_ON:
$this->_executeMode = $mode;
db2_autocommit($this->_connection, $mode);
break;
default:
throw new Doctrine_Adapter_Exception("execution mode not supported");
break;
}
}
/**
* Quote a raw string.
*
* @param string $value Raw string
* @return string Quoted string
*/
protected function _quote($value)
{
/**
* Some releases of the IBM DB2 extension appear
* to be missing the db2_escape_string() method.
* The method was added in ibm_db2.c revision 1.53
* according to cvs.php.net. But the function is
* not present in my build of PHP 5.2.1.
*/
if (function_exists('db2_escape_string')) {
return db2_escape_string($value);
}
return parent::_quote($value);
}
/**
* Get the symbol used for identifier quoting
*
* @return string
*/
public function getQuoteIdentifierSymbol()
{
$info = db2_server_info($this->_connection);
$identQuote = $info->IDENTIFIER_QUOTE_CHAR;
return $identQuote;
}
/**
* Begin a transaction.
*
* @return void
*/
protected function _beginTransaction()
{
$this->_setExecuteMode(DB2_AUTOCOMMIT_OFF);
}
/**
* Commit a transaction.
*
* @return void
*/
protected function _commit()
{
if ( ! db2_commit($this->_connection)) {
throw new Doctrine_Adapter_Exception(
db2_conn_errormsg($this->_connection),
db2_conn_error($this->_connection));
}
$this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
}
/**
* Rollback a transaction.
*
* @return void
*/
protected function _rollBack()
{
if ( ! db2_rollback($this->_connection)) {
throw new Doctrine_Adapter_Exception(
db2_conn_errormsg($this->_connection),
db2_conn_error($this->_connection));
}
$this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
}
/**
* Set the fetch mode.
*
* @param integer $mode
* @return void
*/
public function setFetchMode($mode)
{
switch ($mode) {
case Doctrine::FETCH_NUM: // seq array
case Doctrine::FETCH_ASSOC: // assoc array
case Doctrine::FETCH_BOTH: // seq+assoc array
case Doctrine::FETCH_OBJ: // object
$this->_fetchMode = $mode;
break;
default:
throw new Doctrine_Adapter_Exception('Invalid fetch mode specified');
break;
}
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Adapter exception class
*
* @package Doctrine
* @subpackage Adapter
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Adapter_Exception extends Doctrine_Exception
{ }

View File

@ -0,0 +1,45 @@
<?php
/*
* $Id: Interface.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* This adapter interface should be implemented by all custom adapters
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
interface Doctrine_Adapter_Interface
{
public function prepare($prepareString);
public function query($queryString);
public function quote($input);
public function exec($statement);
public function lastInsertId();
public function beginTransaction();
public function commit();
public function rollBack();
public function errorCode();
public function errorInfo();
}

View File

@ -0,0 +1,294 @@
<?php
/*
* $Id: Mock.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine mock connection adapter. This class is used for special testing purposes.
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable
{
/**
* Name of the dbms to mock
*
* @var string
*/
private $_name;
/**
* Array of queries executed through this instance of the mock adapter
*
* @var array $queries
*/
private $_queries = array();
/**
* Array of exceptions thrown
*
* @var array $exceptions
*/
private $_exception = array();
/**
* Bool true/false variable for whether or not the last insert failed
*
* @var boolean $lastInsertIdFail
*/
private $_lastInsertIdFail = false;
/**
* Doctrine mock adapter constructor
*
* <code>
* $conn = new Doctrine_Adapter_Mock('mysql');
* </code>
*
* @param string $name
* @return void
*/
public function __construct($name = null)
{
$this->_name = $name;
}
/**
* Get the name of the dbms used in this instance of the mock adapter
*
* @return string $name Name of the dbms
*/
public function getName()
{
return $this->_name;
}
/**
* Pop the last executed query from the array of executed queries and return it
*
* @return string $sql Last executed sql string
*/
public function pop()
{
return array_pop($this->_queries);
}
/**
* Force an exception in to the array of exceptions
*
* @param string $name Name of exception
* @param string $message Message for the exception
* @param integer $code Code of the exception
* @return void
*/
public function forceException($name, $message = '', $code = 0)
{
$this->_exception = array($name, $message, $code);
}
/**
* Prepare a query statement
*
* @param string $query Query to prepare
* @return Doctrine_Adapter_Statement_Mock $mock Mock prepared statement
*/
public function prepare($query)
{
$mock = new Doctrine_Adapter_Statement_Mock($this, $query);
$mock->queryString = $query;
return $mock;
}
/**
* Add query to the stack of executed queries
*
* @param string $query
* @return void
*/
public function addQuery($query)
{
$this->_queries[] = $query;
}
/**
* Fake the execution of query and add it to the stack of executed queries
*
* @param string $query
* @return Doctrine_Adapter_Statement_Mock $stmt
*/
public function query($query)
{
$this->_queries[] = $query;
$e = $this->_exception;
if ( ! empty($e)) {
$name = $e[0];
$this->_exception = array();
throw new $name($e[1], $e[2]);
}
$stmt = new Doctrine_Adapter_Statement_Mock($this, $query);
$stmt->queryString = $query;
return $stmt;
}
/**
* Get all the executed queries
*
* @return array $queries Array of all executed queries
*/
public function getAll()
{
return $this->_queries;
}
/**
* Quote a value for the dbms
*
* @param string $input
* @return string $quoted
*/
public function quote($input)
{
return "'" . addslashes($input) . "'";
}
/**
* Execute a raw sql statement
*
* @param string $statement
* @return void
*/
public function exec($statement)
{
$this->_queries[] = $statement;
$e = $this->_exception;
if ( ! empty($e)) {
$name = $e[0];
$this->_exception = array();
throw new $name($e[1], $e[2]);
}
return 0;
}
/**
* Force last insert to be failed
*
* @param boolean $fail
* @return void
*/
public function forceLastInsertIdFail($fail = true)
{
if ($fail) {
$this->_lastInsertIdFail = true;
} else {
$this->_lastInsertIdFail = false;
}
}
/**
* Get the id of the last inserted record
*
* @return integer $id
*/
public function lastInsertId()
{
$this->_queries[] = 'LAST_INSERT_ID()';
if ($this->_lastInsertIdFail) {
return null;
} else {
return 1;
}
}
/**
* Get the number of queries executed
*
* @return integer $count
*/
public function count()
{
return count($this->_queries);
}
/**
* Begin a transaction
*
* @return void
*/
public function beginTransaction()
{
$this->_queries[] = 'BEGIN TRANSACTION';
}
/**
* Commit a transaction
*
* @return void
*/
public function commit()
{
$this->_queries[] = 'COMMIT';
}
/**
* Rollback a transaction
*
* @return void
*/
public function rollBack()
{
$this->_queries[] = 'ROLLBACK';
}
public function getAttribute($attribute)
{
if ($attribute == Doctrine::ATTR_DRIVER_NAME) {
return strtolower($this->_name);
}
}
public function errorCode()
{ }
public function errorInfo()
{ }
public function setAttribute($attribute, $value)
{ }
public function sqliteCreateFunction()
{ }
}

View File

@ -0,0 +1,142 @@
<?php
/*
* $Id: Mock.php 1080 2007-02-10 18:17:08Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Custom Doctrine connection adapter for mysqli
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1080 $
*/
class Doctrine_Adapter_Mysqli extends Doctrine_Adapter
{
/**
* Creates a connection to the database.
*
* @return void
* @throws Doctrine_Adapter_Exception
*/
protected function _connect()
{
if ($this->_connection) {
return;
}
// Suppress connection warnings here.
// Throw an exception instead.
@$this->_connection = new mysqli(
$this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname']
);
if ($this->_connection === false || mysqli_connect_errno()) {
throw new Doctrine_Adapter_Exception(mysqli_connect_error());
}
}
/**
* Force the connection to close.
*
* @return void
*/
public function closeConnection()
{
$this->_connection->close();
$this->_connection = null;
}
/**
* Prepare a statement and return a PDOStatement-like object.
*
* @param string $sql SQL query
* @return Doctrine_Statement_Mysqli
*/
public function prepare($sql)
{
$this->_connect();
$stmt = new Doctrine_Statement_Mysqli($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
}
/**
* lastInsertId
*
* Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
*
* As a convention, on RDBMS brands that support sequences
* (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
* from the arguments and returns the last id generated by that sequence.
* On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
* returns the last value generated for such a column, and the table name
* argument is disregarded.
*
* MySQL does not support sequences, so $tableName and $primaryKey are ignored.
*
* @param string $tableName OPTIONAL Name of table.
* @param string $primaryKey OPTIONAL Name of primary key column.
* @return integer
*/
public function lastInsertId($tableName = null, $primaryKey = null)
{
$mysqli = $this->_connection;
return $mysqli->insert_id;
}
/**
* Begin a transaction.
*
* @return void
*/
protected function _beginTransaction()
{
$this->_connect();
$this->_connection->autocommit(false);
}
/**
* Commit a transaction.
*
* @return void
*/
protected function _commit()
{
$this->_connect();
$this->_connection->commit();
$this->_connection->autocommit(true);
}
/**
* Roll-back a transaction.
*
* @return void
*/
protected function _rollBack()
{
$this->_connect();
$this->_connection->rollback();
$this->_connection->autocommit(true);
}
}

View File

@ -0,0 +1,287 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Custom Doctrine connection adapter for oracle
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author vadik56
* @author Miloslav Kmet <adrive-nospam@hip-hop.sk>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
*/
class Doctrine_Adapter_Oracle implements Doctrine_Adapter_Interface{
/**
* execution mode
*/
protected $executeMode = OCI_COMMIT_ON_SUCCESS;
/**
* Resource representing connection to database
*/
protected $connection = false;
protected $attributes = array(Doctrine::ATTR_DRIVER_NAME => "oci8",
Doctrine::ATTR_ERRMODE => Doctrine::ERRMODE_SILENT);
/**
* User-provided configuration.
*
* Basic keys are:
*
* username => (string) Connect to the database as this username.
* password => (string) Password associated with the username.
* dbname => Either the name of the local Oracle instance, or the
* name of the entry in tnsnames.ora to which you want to connect.
*
* @var array
*/
protected $config = array('dbname' => null,
'username' => null,
'password' => null,
'charset' => null);
/**
* Doctrine Oracle adapter constructor
*
* <code>
* $conn = new Doctrine_Adapter_Oracle(array('dbname'=>'db','username'=>'usr','password'=>'pass'));
* </code>
*
* or
*
* <code>
* Doctrine_Manager::connection(array('oracle:dbname=SID;charset=NLS_CHARACTERSET','usr', 'pass'),"doctrine_connection_name")
* </code>
*
* @param string $name
* @return void
*/
public function __construct($config = array(), $username = null, $password = null)
{
if (is_string($config))
{
$config = str_replace("oracle:","",$config);
$parts = explode(";", $config);
foreach($parts as $part) {
list($var, $value)=explode("=", $part);
switch($var)
{
case 'dbname':
$this->config['dbname'] = $value;
break;
case 'charset':
$this->config['charset'] = $value;
break;
}
}
$this->config['username'] = $username;
$this->config['password'] = $password;
} else {
if ( ! isset($config['password']) || ! isset($config['username'])) {
throw new Doctrine_Adapter_Exception('config array must have at least a username and a password');
}
$this->config['username'] = $config['username'];
$this->config['password'] = $config['password'];
$this->config['dbname'] = $config['dbname'];
$this->config['charset'] = $config['charset'];
}
$this->connection = @oci_connect($this->config['username'], $this->config['password'],
$this->config['dbname'], $this->config['charset']);
if ($this->connection === false) {
throw new Doctrine_Adapter_Exception(sprintf("Unable to Connect to :'%s' as '%s'", $this->config['dbname'], $this->config['username']));
}
}
/**
* Prepare a query statement
*
* @param string $query Query to prepare
* @return Doctrine_Adapter_Statement_Oracle $stmt prepared statement
*/
public function prepare($query)
{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode);
return $stmt;
}
/**
* Execute query and return results as statement object
*
* @param string $query
* @return Doctrine_Adapter_Statement_Oracle $stmt
*/
public function query($query)
{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode);
$stmt->execute();
return $stmt;
}
/**
* Quote a value for the dbms
*
* @param string $input
* @return string $quoted
*/
public function quote($input)
{
return "'" . str_replace("'","''",$input) . "'";
}
/**
* Execute a raw sql statement
*
* @param string $statement
* @return void
*/
public function exec($statement)
{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $statement, $this->executeMode);
$stmt->execute();
$count = $stmt->rowCount();
return $count;
}
/**
* Get the id of the last inserted record
*
* @return integer $id
*/
public function lastInsertId()
{
throw new Exception("unsupported");
}
/**
* Begin a transaction
*
* @return boolean
*/
public function beginTransaction()
{
$this->executeMode = OCI_DEFAULT;
return true;
}
/**
* Commit a transaction
*
* @return void
*/
public function commit()
{
return @oci_commit($this->connection);
}
/**
* Rollback a transaction
*
* @return boolean
*/
public function rollBack()
{
return @oci_rollback($this->connection);
}
/**
* Set connection attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value)
{
switch ($attribute) {
case Doctrine::ATTR_DRIVER_NAME:
//TODO throw an error since driver name can not be changed
case Doctrine::ATTR_ERRMODE:
break;
case Doctrine::ATTR_CASE:
if ($value == Doctrine::CASE_NATURAL) {
break;
} else {
throw new Doctrine_Adapter_Exception("Unsupported Option for ATTR_CASE: $value");
}
default:
throw new Doctrine_Adapter_Exception("Unsupported Attribute: $attribute");
return false;
}
$this->attributes[$attribute] = $value;
return true;
}
/**
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute)
{
return $this->attributes[$attribute];
}
/**
* Returns established OCI connection handler
*
* @return resource OCI connection handler
*/
public function getConnection()
{
return $this->connection;
}
public function errorCode()
{
if (is_resource($this->connection)) {
$error = @oci_error($this->connection);
} else {
$error = @oci_error();
}
return $error['code'];
}
public function errorInfo()
{
if (is_resource($this->connection)) {
$error = @oci_error($this->connection);
} else {
$error = @oci_error();
}
return $error['message'];
}
}

View File

@ -0,0 +1,131 @@
<?php
/*
* $Id: Statement.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Adapter_Statement
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
abstract class Doctrine_Adapter_Statement
{
/**
* bindValue
*
* @param string $no
* @param string $value
* @return void
*/
public function bindValue($no, $value)
{ }
/**
* fetch
*
* @see Doctrine::FETCH_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
* Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
* Doctrine_Adapter_Statement_Interface object,
* you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* Doctrine_Adapter_Statement_Interface->fetch() was called.
*
* @return mixed
*/
public function fetch()
{ }
/**
* nextRowSet
*
* @return void
*/
public function nextRowset()
{ }
/**
* execute()
*
* @return void
*/
public function execute()
{ }
/**
* errorCode
*
* @return void
*/
public function errorCode()
{ }
/**
* errorInfo
*
* @return void
*/
public function errorInfo()
{ }
/**
* rowCount
*
* @return void
*/
public function rowCount()
{ }
/**
* setFetchMode
*
* @param string $mode
* @return void
*/
public function setFetchMode($mode)
{ }
/**
* columnCount
*
* @return void
*/
public function columnCount()
{ }
}

View File

@ -0,0 +1,276 @@
<?php
/*
* $Id: Interface.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Interface for Doctrine adapter statements
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
interface Doctrine_Adapter_Statement_Interface
{
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, $param, $type = null);
/**
* Binds a value to a corresponding named or question mark
* placeholder in the SQL statement that was use to prepare the statement.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $value The value to bind to the parameter.
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null);
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that Doctrine_Adapter_Statement_Interface->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
*
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter
* from a stored procedure, you must explicitly set the length.
* @param mixed $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array());
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor();
/**
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the Doctrine_Adapter_Statement_Interface object. If there is no result set,
* this method should return 0.
*/
public function columnCount();
/**
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode();
/**
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo();
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null);
/**
* fetch
*
* @see Doctrine::FETCH_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
* Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
* Doctrine_Adapter_Statement_Interface object,
* you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* Doctrine_Adapter_Statement_Interface->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchStyle = Doctrine::FETCH_BOTH,
$cursorOrientation = Doctrine::FETCH_ORI_NEXT,
$cursorOffset = null);
/**
* Returns an array containing all of the result set rows
*
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Doctrine::FETCH_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH);
/**
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0);
/**
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array());
/**
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute);
/**
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column);
/**
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset();
/**
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount();
/**
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value);
/**
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1 = null, $arg2 = null);
}

View File

@ -0,0 +1,379 @@
<?php
/*
* $Id: Mock.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Mock connection adapter statement class. Used for special testing purposes
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface
{
/**
* Variable which stores instance of Doctrine_Adapter_Mock
*
* @var Doctrine_Adapter_Mock
*/
private $_mock;
/**
* queryString
*
* @var string
*/
public $queryString;
/**
* Constructor for mock adapter statements. Accepts instance of Doctrine_Adapter_Mock
*
* @param Doctrine_Adapter_Mock $mock
*/
public function __construct($mock)
{
$this->_mock = $mock;
}
/**
* bindColumn
*
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, $param, $type = null)
{ }
/**
* bindValue
*
* Binds a value to a corresponding named or question mark
* placeholder in the SQL statement that was use to prepare the statement.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $value The value to bind to the parameter.
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null)
{ }
/**
* bindParam
*
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that Doctrine_Adapter_Statement_Interface->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
*
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter
* from a stored procedure, you must explicitly set the length.
* @param mixed $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
}
/**
* closeCursor
*
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor()
{
return true;
}
/**
* columnCount
*
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the Doctrine_Adapter_Statement_Interface object. If there is no result set,
* this method should return 0.
*/
public function columnCount()
{
return 0;
}
/**
* errorCode
*
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode()
{
return array();
}
/**
* errorInfo
*
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo()
{
return array();
}
/**
* fetch
*
* @see Doctrine::FETCH_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
* Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
* Doctrine_Adapter_Statement_Interface object,
* you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* Doctrine_Adapter_Statement_Interface->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchStyle = Doctrine::FETCH_BOTH,
$cursorOrientation = Doctrine::FETCH_ORI_NEXT,
$cursorOffset = null)
{
return array();
}
/**
* fetchAll
*
* Returns an array containing all of the result set rows
*
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Doctrine::FETCH_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchMode = Doctrine::FETCH_BOTH)
{
return array();
}
/**
* execute
*
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
if (is_object($this->_mock)) {
$this->_mock->addQuery($this->queryString);
}
return true;
}
/**
* fetchColumn
*
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0)
{
return 0;
}
/**
* fetchObject
*
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array())
{
return new $className();
}
/**
* nextRowset
*
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset()
{
return true;
}
/**
* rowCount
*
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount()
{
return 0;
}
/**
* getColumnMeta
*
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column)
{ }
/**
* getAttribute
*
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute)
{ }
/**
* setAttribute
*
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value)
{ }
/**
* setFetchMode
*
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1 = null, $arg2 = null)
{ }
}

View File

@ -0,0 +1,586 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Oracle connection adapter statement class.
*
* @package Doctrine
* @subpackage Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author vadik56
* @author Miloslav Kmet <adrive-nospam@hip-hop.sk>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Rev$
*/
class Doctrine_Adapter_Statement_Oracle implements Doctrine_Adapter_Statement_Interface
{
/**
* @var string $queryString actual query string
*/
public $queryString;
/**
* @var resource $connection OCI connection handler
*/
protected $connection;
/**
* @var resource $statement OCI prepared statement
*/
protected $statement;
/**
* @var integer $executeMode OCI statement execution mode
*/
protected $executeMode = OCI_COMMIT_ON_SUCCESS;
/**
* @var array $bind_params Array of parameters bounded to a statement
*/
protected $bindParams = array();
/**
* @var array $attributes Array of attributes
*/
protected $attributes = array();
/**
* @var array $ociErrors Array of errors
*/
protected $ociErrors = array();
/**
* the constructor
*
* @param Doctrine_Adapter_Oracle $connection
* @param string $query Query string to be executed
* @param integer $executeMode OCI execute mode
*/
public function __construct( Doctrine_Adapter_Oracle $connection, $query, $executeMode)
{
$this->connection = $connection->getConnection();
$this->queryString = $query;
$this->executeMode = $executeMode;
$this->attributes[Doctrine::ATTR_ERRMODE] = $connection->getAttribute(Doctrine::ATTR_ERRMODE);
$this->parseQuery();
}
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, $param, $type = null)
{
throw new Exception("Unsupported");
}
/**
* Binds a value to a corresponding named or question mark
* placeholder in the SQL statement that was use to prepare the statement.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $value The value to bind to the parameter.
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null){
/**
* need to store the value internally since binding is done by reference
*/
$this->bindParams[] = $value;
$this->bindParam($param, $this->bindParams[count($this->bindParams) - 1], $type);
}
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that Doctrine_Adapter_Statement_Interface->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter
*
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
*
* @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter
* from a stored procedure, you must explicitly set the length.
* @param mixed $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()){
if ($driverOptions || $length ) {
throw new Doctrine_Adapter_Exception('Unsupported parameters:$length, $driverOptions');
}
if ($length === null) {
$oci_length = -1;
}
$oci_type = SQLT_CHR;
switch ($type) {
case Doctrine::PARAM_STR:
$oci_type = SQLT_CHR;
break;
}
if (is_integer($column)) {
$variable_name = ":oci_b_var_$column";
} else {
$variable_name = $column;
}
//print "Binding $variable to $variable_name".PHP_EOL;
$status = @oci_bind_by_name($this->statement, $variable_name, $variable, $oci_length, $oci_type);
if($status === false){
$this->handleError();
}
return $status;
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor(){
$this->bind_params = array();
return oci_free_statement($this->statement);
}
/**
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the Doctrine_Adapter_Statement_Interface object. If there is no result set,
* this method should return 0.
*/
public function columnCount(){
return oci_num_fields ( $this->statement );
}
/**
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode(){
$oci_error = $this->getOciError();
return $oci_error['code'];
}
/**
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo(){
$oci_error = $this->getOciError();
return $oci_error['message'] . " : " . $oci_error['sqltext'];
}
private function getOciError()
{
if (is_resource($this->statement)) {
$oci_error = oci_error ($this->statement);
} else {
$oci_error = oci_error ();
}
if ($oci_error) {
//store the error
$this->oci_errors[] = $oci_error;
} else if (count($this->ociErrors) > 0) {
$oci_error = $this->ociErrors[count($this->ociErrors)-1];
}
return $oci_error;
}
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
if (is_array($params)) {
foreach ($params as $var => $value) {
$this->bindValue($var, $value);
}
}
$result = @oci_execute($this->statement , $this->executeMode );
if ($result === false) {
$this->handleError();
return false;
}
return true;
}
/**
* fetch
*
* @see Doctrine::FETCH_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
* Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
* Doctrine_Adapter_Statement_Interface object,
* you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* Doctrine_Adapter_Statement_Interface->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchStyle = Doctrine::FETCH_BOTH, $cursorOrientation = Doctrine::FETCH_ORI_NEXT, $cursorOffset = null)
{
switch ($fetchStyle) {
case Doctrine::FETCH_BOTH :
return oci_fetch_array($this->statement, OCI_BOTH + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
break;
case Doctrine::FETCH_ASSOC :
return oci_fetch_array($this->statement, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
break;
case Doctrine::FETCH_NUM :
return oci_fetch_array($this->statement, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
break;
case FETCH_OBJ:
return oci_fetch_object($this->statement, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
break;
default:
throw new Doctrine_Adapter_Exception("This type of fetch is not supported: ".$fetchStyle);
/*
case Doctrine::FETCH_BOUND:
case Doctrine::FETCH_CLASS:
case FETCH_CLASSTYPE:
case FETCH_COLUMN:
case FETCH_FUNC:
case FETCH_GROUP:
case FETCH_INTO:
case FETCH_LAZY:
case FETCH_NAMED:
case FETCH_SERIALIZE:
case FETCH_UNIQUE:
case FETCH_ORI_ABS:
case FETCH_ORI_FIRST:
case FETCH_ORI_LAST:
case FETCH_ORI_NEXT:
case FETCH_ORI_PRIOR:
case FETCH_ORI_REL:
*/
}
}
/**
* Returns an array containing all of the result set rows
*
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Doctrine::FETCH_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH, $colnum=0)
{
$fetchColumn = false;
$skip = 0;
$maxrows = -1;
$data = array();
$flags = OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC;
$int = $fetchStyle & Doctrine::FETCH_COLUMN;
if ($fetchStyle == Doctrine::FETCH_BOTH) {
$flags = OCI_BOTH;
} else if ($fetchStyle == Doctrine::FETCH_ASSOC) {
$numberOfRows = @oci_fetch_all($this->statement, $data, $skip, $maxrows, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC + OCI_RETURN_LOBS);
} else if ($fetchStyle == Doctrine::FETCH_NUM) {
$numberOfRows = @oci_fetch_all($this->statement, $data, $skip, $maxrows, OCI_FETCHSTATEMENT_BY_ROW + OCI_NUM + OCI_RETURN_LOBS);
} else if ($fetchStyle == Doctrine::FETCH_COLUMN) {
while ($row = @oci_fetch_array ($this->statement, OCI_NUM+OCI_RETURN_LOBS)) {
$data[] = $row[$colnum];
}
} else {
throw new Exception("Unsupported mode: '" . $fetchStyle . "' ");
}
return $data;
}
/**
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0)
{
if( ! is_integer($columnIndex)) {
$this->handleError(array('message'=>"columnIndex parameter should be numeric"));
}
$row = $this->fetch(Doctrine::FETCH_NUM);
return $row[$columnIndex];
}
/**
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array())
{
$row = $this->fetch(Doctrine::FETCH_ASSOC);
if ($row === false) {
return false;
}
$instantiation_code = "\$object = new $className(";
$firstParam=true;
foreach ($args as $index=>$value) {
if ( ! $firstParam ) {
$instantiation_code = $instantiation_code . ",";
} else {
$firstParam= false;
}
if ( is_string($index)) {
$instantiation_code = $instantiation_code . " \$args['$index']";
} else {
$instantiation_code = $instantiation_code . "\$args[$index]";
}
}
$instantiation_code = $instantiation_code . ");";
eval($instantiation_code);
//initialize instance of $className class
foreach ($row as $col => $value) {
$object->$col = $value;
}
return $object;
}
/**
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column)
{
if (is_integer($column)) {
$internal_column = $column +1;
} else {
$internal_column = $column;
}
$data = array();
$data['native_type'] = oci_field_type($this->statement, $internal_column);
$data['flags'] = "";
$data['len'] = oci_field_size($this->statement, $internal_column);
$data['name'] = oci_field_name($this->statement, $internal_column);
$data['precision'] = oci_field_precision($this->statement, $internal_column);
return $data;
}
/**
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset()
{
throw new Exception("Unsupported");
}
/**
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount()
{
return @oci_num_rows($this->statement);
}
/**
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value)
{
switch ($attribute) {
case Doctrine::ATTR_ERRMODE;
break;
default:
throw new Doctrine_Adapter_Exception("Unsupported Attribute: $attribute");
}
$this->attributes[$attribute] = $value;
}
/**
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute)
{
return $this->attributes[$attribute];
}
/**
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1 = null, $arg2 = null)
{
throw new Exception("Unsupported");
}
private function handleError($params=array())
{
switch ($this->attributes[Doctrine::ATTR_ERRMODE]) {
case Doctrine::ERRMODE_EXCEPTION:
if (isset($params['message'])) {
throw new Doctrine_Adapter_Exception($params['message']);
} else {
throw new Doctrine_Adapter_Exception($this->errorInfo());
}
break;
case Doctrine::ERRMODE_WARNING:
case Doctrine::ERRMODE_SILENT:
break;
}
}
/**
* Parse actual query from queryString and returns OCI statement handler
* @param string Query string to parse, if NULL, $this->queryString is used
*
* @return resource OCI statement handler
*/
private function parseQuery($query=null)
{
if (is_null($query)) {
$query = $this->queryString;
}
$bind_index = 0;
// Replace ? bind-placeholders with :oci_b_var_ variables
$query = preg_replace("/(\?)/e", '":oci_b_var_". $bind_index++' , $query);
$this->statement = @oci_parse($this->connection, $query);
if ( $this->statement == false )
{
throw new Doctrine_Adapter_Exception($this->getOciError());
}
return $this->statement;
}
}

View File

@ -0,0 +1,157 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_AuditLog
*
* @package Doctrine
* @subpackage AuditLog
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_AuditLog extends Doctrine_Record_Generator
{
/**
* Array of AuditLog Options
*
* @var array
*/
protected $_options = array('className' => '%CLASS%Version',
'version' => array('name' => 'version',
'alias' => null,
'type' => 'integer',
'length' => 8,
'options' => array('primary' => true)),
'tableName' => false,
'generateFiles' => false,
'table' => false,
'pluginTable' => false,
'children' => array(),
'auditLog' => true,
'deleteVersions' => true);
/**
* Accepts array of options to configure the AuditLog
*
* @param array $options An array of options
* @return void
*/
public function __construct(array $options = array())
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
}
/**
* Set the table definition for the audit log table
*
* @return void
*/
public function setTableDefinition()
{
$name = $this->_options['table']->getComponentName();
// Building columns
$columns = $this->_options['table']->getColumns();
// remove all sequence, autoincrement and unique constraint definitions and add to the behavior model
foreach ($columns as $column => $definition) {
unset($definition['autoincrement']);
unset($definition['sequence']);
unset($definition['unique']);
$fieldName = $this->_options['table']->getFieldName($column);
if ($fieldName != $column) {
$name = $column . ' as ' . $fieldName;
} else {
$name = $fieldName;
}
$this->hasColumn($name, $definition['type'], $definition['length'], $definition);
}
// the version column should be part of the primary key definition
$this->hasColumn(
$this->_options['version']['name'],
$this->_options['version']['type'],
$this->_options['version']['length'],
$this->_options['version']['options']);
}
/**
* Get array of information for the passed record and the specified version
*
* @param Doctrine_Record $record
* @param integer $version
* @param integer $hydrationMode
* @param boolean $asCollection
* @return array An array or Doctrine_Collection or a Doctrine_Record
*/
public function getVersion(Doctrine_Record $record, $version, $hydrationMode = Doctrine::HYDRATE_ARRAY, $asCollection = true)
{
$className = $this->_options['className'];
$method = ($asCollection) ? 'execute' : 'fetchOne';
$q = new Doctrine_Query();
$values = array();
foreach ((array) $this->_options['table']->getIdentifier() as $id) {
$conditions[] = $className . '.' . $id . ' = ?';
$values[] = $record->get($id);
}
$where = implode(' AND ', $conditions) . ' AND ' . $className . '.' . $this->_options['version']['name'] . ' = ?';
$values[] = $version;
$q->from($className)->where($where);
return $q->$method($values, $hydrationMode);
}
/**
* Get the max version number for a given Doctrine_Record
*
* @param Doctrine_Record $record
* @return Integer $versionnumber
*/
public function getMaxVersion(Doctrine_Record $record)
{
$className = $this->_options['className'];
$select = 'MAX(' . $className . '.' . $this->_options['version']['name'] . ') max_version';
foreach ((array) $this->_options['table']->getIdentifier() as $id) {
$conditions[] = $className . '.' . $id . ' = ?';
$values[] = $record->get($id);
}
$q = Doctrine_Query::create()
->select($select)
->from($className)
->where(implode(' AND ',$conditions));
$result = $q->execute($values, Doctrine::HYDRATE_ARRAY);
return isset($result[0]['max_version']) ? $result[0]['max_version']:0;
}
}

View File

@ -0,0 +1,152 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_AuditLog_Listener
*
* @package Doctrine
* @subpackage AuditLog
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_AuditLog_Listener extends Doctrine_Record_Listener
{
/**
* Instance of Doctrine_Auditlog
*
* @var Doctrine_AuditLog
*/
protected $_auditLog;
/**
* Instantiate AuditLog listener and set the Doctrine_AuditLog instance to the class
*
* @param Doctrine_AuditLog $auditLog
* @return void
*/
public function __construct(Doctrine_AuditLog $auditLog)
{
$this->_auditLog = $auditLog;
}
/**
* Pre insert event hook for incrementing version number
*
* @param Doctrine_Event $event
* @return void
*/
public function preInsert(Doctrine_Event $event)
{
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
$event->getInvoker()->set($name, 1);
}
/**
* Post insert event hook which creates the new version record
* This will only insert a version record if the auditLog is enabled
*
* @param Doctrine_Event $event
* @return void
*/
public function postInsert(Doctrine_Event $event)
{
if ($this->_auditLog->getOption('auditLog')) {
$class = $this->_auditLog->getOption('className');
$record = $event->getInvoker();
$version = new $class();
$version->merge($record->toArray(), false);
$version->save();
}
}
/**
* Pre delete event hook deletes all related versions
* This will only delete version records if the auditLog is enabled
*
* @param Doctrine_Event $event
* @return void
*/
public function preDelete(Doctrine_Event $event)
{
if ($this->_auditLog->getOption('auditLog')) {
$className = $this->_auditLog->getOption('className');
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
$event->getInvoker()->set($name, null);
if ($this->_auditLog->getOption('deleteVersions')) {
$q = Doctrine_Query::create();
foreach ((array) $this->_auditLog->getOption('table')->getIdentifier() as $id) {
$conditions[] = 'obj.' . $id . ' = ?';
$values[] = $event->getInvoker()->get($id);
}
$rows = $q->delete($className)
->from($className.' obj')
->where(implode(' AND ', $conditions))
->execute($values);
}
}
}
/**
* Pre update event hook for inserting new version record
* This will only insert a version record if the auditLog is enabled
*
* @param Doctrine_Event $event
* @return void
*/
public function preUpdate(Doctrine_Event $event)
{
if ($this->_auditLog->getOption('auditLog')) {
$class = $this->_auditLog->getOption('className');
$record = $event->getInvoker();
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
$record->set($name, $this->_getNextVersion($record));
$version = new $class();
$version->merge($record->toArray(), false);
$version->save();
}
}
/**
* Get the next version number for the audit log
*
* @param Doctrine_Record $record
* @return integer $nextVersion
*/
protected function _getNextVersion(Doctrine_Record $record)
{
if ($this->_auditLog->getOption('auditLog')) {
return ($this->_auditLog->getMaxVersion($record) + 1);
}
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
* $Id: Builder.php 4593 2008-06-29 03:24:50Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Base class for any code builders/generators for Doctrine
*
* @package Doctrine
* @subpackage Builder
* @link www.phpdoctrine.org
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0
* @version $Revision: 4593 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class Doctrine_Builder
{
/**
* Special function for var_export()
* The normal code which is returned is malformed and does not follow Doctrine standards
* So we do some string replacing to clean it up
*
* @param string $var
* @return void
*/
public function varExport($var)
{
$export = var_export($var, true);
$export = str_replace("\n", PHP_EOL . str_repeat(' ', 50), $export);
$export = str_replace(' ', ' ', $export);
$export = str_replace('array (', 'array(', $export);
$export = str_replace('array( ', 'array(', $export);
$export = str_replace(',)', ')', $export);
$export = str_replace(', )', ')', $export);
$export = str_replace(' ', ' ', $export);
return $export;
}
}

416
includes/Doctrine/Cache.php Normal file
View File

@ -0,0 +1,416 @@
<?php
/*
* $Id: Cache.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Cache
*
* @package Doctrine
* @subpackage Cache
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
*/
class Doctrine_Cache extends Doctrine_EventListener implements Countable, IteratorAggregate
{
/**
* @var array $_options an array of general caching options
*/
protected $_options = array('size' => 1000,
'lifeTime' => 3600,
'addStatsPropability' => 0.25,
'savePropability' => 0.10,
'cleanPropability' => 0.01,
'statsFile' => '../data/stats.cache',
);
/**
* @var array $_queries query stack
*/
protected $_queries = array();
/**
* @var Doctrine_Cache_Interface $_driver the cache driver object
*/
protected $_driver;
/**
* @var array $data current cache data array
*/
protected $_data = array();
/**
* @var boolean $success the success of last operation
*/
protected $_success = false;
/**
* constructor
*
* @param Doctrine_Cache_Interface|string $driver cache driver name or a driver object
* @param array $options cache driver options
*/
public function __construct($driver, $options = array())
{
if (is_object($driver)) {
if ( ! ($driver instanceof Doctrine_Cache_Interface)) {
throw new Doctrine_Cache_Exception('Driver should implement Doctrine_Cache_Interface.');
}
$this->_driver = $driver;
$this->_driver->setOptions($options);
} else {
$class = 'Doctrine_Cache_' . ucwords(strtolower($driver));
if ( ! class_exists($class)) {
throw new Doctrine_Cache_Exception('Cache driver ' . $driver . ' could not be found.');
}
$this->_driver = new $class($options);
}
}
/**
* Get the current cache driver instance
*
* @return Doctrine_Cache_Driver $driver
*/
public function getDriver()
{
return $this->_driver;
}
/**
* Set option name and value
*
* @param mixed $option the option name
* @param mixed $value option value
* @return boolean TRUE on success, FALSE on failure
*/
public function setOption($option, $value)
{
// sanity check (we need this since we are using isset() instead of array_key_exists())
if ($value === null) {
throw new Doctrine_Cache_Exception('Null values not accepted for options.');
}
if (isset($this->_options[$option])) {
$this->_options[$option] = $value;
return true;
}
return false;
}
/**
* Get value of option name
*
* @param mixed $option the option name
* @return mixed option value
*/
public function getOption($option)
{
if ( ! isset($this->_options[$option])) {
throw new Doctrine_Cache_Exception('Unknown option ' . $option);
}
return $this->_options[$option];
}
/**
* Adds a query to internal query stack
*
* @param string|array $query sql query string
* @param string $namespace connection namespace
* @return void
*/
public function add($query, $namespace = null)
{
if (isset($namespace)) {
$this->_queries[$namespace][] = $query;
} else {
$this->_queries[] = $query;
}
}
/**
* Get array of all executed queries
*
* @param string $namespace optional query namespace
* @return array an array of sql query strings
*/
public function getAll($namespace = null)
{
if (isset($namespace)) {
if ( ! isset($this->_queries[$namespace])) {
return array();
}
return $this->_queries[$namespace];
}
return $this->_queries;
}
/**
* Pops a query from the stack
*
* @return string $query
*/
public function pop()
{
return array_pop($this->_queries);
}
/**
* Removes all queries from the query stack
*
* @return void
*/
public function reset()
{
$this->_queries = array();
}
/**
* Count the number of queries on the stack
*
* @return integer the number of queries in the stack
*/
public function count()
{
return count($this->_queries);
}
/**
* Get queries iterator
*
* @return ArrayIterator an iterator that iterates through the query stack
*/
public function getIterator()
{
return new ArrayIterator($this->_queries);
}
/**
* Check whether or not the last cache opration was successful or not
*
* @return boolean whether or not the last cache operation was successful
*/
public function isSuccessful()
{
return $this->_success;
}
/**
* Delete all cache
*
* @return void
*/
public function clean()
{
$rand = (mt_rand() / mt_getrandmax());
if ($rand <= $this->_options['cleanPropability']) {
$queries = $this->readStats();
$stats = array();
foreach ($queries as $query) {
if (isset($stats[$query])) {
$stats[$query]++;
} else {
$stats[$query] = 1;
}
}
sort($stats);
$i = $this->_options['size'];
while ($i--) {
$element = next($stats);
$query = key($stats);
$hash = md5($query);
$this->_driver->delete($hash);
}
}
}
/**
* Read stats file from disk
*
* @return array $stats
*/
public function readStats()
{
if ($this->_options['statsFile'] !== false) {
$content = file_get_contents($this->_options['statsFile']);
$e = explode("\n", $content);
return array_map('unserialize', $e);
}
return array();
}
/**
* Append all queries to stats file
* @return void
*/
public function appendStats()
{
if ($this->_options['statsFile'] !== false) {
if ( ! file_exists($this->_options['statsFile'])) {
throw new Doctrine_Cache_Exception("Couldn't save cache statistics. Cache statistics file doesn't exists!");
}
$rand = (mt_rand() / mt_getrandmax());
if ($rand <= $this->_options['addStatsPropability']) {
file_put_contents($this->_options['statsFile'], implode("\n", array_map('serialize', $this->_queries)));
}
}
}
/**
* Listens on the Doctrine_Event preQuery event
*
* adds the issued query to internal query stack
* and checks if cached element exists
*
* @return boolean
*/
public function preQuery(Doctrine_Event $event)
{
$query = $event->getQuery();
$data = false;
// only process SELECT statements
if (strtoupper(substr(ltrim($query), 0, 6)) != 'SELECT') {
return false;
}
$this->add($query, $event->getInvoker()->getName());
$data = $this->_driver->fetch(md5(serialize($query)));
$this->success = ($data) ? true : false;
if ( ! $data) {
$rand = (mt_rand() / mt_getrandmax());
if ($rand < $this->_options['savePropability']) {
$stmt = $event->getInvoker()->getAdapter()->query($query);
$data = $stmt->fetchAll(Doctrine::FETCH_ASSOC);
$this->success = true;
$this->_driver->save(md5(serialize($query)), $data);
}
}
if ($this->success)
{
$this->_data = $data;
return true;
}
return false;
}
/**
* Listens the preFetch event of Doctrine_Connection_Statement
*
* advances the internal pointer of cached data and returns
* the current element
*
* @return array
*/
public function preFetch(Doctrine_Event $event)
{
$ret = current($this->_data);
next($this->_data);
return $ret;
}
/**
* Listens the preFetchAll event of Doctrine_Connection_Statement
*
* returns the current cache data array
*
* @return array
*/
public function preFetchAll(Doctrine_Event $event)
{
return $this->_data;
}
/**
* Listens the preExecute event of Doctrine_Connection_Statement
*
* adds the issued query to internal query stack
* and checks if cached element exists
*
* @return boolean
*/
public function preExecute(Doctrine_Event $event)
{
$query = $event->getQuery();
$data = false;
// only process SELECT statements
if (strtoupper(substr(ltrim($query), 0, 6)) != 'SELECT') {
return false;
}
$this->add($query, $event->getInvoker()->getDbh()->getName());
$data = $this->_driver->fetch(md5(serialize(array($query, $event->getParams()))));
$this->success = ($data) ? true : false;
if ( ! $data) {
$rand = (mt_rand() / mt_getrandmax());
if ($rand <= $this->_options['savePropability']) {
$stmt = $event->getInvoker()->getStatement();
$stmt->execute($event->getParams());
$data = $stmt->fetchAll(Doctrine::FETCH_ASSOC);
$this->success = true;
$this->_driver->save(md5(serialize(array($query, $event->getParams()))), $data);
}
}
if ($this->success)
{
$this->_data = $data;
return true;
}
return false;
}
}

View File

@ -0,0 +1,98 @@
<?php
/*
* $Id: Apc.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* APC Cache Driver
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Apc extends Doctrine_Cache_Driver
{
/**
* constructor
*
* @param array $options associative array of cache driver options
*/
public function __construct($options = array())
{
if ( ! extension_loaded('apc')) {
throw new Doctrine_Cache_Exception('The apc extension must be loaded for using this backend !');
}
parent::__construct($options);
}
/**
* Test if a cache is available for the given id and (if yes) return it (false else).
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return mixed The stored variable on success. FALSE on failure.
*/
public function fetch($id, $testCacheValidity = true)
{
$results = apc_fetch($this->_getKey($id));
$results = (array) $results;
return $results[0];
}
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id)
{
return apc_fetch($this->_getKey($id)) === false ? false : true;
}
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $data data to cache
* @param string $id cache id
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false)
{
return (bool) apc_store($this->_getKey($id), $data, $lifeTime);
}
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id)
{
return apc_delete($this->_getKey($id));
}
}

View File

@ -0,0 +1,113 @@
<?php
/*
* $Id: Array.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Array cache driver
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Array extends Doctrine_Cache_Driver implements Countable
{
/**
* @var array $data an array of cached data
*/
protected $data;
/**
* Test if a cache is available for the given id and (if yes) return it (false else)
*
* Note : return value is always "string" (unserialization is done by the core not by the backend)
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return string cached datas (or false)
*/
public function fetch($id, $testCacheValidity = true)
{
if (isset($this->data[$id])) {
return $this->data[$id];
}
return false;
}
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id)
{
return isset($this->data[$this->_getKey($id)]);
}
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $data data to cache
* @param string $id cache id
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false)
{
$this->data[$this->_getKey($id)] = $data;
}
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id)
{
unset($this->data[$this->_getKey($id)]);
}
/**
* Remove all cache record
*
* @return boolean true if no problem
*/
public function deleteAll()
{
$this->data = array();
}
/**
* count
*
* @return integer
*/
public function count()
{
return count($this->data);
}
}

View File

@ -0,0 +1,235 @@
<?php
/*
* $Id: Db.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Database cache driver
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Db extends Doctrine_Cache_Driver implements Countable
{
/**
* Configure Database cache driver. Specify instance of Doctrine_Connection
* and tableName to store cache in
*
* @param array $_options an array of options
*/
public function __construct($options = array())
{
if ( ! isset($options['connection']) ||
! ($options['connection'] instanceof Doctrine_Connection)) {
throw new Doctrine_Cache_Exception('Connection option not set.');
}
if ( ! isset($options['tableName']) ||
! is_string($options['tableName'])) {
throw new Doctrine_Cache_Exception('Table name option not set.');
}
$this->_options = $options;
}
/**
* Get the connection object associated with this cache driver
*
* @return Doctrine_Connection $connection
*/
public function getConnection()
{
return $this->_options['connection'];
}
/**
* Test if a cache is available for the given id and (if yes) return it (false else).
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return string cached datas (or false)
*/
public function fetch($id, $testCacheValidity = true)
{
$sql = 'SELECT data, expire FROM ' . $this->_options['tableName']
. ' WHERE id = ?';
if ($testCacheValidity) {
$sql .= " AND (expire is null OR expire > '" . date('Y-m-d H:i:s') . "')";
}
$result = $this->getConnection()->execute($sql, array($this->_getKey($id)))->fetchAll(Doctrine::FETCH_NUM);
if ( ! isset($result[0])) {
return false;
}
return unserialize($this->_hex2bin($result[0][0]));
}
protected function _hex2bin($hex)
{
if ( ! is_string($hex)) {
return null;
}
$bin = '';
for ($a = 0; $a < strlen($hex); $a += 2) {
$bin .= chr(hexdec($hex{$a} . $hex{($a + 1)}));
}
return $bin;
}
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id)
{
$sql = 'SELECT id, expire FROM ' . $this->_options['tableName']
. ' WHERE id = ?';
$result = $this->getConnection()->fetchOne($sql, array($this->_getKey($id)));
if(isset($result[0] )){
return time();
}
return false;
}
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $id cache id
* @param string $data data to cache
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false)
{
if ($this->contains($id)) {
//record is in database, do update
$sql = 'UPDATE ' . $this->_options['tableName']
. ' SET data = ?, expire=? '
. ' WHERE id = ?';
if ($lifeTime) {
$expire = date('Y-m-d H:i:s',time() + $lifeTime);
} else {
$expire = NULL;
}
$params = array(bin2hex(serialize($data)), $expire, $this->_getKey($id));
} else {
//record is not in database, do insert
$sql = 'INSERT INTO ' . $this->_options['tableName']
. ' (id, data, expire) VALUES (?, ?, ?)';
if ($lifeTime) {
$expire = date('Y-m-d H:i:s', time() + $lifeTime);
} else {
$expire = NULL;
}
$params = array($this->_getKey($id), bin2hex(serialize($data)), $expire);
}
return (bool) $this->getConnection()->exec($sql, $params);
}
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id)
{
$sql = 'DELETE FROM ' . $this->_options['tableName'] . ' WHERE id = ?';
return (bool) $this->getConnection()->exec($sql, array($this->_getKey($id)));
}
/**
* Removes all cache records
*
* $return bool true on success, false on failure
*/
public function deleteAll()
{
$sql = 'DELETE FROM ' . $this->_options['tableName'];
return (bool) $this->getConnection()->exec($sql);
}
/**
* count
* returns the number of cached elements
*
* @return integer
*/
public function count()
{
$sql = 'SELECT COUNT(*) FROM ' . $this->_options['tableName'];
return (int) $this->getConnection()->fetchOne($sql);
}
/**
* Create the cache table
*
* @return void
*/
public function createTable()
{
$name = $this->_options['tableName'];
$fields = array(
'id' => array(
'type' => 'string',
'length' => 255
),
'data' => array(
'type' => 'blob'
),
'expire' => array(
'type' => 'timestamp'
)
);
$options = array(
'primary' => array('id')
);
$this->getConnection()->export->createTable($name, $fields, $options);
}
}

View File

@ -0,0 +1,92 @@
<?php
/*
* $Id: Driver.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Abstract cache driver class
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Cache_Driver implements Doctrine_Cache_Interface
{
/**
* @var array $_options an array of options
*/
protected $_options = array();
/**
* Configure cache driver with an array of options
*
* @param array $_options an array of options
*/
public function __construct($options = array())
{
$this->_options = $options;
}
/**
* Set option name and value
*
* @param mixed $option the option name
* @param mixed $value option value
* @return boolean TRUE on success, FALSE on failure
*/
public function setOption($option, $value)
{
if (isset($this->_options[$option])) {
$this->_options[$option] = $value;
return true;
}
return false;
}
/**
* Get value of option
*
* @param mixed $option the option name
* @return mixed option value
*/
public function getOption($option)
{
if ( ! isset($this->_options[$option])) {
return null;
}
return $this->_options[$option];
}
/**
* Get the hash key passing its suffix
*
* @param string $id The hash key suffix
* @return string Hash key to be used by drivers
*/
protected function _getKey($id)
{
return (isset($this->_options['prefix']) ? $this->_options['prefix'] : '') . $id;
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
* $Id: Exception.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine cache exception class
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Exception extends Doctrine_Exception
{ }

View File

@ -0,0 +1,73 @@
<?php
/*
* $Id: Interface.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine cache driver interface
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
interface Doctrine_Cache_Interface
{
/**
* Test if a cache is available for the given id and (if yes) return it (false else)
*
* Note : return value is always "string" (unserialization is done by the core not by the backend)
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return string cached datas (or false)
*/
public function fetch($id, $testCacheValidity = true);
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id);
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $id cache id
* @param string $data data to cache
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false);
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id);
}

View File

@ -0,0 +1,128 @@
<?php
/*
* $Id: Memcache.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Memcache cache driver
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Memcache extends Doctrine_Cache_Driver
{
/**
* @var Memcache $_memcache memcache object
*/
protected $_memcache = null;
/**
* constructor
*
* @param array $options associative array of cache driver options
*/
public function __construct($options = array())
{
if ( ! extension_loaded('memcache')) {
throw new Doctrine_Cache_Exception('In order to use Memcache driver, the memcache extension must be loaded.');
}
parent::__construct($options);
if (isset($options['servers'])) {
$value= $options['servers'];
if (isset($value['host'])) {
// in this case, $value seems to be a simple associative array (one server only)
$value = array(0 => $value); // let's transform it into a classical array of associative arrays
}
$this->setOption('servers', $value);
}
$this->_memcache = new Memcache;
foreach ($this->_options['servers'] as $server) {
if ( ! array_key_exists('persistent', $server)) {
$server['persistent'] = true;
}
if ( ! array_key_exists('port', $server)) {
$server['port'] = 11211;
}
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent']);
}
}
/**
* Test if a cache is available for the given id and (if yes) return it (false else)
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return mixed The stored variable on success. FALSE on failure.
*/
public function fetch($id, $testCacheValidity = true)
{
return $this->_memcache->get($this->_getKey($id));
}
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id)
{
return (bool) $this->_memcache->get($this->_getKey($id));
}
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $data data to cache
* @param string $id cache id
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false)
{
if ($this->_options['compression']) {
$flag = MEMCACHE_COMPRESSED;
} else {
$flag = 0;
}
$result = $this->_memcache->set($this->_getKey($id), $data, $flag, $lifeTime);
}
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id)
{
return $this->_memcache->delete($this->_getKey($id));
}
}

View File

@ -0,0 +1,99 @@
<?php
/*
* $Id: Xcache.php 2007-11-19 14:47:59Z demongloom $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Xcache cache driver
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: $
* @author Dmitry Bakaleinik (dima@snaiper.net)
*/
class Doctrine_Cache_Xcache extends Doctrine_Cache_Driver
{
/**
* constructor
*
* @param array $options associative array of cache driver options
*/
public function __construct($options = array())
{
if ( ! extension_loaded('xcache') ) {
throw new Doctrine_Cache_Exception('In order to use Xcache driver, the xcache extension must be loaded.');
}
parent::__construct($options);
}
/**
* Test if a cache is available for the given id and (if yes) return it (false else).
*
* @param string $id cache id
* @param boolean $testCacheValidity if set to false, the cache validity won't be tested
* @return string cached datas (or false)
*/
public function fetch($id, $testCacheValidity = true)
{
$key = $this->_getKey($id);
return $this->contains($key) ? xcache_get($key) : false;
}
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id)
{
return xcache_isset($this->_getKey($id));
}
/**
* Save some string datas into a cache record
*
* Note : $data is always saved as a string
*
* @param string $data data to cache
* @param string $id cache id
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false)
{
return xcache_set($this->_getKey($id), $data, $lifeTime);
}
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id)
{
return xcache_unset($this->_getKey($id));
}
}

356
includes/Doctrine/Cli.php Normal file
View File

@ -0,0 +1,356 @@
<?php
/*
* $Id: Cli.php 2761 2007-10-07 23:42:29Z zYne $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Command line interface class
* Interface for easily executing Doctrine_Task classes from a
* command line interface
*
* @package Doctrine
* @subpackage Cli
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class Doctrine_Cli
{
protected $_tasks = array(),
$_taskInstance = null,
$_formatter = null,
$_scriptName = null,
$_message = null,
$_config = array();
/**
* __construct
*
* @param string $config
* @return void
*/
public function __construct($config = array())
{
$this->_config = $config;
$this->_formatter = new Doctrine_Cli_AnsiColorFormatter();
$this->loadTasks();
}
/**
* Notify the formatter of a message
*
* @param string $notification The notification message
* @param string $style Style to format the notification with(INFO, ERROR)
* @return void
*/
public function notify($notification = null, $style = 'HEADER')
{
echo $this->_formatter->format($this->_taskInstance->getTaskName(), 'INFO') . ' - ' . $this->_formatter->format($notification, $style) . "\n";
}
/**
* Notify the formatter of an exception
*
* @param Exception $exception
* @return void
*/
public function notifyException($exception)
{
echo $this->_formatter->format($exception->getMessage(), 'ERROR') . "\n";
}
/**
* Public function to run the loaded task with the passed arguments
*
* @param array $args
* @return void
* @throws new Doctrine_Cli_Exception
*/
public function run($args)
{
try {
$this->_run($args);
} catch (Exception $exception) {
$this->notifyException($exception);
}
}
/**
* Get the name of the task class based on the first argument
* which is always the task name. Do some inflection to determine the class name
*
* @param array $args Array of arguments from the cli
* @return string $taskClass Task class name
*/
protected function _getTaskClassFromArgs($args)
{
$taskName = str_replace('-', '_', $args[1]);
$taskClass = 'Doctrine_Task_' . Doctrine_Inflector::classify($taskName);
return $taskClass;
}
/**
* Run the actual task execution with the passed arguments
*
* @param array $args Array of arguments for this task being executed
* @return void
* @throws Doctrine_Cli_Exception $e
*/
protected function _run($args)
{
$this->_scriptName = $args[0];
$arg1 = isset($args[1]) ? $args[1]:null;
if ( ! $arg1 || $arg1 == 'help') {
echo $this->printTasks(null, $arg1 == 'help' ? true:false);
return;
}
if (isset($args[1]) && isset($args[2]) && $args[2] === 'help') {
echo $this->printTasks($args[1], true);
return;
}
$taskClass = $this->_getTaskClassFromArgs($args);
if ( ! class_exists($taskClass)) {
throw new Doctrine_Cli_Exception('Cli task could not be found: ' . $taskClass);
}
unset($args[0]);
unset($args[1]);
$this->_taskInstance = new $taskClass($this);
$args = $this->prepareArgs($args);
$this->_taskInstance->setArguments($args);
try {
if ($this->_taskInstance->validate()) {
$this->_taskInstance->execute();
} else {
echo $this->_formatter->format('Requires arguments missing!!', 'ERROR') . "\n\n";
echo $this->printTasks($arg1, true);
}
} catch (Exception $e) {
throw new Doctrine_Cli_Exception($e->getMessage());
}
}
/**
* Prepare the raw arguments for execution. Combines with the required and optional argument
* list in order to determine a complete array of arguments for the task
*
* @param array $args Array of raw arguments
* @return array $prepared Array of prepared arguments
*/
protected function prepareArgs($args)
{
$taskInstance = $this->_taskInstance;
$args = array_values($args);
// First lets load populate an array with all the possible arguments. required and optional
$prepared = array();
$requiredArguments = $taskInstance->getRequiredArguments();
foreach ($requiredArguments as $key => $arg) {
$prepared[$arg] = null;
}
$optionalArguments = $taskInstance->getOptionalArguments();
foreach ($optionalArguments as $key => $arg) {
$prepared[$arg] = null;
}
// If we have a config array then lets try and fill some of the arguments with the config values
if (is_array($this->_config) && !empty($this->_config)) {
foreach ($this->_config as $key => $value) {
if (array_key_exists($key, $prepared)) {
$prepared[$key] = $value;
}
}
}
// Now lets fill in the entered arguments to the prepared array
$copy = $args;
foreach ($prepared as $key => $value) {
if ( ! $value && !empty($copy)) {
$prepared[$key] = $copy[0];
unset($copy[0]);
$copy = array_values($copy);
}
}
return $prepared;
}
/**
* Prints an index of all the available tasks in the CLI instance
*
* @return void
*/
public function printTasks($task = null, $full = false)
{
$task = Doctrine_Inflector::classify(str_replace('-', '_', $task));
$tasks = $this->getLoadedTasks();
echo $this->_formatter->format("Doctrine Command Line Interface", 'HEADER') . "\n\n";
foreach ($tasks as $taskName)
{
if ($task != null && strtolower($task) != strtolower($taskName)) {
continue;
}
$className = 'Doctrine_Task_' . $taskName;
$taskInstance = new $className();
$taskInstance->taskName = str_replace('_', '-', Doctrine_Inflector::tableize($taskName));
$syntax = $this->_scriptName . ' ' . $taskInstance->getTaskName();
echo $this->_formatter->format($syntax, 'INFO');
if ($full) {
echo " - " . $taskInstance->getDescription() . "\n";
$args = null;
$requiredArguments = $taskInstance->getRequiredArgumentsDescriptions();
if ( ! empty($requiredArguments)) {
foreach ($requiredArguments as $name => $description) {
$args .= $this->_formatter->format($name, "ERROR");
if (isset($this->_config[$name])) {
$args .= " - " . $this->_formatter->format($this->_config[$name], 'COMMENT');
} else {
$args .= " - " . $description;
}
$args .= "\n";
}
}
$optionalArguments = $taskInstance->getOptionalArgumentsDescriptions();
if ( ! empty($optionalArguments)) {
foreach ($optionalArguments as $name => $description) {
$args .= $name . ' - ' . $description."\n";
}
}
if ($args) {
echo "\n" . $this->_formatter->format('Arguments:', 'HEADER') . "\n" . $args;
}
}
echo "\n";
}
}
/**
* Load tasks from the passed directory. If no directory is given it looks in the default
* Doctrine/Task folder for the core tasks.
*
* @param mixed $directory Can be a string path or array of paths
* @return array $loadedTasks Array of tasks loaded
*/
public function loadTasks($directory = null)
{
if ($directory === null) {
$directory = Doctrine::getPath() . DIRECTORY_SEPARATOR . 'Doctrine' . DIRECTORY_SEPARATOR . 'Task';
}
$parent = new ReflectionClass('Doctrine_Task');
$tasks = array();
if (is_dir($directory)) {
foreach ((array) $directory as $dir) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($it as $file) {
$e = explode('.', $file->getFileName());
if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) {
$className = 'Doctrine_Task_' . $e[0];
if ( ! class_exists($className)) {
require_once($file->getPathName());
$class = new ReflectionClass($className);
if ($class->isSubClassOf($parent)) {
$tasks[$e[0]] = $e[0];
}
}
}
}
}
}
$classes = get_declared_classes();
foreach ($classes as $className) {
$class = new Reflectionclass($className);
if ($class->isSubClassOf($parent)) {
$task = str_replace('Doctrine_Task_', '', $className);
$tasks[$task] = $task;
}
}
$this->_tasks = array_merge($this->_tasks, $tasks);
return $this->_tasks;
}
/**
* Get array of all the Doctrine_Task child classes that are loaded
*
* @return array $tasks
*/
public function getLoadedTasks()
{
$parent = new ReflectionClass('Doctrine_Task');
$classes = get_declared_classes();
$tasks = array();
foreach ($classes as $className) {
$class = new ReflectionClass($className);
if ($class->isSubClassOf($parent)) {
$task = str_replace('Doctrine_Task_', '', $className);
$tasks[$task] = $task;
}
}
return array_merge($this->_tasks, $tasks);
}
}

View File

@ -0,0 +1,160 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* $Id: AnsiColorFormatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_AnsiColorFormatter provides methods to colorize text to be displayed on a console.
* This class was taken from the symfony-project source
*
* @package Doctrine
* @subpackage Cli
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 4252 $
*/
class Doctrine_Cli_AnsiColorFormatter extends Doctrine_Cli_Formatter
{
protected
$_styles = array(
'HEADER' => array('fg' => 'black', 'bold' => true),
'ERROR' => array('bg' => 'red', 'fg' => 'white', 'bold' => true),
'INFO' => array('fg' => 'green', 'bold' => true),
'COMMENT' => array('fg' => 'yellow'),
),
$_options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8),
$_foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37),
$_background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
/**
* Sets a new style.
*
* @param string The style name
* @param array An array of options
*/
public function setStyle($name, $options = array())
{
$this->_styles[$name] = $options;
}
/**
* Formats a text according to the given style or parameters.
*
* @param string The test to style
* @param mixed An array of options or a style name
*
* @return string The styled text
*/
public function format($text = '', $parameters = array(), $stream = STDOUT)
{
if ( ! $this->supportsColors($stream)) {
return $text;
}
if ( ! is_array($parameters) && 'NONE' == $parameters) {
return $text;
}
if ( ! is_array($parameters) && isset($this->_styles[$parameters])) {
$parameters = $this->_styles[$parameters];
}
$codes = array();
if (isset($parameters['fg'])) {
$codes[] = $this->_foreground[$parameters['fg']];
}
if (isset($parameters['bg'])) {
$codes[] = $this->_background[$parameters['bg']];
}
foreach ($this->_options as $option => $value) {
if (isset($parameters[$option]) && $parameters[$option]) {
$codes[] = $value;
}
}
return "\033[".implode(';', $codes).'m'.$text."\033[0m";
}
/**
* Formats a message within a section.
*
* @param string The section name
* @param string The text message
* @param integer The maximum size allowed for a line (65 by default)
*/
public function formatSection($section, $text, $size = null)
{
$width = 9 + strlen($this->format('', 'INFO'));
return sprintf(">> %-${width}s %s", $this->format($section, 'INFO'), $this->excerpt($text, $size));
}
/**
* Truncates a line.
*
* @param string The text
* @param integer The maximum size of the returned string (65 by default)
*
* @return string The truncated string
*/
public function excerpt($text, $size = null)
{
if ( ! $size) {
$size = $this->size;
}
if (strlen($text) < $size) {
return $text;
}
$subsize = floor(($size - 3) / 2);
return substr($text, 0, $subsize) . $this->format('...', 'INFO').substr($text, -$subsize);
}
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - windows
* - non tty consoles
*
* @param mixed A stream
*
* @return Boolean true if the stream supports colorization, false otherwise
*/
public function supportsColors($stream)
{
return DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty($stream);
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
* $Id: Exception.php 2761 2007-10-07 23:42:29Z zYne $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Cli exception class
*
* @package Doctrine
* @subpackage Cli
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class Doctrine_Cli_Exception extends Doctrine_Exception
{ }

View File

@ -0,0 +1,116 @@
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* $Id: Formatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Cli_Formatter provides methods to format text to be displayed on a console.
* This class was taken from the symfony-project source
*
* @package Doctrine
* @subpackage Cli
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 2761 $
*/
class Doctrine_Cli_Formatter
{
protected $_size = 65;
/**
* __construct
*
* @param string $maxLineSize
* @return void
*/
function __construct($maxLineSize = 65)
{
$this->_size = $maxLineSize;
}
/**
* Formats a text according to the given parameters.
*
* @param string The test to style
* @param mixed An array of parameters
* @param stream A stream (default to STDOUT)
*
* @return string The formatted text
*/
public function format($text = '', $parameters = array(), $stream = STDOUT)
{
return $text;
}
/**
* Formats a message within a section.
*
* @param string The section name
* @param string The text message
* @param integer The maximum size allowed for a line (65 by default)
*/
public function formatSection($section, $text, $size = null)
{
return sprintf(">> %-$9s %s", $section, $this->excerpt($text, $size));
}
/**
* Truncates a line.
*
* @param string The text
* @param integer The maximum size of the returned string (65 by default)
*
* @return string The truncated string
*/
public function excerpt($text, $size = null)
{
if ( ! $size) {
$size = $this->_size;
}
if (strlen($text) < $size) {
return $text;
}
$subsize = floor(($size - 3) / 2);
return substr($text, 0, $subsize).'...'.substr($text, -$subsize);
}
/**
* Sets the maximum line size.
*
* @param integer The maximum line size for a message
*/
public function setMaxLineSize($size)
{
$this->_size = $size;
}
}

View File

@ -0,0 +1,950 @@
<?php
/*
* $Id: Collection.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Collection
* Collection of Doctrine_Record objects.
*
* @package Doctrine
* @subpackage Collection
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection extends Doctrine_Access implements Countable, IteratorAggregate, Serializable
{
/**
* @var array $data an array containing the records of this collection
*/
protected $data = array();
/**
* @var Doctrine_Table $table each collection has only records of specified table
*/
protected $_table;
/**
* @var array $_snapshot a snapshot of the fetched data
*/
protected $_snapshot = array();
/**
* @var Doctrine_Record $reference collection can belong to a record
*/
protected $reference;
/**
* @var string $referenceField the reference field of the collection
*/
protected $referenceField;
/**
* @var Doctrine_Relation the record this collection is related to, if any
*/
protected $relation;
/**
* @var string $keyColumn the name of the column that is used for collection key mapping
*/
protected $keyColumn;
/**
* @var Doctrine_Null $null used for extremely fast null value testing
*/
protected static $null;
/**
* constructor
*
* @param Doctrine_Table|string $table
*/
public function __construct($table, $keyColumn = null)
{
if ( ! ($table instanceof Doctrine_Table)) {
$table = Doctrine::getTable($table);
}
$this->_table = $table;
if ($keyColumn === null) {
$keyColumn = $table->getBoundQueryPart('indexBy');
}
if ($keyColumn === null) {
$keyColumn = $table->getAttribute(Doctrine::ATTR_COLL_KEY);
}
if ($keyColumn !== null) {
$this->keyColumn = $keyColumn;
}
}
/**
* Initializes the null object for this collection
*
* @return void
*/
public static function initNullObject(Doctrine_Null $null)
{
self::$null = $null;
}
/**
* Get the table this collection belongs to
*
* @return Doctrine_Table
*/
public function getTable()
{
return $this->_table;
}
/**
* Set the data for the Doctrin_Collection instance
*
* @param array $data
* @return Doctrine_Collection
*/
public function setData(array $data)
{
$this->data = $data;
}
/**
* This method is automatically called when this Doctrine_Collection is serialized
*
* @return array
*/
public function serialize()
{
$vars = get_object_vars($this);
unset($vars['reference']);
unset($vars['reference_field']);
unset($vars['relation']);
unset($vars['expandable']);
unset($vars['expanded']);
unset($vars['generator']);
$vars['_table'] = $vars['_table']->getComponentName();
return serialize($vars);
}
/**
* This method is automatically called everytime a Doctrine_Collection object is unserialized
*
* @return void
*/
public function unserialize($serialized)
{
$manager = Doctrine_Manager::getInstance();
$connection = $manager->getCurrentConnection();
$array = unserialize($serialized);
foreach ($array as $name => $values) {
$this->$name = $values;
}
$this->_table = $connection->getTable($this->_table);
$keyColumn = isset($array['keyColumn']) ? $array['keyColumn'] : null;
if ($keyColumn === null) {
$keyColumn = $this->_table->getBoundQueryPart('indexBy');
}
if ($keyColumn !== null) {
$this->keyColumn = $keyColumn;
}
}
/**
* Sets the key column for this collection
*
* @param string $column
* @return Doctrine_Collection $this
*/
public function setKeyColumn($column)
{
$this->keyColumn = $column;
return $this;
}
/**
* Get the name of the key column
*
* @return string
*/
public function getKeyColumn()
{
return $this->keyColumn;
}
/**
* Get all the records as an array
*
* @return array
*/
public function getData()
{
return $this->data;
}
/**
* Get the first record in the collection
*
* @return Doctrine_Record
*/
public function getFirst()
{
return reset($this->data);
}
/**
* Get the last record in the collection
*
* @return Doctrine_Record
*/
public function getLast()
{
return end($this->data);
}
/**
* Get the last record in the collection
*
* @return Doctrine_Record
*/
public function end()
{
return end($this->data);
}
/**
* Get the current key
*
* @return Doctrine_Record
*/
public function key()
{
return key($this->data);
}
/**
* Sets a reference pointer
*
* @return void
*/
public function setReference(Doctrine_Record $record, Doctrine_Relation $relation)
{
$this->reference = $record;
$this->relation = $relation;
if ($relation instanceof Doctrine_Relation_ForeignKey ||
$relation instanceof Doctrine_Relation_LocalKey) {
$this->referenceField = $relation->getForeignFieldName();
$value = $record->get($relation->getLocalFieldName());
foreach ($this->data as $record) {
if ($value !== null) {
$record->set($this->referenceField, $value, false);
} else {
$record->set($this->referenceField, $this->reference, false);
}
}
} elseif ($relation instanceof Doctrine_Relation_Association) {
}
}
/**
* Get reference to Doctrine_Record instance
*
* @return Doctrine_Record $reference
*/
public function getReference()
{
return $this->reference;
}
/**
* Removes a specified collection element
*
* @param mixed $key
* @return boolean
*/
public function remove($key)
{
$removed = $this->data[$key];
unset($this->data[$key]);
return $removed;
}
/**
* Whether or not this collection contains a specified element
*
* @param mixed $key the key of the element
* @return boolean
*/
public function contains($key)
{
return isset($this->data[$key]);
}
/**
* Search a Doctrine_Record instance
*
* @param string $Doctrine_Record
* @return void
*/
public function search(Doctrine_Record $record)
{
return array_search($record, $this->data, true);
}
/**
* Gets a record for given key
*
* There are two special cases:
*
* 1. if null is given as a key a new record is created and attached
* at the end of the collection
*
* 2. if given key does not exist, then a new record is create and attached
* to the given key
*
* Collection also maps referential information to newly created records
*
* @param mixed $key the key of the element
* @return Doctrine_Record return a specified record
*/
public function get($key)
{
if ( ! isset($this->data[$key])) {
$record = $this->_table->create();
if (isset($this->referenceField)) {
$value = $this->reference->get($this->relation->getLocalFieldName());
if ($value !== null) {
$record->set($this->referenceField, $value, false);
} else {
$record->set($this->referenceField, $this->reference, false);
}
}
if ($key === null) {
$this->data[] = $record;
} else {
$this->data[$key] = $record;
}
if (isset($this->keyColumn)) {
$record->set($this->keyColumn, $key);
}
return $record;
}
return $this->data[$key];
}
/**
* Get array of primary keys for all the records in the collection
*
* @return array an array containing all primary keys
*/
public function getPrimaryKeys()
{
$list = array();
$name = $this->_table->getIdentifier();
foreach ($this->data as $record) {
if (is_array($record) && isset($record[$name])) {
$list[] = $record[$name];
} else {
$list[] = $record->getIncremented();
}
}
return $list;
}
/**
* Get all keys of the data in the collection
*
* @return array
*/
public function getKeys()
{
return array_keys($this->data);
}
/**
* Gets the number of records in this collection
* This class implements interface countable
*
* @return integer
*/
public function count()
{
return count($this->data);
}
/**
* Set a Doctrine_Record instance to the collection
*
* @param integer $key
* @param Doctrine_Record $record
* @return void
*/
public function set($key, $record)
{
if (isset($this->referenceField)) {
$record->set($this->referenceField, $this->reference, false);
}
$this->data[$key] = $record;
}
/**
* Adds a record to collection
*
* @param Doctrine_Record $record record to be added
* @param string $key optional key for the record
* @return boolean
*/
public function add($record, $key = null)
{
if (isset($this->referenceField)) {
$value = $this->reference->get($this->relation->getLocalFieldName());
if ($value !== null) {
$record->set($this->referenceField, $value, false);
} else {
$record->set($this->referenceField, $this->reference, false);
}
$relations = $this->relation['table']->getRelations();
foreach ($relations as $relation) {
if ($this->relation['class'] == $relation['localTable']->getOption('name') && $relation->getLocal() == $this->relation->getForeignFieldName()) {
$record->$relation['alias'] = $this->reference;
break;
}
}
}
/**
* for some weird reason in_array cannot be used here (php bug ?)
*
* if used it results in fatal error : [ nesting level too deep ]
*/
foreach ($this->data as $val) {
if ($val === $record) {
return false;
}
}
if (isset($key)) {
if (isset($this->data[$key])) {
return false;
}
$this->data[$key] = $record;
return true;
}
if (isset($this->keyColumn)) {
$value = $record->get($this->keyColumn);
if ($value === null) {
throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '".$this->keyColumn."' was null.");
}
$this->data[$value] = $record;
} else {
$this->data[] = $record;
}
return true;
}
/**
* Merges collection into $this and returns merged collection
*
* @param Doctrine_Collection $coll
* @return Doctrine_Collection
*/
public function merge(Doctrine_Collection $coll)
{
$localBase = $this->getTable()->getComponentName();
$otherBase = $coll->getTable()->getComponentName();
if ($otherBase != $localBase && !is_subclass_of($otherBase, $localBase) ) {
throw new Doctrine_Collection_Exception("Can't merge collections with incompatible record types");
}
foreach ($coll->getData() as $record) {
$this->add($record);
}
return $this;
}
/**
* Load all relationships or the named relationship passed
*
* @param mixed $name
* @return boolean
*/
public function loadRelated($name = null)
{
$list = array();
$query = new Doctrine_Query($this->_table->getConnection());
if ( ! isset($name)) {
foreach ($this->data as $record) {
$value = $record->getIncremented();
if ($value !== null) {
$list[] = $value;
}
}
$query->from($this->_table->getComponentName());
$query->where($this->_table->getComponentName() . '.id IN (' . substr(str_repeat("?, ", count($list)),0,-2) . ')');
return $query;
}
$rel = $this->_table->getRelation($name);
if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
foreach ($this->data as $record) {
$list[] = $record[$rel->getLocal()];
}
} else {
foreach ($this->data as $record) {
$value = $record->getIncremented();
if ($value !== null) {
$list[] = $value;
}
}
}
$dql = $rel->getRelationDql(count($list), 'collection');
$coll = $query->query($dql, $list);
$this->populateRelated($name, $coll);
}
/**
* Populate the relationship $name for all records in the passed collection
*
* @param string $name
* @param Doctrine_Collection $coll
* @return void
*/
public function populateRelated($name, Doctrine_Collection $coll)
{
$rel = $this->_table->getRelation($name);
$table = $rel->getTable();
$foreign = $rel->getForeign();
$local = $rel->getLocal();
if ($rel instanceof Doctrine_Relation_LocalKey) {
foreach ($this->data as $key => $record) {
foreach ($coll as $k => $related) {
if ($related[$foreign] == $record[$local]) {
$this->data[$key]->setRelated($name, $related);
}
}
}
} elseif ($rel instanceof Doctrine_Relation_ForeignKey) {
foreach ($this->data as $key => $record) {
if ( ! $record->exists()) {
continue;
}
$sub = new Doctrine_Collection($table);
foreach ($coll as $k => $related) {
if ($related[$foreign] == $record[$local]) {
$sub->add($related);
$coll->remove($k);
}
}
$this->data[$key]->setRelated($name, $sub);
}
} elseif ($rel instanceof Doctrine_Relation_Association) {
$identifier = $this->_table->getIdentifier();
$asf = $rel->getAssociationFactory();
$name = $table->getComponentName();
foreach ($this->data as $key => $record) {
if ( ! $record->exists()) {
continue;
}
$sub = new Doctrine_Collection($table);
foreach ($coll as $k => $related) {
if ($related->get($local) == $record[$identifier]) {
$sub->add($related->get($name));
}
}
$this->data[$key]->setRelated($name, $sub);
}
}
}
/**
* Get normal iterator - an iterator that will not expand this collection
*
* @return Doctrine_Iterator_Normal $iterator
*/
public function getNormalIterator()
{
return new Doctrine_Collection_Iterator_Normal($this);
}
/**
* Takes a snapshot from this collection
*
* snapshots are used for diff processing, for example
* when a fetched collection has three elements, then two of those
* are being removed the diff would contain one element
*
* Doctrine_Collection::save() attaches the diff with the help of last
* snapshot.
*
* @return Doctrine_Collection
*/
public function takeSnapshot()
{
$this->_snapshot = $this->data;
return $this;
}
/**
* Gets the data of the last snapshot
*
* @return array returns the data in last snapshot
*/
public function getSnapshot()
{
return $this->_snapshot;
}
/**
* Processes the difference of the last snapshot and the current data
*
* an example:
* Snapshot with the objects 1, 2 and 4
* Current data with objects 2, 3 and 5
*
* The process would remove object 4
*
* @return Doctrine_Collection
*/
public function processDiff()
{
foreach (array_udiff($this->_snapshot, $this->data, array($this, "compareRecords")) as $record) {
$record->delete();
}
return $this;
}
/**
* Mimics the result of a $query->execute(array(), Doctrine::HYDRATE_ARRAY);
*
* @param boolean $deep
*/
public function toArray($deep = false, $prefixKey = false)
{
$data = array();
foreach ($this as $key => $record) {
$key = $prefixKey ? get_class($record) . '_' .$key:$key;
$data[$key] = $record->toArray($deep, $prefixKey);
}
return $data;
}
/**
* Build an array made up of the values from the 2 specified columns
*
* @param string $key
* @param string $value
* @return array $result
*/
public function toKeyValueArray($key, $value)
{
$result = array();
foreach ($this as $record) {
$result[$record->$key] = $record->$value;
}
return $result;
}
/**
* Populate a Doctrine_Collection from an array of data
*
* @param string $array
* @return void
*/
public function fromArray($array, $deep = true)
{
$data = array();
foreach ($array as $rowKey => $row) {
$this[$rowKey]->fromArray($row, $deep);
}
}
/**
* synchronizes a Doctrine_Collection with data from an array
*
* it expects an array representation of a Doctrine_Collection similar to the return
* value of the toArray() method. It will create Dectrine_Records that don't exist
* on the collection, update the ones that do and remove the ones missing in the $array
*
* @param array $array representation of a Doctrine_Collection
*/
public function synchronizeWithArray(array $array)
{
foreach ($this as $key => $record) {
if (isset($array[$key])) {
$record->synchronizeWithArray($array[$key]);
unset($array[$key]);
} else {
// remove records that don't exist in the array
$this->remove($key);
}
}
// create new records for each new row in the array
foreach ($array as $rowKey => $row) {
$this[$rowKey]->fromArray($row);
}
}
public function synchronizeFromArray(array $array)
{
return $this->synchronizeWithArray($array);
}
/**
* Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $deep
* @return void
*/
public function exportTo($type, $deep = false)
{
if ($type == 'array') {
return $this->toArray($deep);
} else {
return Doctrine_Parser::dump($this->toArray($deep, true), $type);
}
}
/**
* Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $data
* @return void
*/
public function importFrom($type, $data)
{
if ($type == 'array') {
return $this->fromArray($data);
} else {
return $this->fromArray(Doctrine_Parser::load($data, $type));
}
}
/**
* Perform a delete diff between the last snapshot and the current data
*
* @return array $diff
*/
public function getDeleteDiff()
{
return array_udiff($this->_snapshot, $this->data, array($this, 'compareRecords'));
}
/**
* Perform a insert diff between the last snapshot and the current data
*
* @return array $diff
*/
public function getInsertDiff()
{
return array_udiff($this->data, $this->_snapshot, array($this, "compareRecords"));
}
/**
* Compares two records. To be used on _snapshot diffs using array_udiff
*
* @param Doctrine_Record $a
* @param Doctrine_Record $b
* @return integer
*/
protected function compareRecords($a, $b)
{
if ($a->getOid() == $b->getOid()) {
return 0;
}
return ($a->getOid() > $b->getOid()) ? 1 : -1;
}
/**
* Saves all records of this collection and processes the
* difference of the last snapshot and the current data
*
* @param Doctrine_Connection $conn optional connection parameter
* @return Doctrine_Collection
*/
public function save(Doctrine_Connection $conn = null, $processDiff = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
}
try {
$conn->beginInternalTransaction();
$conn->transaction->addCollection($this);
if ($processDiff) {
$this->processDiff();
}
foreach ($this->getData() as $key => $record) {
$record->save($conn);
}
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw $e;
}
return $this;
}
/**
* Deletes all records from this collection
*
* @return Doctrine_Collection
*/
public function delete(Doctrine_Connection $conn = null, $clearColl = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
}
try {
$conn->beginInternalTransaction();
$conn->transaction->addCollection($this);
foreach ($this as $key => $record) {
$record->delete($conn);
}
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw $e;
}
if ($clearColl) {
$this->clear();
}
return $this;
}
/**
* Clears the collection.
*
* @return void
*/
public function clear()
{
$this->data = array();
}
/**
* Frees the resources used by the collection.
* WARNING: After invoking free() the collection is no longer considered to
* be in a useable state. Subsequent usage may result in unexpected behavior.
*
* @return void
*/
public function free($deep = false)
{
foreach ($this->getData() as $key => $record) {
if ( ! ($record instanceof Doctrine_Null)) {
$record->free($deep);
}
}
$this->data = array();
if ($this->reference) {
$this->reference->free($deep);
$this->reference = null;
}
}
/**
* Get collection data iterator
*
* @return Iterator
*/
public function getIterator()
{
$data = $this->data;
return new ArrayIterator($data);
}
/**
* Returns a string representation of this object
*
* @return string $string
*/
public function __toString()
{
return Doctrine_Lib::getCollectionAsString($this);
}
/**
* Returns the relation object
*
* @return Doctrine_Relation
*/
public function getRelation()
{
return $this->relation;
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
* $Id: Exception.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Collection exception class
*
* @package Doctrine
* @subpackage Collection
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Exception extends Doctrine_Exception
{ }

View File

@ -0,0 +1,119 @@
<?php
/*
* $Id: Iterator.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Collection_Iterator
* iterates through Doctrine_Collection
*
* @package Doctrine
* @subpackage Collection
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Collection_Iterator implements Iterator
{
/**
* @var Doctrine_Collection $collection
*/
protected $collection;
/**
* @var array $keys
*/
protected $keys;
/**
* @var mixed $key
*/
protected $key;
/**
* @var integer $index
*/
protected $index;
/**
* @var integer $count
*/
protected $count;
/**
* constructor
* @var Doctrine_Collection $collection
*/
public function __construct($collection)
{
$this->collection = $collection;
$this->keys = $this->collection->getKeys();
$this->count = $this->collection->count();
}
/**
* rewinds the iterator
*
* @return void
*/
public function rewind()
{
$this->index = 0;
$i = $this->index;
if (isset($this->keys[$i])) {
$this->key = $this->keys[$i];
}
}
/**
* returns the current key
*
* @return integer
*/
public function key()
{
return $this->key;
}
/**
* returns the current record
*
* @return Doctrine_Record
*/
public function current()
{
return $this->collection->get($this->key);
}
/**
* advances the internal pointer
*
* @return void
*/
public function next()
{
$this->index++;
$i = $this->index;
if (isset($this->keys[$i])) {
$this->key = $this->keys[$i];
}
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
* $Id: Expandable.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Expandable collection iterator class
*
* @package Doctrine
* @subpackage Collection
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator
{
public function valid()
{
if ($this->index < $this->count) {
return true;
} elseif ($this->index == $this->count) {
$coll = $this->collection->expand($this->index);
if ($coll instanceof Doctrine_Collection) {
$count = count($coll);
if ($count > 0) {
$this->keys = array_merge($this->keys, $coll->getKeys());
$this->count += $count;
return true;
}
}
return false;
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/*
* $Id: Normal.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Collection_Iterator_Normal
*
* @package Doctrine
* @subpackage Collection
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator
{
/**
* @return boolean whether or not the iteration will continue
*/
public function valid()
{
return ($this->index < $this->count);
}
}

Some files were not shown because too many files have changed in this diff Show More