PHP - 使用 GET 包含 cms(位于 Web 根目录之上),如何包含 cms 索引中的其他文件?

发布于 2024-12-28 20:25:10 字数 1140 浏览 2 评论 0原文

我试图隐藏我的网站 cms 应用程序...

所以我想我会添加一些 php 到我网站上的任何随机页面,其中包括对某些随机字符串的 GET 引用...所以基本上,如果您转到 x页面,并添加 ?RANDOMSTRING 包含 cms 索引。它存储在 Web 根目录之上...这是 php 的一部分:

if (isset($_GET['J7sd-H3sc9-As3R']))
{
require_once($docRoot . '/../../includes/admin/index.php');
}

基本上,index.php 被布局为具有 3 个字段集的页面。在 3 个字段集中是与处理各种任务的各种应用程序相关的各种链接。它们的访问方式与上述代码相同。它们保存在 Web 根目录中,并且能够通过 http 进行访问...

一切都工作得很好,但是当我尝试访问 cms 的任何特定部分时,问题就出现了...所以会发生什么:

http://www.mysite.com/admin/part/

现在是:

include($_SERVER['DOCUMENT_ROOT'] . '/../../includes/admin/part/index.php');

或者类似的东西...

所以现在当我转到我的页面

http://www.mysite.com/randomDirectory/

并添加:

http://www.mysite.com/randomDirectory/?J7sd-H3sc9-As3R

我被发送到我的cms...酷...但是当我尝试单击任何部分时我得到这个标题:

http://www.mysite.com/randomDirectory/?part

并且页面刷新为:

http://www.mysite.com/randomDirectory/

如果这是有道理的...

可以向我提供有关该任务的任何意见或建议吗我正在努力实现什么?我不确定是否可以开始,但看起来很简单。

任何答复将不胜感激,谢谢!

I am trying to hide my websites cms application...

So i thought i would add a bit of php to any random page on my site, that includes a GET referance to some random string... So basically, if you go to x page, and add ?RANDOMSTRING the cms index is included. This is stored above the web root... Here is the peice of php:

if (isset($_GET['J7sd-H3sc9-As3R']))
{
require_once($docRoot . '/../../includes/admin/index.php');
}

Basically, index.php is laid out as a page with 3 fieldsets. In the 3 field sets are various links relating to various applications that deal with various tasks. They were accessed through the same means as the above code. And they were held in the web root and were able to be accessed via http...

That all worked perfectly fine, But the problem now comes when i try to access any specific part of the cms...so what would have been:

http://www.mysite.com/admin/part/

is now:

include($_SERVER['DOCUMENT_ROOT'] . '/../../includes/admin/part/index.php');

Or something of the sort...

So now when i go to my page at

http://www.mysite.com/randomDirectory/

and add:

http://www.mysite.com/randomDirectory/?J7sd-H3sc9-As3R

I get sent to my cms... Cool... But when i try to click on any section i get this header:

http://www.mysite.com/randomDirectory/?part

and the page gets refreshed to:

http://www.mysite.com/randomDirectory/

If that makes sense...

Could any provide me with any input or suggestions regarding the task that i am trying to accomplish? I am not sure if it is even possible to start off with, but it seems simple enough.

Any replies would be greatly appreciated, Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身仙ぐ女味 2025-01-04 20:25:10

我想您应该在页面中的每个链接末尾附加类似

<?php if (isset($_GET['J7sd-H3sc9-As3R'])) echo '?J7sd-H3sc9-As3R'; ?>

示例:

http://www.mysite.com/randomDirectory/randomPage<?php if (isset($_GET['J7sd-H3sc9-As3R'])) echo '?J7sd-H3sc9-As3R'; ?>

编辑

更简单的方法是使用会话,如下所示

<?php

session_start();

if (isset($_GET['J7sd-H3sc9-As3R']))
{
    $_SESSION['token'] = 'J7sd-H3sc9-As3R';
}

if (!isset($_SESSION['token']) || $_SESSION['token'] !== 'J7sd-H3sc9-As3R')
{
    exit;
}

// go on with your page

?>

:这样,当您打开 url 中包含令牌的页面时,会话就会启动,并且令牌会保存在会话中,因此它应该可以正常工作,而无需在每个 url 中插入令牌,直到您关闭浏览器。

I guess you should append at the end of every link in your page something like

<?php if (isset($_GET['J7sd-H3sc9-As3R'])) echo '?J7sd-H3sc9-As3R'; ?>

Example:

http://www.mysite.com/randomDirectory/randomPage<?php if (isset($_GET['J7sd-H3sc9-As3R'])) echo '?J7sd-H3sc9-As3R'; ?>

edit

An easier way to do this would be to use sessions, in this way:

<?php

session_start();

if (isset($_GET['J7sd-H3sc9-As3R']))
{
    $_SESSION['token'] = 'J7sd-H3sc9-As3R';
}

if (!isset($_SESSION['token']) || $_SESSION['token'] !== 'J7sd-H3sc9-As3R')
{
    exit;
}

// go on with your page

?>

In this way, when you open a page with your token in the url, the session is started and the token is saved in the session, so it should work without the need to insert the token in every url until you close your browser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文