shocker-z Posted January 30, 2007 Share Posted January 30, 2007 Hi what would you reccomend as being the best way to parse a rdp file?here is an example of the file:[code]screen mode id:i:2desktopwidth:i:1024desktopheight:i:768session bpp:i:16winposstr:s:0,3,0,0,800,600full address:s:127.0.0.1compression:i:1keyboardhook:i:2audiomode:i:0redirectdrives:i:0redirectprinters:i:1redirectcomports:i:0redirectsmartcards:i:1displayconnectionbar:i:1autoreconnection enabled:i:1username:s:administratordomain:s:MyDomainalternate shell:s:shell working directory:s:disable wallpaper:i:1disable full window drag:i:1disable menu anims:i:1disable themes:i:0disable cursor setting:i:0bitmapcachepersistenable:i:1[/code]So what i actually want is to grab the IP and Domain name but the files change format as in extra lines could be added so i can't just use line number.RegardsLiam (Getting rusty on PHP) Link to comment https://forums.phpfreaks.com/topic/36337-parse-rdp-file/ Share on other sites More sharing options...
Jessica Posted January 30, 2007 Share Posted January 30, 2007 probably some regular expression. Link to comment https://forums.phpfreaks.com/topic/36337-parse-rdp-file/#findComment-172762 Share on other sites More sharing options...
trq Posted January 30, 2007 Share Posted January 30, 2007 Could do with some cleaning, but it'll get you started....[code]<?php function getrdpinfo($rdp) { $lines = file($rdp); foreach ($lines as $line) { $tmp = explode(':',$line) { if ($tmp[0] == "domain") { $return['domain'] = $tmp[2]; } if ($tmp[0] == "full address") { $return['ip'] = $tmp[2]; } } return $return; } $result = getrdpinfo('file.rdp'); echo $result['domain']; echo $result['ip'];?>[/code] Link to comment https://forums.phpfreaks.com/topic/36337-parse-rdp-file/#findComment-172765 Share on other sites More sharing options...
shocker-z Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks mate just as i read your post i realised that each line has values seperated by : so is actualy very easy :)Thanks mateLiam Link to comment https://forums.phpfreaks.com/topic/36337-parse-rdp-file/#findComment-172786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.