diff options
| author | 2014-10-05 12:14:22 +0200 | |
|---|---|---|
| committer | 2014-10-05 12:14:22 +0200 | |
| commit | febabccdd5e6db573ab80bd5c1758d136b91cd78 (patch) | |
| tree | e72478f423302904d995402fb03caf8871f933bd /p/ext.php | |
| parent | 5474803aa7a05e4afa851c88bf21fd8383bf59d9 (diff) | |
Primitive extension system
https://github.com/marienfressinaud/FreshRSS/issues/252
I have been using this extension system for a little while, in
particular to include custom CSS and/or JavaScript (inclusion of PHP
code is not done yet).
There is very little code and it does not impact performances.
I hurry to post it before
https://github.com/marienfressinaud/FreshRSS/issues/655
Diffstat (limited to 'p/ext.php')
| -rw-r--r-- | p/ext.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/p/ext.php b/p/ext.php new file mode 100644 index 000000000..cff194343 --- /dev/null +++ b/p/ext.php @@ -0,0 +1,35 @@ +<?php +if (!isset($_GET['e'])) { + header('HTTP/1.1 400 Bad Request'); + die(); +} +$extension = substr($_GET['e'], 0, 64); +if (!ctype_alpha($extension)) { + header('HTTP/1.1 400 Bad Request'); + die(); +} + +require('../constants.php'); +$filename = FRESHRSS_PATH . '/extensions/' . $extension . '/'; + +if (isset($_GET['j'])) { + header('Content-Type: application/javascript; charset=UTF-8'); + header('Content-Disposition: inline; filename="script.js"'); + $filename .= 'script.js'; +} elseif (isset($_GET['c'])) { + header('Content-Type: text/css; charset=UTF-8'); + header('Content-Disposition: inline; filename="style.css"'); + $filename .= 'style.css'; +} + +$mtime = @filemtime($filename); +if ($mtime == false) { + header('HTTP/1.1 404 Not Found'); + die(); +} + +require(LIB_PATH . '/http-conditional.php'); + +if (!httpConditional($mtime, 604800, 2)) { + readfile($filename); +} |
