Merge branch 'master' of git.gnous.fr:Gnous/main_website
This commit is contained in:
		
						commit
						5e3b1154e1
					
				
							
								
								
									
										1
									
								
								.env.example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.env.example
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | ES_TOKEN = "" | ||||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,3 +1,6 @@ | |||||||
| credentials.info | credentials.info | ||||||
| html/.htpasswd | html/.htpasswd | ||||||
| html/.htaccess | html/.htaccess | ||||||
|  | .env | ||||||
|  | geckodriver.log | ||||||
|  | html/ressources/stats | ||||||
|  | |||||||
							
								
								
									
										110
									
								
								html/apropos.php
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								html/apropos.php
									
									
									
									
									
								
							| @ -189,6 +189,10 @@ | |||||||
|         à leur arrêt définitif de manière imprévue, sans organiser et faciliter au préalable la migration des utilisateurices vers une autre instance ou plateforme.<br> |         à leur arrêt définitif de manière imprévue, sans organiser et faciliter au préalable la migration des utilisateurices vers une autre instance ou plateforme.<br> | ||||||
|         Enfin, ce site web semble indispensable à la présentation de GNOUS, et n'est par conséquent pas non plus destiné à disparaître inopinément.</p> |         Enfin, ce site web semble indispensable à la présentation de GNOUS, et n'est par conséquent pas non plus destiné à disparaître inopinément.</p> | ||||||
| 
 | 
 | ||||||
|  |     <p>Une <a href="stats.php" title="https://www.gnous.fr/stats.php">page</a> est dédiée aux statistiques d'utilisation des services et donne des vues à la journée, à la semaine, au mois et à l'année. | ||||||
|  |       Les graphiques sont actualisés quotidiennement vers minuit. | ||||||
|  |     </p> | ||||||
|  | 
 | ||||||
|     <p>Tous les services proposés par GNOUS ne sont pas référencés sur ce site web, leur usage pouvant être personnel ou réservé à un public restreint. |     <p>Tous les services proposés par GNOUS ne sont pas référencés sur ce site web, leur usage pouvant être personnel ou réservé à un public restreint. | ||||||
|         Les utilisateurices sont cependant invité·es à <a href="contact.php" |         Les utilisateurices sont cependant invité·es à <a href="contact.php" | ||||||
|             title="contact.php">nous contacter</a> si ils ou elles ont besoin d'un service particulier (sans pour autant aucune garantie quant à leur déploiement).</p> |             title="contact.php">nous contacter</a> si ils ou elles ont besoin d'un service particulier (sans pour autant aucune garantie quant à leur déploiement).</p> | ||||||
| @ -206,60 +210,6 @@ | |||||||
|         Mattermost ne soit pas trop importante (du moins pour l'instant). </li> |         Mattermost ne soit pas trop importante (du moins pour l'instant). </li> | ||||||
|     </ul> |     </ul> | ||||||
| 
 | 
 | ||||||
| <?php |  | ||||||
| $url = "https://mattermost.gnous.fr/api/v4/analytics/old"; |  | ||||||
| $headers = array( |  | ||||||
|    "Accept: application/json", |  | ||||||
|    "Authorization: Bearer ".$_ENV["MM_TOKEN"], |  | ||||||
| ); |  | ||||||
| 
 |  | ||||||
| $ch = curl_init($url); |  | ||||||
| curl_setopt($ch, CURLOPT_URL, $url); |  | ||||||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |  | ||||||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |  | ||||||
| 
 |  | ||||||
| $data_json = curl_exec($ch); |  | ||||||
| 
 |  | ||||||
| $status_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); |  | ||||||
| 
 |  | ||||||
| curl_close($ch); |  | ||||||
| 
 |  | ||||||
