2011-12-20 6 views
0

私はいくつかのWebページのiframeを生成するためにこのコードを持っています。下のicframeのソースコードを表示する必要があります。あなたはまた、私はwww.pluspon.com/get3.phpでやろうとしているかを見ることができますすることができます文字列のようなソースコード

<?php 

error_reporting(E_ALL^E_NOTICE); 

$url = $_GET['url']; 

if(! empty($url)) 
{ 
    $data = file_get_contents($url); 

    $data = str_replace('<head>', '<head><base href="'.$url.'" /></base>', $data); 

    $data = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $data); 
    $data = preg_replace('#<iframe(.*?)></iframe>#is', '', $data); 

    $data .= 
    ' 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
    <script> 
    $("div").each(function(i){ 
     if($(this).css("position") == "fixed") $(this).css("display", "none"); 
    }); 
    </script> 
    ' 
    ; 

    die($data); 
} 

?> 


<iframe id="iframe" src="?url=http://kupime.com"></iframe></div> 

今、私はこのIFRAMEのソースコードを表示する必要がありますが、私は試してみてください。

<?php echo htmlspecialchars(file_get_contents($_GET['url'])); ?> 

けどdoen't作品。どうして?誰か教えていただけますか?

UPDATE:

<?php 

error_reporting(E_ALL^E_NOTICE); 

$url = $_GET['url']; 

if(! empty($url)) 
{ 
    $data = file_get_contents($url); 

    $data = str_replace('<head>', '<head><base href="'.$url.'" /></base>', $data); 

    $data = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $data); 
    $data = preg_replace('#<iframe(.*?)></iframe>#is', '', $data); 

    $data .= 
    ' 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
    <script> 
    $("div").each(function(i){ 
     if($(this).css("position") == "fixed") $(this).css("display", "none"); 
    }); 
    </script> 
    ' 
    ; 

    die($data); 
} 

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <meta name="author" content="Webarto" /> 

    <title>AdriaMart</title> 

<script src="http://code.jquery.com/jquery-latest.js"></script> 

<style type="text/css"> 
<!-- 
iframe{width:100%;height:400px;} 
--> 
</style> 

</head> 
<body> 

<iframe id="iframe" src="?url=http://kupime.com"></iframe> 

</body> 
</html> 
+0

の下に「動作しない」の定義のようにそれを使用し、あなたのPHPページにURLをdefineingてみてください。 –

+0

plusphone.com/get3.php - (警告:file_get_contents()[function.file-get-contents]:ファイル名は/home/pluspon/public_html/get3.phpの131行目で空にすることはできません) –

+0

私の更新完全なコードの質問 –

答えて

0

あなたはインラインフレーム内のURL変数を定義し、それ以外で使用しようとするためである。ここでは完全なコードです。

<iframe id="iframe" src="?url=$url"></iframe></div> 
+0

それを行う方法? –

+0

はすべてコードで定義されています! –

+0

Iframeはうまく動作しますが、文字列のようなソースコードではありません –

関連する問題