Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Ever wondered how someone posts the source of their PHP, and in color? Here's how! http://us4.php.net/manual/en/functio...light-file.php

    Step 1: save the following code as source.php

    PHP Code:
    <html>
    <head>
    <title>Source Display</title>
    </head>
    <body bgcolor="white">
    <?php
        $script 
    getenv("PATH_TRANSLATED");
        if (!
    $script) {
            echo 
    "<br /><b>ERROR: Script Name needed</b><br />";
        } else {
            if (
    ereg("(\.php|\.inc)$",$script)) {
                echo 
    "<h1>Source of: $PATH_INFO</h1>\n<hr />\n";
                
    highlight_file($script);
            } else {
                echo 
    "<h1>ERROR: Only PHP or include script names are allowed</h1>"
            }
        }
        echo 
    "<hr />Processed: "date("Y/M/d H:i:s"time());
    ?>
    </BODY>
    </HTML>
    From here, there are 2 ways to go.

    If you have access to your server's httpd.conf file, add the following into it:
    <Location /source>
    ForceType application/x-httpd-php
    </Location>
    From here, all you would have to do is to reference your code like so: webdesignforums.net/source/whatever.php

    If you don't have access to your httpd.conf file, then you can reference the same file like so:
    webdesignforums.net/source.php/whatever.php

    Note: Either way you go, don't forget to replace webdesignforums.net with your domain name. And this will only work with php files in the same directory or in a sub-directory, so this will not work with php files hosted on other sites. Because PHP is a server-side language, this is not possible.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  2.  

  3. #2
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    Actually there is a much easier way to do this.

    PHP Code:
    <?php
     
    $file 
    $_GET["file"];
     
    show_source($file);
     
    ?>
    Save that file as source.php and you have it. You can then view the source of a file by going to http://www.my-site.com/source.php?file=whatever.xxx

    Obviously, you will get errors if the file does not exist, or if you don't have proper permissions on the file.
    -drews
    -White Fiber Hosting - Coming Soon!

  4. #3
    Member
    Join Date
    Dec 2004
    Posts
    67
    Member #
    8452
    Liked
    1 times
    Even easier. If you have a properly done php/apache server, just name it as a .phps

    It will show it in color, as well :-D

    ::coughs:: http://www.webdesignforums.net/php_a...ode_18115.html
    Brian : This must be the physics department.
    Chris : That explains all the gravity.

  5. #4
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    correct, however some people don't have the ability to change their apache settings.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  6. #5
    Junior Member
    Join Date
    Oct 2005
    Posts
    4
    Member #
    11607
    is there a way out ?

  7. #6
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Quote Originally Posted by Detective
    is there a way out ?
    What are you talking about?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  8. #7
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    Quote Originally Posted by Wired
    What are you talking about?
    I think he is talking about how to get out of this thread! LOL :classic:

  9. #8
    Member
    Join Date
    Dec 2004
    Posts
    67
    Member #
    8452
    Liked
    1 times
    Quote Originally Posted by jbagley
    I think he is talking about how to get out of this thread! LOL :classic:
    wtf?? lol
    Brian : This must be the physics department.
    Chris : That explains all the gravity.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:51 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com