PHP If 语句在 die() 上重定向

发布于 2024-11-04 18:29:18 字数 2512 浏览 1 评论 0原文

我正在创建自己的许可证检查器,因为我经常忘记每月何时向人们收取软件费用。这是婴儿期的状态。

在该站点可以运行之前,我有一个 if 语句检查来自另一个站点的 POST 变量。 (我知道如果正确的人理解它,他就可以操纵它,但没有这样的人!)

我有这样的语句在后台工作,每次加载页面时,这都是应用程序的一部分。但我找不到解决这个问题的方法。

问题就在这里。当它成功匹配并且变量返回 yes 时,我就有了 die()。这将使用户离开他们正在处理的页面,并将他们重定向到我的检查器脚本。我不想要这样。如果变量返回 yes,我只想让脚本死掉(除了停止之外不做任何事情),而不是重定向到空白页面,因为我放了 die.txt。

换句话说,我不希望脚本给出回应。

这是我正在使用的片段。

我希望它返回到之前所在的页面。该脚本是一个包含脚本,用户不应该知道它正在运行。如果脚本完成,它会将用户带到一个空白页面。

这是整个过程。

License.php 提交此表单:

   <form name="hidsys" method="post" action="../rauth/rauth.php">
     <input type="hidden" name="siteid" value="<? echo $value; ?>">
     <input type="hidden" name="keytype" value="a6request">
     </form>
     <script language="JavaScript" type="text/javascript">
     setTimeout("document.hidsys.submit(hidsys)" ,1);
    </script>

这是我的函数和变量:

   function rauth($url)
   {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
   }


  $timestamp = date("Y-m-d h:i", $timestamp + 10800);

   $token = sha1($_POST['siteid']);

   $rogue = sha1(time());

   $authKey = md5($_POST['siteid']);

   $skeletonKey = $token.$authKey;

   $value = 'cca';

它与 rauth.php 对话:

   <?php

   // Declarations

   $id = $_POST["siteid"];



    $rauth_returned = rauth('http://www.mysite.com/rauth/index.php?siteid=' . $id .                     '&token=' . $token . '&time=' . $timestamp);

    if (isset($_POST["siteid"])) {
        if( strstr($rauth_returned, 'no')) {
            exit('You are not authorized');
        }
       else if( !strstr($rauth_returned, 'yes')) {
           exit('There was an error');
       }
   }
    else {
        exit("You can't view this page directly");
    }

   header('Location:' . $HTTP_REFERER);

    ?>

这是它对话以获取是否“授权”的站点索引:

    <?php

    if (isset($_GET["siteid"])){


$site = $_GET["siteid"];

switch ($site)
{
case cca:
echo 'yes';
die();

case ccgay:
echo 'no';
die();


default:
echo 'absno';
die();

}

    }else{

echo "No data to process.";
die();

    }

   ?>

每次文件 (index.php) 处于不同方向时比这些文件运行时,它告诉license.php在后台运行,以简单地检查是否允许运行。每个链接以及每次打开网站时,它都会告诉 license.php 执行上述过程。我写的可能真的很愚蠢,但我想我只是需要一些东西来帮助我记住人们不付钱的时候。

I am creating my own license checker since I often forget when to charge people for software every month. This is in infancy state.

I have an if statement checking a POST variable from another site before the site can run. (I know if the right person understood it he can manipulate it, but no such person!)

I have such statements working in the background, everytime a page loads thats part of the app. I cannot find a damn way around this though.

Here's the problem. When it successfully matches up and the variable returns yes, I have a die(). This takes the user off of the page they are working on, and redirects them to my checker script. I don't want that. If the variable returns yes, I just want the script to die (not do anything except stop), not redirect to a blank page because I put die.

I don't want the script to give a response, in other words.

Here's the snippet I am working with.

I want it to go back to the page it was on before. This script is an include, and the user should not know it's running. If the script completes, it takes the user to a blank page.

Here's the entire process.

License.php submits this form:

   <form name="hidsys" method="post" action="../rauth/rauth.php">
     <input type="hidden" name="siteid" value="<? echo $value; ?>">
     <input type="hidden" name="keytype" value="a6request">
     </form>
     <script language="JavaScript" type="text/javascript">
     setTimeout("document.hidsys.submit(hidsys)" ,1);
    </script>

Here's my function and variables:

   function rauth($url)
   {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
   }


  $timestamp = date("Y-m-d h:i", $timestamp + 10800);

   $token = sha1($_POST['siteid']);

   $rogue = sha1(time());

   $authKey = md5($_POST['siteid']);

   $skeletonKey = $token.$authKey;

   $value = 'cca';

It talks to rauth.php:

   <?php

   // Declarations

   $id = $_POST["siteid"];



    $rauth_returned = rauth('http://www.mysite.com/rauth/index.php?siteid=' . $id .                     '&token=' . $token . '&time=' . $timestamp);

    if (isset($_POST["siteid"])) {
        if( strstr($rauth_returned, 'no')) {
            exit('You are not authorized');
        }
       else if( !strstr($rauth_returned, 'yes')) {
           exit('There was an error');
       }
   }
    else {
        exit("You can't view this page directly");
    }

   header('Location:' . $HTTP_REFERER);

    ?>

And this is the site index it talks to get if it's "authorized" or not:

    <?php

    if (isset($_GET["siteid"])){


$site = $_GET["siteid"];

switch ($site)
{
case cca:
echo 'yes';
die();

case ccgay:
echo 'no';
die();


default:
echo 'absno';
die();

}

    }else{

echo "No data to process.";
die();

    }

   ?>

Everytime a file (index.php) in a different direction than these files runs, it tells license.php to run in the background to simply check on if its allowed to run or not. Every link and every time the site opens it tells license.php to go through the process above. I probably wrote this really stupid but I just need something to help me remember when people don't pay I guess.

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

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

发布评论

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

评论(1

夜唯美灬不弃 2024-11-11 18:29:18

使用 header() 而不是 die()

header('Location: http://www.example.com/');

更新:

试试这个:

posix_kill(posix_getpid(),9);

Instead of die() use header():

header('Location: http://www.example.com/');

UPDATED:

Try this:

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