English 中文(简体)
防止通过浏览器直接访问 inde.php
原标题:Prevent Direct Access to inde.php via the browser

我制作了一个酒精网站, 这个网站拥有年龄验证愿望的网关, 称为默认 。 html 是一个它在我网络空间的根部 。 我使用过两个索引文件的Joomla, 一个来自根文件夹, 另一个来自我使用的模板 。 现在我知道可以使用. htaccess 文件限制直接访问权限, 但我的问题是, 我应该把它放在根文件夹或模板文件夹里吗?

最佳回答

我在网关页面中设置了一个 cookie, 然后检查它在模板索引文件中是否存在。 所以一旦您在网关上降落, cookie就被设置了 。

这是设定饼干的代码

var theDate = new Date(); var oneYearLater = new Date(
theDate.getTime() + 31536000000       );    var expiryDate =
oneYearLater.toGMTString(); document.cookie =    "myTusker=tuskerUser;
expires=expiryDate;

然后在模板索引文件中我检查 cookie 是否被设置, 如果不是, 则重定向到网关页面, 称为默认. php。 下面是代码片断 。

$cookies = $_COOKIE;

if(!array_key_exists( myTusker , $cookies)) {

header("Location:http://zmbiz.net/tpfnew/default.php");
}
问题回答

如果它位于 template 文件夹中, 那么它只在访问该文件夹时才考虑。 因此它不是合适的位置 。

把它放到根文件夹中 。

Joomla s 模型使用站点根的索引.php 文件, 但如果您屏蔽, 站点将无法工作 。

您是否在 < a href=> http://extensions.joomla.org/extensions/ access-a-security/site-asecurity/content- restriction" rel=“nofollow” >Content 限制扩展 Jomla!扩展目录 ?

EDIT I just has a look and found this one - Age Lock - which appears to do what you want.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签