From ebbae37f009e3cd2d8a62f15ac2364ea47dce542 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 17 Jun 2020 20:06:46 +0200 Subject: [PATCH 1/5] Subpath and different corrections --- conf/nginx.conf | 45 ++++++++++++++++++++++----------------------- scripts/change_url | 34 ++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8328b41..bb48715 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,27 +1,26 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__ { -# Path to source -alias __FINALPATH__/www/ ; + # Path to source + alias __FINALPATH__/www/ ; -if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + index index.php /_route.php; + try_files $uri $uri/ index.php /_route.php; + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } - - # Example PHP configuration (remove if not used) - index index.php /_route.php; - try_files $uri $uri/ index.php /_route.php; - -location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; -} - # PHP configuration end - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; -} \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index 7244972..dfd11fe 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,27 +29,37 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# #================================================= -# # CHECK THE SYNTAX OF THE PATHS -# #================================================= +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 -# test -n "$old_path" || old_path="/" -# test -n "$new_path" || new_path="/" -# new_path=$(ynh_normalize_url_path $new_path) -# old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= change_domain=0 -if [ "$old_domain" != "$new_domain" ]; then - change_domain=1 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 fi change_path=0 -if [ "$old_path" != "$new_path" ]; then - change_path=1 +if [ "$old_path" != "$new_path" ] +then + change_path=1 fi #================================================= @@ -107,4 +117,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last \ No newline at end of file +ynh_script_progression --message="Change of URL completed for $app" --time --last From a7075ac9c81f2b619f84cc4ec98d11e74515a8a6 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 17 Jun 2020 20:46:32 +0200 Subject: [PATCH 2/5] Little correction --- scripts/change_url | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index dfd11fe..241aa1b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -69,7 +69,6 @@ fi #================================================= ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] From cbacd71a4456ea496625fe1e54644bc1b3129204 Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Mon, 1 Feb 2021 13:30:54 +0100 Subject: [PATCH 3/5] update app version 1.0.4 --- README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8a76b44..a029745 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview Garradin is a free association managing software. -**Shipped version:** 1.0.3 +**Shipped version:** 1.0.4 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 744cae9..21567a2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install ## Vue d'ensemble Garradin est un logiciel libre de gestion associative. il permet de gérer des membres. -**Version incluse :** 1.0.3 +**Version incluse :** 1.0.4 ## Captures d'écran diff --git a/conf/app.src b/conf/app.src index 00a5ed5..0f3f9ab 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-1.0.3.tar.bz2 -SOURCE_SUM=d8e414d4798dcf5036ca2a22fdf285d0934d353c47466758e1922b8f34806e10 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-1.0.4.tar.bz2 +SOURCE_SUM=dc5e0ef1365d7457d9eeb87fc8e089ccfe85421e4df67db5a9845d02fb1fc9ac SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 224081a..3931785 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "1.0.3~ynh2", + "version": "1.0.4~ynh1", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { From f5d1c6d4b4a08e462bab16ce78e831958965e2b6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 2 Feb 2021 11:42:25 +0100 Subject: [PATCH 4/5] add file to debug mismatch urls in version 1.0.4 --- conf/Utils.php | 921 ++++++++++++++++++++++++++++++++++++++++++++++++ conf/nginx.conf | 1 - scripts/install | 3 + scripts/upgrade | 3 + 4 files changed, 927 insertions(+), 1 deletion(-) create mode 100644 conf/Utils.php diff --git a/conf/Utils.php b/conf/Utils.php new file mode 100644 index 0000000..244cffa --- /dev/null +++ b/conf/Utils.php @@ -0,0 +1,921 @@ +'Janvier', 'February'=>'Février', 'March'=>'Mars', 'April'=>'Avril', 'May'=>'Mai', + 'June'=>'Juin', 'July'=>'Juillet', 'August'=>'Août', 'September'=>'Septembre', 'October'=>'Octobre', + 'November'=>'Novembre', 'December'=>'Décembre', 'Monday'=>'Lundi', 'Tuesday'=>'Mardi', 'Wednesday'=>'Mercredi', + 'Thursday'=>'Jeudi','Friday'=>'Vendredi','Saturday'=>'Samedi','Sunday'=>'Dimanche', + 'Feb'=>'Fév','Apr'=>'Avr','Jun'=>'Juin', 'Jul'=>'Juil','Aug'=>'Aout','Dec'=>'Déc', + 'Mon'=>'Lun','Tue'=>'Mar','Wed'=>'Mer','Thu'=>'Jeu','Fri'=>'Ven','Sat'=>'Sam','Sun'=>'Dim']; + + static public function get_datetime($ts) + { + if (is_object($ts) && $ts instanceof \DateTimeInterface) { + return $ts; + } + elseif (is_numeric($ts)) { + return new \DateTime('@' . $ts); + } + elseif (strlen($ts) == 10) { + return \DateTime::createFromFormat('!Y-m-d', $ts); + } + elseif (strlen($ts) == 19) { + return \DateTime::createFromFormat('Y-m-d H:i:s', $ts); + } + else { + return null; + } + } + + static public function strftime_fr($ts, $format) + { + $ts = self::get_datetime($ts); + + if (null === $ts) { + return $ts; + } + + $date = strftime($format, $ts->getTimestamp()); + + $date = strtr($date, self::FRENCH_DATE_NAMES); + $date = strtolower($date); + return $date; + } + + static public function date_fr($ts, $format = null) + { + $ts = self::get_datetime($ts); + + if (null === $ts) { + return $ts; + } + + if (is_null($format)) + { + $format = 'd/m/Y à H:i'; + } + + $date = $ts->format($format); + + $date = strtr($date, self::FRENCH_DATE_NAMES); + $date = strtolower($date); + return $date; + } + + /** + * @deprecated + */ + static public function checkDate($str) + { + if (!preg_match('!^(\d{4})-(\d{2})-(\d{2})$!', $str, $match)) + return false; + + if (!checkdate($match[2], $match[3], $match[1])) + return false; + + return true; + } + + /** + * @deprecated + */ + static public function checkDateTime($str) + { + if (!preg_match('!^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})!', $str, $match)) + return false; + + if (!self::checkDate($match[1])) + return false; + + if ((int) $match[2] < 0 || (int) $match[2] > 23) + return false; + + if ((int) $match[3] < 0 || (int) $match[3] > 59) + return false; + + if (isset($match[4]) && ((int) $match[4] < 0 || (int) $match[4] > 59)) + return false; + + return true; + } + + static public function moneyToInteger($value) + { + if (trim($value) === '') { + return 0; + } + + if (!preg_match('/^-?(\d+)(?:[,.](\d{1,2}))?$/', $value, $match)) { + throw new UserException(sprintf('Le montant est invalide : %s. Exemple de format accepté : 142,02', $value)); + } + + $value = $match[1] . str_pad(@$match[2], 2, '0', STR_PAD_RIGHT); + $value = (int) $value; + return $value; + } + + static public function money_format($number, string $dec_point = ',', string $thousands_sep = ' ', $zero_if_empty = true): string { + if ($number == 0) { + return $zero_if_empty ? '0' : '0,00'; + } + + $sign = $number < 0 ? '-' : ''; + $number = abs((int) $number); + + $decimals = substr('0' . $number, -2); + $number = (int) substr($number, 0, -2); + + return sprintf('%s%s%s%s', $sign, number_format($number, 0, $dec_point, $thousands_sep), $dec_point, $decimals); + } + + static public function getLocalURL(string $url = '', ?string $default_prefix = null): string + { + if ($url[0] == '!') { + return ADMIN_URL . substr($url, 1); + } + elseif ($url[0] == '/' && ($pos = strpos($url, WWW_URI)) === 0) { + return WWW_URL . substr($url, strlen(WWW_URI)); + } + elseif (substr($url, 0, 5) == 'http:' || substr($url, 0, 6) == 'https:') { + return $url; + } + elseif ($url == '') { + return ADMIN_URL; + } + else { + if (null !== $default_prefix) { + $default_prefix = self::getLocalURL($default_prefix); + } + + return $default_prefix . $url; + } + } + + static public function getRequestURI() + { + if (!empty($_SERVER['REQUEST_URI'])) + return $_SERVER['REQUEST_URI']; + else + return false; + } + + static public function getSelfURL($qs = true) + { + $uri = self::getSelfURI($qs); + + // Make absolute URI relative to parent URI + if (strpos($uri, WWW_URI . 'admin/') === 0) + { + $uri = substr($uri, strlen(WWW_URI . 'admin/')); + } + + return ADMIN_URL . $uri; + } + + static public function getSelfURI($qs = true) + { + $uri = self::getRequestURI(); + + if ($qs !== true && (strpos($uri, '?') !== false)) + { + $uri = substr($uri, 0, strpos($uri, '?')); + } + + if (is_array($qs)) + { + $uri .= '?' . http_build_query($qs); + } + + return $uri; + } + + static public function getModifiedURL(string $new) + { + return HTTP::mergeURLs(self::getSelfURL(), $new); + } + + public static function redirect($destination=false, $exit=true) + { + $destination = self::getLocalURL($destination); + + if (PHP_SAPI == 'cli') { + echo 'Please visit ' . $destination . PHP_EOL; + exit; + } + + if (headers_sent()) + { + echo + ''. + ' ' . + ' ' . + ' '. + ' '. + '
'. + ' Cliquez ici pour continuer...'. + '
'. + ' '. + ''; + + if ($exit) + exit(); + + return true; + } + + header("Location: " . $destination); + + if ($exit) + exit(); + } + + static public function getIP() + { + if (!empty($_SERVER['REMOTE_ADDR'])) + return $_SERVER['REMOTE_ADDR']; + return ''; + } + + static public function getCountryList() + { + return Translate::getCountriesList('fr'); + } + + static public function getCountryName($code) + { + $list = self::getCountryList(); + + if (!isset($list[$code])) + return false; + + return $list[$code]; + } + + /** + * Génération pagination à partir de la page courante ($current), + * du nombre d'items total ($total), et du nombre d'items par page ($bypage). + * $listLength représente la longueur d'items de la pagination à génerer + * + * @param int $current + * @param int $total + * @param int $bypage + * @param int $listLength + * @param bool $showLast Toggle l'affichage du dernier élément de la pagination + * @return array|null + */ + public static function getGenericPagination($current, $total, $bypage, $listLength=11, $showLast = true) + { + if ($total <= $bypage) + return null; + + $total = ceil($total / $bypage); + + if ($total < $current) + return null; + + $length = ($listLength / 2); + + $begin = $current - ceil($length); + if ($begin < 1) + { + $begin = 1; + } + + $end = $begin + $listLength; + if($end > $total) + { + $begin -= ($end - $total); + $end = $total; + } + if ($begin < 1) + { + $begin = 1; + } + if($end==($total-1)) { + $end = $total; + } + if($begin == 2) { + $begin = 1; + } + $out = []; + + if ($current > 1) { + $out[] = ['id' => $current - 1, 'label' => '« ' . 'Page précédente', 'class' => 'prev', 'accesskey' => 'a']; + } + + if ($begin > 1) { + $out[] = ['id' => 1, 'label' => '1 ...', 'class' => 'first']; + } + + for ($i = $begin; $i <= $end; $i++) + { + $out[] = ['id' => $i, 'label' => $i, 'class' => ($i == $current) ? 'current' : '']; + } + + if ($showLast && $end < $total) { + $out[] = ['id' => $total, 'label' => '... ' . $total, 'class' => 'last']; + } + + if ($current < $total) { + $out[] = ['id' => $current + 1, 'label' => 'Page suivante' . ' »', 'class' => 'next', 'accesskey' => 'z']; + } + + return $out; + } + + static public function transliterateToAscii($str, $charset='UTF-8') + { + // Don't process empty strings + if (!trim($str)) + return $str; + + // We only process non-ascii strings + if (preg_match('!^[[:ascii:]]+$!', $str)) + return $str; + + $str = htmlentities($str, ENT_NOQUOTES, $charset); + + $str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str); + $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ' + + $str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères + $str = preg_replace('![^[:ascii:]]+!', '', $str); + + return $str; + } + + /** + * Transforme un texte SkrivML en HTML + * @param string $str Texte SkrivML + * @return string Texte HTML + */ + static public function SkrivToHTML($str) + { + if (!self::$skriv) + { + self::$skriv = new \KD2\SkrivLite; + self::$skriv->registerExtension('fichier', ['\\Garradin\\Fichiers', 'SkrivFichier']); + self::$skriv->registerExtension('image', ['\\Garradin\\Fichiers', 'SkrivImage']); + + // Enregistrer d'autres extensions éventuellement + Plugin::fireSignal('skriv.init', ['skriv' => self::$skriv]); + } + + $skriv =& self::$skriv; + + $str = preg_replace_callback('/(fichier|image):\/\/(\d+)/', function ($match) use ($skriv) { + try { + $file = new Fichiers((int)$match[2]); + } + catch (\InvalidArgumentException $e) + { + return $skriv->parseError('/!\ Lien fichier : ' . $e->getMessage()); + } + + return $file->getURL(); + }, $str); + + $str = self::$skriv->render($str); + + return $str; + } + + /** + * Transforme les tags de base SPIP en tags SkrivML + * @param string $str Texte d'entrée + * @return string Texte transformé + */ + static public function SpipToSkriv($str) + { + $str = preg_replace('/(?(.+?)\]/', '[[$1 | $2]]', $str); + $str = preg_replace('/(?(\V*?)<\/h3>/', '=== $1 ===', $str); + $str = preg_replace('/(\V*)<\/b>/', '**$1**', $str); + $str = preg_replace('/(\V*?)<\/strong>/', '**$1**', $str); + $str = preg_replace('/(\V*?)<\/i>/', '\'\'$1\'\'', $str); + $str = preg_replace('/(\V*?)<\/em>/', '\'\'$1\'\'', $str); + $str = preg_replace('/
  • (\V*?)<\/li>/', '* $1', $str); + $str = preg_replace('/