1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jappix_ynh.git synced 2024-09-03 19:26:19 +02:00
jappix_ynh/source/server/download-chat.php
2014-11-25 23:42:38 +01:00

54 lines
1.2 KiB
PHP

<?php
/*
Jappix - An open social platform
This is the PHP script used to download a chat log
-------------------------------------------------
License: AGPL
Author: Valérian Saliou
*/
// PHP base
define('JAPPIX_BASE', '..');
// Get the needed files
require_once('./functions.php');
require_once('./read-main.php');
require_once('./read-hosts.php');
// Prepare application
enableErrorSink();
hideErrors();
compressThis();
// Not allowed for a special node
if(isStatic() || isUpload()) {
exit;
}
// Send the HTML file to be downloaded
if(isset($_GET['id']) && !empty($_GET['id']) && isSafe($_GET['id'])) {
// We define the variables
$filename = $_GET['id'];
$content_dir = '../tmp/archives/';
$filepath = $content_dir.$filename.'.html';
// We set special headers
header("Content-disposition: attachment; filename=\"$filename.html\"");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: text/html\n");
header("Content-Length: ".filesize($filepath));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");
readfile($filepath);
// We delete the stored log file
unlink($filepath);
}
?>