Results 1 to 10 of 10

Thread: Viewing php code from php server

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Question Viewing php code from php server

    Anyone know how do review the php code in server? Normally the php code will be process by the server before sending back to client. Is that anyway from a client that i can request the source code from the server? Just want to know is that impossible. Thanks in advance.
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Re: Viewing php code from php server

    A references web site. Search on google ^_^. But still i am interested to know if any ways that could used.
    http://www.dynamicdrive.com/forums/a...hp/t-8062.html
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Re: Viewing php code from php server

    Seems like if we request with the http or https is imposible to get the source code. Only if we used other protocols like ftp or SFTP we can get the raw files. Which means that the code is acctually secured by the protocols it self. But is there anyway to prevent the server to process the php page and sent the raw code? Should be no. That was secure by apache. Anyway, I am still hopng for an answer.
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Viewing php code from php server

    After the script is parsed by PHP itself, it sends the page to the webserver, which then serves it to the client. If you used fopen() or file_get_contents() to open a PHP script on an external link (ie: http://www.domain.com/index.php), the script will be parsed by PHP and the output given to YOUR PHP script would be only the HTML given out by domain.com/index.php, if that makes any sense to you. The only way you could possibly get the source of another page online would be if your script was physically located on the same server and you had the permissions to browse to that directory on the file system (ie: C:/webroot/index.php, or /usr/home/web/index.php), and then opened the file directly. you can't do what you're trying to do with the HTT protocol. I hope I got most of that right.

    however, if you're looking to make a script that just prints out the source of another script on YOUR server to let people view it through their browser, it's easy: just use fopen().
    Like Archer? Check out some Sterling Archer quotes.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Re: Viewing php code from php server

    So does it means that there is no way we can view a php site through HTTP or HTTPS protocols from the client site? The server will process all the php script and pass back only plain HTML to the client. The fopen is script from server, not client...
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  6. #6
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Viewing php code from php server

    I didn't say fopen() was used by a client.. :/

    no, you can't get the source of a PHP file using HTTP.
    Like Archer? Check out some Sterling Archer quotes.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Re: Viewing php code from php server

    Thanks but the answer is disappoint.
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Viewing php code from php server

    Can you imagine how much of a security issue it would be if server-side code that handled sensitive data could be requested from a client using simple HTTP?

    If you want, you can add something like this to the top of a file that you don't mind showing the source for:
    PHP Code:
    if (isset($_GET['source'])) {
      
    readfile(__FILE__);
      exit();

    and call the file using ?source as the query string.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    64

    Re: Viewing php code from php server

    I get your point, we shouldn't able to view the source from client. I am just curious on how people can hack into server by using only HTTP or HTTPS protocol. Thanks anyway
    </HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
    <?PHP
    $j=0;
    for($j=0;$j<=9999;$j++){
    echo 'Why job is so boring<BR>';
    }
    ?>
    Just want to test does it works?

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Viewing php code from php server

    You can't by principle, only if there is some security vulnerability in the web server.

Posting Permissions

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



Click Here to Expand Forum to Full Width