newbtophp Posted September 5, 2009 Share Posted September 5, 2009 I've got some code like: $_F=__FILE__;$_X="STRING1";$_D=strrev('edoced_46esab');eval($_D("STRING2")); Note: The code always is the same, except its not allways like the above, sometimes it may contain other phpcode surrounding the above line. How would i grab and echo the two strings using regex?. Im only looking to get the 2 strings, the strings are base64 (letters [some with caps and some not], numbers and plus signs) I'm new to regex and I've come up with: if (preg_match('/="[^"]+"/Umis', $string1)) { echo $string1[1] if (preg_match('/="([^"]+)"/Umis', $string2)) { echo $string2[1] But still no luck :-\ Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/ Share on other sites More sharing options...
.josh Posted September 6, 2009 Share Posted September 6, 2009 preg_match('~"([^"]+)"~',$string,$matches); echo "<pre>";print_r($matches); Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-913417 Share on other sites More sharing options...
newbtophp Posted September 6, 2009 Author Share Posted September 6, 2009 preg_match('~"([^"]+)"~',$string,$matches); echo "<pre>";print_r($matches); Thanks but that just echos: Array ( ) Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-913481 Share on other sites More sharing options...
newbtophp Posted September 6, 2009 Author Share Posted September 6, 2009 Maybe this may give you a better understanding of what im trying to do: <form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> <input type="file" name="Upload" value="Upload" /> <input type="submit" name="submit" value="Upload" /> <br /> </form> <br> <?php if (isset($_FILES['Upload'])) { $file = file_get_contents($_FILES['Upload']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo ""; else { if($submit == "Upload") { if (preg_match('~"([^"]+)"~', $file, $match)) { //The first string gets echo'd here echo "<textarea>$match[1]</textarea>"; if (preg_match('/="([^"]+)"/Umis', $file, $match)) { //Second strings get echo'd here echo "<textarea>$match2[1]</textarea>"; } } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-913486 Share on other sites More sharing options...
.josh Posted September 6, 2009 Share Posted September 6, 2009 echo out $file see if it has what you expect it to have. Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-913630 Share on other sites More sharing options...
newbtophp Posted September 7, 2009 Author Share Posted September 7, 2009 echo out $file see if it has what you expect it to have. echos nothing, i click the submit button, the browser looks like is loading for a few seconds then just remains the same, and dont echo anything. Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-913941 Share on other sites More sharing options...
thebadbad Posted September 7, 2009 Share Posted September 7, 2009 Did you check the source code (i.e. right click > view source)? Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-914000 Share on other sites More sharing options...
newbtophp Posted September 7, 2009 Author Share Posted September 7, 2009 Did you check the source code (i.e. right click > view source)? Nope it was my problem, i add to ad '.php code here.' for the textareas and then it worked fine Quote Link to comment https://forums.phpfreaks.com/topic/173273-solved-preg_match-problems/#findComment-914003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.