Injection database
This commit is contained in:
parent
6852da1c60
commit
ad1b8c0407
@ -1,7 +1,6 @@
|
||||
<?
|
||||
|
||||
class MOrias {
|
||||
|
||||
<?php
|
||||
class MOrias
|
||||
{
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
@ -15,15 +14,22 @@ class MOrias {
|
||||
public $annee=0;
|
||||
public $erreur='';
|
||||
|
||||
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
|
||||
$this->accesDist=$accesDist;
|
||||
$this->iDb=new WDb('sdv1');
|
||||
function __construct($accesDist = true, $db = null)
|
||||
{
|
||||
$this->accesDist = $accesDist;
|
||||
|
||||
if ( $db === null ) {
|
||||
$this->iDb = new WDB();
|
||||
} else {
|
||||
$this->iDb = $db;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaxOrias($annee=0) {
|
||||
public function getMaxOrias($annee=0)
|
||||
{
|
||||
if ($annee*1>0 && $annee*1<100) {
|
||||
$this->annee='20'.$annee;
|
||||
$annee++;
|
||||
$annee++;
|
||||
$strWhere="(numOrias/1000000)<=$annee";
|
||||
} elseif ($annee*1>1900 && $annee*1<9999) {
|
||||
$this->annee=$annee;
|
||||
@ -34,12 +40,13 @@ class MOrias {
|
||||
$this->annee=date('Y')*1;
|
||||
}
|
||||
|
||||
$ret=$this->iDb->select('orias','MAX(numOrias) AS numOrias', $strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','MAX(numOrias) AS numOrias', $strWhere, false, MYSQL_ASSOC);
|
||||
//die($strWhere);
|
||||
return sprintf('%08d',$ret[0]['numOrias']);
|
||||
}
|
||||
|
||||
public function getInfosOrias($siren, $numOrias=0) {
|
||||
public function getInfosOrias($siren, $numOrias=0)
|
||||
{
|
||||
//die('numOrias 1:"'.$numOrias.'"');
|
||||
if ($siren*1>1000)
|
||||
$strWhere="siren=$siren";
|
||||
@ -55,11 +62,11 @@ class MOrias {
|
||||
echo "==== SELECT siren, id, nom, cp, ville, adresse, numOrias FROM orias WHERE $strWhere;".EOL;
|
||||
echo "=================================================================================================".EOL;
|
||||
*/
|
||||
$ret=$this->iDb->select('orias','siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue', $strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue', $strWhere, false, MYSQL_ASSOC);
|
||||
if (!$this->force && count($ret)>0) {
|
||||
$this->enCache=true;
|
||||
$tabRet=$ret[0];//array();
|
||||
$ret=$this->iDb->select('orias','categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',$strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',$strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp)
|
||||
$tabRet['categories'][]=$tabTmp;
|
||||
//die('numOrias 3:"'.$numOrias.'"');
|
||||
@ -90,7 +97,7 @@ class MOrias {
|
||||
'menu%3AiasSearchForm%3AiasSearch'=>'menu%3AiasSearchForm%3AiasSearch',
|
||||
);
|
||||
} else {
|
||||
// Recherche avec Siren
|
||||
// Recherche avec Siren
|
||||
$url='http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
$post=array('j_id_id45'=>'j_id_id45',
|
||||
'j_id_id45%3Aj_id_id52'=>'',
|
||||
@ -101,7 +108,7 @@ class MOrias {
|
||||
'j_id_id45%3Aj_id_id175'=>'',
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'j_id_id45%3Aj_id_id203'=>'j_id_id45%3Aj_id_id203');
|
||||
$this->referer='http://www.orias.fr/orias/public/list.html';
|
||||
$this->referer='http://www.orias.fr/orias/public/list.html';
|
||||
}
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 15);
|
||||
@ -116,7 +123,7 @@ class MOrias {
|
||||
$this->erreur='Numéro Orias inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($numOrias<$this->getMaxOrias())
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -126,7 +133,7 @@ class MOrias {
|
||||
$this->referer=$url;
|
||||
$this->body=$page['body'];
|
||||
echo "Recherche par Orias : url=$url".EOL;
|
||||
die(print_r($page));
|
||||
die(print_r($page));
|
||||
} /* else { */
|
||||
|
||||
// Liste contenant l'entreprise
|
||||
@ -187,7 +194,7 @@ class MOrias {
|
||||
if (count($tabTmp)==1) {
|
||||
$tabInsert=array_merge($tabRet, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
$tabRet['categories']=array();
|
||||
continue;
|
||||
@ -235,7 +242,7 @@ class MOrias {
|
||||
$tabCat['rcsCode']=trim(strtr(strip_tags($matches[2]), array(' '=>'',' '=>'',chr(160)=>'',"\r"=>'',"\n"=>'')));
|
||||
$tabCat['rcsSiren']=trim($matches[3]);
|
||||
if ($siren==0) $tabRet['siren']=$tabCat['rcsSiren'];
|
||||
}
|
||||
}
|
||||
/*<td align="right">Contact</td>
|
||||
<td></td>
|
||||
<td><strong> François Meunier
|
||||
@ -272,10 +279,10 @@ class MOrias {
|
||||
unset($tabInsert['categories']);
|
||||
$tabInsert=array_merge($tabInsert, $tabCat, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
//echo $tmpCat[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user