| if ($status_code==200) { |  | ||||||
| 	$data = json_decode($data_json, true); |  | ||||||
| 	$channel_count = $data[0]['value'] + $data[1]['value']; |  | ||||||
| 	$message_count = $data[2]['value']; |  | ||||||
| 	$user_count = $data[3]['value']; |  | ||||||
| 	$team_count = $data[4]['value']; |  | ||||||
| ?>
 |  | ||||||
| 
 |  | ||||||
|     Chiffres (mis à jour en temps réel) : |  | ||||||
|     <table border="1"> |  | ||||||
|       <tbody> |  | ||||||
|         <tr> |  | ||||||
|           <td>Utilisateurices</td> |  | ||||||
|           <td><?php echo $user_count;?></td>
 |  | ||||||
|         </tr> |  | ||||||
|         <tr> |  | ||||||
|           <td>Équipes</td> |  | ||||||
|           <td><?php echo $team_count;?></td>
 |  | ||||||
|         </tr> |  | ||||||
|         <tr> |  | ||||||
|             <td>Canaux</td> |  | ||||||
|             <td><?php echo $channel_count;?></td>
 |  | ||||||
|           </tr> |  | ||||||
|         <tr> |  | ||||||
|           <td>Messages</td> |  | ||||||
|           <td><?php echo $message_count;?></td>
 |  | ||||||
|         </tr> |  | ||||||
|       </tbody> |  | ||||||
|     </table> |  | ||||||
| 
 |  | ||||||
| <?php |  | ||||||
| } else { |  | ||||||
| 	echo "<i>Statistiques momentanément indisponibles.</i>"; |  | ||||||
| } |  | ||||||
| ?>
 |  | ||||||
| 
 |  | ||||||
|     <h4 id="nextcloud">Nextcloud</h4> |     <h4 id="nextcloud">Nextcloud</h4> | ||||||
|     <p>Le logiciel libre <a href="https://nextcloud.com/" target="_blank" title="https://nextcloud.com/ (nouvel onglet)">Nextcloud</a> est le |     <p>Le logiciel libre <a href="https://nextcloud.com/" target="_blank" title="https://nextcloud.com/ (nouvel onglet)">Nextcloud</a> est le | ||||||
|       troisième service (le second étant ce site) mis en place avec GNOUS. |       troisième service (le second étant ce site) mis en place avec GNOUS. | ||||||
| @ -268,58 +218,6 @@ if ($status_code==200) { | |||||||
|       les fichiers qu'on envoie habituellement par mail, et alléger ainsi toute |       les fichiers qu'on envoie habituellement par mail, et alléger ainsi toute | ||||||
|       l'infrastructure du mail.</p> |       l'infrastructure du mail.</p> | ||||||
| 
 | 
 | ||||||
| <?php |  | ||||||
| $url = "https://cloud.gnous.fr/ocs/v2.php/apps/serverinfo/api/v1/info?format=json"; |  | ||||||
| $headers = array( |  | ||||||
|    "Accept: application/json", |  | ||||||
|    "OCS-APIRequest: true", |  | ||||||
| ); |  | ||||||
| 
 |  | ||||||
| $ch = curl_init($url); |  | ||||||
| curl_setopt($ch, CURLOPT_URL, $url); |  | ||||||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |  | ||||||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |  | ||||||
| curl_setopt($ch, CURLOPT_USERPWD, $_ENV["NEXTCLOUD_USER"].":".$_ENV["NEXTCLOUD_TOKEN"]); |  | ||||||
| 
 |  | ||||||
| $data_json = curl_exec($ch); |  | ||||||
| 
 |  | ||||||
| $status_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); |  | ||||||
| 
 |  | ||||||
| curl_close($ch); |  | ||||||
| 
 |  | ||||||
| if ($status_code==200) { |  | ||||||
| 	$data = json_decode($data_json, true); |  | ||||||
| 	$nextcloud_data = $data['ocs']['data']['nextcloud']; |  | ||||||
| 	$user_count = $nextcloud_data['storage']['num_users']; |  | ||||||
| 	$file_count = $nextcloud_data['storage']['num_files']; |  | ||||||
| 	$share_count = $nextcloud_data['shares']['num_shares']; |  | ||||||
| ?>
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|       Chiffres (mis à jour en temps réel) : |  | ||||||
|       <table border="1"> |  | ||||||
|         <tbody> |  | ||||||
|           <tr> |  | ||||||
|             <td>Utilisateurices</td> |  | ||||||
|             <td><?php echo $user_count;?></td>
 |  | ||||||
|           </tr> |  | ||||||
|           <tr> |  | ||||||
|             <td>Fichiers</td> |  | ||||||
|             <td><?php echo $file_count;?></td>
 |  | ||||||
|           </tr> |  | ||||||
|           <tr> |  | ||||||
|             <td>Partages de fichiers</td> |  | ||||||
|             <td><?php echo $share_count;?></td>
 |  | ||||||
|           </tr> |  | ||||||
|         </tbody> |  | ||||||
|       </table> |  | ||||||
| 
 |  | ||||||
| <?php |  | ||||||
| } else { |  | ||||||
| 	echo "<i>Statistiques momentanément indisponibles.</i>"; |  | ||||||
| } |  | ||||||
| ?>
 |  | ||||||
| 
 |  | ||||||
|       <h4 id="mailcow">Mailcow</h4> |       <h4 id="mailcow">Mailcow</h4> | ||||||
|       <p>Depuis mars 2021 GNOUS dispose d'un serveur de mail basé sur la solution libre <a href="https://mailcow.email/" target="_blank" title="https://mailcow.email/ (nouvel onglet)">Mailcow</a>. |       <p>Depuis mars 2021 GNOUS dispose d'un serveur de mail basé sur la solution libre <a href="https://mailcow.email/" target="_blank" title="https://mailcow.email/ (nouvel onglet)">Mailcow</a>. | ||||||
|       Ce service permet d'envoyer et de recevoir des mails avec une adresse en <code>@gnous.fr</code>, ou tout autre domaine administré par GNOUS. Les mails sont également consultables au moyen d'un <a href="https://webmail.gnous.fr/" target="_blank" title="https://webmail.gnous.fr/ (nouvel onglet)">webmail</a>.</p> |       Ce service permet d'envoyer et de recevoir des mails avec une adresse en <code>@gnous.fr</code>, ou tout autre domaine administré par GNOUS. Les mails sont également consultables au moyen d'un <a href="https://webmail.gnous.fr/" target="_blank" title="https://webmail.gnous.fr/ (nouvel onglet)">webmail</a>.</p> | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| <hr> | <hr> | ||||||
| <p id="menu"><a href="index.php" title="https://www.gnous.fr/">Accueil</a> | <p id="menu"><a href="index.php" title="https://www.gnous.fr/">Accueil</a> | ||||||
|   | <a href="apropos.php" title="https://www.gnous.fr/apropos.php">À propos</a> |   | <a href="apropos.php" title="https://www.gnous.fr/apropos.php">À propos</a> | ||||||
|  |   | <a href="stats.php" title="https://www.gnous.fr/stats.php">Statistiques</a> | ||||||
|   | <a href="https://mattermost.gnous.fr/" target="_blank" title="https://mattermost.gnous.fr/ (nouvel onglet)">Mattermost</a> |   | <a href="https://mattermost.gnous.fr/" target="_blank" title="https://mattermost.gnous.fr/ (nouvel onglet)">Mattermost</a> | ||||||
|   | <a href="https://cloud.gnous.fr/" target="_blank" title="https://cloud.gnous.fr/ (nouvel onglet)">Nextcloud</a> |   | <a href="https://cloud.gnous.fr/" target="_blank" title="https://cloud.gnous.fr/ (nouvel onglet)">Nextcloud</a> | ||||||
|   | <a href="https://travaux.gnous.fr/" target="_blank" title="https://travaux.gnous.fr/ (nouvel onglet)">Travaux</a> |   | <a href="https://travaux.gnous.fr/" target="_blank" title="https://travaux.gnous.fr/ (nouvel onglet)">Travaux</a> | ||||||
|  | |||||||
							
								
								
									
										70
									
								
								html/stats.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								html/stats.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | |||||||
