WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
<?phprequire("config.php");if(isset($_SESSION['USER_ID']) && SESSION_STARTED) { $allowedtypes = array('image/gif', 'image/png', 'image/jpeg'); $fichier = str_replace('../','',WB_PATH.'/'.urldecode($_GET['fichier'])); if(file_exists($fichier)) { $mimetype = mime_content_type($fichier); if(in_array($mimetype, $allowedtypes)) { header("Content-Type: " . $mimetype); header("Content-Length: " . filesize($fichier)); header("Cache-Control: private"); echo file_get_contents($fichier); } } else { echo 'oups'; }} else { header('HTTP/1.0 403 forbidden', TRUE, 403); die('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don\'t have permission to access '.urldecode($_GET['fichier']).'on this server.</p> </body></html> ');}?>
<?phprequire("config.php");if(isset($_SESSION['USER_ID']) && SESSION_STARTED) { # code the url $DEC = urldecode($_GET['fichier']); # set unalloewed file, so nobody want to read /config.php or something $unallowed_to_read = array('php','html','htm','htaccess'); # remove any attempt to back up your folders $fichier = str_replace('../','',WB_PATH.'/'.urldecode($_GET['fichier'])); #end(explode('.',$fichier)) = the remaining of an explosion of the filename of '.' (the extension) if(file_exists($fichier) && (!in_array(end(explode('.',$fichier)),$unallowed_to_read))) { header("Content-Type: " . mime_content_type($fichier)); header("Content-Length: " . filesize($fichier)); header("Content-Transfer-Encoding: binary"); header("Cache-Control: private"); header('Content-Disposition: attachment; filename="'.end(explode('/',$DEC)).'"'); echo file_get_contents($fichier); } else { # in case of absent file or attempt at hacking echo 'oups'; }} else { # not logged ? forbidden! header('HTTP/1.0 403 forbidden', TRUE, 403); die('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don\'t have permission to access '.urldecode($_GET['fichier']).'on this server.</p> </body></html> ');}?>
if(!function_exists('mime_content_type')) { function mime_content_type($filename) { $mime_types = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', ); $ext = strtolower(array_pop(explode('.',$filename))); if (array_key_exists($ext, $mime_types)) { return $mime_types[$ext]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } else { return 'application/octet-stream'; } }}