Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.  
  3.     $logDirectory = '/Users/sadasd/Dropbox/Adium Logs/';
  4.     $logHandle = @opendir($logDirectory);
  5.     $myNames = array(  "Mr wurst." );
  6.  
  7.     if( !$logHandle ) {
  8.         echo "Unable to Open Log Directory\n";
  9.         exit;
  10.     }
  11.  
  12.     while( false !== ($userDirectory = readdir($logHandle) ) ) {
  13.  
  14.         try {
  15.  
  16.             if( is_dir( $userDirectory) ) {
  17.  
  18.                 $fullDirectory = $logDirectory . DIRECTORY_SEPARATOR . $userDirectory;
  19.                 $chatlogs = array();
  20.                 foreach( glob($fullDirectory . DIRECTORY_SEPARATOR . '*.chatlog' ) as $chatlog ) {
  21.                     $mtime = filemtime( $chatlog );
  22.                     $chatlogs[ $mtime ] = $chatlog;
  23.                 }
  24.  
  25.                 var_dump( $fullDirectory );
  26.  
  27.                 if( empty( $chatlogs ) ) {
  28.                     continue;    
  29.                 }
  30.  
  31.                 krsort( $chatlogs );
  32.  
  33.                 $oldestLog = array_shift( $chatlogs );
  34.                 $basename = basename( $oldestLog );
  35.                 $xml = str_replace('chatlog', 'xml', $basename );
  36.  
  37.                 $oldestLog .= DIRECTORY_SEPARATOR . $xml;
  38.  
  39.                 $content = @file_get_contents( $oldestLog );
  40.                 if( $content === null ) {
  41.                     throw new Exception('Cant open '.$oldestLost." :(");  
  42.                 }
  43.  
  44.                 $names = array();
  45.                 if( preg_match_all('/alias=\"(.*?)\"/', $content, $m ) ) {
  46.                     foreach( $m[1] as $Name ) {
  47.                         if( !in_array( $Name, $myNames ) ) {
  48.                             $names[ $Name ] = $Name;    
  49.                         }
  50.                     }
  51.                 } else {
  52.                     continue;    
  53.                 }
  54.  
  55.                 $topName = array_shift( $names );
  56.  
  57.                 echo "$userDirectory => $topName\n";
  58.             }
  59.  
  60.         } catch( Exception $e ) {
  61.             echo $e->getMessage()."\n";
  62.         }
  63.  
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement