Jump to content

[SOLVED] simple preg_match help


newbtophp

Recommended Posts

try this

<?php
$html = '<script LANGUAGE="JavaScript"><!--
document.write(unescape("%3C%53%43%52%49%50%54%20%4C%41%4E%47%55%41%47%45%3D%22%4A%61%"));//--></SCRIPT>';
if (preg_match('/unescape\((["\'])([\da-f%]*?)\1\)/i', $html, $regs)) {
echo urldecode($regs[2]);
}
?>

that's not what you asked and from the first question you haven't given any details i can work with!

 

Sorry i was tired, for example:

 

I have this code:

 

$file = file_get contents($upload);

echo $file;

 

 

Its an upload form where i echo whats directally uploaded, the uploaded file always contains urlencoded data which is wrapped in script tags, but the trouble is i want to only echo the code after the first </SCRIPT> end tag.

 

 

So lets say i have uploaded:

 

<script LANGUAGE="JavaScript"><!--
document.write(unescape("%3C%53%43%52%49%50%54%20%4C%41%4E%47%55%41%47%45%3D%22%4A%61%"));//--></SCRIPT>

<SCRIPT>
text etc.

</script>

<script LANGUAGE="JavaScript">
more js...

</script>

<html>

 

 

It will only echo:

 


<SCRIPT>
text etc.

</script>

<script LANGUAGE="JavaScript">
more js...

</script>

<html>

 

I thought it can possibly be done by preg_match but not intially sure

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.