Log in

View Full Version : Need help with translating ASP code to PHP


skogen
03-08-2005, 05:45 AM
I've found that it's possible to check if a user logged in with this code

if ($bbuserinfo[userid])
{
// CODE TO EXECUTE IF USER IS LOGGED IN
}

On my (currently Snitz) board we have a function that allow users to download files (not from the forum but from the site)

I need help how to change this pice of ASP code into PHP so I can put it on the above posted code.

<%

strFile2Show = Request.QueryString("asset")

Response.Redirect "../DOWNLOADS/" & strFile2Show

%>


Thanks


/Fredrik

why-not
03-08-2005, 11:59 AM
Hi

To do this your way, which is not the best way do this!

do this!


header ( 'Location: ../DOWNLOADS/' . $_REQUEST['asset'] );

exit ();



To do it so that you validate the request (don't do something if something does not exist)

Then you would this!!!


<?
// system path to files windows full path ie: 'c:/www/docs/files/'

$system = './http_docs/files/';

// url to the files directory!

$url = '/downloads/';


if ( ! empty ( $_REQUEST['asset'] ) && is_readable ( $system . $_REQUEST['asset'] ) )
{
header ( 'Location: ' . $url . $_REQUEST['asset'] );

exit ();
}
else if ( empty ( $_REQUEST['asset'] ) )
{
echo 'no valid file request sent';
}
else
{
echo 'file not found';
}
<?




Sonia