我的核心应用程序有很多脚本
include('JS/gramp.php');
include('JS/est.php');
include('JS/curest.php');
include('JS/memomarker.php');
include('JS/local----------.php');
include('JS/poirel.php');
include('JS/maplayers.php');
include('JS/trafficinc.php');
include('JS/plannedtraffic.php');
include('JS/transportissues.php');
include('JS/cams_traff.php');
include('JS/places2.php');
现在这些都被移动到飞行加载,以减少加载时应用程序的大小
if(button_case_curtime==true){
$(".jsstm").load("<?php echo $core_dir; ?>JS/curresttime.php?la=<?php echo $caseset['iplat']; ?>&lo=<?php echo $caseset['iplong']; ?>&h=<?php echo $days_h; ?>");
rendermap = true;
}
问题!应用程序要求这些文件是安全的,所涉及的数据要求没有人可以访问。
将要求这些文件的ONLY文件将是 index.php
任何输入或想法都会很棒!
答案 0 :(得分:1)
如果没有将文件提供给用户,则无法向浏览器提供文件。
您可以将服务器配置为仅提供给定额外HTTP标头的文件(您可以使用JS添加),但没有什么能阻止人们手动发送该标头或只是从浏览器的调试工具中挖掘出来源。 / p>
您提供文件的任何用户都可以访问这些文件。如果您想限制哪些用户可以访问它们,那么您必须使用auth / authz(您也希望将其应用于index.php文件,以便未经授权的用户不会仅获得JS错误或无提示失败状态)。
答案 1 :(得分:0)
没有。你想要做的是不可能的。 Ajax请求并不特殊。它们只是HTTP请求。为Ajax创建的端点应该使用身份验证/授权进行保护,就像任何其他HTTP请求端点一样。
答案 2 :(得分:0)
这是一个简单的解决方案,可以解决您的问题。通过POST请求请求它们,如下所示:
$.post('JS/maplayers.php', {'ajax':true}, function(){});
注意POST变量'ajax'。在文件maplayers.php中,将以下代码添加到开头:
if((!isset($_POST['ajax']))) {
die('Invalid request, only ajax requests are permitted');
}