开发者

PHP If Statement redirects on a die()

开发者 https://www.devze.com 2023-03-02 20:44 出处:网络
I am creatingmy own license checker since I often forget when to charge people for software every month. This is in infancy state.

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.


Instead of die() use header():

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

UPDATED:

Try this:

posix_kill(posix_getpid(),9);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号