Freitag, 10. Juli 2015

MapGuide / AIMS - show number of sessions

As shown in Jackie's blog one can easily count the number of current sessions. I put such a counter on our internal web site where we keep links to different web interfaces and scripts related to our AIMS/MapGuide installations:




The script is written in PHP:

 <?php  
 // for remote server  
 //  
 // (1) INLCUDE ../vaw_settings.php;  
 //  
 // for local server  
 //  
 // (1) INLCUDE Verweis mit ./vaw_settings.php;  
 //  
 include './vaw_settings.php';  
 $fi = new FilesystemIterator($pathSessionRepository, FilesystemIterator::SKIP_DOTS);  
 //  
 $number = (iterator_count($fi)-1)/2 ;   
 // for remote server  
 //  
 // (2) echo $number;  
 //  
 // for local server  
 //  
 // (2) return $number;  
 //   
 return $number;  
 ?>  

The vaw_settings.php file contains only the path to MapGuide session repository ($pathSessionRepository).

The script for counting current sessions is called from within another PHP script which runs on one of the AIMS servers. It also calls the slightly modified version of the script on the remote server:

 ...  
 $script_number_users = 'misc/count_logged_users.php';  
 ...  
 //local server  
 //only relative path to script  
 $request_url = $script_number_users;  
 echo "# of users logged in ($label_server1):____".include($request_url).".";  
 //remote server  
 //complete url  
 $request_url = $basis_url_server3.$url_vaw_scripte.$script_number_users;  
 echo "# of users logged in ($label_server3):____".file_get_contents($request_url).".";  

Depending on whether the script runs locally or remotely it needs to be modified slightly (see comments in scripts) and the way the script is called varies as well (relative path vs. complete URL, include vs. file_get_contents). 


AIMS/MapGuide 2013

Keine Kommentare:

Kommentar veröffentlichen