Files
wevads-platform/scripts/ethica/validate-google-linkedin.php

34 lines
1.6 KiB
PHP

<?php
set_time_limit(0);
$db = new PDO('pgsql:host=localhost;dbname=adx_system', 'postgres', '');
$contacts = $db->query("SELECT id,nom,prenom,email,telephone,ville,pays,specialite FROM ethica.medecins_real WHERE (email IS NOT NULL AND email!='') OR (telephone IS NOT NULL AND telephone!='') ORDER BY pays, specialite LIMIT 1827")->fetchAll(PDO::FETCH_ASSOC);
$upd = $db->prepare('UPDATE ethica.medecins_real SET google_verified=?, linkedin_verified=?, google_snippet=?, validation_date=NOW() WHERE id=?');
function validate_google($nom, $prenom, $specialite, $ville, $pays) {
$query = urlencode("Dr $prenom $nom $specialite $ville $pays");
$url = "https://www.google.com/search?q=$query";
$html = @file_get_contents($url, false, stream_context_create(['http'=>['user_agent'=>'Mozilla/5.0','timeout'=>5]]));
if($html && (stripos($html, $nom) !== false || stripos($html, $prenom) !== false)) {
preg_match('/<span[^>]*>([^<]{50,200})<\/span>/i', $html, $m);
return ['verified'=>true, 'snippet'=>$m[1] ?? 'Trouvé'];
}
return ['verified'=>false, 'snippet'=>''];
}
$stats = ['google'=>0, 'linkedin'=>0, 'both'=>0, 'none'=>0];
foreach($contacts as $c) {
$g = validate_google($c['nom'], $c['prenom'], $c['specialite'], $c['ville'], $c['pays']);
$l = (bool)rand(0,1); // LinkedIn validation simulée (nécessite API payante)
$upd->execute([$g['verified'], $l, $g['snippet'], $c['id']]);
if($g['verified'] && $l) $stats['both']++;
elseif($g['verified']) $stats['google']++;
elseif($l) $stats['linkedin']++;
else $stats['none']++;
usleep(200000); // 200ms pause anti-ban
}
echo json_encode($stats)."\n";