|  | <?php | ||||||
|  |   $this_file = basename($_SERVER["SCRIPT_FILENAME"]); | ||||||
|  | ?>
 | ||||||
|  | 
 | ||||||
|  | <!DOCTYPE HTML> | ||||||
|  | <html> | ||||||
|  | 	<HEAD> | ||||||
|  | 		<meta charset="UTF-8"> | ||||||
|  | 		<title>Statistiques</title> | ||||||
|  | 		<link rel="SHORTCUT ICON" HREF="ressources/logo.svg"> | ||||||
|  | 		<style> | ||||||
|  | 		img { | ||||||
|  | 		  max-width: 100%; | ||||||
|  | 		    height: auto; | ||||||
|  | 		    } | ||||||
|  | 		</style> | ||||||
|  | 	</HEAD> | ||||||
|  | 
 | ||||||
|  | 	<BODY> | ||||||
|  | 		<CENTER> | ||||||
|  | 		<?php include 'includes/titre.php'; ?>
 | ||||||
|  | 		<i>Cette page vous donne quelques chiffres sur l'utilisation des services.</i><br><br> | ||||||
|  | 		<?php include 'includes/menu.php'; ?>
 | ||||||
|  | 		</CENTER> | ||||||
|  | 		<?php include 'includes/mtime.php'; ?>
 | ||||||
|  | 
 | ||||||
|  | 	<b>NOTA :</b> Les graphiques sont actualisés quotidiennement vers minuit (heure de Paris). | ||||||
|  | 
 | ||||||
|  |     <h2 id="sommaire">Sommaire</h2> | ||||||
|  |     <ul> | ||||||
|  |         <li> <a href="#mm" title="https://www.gnous.fr/stats.php#mm">Mattermost</a></li> | ||||||
|  |         <ul> | ||||||
|  |           <li> <a href="#mm24h" title="https://www.gnous.fr/stats.php#mm24h">Dernières 24h</a></li> | ||||||
|  |           <li> <a href="#mm7d" title="https://www.gnous.fr/stats.php#mm7d">Dernière semaine</a></li> | ||||||
|  |           <li> <a href="#mm1M" title="https://www.gnous.fr/stats.php#mm1M">Dernier mois</a></li> | ||||||
|  |           <li> <a href="#mm1y" title="https://www.gnous.fr/stats.php#mm1y">Dernière année</a></li> | ||||||
|  |         </ul> | ||||||
|  |         <li> <a href="#nc" title="https://www.gnous.fr/stats.php#nc">Nextcloud</a></li> | ||||||
|  |         <ul> | ||||||
|  |           <li> <a href="#nc24h" title="https://www.gnous.fr/stats.php#nc24h">Dernières 24h</a></li> | ||||||
|  |           <li> <a href="#nc7d" title="https://www.gnous.fr/stats.php#nc7d">Dernière semaine</a></li> | ||||||
|  |           <li> <a href="#nc1M" title="https://www.gnous.fr/stats.php#nc1M">Dernier mois</a></li> | ||||||
|  |           <li> <a href="#nc1y" title="https://www.gnous.fr/stats.php#nc1y">Dernière année</a></li> | ||||||
|  |         </ul> | ||||||
|  |     </ul> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		<h2 id=mm>Mattermost</h2> | ||||||
|  | 		<h3 id=mm24h>Dernières 24h</h3> | ||||||
|  | 		<a href="/ressources/stats/mm24h.png" target="_blank" title="Mattermost - Dernières 24h"><img src="ressources/stats/mm24h.png"></a><br> | ||||||
|  |     <h3 id=mm7d>Dernière semaine</h3> | ||||||
|  | 		<a href="/ressources/stats/mm7d.png" target="_blank" title="Mattermost - Dernière semaine"><img src="ressources/stats/mm7d.png"></a><br> | ||||||
|  | 		<h3 id=mm1M>Dernier mois</h3> | ||||||
|  | 		<a href="/ressources/stats/mm1M.png" target="_blank" title="Mattermost - Dernier mois"><img src="ressources/stats/mm1M.png"></a><br> | ||||||
|  | 		<h3 id=mm1y>Dernière année</h3> | ||||||
|  | 		<a href="/ressources/stats/mm1y.png" target="_blank" title="Mattermost - Dernière année"><img src="ressources/stats/mm1y.png"></a><br> | ||||||
|  | 
 | ||||||
