Jump to content

How to output the page generated from an included PHP script in a new window.


sjohns

Recommended Posts

I am attempting to output the page that is generated from an included PHP script in a new browser window, but have had no success in doing so.

 

The following generate_url.php script will generate a one time key that will allow a new user to download a file when they log in to my mambo based web site for the first time after registration. This script is included by the login script only if it is the new user's first login; fine so far. The problem is that I need it to pop a new browser window and output the generated page into this window. As written, the script will run, but the output cannot be seen because the login script process will then complete and the user will only see the site home page. Any help in doing this would be greatly appreciated.

 

<?

/*

* generate_url.php

*

* Script for generating URLs that can be accessed one single time.

*

/** ensure this file is being included by a parent file */

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

 

 

/* Generate a unique token: */

$token = md5(uniqid(rand(),1));

 

/* This file is used for storing tokens. One token per line. */

$file = "/tmp/urls.txt";

if( !($fd = fopen($file,"a")) )

        die("Could not open $file!");

 

if( !(flock($fd,LOCK_EX)) )

        die("Could not aquire exclusive lock on $file!");

 

if( !(fwrite($fd,$token."\n")) )

        die("Could not write to $file!");

 

if( !(flock($fd,LOCK_UN)) )

        die("Could not release lock on $file!");

 

if( !(fclose($fd)) )

        die("Could not close file pointer for $file!");

 

/* Parse out the current working directory for this script. */

$cwd = substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/"));

 

/* Report the one-time URL to the user: */

 

print "<a href='http://".$_SERVER['HTTP_HOST'].

      "$cwd/get_file.php?q=$token'>\n";

 

print "http://".$_SERVER['HTTP_HOST']."/get_file.php?q=$token</a><br><br>\n";

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.