vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Need help with translating ASP code to PHP (https://vborg.vbsupport.ru/showthread.php?t=77707)

skogen 03-08-2005 05:45 AM

Need help with translating ASP code to PHP
 
I've found that it's possible to check if a user logged in with this code

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.

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!

PHP Code:

        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!!!

PHP Code:

<?
    // 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


All times are GMT. The time now is 09:24 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00998 seconds
  • Memory Usage 1,715KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete