diff --git a/lib/plugins/popularity/admin.php b/lib/plugins/popularity/admin.php new file mode 100644 index 0000000000000000000000000000000000000000..fc2ab3e3fb6fa7cce20609c53ed4ac0df2930621 --- /dev/null +++ b/lib/plugins/popularity/admin.php @@ -0,0 +1,249 @@ +<?php +/** + * Popularity Feedback Plugin + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Andreas Gohr <andi@splitbrain.org> + */ +// must be run within Dokuwiki +if(!defined('DOKU_INC')) die(); + +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'admin.php'); +require_once(DOKU_INC.'inc/infoutils.php'); +require_once(DOKU_INC.'inc/pluginutils.php'); +require_once(DOKU_INC.'inc/search.php'); + +/** + * All DokuWiki plugins to extend the admin function + * need to inherit from this class + */ +class admin_plugin_popularity extends DokuWiki_Admin_Plugin { + var $version = '2008-02-18'; + + + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Andreas Gohr', + 'email' => 'andi@splitbrain.org', + 'date' => $this->version, + 'name' => 'Popularity Feedback Plugin', + 'desc' => 'Send anonymous data about your wiki to the developers.', + 'url' => 'http://wiki.splitbrain.org/wiki:popularity', + ); + } + + /** + * return prompt for admin menu + */ + function getMenuText($language) { + return $this->getLang('name'); + } + + /** + * return sort order for position in admin menu + */ + function getMenuSort() { + return 2000; + } + + /** + * handle user request + * + * + * @author Andreas Gohr <andi@splitbrain.org> + */ + function handle() { + } + + /** + * @author Andreas Gohr <andi@splitbrain.org> + */ + function html() { + echo $this->locale_xhtml('intro'); + + flush(); + $data = $this->_gather(); + echo '<form method="post" action="http://update.dokuwiki.org/popularity.php" accept-charset="utf-8">'; + echo '<fieldset style="width: 60%;">'; + echo '<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">'; + foreach($data as $key => $val){ + if(is_array($val)) foreach($val as $v){ + echo hsc($key)."\t".hsc($v)."\n"; + }else{ + echo hsc($key)."\t".hsc($val)."\n"; + } + } + echo '</textarea><br />'; + echo '<input type="submit" class="button" value="'.$this->getLang('submit').'"/>'; + echo '</fieldset>'; + echo '</form>'; + +// dbg($data); + } + + + /** + * Gather all information + */ + function _gather(){ + global $conf; + global $auth; + $data = array(); + $phptime = ini_get('max_execution_time'); + @set_time_limit(0); + + // version + $data['anon_id'] = md5(auth_cookiesalt()); + $data['version'] = getVersion(); + $data['popversion'] = $this->version; + $data['language'] = $conf['lang']; + $data['now'] = time(); + + // some config values + $data['conf_useacl'] = $conf['useacl']; + $data['conf_authtype'] = $conf['authtype']; + $data['conf_template'] = $conf['template']; + + // number and size of pages + $list = array(); + search($list,$conf['datadir'],array($this,'_search_count'),'',''); + $data['page_count'] = $list['file_count']; + $data['page_size'] = $list['file_size']; + $data['page_biggest'] = $list['file_max']; + $data['page_smallest'] = $list['file_min']; + if($list['file_count']) $data['page_avg'] = $list['file_size'] / $list['file_count']; + $data['page_oldest'] = $list['file_oldest']; + unset($list); + + // number and size of media + $list = array(); + search($list,$conf['mediadir'],array($this,'_search_count'),array('all'=>true)); + $data['media_count'] = $list['file_count']; + $data['media_size'] = $list['file_size']; + $data['media_biggest'] = $list['file_max']; + $data['media_smallest'] = $list['file_min']; + if($list['file_count']) $data['media_avg'] = $list['file_size'] / $list['file_count']; + unset($list); + + // number and size of cache + $list = array(); + search($list,$conf['cachedir'],array($this,'_search_count'),array('all'=>true)); + $data['cache_count'] = $list['file_count']; + $data['cache_size'] = $list['file_size']; + $data['cache_biggest'] = $list['file_max']; + $data['cache_smallest'] = $list['file_min']; + if($list['file_count']) $data['cache_avg'] = $list['file_size'] / $list['file_count']; + unset($list); + + // number and size of index + $list = array(); + search($list,$conf['indexdir'],array($this,'_search_count'),array('all'=>true)); + $data['index_count'] = $list['file_count']; + $data['index_size'] = $list['file_size']; + $data['index_biggest'] = $list['file_max']; + $data['index_smallest'] = $list['file_min']; + if($list['file_count']) $data['index_avg'] = $list['file_size'] / $list['file_count']; + unset($list); + + // number and size of meta + $list = array(); + search($list,$conf['metadir'],array($this,'_search_count'),array('all'=>true)); + $data['meta_count'] = $list['file_count']; + $data['meta_size'] = $list['file_size']; + $data['meta_biggest'] = $list['file_max']; + $data['meta_smallest'] = $list['file_min']; + if($list['file_count']) $data['meta_avg'] = $list['file_size'] / $list['file_count']; + unset($list); + + // number and size of attic + $list = array(); + search($list,$conf['olddir'],array($this,'_search_count'),array('all'=>true)); + $data['attic_count'] = $list['file_count']; + $data['attic_size'] = $list['file_size']; + $data['attic_biggest'] = $list['file_max']; + $data['attic_smallest'] = $list['file_min']; + if($list['file_count']) $data['attic_avg'] = $list['file_size'] / $list['file_count']; + $data['attic_oldest'] = $list['file_oldest']; + unset($list); + + // user count + if($auth && $auth->canDo('getUserCount')){ + $data['user_count'] = $auth->getUserCount(); + } + + // calculate edits per day + $list = @file($conf['metadir'].'/_dokuwiki.changes'); + $count = count($list); + if($count > 2){ + $first = (int) substr(array_shift($list),0,10); + $last = (int) substr(array_pop($list),0,10); + $dur = ($last - $first)/(60*60*24); // number of days in the changelog + $data['edits_per_day'] = $count/$dur; + } + unset($list); + + // plugins + $data['plugin'] = plugin_list(); + + // php info + $data['os'] = PHP_OS; + $data['webserver'] = $_SERVER['SERVER_SOFTWARE']; + $data['php_version'] = phpversion(); + $data['php_sapi'] = php_sapi_name(); + $data['php_memory'] = $this->_to_byte(ini_get('memory_limit')); + $data['php_exectime'] = $phptime; + $data['php_extension'] = get_loaded_extensions(); + + return $data; + } + + + function _search_count(&$data,$base,$file,$type,$lvl,$opts){ + // traverse + if($type == 'd'){ + $data['dir_count']++; + return true; + } + + //only search txt files if 'all' option not set + if($opts['all'] || substr($file,-4) == '.txt'){ + $size = filesize($base.'/'.$file); + $date = filemtime($base.'/'.$file); + $data['file_count']++; + $data['file_size'] += $size; + if(!isset($data['file_min']) || $data['file_min'] > $size) $data['file_min'] = $size; + if($data['file_max'] < $size) $data['file_max'] = $size; + if(!isset($data['file_oldest']) || $data['file_oldest'] > $date) $data['file_oldest'] = $date; + } + return false; + } + + /** + * Convert php.ini shorthands to byte + * + * @author <gilthans dot NO dot SPAM at gmail dot com> + * @link http://de3.php.net/manual/en/ini.core.php#79564 + */ + function _to_byte($v){ + $l = substr($v, -1); + $ret = substr($v, 0, -1); + switch(strtoupper($l)){ + case 'P': + $ret *= 1024; + case 'T': + $ret *= 1024; + case 'G': + $ret *= 1024; + case 'M': + $ret *= 1024; + case 'K': + $ret *= 1024; + break; + } + return $ret; + } +} diff --git a/lib/plugins/popularity/lang/de/intro.txt b/lib/plugins/popularity/lang/de/intro.txt new file mode 100644 index 0000000000000000000000000000000000000000..69651599af199bedaeab1ecc2b6adcf48ab094e8 --- /dev/null +++ b/lib/plugins/popularity/lang/de/intro.txt @@ -0,0 +1,19 @@ +====== Popularitäts-Feedback ====== + +Dieses Werkzeug sammelt verschiedene anonyme Daten über Ihr Wiki und erlaubt es Ihnen +diese an die DokuWiki-Entwickler zurückzusenden. Diese Daten helfen den +Entwicklern besser zu verstehen wie DokuWiki eingesetzt wird und stellt sicher, +dass zukünftige, die Weiterentwicklung von DokuWiki betreffende, Entscheidungen +auf Basis echter Nutzerdaten getroffen werden. + +Bitte wiederholen Sie das Versenden der Daten von Zeit zu Zeit um die Entwickler über +das Wachstum Ihres Wikis auf dem Laufenden zu halten. Ihre wiederholten Dateneinsendungen +werden über eine anonyme ID identifieziert. + +Die gesammelten Daten enthalten Informationen wie Ihre DokuWiki Version, die Anzahl +und Größe Ihrer Seiten und Dateien, installierte Plugins und die eingesetzte PHP Installation. + +Die zu übertragenen Roh-Daten werden in der untenstehenden Box angezeigt. Bitte +drücken Sie die "Daten Senden" Schaltfläche um die Information zu übertragen. + + diff --git a/lib/plugins/popularity/lang/de/lang.php b/lib/plugins/popularity/lang/de/lang.php new file mode 100644 index 0000000000000000000000000000000000000000..01a6ca3ee2816d086a78bd6758141e1089058621 --- /dev/null +++ b/lib/plugins/popularity/lang/de/lang.php @@ -0,0 +1,4 @@ +<?php + +$lang['name'] = 'Popularitäts-Feedback (Eventuell längere Ladezeit)'; +$lang['submit'] = 'Daten Senden'; diff --git a/lib/plugins/popularity/lang/en/intro.txt b/lib/plugins/popularity/lang/en/intro.txt new file mode 100644 index 0000000000000000000000000000000000000000..495c0841a4f23cddec99de55ad03ff026a79447a --- /dev/null +++ b/lib/plugins/popularity/lang/en/intro.txt @@ -0,0 +1,19 @@ +====== Popularity Feedback ====== + +This tool gathers anonymous data about your wiki and allows you to send it back +to the DokuWiki developers. This helps them to understand them how DokuWiki is +used by its users and makes sure future development decisions are backed up by +real world usage statistics. + +You are encouraged to repeat this step from time to time to keep developers +informed when your wiki grows. Your repeated data sets will be identified by an +anonymous ID. + +Data collected contains information like your DokuWiki version, the number and +size of your pages and files, installed plugins and information about your PHP +install. + +The raw data that will be send is shown below. Please use the "Send Data" button +to transfer the information. + + diff --git a/lib/plugins/popularity/lang/en/lang.php b/lib/plugins/popularity/lang/en/lang.php new file mode 100644 index 0000000000000000000000000000000000000000..c9912b7ad022f0335c916efef9c6f50b613e9d09 --- /dev/null +++ b/lib/plugins/popularity/lang/en/lang.php @@ -0,0 +1,4 @@ +<?php + +$lang['name'] = 'Popularity Feedback (may take some time to load)'; +$lang['submit'] = 'Send Data';