]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
stats and some other code cleanup
authorBanana <mail@bananas-playground.net>
Tue, 10 Aug 2021 09:02:36 +0000 (11:02 +0200)
committerBanana <mail@bananas-playground.net>
Tue, 10 Aug 2021 09:02:36 +0000 (11:02 +0200)
17 files changed:
CHANGELOG
TODO
documentation/requirements.txt
documentation/setup/bibliotheca.sql
documentation/setup/install.txt
sources/updatecheck.txt
upgrade/from-version-1.2.txt
webclient/index.php
webclient/lib/doomguy.class.php
webclient/lib/managecollections.class.php
webclient/lib/summoner.class.php
webclient/lib/trite.class.php
webclient/setup/bibliotheca.sql.default
webclient/setup/index.php
webclient/view/default/sysinfo/sysinfo.html [new file with mode: 0644]
webclient/view/default/sysinfo/sysinfo.php [new file with mode: 0644]
webclient/view/default/ui/css/style.css

index 2acd30cac457be79220dec629a7a0567a68fb2f4..41abb567ef2131096b7db900808538f8c46e5fbd 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,8 @@
 1.x - Rrajigar Mine
        * Fixed install sql file.
        * New field: artists - lookupmultiple field
-       * Added setup file. See setup/install.txt for more details
+       * Added setup process. See setup/install.txt for more details
+       * Stats info page
 
 1.2 - NyLeve's Falls 20210717
        * Updated requirements information
diff --git a/TODO b/TODO
index 42d468e459fb1790bff14e65e27cdeefeca49019..fc3c759fcadc3dc3b03c2eb42e6d9a34187fc344 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 * Automatic upgrades of DB
-* stats overview page. amount of entries. file / cache and db storage. Version info and where to find it.
 * Definition of fields in "card view"
 * User and groupmanagement: Check where a user or group is used!
 * Better error handling and display while adding / update and delete
index c39ad59eac265af41f00f208e72fb1d8af632491..eff02e751c050066817e9d3a69979e88427a0e15 100644 (file)
@@ -1,5 +1,6 @@
 * A Webserver (tested on Apache 2.4)
 * PHP 7+ with mysqli, mbstring, curl
 * MySQL 8+; MariaDB 10.2/MySQL 8
+-- User with full rights on the Database. Including lock tables
 * At least 20MB webserver storage WITHOUT images
-* At least 100MB DB storage.
+* At least 20MB DB storage.
index fe12c78d24b1aaa03a3bd08e2ff474134bb53120..fa1241dc756f09f330b20e6f3bd77508df03764a 100644 (file)
@@ -98,7 +98,7 @@ CREATE TABLE `#REPLACEME#_menu` (
   `position` int NOT NULL DEFAULT '0',
   `category` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -107,7 +107,7 @@ CREATE TABLE `#REPLACEME#_menu` (
 
 LOCK TABLES `#REPLACEME#_menu` WRITE;
 /*!40000 ALTER TABLE `#REPLACEME#_menu` DISABLE KEYS */;
-INSERT INTO `#REPLACEME#_menu` VALUES (1,'Dashboard','','home',1,1,'rw-r--r--',0,'show'),(2,'Collections','collections','database',1,1,'rw-r--r--',1,'show'),(3,'Tags','tags','tag',1,1,'rw-r--r--',2,'show'),(4,'Add','manageentry','plus-circle',1,2,'rw-rw----',0,'manage'),(6,'Tags','managetags','tag',1,2,'rw-rw----',2,'manage'),(7,'Collections','managecolletions','database',1,2,'rw-rw----',3,'manage'),(8,'Users','manageusers','users',1,1,'rw-------',4,'manage'),(9,'Login','auth','',1,1,'rw-r--r--',0,''),(10,'Collection fields','managecollectionfields','',1,2,'rw-rw----',0,''),(11,'Entry','entry','',1,1,'rw-r--r--',0,''),(12,'Search','search','',1,1,'rw-r--r--',0,''),(14,'Tool','tool','',1,2,'rw-rw----',0,''),(15,'Advanced search','advancedsearch','',1,1,'rw-r--r--',0,''),(16,'Profile','profile','user',1,2,'rw-rw----',6,'manage'),(17,'Groups','managegroups','users',1,1,'rw-------',5,'manage'),(18,'Bulkedit','bulkedit','',1,2,'rw-rw----',0,'');
+INSERT INTO `#REPLACEME#_menu` VALUES (1,'Dashboard','','home',1,1,'rw-r--r--',0,'show'),(2,'Collections','collections','database',1,1,'rw-r--r--',1,'show'),(3,'Tags','tags','tag',1,1,'rw-r--r--',2,'show'),(4,'Add','manageentry','plus-circle',1,2,'rw-rw----',0,'manage'),(6,'Tags','managetags','tag',1,2,'rw-rw----',2,'manage'),(7,'Collections','managecolletions','database',1,2,'rw-rw----',3,'manage'),(8,'Users','manageusers','users',1,1,'rw-------',4,'manage'),(9,'Login','auth','',1,1,'rw-r--r--',0,''),(10,'Collection fields','managecollectionfields','',1,2,'rw-rw----',0,''),(11,'Entry','entry','',1,1,'rw-r--r--',0,''),(12,'Search','search','',1,1,'rw-r--r--',0,''),(14,'Tool','tool','',1,2,'rw-rw----',0,''),(15,'Advanced search','advancedsearch','',1,1,'rw-r--r--',0,''),(16,'Profile','profile','user',1,2,'rw-rw----',6,'manage'),(17,'Groups','managegroups','users',1,1,'rw-------',5,'manage'),(18,'Bulkedit','bulkedit','',1,2,'rw-rw----',0,''),(19,'System Information','sysinfo','info',1,1,'rw-------',3,'show');
 /*!40000 ALTER TABLE `#REPLACEME#_menu` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 1bfa447425ca112415c8c086f2a0c210883d51d7..e1be19b9ac5d1fa283d081e36313bdf457c69f67 100644 (file)
@@ -26,3 +26,6 @@ Default admin user pw: test
 Login with default admin account and change the password!
 Create your own user.
 Create your first collection.
+
+To re run the setup:
+Upload the setup folder again. It deletes itself after a successfull setup
index 02964ff5e13ce34f82499d02769c20b1a5528a7b..ee3e62a2bd87713f69524279cab921ad0bd4e5c9 100644 (file)
@@ -2,10 +2,13 @@ setup
 - sql file mit mysqldump
 - config files in setup.php
 - options in setup.php
+- sql file in setup
 
 documentation
 version, readme and changelog
 
-upgrade file
+upgrade file with correct placeholders
 
-correct placeholders
+correct placeholders in sql file for manual setup
+
+correct version info in VERSION and index.php
index c35efebd73361513618c6c2b4d37b6d278ab023a..6f6c0c52b768aa4559af9f6405c02ea9d300f242 100644 (file)
@@ -1,3 +1,4 @@
 # DB changes. Run each line against your bibliotheca DB.
 # Replace #REPLACEME# with your table prefix. Default is bib
 INSERT INTO `#REPLACEME#_sys_fields` (`id`, `identifier`, `displayname`, `type`, `searchtype`, `createstring`, `inputValidation`, `value`, `apiinfo`, `created`, `modified`, `modificationuser`, `owner`, `group`, `rights`) VALUES (NULL, 'artists', 'Artists', 'lookupmultiple', 'tag', NULL, 'allowSpace', NULL, 'string 64', NOW(), NOW(), NULL, '1', '1', 'rw-r--r--');
+INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES (NULL, 'System Information', 'sysinfo', 'info', '1', '1', 'rw-------', '3', 'show');
index d379624ed3bef7df9792e2c23139144e2359465c..65be066de30a9d3251790f9d5e960020277fa7eb 100644 (file)
@@ -18,6 +18,8 @@
 
 require_once './config/config.php';
 
+define('BIB_VERSION','1.x - Rrajigar Mine ()');
+
 mb_http_output('UTF-8');
 mb_internal_encoding('UTF-8');
 ini_set('error_reporting',-1); // E_ALL & E_STRICT
index 3058afdf45c4cc1eb8cd9751d2f6bf3518d5a716..39432813dd3280d49e9c593eb529912895e47c53 100644 (file)
@@ -251,7 +251,7 @@ class Doomguy {
         * @param bool $tableName
         * @return string
         */
-       public function getSQLRightsString($mode = "read", $tableName=false) {
+       public function getSQLRightsString($mode = "read", $tableName=false): string {
                $str = '';
                $prefix = '';
 
index 324153da21ad1ddeff0a6393cab8126735498535..023c238494fe539f0aacb000403329f7d1cd0ae6 100644 (file)
@@ -40,47 +40,17 @@ class ManageCollections {
         * @param mysqli $databaseConnectionObject
         * @param Doomguy $userObj
         */
-       public function __construct($databaseConnectionObject, $userObj) {
+       public function __construct(mysqli $databaseConnectionObject, Doomguy $userObj) {
                $this->_DB = $databaseConnectionObject;
                $this->_User = $userObj;
        }
 
-       /**
-        * Load collection info from table. Checks user rights
-        *
-        * @param string $id
-        * @param string $rightsMode
-        * @return array
-        */
-       public function getCollection($id,$rightsMode="read") {
-               $ret = array();
-
-               if (Summoner::validate($id, 'digit')) {
-                       $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`
-                                       FROM `".DB_PREFIX."_collection` AS c
-                                       WHERE ".$this->_User->getSQLRightsString($rightsMode, "c")."
-                                       AND `c`.`id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
-                       try {
-                               $query = $this->_DB->query($queryStr);
-                               if ($query !== false && $query->num_rows > 0) {
-                                       $ret = $query->fetch_assoc();
-                               }
-                       }
-                       catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
-                       }
-               }
-
-               return $ret;
-       }
-
        /**
         * Get all available collections for display based on current user
         *
         * @return array
         */
-       public function getCollections() {
+       public function getCollections(): array{
                $ret = array();
 
                $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
@@ -94,7 +64,6 @@ class ManageCollections {
                if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
                try {
                        $query = $this->_DB->query($queryStr);
-
                        if ($query !== false && $query->num_rows > 0) {
                                while (($result = $query->fetch_assoc()) != false) {
                                        $ret[$result['id']] = $result;
index ea684dbbf5ca31c29dab1b638ac15e02d6cc0416..b3aed8cd43890862d9e5ea7d99905c426ff6a09c 100644 (file)
@@ -684,4 +684,34 @@ class Summoner {
 
                return $ret;
        }
+
+       /**
+        * Size of the folder and the data within in bytes
+        *
+        * @param string $dir
+        * @return int
+        */
+       static function folderSize(string $dir): int {
+               $size = 0;
+
+               foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
+                       $size += is_file($each) ? filesize($each) : self::folderSize($each);
+               }
+
+               return $size;
+       }
+
+       /**
+        * Given bytes to human format with unit
+        *
+        * @param int $bytes
+        * @return string
+        */
+       static function bytesToHuman(int $bytes): string {
+               $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
+               for ($i = 0; $bytes > 1024; $i++) {
+                       $bytes /= 1024;
+               }
+               return round($bytes, 2) . ' ' . $units[$i];
+       }
 }
index 9538730a77b21314bdbb4bbc51ba141391925487..dc65c381d99c004613a19dcce2676935c38a29e1 100644 (file)
@@ -104,7 +104,7 @@ class Trite {
        }
 
        /**
-        * Get information to display for current collection
+        * Get information to display for given collection
         * based on current user and given rights
         *
         * @param string $id The collection ID to load
@@ -145,10 +145,10 @@ class Trite {
         * get the value of the specified param from the collection data array
         *
         * @param string $param
-        * @return bool|mixed
+        * @return string
         */
-       public function param($param) {
-               $ret = false;
+       public function param(string $param): string {
+               $ret = '';
 
                $param = trim($param);
 
@@ -163,9 +163,10 @@ class Trite {
         * Get all available collections for display based on current user
         * and read mode
         *
+        * @param string $rightsMode
         * @return array
         */
-       public function getCollections($rightsMode="read") {
+       public function getCollections($rightsMode="read"): array {
                $ret = array();
 
                $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`
@@ -264,7 +265,7 @@ class Trite {
         * @param string $search String value to search value against
         * @return array
         */
-       public function getTags($search='') {
+       public function getTags($search=''): array {
                $ret = array();
 
                $queryStr = "SELECT `cf`.`fk_field_id` AS id,
@@ -311,7 +312,7 @@ class Trite {
         *
         * @return array
         */
-       public function getAvailableTools() {
+       public function getAvailableTools(): array {
                $ret = array();
 
                $queryStr = "SELECT `t`.`id`, `t`.`name`, `t`.`description`, `t`.`action`, `t`.`target`
@@ -334,6 +335,64 @@ class Trite {
                return  $ret;
        }
 
+       /**
+        * Some statistics about the current collection.
+        * Entries, tags, storage
+        * Adds a stats array to _collectionData
+        *
+        * @return array
+        */
+       public function getStats(): array {
+               if(empty($this->_id)) return array();
+
+               $this->_collectionData['stats'] = array();
+
+               $queryStr = "SELECT COUNT(*) AS entries FROM `".DB_PREFIX."_collection_entry_".$this->_id."`";
+               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               try {
+                       $query = $this->_DB->query($queryStr);
+                       if($query !== false && $query->num_rows > 0) {
+                               $result = $query->fetch_assoc();
+                               $this->_collectionData['stats']['entriesCount'] = $result['entries'];
+                       }
+               }
+               catch (Exception $e) {
+                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+               }
+
+               $tags = $this->getTags();
+               $tagsCount = 0;
+               foreach ($tags as $k=>$v) {
+                       $tagsCount += count($v['entries']);
+               }
+               $this->_collectionData['stats']['tagsCount'] = $tagsCount;
+
+               $tableSize = 0; // in MB
+               $queryStr = "SELECT (DATA_LENGTH + INDEX_LENGTH) AS `size`
+                                               FROM information_schema.TABLES
+                                               WHERE TABLE_SCHEMA = 'bibliotheca'
+                                               AND TABLE_NAME LIKE 'bib_collection_%_".$this->_id."'
+                                               ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC";
+               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               try {
+                       $query = $this->_DB->query($queryStr);
+                       if($query !== false && $query->num_rows > 0) {
+                               while(($result = $query->fetch_assoc()) != false) {
+                                       $tableSize += $result['size'];
+                               }
+                       }
+               }
+               catch (Exception $e) {
+                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+               }
+               $this->_collectionData['stats']['tableSize'] = Summoner::bytesToHuman($tableSize);
+
+               $this->_collectionData['stats']['storageSize'] = Summoner::bytesToHuman(Summoner::folderSize(PATH_STORAGE.'/'.$this->_id));
+
+
+               return $this->_collectionData;
+       }
+
        /**
         * set some defaults by init of the class
         *
@@ -351,15 +410,20 @@ class Trite {
        /**
         * Make a key=>value array of a comma seperated string and use the value as key
         *
-        * @param array $data
+        * @param string $data
         * @return array
         */
-       private function _loadAdvancedSearchTableFields($data) {
+       private function _loadAdvancedSearchTableFields(string $data): array {
                $ret = array();
 
-               $_t = explode(',',$data);
-               foreach($_t as $e) {
-                       $ret[$e] = $e;
+               if(!strstr($data, ',')) {
+                       $ret[$data] = $data;
+               }
+               else {
+                       $_t = explode(',',$data);
+                       foreach($_t as $e) {
+                               $ret[$e] = $e;
+                       }
                }
 
                return $ret;
index fe12c78d24b1aaa03a3bd08e2ff474134bb53120..fa1241dc756f09f330b20e6f3bd77508df03764a 100644 (file)
@@ -98,7 +98,7 @@ CREATE TABLE `#REPLACEME#_menu` (
   `position` int NOT NULL DEFAULT '0',
   `category` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -107,7 +107,7 @@ CREATE TABLE `#REPLACEME#_menu` (
 
 LOCK TABLES `#REPLACEME#_menu` WRITE;
 /*!40000 ALTER TABLE `#REPLACEME#_menu` DISABLE KEYS */;
-INSERT INTO `#REPLACEME#_menu` VALUES (1,'Dashboard','','home',1,1,'rw-r--r--',0,'show'),(2,'Collections','collections','database',1,1,'rw-r--r--',1,'show'),(3,'Tags','tags','tag',1,1,'rw-r--r--',2,'show'),(4,'Add','manageentry','plus-circle',1,2,'rw-rw----',0,'manage'),(6,'Tags','managetags','tag',1,2,'rw-rw----',2,'manage'),(7,'Collections','managecolletions','database',1,2,'rw-rw----',3,'manage'),(8,'Users','manageusers','users',1,1,'rw-------',4,'manage'),(9,'Login','auth','',1,1,'rw-r--r--',0,''),(10,'Collection fields','managecollectionfields','',1,2,'rw-rw----',0,''),(11,'Entry','entry','',1,1,'rw-r--r--',0,''),(12,'Search','search','',1,1,'rw-r--r--',0,''),(14,'Tool','tool','',1,2,'rw-rw----',0,''),(15,'Advanced search','advancedsearch','',1,1,'rw-r--r--',0,''),(16,'Profile','profile','user',1,2,'rw-rw----',6,'manage'),(17,'Groups','managegroups','users',1,1,'rw-------',5,'manage'),(18,'Bulkedit','bulkedit','',1,2,'rw-rw----',0,'');
+INSERT INTO `#REPLACEME#_menu` VALUES (1,'Dashboard','','home',1,1,'rw-r--r--',0,'show'),(2,'Collections','collections','database',1,1,'rw-r--r--',1,'show'),(3,'Tags','tags','tag',1,1,'rw-r--r--',2,'show'),(4,'Add','manageentry','plus-circle',1,2,'rw-rw----',0,'manage'),(6,'Tags','managetags','tag',1,2,'rw-rw----',2,'manage'),(7,'Collections','managecolletions','database',1,2,'rw-rw----',3,'manage'),(8,'Users','manageusers','users',1,1,'rw-------',4,'manage'),(9,'Login','auth','',1,1,'rw-r--r--',0,''),(10,'Collection fields','managecollectionfields','',1,2,'rw-rw----',0,''),(11,'Entry','entry','',1,1,'rw-r--r--',0,''),(12,'Search','search','',1,1,'rw-r--r--',0,''),(14,'Tool','tool','',1,2,'rw-rw----',0,''),(15,'Advanced search','advancedsearch','',1,1,'rw-r--r--',0,''),(16,'Profile','profile','user',1,2,'rw-rw----',6,'manage'),(17,'Groups','managegroups','users',1,1,'rw-------',5,'manage'),(18,'Bulkedit','bulkedit','',1,2,'rw-rw----',0,''),(19,'System Information','sysinfo','info',1,1,'rw-------',3,'show');
 /*!40000 ALTER TABLE `#REPLACEME#_menu` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 51d19c28876d8dc041fb5615c33291be29c4f995..ae360d866cdb9977f8f9e601f61dcbb84bd67afe 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * A plain and simple setup for bibliotheca
+ * It creates the config file based on the .default file.
+ * It creates the default database tables.
+ * It self deletes after a setup is complete to reduce some sercuirty risks
+ */
+
 mb_http_output('UTF-8');
 mb_internal_encoding('UTF-8');
 ini_set('error_reporting',-1); // E_ALL & E_STRICT
@@ -41,6 +48,9 @@ if(!is_dir('../storage') || !is_writeable('../storage')) {
 if(!is_dir('../systemout') || !is_writeable('../systemout')) {
        die('Missing correct write permissions for ../systemout dir');
 }
+if(!is_writeable(getcwd())) {
+       die('Missing correct write/delete permissions for the setup folder');
+}
 
 $configStep = 'ready';
 $configFile = '../config/config.php';
@@ -164,7 +174,6 @@ switch($configStep) {
                        $DB->query("SET collation_connection = 'utf8mb4_unicode_ci'");
                }
 
-
                if(!empty($_conCheck)) {
                        try {
                                $query = $DB->query("SELECT * FROM information_schema.tables WHERE table_schema = '".DB_NAME."' AND table_name = '".DB_PREFIX."_sys_fields' LIMIT 1");
diff --git a/webclient/view/default/sysinfo/sysinfo.html b/webclient/view/default/sysinfo/sysinfo.html
new file mode 100644 (file)
index 0000000..873b338
--- /dev/null
@@ -0,0 +1,32 @@
+<h3 class="uk-h3">System information</h3>
+<div class="uk-grid-small uk-grid-row-small" uk-grid>
+       <div class="uk-width-1-2">
+               <div class="uk-grid-divider uk-child-width-expand@s" uk-grid>
+                       <?php foreach($TemplateData['existingCollections'] as $k=>$v) { ?>
+                       <div>
+                               <p>
+                                       <b><?php echo $v['name']; ?></b><br/>
+                                       <?php echo $v['description']; ?>
+                               </p>
+                               <p>
+                                       Created: <code><?php echo $v['created']; ?></code></code><br />
+                                       Entries: <code><?php echo $v['stats']['entriesCount']; ?></code><br />
+                                       Tags: <code><?php echo $v['stats']['tagsCount']; ?></code><br />
+                                       DB Usage: <code><?php echo $v['stats']['tableSize']; ?></code><br />
+                                       Disk Usage: <code><?php echo $v['stats']['storageSize']; ?></code>
+                               </p>
+                       </div>
+                       <?php } ?>
+               </div>
+       </div>
+       <div class="uk-width-1-2">
+               <ul>
+                       <li>Bibliotheca: <code><?php echo $TemplateData['bibVersion']; ?></code></li>
+                       <li>Apache (depends on ServerTokens setting): <code><?php echo $TemplateData['apacheVersion']; ?></code></li>
+                       <li>PHP: <code><?php echo $TemplateData['phpVersion']; ?></code></li>
+                       <li>MySQL server: <code><?php echo $TemplateData['mysqlVersion']; ?></code></li>
+                       <li>MySQL data usage: <code><?php echo $TemplateData['overallTableSize']; ?></code>MB</li>
+                       <li>Storage usage: <code><?php echo $TemplateData['overallStorageSize']; ?></code></li>
+               </ul>
+       </div>
+</div>
diff --git a/webclient/view/default/sysinfo/sysinfo.php b/webclient/view/default/sysinfo/sysinfo.php
new file mode 100644 (file)
index 0000000..6b479bd
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+* Bibliotheca
+*
+* Copyright 2018-2020 Johannes Keßler
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+$TemplateData['bibVersion'] = BIB_VERSION;
+$TemplateData['apacheVersion'] = apache_get_version();
+$TemplateData['phpVersion'] = phpversion();
+$TemplateData['mysqlVersion'] = mysqli_get_server_info($DB);
+
+$overallTableSize = 0; // MB
+$queryStr = "SELECT (DATA_LENGTH + INDEX_LENGTH) AS `size`
+                                               FROM information_schema.TABLES
+                                               WHERE TABLE_SCHEMA = 'bibliotheca'
+                                               ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC";
+if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+try {
+       $query = $DB->query($queryStr);
+       if($query !== false && $query->num_rows > 0) {
+               while(($result = $query->fetch_assoc()) != false) {
+                       $overallTableSize += $result['size'];
+               }
+       }
+}
+catch (Exception $e) {
+       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+}
+$TemplateData['overallTableSize'] = Summoner::bytesToHuman($overallTableSize);
+
+$TemplateData['overallStorageSize'] = Summoner::bytesToHuman(Summoner::folderSize(PATH_STORAGE));
+
+require_once 'lib/trite.class.php';
+$Trite = new Trite($DB,$Doomguy);
+$TemplateData['existingCollections'] = $Trite->getCollections("write");
+foreach($TemplateData['existingCollections'] as $k=>$v) {
+       $Trite->load($k);
+       $TemplateData['existingCollections'][$k] = $Trite->getStats();
+}
index 4ac5c05b43306f853970683f8ef61fd5bc50726a..94b30839f88c5934682707e9c14da8ca20b6d88f 100644 (file)
@@ -11,3 +11,7 @@
 .input-multiple-template {
        margin: 1px;
 }
+
+.uk-navbar-dropdown {
+       width: auto;
+}