• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

see php code

cmsms
content management system made simple

is there a way to see the php code when logging on to admin using a browser
0
rgb192
Asked:
rgb192
  • 3
  • 2
  • 2
2 Solutions
 
Darude1234Commented:
Want do you mean exactly? PHP-scripts are executed on the server so they can't display the code by default.
However there are ways to display php code of script for example:

<?php
     if (isset($_GET['file'])) 
       {
         $page = highlight_file ($_GET['file'], TRUE); 
         $page = str_replace ( 
         array ( '<code>', '/code>', '','</ are >','<font color ="'), 
         array ( '<pre style="padding:1em;border:2px solid black;overflow:scroll">', '/pre>', '','</span>','<span style = "color:' ), $page); 
         echo $page;
       } 
  ?>

Open in new window


Save this file as show_code.php and include it from the page you want to show the code in for example:
<?php
include("show_code.php?file=anyphpfile.php");
?>

Open in new window

0
 
rgb192Author Commented:
I wish I could do that,
but I can only use the browser.

0
 
Darude1234Commented:
Do you mean that you don't have access to the server/php files?
You can only display the php-files if you have access to the server. It's not that you can view a php-file of a random website that is running php.
That would be a big security leak ;)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ray PaseurCommented:
When a browser (called a "client") makes a request for a page from a server (called a "server") the server prepares a response string including headers and browser output.  Browsers use HTML to mark up and format the data from the server.  PHP scripts generate this HTML on the server, and then the server sends the HTML to the client machine.  The PHP code is never sent, just the HTML statements it generates.

But good news: http://www.cmsmadesimple.org/ is open source, so you can grab a copy and install it on your local machine.  Then you can see the PHP code.

My own IDE goes like this.  I use TextPad or NotePad++ to write PHP code.  When I am ready to test, I upload the PHP code to a URL on my server using an FTP client.  Then I visit the URL and see what the PHP code creates.  I do not need to see the PHP code on the server because I have a copy of it in front of me on my machine.

HTH, ~Ray
0
 
rgb192Author Commented:
May not be a security risk because i am Given browser admin access to files and filemanager. Could I download the php files and view them on my computer.
0
 
Ray PaseurCommented:
Could I download the php files and view them on my computer.

Yes, if you have "read" access to the files.  And you can replace the files if you have "write" access.  There are any number of FTP clients that can help with this.
0
 
rgb192Author Commented:
one answer is to create a browser script another answer is to just use ftp.
both work, thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now