diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/autologon/autologon.php | 44 | ||||
-rw-r--r-- | plugins/debug_logger/debug_logger.php | 146 | ||||
-rw-r--r-- | plugins/debug_logger/runlog/runlog.php | 227 | ||||
-rw-r--r-- | plugins/example_addressbook/example_addressbook.php | 42 | ||||
-rw-r--r-- | plugins/example_addressbook/example_addressbook_backend.php | 72 | ||||
-rw-r--r-- | plugins/userinfo/localization/de_CH.inc | 9 | ||||
-rw-r--r-- | plugins/userinfo/localization/en_US.inc | 9 | ||||
-rw-r--r-- | plugins/userinfo/localization/et_EE.inc | 9 | ||||
-rw-r--r-- | plugins/userinfo/localization/pl_PL.inc | 9 | ||||
-rw-r--r-- | plugins/userinfo/userinfo.js | 16 | ||||
-rw-r--r-- | plugins/userinfo/userinfo.php | 53 |
11 files changed, 0 insertions, 636 deletions
diff --git a/plugins/autologon/autologon.php b/plugins/autologon/autologon.php deleted file mode 100644 index c40f2d4eb..000000000 --- a/plugins/autologon/autologon.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -/** - * Sample plugin to try out some hooks. - * This performs an automatic login if accessed from localhost - */ -class autologon extends rcube_plugin -{ - - function init() - { - $this->add_hook('startup', array($this, 'startup')); - $this->add_hook('authenticate', array($this, 'authenticate')); - } - - function startup($args) - { - $rcmail = rcmail::get_instance(); - - // change action to login - if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost()) - $args['action'] = 'login'; - - return $args; - } - - function authenticate($args) - { - if (!empty($_GET['_autologin']) && $this->is_localhost()) { - $args['user'] = 'me'; - $args['pass'] = '******'; - $args['host'] = 'localhost'; - } - - return $args; - } - - function is_localhost() - { - return $_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '127.0.0.1'; - } - -} - diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php deleted file mode 100644 index 8cd335187..000000000 --- a/plugins/debug_logger/debug_logger.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php - -/** - * Debug Logger - * - * Enhanced logging for debugging purposes. It is not recommened - * to be enabled on production systems without testing because of - * the somewhat increased memory, cpu and disk i/o overhead. - * - * Debug Logger listens for existing console("message") calls and - * introduces start and end tags as well as free form tagging - * which can redirect messages to files. The resulting log files - * provide timing and tag quantity results. - * - * Enable the plugin in config/main.inc.php and add your desired - * log types and files. - * - * @version 1.0 - * @author Ziba Scott - * @website http://roundcube.net - * - * Example: - * - * config/main.inc.php: - * - * // $rcmail_config['debug_logger'][type of logging] = name of file in log_dir - * // The 'master' log includes timing information - * $rcmail_config['debug_logger']['master'] = 'master'; - * // If you want sql messages to also go into a separate file - * $rcmail_config['debug_logger']['sql'] = 'sql'; - * - * index.php (just after $RCMAIL->plugins->init()): - * - * console("my test","start"); - * console("my message"); - * console("my sql calls","start"); - * console("cp -r * /dev/null","shell exec"); - * console("select * from example","sql"); - * console("select * from example","sql"); - * console("select * from example","sql"); - * console("end"); - * console("end"); - * - * - * logs/master (after reloading the main page): - * - * [17-Feb-2009 16:51:37 -0500] start: Task: mail. - * [17-Feb-2009 16:51:37 -0500] start: my test - * [17-Feb-2009 16:51:37 -0500] my message - * [17-Feb-2009 16:51:37 -0500] shell exec: cp -r * /dev/null - * [17-Feb-2009 16:51:37 -0500] start: my sql calls - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - * [17-Feb-2009 16:51:37 -0500] end: my sql calls - 0.0018 seconds shell exec: 1, sql: 3, - * [17-Feb-2009 16:51:37 -0500] end: my test - 0.0055 seconds shell exec: 1, sql: 3, - * [17-Feb-2009 16:51:38 -0500] end: Task: mail. - 0.8854 seconds shell exec: 1, sql: 3, - * - * logs/sql (after reloading the main page): - * - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - * [17-Feb-2009 16:51:37 -0500] sql: select * from example - */ -class debug_logger extends rcube_plugin -{ - function init() - { - require_once(dirname(__FILE__).'/runlog/runlog.php'); - $this->runlog = new runlog(); - - if(!rcmail::get_instance()->config->get('log_dir')){ - rcmail::get_instance()->config->set('log_dir',INSTALL_PATH.'logs'); - } - - $log_config = rcmail::get_instance()->config->get('debug_logger',array()); - - foreach($log_config as $type=>$file){ - $this->runlog->set_file(rcmail::get_instance()->config->get('log_dir').'/'.$file, $type); - } - - $start_string = ""; - $action = rcmail::get_instance()->action; - $task = rcmail::get_instance()->task; - if($action){ - $start_string .= "Action: ".$action.". "; - } - if($task){ - $start_string .= "Task: ".$task.". "; - } - $this->runlog->start($start_string); - - $this->add_hook('console', array($this, 'console')); - $this->add_hook('authenticate', array($this, 'authenticate')); - } - - function authenticate($args){ - $this->runlog->note('Authenticating '.$args['user'].'@'.$args['host']); - return $args; - } - - function console($args){ - $note = $args[0]; - $type = $args[1]; - - - if(!isset($args[1])){ - // This could be extended to detect types based on the - // file which called console. For now only rcube_imap.inc is supported - $bt = debug_backtrace(true); - $file = $bt[3]['file']; - switch(basename($file)){ - case 'rcube_imap.php': - $type = 'imap'; - break; - default: - $type = FALSE; - break; - } - } - switch($note){ - case 'end': - $type = 'end'; - break; - } - - - switch($type){ - case 'start': - $this->runlog->start($note); - break; - case 'end': - $this->runlog->end(); - break; - default: - $this->runlog->note($note, $type); - break; - } - return $args; - } - - function __destruct(){ - $this->runlog->end(); - } -} -?> diff --git a/plugins/debug_logger/runlog/runlog.php b/plugins/debug_logger/runlog/runlog.php deleted file mode 100644 index c9f672615..000000000 --- a/plugins/debug_logger/runlog/runlog.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php - -/** - * runlog - * - * @author Ziba Scott <ziba@umich.edu> - */ -class runlog { - - private $start_time = FALSE; - - private $parent_stack = array(); - - public $print_to_console = FALSE; - - private $file_handles = array(); - - private $indent = 0; - - public $threshold = 0; - - public $tag_count = array(); - - public $timestamp = "d-M-Y H:i:s O"; - - public $max_line_size = 150; - - private $run_log = array(); - - function runlog() - { - $this->start_time = microtime( TRUE ); - } - - public function start( $name, $tag = FALSE ) - { - $this->run_log[] = array( 'type' => 'start', - 'tag' => $tag, - 'index' => count($this->run_log), - 'value' => $name, - 'time' => microtime( TRUE ), - 'parents' => $this->parent_stack, - 'ended' => false, - ); - $this->parent_stack[] = $name; - - $this->print_to_console("start: ".$name, $tag, 'start'); - $this->print_to_file("start: ".$name, $tag, 'start'); - $this->indent++; - } - - public function end() - { - $name = array_pop( $this->parent_stack ); - foreach ( $this->run_log as $k => $entry ) { - if ( $entry['value'] == $name && $entry['type'] == 'start' && $entry['ended'] == false) { - $lastk = $k; - } - } - $start = $this->run_log[$lastk]['time']; - $this->run_log[$lastk]['duration'] = microtime( TRUE ) - $start; - $this->run_log[$lastk]['ended'] = true; - - $this->run_log[] = array( 'type' => 'end', - 'tag' => $this->run_log[$lastk]['tag'], - 'index' => $lastk, - 'value' => $name, - 'time' => microtime( TRUE ), - 'duration' => microtime( TRUE ) - $start, - 'parents' => $this->parent_stack, - ); - $this->indent--; - if($this->run_log[$lastk]['duration'] >= $this->threshold){ - $tag_report = ""; - foreach($this->tag_count as $tag=>$count){ - $tag_report .= "$tag: $count, "; - } - if(!empty($tag_report)){ -// $tag_report = "\n$tag_report\n"; - } - $end_txt = sprintf("end: $name - %0.4f seconds $tag_report", $this->run_log[$lastk]['duration'] ); - $this->print_to_console($end_txt, $this->run_log[$lastk]['tag'] , 'end'); - $this->print_to_file($end_txt, $this->run_log[$lastk]['tag'], 'end'); - } - } - - public function increase_tag_count($tag){ - if(!isset($this->tag_count[$tag])){ - $this->tag_count[$tag] = 0; - } - $this->tag_count[$tag]++; - } - - public function get_text(){ - $text = ""; - foreach($this->run_log as $entry){ - $text .= str_repeat(" ",count($entry['parents'])); - if($entry['tag'] != 'text'){ - $text .= $entry['tag'].': '; - } - $text .= $entry['value']; - - if($entry['tag'] == 'end'){ - $text .= sprintf(" - %0.4f seconds", $entry['duration'] ); - } - - $text .= "\n"; - } - return $text; - } - - public function set_file($filename, $tag = 'master'){ - if(!isset($this->file_handle[$tag])){ - $this->file_handles[$tag] = fopen($filename, 'a'); - if(!$this->file_handles[$tag]){ - trigger_error('Could not open file for writing: '.$filename); - } - } - } - - public function note( $msg, $tag = FALSE ) - { - if($tag){ - $this->increase_tag_count($tag); - } - if ( is_array( $msg )) { - $msg = '<pre>' . print_r( $msg, TRUE ) . '</pre>'; - } - $this->debug_messages[] = $msg; - $this->run_log[] = array( 'type' => 'note', - 'tag' => $tag ? $tag:"text", - 'value' => htmlentities($msg), - 'time' => microtime( TRUE ), - 'parents' => $this->parent_stack, - ); - - $this->print_to_file($msg, $tag); - $this->print_to_console($msg, $tag); - - } - - public function print_to_file($msg, $tag = FALSE, $type = FALSE){ - if(!$tag){ - $file_handle_tag = 'master'; - } - else{ - $file_handle_tag = $tag; - } - if($file_handle_tag != 'master' && isset($this->file_handles[$file_handle_tag])){ - $buffer = $this->get_indent(); - $buffer .= "$msg\n"; - if(!empty($this->timestamp)){ - $buffer = sprintf("[%s] %s",date($this->timestamp, mktime()), $buffer); - } - fwrite($this->file_handles[$file_handle_tag], wordwrap($buffer, $this->max_line_size, "\n ")); - } - if(isset($this->file_handles['master']) && $this->file_handles['master']){ - $buffer = $this->get_indent(); - if($tag){ - $buffer .= "$tag: "; - } - $msg = str_replace("\n","",$msg); - $buffer .= "$msg"; - if(!empty($this->timestamp)){ - $buffer = sprintf("[%s] %s",date($this->timestamp, mktime()), $buffer); - } - if(strlen($buffer) > $this->max_line_size){ - $buffer = substr($buffer,0,$this->max_line_size - 3)."..."; - } - fwrite($this->file_handles['master'], $buffer."\n"); - } - } - - public function print_to_console($msg, $tag=FALSE){ - if($this->print_to_console){ - if(is_array($this->print_to_console)){ - if(in_array($tag, $this->print_to_console)){ - echo $this->get_indent(); - if($tag){ - echo "$tag: "; - } - echo "$msg\n"; - } - } - else{ - echo $this->get_indent(); - if($tag){ - echo "$tag: "; - } - echo "$msg\n"; - } - } - } - - public function print_totals(){ - $totals = array(); - foreach ( $this->run_log as $k => $entry ) { - if ( $entry['type'] == 'start' && $entry['ended'] == true) { - $totals[$entry['value']]['duration'] += $entry['duration']; - $totals[$entry['value']]['count'] += 1; - } - } - if($this->file_handle){ - foreach($totals as $name=>$details){ - fwrite($this->file_handle,$name.": ".number_format($details['duration'],4)."sec, ".$details['count']." calls \n"); - } - } - } - - private function get_indent(){ - $buf = ""; - for($i = 0; $i < $this->indent; $i++){ - $buf .= " "; - } - return $buf; - } - - - function __destruct(){ - foreach($this->file_handles as $handle){ - fclose($handle); - } - } - -} - -?> diff --git a/plugins/example_addressbook/example_addressbook.php b/plugins/example_addressbook/example_addressbook.php deleted file mode 100644 index 081efcb13..000000000 --- a/plugins/example_addressbook/example_addressbook.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/** - * Sample plugin to add a new address book - * with just a static list of contacts - */ -class example_addressbook extends rcube_plugin -{ - private $abook_id = 'static'; - - public function init() - { - $this->add_hook('address_sources', array($this, 'address_sources')); - $this->add_hook('get_address_book', array($this, 'get_address_book')); - - // use this address book for autocompletion queries - // (maybe this should be configurable by the user?) - $config = rcmail::get_instance()->config; - $sources = $config->get('autocomplete_addressbooks', array('sql')); - if (!in_array($this->abook_id, $sources)) { - $sources[] = $this->abook_id; - $config->set('autocomplete_addressbooks', $sources); - } - } - - public function address_sources($p) - { - $p['sources'][$this->abook_id] = array('id' => $this->abook_id, 'name' => 'Static List', 'readonly' => true); - return $p; - } - - public function get_address_book($p) - { - if ($p['id'] == $this->abook_id) { - require_once(dirname(__FILE__) . '/example_addressbook_backend.php'); - $p['instance'] = new example_addressbook_backend; - } - - return $p; - } - -} diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php deleted file mode 100644 index ad6b89d67..000000000 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -/** - * Example backend class for a custom address book - * - * This one just holds a static list of address records - * - * @author Thomas Bruederli - */ -class example_addressbook_backend extends rcube_addressbook -{ - public $primary_key = 'ID'; - public $readonly = true; - - private $filter; - private $result; - - public function __construct() - { - $this->ready = true; - } - - public function set_search_set($filter) - { - $this->filter = $filter; - } - - public function get_search_set() - { - return $this->filter; - } - - public function reset() - { - $this->result = null; - $this->filter = null; - } - - public function list_records($cols=null, $subset=0) - { - $this->result = $this->count(); - $this->result->add(array('ID' => '111', 'name' => "Example Contact", 'firstname' => "Example", 'surname' => "Contact", 'email' => "example@roundcube.net")); - - return $this->result; - } - - public function search($fields, $value, $strict=false, $select=true) - { - // no search implemented, just list all records - return $this->list_records(); - } - - public function count() - { - return new rcube_result_set(1, ($this->list_page-1) * $this->page_size); - } - - public function get_result() - { - return $this->result; - } - - public function get_record($id, $assoc=false) - { - $this->list_records(); - $first = $this->result->first(); - $sql_arr = $first['ID'] == $id ? $first : null; - - return $assoc && $sql_arr ? $sql_arr : $this->result; - } - -} diff --git a/plugins/userinfo/localization/de_CH.inc b/plugins/userinfo/localization/de_CH.inc deleted file mode 100644 index 5f236b66c..000000000 --- a/plugins/userinfo/localization/de_CH.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$labels = array(); -$labels['userinfo'] = 'Benutzerinfo'; -$labels['created'] = 'Erstellt'; -$labels['lastlogin'] = 'Letztes Login'; -$labels['defaultidentity'] = 'Standard-Absender'; - -?>
\ No newline at end of file diff --git a/plugins/userinfo/localization/en_US.inc b/plugins/userinfo/localization/en_US.inc deleted file mode 100644 index 1a2fd9016..000000000 --- a/plugins/userinfo/localization/en_US.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$labels = array(); -$labels['userinfo'] = 'User info'; -$labels['created'] = 'Created'; -$labels['lastlogin'] = 'Last Login'; -$labels['defaultidentity'] = 'Default Identity'; - -?>
\ No newline at end of file diff --git a/plugins/userinfo/localization/et_EE.inc b/plugins/userinfo/localization/et_EE.inc deleted file mode 100644 index 97830b45c..000000000 --- a/plugins/userinfo/localization/et_EE.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$labels = array(); -$labels['userinfo'] = 'Kasutaja info'; -$labels['created'] = 'Loodud'; -$labels['lastlogin'] = 'Viimane logimine'; -$labels['defaultidentity'] = 'Vaikeidentiteet'; - -?> diff --git a/plugins/userinfo/localization/pl_PL.inc b/plugins/userinfo/localization/pl_PL.inc deleted file mode 100644 index 6b03c32e7..000000000 --- a/plugins/userinfo/localization/pl_PL.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$labels = array(); -$labels['userinfo'] = 'Informacje'; -$labels['created'] = 'Utworzony'; -$labels['lastlogin'] = 'Ostatnie logowanie'; -$labels['defaultidentity'] = 'Domyślna tożsamość'; - -?> diff --git a/plugins/userinfo/userinfo.js b/plugins/userinfo/userinfo.js deleted file mode 100644 index 70a5085b3..000000000 --- a/plugins/userinfo/userinfo.js +++ /dev/null @@ -1,16 +0,0 @@ -/* Show user-info plugin script */ - -if (window.rcmail) { - rcmail.addEventListener('init', function(evt) { - // <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span> - var tab = $('<span>').attr('id', 'settingstabpluginuserinfo').addClass('tablink'); - - var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.userinfo').html(rcmail.gettext('userinfo', 'userinfo')).appendTo(tab); - button.bind('click', function(e){ return rcmail.command('plugin.userinfo', this) }); - - // add button and register command - rcmail.add_element(tab, 'tabs'); - rcmail.register_command('plugin.userinfo', function(){ rcmail.goto_url('plugin.userinfo') }, true); - }) -} - diff --git a/plugins/userinfo/userinfo.php b/plugins/userinfo/userinfo.php deleted file mode 100644 index 0f1b18cd9..000000000 --- a/plugins/userinfo/userinfo.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Sample plugin that adds a new tab to the settings section - * to display some information about the current user - */ -class userinfo extends rcube_plugin -{ - public $task = 'settings'; - - function init() - { - $this->add_texts('localization/', array('userinfo')); - $this->register_action('plugin.userinfo', array($this, 'infostep')); - $this->include_script('userinfo.js'); - } - - function infostep() - { - $this->register_handler('plugin.body', array($this, 'infohtml')); - rcmail::get_instance()->output->send('plugin'); - } - - function infohtml() - { - $rcmail = rcmail::get_instance(); - $user = $rcmail->user; - - $table = new html_table(array('cols' => 2, 'cellpadding' => 3)); - - $table->add('title', 'ID'); - $table->add('', Q($user->ID)); - - $table->add('title', Q($this->gettext('username'))); - $table->add('', Q($user->data['username'])); - - $table->add('title', Q($this->gettext('server'))); - $table->add('', Q($user->data['mail_host'])); - - $table->add('title', Q($this->gettext('created'))); - $table->add('', Q($user->data['created'])); - - $table->add('title', Q($this->gettext('lastlogin'))); - $table->add('', Q($user->data['last_login'])); - - $identity = $user->get_identity(); - $table->add('title', Q($this->gettext('defaultidentity'))); - $table->add('', Q($identity['name'] . ' <' . $identity['email'] . '>')); - - return html::tag('h4', null, Q('Infos for ' . $user->get_username())) . $table->show(); - } - -}
\ No newline at end of file |