Browscap automatically updated plus fixes

This commit is contained in:
Juan Ferrer 2019-05-09 12:02:23 +02:00
parent 94590ac50a
commit 0882952dcf
7 changed files with 53 additions and 16 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.406.45) stable; urgency=low hedera-web (1.406.46) stable; urgency=low
* Initial Release. * Initial Release.

2
debian/control vendored
View File

@ -10,7 +10,7 @@ Vcs-Git: https://git.verdnatura.es/hedera-web
Package: hedera-web Package: hedera-web
Architecture: all Architecture: all
Depends: apache2 | httpd, nodejs, php-cli, php-vn-lib, php-apcu, php-ldap, php-ssh2, php-mcrypt, php-imap 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 Section: misc
Priority: optional Priority: optional
Description: Verdnatura's web page Description: Verdnatura's web page

13
debian/cron.d vendored
View File

@ -1,7 +1,8 @@
MAILTO=webmaster MAILTO=webmaster
*/4 * * * * root hedera-web.php -m tpv/confirm-mail */1 * * * * root hedera-web.php -m misc/mail
*/2 * * * * root hedera-web.php -m edi/load */4 * * * * root hedera-web.php -m tpv/confirm-mail
0 23 * * * root hedera-web.php -m edi/clean */2 * * * * root hedera-web.php -m edi/load
0 5 * * * root hedera-web.php -m edi/update 0 23 * * * root hedera-web.php -m edi/clean
*/1 * * * * root hedera-web.php -m misc/mail 0 5 * * * root hedera-web.php -m edi/update
0 5 * * * root hedera-web.php -m misc/exchange-rate 0 5 * * * root hedera-web.php -m misc/exchange-rate
0 */1 * * * root /usr/share/hedera-web/utils/update-browscap.sh > /dev/null

1
debian/install vendored
View File

@ -9,6 +9,7 @@ js usr/share/hedera-web
pages usr/share/hedera-web pages usr/share/hedera-web
reports usr/share/hedera-web reports usr/share/hedera-web
rest usr/share/hedera-web rest usr/share/hedera-web
utils usr/share/hedera-web
index.php usr/share/hedera-web index.php usr/share/hedera-web
package.json usr/share/hedera-web package.json usr/share/hedera-web
build usr/share/hedera-web build usr/share/hedera-web

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "1.406.45", "version": "1.406.46",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {

View File

@ -2,11 +2,24 @@
class VisitsSync extends Vn\Lib\Method { class VisitsSync extends Vn\Lib\Method {
function run($db) { function run($db) {
$result = $db->query("SELECT id, agent FROM visit_agent $result = $db->query(
WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC"); "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 $stmt = $db->prepare(
SET platform = ?, browser = ?, version = ?, javascript = ?, cookies = ? WHERE id = ?'); "UPDATE visitAgent
SET platform = ?,
browser = ?,
version = ?,
javascript = ?,
cookies = ?
WHERE id = ?"
);
if ($result && $stmt) { if ($result && $stmt) {
set_time_limit(0); set_time_limit(0);
@ -26,18 +39,20 @@ class VisitsSync extends Vn\Lib\Method {
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$info = get_browser($row['agent']); $info = get_browser($row['agent']);
if (!$info) continue;
$platform = $info->platform; $platform = $info->platform;
$browser = $info->browser; $browser = $info->browser;
$version = $info->version; $version = $info->version;
$javascript = $info->javascript; $javascript = !property_exists($info, 'javascript') || $info->javascript;
$cookies = $info->cookies; $cookies = !property_exists($info, 'cookies') || $info->cookies;
$id = $row['id']; $id = $row['id'];
$stmt->execute(); $stmt->execute();
$count++; $count++;
} }
echo "$count records updated\n"; echo "$count records updated.\n";
} }
if ($stmt) if ($stmt)

20
utils/update-browscap.sh Executable file
View File

@ -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