index.php 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. <?php
  2. define('VERSION', '1.1');
  3. if (!is_readable('./config.yaml')) {
  4. exit('Error: The configuration file is not present, move config.yaml.default to config.yaml');
  5. }
  6. if (($config = yaml_parse_file('./config.yaml')) == false) {
  7. exit('config.yaml syntax error, check with : http://www.yamllint.com/');
  8. }
  9. include('./lib/functions.php');
  10. if ($config['check_checksum'] === true) {
  11. $checksum = new Checksum;
  12. }
  13. if (isset($_GET['id'])){
  14. $id = $_GET['id'];
  15. if (!preg_match('/^[0-9]+-[0-9]{1,2}$/', $id)) {
  16. exit('No Hack ID');
  17. }
  18. } else {
  19. $id = null;
  20. }
  21. /* Language */
  22. if (isset($_GET['langueChange'])) {
  23. $locale = lang2locale($_GET['langueChange']);
  24. $localeshort=locale2lang($locale);
  25. setcookie("langue",$localeshort,strtotime( '+1 year' ), '/');
  26. } else {
  27. if (isset($_COOKIE['langue'])) {
  28. $locale = lang2locale($_COOKIE['langue']);
  29. $localeshort=locale2lang($locale);
  30. } else {
  31. $HTTP_ACCEPT_LANGUAGE=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
  32. //echo $HTTP_ACCEPT_LANGUAGE.'<br />';
  33. $lang_from_http_accept = explode(',', $HTTP_ACCEPT_LANGUAGE);
  34. //echo $lang_from_http_accept[0].'<br />';
  35. $locale = lang2locale($lang_from_http_accept[0]);
  36. if (substr($locale,0,2) != substr($lang_from_http_accept[0],0,2)) {
  37. //echo "Non trouvé, 2ème tentative";
  38. $lang_from_http_accept = explode('-', $lang_from_http_accept[0]);
  39. //echo $lang_from_http_accept[0].'<br />';
  40. $locale = lang2locale($lang_from_http_accept[0]);
  41. }
  42. //echo $locale.'<br />';
  43. $localeshort=locale2lang($locale);
  44. }
  45. }
  46. // Définition de la langue :
  47. $results=putenv("LC_ALL=$locale.utf8");
  48. if (!$results) {
  49. exit ('putenv failed');
  50. }
  51. $results=putenv("LC_LANG=$locale.utf8");
  52. if (!$results) {
  53. exit ('putenv failed');
  54. }
  55. $results=putenv("LC_LANGUAGE=$locale.utf8");
  56. if (!$results) {
  57. exit ('putenv failed');
  58. }
  59. $results=setlocale(LC_ALL, "$locale.utf8");
  60. if (!$results) {
  61. exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment');
  62. }
  63. bindtextdomain("messages", "./lang");
  64. textdomain("messages");
  65. /* / language */
  66. if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('upload_max_filesize'))) {
  67. exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration upload_max_filesize to %s'), $config['maxUploadPerFile']));
  68. }
  69. if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('post_max_size'))) {
  70. exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration post_max_size to %s'), $config['maxUploadPerFile']));
  71. }
  72. if (convertHumain2octect($config['maxUploadNb']) > convertHumain2octect(ini_get('max_file_uploads'))) {
  73. exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration max_file_uploads to %s'), $config['maxUploadNb']));
  74. }
  75. // Password
  76. $passwordEnter=false;
  77. if (isset($_POST['password'])) {
  78. //session_start();
  79. setcookie("password".$id,base64_encode($config['passwordUniqKey'].$_POST['password']),strtotime( $config['passwordTimeRemember'] ), '/');
  80. $passwordEnter=base64_encode($config['passwordUniqKey'].$_POST['password']);
  81. } elseif (isset($_COOKIE['password'.$id])) {
  82. $passwordEnter=$_COOKIE['password'.$id];
  83. }
  84. $uploadDirId=$config['uploadDir'].'/'.$id.'/';
  85. $passwordInvalid=false;
  86. $passwordForm=false;
  87. if (is_file($uploadDirId.'/.password.cfg') && $passwordEnter != false) {
  88. $countPasswordChar = strlen(base64_decode($passwordEnter))-strlen($config['passwordUniqKey']);
  89. $password = substr(base64_decode($passwordEnter), -$countPasswordChar);
  90. if (password_verify($config['passwordUniqKey'].$password, file_get_contents($uploadDirId.'/.password.cfg'))) {
  91. $passwordForm=false;
  92. } else {
  93. $passwordForm=true;
  94. $passwordInvalid=true;
  95. }
  96. } elseif (is_file($uploadDirId.'/.password.cfg')) {
  97. $passwordForm=true;
  98. }
  99. if ($passwordForm == false) {
  100. // ZIP, READ ou DL
  101. if (isset($_GET['action']) && ($_GET['action'] == 'zip' || $_GET['action'] == 'dl' || $_GET['action'] == 'read')) {
  102. if ($_GET['action'] == 'zip') {
  103. genZip($id);
  104. $filename = $id.'.zip';
  105. $contentType='application/zip';
  106. } elseif ($_GET['action'] == 'dl' || $_GET['action'] == 'read') {
  107. $filename = $_GET['file'];
  108. $contentType=mime_content_type($uploadDirId.$filename);
  109. }
  110. // HTTP Headers File Downloads
  111. // https://perishablepress.com/press/2010/11/17/http-headers-file-downloads/
  112. // http headers for zip downloads
  113. if (headers_sent()) {
  114. echo 'HTTP header already sent';
  115. } else {
  116. if (!is_file($uploadDirId.$filename)) {
  117. header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
  118. header('Location: '.$config['baseUrl'].'404');
  119. } else if (!is_readable($uploadDirId.$filename)) {
  120. header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
  121. header('Location: '.$config['baseUrl'].'403');
  122. } else {
  123. header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
  124. header("Pragma: public");
  125. if ($_GET['action'] != 'read') {
  126. header("Expires: 0");
  127. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  128. header("Cache-Control: public");
  129. header("Content-Description: File Transfer");
  130. header("Content-Disposition: attachment; filename=\"".$filename."\"");
  131. header("Content-Transfer-Encoding: binary");
  132. header("Content-Length: ".filesize($uploadDirId.$filename));
  133. }
  134. header("Content-Type: ".$contentType);
  135. @readfile($uploadDirId.$filename);
  136. // Access count
  137. if (!preg_match('/^\.(.+)\.small$/', $filename) && is_file($uploadDirId.'/.access.cfg')) {
  138. $nbAccess = file_get_contents($uploadDirId.'/.access.cfg')-1;
  139. file_put_contents($uploadDirId.'/.access.cfg', $nbAccess);
  140. if (! $nbAccess > 0) {
  141. rrmdir($uploadDirId);
  142. }
  143. }
  144. }
  145. }
  146. exit();
  147. }
  148. // Del
  149. if (isset($_GET['action']) && $_GET['action'] == 'del') {
  150. //echo $config['uploadDir'].'/'.$id.'/.key-'.$_GET['key'];
  151. //print_r($_GET);
  152. if (! is_file($config['uploadDir'].'/'.$id.'/.key-'.$_GET['key'].'.cfg'))
  153. exit('No hack 5 - delete not Unauthorized');
  154. // Si c'est juste un fichier
  155. if (isset($_GET['file'])) {
  156. @unlink($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
  157. @unlink($config['uploadDir'].'/'.$id.'/.'.$_GET['file'].'.small');
  158. // Checksum
  159. $checksum = new Checksum();
  160. $deleteFile = $checksum->deleteFile($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
  161. //error_log('checksum>deleteFile : '.$config['uploadDir'].'/'.$id.'/'.$_GET['file']);
  162. //error_log('checksum>deleteFile return : '.json_encode($deleteFile));
  163. if ($deleteFile != true) {
  164. exit("deleteFile : ".json_encode($deleteFile));
  165. }
  166. // Si c'est le dernire, on supprime le tout
  167. $uploadDirId = $config['uploadDir'].'/'.$id.'/';
  168. $nbFile=0;
  169. foreach (scandir($uploadDirId) as $file) {
  170. if (is_file($uploadDirId.'/'.$file)
  171. && $file != $id.'.zip'
  172. && !preg_match('/^\.(.+)\.cfg$/', $file)
  173. && !preg_match('/^\.(.+)\.small$/', $file)) {
  174. $nbFile++;
  175. }
  176. }
  177. if ($nbFile == 0) {
  178. rrmdir($config['uploadDir'].'/'.$id);
  179. }
  180. } else {
  181. // Si c'est le dossier
  182. rrmdir($config['uploadDir'].'/'.$id);
  183. $nbFile = 0;
  184. }
  185. @include_once('./header.php');
  186. if ($nbFile == 0) {
  187. header('Status: 301 Moved Permanently', false, 301);
  188. header('Location: '.$config['baseUrl']);
  189. } else {
  190. header('Status: 301 Moved Permanently', false, 301);
  191. header('Location: '.$config['baseUrl'].'/'.$id.'/');
  192. }
  193. exit();
  194. }
  195. }
  196. @include_once('./header.php');
  197. ?>
  198. <!DOCTYPE html>
  199. <html>
  200. <head>
  201. <meta charset="UTF-8" />
  202. <title><?= $config['shortTitle'] ?> : <?= $config['title'] ?></title>
  203. <script src="<?= $config['baseUrl'] ?>lib/jquery-3.1.0.min.js"></script>
  204. <script>
  205. var Config_baseUrl = '<?= $config['baseUrl'] ?>'
  206. var Config_maxUploadPerFile = <?= convertHumain2octect($config['maxUploadPerFile']) ?>
  207. var Config_maxUploadTotal = <?= convertHumain2octect($config['maxUploadTotal']) ?>
  208. var Config_maxUploadNb = <?= $config['maxUploadNb'] ?>
  209. var Msg_errorFileSize = '<?php printf(_('this file exceeds the allowed size %s'), $config['maxUploadPerFile']) ?>';
  210. var Msg_errorTotalSize = '<?php printf(_('The total size of the files exceeds the allowed size : %s'), $config['maxUploadTotal']) ?>';
  211. var Msg_errorUploadNb = '<?php printf(_('You can not send more than %d files at a time'), $config['maxUploadNb']) ?>';
  212. var Msg_errorFileType = '<?php printf(_('this type of file isn\\\'t allow')) ?>';
  213. var filesUploadQueu=0;
  214. </script>
  215. <script src="<?= $config['baseUrl'] ?>lib/upload.js"></script>
  216. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/style.css" />
  217. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/css-file-icons.css" />
  218. <link rel="apple-touch-icon" sizes="180x180" href="<?= $config['baseUrl'] ?>/apple-touch-icon.png">
  219. <link rel="icon" type="image/png" sizes="32x32" href="<?= $config['baseUrl'] ?>/favicon-32x32.png">
  220. <link rel="icon" type="image/png" sizes="16x16" href="<?= $config['baseUrl'] ?>/favicon-16x16.png">
  221. <link rel="manifest" href="<?= $config['baseUrl'] ?>/site.webmanifest">
  222. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/jquery-ui.min.css">
  223. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/lightgallery.min.css">
  224. <script src="<?= $config['baseUrl'] ?>lib/jquery-ui.min.js"></script>
  225. <script src="<?= $config['baseUrl'] ?>lib/lightgallery.min.js"></script>
  226. <script>
  227. $( function() {
  228. $( document ).tooltip();
  229. } );
  230. </script>
  231. <!-- Bootstrap styles -->
  232. <!--
  233. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/bootstrap.min.css" />
  234. -->
  235. <link
  236. rel="stylesheet"
  237. href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
  238. integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
  239. crossorigin="anonymous"
  240. />
  241. <!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
  242. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/css/jquery.fileupload.css" />
  243. <link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/css/jquery.fileupload-ui.css" />
  244. </head>
  245. <body>
  246. <div id="langues">
  247. <?php
  248. foreach($langueEtLocalDispo as $langShort=>$lang) {
  249. $flag='';
  250. if ($localeshort == $langShort) {
  251. $flag=' drapeauActif';
  252. }
  253. echo '<a id="href'.$langShort.'" href="?langueChange='.$langShort.'"><img class="drapeau'.$flag.'" src="'.$config['baseUrl'].'lib/'.$langShort.'.png" alt="'.$langShort.'" width="23" height="15" /></a>';
  254. }
  255. ?>
  256. </div>
  257. <div id="languesLegende" style="display: none"></div>
  258. <div id="page-wrap">
  259. <?php
  260. if ($config['maintenanceMod'] == true && $config['mainteneurIp'] != $_SERVER['REMOTE_ADDR']) {
  261. echo '<h1>'._('Maintenance').'</h2>';
  262. echo '<p>'.$config['maintenanceMsg'].'</p>';
  263. } else {
  264. // signaler au mainteneur que le mode maintenance est à true
  265. if ($config['maintenanceMod'] == true) {
  266. echo '<p>'._('Mode Maintenance as true').'</p>';
  267. }
  268. @include_once('./header-page.php');
  269. $similarServicesLink='';
  270. if ($config['similarServicesView']) {
  271. //~ $similarServicesLink='<div class="similarServices">
  272. //~ <div class="similarHref"><a href="#similarServices" id="similarServices">'._('Similar services').'</a></div>
  273. //~ <div class="similarLink">';
  274. //~ $similarServicesLink.= '<script type="text/javascript" src="'.$config['baseUrl'].'/lib/alternative-chatons.js"></script>';
  275. //~ $similarServicesLink.= '<p id="entraide-chatons-alternative"></p>';
  276. //~ $similarServicesLink.='</div></div>';
  277. $similarServicesLink='<div class="similarServices">
  278. <div class="similarHref">'._('Similar services').' :</div>
  279. <div>';
  280. $similarServicesLink.= '<script type="text/javascript" src="'.$config['baseUrl'].'/lib/alternative-chatons.js"></script>';
  281. $similarServicesLink.= '<p id="entraide-chatons-alternative"></p>';
  282. $similarServicesLink.='</div></div>';
  283. }
  284. $uploadDirId=$config['uploadDir'].'/'.$id;
  285. $action = null;
  286. if (isset($_GET['action'])) {
  287. $action = $_GET['action'];
  288. }
  289. if (!is_writable($config['uploadDir'])) {
  290. $action = 'ErrorUploadDir';
  291. }
  292. if ($action == 'html' && !is_dir($config['uploadDir'].'/'.$id)) {
  293. $action = '404';
  294. }
  295. if (!$config['htmlPages'] && $action == 'page') {
  296. $action = '404';
  297. }
  298. if ($passwordForm == true) {
  299. $action = 'password';
  300. }
  301. $echoNewUploadPub = '<div id="newUploadPub"><a href="'.$config['baseUrl'].'">'._('Send / share your files').'</a></div>';
  302. $echoNewUpload = '<div id="newUpload" class="newUpload"><noscript><h3>You must have JavaScript enabled in order to use this site. Please enable JavaScript and then reload this page in order to continue. </h3> </noscript>
  303. <!-- The file upload form used as target for the file upload widget -->
  304. <form
  305. id="fileupload"
  306. action=""
  307. method="POST"
  308. enctype="multipart/form-data"
  309. >
  310. <input type="hidden" value="" id="files_key" name="key" />
  311. <input type="hidden" value="" id="files_id" name="id" />
  312. <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
  313. <div class="fileupload-buttonbar">
  314. <div class="expire-button">'._('Expire').' : <select name="expire" id="expire">';
  315. foreach ($config['expireDay'] as $expireDay) {
  316. $dayOrDays=_('days');
  317. if ($expireDay == 1) {
  318. $dayOrDays=_('day');
  319. }
  320. if ($expireDay == $config['expireDayDefault']) {
  321. $echoNewUpload .= '<option value="'.$expireDay.'" selected="selected">'.$expireDay.' '.$dayOrDays.'</option>';
  322. } else {
  323. $echoNewUpload .= '<option value="'.$expireDay.'" >'.$expireDay.' '.$dayOrDays.'</option>';
  324. }
  325. }
  326. $echoNewUpload .= '
  327. </select></div>
  328. <div class="boutton">
  329. <!-- The fileinput-button span is used to style the file input field as button -->
  330. <span id="ButtonAdd" class="btn btn-success fileinput-button">
  331. <i class="glyphicon glyphicon-plus"></i>
  332. <span>'._('Add files...').'</span>
  333. <input type="file" name="files[]" multiple />
  334. </span>
  335. <button id="ButtonStart" type="submit" class="btn btn-primary start">
  336. <i class="glyphicon glyphicon-upload"></i>
  337. <span>'._('Start upload').'</span>
  338. </button>
  339. <button id="ButtonReset" type="reset" class="btn btn-warning cancel">
  340. <i class="glyphicon glyphicon-ban-circle"></i>
  341. <span>'._('Cancel upload').'</span>
  342. </button>
  343. <button id="ButtonMyFiles" type="reset" onclick="location.href=\''.$config['baseUrl'].'/My\';" class="bulles myFiles btn btn-info">
  344. <i class="glyphicon glyphicon-folder-open"></i>
  345. <span>'._('See the files already sent').'</span>
  346. </button>
  347. <!-- The global file processing state -->
  348. <span class="fileupload-process"></span>
  349. </div>
  350. <div id="redirectToFiles">Redirect to '.$config['baseUrl'].'<span id="redirectToFilesId"></span>/ in progress...</div>
  351. <div class="error" id="maxUploadTotalError">'.
  352. _('The total limit per upload is ').$config['maxUploadTotal']
  353. .'</div>
  354. <!-- The global progress state -->
  355. <div class="fileupload-progress fade">
  356. <!-- The global progress bar -->
  357. <div
  358. class="progress progress-striped active"
  359. role="progressbar"
  360. aria-valuemin="0"
  361. aria-valuemax="100"
  362. >
  363. <div
  364. class="progress-bar progress-bar-success"
  365. style="width: 0%;"
  366. ></div>
  367. </div>
  368. <!-- The extended global progress state -->
  369. <div class="progress-extended">&nbsp;</div>
  370. </div>
  371. </div>
  372. <!-- The table listing the files available for upload/download -->
  373. <table role="presentation" class="table table-striped">
  374. <tbody class="files"></tbody>
  375. </table>
  376. <div class="shareUrlPrint file fileJust1 read input">'._('The sharing will be accessible from').' : <input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].$id.'/" id="shareUrl" readonly=""></div>
  377. <a id="uploadOptionsLinkShow" class="uploadOptionsLink">'._('Options').' &#8642;</a>
  378. <div id="uploadOptions">
  379. <a id="uploadOptionsLinkHide" class="uploadOptionsLink">'._('Options').' &#8638;</a>
  380. <p id="resizeForm">'._('Images resize').' : <select name="resize" id="resize">';
  381. foreach ($config['imageResize'] as $imageResize) {
  382. $imageResizeName = $imageResize.'px';
  383. $imageResizeValue = $imageResize;
  384. if ($imageResize == 0) {
  385. $imageResizeName = _('No resizing');
  386. $imageResizeValue=999999;
  387. }
  388. if ($imageResize == $config['imageResizeDefault']) {
  389. $echoNewUpload .= '<option value="'.$imageResize.'" selected="selected">'.$imageResizeName.'</option>';
  390. } else {
  391. $echoNewUpload .= '<option value="'.$imageResize.'" >'.$imageResizeName.'</option>';
  392. }
  393. }
  394. $echoNewUpload .= '</select></p>
  395. <p id="uploadOptionPassword"><input type="checkbox" name="passwordCheckbox" id="passwordCheckbox" />'._('Protect with password').'<span id="passwordForm"> : <br /><input type="password" name="password" id="password" autocomplete="off" /></span></p>
  396. <p id="uploadOptionAccess"><input type="checkbox" name="accessCheckbox" id="accessCheckbox" />'._('Delete after access').'<span id="accessForm"> : <br /><input title="'._('Number of accesses before deletion (1 minimum)').'" type="number" min="1" max="999999" step="1" name="access" id="access" value="'.$config['deleteAfterAccessDefault'].'" /></span></p>
  397. </div>
  398. </form>
  399. <div>
  400. </div>
  401. <div class="limit"><p>'.
  402. _('The limit per file is ').$config['maxUploadPerFile']
  403. .'</p><p>'.
  404. _('The total limit per upload is ').$config['maxUploadTotal']
  405. .'</p></div>
  406. <script>
  407. if (localStorage.getItem(\'myFiles\')) {
  408. $(\'.myFiles\').show();
  409. }
  410. </script></div>';
  411. switch ($action) {
  412. case 'ErrorUploadDir':
  413. echo '<div class="highlight-1">';
  414. printf(_('Error: The directory (%s) is not writable, please contact the service administrator'), $config['uploadDir']);
  415. echo '</div>';
  416. break;
  417. case 'password':
  418. echo '<h1><a href="'.$config['baseUrl'].'">'.$config['shortTitle'].'</a> : '.$config['title'].'</h1>';
  419. echo $echoNewUploadPub;
  420. if (isset($_POST['password']) && $passwordInvalid == true) {
  421. echo '<div class="highlight-1">';
  422. echo _('Error: Incorrect password');
  423. echo '</div>';
  424. }
  425. echo '<div class="passwordForm">';
  426. echo '<p>'._('This file is protected by a password, thank you to indicate it below').'</p>';
  427. echo '<div><form action="#" method="post">';
  428. echo '<input type="password" name="password" />';
  429. echo '<input type="submit" />';
  430. echo '</form></div>';
  431. echo '</div>';
  432. echo $echoNewUpload;
  433. break;
  434. case 'page':
  435. foreach ($config['htmlPages'] as $fileName => $name) {
  436. if ($_GET['name'] == $fileName) {
  437. $page['fileName'] = $fileName;
  438. $page['name'] = $name;
  439. }
  440. }
  441. if (empty($page['name'])) {
  442. echo '<p>'._('The requested page does not exist').'</p>';
  443. } elseif (!is_file('htmlPages/'.$page['fileName'].'.html')) {
  444. echo '<p>'._('The requested page does not exist').'</p>';
  445. } else {
  446. include('htmlPages/'.$page['fileName'].'.html');
  447. }
  448. echo $echoNewUpload;
  449. break;
  450. case 'html':
  451. echo '<h1><a href="'.$config['baseUrl'].'">'.$config['shortTitle'].'</a> : '.$config['title'].'</h1>';
  452. echo $echoNewUploadPub;
  453. $expire=explode('-', $id);
  454. $dateExpire=date('d/m/Y H:m', $expire[0]);
  455. $dStart = new DateTime(date('Y-m-d', $expire[0]));
  456. $dEnd = new DateTime(date('Y-m-d'));
  457. $dDiff = $dStart->diff($dEnd);
  458. $dayExpire = $dDiff->format('%a');
  459. $classExpire ='';
  460. if ($dayExpire < 2) {
  461. $classExpire='verySpeedDownload';
  462. }elseif ($dayExpire < 5) {
  463. $classExpire='speedDownload';
  464. }
  465. printf('<p class="'.$classExpire.'">'._('These files will be automatically deleted on %s, ie in %d days').'</p>', $dateExpire, $dayExpire);
  466. if (is_file($uploadDirId.'/.access.cfg') ) {
  467. $nbAccess = file_get_contents($uploadDirId.'/.access.cfg');
  468. if ($nbAccess < 3) {
  469. $classExpireAccess='verySpeedDownload';
  470. }elseif ($nbAccess < 6) {
  471. $classExpireAccess='speedDownload';
  472. }
  473. printf('<p class="'.$classExpireAccess.'">'._('These files will be automatically deleted in %d access').'</p>', $nbAccess);
  474. }
  475. $nbFile=0;
  476. $nbImageFile=0;
  477. foreach (scandir($uploadDirId) as $file) {
  478. if (is_file($uploadDirId.'/'.$file)
  479. && $file != $id.'.zip'
  480. && !preg_match('/^\.(.+)\.cfg$/', $file)
  481. && !preg_match('/^\.(.+)\.small$/', $file)) {
  482. $filesInUploadDirId[]=$file;
  483. $nbFile++;
  484. if (preg_match('/^image\/(png|jpeg|gif)$/', mime_content_type($uploadDirId.'/'.$file))) {
  485. $nbImageFile++;
  486. }
  487. }
  488. }
  489. if ($nbImageFile == $nbFile) {
  490. echo '<div id="viewMod">';
  491. if (isset($_GET['gallery'])) {
  492. echo '<a href="'.$config['baseUrl'].$id.'/">'._('View in list mode ').'</a>';
  493. } else {
  494. echo '<a href="'.$config['baseUrl'].'gallery/'.$id.'/">'._('View in gallery mode ').'</a>';
  495. }
  496. echo '</div>';
  497. }
  498. if ($nbFile == 0) {
  499. echo '<p>'._('Error: Nothing to display').'</p>';
  500. } elseif ($nbFile == 1) {
  501. $linkDownload=$config['baseUrl'].$id.'/';
  502. echo '<div class="viewNormal fileGlobal fileJust1 file-ext-html" >';
  503. echo '<div class="file fileJust1 icone" onclick="location.href=\''.$linkDownload.'\'"><div class="fi fi-html fi-size"><div class="fi-content">html</div></div></div>';
  504. echo '<div class="file fileJust1 name"><a href="'.$linkDownload.'" target="_blank">'._('This page').'</a></div>';
  505. echo '<div class="file fileJust1 read input"><a href="'.$config['baseUrl'].$id.'/" target="_blank"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].$id.'/" readonly=""></div>';
  506. echo '</div>';
  507. }
  508. if (isset($_GET['gallery'])) {
  509. echo '<div id="lightgalleryGallery">';
  510. $idFile=0;
  511. foreach ($filesInUploadDirId as $fileInUploadDirId) {
  512. $pathInfo = pathinfo($uploadDirId.'/'.$fileInUploadDirId);
  513. $linkDownload=$config['baseUrl'].'dl/'.$id.'/'.$fileInUploadDirId;
  514. echo '<div class="viewGallery file'.$idFile.' file-ext-'.$pathInfo['extension'].'" >';
  515. echo '<div style="float: left; border: 1px solid #C6C6C6;" class="file file'.$idFile.' icone">';
  516. if (preg_match('/^image\/(png|jpeg|gif)$/', mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']))) {
  517. if (!is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.gallery.small')) {
  518. resize_image($pathInfo['dirname'].'/'.$pathInfo['basename'], $pathInfo['dirname'].'/.'.$pathInfo['basename'].'.gallery.small' , 330, 330);
  519. }
  520. if (is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.gallery.small')) {
  521. echo '<div class="item" data-src="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'"><img width="330" src="'.$config['baseUrl'].$id.'/.'.$pathInfo['basename'].'.gallery.small" /></a></div>';
  522. } else {
  523. echo '<a href="'.$linkDownload.'" target="_blank"><div class="fi fi-'.$pathInfo['extension'].' fi-size-xl"><div class="fi-content">'.$pathInfo['extension'].'</div></div></a>';
  524. }
  525. } else {
  526. echo '<a href="'.$linkDownload.'" target="_blank"><div class="fi fi-'.$pathInfo['extension'].' fi-size-xl"><div class="fi-content">'.$pathInfo['extension'].'</div></div></a>';
  527. }
  528. echo '</div>';
  529. echo '</div>';
  530. }
  531. echo '</div>';
  532. }
  533. if ($nbFile > 1) {
  534. $linkDownload=$config['baseUrl'].$id.'.zip';
  535. echo '<div style="clear : both" class="fileGlobal fileAll file-ext-zip" >';
  536. echo '<div class="file fileAll icone" onclick="location.href=\''.$linkDownload.'\'"><div class="fi fi-zip fi-size-lg"><div class="fi-content">zip</div></div></div>';
  537. echo '<div class="file fileAll name"><a href="'.$linkDownload.'" target="_blank">'._('All').'</a><a class="delete deleteLinkAll bulles" rel="tooltip" title="'._('Delete all (permanently)').'" href="'.$config['baseUrl'].'del/'.$id.'/KEYHERE/"> - <img width="15" src="'.$config['baseUrl'].'/lib/trash.svg" /></a></div>';
  538. echo '<div class="file fileAll read input"><a href="'.$config['baseUrl'].$id.'/"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <a rel="tooltip" class="bulles" title="'._('Click to copy the link to the clipboard').'"><input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].$id.'/" readonly=""></a></div>';
  539. if ($nbImageFile == $nbFile) {
  540. echo '<div class="file fileAll read input"><a href="'.$config['baseUrl'].'gallery/'.$id.'/"><img src="'.$config['baseUrl'].'/lib/gallery.svg" /></a> <a rel="tooltip" class="bulles" title="'._('Click to copy the link to the clipboard').'"><input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].'gallery/'.$id.'/" readonly=""></a></div>';
  541. }
  542. echo '<div class="file fileAll dl input"><a href="'.$linkDownload.'"><img src="'.$config['baseUrl'].'/lib/download.svg" /></a> <a rel="tooltip" class="bulles" title="'._('Click to copy the link to the clipboard').'"><input class="copy dl fileAll" name="dl" type="text" value="'.$linkDownload.'" readonly=""></a></div>';
  543. echo '</div>';
  544. }
  545. if (!isset($_GET['gallery'])) {
  546. $idFile=0;
  547. echo '<div id="lightgalleryNormal">';
  548. foreach ($filesInUploadDirId as $fileInUploadDirId) {
  549. $pathInfo = pathinfo($uploadDirId.'/'.$fileInUploadDirId);
  550. $linkDownload=$config['baseUrl'].'dl/'.$id.'/'.$fileInUploadDirId;
  551. echo '<div class="viewNormal fileGlobal file'.$idFile.' file-ext-'.$pathInfo['extension'].'" >';
  552. echo '<div class="file file'.$idFile.' icone delete"><a href="'.$config['baseUrl'].'del/'.$id.'/KEYHERE/'.$pathInfo['basename'].'" class="deleteLink">azer<img src="'.$config['baseUrl'].'/lib/trash.svg" /></a></div>';
  553. echo '<div class="file file'.$idFile.' icone">';
  554. if (preg_match('/^image\/(png|jpeg|gif)$/', mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']))) {
  555. if (!is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small')) {
  556. resize_image($pathInfo['dirname'].'/'.$pathInfo['basename'], $pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small' , 60, 60);
  557. }
  558. if (is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small')) {
  559. echo '<div class="item" data-src="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'"><img width="55" src="'.$config['baseUrl'].$id.'/.'.$pathInfo['basename'].'.small" /></a></div>';
  560. } else {
  561. echo '<a href="'.$linkDownload.'" target="_blank"><div class="fi fi-'.$pathInfo['extension'].' fi-size-lg"><div class="fi-content">'.$pathInfo['extension'].'</div></div></a>';
  562. }
  563. } else {
  564. echo '<a href="'.$linkDownload.'" target="_blank"><div class="fi fi-'.$pathInfo['extension'].' fi-size-lg"><div class="fi-content">'.$pathInfo['extension'].'</div></div></a>';
  565. }
  566. echo '</div>';
  567. echo '<div class="file file'.$idFile.' name"><a href="'.$linkDownload.'" target="_blank">'.truncate($fileInUploadDirId, 40, '...', true).'</a></div>';
  568. echo '<div class="file file'.$idFile.' info">';
  569. echo '<span class="size file'.$idFile.'">'._('Size').' : '.convertOctect2humain(filesize($pathInfo['dirname'].'/'.$pathInfo['basename'])).'</span> ';
  570. echo '<span class="type file'.$idFile.'">'._('Type').' : '.mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']).'</span> ';
  571. //echo '<span class="size">'._('Type').' : '.mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']).'</span> ';
  572. echo '</div>';
  573. echo '<div class="file file'.$idFile.' read input"><a href="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'" target="_blank"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <a rel="tooltip" class="bulles" title="'._('Click to copy the link to the clipboard').'"><input class="copy read file'.$idFile.'" name="read" type="text" value="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'"></a></div>';
  574. echo '<div class="file file'.$idFile.' dl input"><a href="'.$linkDownload.'" target="_blank"><img src="'.$config['baseUrl'].'/lib/download.svg" /></a> <a rel="tooltip" class="bulles" title="'._('Click to copy the link to the clipboard').'"><input class="copy dl file'.$idFile.'" name="dl" type="text" value="'.$linkDownload.'" readonly=""></a></div>';
  575. echo '</div>';
  576. $idFile++;
  577. }
  578. echo '</div>';
  579. }
  580. echo '<div id="addToShare"><h3>'._('Add files to this share').'</h3>';
  581. echo $echoNewUpload;
  582. echo '</div>';
  583. ?>
  584. <script type="text/javascript">
  585. $(document).ready(function() {
  586. // lightgallery
  587. // https://github.com/sachinchoolur/lightGallery
  588. $("#lightgalleryNormal").lightGallery({
  589. selector: '.item'
  590. });
  591. $("#lightgalleryGallery").lightGallery({
  592. selector: '.item'
  593. });
  594. });
  595. // Affiche les bouton de suppression si c'est le poste qui a uploadé
  596. if (localStorage.getItem('myFiles')) {
  597. var storageMyFiles = JSON.parse(localStorage.getItem('myFiles'));
  598. if (storageMyFiles.items.filter(function(e) { return e.id === '<?= $id ?>'; }).length > 0) {
  599. var searchWithId = storageMyFiles.items.filter(function(e) { return e.id === '<?= $id ?>'; })
  600. var keyForThis = Object.values(searchWithId[0])[1];
  601. $('.deleteAll').show();
  602. $('.delete').show();
  603. $('#files_key').val(keyForThis);
  604. $('#uploadOptionPassword').hide();
  605. $('#uploadOptionAccess').hide();
  606. $('.expire-button').hide();
  607. $('#addToShare').show();
  608. var links = $('.deleteLink');
  609. for(var i = 0; i< links.length; i++){
  610. var oldLink = links[i].href;
  611. var newLink = oldLink.replace('KEYHERE', keyForThis);
  612. links[i].href = newLink;
  613. }
  614. var links = $('.deleteLinkAll');
  615. for(var i = 0; i< links.length; i++){
  616. var oldLink = links[i].href;
  617. var newLink = oldLink.replace('KEYHERE', keyForThis);
  618. links[i].href = newLink;
  619. }
  620. } else {
  621. $('#addToShare').hide();
  622. }
  623. } else {
  624. $('#addToShare').hide();
  625. }
  626. function deleteLast(href) {
  627. var hrefSplit = href.split('\/');
  628. var id = false;
  629. var key = false;
  630. for (var i = 0; i < hrefSplit.length; i++) {
  631. var regexTimestamp = RegExp('^[0-9]+-[0-9]{1,2}$');
  632. if (regexTimestamp.test(hrefSplit[i])) {
  633. id=hrefSplit[i];
  634. }
  635. if (parseInt(hrefSplit[i]) >= 100000000000 && parseInt(hrefSplit[i]) <= 999999999999) {
  636. key=hrefSplit[i];
  637. }
  638. }
  639. if (id != false && key != false && localStorage.getItem('myFiles')) {
  640. var storageMyFiles = JSON.parse(localStorage.getItem('myFiles'));
  641. var newData = {items: []};
  642. for (var i = 0; i < storageMyFiles.items.length; i++) {
  643. var idSplit=storageMyFiles.items[i].id.split("-");
  644. var timestampNow = Number(new Date());
  645. var timestampExpire = idSplit[0]*1000;
  646. // Ne pas afficher les expiré
  647. // Et si ce n'est pas celui qu'on efface
  648. if (timestampNow < timestampExpire
  649. && storageMyFiles.items[i].id != id
  650. && storageMyFiles.items[i].key != key) {
  651. // On update le maintient dans le stroage
  652. newData.items.push(
  653. {id: storageMyFiles.items[i].id, key: storageMyFiles.items[i].key}
  654. );
  655. }
  656. }
  657. // Ecriture du storage
  658. localStorage.setItem('myFiles', JSON.stringify(newData));
  659. }
  660. }
  661. $(".deleteLinkAll").on('click',function(){
  662. if (confirm("<?= _('Are you sure you want to delete everything?') ?>")) {
  663. deleteLast(this.href);
  664. return true;
  665. } else {
  666. return false;
  667. }
  668. });
  669. $(".deleteLink").on('click',function(){
  670. if (confirm("<?= _('Are you sure you want to delete it?') ?>")) {
  671. <?php
  672. // Si c'est le dernier, on supprime l'enregistrement localStorage
  673. if ($nbFile == 1) {
  674. echo "deleteLast(this.href);";
  675. }
  676. ?>
  677. return true;
  678. } else {
  679. return false;
  680. }
  681. });
  682. </script>
  683. <?php
  684. break;
  685. case 'myFiles':
  686. ?>
  687. <h1><?= $config['shortTitle'] ?> : <?= _('My files') ?></h1>
  688. <?= $echoNewUploadPub ?>
  689. <p><?= _('Online file sharing service <a href="https://en.wikipedia.org/wiki/Open_source">free of rights</a> (license <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>) and free.') ?></p>
  690. <table id="myFilesTab">
  691. <tr><th> - </th><th><?= _('Nb of files') ?></th><th><?= _('Creation date ') ?></th><th><?= _('Expiration date') ?></th><th><?= _('Size') ?></th><th><?= _('Remaining access') ?></th><th><?= _('Password') ?></th><th><?= _('Link') ?></th></tr>
  692. </table>
  693. <script>
  694. function sleep(milliseconds) {
  695. const date = Date.now();
  696. let currentDate = null;
  697. do {
  698. currentDate = Date.now();
  699. } while (currentDate - date < milliseconds);
  700. }
  701. var fileNotExpire=0;
  702. if (localStorage.getItem('myFiles')) {
  703. var storageMyFiles = JSON.parse(localStorage.getItem('myFiles'));
  704. var newData = {items: []};
  705. for (var i = 0; i < storageMyFiles.items.length; i++) {
  706. var idSplit=storageMyFiles.items[i].id.split("-");
  707. var timestampNow = Number(new Date());
  708. var timestampExpire = idSplit[0]*1000;
  709. // Ne pas afficher les expiré
  710. if (timestampNow < timestampExpire) {
  711. var dateExpire = new Date(idSplit[0]* 1000).toDateString();
  712. $.ajax({
  713. url : 'my.php',
  714. type : 'POST',
  715. dataType : 'html',
  716. data : 'id=' + storageMyFiles.items[i].id + '&dateExpire=' + dateExpire,
  717. success : function(code_html, statut){
  718. $('#myFilesTab>tbody:last').append(code_html);
  719. },
  720. error : function(resultat, statut, erreur){
  721. //console.log(resultat + statut + erreur)
  722. },
  723. });
  724. var fileNotExpire=fileNotExpire+1;
  725. // On update le maintient dans le stroage
  726. newData.items.push(
  727. {id: storageMyFiles.items[i].id, key: storageMyFiles.items[i].key}
  728. );
  729. }
  730. }
  731. // Ecriture du storage
  732. localStorage.setItem('myFiles', JSON.stringify(newData));
  733. }else if (fileNotExpire == 0) {
  734. $('#myFilesTab>tbody:last').append('<tr><td colspan="6" class="error myFiles0"><?= _('All your files have expired.') ?></td></tr>');
  735. } else {
  736. $('#myFilesTab>tbody:last').append('<tr><td colspan="6" class="error myFiles0"><?= _('No files, maybe all of them have expired.') ?></td></tr>');
  737. }
  738. </script>
  739. <?php
  740. echo $echoNewUpload;
  741. break;
  742. case '403':
  743. echo '<h1><a href="'.$config['baseUrl'].'">'.$config['shortTitle'].'</a> : 403 '._('Unauthorized access').'</h1>';
  744. echo $echoNewUploadPub;
  745. echo '<p>'._('Unauthorized access').'</p>';
  746. echo $echoNewUpload;
  747. break;
  748. case '404':
  749. echo '<h1><a href="'.$config['baseUrl'].'">'.$config['shortTitle'].'</a> : 404 '._('Not Found').'</h1>';
  750. echo $echoNewUploadPub;
  751. echo '<p>'._('This sharing does not exist, it has probably expired').'</p>';
  752. echo $echoNewUpload;
  753. break;
  754. default:
  755. ?>
  756. <h1><a href="<?= $config['baseUrl'] ?>"><?= $config['shortTitle'] ?></a> : <?= $config['title'] ?></h1>
  757. <?php @include_once('./start-home.php'); ?>
  758. <p><?= _('Online file sharing service <a href="https://en.wikipedia.org/wiki/Open_source">free of rights</a> (license <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>) and free.') ?></p>
  759. <div id="preUpload"></div>
  760. <!-- For upload results -->
  761. <div id="result"></div>
  762. <div class="uploadArea">
  763. <?= $echoNewUpload ?>
  764. <?= $similarServicesLink ?>
  765. </div>
  766. <?php
  767. @include_once('./end-home.php');
  768. }
  769. ?>
  770. <div id="footer">
  771. <p class="footer_right"><?= _('By') ?> <a href="http://david.mercereau.info/">David Mercereau</a> (<a href="https://framagit.org/kepon/file2link"><?= _('Git repository') ?></a>)</p>
  772. <p class="footer_left">file2link <?= _('version') ?> <?= VERSION ?> <?= _('is an open software licensed <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>') ?> <span id="upgrade"></span></p>
  773. <?php
  774. if ($config['htmlPages']) {
  775. echo '<p class="footer_htmlPages">';
  776. foreach ($config['htmlPages'] as $fileName => $name) {
  777. echo ' <a href="'.$config['baseUrl'].$fileName.'.html">'.$name.'</a> ';
  778. }
  779. echo '</p>';
  780. }
  781. ?>
  782. </div>
  783. <!-- Check Upgrade -->
  784. <?php if ($config['checkUpdate'] != false) { ?>
  785. <script type="text/javascript">
  786. function checkUpdate() {
  787. var timeStamp = Math.floor(Date.now() / 1000);
  788. if (! localStorage.getItem('checkUpdate') || Math.floor(parseInt(localStorage.getItem('checkUpdate'))+<?= $config['checkUpdate'] ?>) < timeStamp) {
  789. localStorage.setItem('checkUpdate', timeStamp);
  790. $.ajax({
  791. url: "https://dl.zici.fr/file2link_checkupdate.php",
  792. type: "GET",
  793. crossDomain: true,
  794. dataType: "html",
  795. success: function (response) {
  796. localStorage.setItem('getVersion', response);
  797. },
  798. error: function (xhr, status) {
  799. trucAdir(3, 'Erreur dans le checkupdate' + status);
  800. }
  801. });
  802. }
  803. }
  804. checkUpdate();
  805. if (localStorage.getItem('getVersion')) {
  806. if (localStorage.getItem('getVersion').replace(/\n|\r/g,'') != '<?= VERSION ?>') {
  807. $('#upgrade').html('(v' + localStorage.getItem('getVersion').replace(/\n|\r/g,'') + ' is ready, <a href="https://framagit.org/kepon/file2link">upgrade</a>)');
  808. }
  809. }
  810. </script>
  811. <?php } ?>
  812. <?php @include_once('./footer-page.php'); ?>
  813. <?php } // mod maintenance end ?>
  814. </div>
  815. <div id="bg">
  816. <img src="<?= $config['backgroundImage'] ?>" alt="">
  817. </div>
  818. <!-- The template to display files available for upload -->
  819. <script id="template-upload" type="text/x-tmpl">
  820. {% for (var i=0, file; file=o.files[i]; i++) { %}
  821. <tr class="template-upload fade">
  822. <td>
  823. <span class="preview"></span>
  824. </td>
  825. <td>
  826. {% if (window.innerWidth > 480 || !o.options.loadImageFileTypes.test(file.type)) { %}
  827. <p class="name">{%=file.name%}</p>
  828. {% } %}
  829. <strong class="error text-danger"></strong>
  830. </td>
  831. <td>
  832. <p class="size">Processing...</p>
  833. <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
  834. </td>
  835. <td>
  836. {% if (!o.options.autoUpload && o.options.edit && o.options.loadImageFileTypes.test(file.type)) { %}
  837. <button class="btn btn-success edit" data-index="{%=i%}" disabled>
  838. <i class="glyphicon glyphicon-edit"></i>
  839. <span>Edit</span>
  840. </button>
  841. {% } %}
  842. {% if (!i && !o.options.autoUpload) { %}
  843. <button style="display: none" class="btn btn-primary start" disabled>
  844. <i class="glyphicon glyphicon-upload"></i>
  845. <span>Start</span>
  846. </button>
  847. {% } %}
  848. {% if (!i) { %}
  849. <button class="btn btn-warning cancel">
  850. <i class="glyphicon glyphicon-ban-circle"></i>
  851. <span><?= _('Cancel') ?></span>
  852. </button>
  853. {% } %}
  854. </td>
  855. </tr>
  856. {% } %}
  857. </script>
  858. <!-- The template to display files available for download -->
  859. <script id="template-download" type="text/x-tmpl">
  860. {% for (var i=0, file; file=o.files[i]; i++) { %}
  861. <tr class="template-download fade">
  862. <td>
  863. <span class="preview">
  864. {% if (file.thumbnailUrl) { %}
  865. <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
  866. {% } %}
  867. </span>
  868. </td>
  869. <td>
  870. {% if (window.innerWidth > 480 || !file.thumbnailUrl) { %}
  871. <p class="name">
  872. {% if (file.url) { %}
  873. <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
  874. {% } else { %}
  875. <span>{%=file.name%}</span>
  876. {% } %}
  877. </p>
  878. {% } %}
  879. {% if (file.error) { %}
  880. <div><span class="label label-danger">Error</span> {%=file.error%}</div>
  881. {% } %}
  882. </td>
  883. <td>
  884. <span class="size">{%=o.formatFileSize(file.size)%}</span>
  885. </td>
  886. <td>
  887. <button class="btn btn-warning cancel">
  888. <i class="glyphicon glyphicon-ban-circle"></i>
  889. <span><?= _('Cancel') ?></span>
  890. </button>
  891. </td>
  892. </tr>
  893. {% } %}
  894. </script>
  895. <!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
  896. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
  897. <!-- The Templates plugin is included to render the upload/download listings -->
  898. <!--
  899. <script src="https://blueimp.github.io/JavaScript-Templates/js/tmpl.min.js"></script>
  900. -->
  901. <script src="<?= $config['baseUrl'] ?>lib/blueimp/tmpl.min.js"></script>
  902. <!-- The Load Image plugin is included for the preview images and image resizing functionality -->
  903. <!--
  904. <script src="https://blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>
  905. -->
  906. <script src="<?= $config['baseUrl'] ?>lib/blueimp/load-image.all.min.js"></script>
  907. <!-- The Canvas to Blob plugin is included for image resizing functionality -->
  908. <!--
  909. <script src="https://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"></script>
  910. -->
  911. <script src="<?= $config['baseUrl'] ?>lib/blueimp/canvas-to-blob.min.js"></script>
  912. <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
  913. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
  914. <!-- The basic File Upload plugin -->
  915. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload.js"></script>
  916. <!-- The File Upload processing plugin -->
  917. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-process.js"></script>
  918. <!-- The File Upload image preview & resize plugin -->
  919. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-image.js"></script>
  920. <!-- The File Upload audio preview plugin -->
  921. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-audio.js"></script>
  922. <!-- The File Upload video preview plugin -->
  923. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-video.js"></script>
  924. <!-- The File Upload validation plugin -->
  925. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-validate.js"></script>
  926. <!-- The File Upload user interface plugin -->
  927. <script src="<?= $config['baseUrl'] ?>lib/jQuery-File-Upload/js/jquery.fileupload-ui.js"></script>
  928. <script type="text/javascript">
  929. function convertHumain2octect(value) {
  930. var regexKB = RegExp('KB$');
  931. var regexMB = RegExp('MB$');
  932. var regexGB = RegExp('GB$');
  933. if (regexKB.test(value)) {
  934. return parseFloat(fileSize)*1024;
  935. }else if (regexMB.test(value)) {
  936. return parseFloat(fileSize)*1024*1024;
  937. }else if (regexGB.test(value)) {
  938. return parseFloat(fileSize)*1024*1024*1024;
  939. }
  940. }
  941. function convertOctect2Humain(value) {
  942. if (value > 1000000000) {
  943. return (value/1024/1024/1024).toFixed(2) + ' Go';
  944. }else if (value > 1000000) {
  945. return (value/1024/1024).toFixed(2) + ' Mo';
  946. }else if (value > 1000) {
  947. return (value/1024).toFixed(2) + ' Ko';
  948. } else {
  949. return value;
  950. }
  951. }
  952. function checkQuotaFiles() {
  953. <?php
  954. if ($action == 'html') {
  955. $fileAlreadyUploadSizeTotal=0;
  956. $uploadDir=$config['uploadDir'].'/'.$id.'/';
  957. foreach (scandir($uploadDir) as $fileAlreadyUpload) {
  958. if (is_file($uploadDir.$fileAlreadyUpload)) {
  959. $fileAlreadyUploadSizeTotal=filesize($uploadDir.$fileAlreadyUpload)+$fileAlreadyUploadSizeTotal;
  960. }
  961. }
  962. echo 'var totalSize='.$fileAlreadyUploadSizeTotal.';';
  963. } else {
  964. echo 'var totalSize=0;';
  965. }
  966. ?>
  967. //~ console.log(totalSize);
  968. findUploadFiles=$('#fileupload').find('.size').get();
  969. for(var i = 0; i< findUploadFiles.length; i++){
  970. fileSize=findUploadFiles[i].innerText;
  971. totalSize=totalSize+convertHumain2octect(fileSize);
  972. }
  973. if (totalSize > <?= convertHumain2octect($config['maxUploadTotal']) ?>) {
  974. $('#maxUploadTotalError').show();
  975. $('#ButtonAdd').hide();
  976. $('#ButtonStart').hide();
  977. } else {
  978. $('#maxUploadTotalError').hide();
  979. $('#ButtonAdd').show();
  980. $('#ButtonStart').show();
  981. }
  982. if (findUploadFiles.length > 0) {
  983. $('#ButtonReset').show();
  984. } else {
  985. $('#ButtonReset').hide();
  986. $('#ButtonStart').hide();
  987. }
  988. //~ console.log(totalSize);
  989. return true;
  990. }
  991. $('#fileupload').fileupload({
  992. url: '<?= $config['baseUrl']?>/upload.php',
  993. added: function (e) {
  994. checkQuotaFiles();
  995. },
  996. started: function (e) {
  997. console.log('started');
  998. $('.shareUrlPrint').show();
  999. $('.expire-button').hide();
  1000. $('#uploadOptionsLinkShow').hide();
  1001. $('#uploadOptions').hide();
  1002. $('#ButtonStart').hide();
  1003. $('#ButtonMyFiles').hide();
  1004. $('#ButtonAdd').hide();
  1005. },
  1006. // Se déclenche
  1007. finished: function (e, data) {
  1008. // Si ce n'est pas une annulatoin mais bien une fin d'upload
  1009. if (data.errorThrown != 'abort') {
  1010. // On mémorise l'upload dans le localStorage
  1011. if (localStorage.getItem('myFiles')) {
  1012. var data = JSON.parse(localStorage.getItem('myFiles'));
  1013. } else {
  1014. var data = {items: []};
  1015. }
  1016. // S'il n'existe pas déjà
  1017. if (data.items.filter(function(e) { return e.id === $('#files_id').val(); }).length == 0) {
  1018. data.items.push(
  1019. {id: $('#files_id').val(), key: $('#files_key').val()}
  1020. );
  1021. localStorage.setItem('myFiles', JSON.stringify(data));
  1022. }
  1023. }
  1024. },
  1025. failed: function (e, data) {
  1026. console.log(data);
  1027. console.log(e);
  1028. // Si un upload est en cours
  1029. if (data.loaded > 0) {
  1030. //~ console.log(data);
  1031. //~ location.href='<?= $config['baseUrl']?>/'+$('#files_id').val()+'/';
  1032. $('#files_id').val(idGen());
  1033. $('#shareUrl').val('<?= $config['baseUrl'] ?>/' + $('#files_id').val() + '/');
  1034. var keyGen = Math.floor(Math.random() * (999999999999 - 100000000000) + 100000000000);
  1035. $('#files_key').val(keyGen);
  1036. } else {
  1037. checkQuotaFiles();
  1038. }
  1039. }
  1040. });
  1041. // Enable iframe cross-domain access via redirect option:
  1042. //~ $('#fileupload').fileupload(
  1043. //~ 'option',
  1044. //~ 'redirect',
  1045. //~ window.location.href.replace(/\/[^/]*$/, 'lib/jQuery-File-Upload-master//cors/result.html?%s')
  1046. //~ );
  1047. function redirectToFiles() {
  1048. location.replace('<?= $config['baseUrl']?>/'+ $('#files_id').val() + '/');
  1049. }
  1050. $('#fileupload').fileupload('option', {
  1051. // Enable image resizing, except for Android and Opera,
  1052. // which actually support image resizing, but fail to
  1053. // send Blob objects via XHR requests:
  1054. disableImageResize: /Android(?!.*Chrome)|Opera/.test(
  1055. window.navigator.userAgent
  1056. ),
  1057. imageMaxWidth: $('#resize').val(),
  1058. imageMaxHeight: $('#resize').val(),
  1059. maxFileSize: <?= convertHumain2octect($config['maxUploadPerFile']) ?>,
  1060. minFileSize: <?= convertHumain2octect($config['minUploadPerFile']) ?>,
  1061. maxNumberOfFiles: <?= $config['maxUploadNb'] ?>,
  1062. sequentialUploads: true,
  1063. limitConcurrentUploads: 1, // To limit the number of concurrent uploads, set this option to an integer value greater than 0.
  1064. acceptFileTypes: <?= $config['acceptFileTypes'] ?>
  1065. }).on('fileuploadprogressall', function (e, data) {
  1066. if (data.loaded == data.total) {
  1067. $('#ButtonReset').hide();
  1068. $('.btn.btn-warning.cancel').hide();
  1069. $('#redirectToFiles').show();
  1070. $('.redirectToFilesId').text($('#files_id').val());
  1071. setTimeout(redirectToFiles, 1000);
  1072. }
  1073. });
  1074. <?php if ($action == 'html') { ?>
  1075. $('#files_id').val('<?= $id ?>');
  1076. <?php } else { ?>
  1077. $('#files_id').val(idGen());
  1078. var keyGen = Math.floor(Math.random() * (999999999999 - 100000000000) + 100000000000);
  1079. $('#files_key').val(keyGen);
  1080. <?php } ?>
  1081. $('#shareUrl').val('<?= $config['baseUrl'] ?>/' + $('#files_id').val() + '/');
  1082. </script>
  1083. <!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
  1084. <!--[if (gte IE 8)&(lt IE 10)]>
  1085. <script src="js/cors/jquery.xdr-transport.js"></script>
  1086. <![endif]-->
  1087. </body>
  1088. </html>
  1089. <?php
  1090. if ($config['expireCron'] == 'web') {
  1091. if (is_file($config['uploadDir'].'/.cronWeb')) {
  1092. if (file_get_contents($config['uploadDir'].'/.cronWeb')+$config['expireCronFreq'] < time()) {
  1093. cronExpire();
  1094. file_put_contents($config['uploadDir'].'/.cronWeb', time());
  1095. }
  1096. } else {
  1097. file_put_contents($config['uploadDir'].'/.cronWeb', time());
  1098. }
  1099. }
  1100. @include_once('./footer.php');
  1101. ?>