php kod işleme

3 Cevap

sabah. Benim yerel sunucuda bulunan bir dosyanın dışında php kod tüm kesimlerini almak isteyen duyuyorum. Sorun i php hataları sadece tarayıcı hataları, her yerde alma gibi görünüyor dont.

$file_contents = "<xmp>".file_get_contents("../www.cms.actwebdesigns.co.uk2/pageIncludes/instalation/selectMainPages.php")."</xmp>";

if(preg_match_all("#<\?php((?!\?>).)*#is", $file_contents, $matches))
{
    foreach($matches[0] as $phpCode)
    {
    	$code = "<xmp>".$phpCode."\n?></xmp>";
    }
}
echo "dsds";
?>

Birisi bana doğru yönde işaret misiniz?

3 Cevap

Sen Simgeleştirici uzantısını kullanarak PHP komut tokenize isteyebilirsiniz:

http://php.net/manual/en/book.tokenizer.php

Uzantıları PHP v4.3.0 beri PHP içine inşa edilmiştir.

$tokens = token_get_all(file_get_contents($file));

http://www.php.net/manual/en/function.token-get-all.php

Bu çalışma:

$file_contents = token_get_all(file_get_contents("../www.cms.actwebdesigns.co.uk2/logged.php"));
$start=0;
$end=0;
$segmentArray = array();
foreach($file_contents as $key => $token)
{
    $tokenName = token_name($key);
    if($start==0 && $end==0 && $tokenName=="T_OPEN_TAG")
    {
    	$start=1;
    }
    if(start==1 && $end==0 && $tokenName!="T_CLOSE_TAG")
    {
    	$entryNo = count($segmentArray);
    	$segmentArray[$entryNo][] = $token;
    }
    if($tokenName=="T_CLOSE_TAG")
    {
    	$start=0;	
    }
}

Değil bu nasıl kullanılacağını emin olun. Bir diziye tüm kod koyar. Kullanmak benim için o ben onu içeriye patlamak falan sonra silbaştan im var değil mi?