From efd79d42f3a6b4fdd01b5c4c6cf81606e0de03c4 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 23 Nov 2020 14:15:07 +0100 Subject: [PATCH 01/11] delete useless location in nginx.conf --- conf/nginx.conf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a26d0a0..39a7d56 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,19 +8,7 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - location ~ 403 { - rewrite ^(.*)$ /include/ redirect; - rewrite ^(.*)$ /cache/ redirect; - rewrite ^(.*)$ /plugins/ redirect; - rewrite ^(.*)$ /templates/ redirect; - rewrite ^(.*)$ /.*.sqlite redirect; - rewrite ^(.*)$ /.*.log redirect; - rewrite ^(.*)$ /(README|VERSION|COPYING) redirect; - rewrite ^(.*)$ /config\.(.*)\.php redirect; - } - index index.php /_route.php; - try_files $uri $uri/ __PATH__/__PATH__/_route.php?$query_string; location ~ \.php$ { From c2ea6d0f82fef9c4b5fff9ea828a6608451de290 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 23 Nov 2020 14:30:31 +0100 Subject: [PATCH 02/11] delete useless location in nginx.conf --- pull_request_template.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 9df1757..60751f2 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,18 +1,14 @@ ## Problem -- *Upgrade of the application to v0.9.8.1 resolves some issues* -- *Adding links in the public page made issues due to the nginx.conf* -- *Protect somes links vilnerables for security* +- *Useless redirection in nginx.conf* ## Solution -- *I do the necessary to upgrade the application to the new sources* -- *@ericg found the solution to add in the nginx.conf* -- *Redirections to 403 on the nginx.conf for sensibles urls* +- *Delete redirections to 403 on the nginx.conf for sensibles urls* ## PR Status -- [x] Code finished. -- [x] Tested with Package_check. +- [ ] Code finished. +- [ ] Tested with Package_check. - [x] Fix or enhancement tested. -- [x] Upgrade from last version tested. +- [ ] Upgrade from last version tested. - [x] Can be reviewed and tested. ## Package_check results From b969395ca39eb8914716de93f873b74545ab01e4 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 23 Nov 2020 14:35:55 +0100 Subject: [PATCH 03/11] keep template PR as origin --- pull_request_template.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 60751f2..081b7c5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,15 +1,14 @@ ## Problem -- *Useless redirection in nginx.conf* - +- *Description of why you made this PR* ## Solution -- *Delete redirections to 403 on the nginx.conf for sensibles urls* +- *And how do you fix that problem* ## PR Status - [ ] Code finished. - [ ] Tested with Package_check. -- [x] Fix or enhancement tested. +- [ ] Fix or enhancement tested. - [ ] Upgrade from last version tested. -- [x] Can be reviewed and tested. +- [ ] Can be reviewed and tested. ## Package_check results --- From 57f4d9e417c73746465ee6ee51be8655270f0fde Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 23 Nov 2020 14:38:13 +0100 Subject: [PATCH 04/11] keep template PR as origin --- pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pull_request_template.md b/pull_request_template.md index 081b7c5..2db70f4 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,5 +1,6 @@ ## Problem - *Description of why you made this PR* + ## Solution - *And how do you fix that problem* From 5476126c22b8c458debfd5fb734d23c1141f51a1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 23 Nov 2020 15:58:15 +0100 Subject: [PATCH 05/11] Small Fixes --- scripts/change_url | 8 ++++---- scripts/install | 6 +++--- scripts/remove | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 8121108..efe3a6b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -58,12 +58,12 @@ final_path=/var/www/$app # Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi @@ -76,7 +76,7 @@ else [ $change_path -eq 1 ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ]; then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" diff --git a/scripts/install b/scripts/install index 8f26d71..65582d4 100644 --- a/scripts/install +++ b/scripts/install @@ -33,7 +33,7 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax +# Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) # Check web path availability @@ -71,7 +71,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -80,7 +80,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=5 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= diff --git a/scripts/remove b/scripts/remove index be524b0..7780ced 100644 --- a/scripts/remove +++ b/scripts/remove @@ -32,7 +32,7 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= @@ -40,7 +40,7 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config --package="$extra_php_dependencies" #================================================= diff --git a/scripts/restore b/scripts/restore index f23b8ad..5d3be8e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -76,7 +76,7 @@ ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=6 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 8d86efd..34f12fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -123,7 +123,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #======================================================= # backup bdd, squelettes directory and config.local.php From fb700f9039924672cb77f1da40834e5415fd5a7a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 23 Nov 2020 22:47:28 +0100 Subject: [PATCH 06/11] remove a trail --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 39a7d56..9ad0765 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - + # Path to source alias __FINALPATH__/www/ ; From 791a8eae72f0c3359430029380fc35992252a071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 6 Jan 2021 17:55:46 +0100 Subject: [PATCH 07/11] Set badge to SVG --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac562df..57ecc05 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Garradin for YunoHost [![Integration level](https://dash.yunohost.org/integration/garradin.svg)](https://dash.yunohost.org/appci/app/garradin) ![](https://ci-apps.yunohost.org/ci/badges/garradin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/garradin.maintain.svg) -[![Install Garradin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=garradin) +[![Install Garradin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=garradin) *[Lire ce readme en français.](./README_fr.md)* From 5a1842b2ef0effdfa622093ffc62f1f01511396b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 18 Jan 2021 14:22:39 +0100 Subject: [PATCH 08/11] upgrade to version 1.0.2, add a file Utils.php to debug this version with Yunohost --- README.md | 2 +- README_fr.md | 2 +- conf/Utils.php | 904 ++++++++++++++++++++++++++++++++++++++++++++++++ conf/app.src | 4 +- manifest.json | 2 +- scripts/install | 3 + scripts/upgrade | 3 + 7 files changed, 915 insertions(+), 5 deletions(-) create mode 100644 conf/Utils.php diff --git a/README.md b/README.md index ac562df..4eec7d6 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:** 0.9.8.1 +**Shipped version:** 1.0.2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 05337c9..7f7254e 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 :** 0.9.8.1 +**Version incluse :** 1.0.2 ## Captures d'écran diff --git a/conf/Utils.php b/conf/Utils.php new file mode 100644 index 0000000..28d8a09 --- /dev/null +++ b/conf/Utils.php @@ -0,0 +1,904 @@ +'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 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) === 0) + { + $uri = substr($uri, strlen(WWW_URI)); + } + + return WWW_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) + { + if (empty($destination) || !preg_match('/^https?:\/\//', $destination)) + { + if (empty($destination)) + $destination = WWW_URL; + else + $destination = WWW_URL . preg_replace('/^\//', '', $destination); + } + + if (PHP_SAPI == 'cli') { + echo 'Please visit ' . $destination . PHP_EOL; + exit; + } + + if (headers_sent()) + { + echo + ''. + ' ' . + ' ' . + ' '. + ' '. + ' '. + ' '. + ''; + + 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('/