Skip to content

Instantly share code, notes, and snippets.

@mathieu-aubin
Created January 25, 2016 08:17
Show Gist options
  • Save mathieu-aubin/c6fab852556dddb49ff6 to your computer and use it in GitHub Desktop.
Save mathieu-aubin/c6fab852556dddb49ff6 to your computer and use it in GitHub Desktop.
PHP - Show file source from url query
<?php
# Including this conditional code to the top of a script allows to display it's content
# (sourcecode), highlighted, adding query string "?showSource" to the file request.
# ex: http://example.com/scriptname.php?showSource
# fully modifiable, __FILE__ can be another local file, query can be changed....
if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource'])) {
highlight_file(__FILE__);
die();
}
// start of script code
$normal = phpCode['here'];
// source: http://phpxmlrpc.sourceforge.net/server.php?showSource=TRUE
@mathieu-aubin
Copy link
Author

I did not know about highlight_file, less stupid day after day...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment