ham*_*mid 4 php permissions iframe redirect load
如何允许我的PHP文件只加载iframe?
例如:
example.com/Loader.php<iframe name="TEST" src="Example.com/Loader.php"></iframe> Ric*_*ard 12
你不会使用PHP.试试javascript.
if(window==window.top) {
// not in an iframe
}
Run Code Online (Sandbox Code Playgroud)
假设您的文件file1.php具有iframe内部和此iframe点file2.php
应该为文件file1.php的代码:
<iframe src="file2.php" width="500" height="100"></iframe>
Run Code Online (Sandbox Code Playgroud)
file2.php文件的内容:
<?php
echo "This file exist in an iframe";
?>
Run Code Online (Sandbox Code Playgroud)
所以让我们将file1.php更新为以下代码:
<?php
session_start();
$_SESSION['iframe'] = md5(time()."random sentence");
?>
<iframe src="file2.php?internal=<?php echo $_SESSION['iframe'];?>" width="500" height="100"></iframe>
Run Code Online (Sandbox Code Playgroud)
并更新file2.php如下:
<?php
session_start();
if(!isset($_SESSION['iframe']) || !isset($_GET['internal']) || $_SESSION['iframe'] != $_GET['internal'])
{
die("This page can be accessed just from within an iframe");
}
unset($_SESSION['iframe']);
//Continue processing using your own script
?>
Run Code Online (Sandbox Code Playgroud)
试试这个并告诉我这是否有效:)
| 归档时间: |
|
| 查看次数: |
7615 次 |
| 最近记录: |