Skip to content

Commit

Permalink
Initial commit of markdown handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Minnee committed Oct 7, 2009
0 parents commit 6657407
Show file tree
Hide file tree
Showing 4 changed files with 1,804 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Action markdown /markdown/handler.php
AddHandler markdown .md
27 changes: 27 additions & 0 deletions markdown/handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/markdown/style.css">
<meta name="content-type" http-equiv="content-type" value="text/html; utf-8">
</head>
<body>
<?php

require('markdown.php');

$legalExtensions = array('md', 'markdown');

$file = realpath($_SERVER['PATH_TRANSLATED']);
if($file
&& in_array(strtolower(substr($file,strrpos($file,'.')+1)), $legalExtensions)
&& substr($file,0,strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT']) {
echo Markdown(file_get_contents($file));
} else {
echo "<p>Bad filename given</p>";
}
?>
</body>
</html>
Loading

0 comments on commit 6657407

Please sign in to comment.