0

嗨,这段代码应该将所有段放入一个数组中。

    $dir = "../www.cms.actwebdesigns.co.uk2/logged.php";
#$dir = "../../logged.php";

$str = base64_encode(htmlspecialchars(preg_replace("#(?:\s\s+)|(?:\n)|(?:\t)|(?:\r)#", " ", file_get_contents($dir))));
$dataToAdd = array();

for($x=0; true; $x++)
{
    if(preg_match("#(".base64_encode("<?php ").")((?!(".base64_encode("?> ").")).)*#is", $str, $match))
    {
        $dataToAdd[] = $match[0].base64_encode("?> ");
        $PQmatch = preg_quote($match[0].base64_encode("?> "), "#");
        $str = preg_replace("#".$PQmatch."#is", "", $str, 1);
    }
    else
    {
        break;
    }
}

$z=1;

foreach($dataToAdd as $data)
{
    echo "<xmp>".$z."----->>> ".base64_decode($data)."<br /></xmp>";    
    $z++;
}

//1----->>> &lt;?php include(&quot;scripts/php/auth.php&quot;); include(&quot;scripts/php/sessions.php&quot;); ?&gt;<br />
//2----->>> &lt;?php if($VERIFICATION!==1) { ?&gt;<br />
//3----->>> &lt;?php echo $WEBSITE; ?&gt;<br />
//4----->>> &lt;?php } ?&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;contentBlock&quot;&gt; &lt;h2&gt;ACT Web Designs Group&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;http://www.actwebdesigns.co.uk&quot; title=&quot;link to ACT Web Designs Home&quot;&gt;www.actwebdesigns.co.uk&lt;/a&gt;&lt;br /&gt; &lt;a href=&quot;http://hosting.actwebdesigns.co.uk&quot; title=&quot;link to ACT Web Designs Hosting Solutions&quot;&gt;www.hosting.actwebdesigns.co.uk&lt;/a&gt; &lt;a href=&quot;http://www.plugnplaycms.co.uk.co.uk&quot; title=&quot;link to the home of plug n play cms&quot;&gt;www.plugnplaycms.co.uk&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id=&quot;mainBodyRight&quot;&gt; &lt;?php if(isset($_GET['msg']) &amp;&amp; !empty($_GET['msg'])) { echo &quot;&lt;div class=\&quot;contentBlock\&quot;&gt;\n&quot;; echo &quot;&lt;h2&gt;&quot;.$_GET['h2'].&quot;&lt;/h2&gt;&quot;; echo &quot;    &lt;p style=\&quot;color:&quot;.$_GET['color'].&quot;\&quot;&gt;&quot;.$_GET['msg'].&quot;&lt;/p&gt;\n&quot;; echo &quot;&lt;/div&gt;\n&quot;; } if($VERIFICATION==0) { issetJava(&quot;Your account needs verifying.&quot;, &quot;javascript&quot;, &quot;Authorisation&quot;, &quot;red&quot;); } elseif($VERIFICATION==1) { include(&quot;pageIncludes/install.php&quot;); } elseif($VERIFICATION==2) { include(&quot;pageIncludes/mainPage.php&quot;); } ?&gt;<br />

?>  

最后一个输出 (4) 应该分成 4 或 5 个结果,但事实并非如此。没人知道为什么??

4

1 回答 1

1

基本上,你的整个方法论都是由相互争斗的层层疯狂组成的。我这样做了,它有效:

<?
$file = '<?php include("scripts/php/auth.php"); include("scripts/php/sessions.php"); ?><?php if($VERIFICATION!==1) { ?><?php echo $WEBSITE; ?><?php } ?> </p> </div> <div class="contentBlock"> <h2>ACT Web Designs Group</h2> <p><a href="http://www.actwebdesigns.co.uk" title="link to ACT Web Designs Home">www.actwebdesigns.co.uk</a><br /> <a href="http://hosting.actwebdesigns.co.uk" title="link to ACT Web Designs Hosting Solutions">www.hosting.actwebdesigns.co.uk</a> <a href="http://www.plugnplaycms.co.uk.co.uk" title="link to the home of plug n play cms">www.plugnplaycms.co.uk</a></p> </div> </div> <div id="mainBodyRight"> <?php if(isset($_GET[\'msg\']) && !empty($_GET[\'msg\'])) { echo "<div class=\"contentBlock\">\n"; echo "<h2>".$_GET[\'h2\']."</h2>"; echo "    <p style=\"color:".$_GET[\'color\']."\">".$_GET[\'msg\']."</p>\n"; echo "</div>\n"; } if($VERIFICATION==0) { issetJava("Your account needs verifying.", "javascript", "Authorisation", "red"); } elseif($VERIFICATION==1) { include("pageIncludes/install.php"); } elseif($VERIFICATION==2) { include("pageIncludes/mainPage.php"); } ?>';

$str = preg_replace("#(?:\s\s+)|(?:\n)|(?:\t)|(?:\r)#", " ", $file);
$dataToAdd = array();

while(preg_match("#(<\?php .*?\?>)#is", $str, $match)) {
    $dataToAdd[] = $match[1];
    $PQmatch = preg_quote($match[1], "#");
    $str = preg_replace("#".$PQmatch."#is", "", $str, 1);
}

$z=1;
foreach($dataToAdd as $data) {
    echo "<xmp>".$z."----->>> ".$data."<br /></xmp>\n";
    $z++;
}
?>
于 2009-10-18T16:44:45.207 回答