public function getVersion($package, $full = false) { $version = Versions::getVersion($package); return $full ? $version : strstr($version, '@', true); }
echo '~~~ Load all UAs ~~~' . PHP_EOL; $files = ['browscap.php', 'donatj.php', 'jenssegers-agent.php', 'mobile-detect.php', 'piwik.php', 'sinergi.php', 'uap-core.php', 'whichbrowser.php', 'woothee.php', 'zsxsoft.php']; foreach ($files as $file) { if (strpos($file, '.php') === false) { continue; } echo $file . PHP_EOL; $result = (include 'data/datasets/' . $file); if (!isset($result['provider']) || !isset($result['userAgents']) || !is_array($result['userAgents'])) { throw new \Exception('Result is not valid! ' . $file); } /* * save provider */ $provider = $result['provider']; $version = \PackageVersions\Versions::getVersion($provider['proPackageName']); $version = explode('@', $version); $version = $version[0]; $provider['proVersion'] = $version; $sql = "\n SELECT\n *\n FROM provider\n WHERE\n proType = '" . $provider['proType'] . "'\n AND proName = '" . $provider['proName'] . "'\n "; $dbResult = $conn->fetchAll($sql); if (count($dbResult) === 1) { // update! $proId = $dbResult[0]['proId']; $conn->update('provider', $provider, ['proId' => $dbResult[0]['proId']]); echo 'U'; } else { $proId = Uuid::uuid4()->toString(); $provider['proId'] = $proId; $conn->insert('provider', $provider); echo 'I';