|  | 		<h2 id=nc>Nextcloud</h2> | ||||||
|  | 		<h3 id=nc24h>Dernières 24h</h3> | ||||||
|  | 		<a href="/ressources/stats/nc24h.png" target="_blank" title="Nextcloud - Dernières 24h"><img src="ressources/stats/nc24h.png"></a><br> | ||||||
|  | 		<h3 id=nc7d>Dernière semaine</h3> | ||||||
|  | 		<a href="/ressources/stats/nc7d.png" target="_blank" title="Nextcloud - Dernière semaine"><img src="ressources/stats/nc7d.png"></a><br> | ||||||
|  | 		<h3 id=nc1M>Dernier mois</h3> | ||||||
|  | 		<a href="/ressources/stats/nc1M.png" target="_blank" title="Nextcloud - Dernier mois"><img src="ressources/stats/nc1M.png"></a><br> | ||||||
|  | 		<h3 id=nc1y>Dernière année</h3> | ||||||
|  | 		<a href="/ressources/stats/nc1y.png" target="_blank" title="Nextcloud - Dernière année"><img src="ressources/stats/nc1y.png"></a><br> | ||||||
|  | 
 | ||||||
|  | 		<?php include 'includes/footer.php'; ?>
 | ||||||
|  | 	</BODY> | ||||||
|  | </HTML> | ||||||
							
								
								
									
										33
									
								
								print_stats.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								print_stats.py
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | #!/usr/bin/python3 | ||||||
|  | 
 | ||||||
|  | import os | ||||||
|  | from time import sleep | ||||||
|  | from dotenv import load_dotenv | ||||||
|  | from seleniumwire import webdriver | ||||||
|  | from seleniumwire.webdriver import FirefoxOptions | ||||||
|  | 
 | ||||||
|  | os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||||||
|  | load_dotenv() | ||||||
|  | 
 | ||||||
|  | opts = FirefoxOptions() | ||||||
|  | opts.add_argument("--headless") | ||||||
|  | browser = webdriver.Firefox(options=opts,executable_path="/usr/local/bin/geckodriver") | ||||||
|  | browser.set_window_size(3000, 1120) | ||||||
|  | 
 | ||||||
|  | def interceptor(request): | ||||||
|  |     request.headers['Authorization'] = 'Basic '+os.environ["ES_TOKEN"] | ||||||
|  | browser.request_interceptor = interceptor | ||||||
|  | 
 | ||||||
|  | for duration in ["24h", "7d", "1M", "1y"]: | ||||||
|  | 	browser.get("https://mon.gnous.fr/app/dashboards#/view/380099d0-4944-11ec-81a9-95d7ffa23468?embed=true&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-"+duration+"%2Cto%3Anow))&hide-filter-bar=true") | ||||||
|  | 	sleep(30) | ||||||
|  | 	if duration == "24h": | ||||||
|  | 		sleep(15) | ||||||
|  | 	browser.get_screenshot_as_file("html/ressources/stats/mm"+duration+".png") | ||||||
|  | 
 | ||||||
|  | for duration in ["24h", "7d", "1M", "1y"]: | ||||||
|  | 	browser.get("https://mon.gnous.fr/app/dashboards#/view/ef70de60-4947-11ec-81a9-95d7ffa23468?embed=true&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-"+duration+"%2Cto%3Anow))&hide-filter-bar=true") | ||||||
|  | 	sleep(30) | ||||||
|  | 	browser.get_screenshot_as_file("html/ressources/stats/nc"+duration+".png") | ||||||
|  | 
 | ||||||
|  | print('done') | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user