';
$lang_from_http_accept = explode(',', $HTTP_ACCEPT_LANGUAGE);
//echo $lang_from_http_accept[0].'
';
$locale = lang2locale($lang_from_http_accept[0]);
if (substr($locale,0,2) != substr($lang_from_http_accept[0],0,2)) {
//echo "Non trouvé, 2ème tentative";
$lang_from_http_accept = explode('-', $lang_from_http_accept[0]);
//echo $lang_from_http_accept[0].'
';
$locale = lang2locale($lang_from_http_accept[0]);
}
//echo $locale.'
';
$localeshort=locale2lang($locale);
}
}
// Définition de la langue :
$results=putenv("LC_ALL=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=putenv("LC_LANG=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=putenv("LC_LANGUAGE=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=setlocale(LC_ALL, "$locale.utf8");
if (!$results) {
exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment');
}
bindtextdomain("messages", "./lang");
textdomain("messages");
/* / language */
if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('upload_max_filesize'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration upload_max_filesize to %s'), $config['maxUploadPerFile']));
}
if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('post_max_size'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration post_max_size to %s'), $config['maxUploadPerFile']));
}
if (convertHumain2octect($config['maxUploadNb']) > convertHumain2octect(ini_get('max_file_uploads'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration max_file_uploads to %s'), $config['maxUploadNb']));
}
// Password
$passwordEnter=false;
if (isset($_POST['password'])) {
//session_start();
setcookie("password".$id,base64_encode($config['passwordUniqKey'].$_POST['password']),strtotime( $config['passwordTimeRemember'] ), '/');
$passwordEnter=base64_encode($config['passwordUniqKey'].$_POST['password']);
} elseif (isset($_COOKIE['password'.$id])) {
$passwordEnter=$_COOKIE['password'.$id];
}
$uploadDirId=$config['uploadDir'].'/'.$id.'/';
$passwordInvalid=false;
$passwordForm=false;
if (is_file($uploadDirId.'/.password.cfg') && $passwordEnter != false) {
$countPasswordChar = strlen(base64_decode($passwordEnter))-strlen($config['passwordUniqKey']);
$password = substr(base64_decode($passwordEnter), -$countPasswordChar);
if (password_verify($config['passwordUniqKey'].$password, file_get_contents($uploadDirId.'/.password.cfg'))) {
$passwordForm=false;
} else {
$passwordForm=true;
$passwordInvalid=true;
}
} elseif (is_file($uploadDirId.'/.password.cfg')) {
$passwordForm=true;
}
if ($passwordForm == false) {
// ZIP, READ ou DL
if (isset($_GET['action']) && ($_GET['action'] == 'zip' || $_GET['action'] == 'dl' || $_GET['action'] == 'read')) {
if ($_GET['action'] == 'zip') {
genZip($id);
$filename = $id.'.zip';
$contentType='application/zip';
} elseif ($_GET['action'] == 'dl' || $_GET['action'] == 'read') {
$filename = $_GET['file'];
$contentType=mime_content_type($uploadDirId.$filename);
}
// HTTP Headers File Downloads
// https://perishablepress.com/press/2010/11/17/http-headers-file-downloads/
// http headers for zip downloads
if (headers_sent()) {
echo 'HTTP header already sent';
} else {
if (!is_file($uploadDirId.$filename)) {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
header('Location: '.$config['baseUrl'].'404');
} else if (!is_readable($uploadDirId.$filename)) {
header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
header('Location: '.$config['baseUrl'].'403');
} else {
header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
header("Pragma: public");
if ($_GET['action'] != 'read') {
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($uploadDirId.$filename));
}
header("Content-Type: ".$contentType);
@readfile($uploadDirId.$filename);
// Access count
if (!preg_match('/^\.(.+)\.small$/', $filename) && is_file($uploadDirId.'/.access.cfg')) {
$nbAccess = file_get_contents($uploadDirId.'/.access.cfg')-1;
file_put_contents($uploadDirId.'/.access.cfg', $nbAccess);
if (! $nbAccess > 0) {
rrmdir($uploadDirId);
}
}
}
}
exit();
}
// Del
if (isset($_GET['action']) && $_GET['action'] == 'del') {
//echo $config['uploadDir'].'/'.$id.'/.key-'.$_GET['key'];
//print_r($_GET);
if (! is_file($config['uploadDir'].'/'.$id.'/.key-'.$_GET['key'].'.cfg'))
exit('No hack 5 - delete not Unauthorized');
// Si c'est juste un fichier
if (isset($_GET['file'])) {
@unlink($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
@unlink($config['uploadDir'].'/'.$id.'/.'.$_GET['file'].'.small');
// Checksum
$checksum = new Checksum();
$deleteFile = $checksum->deleteFile($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
//error_log('checksum>deleteFile : '.$config['uploadDir'].'/'.$id.'/'.$_GET['file']);
//error_log('checksum>deleteFile return : '.json_encode($deleteFile));
if ($deleteFile != true) {
exit("deleteFile : ".json_encode($deleteFile));
}
// Si c'est le dernire, on supprime le tout
$uploadDirId = $config['uploadDir'].'/'.$id.'/';
$nbFile=0;
foreach (scandir($uploadDirId) as $file) {
if (is_file($uploadDirId.'/'.$file)
&& $file != $id.'.zip'
&& !preg_match('/^\.(.+)\.cfg$/', $file)
&& !preg_match('/^\.(.+)\.small$/', $file)) {
$nbFile++;
}
}
if ($nbFile == 0) {
rrmdir($config['uploadDir'].'/'.$id);
}
} else {
// Si c'est le dossier
rrmdir($config['uploadDir'].'/'.$id);
$nbFile = 0;
}
@include_once('./header.php');
if ($nbFile == 0) {
header('Status: 301 Moved Permanently', false, 301);
header('Location: '.$config['baseUrl']);
} else {
header('Status: 301 Moved Permanently', false, 301);
header('Location: '.$config['baseUrl'].'/'.$id.'/');
}
exit();
}
}
@include_once('./header.php');
?>
'.$config['maintenanceMsg'].'
'; } else { // signaler au mainteneur que le mode maintenance est à true if ($config['maintenanceMod'] == true) { echo ''._('Mode Maintenance as true').'
'; } @include_once('./header-page.php'); $similarServicesLink=''; if ($config['similarServicesView']) { //~ $similarServicesLink=''. _('The limit per file is ').$config['maxUploadPerFile'] .'
'. _('The total limit per upload is ').$config['maxUploadTotal'] .'
'._('This file is protected by a password, thank you to indicate it below').'
'; echo ''; echo ''._('The requested page does not exist').'
'; } elseif (!is_file('htmlPages/'.$page['fileName'].'.html')) { echo ''._('The requested page does not exist').'
'; } else { include('htmlPages/'.$page['fileName'].'.html'); } echo $echoNewUpload; break; case 'html': echo ''._('These files will be automatically deleted on %s, ie in %d days').'
', $dateExpire, $dayExpire); if (is_file($uploadDirId.'/.access.cfg') ) { $nbAccess = file_get_contents($uploadDirId.'/.access.cfg'); if ($nbAccess < 3) { $classExpireAccess='verySpeedDownload'; }elseif ($nbAccess < 6) { $classExpireAccess='speedDownload'; } printf(''._('These files will be automatically deleted in %d access').'
', $nbAccess); } $nbFile=0; $nbImageFile=0; foreach (scandir($uploadDirId) as $file) { if (is_file($uploadDirId.'/'.$file) && $file != $id.'.zip' && !preg_match('/^\.(.+)\.cfg$/', $file) && !preg_match('/^\.(.+)\.small$/', $file)) { $filesInUploadDirId[]=$file; $nbFile++; if (preg_match('/^image\/(png|jpeg|gif)$/', mime_content_type($uploadDirId.'/'.$file))) { $nbImageFile++; } } } if ($nbImageFile == $nbFile) { echo ''._('Error: Nothing to display').'
'; } elseif ($nbFile == 1) { $linkDownload=$config['baseUrl'].$id.'/'; echo ''; } if (isset($_GET['gallery'])) { echo '= _('Online file sharing service free of rights (license Beerware) and free.') ?>
- | = _('Nb of files') ?> | = _('Creation date ') ?> | = _('Expiration date') ?> | = _('Size') ?> | = _('Remaining access') ?> | = _('Password') ?> | = _('Link') ?> |
---|
'._('Unauthorized access').'
'; echo $echoNewUpload; break; case '404': echo ''._('This sharing does not exist, it has probably expired').'
'; echo $echoNewUpload; break; default: ?>= _('Online file sharing service free of rights (license Beerware) and free.') ?>