stats.inc.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Insipid
  4. * Personal web-bookmark-system
  5. *
  6. * Copyright 2016-2019 Johannes Keßler
  7. *
  8. * Development starting from 2011: Johannes Keßler
  9. * https://www.bananas-playground.net/projekt/insipid/
  10. *
  11. * creator:
  12. * Luke Reeves <luke@neuro-tech.net>
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  26. *
  27. */
  28. $_displayEditButton = false;
  29. if(Summoner::simpleAuthCheck() === true) {
  30. $_displayEditButton = true;
  31. $moderationAmount = $Management->moderationAmount();
  32. }
  33. if(isset($_POST['statsDeleteLocalStorage'])) {
  34. if($Management->clearLocalStorage() === true) {
  35. $TemplateData['refresh'] = 'index.php?p=stats';
  36. }
  37. else {
  38. $submitFeedback['message'] = 'Something went wrong while storage cleaning';
  39. $submitFeedback['status'] = 'error';
  40. }
  41. }
  42. if(isset($_POST['statsCreateDBBackup'])) {
  43. require_once 'lib/Mysqldump.php';
  44. $backupTmpFile = tempnam(sys_get_temp_dir(),'inspid');
  45. $dump = new Ifsnop\Mysqldump\Mysqldump('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD);
  46. $dump->start($backupTmpFile);
  47. header('Content-Type: application/octet-stream');
  48. header("Content-Transfer-Encoding: Binary");
  49. header("Content-disposition: attachment; filename=inspid-db-backup-full.sql");
  50. readfile($backupTmpFile);
  51. exit();
  52. }
  53. $linkAmount = $Management->linkAmount();
  54. $tagAmount = $Management->tagAmount();
  55. $categoryAmount = $Management->categoryAmount();
  56. $localStorageAmount = $Management->storageAmount();
  57. $localStorageAmount = Summoner::humanFileSize($localStorageAmount);