123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * Insipid
- * Personal web-bookmark-system
- *
- * Copyright 2016-2023 Johannes Keßler
- *
- * Development starting from 2011: Johannes Keßler
- * https://www.bananas-playground.net/projekt/insipid/
- *
- * creator:
- * Luke Reeves <luke@neuro-tech.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
- *
- */
- $_displayEditButton = false;
- if(Summoner::simpleAuthCheck() === true) {
- $_displayEditButton = true;
- $moderationAmount = $Management->moderationAmount();
- }
- if(isset($_POST['statsDeleteLocalStorage'])) {
- if($Management->clearLocalStorage() === true) {
- $TemplateData['refresh'] = 'index.php?p=stats';
- }
- else {
- $submitFeedback['message'] = $T->t('stats.storage.clean.fail');
- $submitFeedback['status'] = 'error';
- }
- }
- if(isset($_POST['statsCreateDBBackup'])) {
- require 'lib/Mysqldump.php';
- $dumpSettings = array(
- 'include-tables' => array(
- DB_PREFIX.'_category',
- DB_PREFIX.'_categoryrelation',
- DB_PREFIX.'_link',
- DB_PREFIX.'_tag',
- DB_PREFIX.'_tagrelation'
- ),
- 'include-views' => array(
- DB_PREFIX.'_combined'
- ),
- 'default-character-set' => 'utf8mb4'
- );
- $backupTmpFile = tempnam(sys_get_temp_dir(),'inspid');
- try {
- $dump = new Mysqldump('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD, $dumpSettings);
- $dump->start($backupTmpFile);
- } catch (Exception $e) {
- echo 'mysqldump-php error: ' . $e->getMessage();
- }
- header('Content-Type: application/octet-stream');
- header("Content-Transfer-Encoding: Binary");
- header("Content-disposition: attachment; filename=insipid-db-backup-full.sql");
- readfile($backupTmpFile);
- exit();
- }
- if(isset($_POST['statsImportXML'])) {
- $_options = array();
- if(isset($_FILES['importxmlfile']) && !empty($_FILES['importxmlfile'])) {
- $_options['overwrite'] = false;
- if(isset($_POST['importOverwrite'])) {
- $_options['overwrite'] = true;
- }
- $do = $Management->processImportFile($_FILES['importxmlfile'], $_options);
- if(isset($do['status']) && $do['status'] === 'success') {
- $submitFeedback['status'] = 'success';
- $submitFeedback['message'] = $do['message'];
- }
- else {
- $submitFeedback['message'] = $do['message'];
- $submitFeedback['status'] = 'error';
- }
- }
- else {
- $submitFeedback['message'] = $T->t('stats.import.missing.file');
- $submitFeedback['status'] = 'error';
- }
- }
- if(isset($_POST['statsUpdateSearchIndex'])) {
- if($Management->updateSearchIndex() === true) {
- $TemplateData['refresh'] = 'index.php?p=stats';
- }
- else {
- $submitFeedback['message'] = $T->t('stats.search.index.fail');
- $submitFeedback['status'] = 'error';
- }
- }
- $linkAmount = $Management->linkAmount();
- $tagAmount = $Management->tagAmount();
- $categoryAmount = $Management->categoryAmount();
- $localStorageAmount = $Management->storageAmount();
- $localStorageAmount = Summoner::humanFileSize($localStorageAmount);
|