Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Looks safe to me!


Aaron
 Share

Recommended Posts

<?php
if(!$file){
   if(isset($_GET['file'])){
       $file = $_GET['file'];
   }
}
function highlight_num($file){
   $lines = implode(range(1, count(file($file))), '<br />');
   $content = highlight_file($file, true);
   echo '
       <style type="text/css">
           .num {float: left;color: gray;font-size: 13px;font-family: monospace;text-align: right;margin-right: 6pt;padding-right: 6pt;border-right: 1px solid gray;}
           body {margin: 0px; margin-left: 5px;}
           td {vertical-align: top;}
           code {white-space: nowrap;}
   </style>';
   echo "<table><tr><td class=\"num\">\n$lines\n</td><td>\n$content\n</td></tr></table>";
}
/* Call on the function via a $_GET */
if(isset($_GET['debug']) && $_GET['debug'] == "num"){ //make it so it has numbered lines.
   highlight_num($file);
   exit;
}
else if(isset($_GET['debug'])){ //default without numbered lines.
   highlight_file($file);
   exit();
}
?>

Link to comment
Share on other sites

The code does look fine, except for the fact that we could look at the source of any php file on your server.
You are the only person i've seen yet were i've posted this find that.. Thank you! I added that just to see if anyone could find it.

 

And I posted it so people would use it ;D

Link to comment
Share on other sites

Guest The_Monkey
You are the only person i've seen yet were i've posted this find that.. Thank you! I added that just to see if anyone could find it.

 

And I posted it so people would use it ;D

 

But use it for what? And why do you feel the need to test people?

 

Next thing you are going to do is post stupid forms with SQL injection vulnerabilities. Stop the madness and make a point next time.

Link to comment
Share on other sites

Guest The_Monkey
For debugging their code if they aren't able to view line numbers with highlighted code.

 

That is a shitty way to debug code...might as well go into your editor and look at the code that way.

 

You would be better off writing a debug class in PHP. I'll provide a screen shot of our class at the college in action.

 

debug.gif
Link to comment
Share on other sites

Guest The_Monkey

If you want to view any file on your server...do the following:

 

1. Get an editor (I like jEdit, it runs off of the java run time)

2. Put in FTP credentials, or if directly networked to the server, access it via the file system

3. Open file in editor

4. ????

5. Profit

 

+++++++EDIT++++++++

 

If you have to write code to view the files on your server, UR DOING IT WRONG!

Link to comment
Share on other sites

Guest The_Monkey
Say I update a file then later on I find out it has an error and I want to find the line REALLY FAST without having to open Dreamweaver then this would help.

 

That right there is an oxymoron.

 

Stop writing PHP in dreamweaver!

 

Use an actual editor, and really fast will be faster than viewing the code in a web browser.

Link to comment
Share on other sites

Guest The_Monkey
Notepad++ or GTFO

 

There are other editors out there besides Notepad++, so you GTFO.

 

Dreamweaver is a WYSIWYG more so than an editor.

 

I use jEdit because of it's awesome macro support. I can create a new project on my dev server that will setup all of the base classes and files needed in seconds.

Link to comment
Share on other sites

Notepad? lol

That's what I use, but it's just for Perl... so nothing special there.

I have Visual Studio 2010 for C++ and other languages (but I don't code, maybe a bit of Vbasic though). Like Monkey said, there are soo many IDEs and editors out there... >.<

Edited by enigma#
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share