SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $http_server_vars replacement ?

    Hey,

    Just upgrade to a newer version of php (ver 4.3.8) and of course some of my older code does not work. I like to know how to get this statement to work properly in the current version of php

    PHP Code:
      <?
       $base 
    $HTTP_SERVER_VARS['DOCUMENT_ROOT']."/folder1/tut/";
        
    // Open a known directory, and proceed to read its contents 
               
    if (is_dir($base)) { 
                   if (
    $dh opendir($base)) { 
                      while ((
    $file readdir($dh)) !== false) { 
                           if (!
    is_dir($base $file) && $file !== '.' && $file !== '..') { 
                                echo 
    "<option value='$file'>$file</option>"
                                        } 
                                       } 
                               
    closedir($dh); 
                              } 
                             }

    not sure how to change $HTTP_SERVER_VARS['DOCUMENT_ROOT'] and what to replace it with.

    Thanks in advance !
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_SERVER


    Edit: Goddamnit, vB makes it lower case because it's "shouting"

  3. #3
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    $_SERVER


    Edit: Goddamnit, vB makes it lower case because it's "shouting"
    PHP Code:
     $base $_SERVER['DOCUMENT_ROOT']."/folder1/tut/"

    I did this and it did not work ....
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the problem? You gotta be specific.

    Output $base, see what it is.. and you might wanna use glob now that it's PHP 4.3. http://php.net/glob bit easier than opendir

  5. #5
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry...
    I want the script to be able to find the physical location of the folder. The old script with $http_server_vars['document_root'] was able to find the root directory. I want to get the same result, instead everytime I move the script to another folder etc... i have to go in there manually and change $base to point to the current directory.

    Not sure on how to use glob()
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just go to http://php.net/glob it tells you.

    Physical location of which folder? By that I mean, relative to current. Like you want
    /folder1/tut
    Relative how? Is folder1 in the current directory, the previous one, etc.? You don't need to do the full path, a relative path should be sufficient.

  7. #7
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help i fixed it,

    But I did not use glob. I look into it more.

    Thanks again
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Tera,

    glob looks interesting but you do need the $_SERVER global variables which have replaced the depricated $HTTP_SERVER_VARS.

    To find your script location,
    PHP Code:
    $scriptlocation $_SERVER['SCRIPT_FILENAME']; 
    Quote Originally Posted by php.net
    The absolute pathname of the currently executing script.
    If you need to, strip the scriptname with
    PHP Code:
    $scriptlocation substr($scriptlocation,0,strrpos($scriptlocation,"/")); 
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  9. #9
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DK thanks man !

    That was exactly what I was looking for.

    I was not sure what to place with the brackets of the $_SERVER.

    OneX Square Creation
    One man said Why ? ... Another man said Why not ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •