Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $logDirectory = '/Users/sadasd/Dropbox/Adium Logs/';
- $logHandle = @opendir($logDirectory);
- $myNames = array( "Mr wurst." );
- if( !$logHandle ) {
- echo "Unable to Open Log Directory\n";
- exit;
- }
- while( false !== ($userDirectory = readdir($logHandle) ) ) {
- try {
- if( is_dir( $userDirectory) ) {
- $fullDirectory = $logDirectory . DIRECTORY_SEPARATOR . $userDirectory;
- $chatlogs = array();
- foreach( glob($fullDirectory . DIRECTORY_SEPARATOR . '*.chatlog' ) as $chatlog ) {
- $mtime = filemtime( $chatlog );
- $chatlogs[ $mtime ] = $chatlog;
- }
- var_dump( $fullDirectory );
- if( empty( $chatlogs ) ) {
- continue;
- }
- krsort( $chatlogs );
- $oldestLog = array_shift( $chatlogs );
- $basename = basename( $oldestLog );
- $xml = str_replace('chatlog', 'xml', $basename );
- $oldestLog .= DIRECTORY_SEPARATOR . $xml;
- $content = @file_get_contents( $oldestLog );
- if( $content === null ) {
- throw new Exception('Cant open '.$oldestLost." :(");
- }
- $names = array();
- if( preg_match_all('/alias=\"(.*?)\"/', $content, $m ) ) {
- foreach( $m[1] as $Name ) {
- if( !in_array( $Name, $myNames ) ) {
- $names[ $Name ] = $Name;
- }
- }
- } else {
- continue;
- }
- $topName = array_shift( $names );
- echo "$userDirectory => $topName\n";
- }
- } catch( Exception $e ) {
- echo $e->getMessage()."\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement