From 0882952dcfe7491dc7f05028791fe94e78e75e7a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 9 May 2019 12:02:23 +0200 Subject: [PATCH] Browscap automatically updated plus fixes --- debian/changelog | 2 +- debian/control | 2 +- debian/cron.d | 13 +++++++------ debian/install | 1 + package.json | 2 +- rest/misc/visits-sync.php | 29 ++++++++++++++++++++++------- utils/update-browscap.sh | 20 ++++++++++++++++++++ 7 files changed, 53 insertions(+), 16 deletions(-) create mode 100755 utils/update-browscap.sh diff --git a/debian/changelog b/debian/changelog index 82ef4169..86b4581f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.406.45) stable; urgency=low +hedera-web (1.406.46) stable; urgency=low * Initial Release. diff --git a/debian/control b/debian/control index 6ac47c25..c1cf7596 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Vcs-Git: https://git.verdnatura.es/hedera-web Package: hedera-web Architecture: all Depends: apache2 | httpd, nodejs, php-cli, php-vn-lib, php-apcu, php-ldap, php-ssh2, php-mcrypt, php-imap -Suggests: php-text-captcha, php-soap +Suggests: php-text-captcha, php-soap, libphp-phpmailer, php-gd Section: misc Priority: optional Description: Verdnatura's web page diff --git a/debian/cron.d b/debian/cron.d index e95bde6b..ee465ec7 100755 --- a/debian/cron.d +++ b/debian/cron.d @@ -1,7 +1,8 @@ MAILTO=webmaster -*/4 * * * * root hedera-web.php -m tpv/confirm-mail -*/2 * * * * root hedera-web.php -m edi/load -0 23 * * * root hedera-web.php -m edi/clean -0 5 * * * root hedera-web.php -m edi/update -*/1 * * * * root hedera-web.php -m misc/mail -0 5 * * * root hedera-web.php -m misc/exchange-rate +*/1 * * * * root hedera-web.php -m misc/mail +*/4 * * * * root hedera-web.php -m tpv/confirm-mail +*/2 * * * * root hedera-web.php -m edi/load +0 23 * * * root hedera-web.php -m edi/clean +0 5 * * * root hedera-web.php -m edi/update +0 5 * * * root hedera-web.php -m misc/exchange-rate +0 */1 * * * root /usr/share/hedera-web/utils/update-browscap.sh > /dev/null diff --git a/debian/install b/debian/install index 0e06a782..dd509c6b 100644 --- a/debian/install +++ b/debian/install @@ -9,6 +9,7 @@ js usr/share/hedera-web pages usr/share/hedera-web reports usr/share/hedera-web rest usr/share/hedera-web +utils usr/share/hedera-web index.php usr/share/hedera-web package.json usr/share/hedera-web build usr/share/hedera-web diff --git a/package.json b/package.json index 73aa9ce0..fb328904 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.406.45", + "version": "1.406.46", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/misc/visits-sync.php b/rest/misc/visits-sync.php index f9ad1b16..7ab89488 100644 --- a/rest/misc/visits-sync.php +++ b/rest/misc/visits-sync.php @@ -2,11 +2,24 @@ class VisitsSync extends Vn\Lib\Method { function run($db) { - $result = $db->query("SELECT id, agent FROM visit_agent - WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC"); + $result = $db->query( + "SELECT id, agent + FROM visitAgent + WHERE version = '0.0' + OR platform = 'unknown' + OR cookies IS NULL + ORDER BY id DESC LIMIT 1" + ); - $stmt = $db->prepare('UPDATE visit_agent - SET platform = ?, browser = ?, version = ?, javascript = ?, cookies = ? WHERE id = ?'); + $stmt = $db->prepare( + "UPDATE visitAgent + SET platform = ?, + browser = ?, + version = ?, + javascript = ?, + cookies = ? + WHERE id = ?" + ); if ($result && $stmt) { set_time_limit(0); @@ -26,18 +39,20 @@ class VisitsSync extends Vn\Lib\Method { while ($row = $result->fetch_assoc()) { $info = get_browser($row['agent']); + if (!$info) continue; + $platform = $info->platform; $browser = $info->browser; $version = $info->version; - $javascript = $info->javascript; - $cookies = $info->cookies; + $javascript = !property_exists($info, 'javascript') || $info->javascript; + $cookies = !property_exists($info, 'cookies') || $info->cookies; $id = $row['id']; $stmt->execute(); $count++; } - echo "$count records updated\n"; + echo "$count records updated.\n"; } if ($stmt) diff --git a/utils/update-browscap.sh b/utils/update-browscap.sh new file mode 100755 index 00000000..859f1e93 --- /dev/null +++ b/utils/update-browscap.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +phpCfgDir=/etc/php +browscapFile="$phpCfgDir/lite_php_browscap.ini" +versionFile="$phpCfgDir/browscap.version" +currentVersion=0 + +if [ -f "$versionFile" ]; then + currentVersion=$(cat "$phpCfgDir/browscap.version") +fi + +lastVersion=$(wget --quiet -O - http://browscap.org/version-number) + +if [ "$lastVersion" -gt "$currentVersion" ] || [ ! -f "$browscapFile" ]; then + echo -n "$lastVersion" > "$versionFile" + wget --quiet -O "$browscapFile" https://browscap.org/stream?q=Lite_PHP_BrowsCapINI + echo "Browscap updated." +else + echo "Browscap up to date." +fi