blob: fb81ce265ec6505e8b358945e3708939e92f3553 [file] [log] [blame]
<?php
function getNewsHeadline($line){
$headline = explode('__FILE__, "', $line)[1]; //get the start of the headline
return explode('"', $headline)[0]; //strip everything after the ending "
}
function getDateFromFileName($baseFileName) {
$dateString = explode("_", $baseFileName)[2];
$dateString = substr_replace($dateString, '-', 6, 0);
return substr_replace($dateString, '-', 4, 0);
}
function checkPageName($fileName, $defaultFile){
/* the checks in this functions are based on an example from
* Jörg Reinholz at the https://wiki.selfhtml.org/wiki/PHP/Tutorials/Templates/Dateien_mit_include_nachladen
* page provided as public domain.
*/
$fileNameCopy = $fileName; //create copy for later chekcs
//given file name must not contain ../, /. (hidden unix file), url (://)
$arForbiddenStrings = array('../', '/.', '://', '\\\\', '//' );
//replace forbiden strings with nothing
$fileName=str_replace($arForbiddenStrings, '', $fileName);
if(! $fileName == $fileNameCopy){
//there where bad strings in the given param, return the default help file
return $defaultFile;
}
$forbiddenChars='/[^A-Za-z0-9_.\/*+:,-]/';
if ( preg_match($forbiddenChars, $fileName) ) {
return $defaultFile;
}
if ( $fileName && '.' == $fileName{0} ) {
return $defaultFile;
}
return $fileName;
}
?>