IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Parse error : erreur de syntaxe, 'else' inattendu (T_ELSE)


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    débutant
    Inscrit en
    Septembre 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : débutant

    Informations forums :
    Inscription : Septembre 2022
    Messages : 4
    Par défaut Parse error : erreur de syntaxe, 'else' inattendu (T_ELSE)
    Bonjour j'obtient une erreur à la ligne 366
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    <?php
     
    // PHP7 READY
    /******************************************************************************
     * ZADS GATEWAY FOR UBIFLOW AUTO
     * 
     * Note :  need bootstrap0.php
     *
     * @category   CorePackage
     * @package    ZADS
     * @author     romuald boiteux <serviceclient@jetrouvetous.fr>
     * @copyright  2022 
     * @version    0
     ******************************************************************************/
     
    define('DB_MODE', 'pdo'); // both =  create two db accesses (one with old mode and one with new mode)
    require_once("bootstrap0_with_functions.php");
    include_once('inc/API_client_lib.php');
     
    ///////////////////////////////////
    //Importing xml ads ubiflow
    //////////////////////////////////
    function insert_ubiflow_auto($url)
    {
    	global $dbb;
     
    	$str = '';
    	$id_ad = '';
     
    	$context  = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
    	$xml = file_get_contents($url, false, $context);			
        $xml = simplexml_load_string($xml);
     
    	foreach($xml->coordonnees->nom as $name => $value)
    	{
    		$nom_entr = $value;
    	}	
     
    	foreach($xml->coordonnees->siret as $name => $value)
    	{
    		$num_entr = $value;
    	}
     
    	foreach($xml->coordonnees->logo as $name => $value)
    	{
    		$logo_entr = $value;
    	}
     
    	$array_data = array('reference', 'titre', 'texte','contact_a_afficher', 'email_a_afficher', 'telephone_a_afficher');
    	$array_data1 = array('code_postal', 'ville', 'departement');
     
    	$count = 0;
     
    	foreach($xml->annonce as $row)	
    	{
     
    		$i = 0;
     
    			foreach($array_data as $key)
    			{
    				$error = (!isset($row->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
     
    			foreach($array_data1 as $key)
    			{
    				$error = (!isset($row->bien->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
     
    			$departement = ($row->bien->departement);	
                $location_auto = getRegionByCp($departement);
     
    			$reg = $location_auto['region'];
    			$county = $location_auto['dept'];
     
    		   if(empty($row->prestation->prix)){
                  $prix = (float) $row->prestation->loyer;
    		    }else{ 
    		      $prix = (float) $row->prestation->prix; 
    		   }	   
    		//Inserting annonce
     
    			if($error == 0) 
    			{
    				$name_reg = $reg;
    				$name_dept = $county;
    				//$id_cat =  $cat_type;
    				$email = htmlspecialchars($row->email_a_afficher);
    				$ref = htmlspecialchars($row->reference);
    				$postcode = htmlspecialchars($row->bien->code_postal);
    				$city = htmlspecialchars($row->bien->ville);
    				$pays = htmlspecialchars($row->bien->pays);
    				$status = 40;
    				$comp_name = htmlspecialchars($nom_entr);
    				$comp_num = htmlspecialchars($num_entr);
    				$lat = htmlspecialchars($row->bien->latitude);
    				$lng = htmlspecialchars($row->bien->longitude);
    				$type = 'pro';
    				$name = htmlspecialchars($row->contact_a_afficher);
    				$phone = htmlspecialchars($row->telephone_a_afficher);
    				$title = htmlspecialchars($row->titre);
    				$text = htmlspecialchars($row->texte);
    				$price = htmlspecialchars($prix);
    				$logo = htmlspecialchars($logo_entr);
    				$stamp= date( 'Y-m-d H:i:s', time());
    				$phone_hidden = htmlspecialchars($row->phone_hidden);
    				//$id_ad = $row->attributes()->{'id'};
     
    				$cat_type = htmlspecialchars($row->prestation->type);
     
    				$bien_m ='';
     
    				if (!empty($cat_type)) {
    					switch ($cat_type) {
    							case "V":
    								$cat_typ = "vehicule";
    								$id_cat = 21;
    								$millesime = ($row->bien->millesime);
    							    if (!empty($millesime)){
                                        if ($millesime > 1970 ){									
    									   $type_de_vente = implode('=',array(29 , "NEUF"));
    									}else{
    									   $type_de_vente = implode('=',array(29 , "ANCIEN"));
    									}	
    								}else{ 
    									$type_de_vente = '';
    								}
    								break;
     
    						}
    				}
     
     
    				$type_bien ='';
    				$typ_bien = ($row->bien->libelle_type);
    				if (!empty($typ_bien)) {
    					switch ($typ_bien) {
    							case "4X4": 
    								$type_bien = implode('=',array(50 , "4X4"));
    								break;
                                case "Berline":
    								$type_bien = implode('=',array(50 , "Berline"));
    							     break;
    							case "Break":
    								$type_bien = implode('=',array(50 , "Break"));
    								break;
                                case "Cabriolet":
    								$type_bien = implode('=',array(50 , "Cabriolet"));
    							     break;
    							case "Coupé Sport":
    								$type_bien = implode('=',array(50 , "Coupé Sport"));
    								break;
                                case "Citadine":
    								 $type_bien = implode('=',array(50 , "Citadine"));
    							     break;
    							case "Monospace":
    								 $type_bien = implode('=',array(50 , "Monospace"));
    							     break;
    							case "Pick-up":
    								 $type_bien = implode('=',array(50 , "Pick-up"));
    							     break;
    							case "Luxe":
    								 $type_bien = implode('=',array(50 , "Luxe"));
    							     break;
    							case "Sans permis":
    								 $type_bien = implode('=',array(50 , "Sans permis"));
    							     break;
    							case "Voiture de société, commerciale":
    								 $type_bien = implode('=',array(50 , "Voiture de société, commerciale"));
    							     break;
    							case "Voiture sans permis":
    								 $type_bien = implode('=',array(50 , "Voiture sans permis"));
    							     break;
    							case "Accessoires et pièces":
    								 $type_bien = implode('=',array(50 , "Accessoires et pièces"));
    							     break;
    							case "Autre":
    								 $type_bien = implode('=',array(50 , "Autre"));
    							     break;
     
    						   default:
    								$type_bien = implode('=',array(50 , $typ_bien));
    								break;
     
    								case "F":
    								$cat_typ = "MOTO";
    								$id_cat = 22;
    								break;
     
    						}
    				}		
     
              $carrosserie ='';
              $marque ='';
              $millesime ='';
              $kilometrage =''; 
              $energie ='';
              $couleur ='';
              $boite_de_vitesse ='';
              $puissance_fiscale ='';
    		  $nb_places ='';
              $mise_en_circulation ='';
    		  $date_disponibilite_vehicule ='';
    		  $modele ='';
    		  $puissance_reelle ='';
    		  $nb_rapports ='';
    		  $emission_co2 ='';
    		  $puissance_kw ='';
    		  $numero_immatriculation ='';
     
     
    				if (!empty($row->bien->carrosserie)){
    				 $carrosserie = implode('=',array(50 , ($row->bien->carrosserie)));  
    				}				
    				if (!empty($row->bien->marque)){
    				 $marque = implode('=',array(29 , ($row->bien->marque)));  
    				}
                    if (!empty($row->bien->modele)){
    				 $modele = implode('=',array(209 , ($row->bien->modele)));  
    				}				
    				if (!empty($row->bien->millesime)){
    		        $millesime = implode('=',array(28 , ($row->bien->millesime)));
    				}				
    				if (!empty($row->bien->kilometrage)){
    		           $kilometrage = implode('=',array(14 , ($row->bien->kilometrage)));
    				}
                    if (!empty($row->bien->energie)){
    		           $energie = implode('=',array(32 , ($row->bien->energie)));
    				}
                    if (!empty($row->bien->puissance_kw)){
    		           $puissance_kw = implode('=',array(213 , ($row->bien->puissance_kw)));
    				}				
    				if (!empty($row->bien->couleur)){
    		           $couleur = implode('=',array(170 , ($row->bien->couleur)));
    				}
    				if (!empty($row->bien->numero_immatriculation)){
    		           $numero_immatriculation = implode('=',array(214 , ($row->bien->numero_immatriculation)));
    				}
    				if (!empty($row->bien->boite_de_vitesse)){
    		           $boite_de_vitesse = implode('=',array(27 , ($row->bien->boite_de_vitesse)));
    				}
    				if (!empty($row->bien->nb_rapports)){
    		           $nb_rapports = implode('=',array(211 , ($row->bien->nb_rapports)));
    				}
    				if (!empty($row->bien->puissance_fiscale)){
    		           $puissance_fiscale = implode('=',array(132 , ($row->bien->puissance_fiscale)));
    				}
    				if (!empty($row->bien->nb_places)){
    		           $nb_places = implode('=',array(176 , ($row->bien->nb_places)));
    				}
    				if (!empty($row->bien->emission_co2)){
    		           $emission_co2 = implode('=',array(176 , ($row->bien->emission_co2)));
    				}
    				if (!empty($row->bien->puissance_reelle)){
    		           $puissance_reelle = implode('=',array(210 , ($row->bien->puissance_reelle)));
    				}
    				if (!empty($row->bien->mise_en_circulation)){
    		           $mise_en_circulation = implode('=',array(207 , ($row->bien->mise_en_circulation)));
    				}
    				if (!empty($row->bien->date_disponibilite_vehicule)){
    		           $date_disponibilite_vehicule = implode('=',array(208 , ($row->bien->date_disponibilite_vehicule)));
    				}
    				}				
     
    		        //$nb_chambres = implode('=',array(29 , ($row->bien->nb_chambres)));
     
    				$fields_opt = array($type_bien, $carrosserie, $nb_places, $marque, $modele, $millesime, $kilometrage, $puissance_kw, $energie, $couleur, $boite_de_vitesse, $nb_rapports, $puissance_fiscale, $puissance_reelle, $emission_co2, $mise_en_circulation, $date_disponibilite_vehicule, $numero_immatriculation);
    				$fields_opt = implode('|' , $fields_opt);
     
    				$result_user = $dbb->get(DB_TABLE_USERS, ['id',  'status', 'auth'] , "   `email` =  '".$email."' " ); 
    				$user_id = $result_user['id'];
     
                    if($user_id == null){
     
    					    $user_insert_fields= array(
     
    							'moddate'=>$stamp
    							,'username'=>$name
    							,'lastname'=>$comp_name
    							//,'avatarimg'=>$logo
    							,'email'=>$email
    							,'phone'=>$phone
    							,'protype' =>$type
    				            ,'procpny' => $comp_name
    				            ,'prosiret' => $comp_num
    							,'loczipcode'=> $postcode
    							,'loccity'=> $city
                                ,'registerdate'=> $stamp
    							,'status'=>'40'
    							,'indir'=>'yes'
    							,'password'=>bin2hex(openssl_random_pseudo_bytes(16)) 
    							,'auth'=>'lo'
    							,'createdby'=>'ubiflow'
    						  );
     
    						$result_insert_user = $dbb->insert(DB_TABLE_USERS, $user_insert_fields);
     
    					$user_id = $result_insert_user['id'];
     
    				}
     
    				$photos = array();
    				$imgname = array();
     
                    $i = 0;
    				if (isset($row->photos->photo) && sizeof($row->photos->photo) > 0)
    				{
    						foreach ($row->photos->photo as $photo)
    						{	
    							$photos[] = getImageUbiflow($photo, $ref);
    							$imgname[] = $photos[$i]['basename'];
    							$i++;
    							if ($i == 6){
    								break; //stop foreach loop after $limit loop
    							}
    						}	
    						$imgnames = implode(';',$imgname);
    				}
     
    				$lochash = '&amp;locality='.$city.'&amp;locality\_code='.$city.'&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;administrative\_area\_level\_2\_code='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;administrative\_area\_level\_1\_code='.$name_reg.'&amp;country=France&amp;countrycode=FR&amp;country\_code=FR&amp;postal\_code='.$postcode.'&amp;postal\_code\_code='.$postcode.'';
     
    				$lochashregion = '&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;country=France&amp;countrycode=FR';
     
    				$fields_list=array(
     
    					//'id' => $id_ad,
    					'title' => $title,
    					'description' => $text,
    					'catid' => $id_cat,
    					'type' => $type,
    					'price' => $price,
    					'createdate' => $stamp,
    					'firstpublisheddate' => $stamp,
    					'moddate' => $stamp,
    					'email' => $email,
    					'vfields' => $fields_opt,
    					'phone' => $phone,
    					'status' => $status,
    					'username' => $name,
    					'location' => $city.','.$pays,
    					'userid' => $user_id,
    					'loccity' => $city,
    					'locdept' => $name_dept,
    					'locregion' => $name_reg,
    					'lochash' => $lochash,
    					'lochashregion' => $lochashregion,
    					'loccountrycode' => 'FR',
    					'loczipcode' => $postcode,
    					'loclatlng' => $lat.'|'.$lng,
    					'loclng' => $lng,
    					'loclat' => $lat,
    					'imgname' => $imgnames,
    					'sku'=> $ref
    				); 
    				//var_dump($fields_list); exit();
     
    				if (is_array($fields_list)){
    				$id_ad = $dbb->insert(DB_TABLE_ITEMS, $fields_list); 
    				}
     
    			}else{
    				$error = 4;
    				break;
    			}		
    	}
     
    	$result = array('error' => $error, 'comp_name' => $comp_name, 'array_id' => array($id_ad));
    	return $result;
    }
     
     function getImageUbiflow($url, $ref){
     
        $trace=''; $t0=microtime(true);  
     
         $target_dir = '../uploads/img/ubiflow/';
    	 $target_dir_tn = '../uploads/img/tn_ubiflow/';
         $img_prefix = 'ubiflow_'.$ref; 
    									if(!is_dir($target_dir))
    									{
    										umask(0);
    										mkdir($target_dir, 0777, true);
    										umask(022);
    									}
        $out=array($success=>true, 'allow_url_fopen'=> ini_get('allow_url_fopen')); 
     
        $er=0;
        if(!preg_match('/^(https:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $url, $url_ary)) $er=1;
        if(empty($url_ary[4])) $er=1;
        $maxsize = 5000000; 
        $base_filename = substr($url_ary[4],strrpos($url_ary[4],"/")+1);
     
     
        $base_get = '/' . $url_ary[4];
        $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;
     
        if($base_filename=="") { $out['success']=false; $out['msg']  = "empty base file name"; return $out;}
     
         	if (strpos($base_filename, '?') !== false) 
    		{
    			$exp = explode('?',$base_filename,-1);
    		    $nom = array_pop($exp);	
    		}else{
    		    $exp = explode('/',$base_filename);
    			$nom = array_pop($exp);
    		}
     
    		if(!empty($nom)) {
    		  $conthum = (file_get_contents($url,false));	
    		  file_put_contents($target_dir_tn.$img_prefix.$nom,$conthum);
    		}				
     
        if (ini_get('allow_url_fopen')){
     
          $dest_file = $target_dir.$img_prefix.$nom;
          $alreadyExist = file_exists($dest_file);
          $out=array('success'=> true, 'basename'=>'ubiflow/'.$img_prefix.$nom, 'dest'=>$dest_file, 'url'=>$url, 'alreadyexist'=>$alreadyExist);
     
          if (!$alreadyExist){
     
            // read the URL
            //$img_file=file_get_contents($url);
     
            // get it from API call directly 
            $res= simple_rest_client($url, 'GET');
            if ($res['success']) $img_file = $res['response'];
     
            if ($img_file){
              $file_handler=fopen($dest_file,'w');
              if(fwrite($file_handler,$img_file)==false){
                  $out['success']=false; $out['msg']  = "error in writing file content";
              }
              fclose($file_handler);
            } else {
              $out['success']=false; $out['msg']  = "bad response from url ";
            }
     
            $out['filesize'] = strlen($img_file); 
            $out['action'] = 'uploaded'; 
     
            // add some DEBUG info 
            $out['http_response_header']=$http_response_header; 
            if ($img_file===false) $out['content']= false; else $out['content']= true;
     
     
          } else {
            $out['action'] = 'skipped-already exist'; 
            $out['filesize']=0;
          } 
        } else {
          $out['success']=false; 
          $out['filesize'] =0; 
          $out['msg']  = "allow_url_fopen must be activated in php settings to work";
        }
     
        $deltatime= (microtime(true)-$t0);
        $log_time = sprintf("%01.3f", $deltatime); 
        $out['exec_in']=$log_time; 
        return $out ; 
     
    }
     
    function getRegionByCp ($code_postal){
     
    $deps = array(
    array('Ain','Auvergne-Rhône-Alpes', 01),	
    array('Allier','Auvergne-Rhône-Alpes', 03),	
    array('Ardeche','Auvergne-Rhône-Alpes', 07),	
    array('Cantal','Auvergne-Rhône-Alpes', 15),	
    array('Drome','Auvergne-Rhône-Alpes', 26),	
    array('Isère','Auvergne-Rhône-Alpes', 38),	
    array('Loire','Auvergne-Rhône-Alpes', 42),	
    array('Haute-Loire','Auvergne-Rhône-Alpes', 43),	
    array('Puy-de-Dôme','Auvergne-Rhône-Alpes', 63),	
    array('Rhône','Auvergne-Rhône-Alpes', 69),	
    array('Savoie','Auvergne-Rhône-Alpes', 73),	
    array('Haute-Savoie','Auvergne-Rhône-Alpes', 74),	 
    array('Côte-d\'Or','Bourgogne-Franche-Comté', 21),	
    array('Doubs','Bourgogne-Franche-Comté', 25),	
    array('Jura','Bourgogne-Franche-Comté', 39),	
    array('Nièvre','Bourgogne-Franche-Comté', 58),	
    array('Haute-Saône','Bourgogne-Franche-Comté', 70),	
    array('Saône-et-Loire','Bourgogne-Franche-Comté', 71),	
    array('Yonne','Bourgogne-Franche-Comté', 89),	
    array('Territoire de Belfort','Bourgogne-Franche-Comté', 90),	
    array('Côtes-d\'Armor','Bretagne', 22),	
    array('Finistère','Bretagne', 29),	
    array('Ille-et-Vilaine','Bretagne', 35),	
    array('Morbihan','Bretagne', 56),	
    array('Cher','Centre-Val de Loire', 18),	
    array('Eure-et-Loir','Centre-Val de Loire', 28),	
    array('Indre','Centre-Val de Loire', 36),	
    array('Indre-et-Loire','Centre-Val de Loire', 37),	
    array('Loir-et-Cher','Centre-Val de Loire', 41),	
    array('Loiret','Centre-Val de Loire', 45),	
    array('Corse-du-Sud','Corse', "2A"),	
    array('Haute-Corse','Corse', "2B"),
    array('Moselle','Grand Est', 57),	
    array('Vosges','Grand Est', 88),	
    array('Bas-Rhin','Grand Est', 67),	
    array('Haut-Rhin','Grand Est', 68),	
    array('Aube','Grand Est', 10),	
    array('Marne','Grand Est', 51),	
    array('Haute-Marne','Grand Est', 52),	
    array('Meurthe-et-Moselle', 'Grand Est', 54),	
    array('Ardennes','Grand Est', 8),
    array('Loiret','Grand Est', 55),	
    array('Aisne','Hauts-de-France', 02),	
    array('Nord','Hauts-de-France', 59),	
    array('Oise','Hauts-de-France', 60),	
    array('Pas-de-Calais','Hauts-de-France', 62),	
    array('Somme','Hauts-de-France', 80),		
    array('Paris','Île-de-France', 75),	
    array('Seine-et-Marne',' Île-de-France', 77),	
    array('Yvelines',' Île-de-France', 78),	
    array('Essonne',' Île-de-France', 91),	
    array('Hauts-de-Seine','Île-de-France', 92),	
    array('Seine-Saint-Denis','Île-de-France', 93),	
    array('Val-de-Marne','Île-de-France', 94),	
    array('Val-d\'Oise', 'Île-de-France', 95),	
    array('Eure','Normandie', 27),	
    array('Orne','Normandie', 61),	
    array('Manche','Normandie', 50),	
    array('Seine-Maritime','Normandie', 76),	
    array('Calvados','Normandie', 14),	
    array('Charente','Nouvelle-Aquitaine', 16),	
    array('Charente-Maritime','Nouvelle-Aquitaine', 17),	
    array('Corrèze','Nouvelle-Aquitaine', 19),	
    array('Creuse','Nouvelle-Aquitaine', 23),	
    array('Dordogne','Nouvelle-Aquitaine', 24),	
    array('Gironde','Nouvelle-Aquitaine', 33),	
    array('Landes','Nouvelle-Aquitaine', 40),	
    array('Lot-et-Garonne','Nouvelle-Aquitaine', 47),	
    array('Pyrénées-Atlantiques','Nouvelle-Aquitaine', 64),	
    array('Deux-Sèvres','Nouvelle-Aquitaine', 79),	
    array('Vienne','Nouvelle-Aquitaine', 86),		
    array('Haute-Vienne','Nouvelle-Aquitaine', 87),
    array('Ariège','Occitanie', 9),	
    array('Aude','Occitanie', 11),	
    array('Aveyron','Occitanie', 12),	
    array('Gard','Occitanie', 30),	
    array('Gers','Occitanie', 32),	
    array('Haute-Garonne','Occitanie', 31),	
    array('Hérault','Occitanie', 34),	
    array('Lot','Occitanie', 46),	
    array('Lozère','Occitanie', 48),	
    array('Hautes-Pyrénées','Occitanie', 65),	
    array('Pyrénées-Orientales','Occitanie', 66),	
    array('Tarn','Occitanie', 81),	
    array('Tarn-et-Garonne','Occitanie', 82),	
    array('Loire-Atlantique','Pays de la Loire', 44),	
    array('Maine-et-Loire','Pays de la Loire', 49),	
    array('Mayenne','Pays de la Loire', 53),	
    array('Sarthe','Pays de la Loire', 72),	
    array('Vendée','Pays de la Loire', 85),
    array('Var','Provence-Alpes-Côte d\'Azur', 83),	
    array('Hautes-Alpes','Provence-Alpes-Côte d\'Azur', 05),			
    array('Alpes-de-Haute-Provence','Provence-Alpes-Côte d\'Azur', 04),
    array('Vaucluse','Provence-Alpes-Côte d\'Azur', 84),
    array('Alpes-Maritimes','Provence-Alpes-Côte d\'Azur', 06),	
    array('Bouches-du-Rhône ','Provence-Alpes-Côte d\'Azur', 13),
    array('Guadeloupe','Guadeloupe', 971),
    array('Martinique','Martinique', 972),
    array('Guyane','Guyane', 973),
    array('La Réunion','La Réunion', 974),
    array('Mayotte','Mayotte', 976),
     
    ); 
     
    	foreach ($deps as $dep) 
    	{
    		if($code_postal == $dep[2])
    		{	
    		 $departement = $dep[0];
    		 $region = $dep[1];	
    		 }			
    	}	
    	$result = array('dept' => $departement, 'region' => $region);
    	return $result;
    }
    Auriez vous une solution s'il vous plait ?
    Cordialement

  2. #2
    Expert confirmé
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 140
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 140
    Par défaut
    Salut

    Enlever le } en trop ligne 364
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont dépannés.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

  3. #3
    Futur Membre du Club
    Homme Profil pro
    débutant
    Inscrit en
    Septembre 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : débutant

    Informations forums :
    Inscription : Septembre 2022
    Messages : 4
    Par défaut Réponse
    Bonsoir j'ai supprimer mais sa ne fonctionne pas non plus .

    Voici se que sa affiche maintenant :

    {"success":false,"code":500,"message":"500 Internal Server Error","extendedMessage":" ZADSERROR = [256] SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'moddate' cannot be null query=INSERT INTO \"zads_users\" (`moddate`, `username`, `lastname`, `email`, `phone`, `protype`, `procpny`, `prosiret`, `loczipcode`, `loccity`, `registerdate`, `status`, `indir`, `password`, `auth`, `createdby`) VALUES (NULL, 'logo', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '40', 'yes', '943bdbc2eaacfc9745a1cf37c86f54a0', 'lo', 'ubiflow') - Fatal Error on line:251 in file:\/home\/c1917476c\/public_html\/*********\/phpsvr\/inc\/db_class.php"}
    Cdlt

  4. #4
    Futur Membre du Club
    Homme Profil pro
    débutant
    Inscrit en
    Septembre 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : débutant

    Informations forums :
    Inscription : Septembre 2022
    Messages : 4
    Par défaut Réponse
    J'ai modifié le fichier sa l'appel mais ne s'ajoute.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    <?php
    
    // PHP7 READY
    /******************************************************************************
     * ZADS GATEWAY FOR UBIFLOW AUTO
     * 
     * Note :  need bootstrap0.php
     *
     * @category   CorePackage
     * @package    ZADS
     * @author     romuald boiteux <***@***>
     * @copyright  2022 
     * @version    0
     ******************************************************************************/
    
    define('DB_MODE', 'pdo'); // both =  create two db accesses (one with old mode and one with new mode)
    require_once("bootstrap0_with_functions.php");
    include_once('inc/API_client_lib.php');
    	
    ///////////////////////////////////
    //Importing xml ads ubiflow
    //////////////////////////////////
    function insert_ubiflow_vehicule($url)
    {
    	global $dbb;
    	
    	$str = '';
    	$id_ad = '';
    	
    	$context  = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
    	$xml = file_get_contents($url, false, $context);			
        $xml = simplexml_load_string($xml);
    
    	foreach($xml->coordonnees->nom as $name => $value)
    	{
    		$nom_entr = $value;
    	}	
    	
    	foreach($xml->coordonnees->siret as $name => $value)
    	{
    		$num_entr = $value;
    	}
     	
    	foreach($xml->coordonnees->logo as $name => $value)
    	{
    		$logo_entr = $value;
    	}
    
    	$array_data = array('reference', 'titre', 'texte','contact_a_afficher', 'email_a_afficher', 'telephone_a_afficher');
    	$array_data1 = array('code_postal', 'ville', 'departement');
    	
    	$count = 0;
    	
    	foreach($xml->annonce as $row)	
    	{
    					
    		$i = 0;
    
    			foreach($array_data as $key)
    			{
    				$error = (!isset($row->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
    
    			foreach($array_data1 as $key)
    			{
    				$error = (!isset($row->bien->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
    
    			$departement = ($row->bien->departement);	
                $location_vehicule = getRegionByCp($departement);
    			
    			$reg = $location_vehicule['region'];
    			$county = $location_vehicule['dept'];
    
    		    if(empty($row->prestation->prix)){
                  $prix = (float) $row->prestation->loyer;
    		    }else{ 
    		      $prix = (float) $row->prestation->prix; 
    		   }	   
    		//Inserting annonce
    
    			if($error == 0) 
    			{
    				$name_reg = $reg;
    				$name_dept = $county;
    				//$id_cat =  $cat_type;
    				$email = htmlspecialchars($row->email_a_afficher);
    				$ref = htmlspecialchars($row->reference);
    				$postcode = htmlspecialchars($row->bien->code_postal);
    				$city = htmlspecialchars($row->bien->ville);
    				$pays = htmlspecialchars($row->bien->pays);
    				$status = 40;
    				$comp_name = htmlspecialchars($nom_entr);
    				$comp_num = htmlspecialchars($num_entr);
    				$lat = htmlspecialchars($row->bien->latitude);
    				$lng = htmlspecialchars($row->bien->longitude);
    				$type = 'pro';
    				$name = htmlspecialchars($row->contact_a_afficher);
    				$phone = htmlspecialchars($row->telephone_a_afficher);
    				$title = htmlspecialchars($row->titre);
    				$text = htmlspecialchars($row->texte);
    				$price = htmlspecialchars($prix);
    				$logo = htmlspecialchars($logo_entr);
    				$stamp= date( 'Y-m-d H:i:s', time());
    				$phone_hidden = htmlspecialchars($row->phone_hidden);
    				//$id_ad = $row->attributes()->{'id'};
    
    				$cat_type = htmlspecialchars($row->prestation->type);
    				
    				$bien_m ='';
    				
    				if (!empty($cat_type)) {
    					switch ($cat_type) {
    							case "V":
    								case "V":
    								$cat_typ = "VEHICULES";
    								$id_cat = 21;
    									
    								
    								
    								break;
    								
                                case "M":
    							     $id_cat = 21;
    							     break;
    							case "L":
    								$cat_typ = "Moto";
    								$id_cat = 22;
    							    
    								break;
    
    						 default:
    								$cat_typ = "AUTRES";
    							    $id_cat = 21;
    								break;
    						}
    				}
    							
    				
    $type_bien ='';
    				$typ_bien = ($row->bien->libelle_type);
    				if (!empty($typ_bien)) {
    					switch ($typ_bien) {
    							case "Voiture": 
    								$type_bien = implode('=',array(217 , "voiture"));
    								break;
                                case "Moto":
    								$type_bien = implode('=',array(217 , "Moto"));
    							     break;
    							case "Scooter":
    								$type_bien = implode('=',array(217 , "Scooter"));
    								break;
                                
    								 
    						   default:
    								$type_bien = implode('=',array(217 , $typ_bien));
    								break;
    						}
    				}			
    				
    				
    		  $carrosserie ='';
              $marque ='';
              $millesime ='';
              $kilometrage =''; 
              $energie ='';
              $couleur ='';
              $boite_de_vitesse ='';
              $puissance_fiscale ='';
    		  $nb_places ='';
              $modele ='';
    		  $puissance_reelle ='';
    		  $nb_rapports ='';
    		  $emission_co2 ='';
    		  $puissance_kw ='';
    		  
    				
    				
    				if (!empty($row->bien->carrosserie)){
    				 $carrosserie = implode('=',array(50 , ($row->bien->carrosserie)));  
    				}				
    				if (!empty($row->bien->marque)){
    				 $marque = implode('=',array(29 , ($row->bien->marque)));  
    				}
                    if (!empty($row->bien->modele)){
    				 $modele = implode('=',array(209 , ($row->bien->modele)));  
    				}				
    				if (!empty($row->bien->millesime)){
    		        $millesime = implode('=',array(28 , ($row->bien->millesime)));
    				}				
    				if (!empty($row->bien->kilometrage)){
    		           $kilometrage = implode('=',array(14 , ($row->bien->kilometrage)));
    				}
                    if (!empty($row->bien->energie)){
    		           $energie = implode('=',array(32 , ($row->bien->energie)));
    				}
                    if (!empty($row->bien->puissance_kw)){
    		           $puissance_kw = implode('=',array(213 , ($row->bien->puissance_kw)));
    				}				
    				if (!empty($row->bien->couleur)){
    		           $couleur = implode('=',array(170 , ($row->bien->couleur)));
    				}
    				if (!empty($row->bien->boite_de_vitesse)){
    		           $boite_de_vitesse = implode('=',array(27 , ($row->bien->boite_de_vitesse)));
    				}
    				if (!empty($row->bien->nb_rapports)){
    		           $nb_rapports = implode('=',array(211 , ($row->bien->nb_rapports)));
    				}
    				if (!empty($row->bien->puissance_fiscale)){
    		           $puissance_fiscale = implode('=',array(132 , ($row->bien->puissance_fiscale)));
    				}
    				if (!empty($row->bien->nb_places)){
    		           $nb_places = implode('=',array(176 , ($row->bien->nb_places)));
    				}
    				if (!empty($row->bien->emission_co2)){
    		           $emission_co2 = implode('=',array(176 , ($row->bien->emission_co2)));
    				}
    				if (!empty($row->bien->puissance_reelle)){
    		           $puissance_reelle = implode('=',array(210 , ($row->bien->puissance_reelle)));
    				}
    				
    								
    
    		        //$nb_chambres = implode('=',array(29 , ($row->bien->nb_chambres)));
    
    				$fields_opt = array($type_bien, $carrosserie, $nb_places, $marque, $modele, $millesime, $kilometrage, $puissance_kw, $energie, $couleur, $boite_de_vitesse, $nb_rapports, $puissance_fiscale, $puissance_reelle, $emission_co2);
    				$fields_opt = implode('|' , $fields_opt);
    				
                    
    				$result_user = $dbb->get(DB_TABLE_USERS, ['id',  'status', 'auth'] , "   `email` =  '".$email."' " ); 
    				$user_id = $result_user['id'];
    				
                    if($user_id == null){
    											
    					    $user_insert_fields= array(
    						
    							'moddate'=>$stamp
    							,'username'=>$name
    							,'lastname'=>$comp_name
    							//,'avatarimg'=>$logo
    							,'email'=>$email
    							,'phone'=>$phone
    							,'protype' =>$type
    				            ,'procpny' => $comp_name
    				            ,'prosiret' => $comp_num
    							,'loczipcode'=> $postcode
    							,'loccity'=> $city
                                ,'registerdate'=> $stamp
    							,'status'=>'40'
    							,'indir'=>'yes'
    							,'password'=>bin2hex(openssl_random_pseudo_bytes(16)) 
    							,'auth'=>'lo'
    							,'createdby'=>'ubiflow'
    						  );
                             
    						$result_insert_user = $dbb->insert(DB_TABLE_USERS, $user_insert_fields);
    						
    					$user_id = $result_insert_user['id'];
    
    				}
    
    				$photos = array();
    				$imgname = array();
    				
                    $i = 0;
    				if (isset($row->photos->photo) && sizeof($row->photos->photo) > 0)
    				{
    						foreach ($row->photos->photo as $photo)
    						{	
    							$photos[] = getImageUbiflow($photo, $ref);
    							$imgname[] = $photos[$i]['basename'];
    							$i++;
    							if ($i == 6){
    								break; //stop foreach loop after $limit loop
    							}
    						}	
    						$imgnames = implode(';',$imgname);
    				}
    				
    				$lochash = '&amp;locality='.$city.'&amp;locality\_code='.$city.'&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;administrative\_area\_level\_2\_code='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;administrative\_area\_level\_1\_code='.$name_reg.'&amp;country=France&amp;countrycode=FR&amp;country\_code=FR&amp;postal\_code='.$postcode.'&amp;postal\_code\_code='.$postcode.'';
    				
    				$lochashregion = '&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;country=France&amp;countrycode=FR';
    				
    				$fields_list=array(
    				  
    					//'id' => $id_ad,
    					'title' => $title,
    					'description' => $text,
    					'catid' => $id_cat,
    					'type' => $type,
    					'price' => $price,
    					'createdate' => $stamp,
    					'firstpublisheddate' => $stamp,
    					'moddate' => $stamp,
    					'email' => $email,
    					'vfields' => $fields_opt,
    					'phone' => $phone,
    					'status' => $status,
    					'username' => $name,
    					'location' => $city.','.$pays,
    					'userid' => $user_id,
    					'loccity' => $city,
    					'locdept' => $name_dept,
    					'locregion' => $name_reg,
    					'lochash' => $lochash,
    					'lochashregion' => $lochashregion,
    					'loccountrycode' => 'FR',
    					'loczipcode' => $postcode,
    					'loclatlng' => $lat.'|'.$lng,
    					'loclng' => $lng,
    					'loclat' => $lat,
    					'imgname' => $imgnames,
    					'sku'=> $ref
    				); 
    				//var_dump($fields_list); exit();
    
    				if (is_array($fields_list)){
    				$id_ad = $dbb->insert(DB_TABLE_ITEMS, $fields_list); 
    				}
    				
    			}else{
    				$error = 4;
    				break;
    			}		
    	}
    	
    	$result = array('error' => $error, 'comp_name' => $comp_name, 'array_id' => array($id_ad));
    	return $result;
    }
    
     function getImageUbiflow($url, $ref){
    
        $trace=''; $t0=microtime(true);  
    
         $target_dir = '../uploads/img/ubiflow/';
    	 $target_dir_tn = '../uploads/img/tn_ubiflow/';
         $img_prefix = 'ubiflow_'.$ref; 
    									if(!is_dir($target_dir))
    									{
    										umask(0);
    										mkdir($target_dir, 0777, true);
    										umask(022);
    									}
        $out=array($success=>true, 'allow_url_fopen'=> ini_get('allow_url_fopen')); 
       
        $er=0;
        if(!preg_match('/^(https:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $url, $url_ary)) $er=1;
        if(empty($url_ary[4])) $er=1;
        $maxsize = 5000000; 
        $base_filename = substr($url_ary[4],strrpos($url_ary[4],"/")+1);
        
    
        $base_get = '/' . $url_ary[4];
        $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;
    
        if($base_filename=="") { $out['success']=false; $out['msg']  = "empty base file name"; return $out;}
    
         	if (strpos($base_filename, '?') !== false) 
    		{
    			$exp = explode('?',$base_filename,-1);
    		    $nom = array_pop($exp);	
    		}else{
    		    $exp = explode('/',$base_filename);
    			$nom = array_pop($exp);
    		}
    	    
    		if(!empty($nom)) {
    		  $conthum = (file_get_contents($url,false));	
    		  file_put_contents($target_dir_tn.$img_prefix.$nom,$conthum);
    		}				
    
        if (ini_get('allow_url_fopen')){
    
          $dest_file = $target_dir.$img_prefix.$nom;
          $alreadyExist = file_exists($dest_file);
          $out=array('success'=> true, 'basename'=>'ubiflow/'.$img_prefix.$nom, 'dest'=>$dest_file, 'url'=>$url, 'alreadyexist'=>$alreadyExist);
    
          if (!$alreadyExist){
    
            // read the URL
            //$img_file=file_get_contents($url);
    
            // get it from API call directly 
            $res= simple_rest_client($url, 'GET');
            if ($res['success']) $img_file = $res['response'];
    
            if ($img_file){
              $file_handler=fopen($dest_file,'w');
              if(fwrite($file_handler,$img_file)==false){
                  $out['success']=false; $out['msg']  = "error in writing file content";
              }
              fclose($file_handler);
            } else {
              $out['success']=false; $out['msg']  = "bad response from url ";
            }
    
            $out['filesize'] = strlen($img_file); 
            $out['action'] = 'uploaded'; 
    
            // add some DEBUG info 
            $out['http_response_header']=$http_response_header; 
            if ($img_file===false) $out['content']= false; else $out['content']= true;
    
    
          } else {
            $out['action'] = 'skipped-already exist'; 
            $out['filesize']=0;
          } 
        } else {
          $out['success']=false; 
          $out['filesize'] =0; 
          $out['msg']  = "allow_url_fopen must be activated in php settings to work";
        }
    
        $deltatime= (microtime(true)-$t0);
        $log_time = sprintf("%01.3f", $deltatime); 
        $out['exec_in']=$log_time; 
        return $out ; 
    
    }
    
    function getRegionByCp ($code_postal){
    	
    $deps = array(
    array('Ain','Auvergne-Rhône-Alpes', 01),	
    array('Allier','Auvergne-Rhône-Alpes', 03),	
    array('Ardeche','Auvergne-Rhône-Alpes', 07),	
    array('Cantal','Auvergne-Rhône-Alpes', 15),	
    array('Drome','Auvergne-Rhône-Alpes', 26),	
    array('Isère','Auvergne-Rhône-Alpes', 38),	
    array('Loire','Auvergne-Rhône-Alpes', 42),	
    array('Haute-Loire','Auvergne-Rhône-Alpes', 43),	
    array('Puy-de-Dôme','Auvergne-Rhône-Alpes', 63),	
    array('Rhône','Auvergne-Rhône-Alpes', 69),	
    array('Savoie','Auvergne-Rhône-Alpes', 73),	
    array('Haute-Savoie','Auvergne-Rhône-Alpes', 74),	 
    array('Côte-d\'Or','Bourgogne-Franche-Comté', 21),	
    array('Doubs','Bourgogne-Franche-Comté', 25),	
    array('Jura','Bourgogne-Franche-Comté', 39),	
    array('Nièvre','Bourgogne-Franche-Comté', 58),	
    array('Haute-Saône','Bourgogne-Franche-Comté', 70),	
    array('Saône-et-Loire','Bourgogne-Franche-Comté', 71),	
    array('Yonne','Bourgogne-Franche-Comté', 89),	
    array('Territoire de Belfort','Bourgogne-Franche-Comté', 90),	
    array('Côtes-d\'Armor','Bretagne', 22),	
    array('Finistère','Bretagne', 29),	
    array('Ille-et-Vilaine','Bretagne', 35),	
    array('Morbihan','Bretagne', 56),	
    array('Cher','Centre-Val de Loire', 18),	
    array('Eure-et-Loir','Centre-Val de Loire', 28),	
    array('Indre','Centre-Val de Loire', 36),	
    array('Indre-et-Loire','Centre-Val de Loire', 37),	
    array('Loir-et-Cher','Centre-Val de Loire', 41),	
    array('Loiret','Centre-Val de Loire', 45),	
    array('Corse-du-Sud','Corse', "2A"),	
    array('Haute-Corse','Corse', "2B"),
    array('Moselle','Grand Est', 57),	
    array('Vosges','Grand Est', 88),	
    array('Bas-Rhin','Grand Est', 67),	
    array('Haut-Rhin','Grand Est', 68),	
    array('Aube','Grand Est', 10),	
    array('Marne','Grand Est', 51),	
    array('Haute-Marne','Grand Est', 52),	
    array('Meurthe-et-Moselle', 'Grand Est', 54),	
    array('Ardennes','Grand Est', 8),
    array('Loiret','Grand Est', 55),	
    array('Aisne','Hauts-de-France', 02),	
    array('Nord','Hauts-de-France', 59),	
    array('Oise','Hauts-de-France', 60),	
    array('Pas-de-Calais','Hauts-de-France', 62),	
    array('Somme','Hauts-de-France', 80),		
    array('Paris','Île-de-France', 75),	
    array('Seine-et-Marne',' Île-de-France', 77),	
    array('Yvelines',' Île-de-France', 78),	
    array('Essonne',' Île-de-France', 91),	
    array('Hauts-de-Seine','Île-de-France', 92),	
    array('Seine-Saint-Denis','Île-de-France', 93),	
    array('Val-de-Marne','Île-de-France', 94),	
    array('Val-d\'Oise', 'Île-de-France', 95),	
    array('Eure','Normandie', 27),	
    array('Orne','Normandie', 61),	
    array('Manche','Normandie', 50),	
    array('Seine-Maritime','Normandie', 76),	
    array('Calvados','Normandie', 14),	
    array('Charente','Nouvelle-Aquitaine', 16),	
    array('Charente-Maritime','Nouvelle-Aquitaine', 17),	
    array('Corrèze','Nouvelle-Aquitaine', 19),	
    array('Creuse','Nouvelle-Aquitaine', 23),	
    array('Dordogne','Nouvelle-Aquitaine', 24),	
    array('Gironde','Nouvelle-Aquitaine', 33),	
    array('Landes','Nouvelle-Aquitaine', 40),	
    array('Lot-et-Garonne','Nouvelle-Aquitaine', 47),	
    array('Pyrénées-Atlantiques','Nouvelle-Aquitaine', 64),	
    array('Deux-Sèvres','Nouvelle-Aquitaine', 79),	
    array('Vienne','Nouvelle-Aquitaine', 86),		
    array('Haute-Vienne','Nouvelle-Aquitaine', 87),
    array('Ariège','Occitanie', 9),	
    array('Aude','Occitanie', 11),	
    array('Aveyron','Occitanie', 12),	
    array('Gard','Occitanie', 30),	
    array('Gers','Occitanie', 32),	
    array('Haute-Garonne','Occitanie', 31),	
    array('Hérault','Occitanie', 34),	
    array('Lot','Occitanie', 46),	
    array('Lozère','Occitanie', 48),	
    array('Hautes-Pyrénées','Occitanie', 65),	
    array('Pyrénées-Orientales','Occitanie', 66),	
    array('Tarn','Occitanie', 81),	
    array('Tarn-et-Garonne','Occitanie', 82),	
    array('Loire-Atlantique','Pays de la Loire', 44),	
    array('Maine-et-Loire','Pays de la Loire', 49),	
    array('Mayenne','Pays de la Loire', 53),	
    array('Sarthe','Pays de la Loire', 72),	
    array('Vendée','Pays de la Loire', 85),
    array('Var','Provence-Alpes-Côte d\'Azur', 83),	
    array('Hautes-Alpes','Provence-Alpes-Côte d\'Azur', 05),			
    array('Alpes-de-Haute-Provence','Provence-Alpes-Côte d\'Azur', 04),
    array('Vaucluse','Provence-Alpes-Côte d\'Azur', 84),
    array('Alpes-Maritimes','Provence-Alpes-Côte d\'Azur', 06),	
    array('Bouches-du-Rhône ','Provence-Alpes-Côte d\'Azur', 13),
    array('Guadeloupe','Guadeloupe', 971),
    array('Martinique','Martinique', 972),
    array('Guyane','Guyane', 973),
    array('La Réunion','La Réunion', 974),
    array('Mayotte','Mayotte', 976),
    
    ); 
    
    	foreach ($deps as $dep) 
    	{
    		if($code_postal == $dep[2])
    		{	
    		 $departement = $dep[0];
    		 $region = $dep[1];	
    		 }			
    	}	
    	$result = array('dept' => $departement, 'region' => $region);
    	return $result;
    }
    Quelqu'un aurait une idée svp ?

    Merci à vous.

    Cordialement

  5. #5
    Expert confirmé
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 719
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 719
    Par défaut
    à quel bloc correspond l'accolade fermante de la ligne 268 ?

  6. #6
    Futur Membre du Club
    Homme Profil pro
    débutant
    Inscrit en
    Septembre 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : débutant

    Informations forums :
    Inscription : Septembre 2022
    Messages : 4
    Par défaut Réponse
    Citation Envoyé par mathieu Voir le message
    à quel bloc correspond l'accolade fermante de la ligne 268 ?
    Bonjour, justement je ne sais pas j'ai fait avec un gars pour l'immobilier et la je souhaite faire pour l'automobile.
    Je persise le gars est d'Abidjan et voulait de plus en plus d'argent donc j'essaie de faire tout seul (je suis novice et perdue la dedans).
    Cordialement

  7. #7
    Membre chevronné Avatar de licardentaistor
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Juillet 2021
    Messages
    346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Juillet 2021
    Messages : 346
    Par défaut
    il manque une accolade fermante pour le for each.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    <?php
     
    // PHP7 READY
    /******************************************************************************
     * ZADS GATEWAY FOR UBIFLOW AUTO
     * 
     * Note :  need bootstrap0.php
     *
     * @category   CorePackage
     * @package    ZADS
     * @author     romuald boiteux <serviceclient@jetrouvetous.fr>
     * @copyright  2022 
     * @version    0
     ******************************************************************************/
     
    define('DB_MODE', 'pdo'); // both =  create two db accesses (one with old mode and one with new mode)
    require_once("bootstrap0_with_functions.php");
    include_once('inc/API_client_lib.php');
     
    ///////////////////////////////////
    //Importing xml ads ubiflow
    //////////////////////////////////
    function insert_ubiflow_auto($url)
    {
    	global $dbb;
     
    	$str = '';
    	$id_ad = '';
     
    	$context  = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
    	$xml = file_get_contents($url, false, $context);			
        $xml = simplexml_load_string($xml);
     
    	foreach($xml->coordonnees->nom as $name => $value)
    	{
    		$nom_entr = $value;
    	}	
     
    	foreach($xml->coordonnees->siret as $name => $value)
    	{
    		$num_entr = $value;
    	}
     
    	foreach($xml->coordonnees->logo as $name => $value)
    	{
    		$logo_entr = $value;
    	}
     
    	$array_data = array('reference', 'titre', 'texte','contact_a_afficher', 'email_a_afficher', 'telephone_a_afficher');
    	$array_data1 = array('code_postal', 'ville', 'departement');
     
    	$count = 0;
     
    	foreach($xml->annonce as $row)	
    	{
     
    		$i = 0;
     
    			foreach($array_data as $key)
    			{
    				$error = (!isset($row->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
     
    			foreach($array_data1 as $key)
    			{
    				$error = (!isset($row->bien->$key)) ? 4 : 0;
    				if($error == 4)
    				break;
    				$i++;
    			}
     
    			$departement = ($row->bien->departement);	
                $location_auto = getRegionByCp($departement);
     
    			$reg = $location_auto['region'];
    			$county = $location_auto['dept'];
     
    		   if(empty($row->prestation->prix)){
                  $prix = (float) $row->prestation->loyer;
    		    }else{ 
    		      $prix = (float) $row->prestation->prix; 
    		   }	   
    		//Inserting annonce
     
    			if($error == 0) 
    			{
    				$name_reg = $reg;
    				$name_dept = $county;
    				//$id_cat =  $cat_type;
    				$email = htmlspecialchars($row->email_a_afficher);
    				$ref = htmlspecialchars($row->reference);
    				$postcode = htmlspecialchars($row->bien->code_postal);
    				$city = htmlspecialchars($row->bien->ville);
    				$pays = htmlspecialchars($row->bien->pays);
    				$status = 40;
    				$comp_name = htmlspecialchars($nom_entr);
    				$comp_num = htmlspecialchars($num_entr);
    				$lat = htmlspecialchars($row->bien->latitude);
    				$lng = htmlspecialchars($row->bien->longitude);
    				$type = 'pro';
    				$name = htmlspecialchars($row->contact_a_afficher);
    				$phone = htmlspecialchars($row->telephone_a_afficher);
    				$title = htmlspecialchars($row->titre);
    				$text = htmlspecialchars($row->texte);
    				$price = htmlspecialchars($prix);
    				$logo = htmlspecialchars($logo_entr);
    				$stamp= date( 'Y-m-d H:i:s', time());
    				$phone_hidden = htmlspecialchars($row->phone_hidden);
    				//$id_ad = $row->attributes()->{'id'};
     
    				$cat_type = htmlspecialchars($row->prestation->type);
     
    				$bien_m ='';
     
    				if (!empty($cat_type)) {
    					switch ($cat_type) {
    							case "V":
    								$cat_typ = "vehicule";
    								$id_cat = 21;
    								$millesime = ($row->bien->millesime);
    							    if (!empty($millesime)){
                                        if ($millesime > 1970 ){									
    									   $type_de_vente = implode('=',array(29 , "NEUF"));
    									}else{
    									   $type_de_vente = implode('=',array(29 , "ANCIEN"));
    									}	
    								}else{ 
    									$type_de_vente = '';
    								}
    								break;
     
    						}
    				}
     
     
    				$type_bien ='';
    				$typ_bien = ($row->bien->libelle_type);
    				if (!empty($typ_bien)) {
    					switch ($typ_bien) {
    							case "4X4": 
    								$type_bien = implode('=',array(50 , "4X4"));
    								break;
                                case "Berline":
    								$type_bien = implode('=',array(50 , "Berline"));
    							     break;
    							case "Break":
    								$type_bien = implode('=',array(50 , "Break"));
    								break;
                                case "Cabriolet":
    								$type_bien = implode('=',array(50 , "Cabriolet"));
    							     break;
    							case "Coupé Sport":
    								$type_bien = implode('=',array(50 , "Coupé Sport"));
    								break;
                                case "Citadine":
    								 $type_bien = implode('=',array(50 , "Citadine"));
    							     break;
    							case "Monospace":
    								 $type_bien = implode('=',array(50 , "Monospace"));
    							     break;
    							case "Pick-up":
    								 $type_bien = implode('=',array(50 , "Pick-up"));
    							     break;
    							case "Luxe":
    								 $type_bien = implode('=',array(50 , "Luxe"));
    							     break;
    							case "Sans permis":
    								 $type_bien = implode('=',array(50 , "Sans permis"));
    							     break;
    							case "Voiture de société, commerciale":
    								 $type_bien = implode('=',array(50 , "Voiture de société, commerciale"));
    							     break;
    							case "Voiture sans permis":
    								 $type_bien = implode('=',array(50 , "Voiture sans permis"));
    							     break;
    							case "Accessoires et pièces":
    								 $type_bien = implode('=',array(50 , "Accessoires et pièces"));
    							     break;
    							case "Autre":
    								 $type_bien = implode('=',array(50 , "Autre"));
    							     break;
     
    						   default:
    								$type_bien = implode('=',array(50 , $typ_bien));
    								break;
     
    								case "F":
    								$cat_typ = "MOTO";
    								$id_cat = 22;
    								break;
     
    						}
    				}		
     
              $carrosserie ='';
              $marque ='';
              $millesime ='';
              $kilometrage =''; 
              $energie ='';
              $couleur ='';
              $boite_de_vitesse ='';
              $puissance_fiscale ='';
    		  $nb_places ='';
              $mise_en_circulation ='';
    		  $date_disponibilite_vehicule ='';
    		  $modele ='';
    		  $puissance_reelle ='';
    		  $nb_rapports ='';
    		  $emission_co2 ='';
    		  $puissance_kw ='';
    		  $numero_immatriculation ='';
     
     
    				if (!empty($row->bien->carrosserie)){
    				 $carrosserie = implode('=',array(50 , ($row->bien->carrosserie)));  
    				}				
    				if (!empty($row->bien->marque)){
    				 $marque = implode('=',array(29 , ($row->bien->marque)));  
    				}
                    if (!empty($row->bien->modele)){
    				 $modele = implode('=',array(209 , ($row->bien->modele)));  
    				}				
    				if (!empty($row->bien->millesime)){
    		        $millesime = implode('=',array(28 , ($row->bien->millesime)));
    				}				
    				if (!empty($row->bien->kilometrage)){
    		           $kilometrage = implode('=',array(14 , ($row->bien->kilometrage)));
    				}
                    if (!empty($row->bien->energie)){
    		           $energie = implode('=',array(32 , ($row->bien->energie)));
    				}
                    if (!empty($row->bien->puissance_kw)){
    		           $puissance_kw = implode('=',array(213 , ($row->bien->puissance_kw)));
    				}				
    				if (!empty($row->bien->couleur)){
    		           $couleur = implode('=',array(170 , ($row->bien->couleur)));
    				}
    				if (!empty($row->bien->numero_immatriculation)){
    		           $numero_immatriculation = implode('=',array(214 , ($row->bien->numero_immatriculation)));
    				}
    				if (!empty($row->bien->boite_de_vitesse)){
    		           $boite_de_vitesse = implode('=',array(27 , ($row->bien->boite_de_vitesse)));
    				}
    				if (!empty($row->bien->nb_rapports)){
    		           $nb_rapports = implode('=',array(211 , ($row->bien->nb_rapports)));
    				}
    				if (!empty($row->bien->puissance_fiscale)){
    		           $puissance_fiscale = implode('=',array(132 , ($row->bien->puissance_fiscale)));
    				}
    				if (!empty($row->bien->nb_places)){
    		           $nb_places = implode('=',array(176 , ($row->bien->nb_places)));
    				}
    				if (!empty($row->bien->emission_co2)){
    		           $emission_co2 = implode('=',array(176 , ($row->bien->emission_co2)));
    				}
    				if (!empty($row->bien->puissance_reelle)){
    		           $puissance_reelle = implode('=',array(210 , ($row->bien->puissance_reelle)));
    				}
    				if (!empty($row->bien->mise_en_circulation)){
    		           $mise_en_circulation = implode('=',array(207 , ($row->bien->mise_en_circulation)));
    				}
    				if (!empty($row->bien->date_disponibilite_vehicule)){
    		           $date_disponibilite_vehicule = implode('=',array(208 , ($row->bien->date_disponibilite_vehicule)));
    				}
    				}				
     
    		        //$nb_chambres = implode('=',array(29 , ($row->bien->nb_chambres)));
     
    				$fields_opt = array($type_bien, $carrosserie, $nb_places, $marque, $modele, $millesime, $kilometrage, $puissance_kw, $energie, $couleur, $boite_de_vitesse, $nb_rapports, $puissance_fiscale, $puissance_reelle, $emission_co2, $mise_en_circulation, $date_disponibilite_vehicule, $numero_immatriculation);
    				$fields_opt = implode('|' , $fields_opt);
     
    				$result_user = $dbb->get(DB_TABLE_USERS, ['id',  'status', 'auth'] , "   `email` =  '".$email."' " ); 
    				$user_id = $result_user['id'];
     
                    if($user_id == null){
     
    					    $user_insert_fields= array(
     
    							'moddate'=>$stamp
    							,'username'=>$name
    							,'lastname'=>$comp_name
    							//,'avatarimg'=>$logo
    							,'email'=>$email
    							,'phone'=>$phone
    							,'protype' =>$type
    				            ,'procpny' => $comp_name
    				            ,'prosiret' => $comp_num
    							,'loczipcode'=> $postcode
    							,'loccity'=> $city
                                ,'registerdate'=> $stamp
    							,'status'=>'40'
    							,'indir'=>'yes'
    							,'password'=>bin2hex(openssl_random_pseudo_bytes(16)) 
    							,'auth'=>'lo'
    							,'createdby'=>'ubiflow'
    						  );
     
    						$result_insert_user = $dbb->insert(DB_TABLE_USERS, $user_insert_fields);
     
    					$user_id = $result_insert_user['id'];
     
    				}
     
    				$photos = array();
    				$imgname = array();
     
                    $i = 0;
    				if (isset($row->photos->photo) && sizeof($row->photos->photo) > 0)
    				{
    						foreach ($row->photos->photo as $photo)
    						{	
    							$photos[] = getImageUbiflow($photo, $ref);
    							$imgname[] = $photos[$i]['basename'];
    							$i++;
    							if ($i == 6){
    								break; //stop foreach loop after $limit loop
    							}
    						}	
    						$imgnames = implode(';',$imgname);
    				}
     
    				$lochash = '&amp;locality='.$city.'&amp;locality\_code='.$city.'&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;administrative\_area\_level\_2\_code='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;administrative\_area\_level\_1\_code='.$name_reg.'&amp;country=France&amp;countrycode=FR&amp;country\_code=FR&amp;postal\_code='.$postcode.'&amp;postal\_code\_code='.$postcode.'';
     
    				$lochashregion = '&amp;dept='.$name_dept.'&amp;deptcode='.$name_dept.'&amp;region='.$name_reg.'&amp;regioncode='.$name_reg.'&amp;country=France&amp;countrycode=FR';
     
    				$fields_list=array(
     
    					//'id' => $id_ad,
    					'title' => $title,
    					'description' => $text,
    					'catid' => $id_cat,
    					'type' => $type,
    					'price' => $price,
    					'createdate' => $stamp,
    					'firstpublisheddate' => $stamp,
    					'moddate' => $stamp,
    					'email' => $email,
    					'vfields' => $fields_opt,
    					'phone' => $phone,
    					'status' => $status,
    					'username' => $name,
    					'location' => $city.','.$pays,
    					'userid' => $user_id,
    					'loccity' => $city,
    					'locdept' => $name_dept,
    					'locregion' => $name_reg,
    					'lochash' => $lochash,
    					'lochashregion' => $lochashregion,
    					'loccountrycode' => 'FR',
    					'loczipcode' => $postcode,
    					'loclatlng' => $lat.'|'.$lng,
    					'loclng' => $lng,
    					'loclat' => $lat,
    					'imgname' => $imgnames,
    					'sku'=> $ref
    				); 
    				//var_dump($fields_list); exit();
     
    				if (is_array($fields_list)){
    				$id_ad = $dbb->insert(DB_TABLE_ITEMS, $fields_list); 
    				}
    				else{
    				$error = 4;
    				break;
    			}
    	}
     
    	$result = array('error' => $error, 'comp_name' => $comp_name, 'array_id' => array($id_ad));
    	return $result;
    }
     
     function getImageUbiflow($url, $ref){
     
        $trace=''; $t0=microtime(true);  
     
         $target_dir = '../uploads/img/ubiflow/';
    	 $target_dir_tn = '../uploads/img/tn_ubiflow/';
         $img_prefix = 'ubiflow_'.$ref; 
    									if(!is_dir($target_dir))
    									{
    										umask(0);
    										mkdir($target_dir, 0777, true);
    										umask(022);
    									}
        $out=array($success=>true, 'allow_url_fopen'=> ini_get('allow_url_fopen')); 
     
        $er=0;
        if(!preg_match('/^(https:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $url, $url_ary)) $er=1;
        if(empty($url_ary[4])) $er=1;
        $maxsize = 5000000; 
        $base_filename = substr($url_ary[4],strrpos($url_ary[4],"/")+1);
     
     
        $base_get = '/' . $url_ary[4];
        $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;
     
        if($base_filename=="") { $out['success']=false; $out['msg']  = "empty base file name"; return $out;}
     
         	if (strpos($base_filename, '?') !== false) 
    		{
    			$exp = explode('?',$base_filename,-1);
    		    $nom = array_pop($exp);	
    		}else{
    		    $exp = explode('/',$base_filename);
    			$nom = array_pop($exp);
    		}
     
    		if(!empty($nom)) {
    		  $conthum = (file_get_contents($url,false));	
    		  file_put_contents($target_dir_tn.$img_prefix.$nom,$conthum);
    		}				
     
        if (ini_get('allow_url_fopen')){
     
          $dest_file = $target_dir.$img_prefix.$nom;
          $alreadyExist = file_exists($dest_file);
          $out=array('success'=> true, 'basename'=>'ubiflow/'.$img_prefix.$nom, 'dest'=>$dest_file, 'url'=>$url, 'alreadyexist'=>$alreadyExist);
     
          if (!$alreadyExist){
     
            // read the URL
            //$img_file=file_get_contents($url);
     
            // get it from API call directly 
            $res= simple_rest_client($url, 'GET');
            if ($res['success']) $img_file = $res['response'];
     
            if ($img_file){
              $file_handler=fopen($dest_file,'w');
              if(fwrite($file_handler,$img_file)==false){
                  $out['success']=false; $out['msg']  = "error in writing file content";
              }
              fclose($file_handler);
            } else {
              $out['success']=false; $out['msg']  = "bad response from url ";
            }
     
            $out['filesize'] = strlen($img_file); 
            $out['action'] = 'uploaded'; 
     
            // add some DEBUG info 
            $out['http_response_header']=$http_response_header; 
            if ($img_file===false) $out['content']= false; else $out['content']= true;
     
     
          } else {
            $out['action'] = 'skipped-already exist'; 
            $out['filesize']=0;
          } 
        } else {
          $out['success']=false; 
          $out['filesize'] =0; 
          $out['msg']  = "allow_url_fopen must be activated in php settings to work";
        }
     
        $deltatime= (microtime(true)-$t0);
        $log_time = sprintf("%01.3f", $deltatime); 
        $out['exec_in']=$log_time; 
        return $out ; 
     
    }
     
    function getRegionByCp ($code_postal){
     
    $deps = array(
    array('Ain','Auvergne-Rhône-Alpes', 01),	
    array('Allier','Auvergne-Rhône-Alpes', 03),	
    array('Ardeche','Auvergne-Rhône-Alpes', 07),	
    array('Cantal','Auvergne-Rhône-Alpes', 15),	
    array('Drome','Auvergne-Rhône-Alpes', 26),	
    array('Isère','Auvergne-Rhône-Alpes', 38),	
    array('Loire','Auvergne-Rhône-Alpes', 42),	
    array('Haute-Loire','Auvergne-Rhône-Alpes', 43),	
    array('Puy-de-Dôme','Auvergne-Rhône-Alpes', 63),	
    array('Rhône','Auvergne-Rhône-Alpes', 69),	
    array('Savoie','Auvergne-Rhône-Alpes', 73),	
    array('Haute-Savoie','Auvergne-Rhône-Alpes', 74),	 
    array('Côte-d\'Or','Bourgogne-Franche-Comté', 21),	
    array('Doubs','Bourgogne-Franche-Comté', 25),	
    array('Jura','Bourgogne-Franche-Comté', 39),	
    array('Nièvre','Bourgogne-Franche-Comté', 58),	
    array('Haute-Saône','Bourgogne-Franche-Comté', 70),	
    array('Saône-et-Loire','Bourgogne-Franche-Comté', 71),	
    array('Yonne','Bourgogne-Franche-Comté', 89),	
    array('Territoire de Belfort','Bourgogne-Franche-Comté', 90),	
    array('Côtes-d\'Armor','Bretagne', 22),	
    array('Finistère','Bretagne', 29),	
    array('Ille-et-Vilaine','Bretagne', 35),	
    array('Morbihan','Bretagne', 56),	
    array('Cher','Centre-Val de Loire', 18),	
    array('Eure-et-Loir','Centre-Val de Loire', 28),	
    array('Indre','Centre-Val de Loire', 36),	
    array('Indre-et-Loire','Centre-Val de Loire', 37),	
    array('Loir-et-Cher','Centre-Val de Loire', 41),	
    array('Loiret','Centre-Val de Loire', 45),	
    array('Corse-du-Sud','Corse', "2A"),	
    array('Haute-Corse','Corse', "2B"),
    array('Moselle','Grand Est', 57),	
    array('Vosges','Grand Est', 88),	
    array('Bas-Rhin','Grand Est', 67),	
    array('Haut-Rhin','Grand Est', 68),	
    array('Aube','Grand Est', 10),	
    array('Marne','Grand Est', 51),	
    array('Haute-Marne','Grand Est', 52),	
    array('Meurthe-et-Moselle', 'Grand Est', 54),	
    array('Ardennes','Grand Est', 8),
    array('Loiret','Grand Est', 55),	
    array('Aisne','Hauts-de-France', 02),	
    array('Nord','Hauts-de-France', 59),	
    array('Oise','Hauts-de-France', 60),	
    array('Pas-de-Calais','Hauts-de-France', 62),	
    array('Somme','Hauts-de-France', 80),		
    array('Paris','Île-de-France', 75),	
    array('Seine-et-Marne',' Île-de-France', 77),	
    array('Yvelines',' Île-de-France', 78),	
    array('Essonne',' Île-de-France', 91),	
    array('Hauts-de-Seine','Île-de-France', 92),	
    array('Seine-Saint-Denis','Île-de-France', 93),	
    array('Val-de-Marne','Île-de-France', 94),	
    array('Val-d\'Oise', 'Île-de-France', 95),	
    array('Eure','Normandie', 27),	
    array('Orne','Normandie', 61),	
    array('Manche','Normandie', 50),	
    array('Seine-Maritime','Normandie', 76),	
    array('Calvados','Normandie', 14),	
    array('Charente','Nouvelle-Aquitaine', 16),	
    array('Charente-Maritime','Nouvelle-Aquitaine', 17),	
    array('Corrèze','Nouvelle-Aquitaine', 19),	
    array('Creuse','Nouvelle-Aquitaine', 23),	
    array('Dordogne','Nouvelle-Aquitaine', 24),	
    array('Gironde','Nouvelle-Aquitaine', 33),	
    array('Landes','Nouvelle-Aquitaine', 40),	
    array('Lot-et-Garonne','Nouvelle-Aquitaine', 47),	
    array('Pyrénées-Atlantiques','Nouvelle-Aquitaine', 64),	
    array('Deux-Sèvres','Nouvelle-Aquitaine', 79),	
    array('Vienne','Nouvelle-Aquitaine', 86),		
    array('Haute-Vienne','Nouvelle-Aquitaine', 87),
    array('Ariège','Occitanie', 9),	
    array('Aude','Occitanie', 11),	
    array('Aveyron','Occitanie', 12),	
    array('Gard','Occitanie', 30),	
    array('Gers','Occitanie', 32),	
    array('Haute-Garonne','Occitanie', 31),	
    array('Hérault','Occitanie', 34),	
    array('Lot','Occitanie', 46),	
    array('Lozère','Occitanie', 48),	
    array('Hautes-Pyrénées','Occitanie', 65),	
    array('Pyrénées-Orientales','Occitanie', 66),	
    array('Tarn','Occitanie', 81),	
    array('Tarn-et-Garonne','Occitanie', 82),	
    array('Loire-Atlantique','Pays de la Loire', 44),	
    array('Maine-et-Loire','Pays de la Loire', 49),	
    array('Mayenne','Pays de la Loire', 53),	
    array('Sarthe','Pays de la Loire', 72),	
    array('Vendée','Pays de la Loire', 85),
    array('Var','Provence-Alpes-Côte d\'Azur', 83),	
    array('Hautes-Alpes','Provence-Alpes-Côte d\'Azur', 05),			
    array('Alpes-de-Haute-Provence','Provence-Alpes-Côte d\'Azur', 04),
    array('Vaucluse','Provence-Alpes-Côte d\'Azur', 84),
    array('Alpes-Maritimes','Provence-Alpes-Côte d\'Azur', 06),	
    array('Bouches-du-Rhône ','Provence-Alpes-Côte d\'Azur', 13),
    array('Guadeloupe','Guadeloupe', 971),
    array('Martinique','Martinique', 972),
    array('Guyane','Guyane', 973),
    array('La Réunion','La Réunion', 974),
    array('Mayotte','Mayotte', 976),
     
    ); 
     
    	foreach ($deps as $dep) 
    	{
    		if($code_postal == $dep[2])
    		{	
    		 $departement = $dep[0];
    		 $region = $dep[1];	
    		 }			
    	}	
    	$result = array('dept' => $departement, 'region' => $region);
    	return $result;
    }

Discussions similaires

  1. Erreur de fonction INSERT TO Parse error: syntax error, unexpected end
    Par Mandragore99 dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 13/05/2020, 22h58
  2. [MySQL] Code PHP et erreur serveur Free : "Parse error: syntax error, unexpected '{' "
    Par mauriiice dans le forum PHP & Base de données
    Réponses: 11
    Dernier message: 31/05/2009, 20h47
  3. Parse error: syntax error, unexpected '}' help
    Par beur dans le forum Langage
    Réponses: 5
    Dernier message: 23/03/2006, 21h33
  4. [Configuration] Problème après l'installation (Parse error: syntax error,..)
    Par beur dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 8
    Dernier message: 21/03/2006, 14h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo