Subversion Repositories eFlore/Applications.cel

Rev

Rev 3771 | Rev 3779 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3771 Rev 3773
Line 1... Line 1...
1
<?php
1
<?php
Line 2... Line 2...
2
 
2
 
3
/*
3
/*
Line 4... Line 4...
4
	PHP 7
4
	PHP 7
-
 
5
 
-
 
6
	Script used to synchronize PN occ with Flora Data
5
 
7
 
Line 6... Line 8...
6
	Script used to synchronize PN occ with CEL
8
	Écrit en franglish pour une meilleure compréhension (lol)
Line 7... Line 9...
7
*/
9
*/
Line -... Line 10...
-
 
10
 
-
 
11
class PullPlantnet extends Script {
8
 
12
 
Line 9... Line 13...
9
class PullPlantnet extends Script {
13
	protected $bdd;
10
 
14
 
Line 23... Line 27...
23
 
27
 
24
	// Paramètre de suivi et de pagination de l'API des obs PN
28
	// Paramètre de suivi et de pagination de l'API des obs PN
25
	protected $currentPage = '';
29
	protected $currentPage = '';
26
	protected $currentProject = '';
30
	protected $currentProject = '';
27
	protected $hasMore = false;
-
 
Line 28... Line 31...
28
	protected $count = 0;
31
	protected $hasMore = false;
29
 
32
 
30
	// Traduction des organes de PN
33
	// Traduction des organes de PN
31
	protected $tagsImageTraduits = [
34
	protected $tagsImageTraduits = [
Line 42... Line 45...
42
	// Created, en fonction de la date de création
45
	// Created, en fonction de la date de création
43
	// Deleted, well, you already got it
46
	// Deleted, well, you already got it
44
	protected $lifecycles = [
47
	protected $lifecycles = [
45
		'created',
48
		'created',
46
		'modified',
49
		'modified',
47
		'deleted', // deleted peut être très lent
50
		'deleted', // deleted peut être très lent (pas d'index coté PN pour le moment)
48
	];
51
	];
Line 49... Line 52...
49
 
52
 
50
	/**
53
	/**
51
	 * Paramêtres par défaut disponibles pour la ligne de commande
54
	 * Paramêtres par défaut disponibles pour la ligne de commande
Line 64... Line 67...
64
		'-startDate' => array(false, true, 'Date de début (parsée par strtotime). Ex: "YYYY:MM:DD HH:II:SS"'),
67
		'-startDate' => array(false, true, 'Date de début (parsée par strtotime). Ex: "YYYY:MM:DD HH:II:SS"'),
65
		'-lifecycle' => array(false, true, 'Par défaut : modified ; Au choix parmi : created/modified/deleted (deleted est lent)'),
68
		'-lifecycle' => array(false, true, 'Par défaut : modified ; Au choix parmi : created/modified/deleted (deleted est lent)'),
66
		'-pnObsId' => array(false, true, "ID de l'obs chez PlantNet"),
69
		'-pnObsId' => array(false, true, "ID de l'obs chez PlantNet"),
67
		'-project' => array(false, true, "projectId de l'obs chez PlantNet"),
70
		'-project' => array(false, true, "projectId de l'obs chez PlantNet"),
68
		'-tbObsId' => array(false, true, "ID de l'obs chez Tela"),
71
		'-tbObsId' => array(false, true, "ID de l'obs chez Tela"),
-
 
72
		'-debug' => array(false, false, "Mode débug (ajoute du log) Au choix parmi : debug/log (log est plus verbeux)"),
69
	);
73
	);
Line 70... Line 74...
70
 
74
 
71
	public function __construct($script_nom, $parametres_cli) {
75
	public function __construct($script_nom, $parametres_cli) {
72
		parent::__construct($script_nom, $parametres_cli);
76
		parent::__construct($script_nom, $parametres_cli);
Line 73... Line 77...
73
		$this->bdd = new Bdd();
77
		$this->bdd = new Bdd();
-
 
78
 
-
 
79
		$this->correspondingIdsFilename = Config::get('correspondingIdsFilename');
74
 
80
 
Line 75... Line 81...
75
		$this->correspondingIdsFilename = Config::get('correspondingIdsFilename');
81
		$this->debug = $this->getParametre('debug');
76
	}
82
	}
Line 77... Line 83...
77
 
83
 
78
	public function executer() {
84
	public function executer() {
79
		$cmd = $this->getParametre('a');
85
		$cmd = $this->getParametre('a');
80
 
86
 
81
		switch ($cmd) {
87
		switch ($cmd) {
82
			case 'updateLatest':
88
			case 'updateLatest':
83
				$this->updateLatest($this->getParametre('startDate'));
89
				$this->updateLatest($this->getParametre('startDate'), $this->getParametre('lifecycle'));
84
				break;
90
				break;
85
			case 'updateOnePN':
91
			case 'updateOnePN':
86
				$this->updateOnePN((int)$this->getParametre('pnObsId'), $this->getParametre('project'));
92
				$this->updateOnePN((int)$this->getParametre('pnObsId'), $this->getParametre('project'));
87
				break;
93
				break;
88
			case 'updateOneTB':
94
			case 'updateOneTB':
89
				$this->updateOneTB($this->getParametre('tbObsId'));
95
				$this->updateOneTB((int)$this->getParametre('tbObsId'));
90
				break;
96
				break;
91
			case 'updateCorrespondingIdsTable':
97
			case 'updateCorrespondingIdsTable':
92
				$this->updateCorrespondingIdsTable();
98
				$this->updateCorrespondingIdsTable();
93
				break;
99
				break;
94
			default:
100
			default:
95
				$msg = "Erreur : la commande '$cmd' n'existe pas!\n"
101
				$msg = "Erreur : la commande '$cmd' n'existe pas!\n"
96
						. ', utilisez plutôt :' . "\n"
102
						. ', utilisez plutôt :' . "\n"
97
						. 'php cli.php PullPlantnet -a updateLatest -startDate "YYYY:MM:DD HH:II:SS" [[-lifecycle [modified]/created/deleted]]' . "\n"
103
						. 'php cli.php PullPlantnet -a updateLatest -startDate "YYYY:MM:DD HH:II:SS" [[-lifecycle [modified]/created/deleted]]' . "\n"
98
						. 'php cli.php PullPlantnet -a updateOnePN -pnObsId "xxxxxx" -project "xxxxxx"' . "\n"
104
						. 'php cli.php PullPlantnet -a updateOnePN -pnObsId "1234567890" -project "xxxxxx"' . "\n"
99
						. 'php cli.php PullPlantnet -a updateOneTB -tbObsId "xxxxxx"' . "\n"
105
						. 'php cli.php PullPlantnet -a updateOneTB -tbObsId "1234567890"' . "\n"
100
						. 'php cli.php PullPlantnet -a updateCorrespondingIdsTable' . "\n"
106
						. 'php cli.php PullPlantnet -a updateCorrespondingIdsTable' . "\n"
Line 130... Line 136...
130
			$url_service = str_replace(
136
			$url_service = str_replace(
131
				['{project}', '{token}', '{startDate}', '{lifecycle}'],
137
				['{project}', '{token}', '{startDate}', '{lifecycle}'],
132
				[$project['id'], Config::get('tokenPlantnet'), $startDate, $lifecycle],
138
				[$project['id'], Config::get('tokenPlantnet'), $startDate, $lifecycle],
133
				Config::get('urlPlantnetBase').Config::get('urlPlantnetLatestChanges')
139
				Config::get('urlPlantnetBase').Config::get('urlPlantnetLatestChanges')
134
			);
140
			);
-
 
141
 
135
			// die(var_dump($url_service));
142
			$this->debug("URL service derniers changements : $url_service");
-
 
143
 
136
			$this->currentPage = $url_service;
144
			$this->currentPage = $url_service;
137
		}
145
		}
Line 138... Line 146...
138
 
146
 
139
		$ch = curl_init($this->currentPage);
147
		$ch = curl_init($this->currentPage);
Line 146... Line 154...
146
		if (!$reponse) {
154
		if (!$reponse) {
147
			throw new Exception("\nPN ne répond rien à l'adresse {$this->currentPage}\n");
155
			throw new Exception("\nPN ne répond rien à l'adresse {$this->currentPage}\n");
148
		} elseif (200 != $code) {
156
		} elseif (200 != $code) {
149
			// l'api répond avec une 404 quand y'a une date dans le futur ou simplement pas de nouvelle obs...
157
			// l'api répond avec une 404 quand y'a une date dans le futur ou simplement pas de nouvelle obs...
150
			if (404 == $code && strpos($reponse, 'No more results')) {
158
			if (404 == $code && strpos($reponse, 'No more results')) {
-
 
159
				$this->log("Pas d'autres résultats");
151
				$this->hasMore = false;
160
				$this->hasMore = false;
152
				$this->currentPage = '';
161
				$this->currentPage = '';
153
				return [];
162
				return [];
154
			}
163
			}
155
			throw new Exception("\nPN répond avec une $code à l'adresse {$this->currentPage} : $reponse\n");
164
			throw new Exception("\nPN répond avec une $code à l'adresse {$this->currentPage} : $reponse\n");
Line 157... Line 166...
157
		$responseJson = json_decode($reponse, true);
166
		$responseJson = json_decode($reponse, true);
158
		$observations_PN = $responseJson['data'] ?? [];
167
		$observations_PN = $responseJson['data'] ?? [];
Line 159... Line 168...
159
 
168
 
160
		$this->hasMore = $responseJson['hasMore'];
169
		$this->hasMore = $responseJson['hasMore'];
161
		if ($this->hasMore) {
-
 
162
			$this->count += count($observations_PN);
170
		if ($this->hasMore) {
-
 
171
			$this->currentPage = Config::get('urlPlantnetBase').$responseJson['next'];
163
			$this->currentPage = Config::get('urlPlantnetBase').$responseJson['next'];
172
			$this->debug("URL service derniers changements, page suivante : {$this->currentPage}");
164
		} else {
173
		} else {
165
			$this->currentPage = '';
-
 
166
			$this->count = 0;
174
			$this->currentPage = '';
Line 167... Line 175...
167
		}
175
		}
168
 
176
 
Line 169... Line 177...
169
		return $observations_PN;
177
		return $observations_PN;
170
	}
178
	}
171
 
179
 
Line -... Line 180...
-
 
180
	private function getProjects(): array {
-
 
181
		// get PN projects list
172
	private function getProjects(): array {
182
		$url = str_replace('{token}', Config::get('tokenPlantnet'), Config::get('urlPlantnetBase').Config::get('urlPlantnetProjects'));
173
		// get PN projects list
183
 
174
		$url = str_replace('{token}', Config::get('tokenPlantnet'), Config::get('urlPlantnetBase').Config::get('urlPlantnetProjects'));
184
		$this->debug("URL service liste projets : $url");
175
 
185
 
176
		$ch = curl_init($url);
186
		$ch = curl_init($url);
Line 184... Line 194...
184
		}
194
		}
185
		$pnProjects = json_decode($reponse, true);
195
		$pnProjects = json_decode($reponse, true);
Line 186... Line 196...
186
 
196
 
Line -... Line 197...
-
 
197
		echo 'Liste de projets récupérée : ' . count($pnProjects) . " projets dans la liste\n";
-
 
198
 
187
		echo 'Liste de projets récupérée : ' . count($pnProjects) . " projets dans la liste\n";
199
		$this->debug("Liste projets : " . json_encode($pnProjects));
188
 
200
 
Line 189... Line 201...
189
		return $pnProjects;
201
		return $pnProjects;
190
	}
202
	}
Line 197... Line 209...
197
		$url_cel_widget_saisie = Config::get('urlCelWidgetSaisie');
209
		$url_cel_widget_saisie = Config::get('urlCelWidgetSaisie');
Line 198... Line 210...
198
 
210
 
199
		foreach ($observations_PN as $obs) {
211
		foreach ($observations_PN as $obs) {
200
			// est-ce qu'on a déjà traité cette obs ? (oui une même obs peut être dans plusieurs projects)
212
			// est-ce qu'on a déjà traité cette obs ? (oui une même obs peut être dans plusieurs projects)
-
 
213
			if (in_array($obs['id'], $this->processedObsId)) {
201
			if (in_array($obs['id'], $this->processedObsId)) {
214
				$this->log("Obs {$obs['id']} déjà traitée pendant cette run");
202
				continue;
215
				continue;
203
			} else {
216
			} else {
-
 
217
				$this->processedObsId[] = $obs['id'];
204
				$this->processedObsId[] = $obs['id'];
218
				$this->log("Obs {$obs['id']} ajoutée à la liste de cette run");
Line 205... Line 219...
205
			}
219
			}
206
 
220
 
-
 
221
			// on ne teste pas la suppression de l'obs ici, faut le faire après avoir vérifié si on l'a déjà synchro
207
			// on ne teste pas la suppression de l'obs ici, faut le faire après avoir vérifié si on l'a déjà synchro
222
			if (!isset($obs['currentName'])) {
208
			if (!isset($obs['currentName'])) {
223
				$this->log("Obs {$obs['id']} sans nom de taxon, on zap");
209
				continue; // pas de nom de taxon, obs inutile
224
				continue; // pas de nom de taxon, obs inutile
-
 
225
			}
210
			}
226
			if (!isset($obs['geo'])) {
211
			if (!isset($obs['geo'])) {
227
				$this->log("Obs {$obs['id']} sans geom, on zap");
212
				continue; // pas de position, obs inutile
228
				continue; // pas de position, obs inutile
-
 
229
			}
213
			}
230
			if (!isset($obs['dateObs'])) {
214
			if (!isset($obs['dateObs'])) {
231
				$this->log("Obs {$obs['id']} sans date, on zap");
Line 215... Line 232...
215
				continue; // pas de date, obs inutile
232
				continue; // pas de date, obs inutile
216
			}
233
			}
217
 
234
 
218
			if (isset($obs['partner']['id']) && 'tela' === $obs['partner']['id']) {
235
			if (isset($obs['partner']['id']) && 'tela' === $obs['partner']['id']) {
219
				// c'est une obs tela
236
				// c'est une obs tela
Line 220... Line 237...
220
				// si c'est mis à jour récemment coté PN et qu'on l'a pas supprimée chez nous entre temps
237
				// si c'est mis à jour récemment coté PN et qu'on l'a pas supprimée chez nous entre temps
-
 
238
					// on update les votes PN
221
					// on update les votes PN
239
					// on update l'identification proposée par PN
222
					// on update l'identification proposée par PN
240
 
223
 
241
				// @TODO
224
				// @TODO
242
				$this->log("Obs {$obs['id']} venant de Tela, mise à jour pas implémentée, on zap");
225
				continue;
243
				continue;
226
			} elseif (!isset($obs['partner']['id'])) {
244
			} elseif (!isset($obs['partner']['id'])) {
227
				// ce n'est pas une obs d'un partenaire, c'est donc une obs PN
245
				// ce n'est pas une obs d'un partenaire, c'est donc une obs PN
-
 
246
				// on récupère l'id utilisateur tela via son mail
228
				// on récupère l'id utilisateur tela via son mail
247
				$email = $obs['author']['email'];
229
				$email = $obs['author']['email'];
248
				$infos_utilisateur = $this->findUserInfo($email);
230
				$infos_utilisateur = $this->findUserInfo($email);
249
				if (!$infos_utilisateur) {
231
				if (!$infos_utilisateur) {
250
					$this->log("Obs {$obs['id']} email $email ne provient pas d'un telabotaniste");
232
					continue; // c'est pas un telabotaniste
251
					continue; // c'est pas un telabotaniste
Line 233... Line 252...
233
				}
252
				}
234
				//echo "Synchro d'une obs d'un telabotaniste : $email";
253
				$this->log("Obs {$obs['id']} email $email provient d'un telabotaniste");
235
				// echo json_encode($obs);
254
				$this->log(json_encode($obs));
Line 252... Line 271...
252
					}
271
					}
253
					continue;
272
					continue;
254
				}
273
				}
Line 255... Line 274...
255
 
274
 
-
 
275
				if (isset($obs['deleted']) && (true === $obs['deleted'])) {
256
				if (isset($obs['deleted']) && (true === $obs['deleted'])) {
276
					$this->log("Obs {$obs['id']} supprimée coté PlantNet");
257
					continue; // obs supprimée chez PN sans être passée par nos serveurs
277
					continue; // obs supprimée chez PN sans être passée par nos serveurs
Line 258... Line 278...
258
				}
278
				}
259
 
279
 
260
				$images = [];
280
				$images = [];
261
				$tags_images = [];
281
				$tags_images = [];
262
				$images_size = 0;
282
				$images_size = 0;
-
 
283
				foreach ($obs['images'] ?? [] as $i => $image) {
263
				foreach ($obs['images'] ?? [] as $i => $image) {
284
					if ($image['deleted']) {
264
					if ($image['deleted']) {
285
						$this->log("Obs {$obs['id']} image {$image['id']} supprimée coté PlantNet");
Line 265... Line 286...
265
						continue;
286
						continue;
266
					}
287
					}
267
 
288
 
268
					// téléchargement de l'image PN
289
					// téléchargement de l'image PN
269
					$img = false;
290
					$img = false;
270
					$retry = 3;
291
					$retry = 3;
-
 
292
					do {
271
					do {
293
						$img = file_get_contents($image['o']);
Line 272... Line 294...
272
						$img = file_get_contents($image['o']);
294
						$retry--;
273
						$retry--;
295
						$this->log("Obs {$obs['id']} lecture image {$image['id']} tentatives restantes : $retry");
274
					} while (!$img && $retry);
296
					} while (!$img && $retry);
Line 283... Line 305...
283
					$handle = fopen($tempfile, "w");
305
					$handle = fopen($tempfile, "w");
284
					fwrite($handle, $img);
306
					fwrite($handle, $img);
285
					fclose($handle);
307
					fclose($handle);
286
					$images_size += filesize($tempfile);
308
					$images_size += filesize($tempfile);
Line 287... Line 309...
287
 
309
 
Line 288... Line 310...
288
					// echo "Image de " . number_format(filesize($tempfile), 0, ',', ' ') . " octets créé : $tempfile\n";
310
					$this->log("Obs {$obs['id']} image {$image['id']} créée " . number_format(filesize($tempfile), 0, ',', ' ') . " octets : $tempfile");
289
 
311
 
290
					$params = [
312
					$params = [
291
						'name' => 'image' . $i,
313
						'name' => 'image' . $i,
Line 296... Line 318...
296
					$ch = curl_init(Config::get('urlCelUploadImageTemp'));
318
					$ch = curl_init(Config::get('urlCelUploadImageTemp'));
297
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
319
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
298
					curl_setopt($ch, CURLOPT_POST, true);
320
					curl_setopt($ch, CURLOPT_POST, true);
299
					curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
321
					curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
300
					$reponse = curl_exec($ch);
322
					$reponse = curl_exec($ch);
301
					// var_dump($reponse);
323
					$this->log("Obs {$obs['id']} image {$image['id']} envoyée à l'api de création. Réponse : $reponse");
302
					$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
324
					$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
303
					curl_close($ch);
325
					curl_close($ch);
Line 304... Line 326...
304
 
326
 
Line 326... Line 348...
326
				}
348
				}
327
				// var_dump($images, $tags_images);
349
				// var_dump($images, $tags_images);
328
				// die();
350
				// die();
Line 329... Line 351...
329
 
351
 
-
 
352
				$geo = $this->getGeoInfo($obs['geo']);
-
 
353
				$this->log("Obs {$obs['id']} décodage du geom : " . json_encode($obs['geo']));
Line 330... Line 354...
330
				$geo = $this->getGeoInfo($obs['geo']);
354
				$this->log("Obs {$obs['id']} geom décodé : " . json_encode($geo));
331
 
355
 
332
				// on insère l'obs via le service CelWidgetSaisie
356
				// on insère l'obs via le service CelWidgetSaisie
333
				$infos_obs = [
357
				$infos_obs = [
Line 346... Line 370...
346
					'obsId1[certitude]' => 'douteux',
370
					'obsId1[certitude]' => 'douteux',
347
					// 'obsId1[notes]' => '',
371
					// 'obsId1[notes]' => '',
348
					// 'obsId1[num_nom_ret]' => '',
372
					// 'obsId1[num_nom_ret]' => '',
349
					// 'obsId1[num_nom_sel]' => '',
373
					// 'obsId1[num_nom_sel]' => '',
350
					// 'obsId1[num_taxon]' => '',
374
					// 'obsId1[num_taxon]' => '',
351
					'obsId1[referentiel]' => $this->findProbableTaxoRepos($this->currentProject['id']),
375
					'obsId1[referentiel]' => $this->findProbableTaxoRepos($this->currentProject['id']), // @TODO faire une fois et mettre en cache
352
					// 'obsId1[station]' => '',
376
					// 'obsId1[station]' => '',
353
					'obsId1[obs_id]' => $obs['id'],
377
					'obsId1[obs_id]' => $obs['id'],
354
					'projet' => 'PlantNet',
378
					'projet' => 'PlantNet',
355
					'tag-img' => implode(', ', $tags_images ?? []),
379
					'tag-img' => implode(', ', $tags_images ?? []),
356
					'tag-obs' => 'plantnet, plantnet-mobile, pn:referentiel-' . $this->currentProject['id'],
380
					'tag-obs' => 'plantnet, plantnet-mobile, pn:referentiel-' . $this->currentProject['id'],
Line 362... Line 386...
362
				];
386
				];
Line 363... Line 387...
363
 
387
 
364
				foreach ($images as $i => $image) {
388
				foreach ($images as $i => $image) {
365
					$infos_obs["obsId1[image_nom][$i]"] = $image;
389
					$infos_obs["obsId1[image_nom][$i]"] = $image;
-
 
390
				}
366
				}
391
 
Line 367... Line 392...
367
				// var_dump($infos_obs);
392
				$this->log("Obs {$obs['id']} prête à être insérée : " . json_encode($infos_obs));
368
 
393
 
369
				// curl post $infos_obs
394
				// curl post $infos_obs
370
				$ch = curl_init($url_cel_widget_saisie);
395
				$ch = curl_init($url_cel_widget_saisie);
371
				curl_setopt($ch, CURLOPT_POST, true);
396
				curl_setopt($ch, CURLOPT_POST, true);
372
				curl_setopt($ch, CURLOPT_POSTFIELDS, $infos_obs);
397
				curl_setopt($ch, CURLOPT_POSTFIELDS, $infos_obs);
-
 
398
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
373
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
399
				$reponse = curl_exec($ch);
374
				$reponse = curl_exec($ch);
400
				$this->log("Obs {$obs['id']} réponse de la requête d'insertion : " . json_encode($reponse));
Line 375... Line 401...
375
				$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
401
				$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
376
				curl_close($ch);
402
				curl_close($ch);
377
 
403
 
Line 378... Line -...
378
				if (!$reponse || 200 != $code) {
-
 
379
					throw new Exception("Ça a pété à l'envoi de l'obs :\n $reponse\n avec l'obs : " . json_encode($infos_obs) . "\n");
404
				if (!$reponse || 200 != $code) {
380
				}
405
					throw new Exception("Ça a pété à l'envoi de l'obs :\n $reponse\n avec l'obs : " . json_encode($infos_obs) . "\n");
381
 
406
				}
382
				// var_dump($reponse);
407
 
383
				$id_obs_tb = json_decode($reponse, true)['id'];
408
				$id_obs_tb = json_decode($reponse, true)['id'];
Line 390... Line 415...
390
				$this->bdd->requeter($sql);
415
				$this->bdd->requeter($sql);
Line 391... Line 416...
391
 
416
 
392
				$date = date('d/m/Y H:i:s', intdiv($obs['dateObs'], 1000));
417
				$date = date('d/m/Y H:i:s', intdiv($obs['dateObs'], 1000));
393
				$count_img = count($images);
418
				$count_img = count($images);
394
				$images_size = number_format($images_size, 0, ',', ' ');
419
				$images_size = number_format($images_size, 0, ',', ' ');
395
				echo "Obs insérée en base : ID PN $id_obs_pn ; ID TB $id_obs_tb ; utilisateur_tb $email ; date $date ; images $count_img ; taille_octets $images_size \n";
420
				echo "Obs insérée en base : ID PN $id_obs_pn ; ID TB $id_obs_tb ; utilisateur_tb $email ; date_obs $date ; images $count_img ; taille_octets $images_size \n";
396
			}
421
			}
397
		}
422
		}
Line 398... Line 423...
398
	}
423
	}
Line 751... Line 776...
751
		if (!file_put_contents($this->correspondingIdsFilename, $reponse)) {
776
		if (!file_put_contents($this->correspondingIdsFilename, $reponse)) {
752
			throw new Exception("\nError writing correspondingIdsFilename with path : " . $this->correspondingIdsFilename . "\n");
777
			throw new Exception("\nError writing correspondingIdsFilename with path : " . $this->correspondingIdsFilename . "\n");
753
		}
778
		}
754
		echo "Matching partners ids saved!";
779
		echo "Matching partners ids saved!";
755
	}
780
	}
-
 
781
 
-
 
782
	private function debug($text) {
-
 
783
		if ($this->debug) {
-
 
784
			echo 'DEBUG - ' . $text . "\n";
-
 
785
		}
-
 
786
	}
-
 
787
 
-
 
788
	private function log($text) {
-
 
789
		if ('log' == $this->debug) {
-
 
790
			echo 'LOG - ' . $text . "\n";
-
 
791
		}
-
 
792
	}
756
}
793
}
757
794