What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [PHP] Regular expressions and Status2FTP

[PHP] Regular expressions and Status2FTP
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
O.P. [PHP] Regular expressions and Status2FTP
Yes, me again. :P

I just downloaded and installed Status2FTP, and I immediatly fell in love with it. :) It does what it has to do, and now I want to use it in my signature, as replacement for Web2Messenger.

This means that I have to replace this:
code:
<Details>
<Username>[c=1]<simply[b]_me>[/b][/c=12]</Username>
<PSM><:o) Messenger Plus! [c=7]Live[/c] is arrived! <:o)</PSM>
<Status>Online</Status>
</Details>
into this:
code:
$nick = "[c=1]<simply[b]_me>[/b][/c=12]";
$psm = "<:o) Messenger Plus! [c=7]Live[/c] is arrived! <:o)";
$status = "Online";
So far, I managed to create a function called getXMLData($i) to return the value for $nick, $psm and $status:
code:
function getXMLData($i) {
global $content2;
$data = str_replace(array("<Details>","</Details>"), "", $content2);
$data0 = preg_replace("/<Username>(.*?)<\/Username>/","\\1", $data);
$data1 = preg_replace("/<PSM>(.*?)<\/PSM>/","\\1", $data);
$data2 = preg_replace("/<Status>(.*?)<\/Status>/","\\1", $data);
eval("return \$data$i;");
}
$content2 is the variable containing the XML file, but unfortunaly it doesn't works like I wanted. As you can see, it only drops the <Username> and </Username> tags, where it has to drop these tags and everything before and behind it. And with my small knowledge of regular expressions, I'm back to ask the Messenger Plus! Live community. :)

Any replies or questions are more than welcome! ;)

This post was edited on 06-25-2006 at 08:18 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-25-2006 08:17 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
O.P. RE: [PHP] Regular expressions and Status2FTP
Woops! Already solved! :P
code:
//Get the XML data and return it
function getXMLData($i) {
    global $content2;
    $data = str_replace(array("<Details>","</Details>"), "", $content2);
    $data0 = preg_replace("/^<Username>(.*?)<\/Username>(.*?)$/","\\1", $data);
    $data1 = preg_replace("/^(.*?)<PSM>(.*?)<\/PSM>(.*?)$/","\\2", $data);
    $data2 = preg_replace("/^(.*?)<Status>(.*?)<\/Status>(.*?)$/","\\2", $data);
    eval("return \$data$i;");
}
Heh... well, thanks for reading. :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-25-2006 08:25 AM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [PHP] Regular expressions and Status2FTP
First of all thanks for loving my script :P

Secondly, why do it that way when you can use SimpleXML (PHP5 only)
code:
<?php
$xml = simplexml_load_file('details.xml');
$Username = $xml->Username;
$PSM = $xml->PSM;
$Status = $xml->Status;
?>
06-25-2006 08:28 AM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: [PHP] Regular expressions and Status2FTP
Insted of eval you could of used variable varibles
http://php.net/language.variables.variable

:-/ you shouldnt preg_replace that , either use simplexml (like eljellybeanfishdog said) or use preg_match and use its matches variable to extract the results

http://php.net/preg_match
[Image: dt2.0v2.png]      Happy Birthday, WDZ
06-25-2006 08:29 AM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
O.P. RE: [PHP] Regular expressions and Status2FTP
quote:
Originally posted by Eljay
code:
$xml = simplexml_load_file('details.xml');
$Username = $xml->Username;
$PSM = $xml->PSM;
$Status = $xml->Status;

Hmm... it seems like that XML thing doesn't work too great. Let's see...
quote:
Originally posted by Mattike's PHP Info
PHP Version 4.4.2
Doooh... :P
quote:
Originally posted by -dt-
or use preg_match and use its matches variable to extract the results
Can you give me an example? (A)


BTW, still didn't found a solution to strip the ·$(color) tags... :(
code:
$string = preg_replace("/·\$[0-9]{1,2}/", "", $string);
[OFFTOPIC]300th post! :D[/OFFTOPIC]

This post was edited on 06-25-2006 at 09:28 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-25-2006 09:16 AM
Profile E-Mail PM Web Find Quote Report
Death.Knight
New Member
*

Avatar
The Knight Of Apocalypse

Posts: 7
38 / Male / –
Joined: Feb 2005
RE: [PHP] Regular expressions and Status2FTP
I'm interested by your plugin eljay! But i don't know php scripting very well.. Mattike can i see an example of the index.php please?
[Image: death.jpg]
11-06-2006 04:09 AM
Profile E-Mail PM Web Find Quote Report
NiteMare
Veteran Member
*****

Avatar
Giga-Byte me

Posts: 2497
Reputation: 37
36 / Male / Flag
Joined: Aug 2003
RE: [PHP] Regular expressions and Status2FTP
lets pressure Eljay to continue develoupment, there are a few bug in it still, and he says it could be better:P
[Image: sig/]
I'll never forget what she said 6652 days, 11 hours, 7 minutes, 19 seconds ago
Need hosting? Check
out my website. we can help you out :)
11-06-2006 04:39 AM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [PHP] Regular expressions and Status2FTP
quote:
Originally posted by NiteMare
lets pressure Eljay to continue develoupment, there are a few bug in it still, and he says it could be better:P

why dont you nagging people feck off :P
11-06-2006 05:30 PM
Profile PM Find Quote Report
NiteMare
Veteran Member
*****

Avatar
Giga-Byte me

Posts: 2497
Reputation: 37
36 / Male / Flag
Joined: Aug 2003
RE: [PHP] Regular expressions and Status2FTP
quote:
Originally posted by Eljay
quote:
Originally posted by NiteMare
lets pressure Eljay to continue develoupment, there are a few bug in it still, and he says it could be better:P

why dont you nagging people feck off :P
i can't make sence of that sentance:P
[Image: sig/]
I'll never forget what she said 6652 days, 11 hours, 7 minutes, 19 seconds ago
Need hosting? Check
out my website. we can help you out :)
11-06-2006 05:32 PM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [PHP] Regular expressions and Status2FTP
quote:
Originally posted by NiteMare
quote:
Originally posted by Eljay
quote:
Originally posted by NiteMare
lets pressure Eljay to continue develoupment, there are a few bug in it still, and he says it could be better:P

why dont you nagging people feck off :P
i can't make sence of that sentance:P

likewise... :refuck:
11-06-2006 05:36 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On