Last active
December 24, 2015 01:59
-
-
Save Flygenring/6728000 to your computer and use it in GitHub Desktop.
Allowing view-source for a file on GET requests using a view-source parameter in the query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Allowing view-source on GET requests using a view-source parameter in the query string | |
if('GET' == $_SERVER['REQUEST_METHOD'] && array_key_exists('view-source', $_GET)) { | |
highlight_file(__FILE__); | |
die(); | |
} | |
// Rest of the code... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run the script: http://example.com/path/to/view-source.php
To view the source: http://example.com/path/to/view-source.php?view-source