1<?php 2 3use dokuwiki\Extension\Plugin; 4 5/** 6 * DokuWiki Plugin cosmocode (Helper Component) 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author Andreas Gohr <dokuwiki@cosmocode.de> 10 */ 11class helper_plugin_cosmocode_support extends Plugin 12{ 13 /** 14 * Get a list of all plugins and their versions 15 * 16 * There is no simple way to get this yet. In future versions of the extension manager we might be able to get this 17 * from there. We supress all errors that might occur during loading of the plugins. 18 * @return array 19 */ 20 public function getPlugins() 21 { 22 ob_start(); 23 $plugins = []; 24 foreach (['syntax', 'admin', 'auth', 'helper', 'action', 'renderer'] as $type) { 25 $list = plugin_list($type); 26 foreach ($list as $plugin) { 27 [$name] = explode('_', $plugin); 28 if (isset($plugins[$name])) continue; 29 try { 30 $instance = plugin_load($type, $plugin); 31 if (!$instance) continue; 32 $info = $instance->getInfo(); 33 $plugins[$name] = $info['date']; 34 } catch (\Exception $ignore) { 35 } 36 } 37 } 38 ob_clean(); 39 40 return $plugins; 41 } 42 43 /** 44 * Get informational data about the linux distribution this wiki is running on 45 * 46 * @return array an os-release array, might be empty 47 * @see https://gist.github.com/natefoo/814c5bf936922dad97ff 48 * @todo this will be included in future versions of DokuWiki 49 */ 50 function getOsRelease() 51 { 52 $osRelease = []; 53 if (file_exists('/etc/os-release')) { 54 // pretty much any common Linux distribution has this 55 $osRelease = parse_ini_file('/etc/os-release'); 56 } elseif (file_exists('/etc/synoinfo.conf') && file_exists('/etc/VERSION')) { 57 // Synology DSM has its own way 58 $synoInfo = parse_ini_file('/usr/lib/synoinfo.conf'); 59 $synoVersion = parse_ini_file('/etc/VERSION'); 60 $osRelease['NAME'] = 'Synology DSM'; 61 $osRelease['ID'] = 'synology'; 62 $osRelease['ID_LIKE'] = 'linux'; 63 $osRelease['VERSION_ID'] = $synoVersion['productversion']; 64 $osRelease['VERSION'] = $synoVersion['productversion']; 65 $osRelease['SYNO_MODEL'] = $synoInfo['upnpmodelname']; 66 $osRelease['PRETTY_NAME'] = implode(' ', [$osRelease['NAME'], $osRelease['VERSION'], $osRelease['SYNO_MODEL']]); 67 } 68 return $osRelease; 69 } 70 71 /** 72 * Get some data about the environment this wiki is running in 73 * 74 * @return array 75 * @todo this will be included in future versions of DokuWiki 76 */ 77 function getRuntimeVersions() 78 { 79 $data = []; 80 $data['php'] = 'PHP ' . PHP_VERSION; 81 82 $osRelease = $this->getOsRelease(); 83 if (isset($osRelease['PRETTY_NAME'])) { 84 $data['dist'] = $osRelease['PRETTY_NAME']; 85 } 86 87 $data['os'] = php_uname('s') . ' ' . php_uname('r'); 88 $data['sapi'] = PHP_SAPI; 89 90 if (getenv('KUBERNETES_SERVICE_HOST')) { 91 $data['container'] = 'Kubernetes'; 92 } elseif (file_exists('/.dockerenv')) { 93 $data['container'] = 'Docker'; 94 } 95 96 return $data; 97 } 98} 99