Connect. Communicate. Collaborate. Securely.

Home » Kerio User Forums » Kerio Connect » php code: who has what mobile device and which EAS version
  •  
Vink

Messages: 32
Karma: 3
Send a private message to this user
I made below php script a while ago. It reads the mailstore of a complete domain and outputs all the users with mobile devices with info on what those are and what EAS version they're using. I found the latter pretty useful since the upgrade to 8.5 which now supports EAS 14.1

<?php
date_default_timezone_set('CET');
// find the include at http://www.bobulous.org.uk/coding/php-5-xml-feeds.html
require_once('xml_regex.php');

$dir = "<mailstore folder>";        // e.g. /data/mail/domain
$dh1 = opendir($dir);

while (($file = readdir($dh1)) !== false)
 {
   if ( $file == "." ) continue;
   if ( $file == ".." ) continue;

   $fp1 = "$dir/$file";
   if ( is_file($fp1) ) continue;               // folders only

   $asycount = 0;
   if ( file_exists ("$fp1/#sync") )
    {
        $out = "";
        $dh2 = opendir("$fp1/#sync");
        while (($asyfile = readdir($dh2)) !== false)
         {
           $fp2 = "$fp1/#sync/$asyfile";
           $path_parts = pathinfo($fp2);
           if ( $path_parts['extension'] !== "asy" ) continue;
           $xml = file_get_contents($fp2);
           $asycount = $asycount + 1;

           $DeviceId = value_in('DeviceId', $xml);
           $DeviceType = value_in('DeviceType', $xml);
           $UserAgent = value_in('UserAgent', $xml);
           $ActiveSyncVersion = value_in('ActiveSyncVersion', $xml);
           $FirstSync = value_in('FirstSync', $xml);
           $LastSync = value_in('LastSync', $xml);

           $DTF = date("d-m-Y H:i" , $FirstSync);
           $DTL = date("d-m-Y H:i" , $LastSync);

           $out = $out . "\t$DeviceType - $UserAgent - EAS $ActiveSyncVersion - $DTF - $DTL\n";

         }
        if ( $asycount != 0 )
         {
           echo "$file\n";
           echo "$out\n";
         }
    }
 }

rewinddir($dh1);
closedir($dh1);
?>


The output is something like:
user1
        WindowsMail - WindowsMail/17.5.9600.20856 - EAS 14.1 - 30-05-2015 09:03 - 30-05-2015 09:14
        WP8 -  - EAS 14.1 - 29-05-2015 20:25 - 30-05-2015 09:37

user2
        WP8 -  - EAS 12.1 - 19-02-2015 11:51 - 29-05-2015 13:17

user3
        SAMSUNGSMG800F - SAMSUNG-SM-G800F/101.40402 - EAS 12.1 - 29-05-2015 21:33 - 29-05-2015 21:33

user4
        SAMSUNGGTS7710 - SAMSUNG-GT-S7710/100.40102 - EAS 12.1 - 29-05-2015 21:15 - 30-05-2015 01:12
        iPad - Apple-iPad4C4/1104.257 - EAS 14.1 - 29-05-2015 20:30 - 30-05-2015 09:42


Changing the script to output a CSV for use in another app or Excel should be easy.
Have fun with it. Smile
  •  
Pavel Dobry (Kerio)

Messages: 5245
Karma: 251
Send a private message to this user
Please, do not touch files in the message store directory. Use API for this: http://www.kerio.com/learn-community/developer-zone
  •  
shaz

Messages: 1
Karma: -1
Send a private message to this user
How to generate report in Kero per user


How to avoid DNS lookup failer.


How to block a website in Kerio per user or for the group.
Previous Topic: Monitoring Kerio
Next Topic: PCI-DSS Apple Mail TLS 1.0
Goto Forum:
  


Disclaimer:
Kerio discussion forums are intended for open communication between forum members and may contain information and material posted by members which may be useful in learning about Kerio products. The discussion forums are not intended to provide technical support for any specific product. Any information implied or expressed in the discussion forums is that of the posting member. Kerio is in no way responsible for the information posted in the forums, or its accuracy. Kerio employees may participate in the discussions, but their postings do not represent an offical position of the company on any issues raised or discussed. Kerio reserves the right to monitor and maintain the forums to promote free and accurate exchange of information.

Current Time: Sun Jun 25 07:16:45 CEST 2017

Total time taken to generate the page: 0.00438 seconds
.:: Contact :: Home ::.
Powered by: FUDforum 3.0.4.