coolcat50
Oct 27 2007, 08:22 PM
Hello! I have just came up with a sweet script to show the source code of any website and it only requires one file. This is the basis of the script and can be customized with CSS and other things and can be instituted as a public resource. Well I will provide the code and a step-by-step tutorial on each of its parts. This code has been tested by me. Enjoy! CODE <?php //This little tag starts our php script and is easily the most important part of the script.
//We will start our base script here. //You can change some of the styles used here to your desired color.
if ( $_GET['page'] == 'source' ) //This line starts our source code page. //There are 2 'pages' to he script. //Both are defined with the get superglobal. {
if ( isset ( $_POST['submit'] ) ) //This line checks our input to make sure submit was clicked. {
//We will define our variables here. $file=$_POST['file']; //This gives us our variable for the file. //Lets check to see if a file was entered. if ( !$file ) { die("Sorry, you did not enter in a file to view.") } //Then we proceed
//Here you could add a user verification var. //Such as a password or a verification number. //For now lets use a verification number $userverify=12345; //The user must enter this field in order to proceed.
//Lets check and see if our user entered the verification number. if ( $_POST['verify'] == $userverify ) //Checks verification {
//Ok, lets get our script going.
echo "<div style=\"background-color:yellow\">; //Ok that sets where the code will show. //Lets show our file url echo "File URL:" . "$file" . "<br />"; //There. Now lets use a rule to seperate the url and source. echo "<hr />"; //Now lets show the user the source code. show_source($file); //There we go //Now lets close up this if statement echo "</div>"; }//End user verify //If the user did not enter the verification else { echo "Sorry, you did not enter in the correct number. Try again." }//Ends error notification
//Lets end our submit statement }
//Now we need to set a statement that if the user did not submit anything. //An error pops up. else { die("Sorry, you shouldn't be viewing this page. Please go back."); } //Now we end our page statement } //now we start an else statement if they did not visit the source page else { ?> <!-- We end the php block for now and focus on html --> <form action="url_source_viewer.php?page=source" method="post"> <!-- There we set up our form and you must fill in the url statement with the appropriate url of the source page --> <input type="text" name="file" value="File URL Here" /> <!-- That defines our input form for the file --><br /> <input type="text" name="verify" value="Verification Number" /> <!-- There is where the user will enter the verification number --><br /> <!-- Now lets display our verification number --> <p>Verification Number: <?php echo $userverify; ?></p><br /> <!-- There we echo out the number --> <input type="submit name="submit" value="See Source" /> </form> <?php //We now need to end our else statement. } //And that is the code. If you copy and paste it please give me some credit. //This is a 'tutorial' that is supposed to teach and provide a resource. //Thank you ?> Live Demo: Source Viewer DemoThere is my code. Also, feel free to move it to tutorials, I just felt that it should be under PHP programming. Thank you for reading.
Reply
jlhaslip
Oct 27 2007, 09:52 PM
Looks great. That yellow background will wake them up... Thanks for the Demo and the script. Nice work.
Reply
truefusion
Oct 28 2007, 12:07 AM
Here's a similar script only without syntax highlighting but line numbers and line highlight. CODE <?php
echo "<html> <head> <title>Source Code Demo</title> <style type=\"text/css\"> body { margin: 0; padding: 0; }
td.auto { content: counter(number); counter-increment: number; padding: 5px; margin-right: 5px; background: #eee; color: black !important; }
td { padding: 5px; font-size: 11px; font-family: Sans, Arial; }
td.content:hover { background: #eee; } </style> </head> <body>\n";
if ($_GET['page'] == "source" && isset($_POST['submit'])){
$filename = $_POST['file'];
if (!empty($filename) && $filename != ""){ $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle);
$contents = str_replace("<", "<", $contents); $contents = str_replace(">", ">", $contents); $contents = explode("\n", $contents);
/* $contents = highlight_string($contents, true); $contents = explode("<br />", $contents); */
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
foreach ($contents as $value){ echo "<tr> <td class=\"auto\"></td> <td class=\"content\">".$value."</td> </tr>\n"; }
echo "</table>";
} else { die ("No file declared."); }
} else { echo "<form method=\"post\" action=\"?page=source\"> <input type=\"text\" name=\"file\" value=\"File URL Here\" onclick=\"this.value='';\" /> <input type=\"submit\" name=\"submit\" value=\"View Source\" /> </form>"; }
echo "</body> </html>";
?> Syntax highlighting, as you can see, i commented out because it doesn't cover the entire syntax, since the SPAN element gets split up along the way. I also did not include any "verification number," for if it's going to be shown on the page, why include it?
Reply
coolcat50
Oct 31 2007, 09:00 PM
Sweet! How would you add line numbers to my script? Also, I know hwo to make it safer. Change the php.ini file to make the php colors be white and change HTML to a different color? Security reasons for that.
Reply
suberatu
Nov 1 2007, 03:05 AM
While I don't actually understand the php programming fully, I can see that this is indeed a VERY useful script. One quick question though, does the htaccess configuration of the page you are trying to view matter? I.e.: If you were trying to view a source of a page that would usually give you a 403 error (Forbidden, you do not have access, etc.) would you also be blocked from viewing the source through this script?
Reply
coolcat50
Nov 2 2007, 12:15 AM
I do not know exactly, but I do believe it will show because you aren't viewing the page but its source. Test it out and post here. One thing for sure it bypasses the Javascript anti-right click code.
Reply
truefusion
Nov 2 2007, 04:53 AM
QUOTE(coolcat50 @ Oct 31 2007, 05:00 PM)  Sweet! How would you add line numbers to my script? Also, I know hwo to make it safer. Change the php.ini file to make the php colors be white and change HTML to a different color? Security reasons for that. Similar to how i did to mine. In your code, you're outputting the file directly. You have to turn it into a string and add 'true' to the return parameter: CODE $source = show_source($file, true); And in my script, pretend $contents is $source, and remove CODE $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); QUOTE(suberatu @ Oct 31 2007, 11:05 PM)  While I don't actually understand the php programming fully, I can see that this is indeed a VERY useful script. One quick question though, does the htaccess configuration of the page you are trying to view matter? I.e.: If you were trying to view a source of a page that would usually give you a 403 error (Forbidden, you do not have access, etc.) would you also be blocked from viewing the source through this script? Viewing the source is dependant on your browser. If you run into a 403 forbidden error page and you view the source, you'll just see the HTML of the 403 forbidden error page.
Reply
coolcat50
Nov 2 2007, 09:34 PM
hmm yeah. also with this 403 error pages this could very likely bypass that filter. i will test that out
Reply
Recent Queries:--
source code viewer script - 308.46 hr back. (1)
Similar Topics
Keywords : awesome, source, code, viewer, script
- How To Make Php Newsletter Script
(3)
Php Guest Online Script
(3) make an index.php copy and paste this code CODE <?php $db_host = "localhost";
$db_user = "root"; $db_pass = ""; $db_name = "test";
$dbc = mysql_connect($db_host, $db_user, $db_pass); $dbs =
mysql_select_db($db_name); $tm = time(); $timeout = $tm -
(30*60);
if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR
"];} else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}....
How To Make A View New Post Script?
(5) Ok so i'm still working on the forum software i posted about a while back, but I have no idea
how to do this. I want to make a view new post script, as this is one of the main things that my
forum software dose not have that all other forums have. so does any body have an idea on how i
would do this? Thanks.....
Guessing Php Script
(2) I am looking for: freeware php quess the person in the photo game script....
Create Table - Mysql Code - Help
(1) I need your feedback about setting the database issues. Please, review them and correct some entries
in the code if they got some mistakes. This is the code itself: SQL CREATE TABLE
`news` ( `id` int(250) NOT NULL auto_increment, `title` varchar(255)
NOT NULL default '', `text` text NOT NULL, `author` varchar(255) NOT
NULL default '', `valid` varchar(255) NOT NULL default '',
`date` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE = ....
Php Source Code Unveiled In Browser?
is that possible? (7) I am quite new to PHP and this concern came to my mind after playing around a bit with it... When
PHP is not correctly configured on the web server the source code of a php file we try to access
through a browser will be shown instead of the result of the code itself. This will normally not
happen when PHP is working properly, but I was just wondering if it could still be possible to see
that code if a user wanted to or if something on the server failed. This would for example expose
sensitive information like mysql passwords and so on... Is anything like that possib....
Malicious Code Injection
(3) Hi everyone! This is my first post, so be kind! Basically, I'm trying to get a free
host together so am writing some posts. Here's a little summin' summin' about malicious
code injection with PHP applications. Basically, this security exploit is one of the oldest tricks
in the books and all comes down to the fact that PHP allows execution of both local and remote
scripts with the SAME function... dur. Anyway, this is how it works. Image you've just employed
a young go getter, straight outta uni, who has found becoming a Jack of all trades a ....
Php And Mysql Programming
anyone knows a code for mysql and php (2) hi everyone! I am making a program using php and mysql...I am a noob on this so i need your
help guys...I want to make a simple program that will some values and then store them on a database
and then retrieve them...uhmm let me give an example out put of what i need. This is the example
say..: Enter First Name: Enter Last Name:
Enter Age: Enter Address: ..those
are the data needed for input values...my question now is how can I make a database....
Need Help Installing Dolphin Community Script!
(5) I'm not sure if this is the right place to post this but I really need help in installing the
dolphin community script. I have absolutely no previous experience of scripts or programming. I
would really appreciate if someone could walk me through it step-by-step, or even do it for me by
logging into my cpanel. I have tried to install it my self but I'm a little confused. I'm
sure it won't take very long at all for someone who has done this before.....
How Do I Connect To Live Database With Php Script?
while being hosted with ComputingHost (6) I am not new to programming. I want to create a form to add some values into my tables, the code
are all working. But I am not sure what is the URL to connect to my site's database. All along,
I have been testing through MAMP, which provides a local copy of mySQL. Can anyone lend me a hand?
My site's URL is http://limetouch.com/ ....
Download Script For Mp3 Files
(0) Hello, I'm looking for a download script for sound files (e.g. mp3, avi, wma, and other ones).
i have found a few download scripts but they would not work for sound files for some reason. also
this will not be used for allowing downloading of illegal or riped music, what i will be using this
script for is i'm making a site for my church and the pastor wants to be able to recored the
services and then have me upload them to the site so that the church members can download them for
what ever reason. If some one could tell me how to make one or could show me a plac....
Php Code Needed Iii
(10) Hello, everyone. I need your help again! Who might create the PHP code, the picture is
above this text. Basically, I want when the user fill in all the information in this form, it
automatically was sent to my email. And, then, the dialog box appears or on the same window, it was
said that your request has been sent. Moreover, if the user did not fill the entire information,
the dialog box appears stating that you did not fill some field. Thanks, for help. You always do
that.....
Php Code?
Mathematical Applications (12) Hello, everyone. The help is needed again. How can I make calculator in PHP language? That will act
like that a user just type in the fields known values, then click the button, and it's going to
be solved automatically. In other words, have can I write a formula in PHP, how to plug it inside
that language. For example, the formula to find a peremeter of square is: P=4a. So, a user
just can write the known value which is peremeter itself and it will find the side of a square; and
vice versa. If you can write many things how to do such formulas, such as comp....
Php Code Needed
Working Together? (5) Hello, everyone. I need your help again. This forum is quite good for it. Well, I need create a
registration form for my web-site using PHP and SQL. The information it should contain: 1) User
Name 2) First Name 3) Last Name 4) Password 5) e-mail Address 6) Security Image: that images helps
to protect a random registration, for instance, 56+2=where user have to type an answer in order to
finish registration. That's all for today. Anymore things, I will post another post over here.
....
Php Rediret Script
(12) Ok, what I am trying to do is this. Re-direct a domain name called: avalon.asn.au to
preschool.stmarksavalon.org.au I have created a script that will re-direct within the a folder.
However, the avalon.asn.au and stmarksavalon.org.au are PARKED Domains. Any ideas on how to create
this PHP Redirect Script please?....
Script Help Required: Undefined Variable
A fault I cannot spot in PHP (3) Hi, when running a PHP script I keep getting the error: QUOTE Notice: Undefined variable: bret
in c:\program files\easyphp1-8\home\poll.php on line 294 Notice: Undefined
variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294 (And,
yes, I get it twice). The code related to the variable is as follows: CODE function
LogString($string,$type) { $t_log = "\n";
$t_log .=
$this->globaldata->server_vars['REMOTE_ADDR']."....
Php Downloads Script
(4) I've been looking all over the net for a PHP script which can provide an interface to browse a
downloads database. The database could be powered by MySQL. If you know a script like this, please
post it here. Thanks in advance, Ironchicken.....
Html Code Tester. Online Script
(15) Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
Current script: CODE <?php //Save this as something like htmltest.php function
CheckForm() { $html_unsafe=$_POST['code']; //Gives us our user
input $html_safe=str_replace("<?php"," ",$html_unsafe);
//Starts security measures $html_safe=str_replace("?>","
",$html_sa....
Very Simple Online Now Script
This is a very simple online now script. (4) Hi all, Its Aldo. anyways, I wont be using the method of pagination, i will just tell you how to
make a basic online now script. When someone logs in, now take into consideration that the name of
the username input is username ( First ,create a table in your database saying online now and add 2
fields to it. id and username CODE id type=integer(INT) , auto increment, length =255
and username = VARCHAR length=the limit a username should be in your site now from there we take
off : CODE <?php //logged.php //authentication script //connection scri....
Creatting A Playlist Through Php
script help needed (5) Hi I am trying to make a script so that i can insert songs into a playlist, but i need a script in
which it opens the playlist file and removes the closing tag at the end, so before i can add more
entrys. e.g CODE <atx> <entry>Location 5</entry> <entry>Location
4</entry> <entry>Location 3</entry> <entry>Location
2</entry> <entry>Location 1</entry> <atx> But to add more entrys
i would have to get rid of the atx, then use the fputs to place the new entry into the file. ....
What Kind Of Script Do You Need ?
post here and get free script (15) Hi everybody sorry if i posting here , i know I want design free PHP script and i dont know
webmasters what kind of scripts want i think its better to aks here becuase trap17 is very nice
webmasters forum So , Plz post here what kind of script with details you need ! sorry may en
is not very well for example you need "upload center" : write "upload center" with upload center
options ( like Ajax , Fast , multi lan and ... ) with this post we can give script details and
webmasters idea /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.....
Free Auction Script
Any Suggestions? (6) Any free auction script suggested? I want it to be as many practical functions as possible, yet
easy to manage. And more importantly, it is free! Appreciate your kind suggestions!....
Wap Source Code Viewer
Mobile/wap source code viewer page (4) This is a source code viewer that will workl on wap/mobile sites but you can easily convert it to
work on web im sure ;-) CODE <? header("Content-Type:
text/vnd.wap.wml"); echo '<?xml version="1.0"
encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head><meta
http-equiv="Cache-Control" content="no-cache"
forua="true"/></head> <card title="s60.nerds.....
Watermark Your Image With Simple Php Script
found it on the net (35) This script was found on the net http://tips-scripts.com/?tip=watermark#tip B&T's Tips &
Scripts site. Just in case the site may not show, I will include the code here: List of things
needed: 1. your image in any format 2. watermark image--in gif format with transparent background 3.
script below with name (i.e. watermark.php) CODE <?php // this script creates a watermarked
image from an image file - can be a .jpg .gif or .png file // where watermark.gif is a mostly
transparent gif image with the watermark - goes in the same directory as this script // ....
Adapting Html Code Embed To Work On Phpnuke
Help With This Html Code Pls (7) QUOTE how can get this html code to work on my phpnuke site? what tags would i
have to enable in the $Allowable HTML part of my config.php file?? Edited topic title. Moved
to Programming. ....
Parse: Error Unexpected T_lnumber
php parse error when running script (4) Hi. I've just created a php script. The main object of the script is to delete some old files
and replace it with a new file with some new content, effectively moving the contents from one file
to another. These are the first 50 lines of the file: /* Calculate For The "A" Group - The
Latest Games ID */ $a_B = 002; while(file_exists("a_" . $a_B . ".dat")) {
$a_B++; } $new_page_contents = " " . $_POST . " " . $_POST . "
include \"/home/cmatcme/public_html/footer.php\"; ?> "; $a_stream = fopen(&....
Just About Completed My Own Message Board Source.
This one looks nice! (10) I've finally completed my message board source code! This one is very nice, and it has
many, many features. So if you can, please rate them and possibly register if you like this
/wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> http://subzer0.net/boards/ ....
Script: Php Jukebox
A one file script! (4) This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
and put it in a folder called 'music': CODE <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
<title>PHP jukebox</title> </head> <body> <!-- ©2005 Craig
lloyd. All rights reserved. Visit cragllo.com for more sc....
Many Php Script Sites
(16) Hi I find many sites has PHP scripts :: http://www.proxy2.de/scripts.php http://www.free-php.net
http://knubbe.t35.com/ http://www.ngcoders.com/ http://www.oxyscripts.com/
http://www.phparena.net/ http://www.1phpstreet.com/ http://px.sklar.com/
http://www.scoznet.com/ http://php.resourceindex.com/ /blink.gif' border='0'
style='vertical-align:middle' alt='blink.gif' /> ....
How do you test your php code
(80) We know that php is a server side scripting language. So we will need a server with the php parser
to parse/test our code. How are you doing that. Do you upload it to a server for testing or did you
instal php and the server (apache) on your computer (localhost)....
Looking for awesome, source, code, viewer, script
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for awesome, source, code, viewer, script
*MORE FROM TRAP17.COM*
|
advertisement
|
|