Added custom changes from chapril-1.1.1.
This commit is contained in:
parent
b11fce7f18
commit
292b9e723e
@ -1,7 +1,7 @@
|
||||
{
|
||||
"PrivateBin": "PrivateBin",
|
||||
"%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted <i>in the browser</i> using 256 bits AES. More information on the <a href=\"https://privatebin.info/\">project page</a>.":
|
||||
"%s est un 'pastebin' (ou gestionnaire d'extraits de texte et de code source) minimaliste et open source, dans lequel le serveur n'a aucune connaissance des données envoyées. Les données sont chiffrées/déchiffrées <i>dans le navigateur</i> par un chiffrement AES 256 bits. Plus d'informations sur <a href=\"https://privatebin.info/\">la page du projet</a>.",
|
||||
"%s est un 'pastebin' (ou gestionnaire d'extraits de texte et de code source) minimaliste et libre, dans lequel le serveur n'a aucune connaissance des données envoyées. Les données sont chiffrées/déchiffrées <i>dans le navigateur</i> par un chiffrement AES 256 bits. Plus d'informations sur <a href=\"https://privatebin.info/\">la page du projet</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Parce que l'ignorance c'est le bonheur",
|
||||
"en": "fr",
|
||||
|
@ -64,6 +64,7 @@ class Filesystem extends AbstractData
|
||||
if (!is_dir($storagedir)) {
|
||||
mkdir($storagedir, 0700, true);
|
||||
}
|
||||
self::logToChapril("CREATE",$pasteid);
|
||||
return DataStore::store($file, $paste);
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ class Filesystem extends AbstractData
|
||||
unset($paste->meta->attachmentname);
|
||||
}
|
||||
}
|
||||
self::logToChapril("READ",$pasteid);
|
||||
return $paste;
|
||||
}
|
||||
|
||||
@ -119,6 +121,7 @@ class Filesystem extends AbstractData
|
||||
$dir->close();
|
||||
rmdir($discdir);
|
||||
}
|
||||
self::logToChapril("DELETE",$pasteid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +176,7 @@ class Filesystem extends AbstractData
|
||||
if (!is_dir($storagedir)) {
|
||||
mkdir($storagedir, 0700, true);
|
||||
}
|
||||
self::logToChapril("COMMENT",$pasteid);
|
||||
return DataStore::store($file, $comment);
|
||||
}
|
||||
|
||||
@ -370,4 +374,17 @@ class Filesystem extends AbstractData
|
||||
{
|
||||
return (bool) preg_match('/^[a-f0-9]{2}$/', $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add log
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
private function logToChapril($message, $id=null)
|
||||
{
|
||||
$today = date('Y-m-d H:i:s');
|
||||
$texte_retour="$today $message \t$id\n";
|
||||
return (bool) file_put_contents("/var/www/paste.chapril.org/paste.log",$texte_retour,FILE_APPEND|LOCK_EX);
|
||||
}
|
||||
}
|
||||
|
126
tools/rapport_activite.sh
Normal file
126
tools/rapport_activite.sh
Normal file
@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2018, 2019 Didier Clermonté <dclermonte@april.org>
|
||||
# Copyright (C) 2018, 2019 Christian Pierre Momon <christian.momon@devinsy.fr>
|
||||
#
|
||||
# This file is part of paste.chapril.org.
|
||||
#
|
||||
# This script is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# ============================================
|
||||
help()
|
||||
{
|
||||
echo "Usage:"
|
||||
echo " $(basename "$0") -h display help"
|
||||
echo " $(basename "$0") analyse current month"
|
||||
echo " $(basename "$0") -p analyse preceding month"
|
||||
echo " $(basename "$0") month_number year analyse this month"
|
||||
}
|
||||
|
||||
generateReport()
|
||||
{
|
||||
local monthEnglish="$1"
|
||||
local year="$2"
|
||||
local yearMonth="$3"
|
||||
echo -e "================================================================="
|
||||
echo
|
||||
httpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep -c "$year")
|
||||
echo "Nombre total de requêtes http = $httpRequestCount"
|
||||
|
||||
trueHttpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep "$year"|grep -vi bot|grep -c -v check)
|
||||
echo "Nombre de vraies requêtes http = $trueHttpRequestCount"
|
||||
|
||||
botRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep "$year"|grep -i bot|grep -c -v check)
|
||||
echo "Nombre de requêtes bot = $botRequestCount"
|
||||
|
||||
errorsRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-error.log*|grep -c "$year")
|
||||
echo "Nombre de requêtes http en erreur = $errorsRequestCount"
|
||||
|
||||
createdPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c CREATE)
|
||||
echo "Nombre de pastes créés ce mois = $createdPasteCount"
|
||||
|
||||
deletedPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c DELETE)
|
||||
echo "Nombre de pastes supprimés ce mois = $deletedPasteCount"
|
||||
|
||||
commentCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c COMMENT)
|
||||
echo "Nombre de commentaires ce mois = $commentCount"
|
||||
|
||||
readPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c READ)
|
||||
echo "Nombre de lectures ce mois = $readPasteCount"
|
||||
|
||||
echo "Nombre de lectures ce mois - les commentaires = $((readPasteCount-commentCount))"
|
||||
pasteCount=$(find ../data -mindepth 2 -maxdepth 3 -type f | wc -l)
|
||||
echo "Nombre de pastes dans la base actuellement = $pasteCount"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# ============================================
|
||||
echo
|
||||
if [ "$#" = 1 ] && [ "$1" = "-h" ]; then
|
||||
help
|
||||
elif [ "$#" = 1 ] && [ "$1" = "-p" ]; then
|
||||
if [ "$(date +%m)" -gt 1 ]; then
|
||||
precedingMonth="$(($(date +%m)-1))"
|
||||
year="$(date +%Y)"
|
||||
if [ $precedingMonth -lt 10 ]; then
|
||||
yearMonth="$year-0$precedingMonth"
|
||||
else
|
||||
yearMonth="$year-$precedingMonth"
|
||||
fi
|
||||
else [ "$(date +%m)" -eq 1 ]
|
||||
precedingMonth=12
|
||||
year="$(($(date +%Y)-1))"
|
||||
fi
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date -d $year-$precedingMonth-01 +%b)
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $monthEnglish $year"
|
||||
generateReport "$monthEnglish" "$year" "$yearMonth"
|
||||
elif [ "$#" -eq 2 ]; then
|
||||
if ! (let "$1") 2>/dev/null; then
|
||||
echo -e "Le mois doit être numérique."
|
||||
help
|
||||
elif ([ "$1" -lt 1 ] || [ "$1" -gt 12 ]); then
|
||||
echo -e "Numéro du mois non valable $1."
|
||||
help
|
||||
elif ! (let "$2") 2>/dev/null; then
|
||||
echo -e "L'année doit être numérique."
|
||||
help
|
||||
elif [ "$2" -lt 2018 ] || [ "$2" -gt "$(date +%Y)" ]; then
|
||||
echo -e "Année non valable $2."
|
||||
help
|
||||
elif [ "$2" -le 2017 ] || [ "$2" -ge $(($(date +%Y)+1)) ] ; then
|
||||
echo -e "Pas de données pour ce mois."
|
||||
help
|
||||
else
|
||||
if [ "$1" -lt 10 ]; then
|
||||
yearMonth="$2-0$1"
|
||||
else
|
||||
yearMonth="$2-$1"
|
||||
fi
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date -d "$2-$1-01" +%b)
|
||||
year="$2"
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $monthEnglish $2"
|
||||
generateReport "$monthEnglish" "$year" "$yearMonth"
|
||||
fi
|
||||
elif [ "$#" -eq 0 ]; then
|
||||
yearMonth="$(date +%Y-%m)"
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date +%b)
|
||||
year="$(date +%Y)"
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $(date +%b) 20$(date +%y)"
|
||||
generateReport "$monthEnglish" "$year" "$yearMonth"
|
||||
else
|
||||
echo -e "Bad parameter."
|
||||
help
|
||||
fi
|
Loading…
Reference in New Issue
Block a user