From ca8ce13359d577b1bb05adce4d1c13ecbc24b1b1 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 25 Aug 2023 13:41:31 +0000 Subject: [PATCH] wip #6219 @2 --- .docker/docker-compose.yml | 8 ++--- .docker/images/php/startup | 8 +++++ bin/fixrights | 1 - inc/ws/Controlleur/class.ws.maintenance.php | 2 +- inc/ws/Controlleur/class.ws.stats.php | 33 ++++++++++----------- inc/ws/DAO/class.ws.dao.book.php | 2 +- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 5f5ca73c2..7d20cca13 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -27,7 +27,6 @@ services: - '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache' - '/home/toolbox/www:/home/toolbox/www' - '/data/toolbox/:/data/toolbox/' - - '/home/stats/www:/home/stats/www' - '/home/wesco:/home/wesco' # Config - '/home/extranet/.docker/config/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf' @@ -67,7 +66,6 @@ services: - '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache' - '/home/toolbox/www:/home/toolbox/www' - '/data/toolbox/:/data/toolbox/' - - '/home/stats/www:/home/stats/www' - '/home/wesco:/home/wesco' # Config - '/home/extranet/.docker/config/httpd/httpd-nb.conf:/usr/local/apache2/conf/httpd.conf' @@ -114,7 +112,6 @@ services: # PHP - '/home/extranet/.docker/config/php.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini' - '/home/extranet/sessions/:/var/lib/php/sessions/' - - '/usr/share/GeoIP/GeoIP.dat:/home/stats/www/GeoIP.dat' # Crontab - '/home/extranet/.docker/config/cron/crontab:/etc/crontab' # Passwords @@ -143,7 +140,6 @@ services: - '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache' - '/home/toolbox/www:/home/toolbox/www' - '/data/toolbox/:/data/toolbox/' - - '/home/stats/www:/home/stats/www' - '/home/wesco:/home/wesco' tmpfs: #- '/tmp:mode=777,uid=1002,gid=33' @@ -160,6 +156,9 @@ services: options: max-size: 10M max-file: 10 + privileged: true + cap_add: + - SYS_ADMIN redis: container_name: extranet-redis @@ -169,6 +168,7 @@ services: networks: - extranet restart: unless-stopped + networks: extranet: external: diff --git a/.docker/images/php/startup b/.docker/images/php/startup index c82563a12..18f547b6d 100644 --- a/.docker/images/php/startup +++ b/.docker/images/php/startup @@ -12,6 +12,14 @@ chmod 0644 /etc/crontab && crontab -u root /etc/crontab && /usr/sbin/service cro # Set user passwords chpasswd < /root/passwords +# Mount stats +mkdir -p /stats +if mountpoint -q "/stats"; then + : +else + sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1002 -o gid=33 -o allow_other stats@dracula.cubedesigners.com:/docker/fluidbook-stats/www /stats +fi + # Launch monit chmod -R 700 /etc/monit;chown -R root:root /etc/monit;/usr/bin/monit sudo chmod -R 777 /etc/monit diff --git a/bin/fixrights b/bin/fixrights index eaba77713..2750f8b21 100644 --- a/bin/fixrights +++ b/bin/fixrights @@ -22,5 +22,4 @@ chmod -R 775 /data/extranet chmod -R 777 /home/extranet/share chmod -R 777 /home/extranet/www/fluidbook/packager/ chmod -R 777 /home/toolbox/www/resources/fluidbookpublication/player -chmod -R 777 /home/stats/www chmod -R 775 /data/extranet/www/fluidbook/books/working diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 736ddce84..ab01c3bb1 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1056,7 +1056,7 @@ class wsMaintenance return false; } - $cmd = "rm -rf /home/stats/www/objects/$book*;/home/stats/www/FWStats.sh /home/stats/www redobook=$book"; + $cmd = "rm -rf /stats/objects/$book*;/stats/FWStats.sh /stats redobook=$book"; `$cmd`; } diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index b40ed1460..60272c30b 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -35,10 +35,12 @@ class wsStats protected static function _getXLSFile($bid, $annee = null, $mois = null) { - self::forceComputation($bid); + if (rand(1, 50) == 20) { + self::forceComputation($bid); + } $e = explode('_', $bid); $bid = $e[0]; - $xname = '/home/stats/www/xls/' . $bid; + $xname = '/stats/xls/' . $bid; if (!is_null($annee)) { $xname .= '/' . $annee; if (!is_null($mois)) { @@ -60,7 +62,9 @@ class wsStats { global $core; - self::forceComputation($bid); + if (rand(1, 50) == 20) { + self::forceComputation($bid); + } cubePHP::set_memory('12G'); @@ -572,7 +576,8 @@ class wsStats $title = ''; $colsTitles = array(__('Période'), /*__('Lieux de visite'),*/ - /*__('Visiteurs uniques'),*/ __('Visites'), __('Pages vues')); + /*__('Visiteurs uniques'),*/ + __('Visites'), __('Pages vues')); if ($afriend) { $colsTitles[] = __('Liens envoyés'); } @@ -689,7 +694,8 @@ class wsStats public static function detailJour($book, $annee, $mois, $stats) { $colsTitles = array(__('Jour'), /*__('Lieux de visite'),*/ - /*__('Visiteurs uniques'),*/ __('Visites'), __('Pages vues'), __('Liens cliqués')); + /*__('Visiteurs uniques'),*/ + __('Visites'), __('Pages vues'), __('Liens cliqués')); $lines = array(); $xlines = array(); @@ -923,7 +929,7 @@ class wsStats } $res = '
' . $maxpages . '
'; $res .= '
' . $maxb . '
'; - // $res .= '
' . $maxv . '
'; + // $res .= '
' . $maxv . '
'; $res .= '
'; $res .= ''; foreach ($months as $m => $t) { @@ -1038,7 +1044,7 @@ class wsStats $res .= '
'; $res .= ''; $res .= ''; - // $res .= ''; + // $res .= ''; $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '' . __('Visiteurs uniques') . '
'; return $res; } @@ -1127,7 +1133,7 @@ class wsStats } $res = '
' . $maxpages . '
'; $res .= '
' . $maxb . '
'; - // $res .= '
' . $maxv . '
'; + // $res .= '
' . $maxv . '
'; $res .= '
'; $res .= ''; foreach ($days as $d => $t) { @@ -1139,20 +1145,13 @@ class wsStats $res .= '
'; $res .= ''; $res .= ''; - // $res .= ''; + // $res .= ''; $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '' . __('Visiteurs uniques') . '
'; return $res; } public static function forceComputation($id) { - `/home/stats/www/FWStats.sh /home/stats/www onlybook=$id`; - } - - /** - * @return \Cubist\Matomo\Reporting - */ - public static function getMatomoAPI(){ - return new \Cubist\Matomo\Reporting('https://v3.stats.fluidbook.com/','ebe362f44c01bda1ddedb75d7726ff78'); + `/stats/FWStats.sh /stats onlybook=$id`; } } \ No newline at end of file diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 1e8c03037..16abbe7b1 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -734,7 +734,7 @@ class wsDAOBook extends commonDAO } } - $file = '/home/stats/www/exclude/' . $book_id; + $file = '/stats/exclude/' . $book_id; if (count($ip)) { file_put_contents($file, implode(',', $ip)); -- 2.39.5