Page MenuHomePhorge

No OneTemporary

Size
133 KB
Referenced Files
None
Subscribers
None
diff --git a/bin/cleandb.sh b/bin/cleandb.sh
index 9edfeec91..d811c8d01 100755
--- a/bin/cleandb.sh
+++ b/bin/cleandb.sh
@@ -1,78 +1,78 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/cleandb.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2010, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Finally remove all db records marked as deleted some time ago |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
// mapping for table name => primary key
$primary_keys = array(
'contacts' => "contact_id",
'contactgroups' => "contactgroup_id",
);
// connect to DB
$RCMAIL = rcube::get_instance();
$db = $RCMAIL->get_dbh();
$db->db_connect('w');
if (!$db->is_connected() || $db->is_error()) {
rcube::raise_error("No DB connection", false, true);
}
if (!empty($_SERVER['argv'][1]))
$days = intval($_SERVER['argv'][1]);
else
$days = 7;
// remove all deleted records older than two days
$threshold = date('Y-m-d 00:00:00', time() - $days * 86400);
foreach (array('contacts','contactgroups','identities') as $table) {
$sqltable = $db->table_name($table, true);
// also delete linked records
// could be skipped for databases which respect foreign key constraints
if ($db->db_provider == 'sqlite'
&& ($table == 'contacts' || $table == 'contactgroups')
) {
$pk = $primary_keys[$table];
$memberstable = $db->table_name('contactgroupmembers');
$db->query(
"DELETE FROM " . $db->quote_identifier($memberstable).
" WHERE `$pk` IN (".
"SELECT `$pk` FROM $sqltable".
" WHERE `del` = 1 AND `changed` < ?".
")",
$threshold);
echo $db->affected_rows() . " records deleted from '$memberstable'\n";
}
// delete outdated records
$db->query("DELETE FROM $sqltable WHERE `del` = 1 AND `changed` < ?", $threshold);
echo $db->affected_rows() . " records deleted from '$table'\n";
}
?>
diff --git a/bin/decrypt.sh b/bin/decrypt.sh
index 7f83f3a7f..dd4525972 100755
--- a/bin/decrypt.sh
+++ b/bin/decrypt.sh
@@ -1,67 +1,67 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/decrypt.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Decrypt the encrypted parts of the HTTP Received: headers |
| |
+-----------------------------------------------------------------------+
| Author: Tomas Tevesz <ice@extreme.hu> |
+-----------------------------------------------------------------------+
*/
/**
* If http_received_header_encrypt is configured, the IP address and the
* host name of the added Received: header is encrypted with 3DES, to
* protect information that some could consider sensitve, yet their
* availability is a must in some circumstances.
*
* Such an encrypted Received: header might look like:
*
* Received: from DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==
* [my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4]
* with HTTP/1.1 (POST); Thu, 14 May 2009 19:17:28 +0200
*
* In this example, the two encrypted components are the sender host name
* (DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==) and the IP
* address (my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4).
*
* Using this tool, they can be decrypted into plain text:
*
* $ bin/decrypt.sh 'my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4' \
* > 'DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ=='
* 84.3.187.208
* 5403BBD0.catv.pool.telekom.hu
* $
*
* Thus it is known that this particular message was sent by 84.3.187.208,
* having, at the time of sending, the name of 5403BBD0.catv.pool.telekom.hu.
*
* If (most likely binary) junk is shown, then
* - either the encryption password has, between the time the mail was sent
* and 'now', changed, or
* - you are dealing with counterfeit header data.
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/');
+define('INSTALL_PATH', realpath(__DIR__ .'/..') . '/');
require INSTALL_PATH . 'program/include/clisetup.php';
if ($argc < 2) {
die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
}
$RCMAIL = rcube::get_instance();
for ($i = 1; $i < $argc; $i++) {
printf("%s\n", $RCMAIL->decrypt($argv[$i]));
};
diff --git a/bin/deluser.sh b/bin/deluser.sh
index 0489f4da4..1e93793cf 100755
--- a/bin/deluser.sh
+++ b/bin/deluser.sh
@@ -1,125 +1,125 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/deluser.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2014, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Utility script to remove all data related to a certain user |
| from the local database. |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <thomas@roundcube.net> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
function print_usage()
{
print "Usage: deluser.sh [--host=mail_host] username\n";
print "--host=HOST The IMAP hostname or IP the given user is related to\n";
}
function _die($msg, $usage=false)
{
fputs(STDERR, $msg . "\n");
if ($usage) print_usage();
exit(1);
}
$rcmail = rcmail::get_instance();
// get arguments
$args = rcube_utils::get_opt(array('h' => 'host'));
$username = trim($args[0]);
if (empty($username)) {
_die("Missing required parameters", true);
}
if (empty($args['host'])) {
$hosts = $rcmail->config->get('default_host', '');
if (is_string($hosts)) {
$args['host'] = $hosts;
}
else if (is_array($hosts) && count($hosts) == 1) {
$args['host'] = reset($hosts);
}
else {
_die("Specify a host name", true);
}
// host can be a URL like tls://192.168.12.44
$host_url = parse_url($args['host']);
if ($host_url['host']) {
$args['host'] = $host_url['host'];
}
}
// connect to DB
$db = $rcmail->get_dbh();
$db->db_connect('w');
$transaction = false;
if (!$db->is_connected() || $db->is_error()) {
_die("No DB connection\n" . $db->is_error());
}
// find user in loca database
$user = rcube_user::query($username, $args['host']);
if (!$user) {
die("User not found.\n");
}
// inform plugins about approaching user deletion
$plugin = $rcmail->plugins->exec_hook('user_delete_prepare', array('user' => $user, 'username' => $username, 'host' => $args['host']));
// let plugins cleanup their own user-related data
if (!$plugin['abort']) {
$transaction = $db->startTransaction();
$plugin = $rcmail->plugins->exec_hook('user_delete', $plugin);
}
if ($plugin['abort']) {
if ($transaction) {
$db->rollbackTransaction();
}
_die("User deletion aborted by plugin");
}
// deleting the user record should be sufficient due to ON DELETE CASCADE foreign key references
// but not all database backends actually support this so let's do it by hand
foreach (array('identities','contacts','contactgroups','dictionary','cache','cache_index','cache_messages','cache_thread','searches','users') as $table) {
$db->query('DELETE FROM ' . $db->table_name($table, true) . ' WHERE `user_id` = ?', $user->ID);
}
if ($db->is_error()) {
$rcmail->plugins->exec_hook('user_delete_rollback', $plugin);
_die("DB error occurred: " . $db->is_error());
}
else {
// inform plugins about executed user deletion
$plugin = $rcmail->plugins->exec_hook('user_delete_commit', $plugin);
if ($plugin['abort']) {
unset($plugin['abort']);
$db->rollbackTransaction();
$rcmail->plugins->exec_hook('user_delete_rollback', $plugin);
}
else {
$db->endTransaction();
echo "Successfully deleted user $user->ID\n";
}
}
diff --git a/bin/dumpschema.sh b/bin/dumpschema.sh
index 6d5cde723..32c90ac13 100755
--- a/bin/dumpschema.sh
+++ b/bin/dumpschema.sh
@@ -1,97 +1,97 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/dumpschema.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Dumps database schema in XML format using MDB2_Schema |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
/** callback function for schema dump **/
function print_schema($dump)
{
foreach ((array)$dump as $part)
echo $dump . "\n";
}
$config = new rcube_config();
// don't allow public access if not in devel_mode
if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) {
header("HTTP/1.0 401 Access denied");
die("Access denied!");
}
$options = array(
'use_transactions' => false,
'log_line_break' => "\n",
'idxname_format' => '%s',
'debug' => false,
'quote_identifier' => true,
'force_defaults' => false,
'portability' => false,
);
$dsnw = $config->get('db_dsnw');
$dsn_array = MDB2::parseDSN($dsnw);
// set options for postgres databases
if ($dsn_array['phptype'] == 'pgsql') {
$options['disable_smart_seqname'] = true;
$options['seqname_format'] = '%s';
}
$schema =& MDB2_Schema::factory($dsnw, $options);
$schema->db->supported['transactions'] = false;
// send as text/xml when opened in browser
if ($_SERVER['REMOTE_ADDR'])
header('Content-Type: text/xml');
if (PEAR::isError($schema)) {
$error = $schema->getMessage() . ' ' . $schema->getUserInfo();
}
else {
$dump_config = array(
// 'output_mode' => 'file',
'output' => 'print_schema',
);
$definition = $schema->getDefinitionFromDatabase();
$definition['charset'] = 'utf8';
if (PEAR::isError($definition)) {
$error = $definition->getMessage() . ' ' . $definition->getUserInfo();
}
else {
$operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE);
if (PEAR::isError($operation)) {
$error = $operation->getMessage() . ' ' . $operation->getUserInfo();
}
}
}
$schema->disconnect();
if ($error && !$_SERVER['REMOTE_ADDR'])
fputs(STDERR, $error);
?>
diff --git a/bin/exportgettext.sh b/bin/exportgettext.sh
index b220b2242..314cae7d2 100755
--- a/bin/exportgettext.sh
+++ b/bin/exportgettext.sh
@@ -1,233 +1,233 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/exportgettext.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2011, The Roundcube Dev Team |
| Licensed under the GNU General Public License |
| |
| PURPOSE: |
| Export PHP-based localization files to PO files for gettext |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
if ($argc < 2) {
die("Usage: " . basename($argv[0]) . " SRCDIR DESTDIR\n");
}
$srcdir = unslashify(realpath($argv[1]));
$destdir = unslashify($argv[2]);
$layout = 'launchpad'; # or 'narro';
$langcode_map = array(
'hy_AM' => 'hy',
'ar_SA' => 'ar',
'az_AZ' => 'az',
'bg_BG' => 'bg',
'bs_BA' => 'bs',
'ca_ES' => 'ca',
'cs_CZ' => 'cs',
'cy_GB' => 'cy',
'da_DK' => 'da',
'et_EE' => 'et',
'el_GR' => 'el',
'eu_ES' => 'eu',
'fa_IR' => 'fa',
'ga_IE' => 'ga',
'ka_GE' => 'ka',
'gl_ES' => 'gl',
'he_IL' => 'he',
'hi_IN' => 'hi',
'hr_HR' => 'hr',
'ja_JP' => 'ja',
'ko_KR' => 'ko',
'km_KH' => 'km',
'ms_MY' => 'ms',
'mr_IN' => 'mr',
'ml_IN' => 'ml',
'pl_PL' => 'pl',
'si_LK' => 'si',
'sl_SI' => 'sl',
'sq_AL' => 'sq',
'sr_CS' => 'sr',
'sv_SE' => 'sv',
'uk_UA' => 'uk',
'vi_VN' => 'vi',
);
// converting roundcube localization dir
if (is_dir($srcdir.'/en_US')) {
load_en_US($srcdir.'/en_US');
foreach (glob($srcdir.'/*') as $locdir) {
if (is_dir($locdir)) {
$lang = basename($locdir);
//echo "$locdir => $destdir$lang\n";
convert_dir($locdir, $destdir . ($layout != 'launchpad' ? $lang : ''));
}
}
}
// converting single localization directory
else if (is_dir($srcdir)) {
if (is_file($srcdir.'/en_US.inc')) // plugin localization
load_en_US($srcdir.'/en_US.inc');
else
load_en_US(realpath($srcdir.'/../en_US')); // single language
convert_dir($srcdir, $destdir);
}
// converting a single file
else if (is_file($srcdir)) {
//load_en_US();
convert_file($srcdir, $destdir);
}
/**
* Load en_US localization which is used to build msgids
*/
function load_en_US($fn)
{
$texts = array();
if (is_dir($fn)) {
foreach (glob($fn.'/*.inc') as $ifn) {
include($ifn);
$texts = array_merge($texts, (array)$labels, (array)$messages);
}
}
else if (is_file($fn)) {
include($fn);
$texts = array_merge($texts, (array)$labels, (array)$messages);
}
$GLOBALS['en_US'] = $texts;
}
/**
* Convert all .inc files in the given src directory
*/
function convert_dir($indir, $outdir)
{
global $layout;
if (!is_dir($outdir)) // attempt to create destination dir
mkdir($outdir, 0777, true);
foreach (glob($indir.'/*.inc') as $fn) {
$filename = basename($fn);
// create subdir for each template (launchpad rules)
if ($layout == 'launchpad' && preg_match('/^(labels|messages)/', $filename, $m)) {
$lang = end(explode('/', $indir));
$destdir = $outdir . '/' . $m[1];
if (!is_dir($destdir))
mkdir($destdir, 0777, true);
$outfn = $destdir . '/' . $lang . '.po';
}
else {
$outfn = $outdir . '/' . preg_replace('/\.[a-z0-9]+$/i', '', basename($fn)) . '.po';
}
convert_file($fn, $outfn);
}
}
/**
* Convert the given Roundcube localization file into a gettext .po file
*/
function convert_file($fn, $outfn)
{
global $layout, $langcode_map;
$basename = basename($fn);
$srcname = str_replace(INSTALL_PATH, '', $fn);
$product = preg_match('!plugins/(\w+)!', $srcname, $m) ? 'roundcube-plugin-' . $m[1] : 'roundcubemail';
$lang = preg_match('!/([a-z]{2}(_[A-Z]{2})?)[./]!', $outfn, $m) ? $m[1] : '';
$labels = $messages = $seen = array();
if (is_dir($outfn))
$outfn .= '/' . $basename . '.po';
// launchpad requires the template file to have the same name as the directory
if (strstr($outfn, '/en_US') && $layout == 'launchpad') {
$a = explode('/', $outfn);
array_pop($a);
$templ = end($a);
$a[] = $templ . '.pot';
$outfn = join('/', $a);
$is_pot = true;
}
// launchpad is very picky about file names
else if ($layout == 'launchpad' && preg_match($regex = '!/([a-z]{2})_([A-Z]{2})!', $outfn, $m)) {
if ($shortlang = $langcode_map[$lang])
$outfn = preg_replace($regex, '/'.$shortlang, $outfn);
else if ($m[1] == strtolower($m[2]))
$outfn = preg_replace($regex, '/\1', $outfn);
}
include($fn);
$texts = array_merge($labels, $messages);
// write header
$header = <<<EOF
# Converted from Roundcube PHP localization files
# Copyright (C) 2011 The Roundcube Dev Team
# This file is distributed under the same license as the Roundcube package.
#
#: %s
msgid ""
msgstr ""
"Project-Id-Version: %s\\n"
"Report-Msgid-Bugs-To: \\n"
"%s: %s\\n"
"Last-Translator: \\n"
"Language-Team: Translations <hello@roundcube.net>\\n"
"Language: %s\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
EOF;
$out = sprintf($header, $srcname, $product, $is_pot ? "POT-Creation-Date" : "PO-Revision-Date", date('c'), $shortlang ? $shortlang : $lang);
$out .= "\n";
$messages = array();
foreach ((array)$texts as $label => $msgstr) {
$msgid = $is_pot ? $msgstr : ($GLOBALS['en_US'][$label] ?: $label);
$messages[$msgid][] = $label;
}
foreach ($messages as $msgid => $labels) {
$out .= "\n";
foreach ($labels as $label)
$out .= "#: $srcname:$label\n";
$msgstr = $texts[$label];
$out .= 'msgid ' . gettext_quote($msgid) . "\n";
$out .= 'msgstr ' . gettext_quote(!$is_pot ? $msgstr : '') . "\n";
}
if ($outfn == '-')
echo $out;
else {
echo "$fn\t=>\t$outfn\n";
file_put_contents($outfn, $out);
}
}
function gettext_quote($str)
{
$out = "";
$lines = explode("\n", wordwrap(stripslashes($str)));
$last = count($lines) - 1;
foreach ($lines as $i => $line)
$out .= '"' . addcslashes($line, '"') . ($i < $last ? ' ' : '') . "\"\n";
return rtrim($out);
}
?>
diff --git a/bin/gc.sh b/bin/gc.sh
index 1ee610741..e0d722a18 100755
--- a/bin/gc.sh
+++ b/bin/gc.sh
@@ -1,27 +1,27 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/gc.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Trigger garbage collecting routines manually (e.g. via cronjob) |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
$rcmail = rcube::get_instance();
$rcmail->gc();
diff --git a/bin/importgettext.sh b/bin/importgettext.sh
index 285f5680f..5a91e6bc1 100755
--- a/bin/importgettext.sh
+++ b/bin/importgettext.sh
@@ -1,196 +1,196 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/importgettext.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2011, The Roundcube Dev Team |
| Licensed under the GNU General Public License |
| |
| PURPOSE: |
| Import localizations from gettext PO format |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
if ($argc < 2) {
die("Usage: " . basename($argv[0]) . " SRCDIR\n");
}
$srcdir = unslashify(realpath($argv[1]));
if (is_dir($srcdir)) {
$out = import_dir($srcdir);
}
else if (is_file($srcdir)) {
$out = import_file($srcdir);
}
// write output files
foreach ($out as $outfn => $texts) {
$lang = preg_match('!/([a-z]{2}(_[A-Z]{2})?)[./]!', $outfn, $m) ? $m[1] : '';
$varname = strpos($outfn, 'messages.inc') !== false ? 'messages' : 'labels';
$header = <<<EOF
<?php
/*
+-----------------------------------------------------------------------+
| localization/%s/%-51s|
| |
| Language file of the Roundcube Webmail client |
| Copyright (C) %s, The Roundcube Dev Team |
| Licensed under the GNU General Public License |
| |
+-----------------------------------------------------------------------+
| Author: %-62s|
+-----------------------------------------------------------------------+
*/
$%s = array();
EOF;
$author = preg_replace('/\s*<Unknown>/i', '', $texts['_translator']);
$output = sprintf($header, $lang, $varname.'.inc', date('Y'), $author, $varname);
foreach ($texts as $label => $value) {
if (is_array($value)) { var_dump($outfn, $label, $value); exit; }
if ($label[0] != '_' && strlen($value))
$output .= sprintf("\$%s['%s'] = '%s';\n", $varname, $label, strtr(addcslashes($value, "'"), array("\r" => '', "\n" => '\n')));
}
$output .= "\n";
$dir = dirname($outfn);
@mkdir($dir, 0755, true);
if (file_put_contents($outfn, $output))
echo "-> $outfn\n";
}
/**
* Convert all .po files in the given src directory
*/
function import_dir($indir)
{
$out = array();
foreach (glob($indir.'/*.po') as $fn) {
$out = array_merge_recursive($out, import_file($fn));
}
return $out;
}
/**
* Convert the given .po file into a Roundcube localization array
*/
function import_file($fn)
{
$out = array();
$lines = file($fn);
$language = '';
$translator = '';
// get language code from file name
if (preg_match('/-([a-z_]+).po$/i', $fn, $m))
$language = expand_langcode($m[1]);
$is_header = true;
$msgid = null;
$msgstr = '';
$dests = array();
foreach ($lines as $i => $line) {
$line = trim($line);
// parse header
if ($is_header && $line[0] == '"') {
list($key, $val) = explode(": ", preg_replace('/\\\n$/', '', trim($line, '"')), 2);
switch (strtolower($key)) {
case 'language':
$language = expand_langcode($val);
break;
case 'last-translator':
$translator = $val;
break;
}
}
// empty line
if ($line == '') {
if ($msgid && $dests) {
foreach ($dests as $dest) {
list($file, $label) = explode(':', $dest);
$out[$file][$label] = $msgstr;
$out[$file]['_translator'] = $translator;
}
}
$msgid = null;
$msgstr = '';
$dests = array();
}
// meta line
if ($line[0] == '#') {
$value = trim(substr($line, 2));
if ($line[1] == ':')
$dests[] = str_replace('en_US', $language, $value);
}
else if (strpos($line, 'msgid') === 0) {
$msgid = gettext_decode(substr($line, 6));
if (!empty($msgid))
$is_header = false;
}
else if (strpos($line, 'msgstr') === 0) {
$msgstr = gettext_decode(substr($line, 7));
}
else if ($msgid && $line[0] == '"') {
$msgstr .= gettext_decode($line);
}
else if ($msgid !== null && $line[0] == '"') {
$msgid .= gettext_decode($line);
}
}
if ($msgid && $dests) {
foreach ($dests as $dest) {
list($file, $label) = explode(':', $dest);
$out[$file][$label] = $msgstr;
$out[$file]['_translator'] = $translator;
}
}
return $language ? $out : array();
}
function gettext_decode($str)
{
return stripslashes(trim($str, '"'));
}
/**
* Translate two-chars language codes to our internally used language identifiers
*/
function expand_langcode($lang)
{
static $rcube_language_aliases, $rcube_languages;
if (!$rcube_language_aliases)
include(INSTALL_PATH . 'program/localization/index.inc');
if ($rcube_language_aliases[$lang])
return $rcube_language_aliases[$lang];
else if (strlen($lang) == 2 && !isset($rcube_languages[$lang]))
return strtolower($lang) . '_' . strtoupper($lang);
else
return $lang;
}
?>
diff --git a/bin/indexcontacts.sh b/bin/indexcontacts.sh
index 9509dc06a..2844742f7 100755
--- a/bin/indexcontacts.sh
+++ b/bin/indexcontacts.sh
@@ -1,54 +1,54 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/indexcontacts.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2011, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Update the fulltext index for all contacts of the internal |
| address book. |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH.'program/include/clisetup.php';
ini_set('memory_limit', -1);
// connect to DB
$RCMAIL = rcube::get_instance();
$db = $RCMAIL->get_dbh();
$db->db_connect('w');
if (!$db->is_connected() || $db->is_error()) {
rcube::raise_error("No DB connection", false, true);
}
// iterate over all users
$sql_result = $db->query("SELECT `user_id` FROM " . $db->table_name('users', true) . " ORDER BY `user_id`");
while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
echo "Indexing contacts for user " . $sql_arr['user_id'] . "...";
$contacts = new rcube_contacts($db, $sql_arr['user_id']);
$contacts->set_pagesize(9999);
$result = $contacts->list_records();
while ($result->count && ($row = $result->next())) {
unset($row['words']);
$contacts->update($row['ID'], $row);
}
echo "done.\n";
}
?>
diff --git a/bin/installto.sh b/bin/installto.sh
index fbd951bdf..d239c633d 100755
--- a/bin/installto.sh
+++ b/bin/installto.sh
@@ -1,81 +1,81 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/installto.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Update an existing Roundcube installation with files from |
| this version |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
$target_dir = unslashify($_SERVER['argv'][1]);
if (empty($target_dir) || !is_dir(realpath($target_dir)))
rcube::raise_error("Invalid target: not a directory\nUsage: installto.sh <TARGET>", false, true);
// read version from iniset.php
$iniset = @file_get_contents($target_dir . '/program/include/iniset.php');
if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m))
rcube::raise_error("No valid Roundcube installation found at $target_dir", false, true);
$oldversion = $m[1];
if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>='))
rcube::raise_error("Installation at target location is up-to-date!", false, true);
echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n";
$input = trim(fgets(STDIN));
if (strtolower($input) == 'y') {
$err = false;
echo "Copying files to target location...";
foreach (array('program','installer','bin','SQL','plugins','skins') as $dir) {
if (!system("rsync -avC " . INSTALL_PATH . "$dir/* $target_dir/$dir/")) {
$err = true;
break;
}
}
foreach (array('index.php','.htaccess','config/defaults.inc.php','CHANGELOG','README.md','UPGRADING','LICENSE') as $file) {
if (!system("rsync -av " . INSTALL_PATH . "$file $target_dir/$file")) {
$err = true;
break;
}
}
echo "done.\n\n";
if (is_dir("$target_dir/skins/default")) {
echo "Removing old default skin...";
system("rm -rf $target_dir/skins/default $target_dir/plugins/jqueryui/themes/default");
foreach (glob(INSTALL_PATH . "plugins/*/skins") as $plugin_skin_dir) {
$plugin_skin_dir = preg_replace('!^.*' . INSTALL_PATH . '!', '', $plugin_skin_dir);
if (is_dir("$target_dir/$plugin_skin_dir/classic"))
system("rm -rf $target_dir/$plugin_skin_dir/default");
}
echo "done.\n\n";
}
if (!$err) {
echo "Running update script at target...\n";
system("cd $target_dir && php bin/update.sh --version=$oldversion");
echo "All done.\n";
}
}
else
echo "Update cancelled. See ya!\n";
?>
diff --git a/bin/moduserprefs.sh b/bin/moduserprefs.sh
index e892b1f4d..3d46baaa4 100755
--- a/bin/moduserprefs.sh
+++ b/bin/moduserprefs.sh
@@ -1,82 +1,82 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/moduserprefs.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Bulk-change settings stored in user preferences |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH.'program/include/clisetup.php';
function print_usage()
{
print "Usage: moduserprefs.sh [--user=user-id] pref-name [pref-value|--delete]\n";
print "--user User ID in local database\n";
print "--delete Unset the given preference\n";
}
// get arguments
$args = rcube_utils::get_opt(array('u' => 'user', 'd' => 'delete'));
if ($_SERVER['argv'][1] == 'help') {
print_usage();
exit;
}
else if (empty($args[0]) || (!isset($args[1]) && !$args['delete'])) {
print "Missing required parameters.\n";
print_usage();
exit;
}
$pref_name = trim($args[0]);
$pref_value = $args['delete'] ? null : trim($args[1]);
// connect to DB
$rcmail = rcube::get_instance();
$db = $rcmail->get_dbh();
$db->db_connect('w');
if (!$db->is_connected() || $db->is_error())
die("No DB connection\n" . $db->is_error());
$query = '1=1';
if ($args['user'])
$query = '`user_id` = ' . intval($args['user']);
// iterate over all users
$sql_result = $db->query("SELECT * FROM " . $db->table_name('users', true) . " WHERE $query");
while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
echo "Updating prefs for user " . $sql_arr['user_id'] . "...";
$user = new rcube_user($sql_arr['user_id'], $sql_arr);
$prefs = $old_prefs = $user->get_prefs();
$prefs[$pref_name] = $pref_value;
if ($prefs != $old_prefs) {
$user->save_prefs($prefs);
echo "saved.\n";
}
else {
echo "nothing changed.\n";
}
}
?>
diff --git a/bin/msgexport.sh b/bin/msgexport.sh
index f68688b67..f76aefe86 100755
--- a/bin/msgexport.sh
+++ b/bin/msgexport.sh
@@ -1,143 +1,143 @@
#!/usr/bin/env php
<?php
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
ini_set('memory_limit', -1);
require_once INSTALL_PATH.'program/include/clisetup.php';
function print_usage()
{
print "Usage: msgexport -h imap-host -u user-name -m mailbox name\n";
print "--host IMAP host\n";
print "--user IMAP user name\n";
print "--mbox Folder name, set to '*' for all\n";
print "--file Output file\n";
}
function vputs($str)
{
$out = $GLOBALS['args']['file'] ? STDOUT : STDERR;
fwrite($out, $str);
}
function progress_update($pos, $max)
{
$percent = round(100 * $pos / $max);
vputs(sprintf("%3d%% [%-51s] %d/%d\033[K\r", $percent, @str_repeat('=', $percent / 2) . '>', $pos, $max));
}
function export_mailbox($mbox, $filename)
{
global $IMAP;
$IMAP->set_folder($mbox);
$index = $IMAP->index($mbox, null, 'ASC');
$count = $index->count();
$index = $index->get();
vputs("Getting message list of {$mbox}...");
vputs("$count messages\n");
if ($filename)
{
if (!($out = fopen($filename, 'w')))
{
vputs("Cannot write to output file\n");
return;
}
vputs("Writing to $filename\n");
}
else
$out = STDOUT;
for ($i = 0; $i < $count; $i++)
{
$headers = $IMAP->get_message_headers($index[$i]);
$from = current(rcube_mime::decode_address_list($headers->from, 1, false));
fwrite($out, sprintf("From %s %s UID %d\n", $from['mailto'], $headers->date, $headers->uid));
$IMAP->get_raw_body($headers->uid, $out);
fwrite($out, "\n\n\n");
progress_update($i+1, $count);
}
vputs("\ncomplete.\n");
if ($filename)
fclose($out);
}
// get arguments
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
if ($_SERVER['argv'][1] == 'help')
{
print_usage();
exit;
}
else if (!$args['host'])
{
vputs("Missing required parameters.\n");
print_usage();
exit;
}
// prompt for username if not set
if (empty($args['user']))
{
vputs("IMAP user: ");
$args['user'] = trim(fgets(STDIN));
}
// prompt for password
$args['pass'] = rcube_utils::prompt_silent("Password: ");
// parse $host URL
$a_host = parse_url($args['host']);
if ($a_host['host'])
{
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
}
else
{
$host = $args['host'];
$imap_port = 143;
}
// instantiate IMAP class
$IMAP = new rcube_imap(null);
// try to connect to IMAP server
if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
{
vputs("IMAP login successful.\n");
$filename = null;
$mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : array($args['mbox']);
foreach ($mailboxes as $mbox)
{
if ($args['file'])
$filename = preg_replace('/\.[a-z0-9]{3,4}$/i', '', $args['file']) . asciiwords($mbox) . '.mbox';
else if ($args['mbox'] == '*')
$filename = asciiwords($mbox) . '.mbox';
if ($args['mbox'] == '*' && in_array(strtolower($mbox), array('junk','spam','trash')))
continue;
export_mailbox($mbox, $filename);
}
}
else
{
vputs("IMAP login failed.\n");
}
?>
diff --git a/bin/msgimport.sh b/bin/msgimport.sh
index 1fcc34680..0c72622c4 100755
--- a/bin/msgimport.sh
+++ b/bin/msgimport.sh
@@ -1,113 +1,113 @@
#!/usr/bin/env php
<?php
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
ini_set('memory_limit', -1);
require_once INSTALL_PATH.'program/include/clisetup.php';
function print_usage()
{
print "Usage: msgimport -h imap-host -u user-name -m mailbox -f message-file\n";
print "--host IMAP host\n";
print "--user IMAP user name\n";
print "--mbox Target mailbox\n";
print "--file Message file to upload\n";
}
// get arguments
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
if ($_SERVER['argv'][1] == 'help')
{
print_usage();
exit;
}
else if (!($args['host'] && $args['file']))
{
print "Missing required parameters.\n";
print_usage();
exit;
}
else if (!is_file($args['file']))
{
rcube::raise_error("Cannot read message file.", false, true);
}
// prompt for username if not set
if (empty($args['user']))
{
//fwrite(STDOUT, "Please enter your name\n");
echo "IMAP user: ";
$args['user'] = trim(fgets(STDIN));
}
// prompt for password
if (empty($args['pass']))
{
$args['pass'] = rcube_utils::prompt_silent("Password: ");
}
// parse $host URL
$a_host = parse_url($args['host']);
if ($a_host['host'])
{
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
}
else
{
$host = $args['host'];
$imap_port = 143;
}
// instantiate IMAP class
$IMAP = new rcube_imap(null);
// try to connect to IMAP server
if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
{
print "IMAP login successful.\n";
print "Uploading messages...\n";
$count = 0;
$message = $lastline = '';
$fp = fopen($args['file'], 'r');
while (($line = fgets($fp)) !== false)
{
if (preg_match('/^From\s+-/', $line) && $lastline == '')
{
if (!empty($message))
{
if ($IMAP->save_message($args['mbox'], rtrim($message)))
$count++;
else
rcube::raise_error("Failed to save message to {$args['mbox']}", false, true);
$message = '';
}
continue;
}
$message .= $line;
$lastline = rtrim($line);
}
if (!empty($message) && $IMAP->save_message($args['mbox'], rtrim($message)))
$count++;
// upload message from file
if ($count)
print "$count messages successfully added to {$args['mbox']}.\n";
else
print "Adding messages failed!\n";
}
else
{
rcube::raise_error("IMAP login failed.", false, true);
}
?>
diff --git a/bin/update.sh b/bin/update.sh
index f0c6d2f6c..cbacb940a 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -1,180 +1,180 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/update.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2010-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Check local configuration and database schema after upgrading |
| to a new version |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept'));
// ask user if no version is specified
if (!$opts['version']) {
echo "What version are you upgrading from? Type '?' if you don't know.\n";
if (($input = trim(fgets(STDIN))) && preg_match('/^[0-9.]+[a-z-]*$/', $input))
$opts['version'] = $input;
else
$opts['version'] = RCMAIL_VERSION;
}
$RCI = rcmail_install::get_instance();
$RCI->load_config();
if ($RCI->configured) {
$success = true;
if (($messages = $RCI->check_config()) || $RCI->legacy_config) {
$success = false;
$err = 0;
// list old/replaced config options
if (is_array($messages['replaced'])) {
echo "WARNING: Replaced config options:\n";
echo "(These config options have been replaced or renamed)\n";
foreach ($messages['replaced'] as $msg) {
echo "- '" . $msg['prop'] . "' was replaced by '" . $msg['replacement'] . "'\n";
$err++;
}
echo "\n";
}
// list obsolete config options (just a notice)
if (is_array($messages['obsolete'])) {
echo "NOTICE: Obsolete config options:\n";
echo "(You still have some obsolete or inexistent properties set. This isn't a problem but should be noticed)\n";
foreach ($messages['obsolete'] as $msg) {
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n";
$err++;
}
echo "\n";
}
if (!$err && $RCI->legacy_config) {
echo "WARNING: Your configuration needs to be migrated!\n";
echo "We changed the configuration files structure and your two config files main.inc.php and db.inc.php have to be merged into one single file.\n";
$err++;
}
// ask user to update config files
if ($err) {
if (!$opts['accept']) {
echo "Do you want me to fix your local configuration? (y/N)\n";
$input = trim(fgets(STDIN));
}
// positive: let's merge the local config with the defaults
if ($opts['accept'] || strtolower($input) == 'y') {
$error = $written = false;
// backup current config
echo ". backing up the current config file(s)...\n";
foreach (array('config', 'main', 'db') as $file) {
if (file_exists(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php')) {
if (!copy(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php', RCMAIL_CONFIG_DIR . '/' . $file . '.old.php')) {
$error = true;
}
}
}
if (!$error) {
$RCI->merge_config();
echo ". writing " . RCMAIL_CONFIG_DIR . "/config.inc.php...\n";
$written = $RCI->save_configfile($RCI->create_config());
}
// Success!
if ($written) {
echo "Done.\n";
echo "Your configuration files are now up-to-date!\n";
if ($messages['missing']) {
echo "But you still need to add the following missing options:\n";
foreach ($messages['missing'] as $msg)
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n";
}
if ($RCI->legacy_config) {
foreach (array('main', 'db') as $file) {
@unlink(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php');
}
}
}
else {
echo "Failed to write config file(s)!\n";
echo "Grant write privileges to the current user or update the files manually according to the above messages.\n";
}
}
else {
echo "Please update your config files manually according to the above messages.\n";
}
}
// check dependencies based on the current configuration
if (is_array($messages['dependencies'])) {
echo "WARNING: Dependency check failed!\n";
echo "(Some of your configuration settings require other options to be configured or additional PHP modules to be installed)\n";
foreach ($messages['dependencies'] as $msg) {
echo "- " . $msg['prop'] . ': ' . $msg['explain'] . "\n";
}
echo "Please fix your config files and run this script again!\n";
echo "See ya.\n";
}
}
// check file type detection
if ($RCI->check_mime_detection()) {
echo "WARNING: File type detection doesn't work properly!\n";
echo "Please check the 'mime_magic' config option or the finfo functions of PHP and run this script again.\n";
}
if ($RCI->check_mime_extensions()) {
echo "WARNING: Mimetype to file extension mapping doesn't work properly!\n";
echo "Please check the 'mime_types' config option and run this script again.\n";
}
// check database schema
if ($RCI->config['db_dsnw']) {
echo "Executing database schema update.\n";
system("php " . INSTALL_PATH . "bin/updatedb.sh --package=roundcube --version=" . $opts['version']
. " --dir=" . INSTALL_PATH . "SQL", $res);
$success = !$res;
}
// index contacts for fulltext searching
if ($opts['version'] && version_compare(version_parse($opts['version']), '0.6.0', '<')) {
system("php " . INSTALL_PATH . 'bin/indexcontacts.sh');
}
if ($success) {
echo "This instance of Roundcube is up-to-date.\n";
echo "Have fun!\n";
}
}
else {
echo "This instance of Roundcube is not yet configured!\n";
echo "Open http://url-to-roundcube/installer/ in your browser and follow the instuctions.\n";
}
?>
diff --git a/bin/updatecss.sh b/bin/updatecss.sh
index 53d237c77..6ecfeac98 100755
--- a/bin/updatecss.sh
+++ b/bin/updatecss.sh
@@ -1,122 +1,122 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/updatecss.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2010-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Update cache-baster marks for css background images |
+-----------------------------------------------------------------------+
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array(
'd' => 'dir',
));
if (empty($opts['dir'])) {
print "Skin directory not specified (--dir). Using skins/ and plugins/*/skins/.\n";
$dir = INSTALL_PATH . 'skins';
$dir_p = INSTALL_PATH . 'plugins';
$skins = glob("$dir/*", GLOB_ONLYDIR);
$skins_p = glob("$dir_p/*/skins/*", GLOB_ONLYDIR);
$dirs = array_merge($skins, $skins_p);
}
// Check if directory exists
else if (!file_exists($opts['dir'])) {
rcube::raise_error("Specified directory doesn't exist.", false, true);
}
else {
$dirs = array($opts['dir']);
}
foreach ($dirs as $dir) {
$img_dir = $dir . '/images';
if (!file_exists($img_dir)) {
continue;
}
$files = get_files($dir);
$images = get_images($img_dir);
$find = array();
$replace = array();
// build regexps array
foreach ($images as $path => $sum) {
$path_ex = str_replace('.', '\\.', $path);
$find[] = "#url\(['\"]?images/$path_ex(\?v=[a-f0-9-\.]+)?['\"]?\)#";
$replace[] = "url(images/$path?v=$sum)";
}
foreach ($files as $file) {
$file = $dir . '/' . $file;
print "File: $file\n";
$content = file_get_contents($file);
$content = preg_replace($find, $replace, $content, -1, $count);
if ($count) {
file_put_contents($file, $content);
}
}
}
function get_images($dir)
{
$images = array();
$dh = opendir($dir);
while ($file = readdir($dh)) {
if (preg_match('/^(.+)\.(gif|ico|png|jpg|jpeg)$/', $file, $m)) {
$filepath = "$dir/$file";
$images[$file] = substr(md5_file($filepath), 0, 4) . '.' . filesize($filepath);
print "Image: $filepath ({$images[$file]})\n";
}
else if ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) {
foreach (get_images($dir . '/' . $file) as $img => $sum) {
$images[$file . '/' . $img] = $sum;
}
}
}
closedir($dh);
return $images;
}
function get_files($dir)
{
$files = array();
$dh = opendir($dir);
while ($file = readdir($dh)) {
if (preg_match('/^(.+)\.(css|html)$/', $file, $m)) {
$files[] = $file;
}
else if ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) {
foreach (get_files($dir . '/' . $file) as $f) {
$files[] = $file . '/' . $f;
}
}
}
closedir($dh);
return $files;
}
?>
diff --git a/bin/updatedb.sh b/bin/updatedb.sh
index e9818074d..ffeac0ba8 100755
--- a/bin/updatedb.sh
+++ b/bin/updatedb.sh
@@ -1,178 +1,178 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/updatedb.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2010-2012, The Roundcube Dev Team |
| Copyright (C) 2010-2012, Kolab Systems AG |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Update database schema |
+-----------------------------------------------------------------------+
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array(
'v' => 'version',
'd' => 'dir',
'p' => 'package',
));
if (empty($opts['dir'])) {
rcube::raise_error("Database schema directory not specified (--dir).", false, true);
}
if (empty($opts['package'])) {
rcube::raise_error("Database schema package name not specified (--package).", false, true);
}
// Check if directory exists
if (!file_exists($opts['dir'])) {
rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
}
$RC = rcube::get_instance();
$DB = rcube_db::factory($RC->config->get('db_dsnw'));
$DB->set_debug((bool)$RC->config->get('sql_debug'));
// Connect to database
$DB->db_connect('w');
if (!$DB->is_connected()) {
rcube::raise_error("Error connecting to database: " . $DB->is_error(), false, true);
}
// Read DB schema version from database (if 'system' table exists)
if (in_array($DB->table_name('system'), (array)$DB->list_tables())) {
$DB->query("SELECT `value`"
." FROM " . $DB->table_name('system', true)
." WHERE `name` = ?",
$opts['package'] . '-version');
$row = $DB->fetch_array();
$version = preg_replace('/[^0-9]/', '', $row[0]);
}
// DB version not found, but release version is specified
if (!$version && $opts['version']) {
// Map old release version string to DB schema version
// Note: This is for backward compat. only, do not need to be updated
$map = array(
'0.1-stable' => 1,
'0.1.1' => 2008030300,
'0.2-alpha' => 2008040500,
'0.2-beta' => 2008060900,
'0.2-stable' => 2008092100,
'0.2.1' => 2008092100,
'0.2.2' => 2008092100,
'0.3-stable' => 2008092100,
'0.3.1' => 2009090400,
'0.4-beta' => 2009103100,
'0.4' => 2010042300,
'0.4.1' => 2010042300,
'0.4.2' => 2010042300,
'0.5-beta' => 2010100600,
'0.5' => 2010100600,
'0.5.1' => 2010100600,
'0.5.2' => 2010100600,
'0.5.3' => 2010100600,
'0.5.4' => 2010100600,
'0.6-beta' => 2011011200,
'0.6' => 2011011200,
'0.7-beta' => 2011092800,
'0.7' => 2011111600,
'0.7.1' => 2011111600,
'0.7.2' => 2011111600,
'0.7.3' => 2011111600,
'0.7.4' => 2011111600,
'0.8-beta' => 2011121400,
'0.8-rc' => 2011121400,
'0.8.0' => 2011121400,
'0.8.1' => 2011121400,
'0.8.2' => 2011121400,
'0.8.3' => 2011121400,
'0.8.4' => 2011121400,
'0.8.5' => 2011121400,
'0.8.6' => 2011121400,
'0.9-beta' => 2012080700,
);
$version = $map[$opts['version']];
}
// Assume last version before the 'system' table was added
if (empty($version)) {
$version = 2012080700;
}
$dir = $opts['dir'] . '/' . $DB->db_provider;
if (!file_exists($dir)) {
rcube::raise_error("DDL Upgrade files for " . $DB->db_provider . " driver not found.", false, true);
}
$dh = opendir($dir);
$result = array();
while ($file = readdir($dh)) {
if (preg_match('/^([0-9]+)\.sql$/', $file, $m) && $m[1] > $version) {
$result[] = $m[1];
}
}
sort($result, SORT_NUMERIC);
foreach ($result as $v) {
echo "Updating database schema ($v)... ";
$error = update_db_schema($opts['package'], $v, "$dir/$v.sql");
if ($error) {
echo "[FAILED]\n";
rcube::raise_error("Error in DDL upgrade $v: $error", false, true);
}
echo "[OK]\n";
}
function update_db_schema($package, $version, $file)
{
global $DB;
// read DDL file
if ($sql = file_get_contents($file)) {
if (!$DB->exec_script($sql)) {
return $DB->is_error();
}
}
// escape if 'system' table does not exist
if ($version < 2013011000) {
return;
}
$system_table = $DB->table_name('system', true);
$DB->query("UPDATE " . $system_table
." SET `value` = ?"
." WHERE `name` = ?",
$version, $package . '-version');
if (!$DB->is_error() && !$DB->affected_rows()) {
$DB->query("INSERT INTO " . $system_table
." (`name`, `value`) VALUES (?, ?)",
$package . '-version', $version);
}
return $DB->is_error();
}
?>
diff --git a/installer/index.php b/installer/index.php
index b93ad2f94..61ff40076 100644
--- a/installer/index.php
+++ b/installer/index.php
@@ -1,179 +1,179 @@
<?php
/*
+-------------------------------------------------------------------------+
| Roundcube Webmail setup tool |
| Version 1.1-git |
| |
| Copyright (C) 2009-2014, The Roundcube Dev Team |
| |
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU General Public License (with exceptions |
| for skins & plugins) as published by the Free Software Foundation, |
| either version 3 of the License, or (at your option) any later version. |
| |
| This file forms part of the Roundcube Webmail Software for which the |
| following exception is added: Plugins and Skins which merely make |
| function calls to the Roundcube Webmail Software, and for that purpose |
| include it by reference shall not be considered modifications of |
| the software. |
| |
| If you wish to use this file in another project or create a modified |
| version that will not be part of the Roundcube Webmail Software, you |
| may remove the exception above and use this source code under the |
| original version of the license. |
| |
| 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/. |
| |
+-------------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-------------------------------------------------------------------------+
*/
ini_set('error_reporting', E_ALL &~ (E_NOTICE | E_STRICT));
ini_set('display_errors', 1);
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
+define('INSTALL_PATH', realpath(__DIR__ . '/../').'/');
define('RCUBE_INSTALL_PATH', INSTALL_PATH);
define('RCUBE_CONFIG_DIR', INSTALL_PATH . 'config/');
$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
// include composer autoloader (if available)
if (@file_exists(INSTALL_PATH . 'vendor/autoload.php')) {
require INSTALL_PATH . 'vendor/autoload.php';
}
require_once 'Roundcube/bootstrap.php';
// deprecated aliases (to be removed)
require_once 'bc.php';
if (function_exists('session_start'))
session_start();
$RCI = rcmail_install::get_instance();
$RCI->load_config();
if (isset($_GET['_getconfig'])) {
$filename = 'config.inc.php';
if (!empty($_SESSION['config'])) {
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $_SESSION['config'];
exit;
}
else {
header('HTTP/1.0 404 Not found');
die("The requested configuration was not found. Please run the installer from the beginning.");
}
}
if ($RCI->configured && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) &&
!empty($_GET['_mergeconfig'])) {
$filename = 'config.inc.php';
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
$RCI->merge_config();
echo $RCI->create_config();
exit;
}
// go to 'check env' step if we have a local configuration
if ($RCI->configured && empty($_REQUEST['_step'])) {
header("Location: ./?_step=1");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Roundcube Webmail Installer</title>
<meta name="Robots" content="noindex,nofollow" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="client.js"></script>
</head>
<body>
<div id="banner">
<div class="banner-bg"></div>
<div class="banner-logo"><a href="http://roundcube.net"><img src="images/roundcube_logo.png" width="210" height="55" border="0" alt="Roundcube - open source webmail software" /></a></div>
</div>
<div id="topnav">
<a href="http://trac.roundcube.net/wiki/Howto_Install">How-to Wiki</a>
</div>
<div id="content">
<?php
// exit if installation is complete
if ($RCI->configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) {
// header("HTTP/1.0 404 Not Found");
if ($RCI->configured && $RCI->legacy_config) {
echo '<h2 class="error">Your configuration needs to be migrated!</h2>';
echo '<p>We changed the configuration files structure and your installation needs to be updated accordingly.</p>';
echo '<p>Please run the <tt>bin/update.sh</tt> script from the command line or set <p>&nbsp; <tt>$rcube_config[\'enable_installer\'] = true;</tt></p>';
echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.</p>';
}
else {
echo '<h2 class="error">The installer is disabled!</h2>';
echo '<p>To enable it again, set <tt>$config[\'enable_installer\'] = true;</tt> in RCUBE_CONFIG_DIR/config.inc.php</p>';
}
echo '</div></body></html>';
exit;
}
?>
<h1>Roundcube Webmail Installer</h1>
<ol id="progress">
<?php
$include_steps = array(
1 => './check.php',
2 => './config.php',
3 => './test.php',
);
if (!in_array($RCI->step, array_keys($include_steps))) {
$RCI->step = 1;
}
foreach (array('Check environment', 'Create config', 'Test config') as $i => $item) {
$j = $i + 1;
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . Q($item) . '</a>' : Q($item);
printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
}
?>
</ol>
<?php
include $include_steps[$RCI->step];
?>
</div>
<div id="footer">
Installer by the Roundcube Dev Team. Copyright &copy; 2008-2012 – Published under the GNU Public License;&nbsp;
Icons by <a href="http://famfamfam.com">famfamfam</a>
</div>
</body>
</html>
diff --git a/plugins/acl/tests/Acl.php b/plugins/acl/tests/Acl.php
index e752ac977..56ae3b5bb 100644
--- a/plugins/acl/tests/Acl.php
+++ b/plugins/acl/tests/Acl.php
@@ -1,23 +1,23 @@
<?php
class Acl_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../acl.php';
+ include_once __DIR__ . '/../acl.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new acl($rcube->api);
$this->assertInstanceOf('acl', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
index 1c54ffc42..55e8c441e 100644
--- a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
+++ b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
@@ -1,23 +1,23 @@
<?php
class AdditionalMessageHeaders_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../additional_message_headers.php';
+ include_once __DIR__ . '/../additional_message_headers.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new additional_message_headers($rcube->api);
$this->assertInstanceOf('additional_message_headers', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/archive/tests/Archive.php b/plugins/archive/tests/Archive.php
index 0a1eeae11..17fcdf7a1 100644
--- a/plugins/archive/tests/Archive.php
+++ b/plugins/archive/tests/Archive.php
@@ -1,23 +1,23 @@
<?php
class Archive_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../archive.php';
+ include_once __DIR__ . '/../archive.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new archive($rcube->api);
$this->assertInstanceOf('archive', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/autologon/tests/Autologon.php b/plugins/autologon/tests/Autologon.php
index 0de193e4a..f3f6b4206 100644
--- a/plugins/autologon/tests/Autologon.php
+++ b/plugins/autologon/tests/Autologon.php
@@ -1,23 +1,23 @@
<?php
class Autologon_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../autologon.php';
+ include_once __DIR__ . '/../autologon.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new autologon($rcube->api);
$this->assertInstanceOf('autologon', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/database_attachments/tests/DatabaseAttachments.php b/plugins/database_attachments/tests/DatabaseAttachments.php
index f260737ab..15ea5f44e 100644
--- a/plugins/database_attachments/tests/DatabaseAttachments.php
+++ b/plugins/database_attachments/tests/DatabaseAttachments.php
@@ -1,23 +1,23 @@
<?php
class DatabaseAttachments_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../database_attachments.php';
+ include_once __DIR__ . '/../database_attachments.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new database_attachments($rcube->api);
$this->assertInstanceOf('database_attachments', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php
index 88237d767..07190e5a1 100644
--- a/plugins/debug_logger/debug_logger.php
+++ b/plugins/debug_logger/debug_logger.php
@@ -1,150 +1,150 @@
<?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.inc.php and add your desired
* log types and files.
*
* @version @package_version@
* @author Ziba Scott
* @website http://roundcube.net
*
* Example:
*
* config.inc.php:
*
* // $config['debug_logger'][type of logging] = name of file in log_dir
* // The 'master' log includes timing information
* $config['debug_logger']['master'] = 'master';
* // If you want sql messages to also go into a separate file
* $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();
+ require_once(__DIR__ . '/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.". ";
+ $start_string .= "Action: ".$action.". ";
}
if($task){
- $start_string .= "Task: ".$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/rcube_storage is supported
$bt = debug_backtrace();
$file = $bt[3]['file'];
switch(basename($file)){
case 'rcube_imap.php':
$type = 'imap';
break;
case 'rcube_storage.php':
$type = 'storage';
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()
{
if ($this->runlog)
$this->runlog->end();
}
}
diff --git a/plugins/debug_logger/tests/DebugLogger.php b/plugins/debug_logger/tests/DebugLogger.php
index de20a069d..8dd0c03fe 100644
--- a/plugins/debug_logger/tests/DebugLogger.php
+++ b/plugins/debug_logger/tests/DebugLogger.php
@@ -1,23 +1,23 @@
<?php
class DebugLogger_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../debug_logger.php';
+ include_once __DIR__ . '/../debug_logger.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new debug_logger($rcube->api);
$this->assertInstanceOf('debug_logger', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/emoticons/tests/Emoticons.php b/plugins/emoticons/tests/Emoticons.php
index 4b6c303c2..e04502285 100644
--- a/plugins/emoticons/tests/Emoticons.php
+++ b/plugins/emoticons/tests/Emoticons.php
@@ -1,23 +1,23 @@
<?php
class Emoticons_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../emoticons.php';
+ include_once __DIR__ . '/../emoticons.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new emoticons($rcube->api);
$this->assertInstanceOf('emoticons', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/enigma/tests/Enigma.php b/plugins/enigma/tests/Enigma.php
index 0d0d8f8ae..3972694fc 100644
--- a/plugins/enigma/tests/Enigma.php
+++ b/plugins/enigma/tests/Enigma.php
@@ -1,23 +1,23 @@
<?php
class Enigma_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../enigma.php';
+ include_once __DIR__ . '/../enigma.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new enigma($rcube->api);
$this->assertInstanceOf('enigma', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/example_addressbook/example_addressbook.php b/plugins/example_addressbook/example_addressbook.php
index 31077adf7..22e230c6f 100644
--- a/plugins/example_addressbook/example_addressbook.php
+++ b/plugins/example_addressbook/example_addressbook.php
@@ -1,53 +1,53 @@
<?php
-require_once(dirname(__FILE__) . '/example_addressbook_backend.php');
+require_once(__DIR__ . '/example_addressbook_backend.php');
/**
* Sample plugin to add a new address book
* with just a static list of contacts
*
* @license GNU GPLv3+
* @author Thomas Bruederli
*/
class example_addressbook extends rcube_plugin
{
private $abook_id = 'static';
private $abook_name = 'Static List';
public function init()
{
$this->add_hook('addressbooks_list', array($this, 'address_sources'));
$this->add_hook('addressbook_get', 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 = (array) $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)
{
$abook = new example_addressbook_backend($this->abook_name);
$p['sources'][$this->abook_id] = array(
'id' => $this->abook_id,
'name' => $this->abook_name,
'readonly' => $abook->readonly,
'groups' => $abook->groups,
);
return $p;
}
public function get_address_book($p)
{
if ($p['id'] === $this->abook_id) {
$p['instance'] = new example_addressbook_backend($this->abook_name);
}
return $p;
}
}
diff --git a/plugins/example_addressbook/tests/ExampleAddressbook.php b/plugins/example_addressbook/tests/ExampleAddressbook.php
index 4a54bd950..762ee7307 100644
--- a/plugins/example_addressbook/tests/ExampleAddressbook.php
+++ b/plugins/example_addressbook/tests/ExampleAddressbook.php
@@ -1,23 +1,23 @@
<?php
class ExampleAddressbook_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../example_addressbook.php';
+ include_once __DIR__ . '/../example_addressbook.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new example_addressbook($rcube->api);
$this->assertInstanceOf('example_addressbook', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/filesystem_attachments/tests/FilesystemAttachments.php b/plugins/filesystem_attachments/tests/FilesystemAttachments.php
index dcab315d3..3b60e12c9 100644
--- a/plugins/filesystem_attachments/tests/FilesystemAttachments.php
+++ b/plugins/filesystem_attachments/tests/FilesystemAttachments.php
@@ -1,23 +1,23 @@
<?php
class FilesystemAttachments_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../filesystem_attachments.php';
+ include_once __DIR__ . '/../filesystem_attachments.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new filesystem_attachments($rcube->api);
$this->assertInstanceOf('filesystem_attachments', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/help/tests/Help.php b/plugins/help/tests/Help.php
index baba492ae..ff5771bf9 100644
--- a/plugins/help/tests/Help.php
+++ b/plugins/help/tests/Help.php
@@ -1,23 +1,23 @@
<?php
class Help_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../help.php';
+ include_once __DIR__ . '/../help.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new help($rcube->api);
$this->assertInstanceOf('help', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/hide_blockquote/tests/HideBlockquote.php b/plugins/hide_blockquote/tests/HideBlockquote.php
index 030c05324..90e209459 100644
--- a/plugins/hide_blockquote/tests/HideBlockquote.php
+++ b/plugins/hide_blockquote/tests/HideBlockquote.php
@@ -1,23 +1,23 @@
<?php
class HideBlockquote_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../hide_blockquote.php';
+ include_once __DIR__ . '/../hide_blockquote.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new hide_blockquote($rcube->api);
$this->assertInstanceOf('hide_blockquote', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/http_authentication/tests/HttpAuthentication.php b/plugins/http_authentication/tests/HttpAuthentication.php
index c17236821..5de968d87 100644
--- a/plugins/http_authentication/tests/HttpAuthentication.php
+++ b/plugins/http_authentication/tests/HttpAuthentication.php
@@ -1,23 +1,23 @@
<?php
class HttpAuthentication_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../http_authentication.php';
+ include_once __DIR__ . '/../http_authentication.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new http_authentication($rcube->api);
$this->assertInstanceOf('http_authentication', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/identity_select/tests/IdentitySelect.php b/plugins/identity_select/tests/IdentitySelect.php
index 3d7269711..461e79d85 100644
--- a/plugins/identity_select/tests/IdentitySelect.php
+++ b/plugins/identity_select/tests/IdentitySelect.php
@@ -1,22 +1,22 @@
<?php
class IdentitySelect_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../identity_select.php';
+ include_once __DIR__ . '/../identity_select.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new identity_select($rcube->api);
$this->assertInstanceOf('identity_select', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/jqueryui/tests/Jqueryui.php b/plugins/jqueryui/tests/Jqueryui.php
index 3bcd27c9f..ee25818ec 100644
--- a/plugins/jqueryui/tests/Jqueryui.php
+++ b/plugins/jqueryui/tests/Jqueryui.php
@@ -1,23 +1,23 @@
<?php
class Jqueryui_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../jqueryui.php';
+ include_once __DIR__ . '/../jqueryui.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new jqueryui($rcube->api);
$this->assertInstanceOf('jqueryui', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/legacy_browser/tests/LegacyBrowser.php b/plugins/legacy_browser/tests/LegacyBrowser.php
index 8e9762fb2..7a35ee5b6 100644
--- a/plugins/legacy_browser/tests/LegacyBrowser.php
+++ b/plugins/legacy_browser/tests/LegacyBrowser.php
@@ -1,23 +1,23 @@
<?php
class Legacy_Browser_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../legacy_browser.php';
+ include_once __DIR__ . '/../legacy_browser.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new legacy_browser($rcube->api);
$this->assertInstanceOf('legacy_browser', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/managesieve/tests/Managesieve.php b/plugins/managesieve/tests/Managesieve.php
index d802f5614..6e930b81d 100644
--- a/plugins/managesieve/tests/Managesieve.php
+++ b/plugins/managesieve/tests/Managesieve.php
@@ -1,23 +1,23 @@
<?php
class Managesieve_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../managesieve.php';
+ include_once __DIR__ . '/../managesieve.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new managesieve($rcube->api);
$this->assertInstanceOf('managesieve', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/managesieve/tests/Parser.php b/plugins/managesieve/tests/Parser.php
index 9050f09c6..33edce0f0 100644
--- a/plugins/managesieve/tests/Parser.php
+++ b/plugins/managesieve/tests/Parser.php
@@ -1,62 +1,62 @@
<?php
class Parser extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_script.php';
+ include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_script.php';
}
/**
* Sieve script parsing
*
* @dataProvider data_parser
*/
function test_parser($input, $output, $message)
{
// get capabilities list from the script
$caps = array();
if (preg_match('/require \[([a-z0-9", ]+)\]/', $input, $m)) {
foreach (explode(',', $m[1]) as $cap) {
$caps[] = trim($cap, '" ');
}
}
$script = new rcube_sieve_script($input, $caps);
$result = $script->as_text();
$this->assertEquals(trim($result), trim($output), $message);
}
/**
* Data provider for test_parser()
*/
function data_parser()
{
- $dir_path = realpath(dirname(__FILE__) . '/src');
+ $dir_path = realpath(__DIR__ . '/src');
$dir = opendir($dir_path);
$result = array();
while ($file = readdir($dir)) {
if (preg_match('/^[a-z0-9_]+$/', $file)) {
$input = file_get_contents($dir_path . '/' . $file);
if (file_exists($dir_path . '/' . $file . '.out')) {
$output = file_get_contents($dir_path . '/' . $file . '.out');
}
else {
$output = $input;
}
$result[] = array(
'input' => $input,
'output' => $output,
'message' => "Error in parsing '$file' file",
);
}
}
return $result;
}
}
diff --git a/plugins/managesieve/tests/Tokenizer.php b/plugins/managesieve/tests/Tokenizer.php
index e71bae015..f50ed75b7 100644
--- a/plugins/managesieve/tests/Tokenizer.php
+++ b/plugins/managesieve/tests/Tokenizer.php
@@ -1,33 +1,33 @@
<?php
class Tokenizer extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_script.php';
+ include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_script.php';
}
function data_tokenizer()
{
return array(
array(1, "text: #test\nThis is test ; message;\nMulti line\n.\n;\n", '"This is test ; message;\nMulti line"'),
array(0, '["test1","test2"]', '[["test1","test2"]]'),
array(1, '["test"]', '["test"]'),
array(1, '"te\\"st"', '"te\\"st"'),
array(0, 'test #comment', '["test"]'),
array(0, "text:\ntest\n.\ntext:\ntest\n.\n", '["test","test"]'),
array(1, '"\\a\\\\\\"a"', '"a\\\\\\"a"'),
);
}
/**
* @dataProvider data_tokenizer
*/
function test_tokenizer($num, $input, $output)
{
$res = json_encode(rcube_sieve_script::tokenize($input, $num));
$this->assertEquals(trim($res), trim($output));
}
}
diff --git a/plugins/managesieve/tests/Vacation.php b/plugins/managesieve/tests/Vacation.php
index e34eb7aa2..942525c2f 100644
--- a/plugins/managesieve/tests/Vacation.php
+++ b/plugins/managesieve/tests/Vacation.php
@@ -1,66 +1,66 @@
<?php
class Managesieve_Vacation extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_engine.php';
- include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_vacation.php';
+ include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_engine.php';
+ include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_vacation.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$vacation = new rcube_sieve_vacation(true);
$this->assertInstanceOf('rcube_sieve_vacation', $vacation);
}
function test_build_regexp_tests()
{
$tests = rcube_sieve_vacation::build_regexp_tests('2014-02-20', '2014-03-05', $error);
$this->assertCount(2, $tests);
$this->assertSame('header', $tests[0]['test']);
$this->assertSame('regex', $tests[0]['type']);
$this->assertSame('received', $tests[0]['arg1']);
$this->assertSame('(20|21|22|23|24|25|26|27|28) Feb 2014', $tests[0]['arg2']);
$this->assertSame('header', $tests[1]['test']);
$this->assertSame('regex', $tests[1]['type']);
$this->assertSame('received', $tests[1]['arg1']);
$this->assertSame('([ 0]1|[ 0]2|[ 0]3|[ 0]4|[ 0]5) Mar 2014', $tests[1]['arg2']);
$tests = rcube_sieve_vacation::build_regexp_tests('2014-02-20', '2014-01-05', $error);
$this->assertSame(null, $tests);
$this->assertSame('managesieve.invaliddateformat', $error);
}
function test_parse_regexp_tests()
{
$tests = array(
array(
'test' => 'header',
'type' => 'regex',
'arg1' => 'received',
'arg2' => '(20|21|22|23|24|25|26|27|28) Feb 2014',
),
array(
'test' => 'header',
'type' => 'regex',
'arg1' => 'received',
'arg2' => '([ 0]1|[ 0]2|[ 0]3|[ 0]4|[ 0]5) Mar 2014',
)
);
$result = rcube_sieve_vacation::parse_regexp_tests($tests);
$this->assertCount(2, $result);
$this->assertSame('20 Feb 2014', $result['from']);
$this->assertSame('05 Mar 2014', $result['to']);
}
}
diff --git a/plugins/markasjunk/tests/Markasjunk.php b/plugins/markasjunk/tests/Markasjunk.php
index cdf13255e..73494b0ec 100644
--- a/plugins/markasjunk/tests/Markasjunk.php
+++ b/plugins/markasjunk/tests/Markasjunk.php
@@ -1,23 +1,23 @@
<?php
class Markasjunk_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../markasjunk.php';
+ include_once __DIR__ . '/../markasjunk.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new markasjunk($rcube->api);
$this->assertInstanceOf('markasjunk', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/new_user_dialog/tests/NewUserDialog.php b/plugins/new_user_dialog/tests/NewUserDialog.php
index 3a52f20f3..e58489a09 100644
--- a/plugins/new_user_dialog/tests/NewUserDialog.php
+++ b/plugins/new_user_dialog/tests/NewUserDialog.php
@@ -1,23 +1,23 @@
<?php
class NewUserDialog_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../new_user_dialog.php';
+ include_once __DIR__ . '/../new_user_dialog.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new new_user_dialog($rcube->api);
$this->assertInstanceOf('new_user_dialog', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/new_user_identity/tests/NewUserIdentity.php b/plugins/new_user_identity/tests/NewUserIdentity.php
index c1d385853..21197362e 100644
--- a/plugins/new_user_identity/tests/NewUserIdentity.php
+++ b/plugins/new_user_identity/tests/NewUserIdentity.php
@@ -1,23 +1,23 @@
<?php
class NewUserIdentity_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../new_user_identity.php';
+ include_once __DIR__ . '/../new_user_identity.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new new_user_identity($rcube->api);
$this->assertInstanceOf('new_user_identity', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/newmail_notifier/tests/NewmailNotifier.php b/plugins/newmail_notifier/tests/NewmailNotifier.php
index 571912a61..ccddccd39 100644
--- a/plugins/newmail_notifier/tests/NewmailNotifier.php
+++ b/plugins/newmail_notifier/tests/NewmailNotifier.php
@@ -1,23 +1,23 @@
<?php
class NewmailNotifier_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../newmail_notifier.php';
+ include_once __DIR__ . '/../newmail_notifier.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new newmail_notifier($rcube->api);
$this->assertInstanceOf('newmail_notifier', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/password/tests/Password.php b/plugins/password/tests/Password.php
index a9663a946..b64c6b889 100644
--- a/plugins/password/tests/Password.php
+++ b/plugins/password/tests/Password.php
@@ -1,23 +1,23 @@
<?php
class Password_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../password.php';
+ include_once __DIR__ . '/../password.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new password($rcube->api);
$this->assertInstanceOf('password', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/redundant_attachments/tests/RedundantAttachments.php b/plugins/redundant_attachments/tests/RedundantAttachments.php
index 386f97e59..53f0c0138 100644
--- a/plugins/redundant_attachments/tests/RedundantAttachments.php
+++ b/plugins/redundant_attachments/tests/RedundantAttachments.php
@@ -1,23 +1,23 @@
<?php
class RedundantAttachments_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../redundant_attachments.php';
+ include_once __DIR__ . '/../redundant_attachments.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new redundant_attachments($rcube->api);
$this->assertInstanceOf('redundant_attachments', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
index 902ce510b..ab77351a4 100644
--- a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
+++ b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
@@ -1,23 +1,23 @@
<?php
class ShowAdditionalHeaders_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../show_additional_headers.php';
+ include_once __DIR__ . '/../show_additional_headers.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new show_additional_headers($rcube->api);
$this->assertInstanceOf('show_additional_headers', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
index 2e35509f0..0e3a5c48a 100644
--- a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
+++ b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
@@ -1,23 +1,23 @@
<?php
class SquirrelmailUsercopy_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../squirrelmail_usercopy.php';
+ include_once __DIR__ . '/../squirrelmail_usercopy.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new squirrelmail_usercopy($rcube->api);
$this->assertInstanceOf('squirrelmail_usercopy', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/subscriptions_option/tests/SubscriptionsOption.php b/plugins/subscriptions_option/tests/SubscriptionsOption.php
index 6932a955f..10168315e 100644
--- a/plugins/subscriptions_option/tests/SubscriptionsOption.php
+++ b/plugins/subscriptions_option/tests/SubscriptionsOption.php
@@ -1,23 +1,23 @@
<?php
class SubscriptionsOption_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../subscriptions_option.php';
+ include_once __DIR__ . '/../subscriptions_option.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new subscriptions_option($rcube->api);
$this->assertInstanceOf('subscriptions_option', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/userinfo/tests/Userinfo.php b/plugins/userinfo/tests/Userinfo.php
index 762d5a1fa..7eb0758b5 100644
--- a/plugins/userinfo/tests/Userinfo.php
+++ b/plugins/userinfo/tests/Userinfo.php
@@ -1,23 +1,23 @@
<?php
class Userinfo_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../userinfo.php';
+ include_once __DIR__ . '/../userinfo.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new userinfo($rcube->api);
$this->assertInstanceOf('userinfo', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/vcard_attachments/tests/VcardAttachments.php b/plugins/vcard_attachments/tests/VcardAttachments.php
index 35fd7f447..4b37cfc01 100644
--- a/plugins/vcard_attachments/tests/VcardAttachments.php
+++ b/plugins/vcard_attachments/tests/VcardAttachments.php
@@ -1,23 +1,23 @@
<?php
class VcardAttachments_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../vcard_attachments.php';
+ include_once __DIR__ . '/../vcard_attachments.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new vcard_attachments($rcube->api);
$this->assertInstanceOf('vcard_attachments', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/virtuser_file/tests/VirtuserFile.php b/plugins/virtuser_file/tests/VirtuserFile.php
index a4362c3dc..80feecd15 100644
--- a/plugins/virtuser_file/tests/VirtuserFile.php
+++ b/plugins/virtuser_file/tests/VirtuserFile.php
@@ -1,23 +1,23 @@
<?php
class VirtuserFile_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../virtuser_file.php';
+ include_once __DIR__ . '/../virtuser_file.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new virtuser_file($rcube->api);
$this->assertInstanceOf('virtuser_file', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/virtuser_query/tests/VirtuserQuery.php b/plugins/virtuser_query/tests/VirtuserQuery.php
index d5bd4ee4b..6c68f4c64 100644
--- a/plugins/virtuser_query/tests/VirtuserQuery.php
+++ b/plugins/virtuser_query/tests/VirtuserQuery.php
@@ -1,23 +1,23 @@
<?php
class VirtuserQuery_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../virtuser_query.php';
+ include_once __DIR__ . '/../virtuser_query.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new virtuser_query($rcube->api);
$this->assertInstanceOf('virtuser_query', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/plugins/zipdownload/tests/Zipdownload.php b/plugins/zipdownload/tests/Zipdownload.php
index f3b4e1b35..3882dea87 100644
--- a/plugins/zipdownload/tests/Zipdownload.php
+++ b/plugins/zipdownload/tests/Zipdownload.php
@@ -1,23 +1,23 @@
<?php
class Zipdownload_Plugin extends PHPUnit_Framework_TestCase
{
function setUp()
{
- include_once dirname(__FILE__) . '/../zipdownload.php';
+ include_once __DIR__ . '/../zipdownload.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new zipdownload($rcube->api);
$this->assertInstanceOf('zipdownload', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
}
}
diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php
index 98bbce5d4..fe9c389fe 100644
--- a/program/lib/Roundcube/bootstrap.php
+++ b/program/lib/Roundcube/bootstrap.php
@@ -1,497 +1,497 @@
<?php
/*
+-----------------------------------------------------------------------+
| This file is part of the Roundcube PHP suite |
| Copyright (C) 2005-2014, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| CONTENTS: |
| Roundcube Framework Initialization |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
/**
* Roundcube Framework Initialization
*
* @package Framework
* @subpackage Core
*/
$config = array(
'error_reporting' => E_ALL & ~E_NOTICE & ~E_STRICT,
// Some users are not using Installer, so we'll check some
// critical PHP settings here. Only these, which doesn't provide
// an error/warning in the logs later. See (#1486307).
'mbstring.func_overload' => 0,
'magic_quotes_runtime' => false,
'magic_quotes_sybase' => false, // #1488506
);
// check these additional ini settings if not called via CLI
if (php_sapi_name() != 'cli') {
$config += array(
'suhosin.session.encrypt' => false,
'file_uploads' => true,
);
}
foreach ($config as $optname => $optval) {
$ini_optval = filter_var(ini_get($optname), is_bool($optval) ? FILTER_VALIDATE_BOOLEAN : FILTER_VALIDATE_INT);
if ($optval != $ini_optval && @ini_set($optname, $optval) === false) {
$error = "ERROR: Wrong '$optname' option value and it wasn't possible to set it to required value ($optval).\n"
. "Check your PHP configuration (including php_admin_flag).";
if (defined('STDERR')) fwrite(STDERR, $error); else echo $error;
exit(1);
}
}
// framework constants
define('RCUBE_VERSION', '1.1-git');
define('RCUBE_CHARSET', 'UTF-8');
if (!defined('RCUBE_LIB_DIR')) {
- define('RCUBE_LIB_DIR', dirname(__FILE__) . '/');
+ define('RCUBE_LIB_DIR', __DIR__ . '/');
}
if (!defined('RCUBE_INSTALL_PATH')) {
define('RCUBE_INSTALL_PATH', RCUBE_LIB_DIR);
}
if (!defined('RCUBE_CONFIG_DIR')) {
define('RCUBE_CONFIG_DIR', RCUBE_INSTALL_PATH . 'config/');
}
if (!defined('RCUBE_PLUGINS_DIR')) {
define('RCUBE_PLUGINS_DIR', RCUBE_INSTALL_PATH . 'plugins/');
}
if (!defined('RCUBE_LOCALIZATION_DIR')) {
define('RCUBE_LOCALIZATION_DIR', RCUBE_INSTALL_PATH . 'localization/');
}
// set internal encoding for mbstring extension
if (extension_loaded('mbstring')) {
mb_internal_encoding(RCUBE_CHARSET);
@mb_regex_encoding(RCUBE_CHARSET);
}
// make sure the Roundcube lib directory is in the include_path
$rcube_path = realpath(RCUBE_LIB_DIR . '..');
$sep = PATH_SEPARATOR;
$regexp = "!(^|$sep)" . preg_quote($rcube_path, '!') . "($sep|\$)!";
$path = ini_get('include_path');
if (!preg_match($regexp, $path)) {
set_include_path($path . PATH_SEPARATOR . $rcube_path);
}
// Register autoloader
spl_autoload_register('rcube_autoload');
// set PEAR error handling (will also load the PEAR main class)
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
/**
* Similar function as in_array() but case-insensitive
*
* @param string $needle Needle value
* @param array $heystack Array to search in
*
* @return boolean True if found, False if not
*/
function in_array_nocase($needle, $haystack)
{
$needle = mb_strtolower($needle);
foreach ((array)$haystack as $value) {
if ($needle === mb_strtolower($value)) {
return true;
}
}
return false;
}
/**
* Parse a human readable string for a number of bytes.
*
* @param string $str Input string
*
* @return float Number of bytes
*/
function parse_bytes($str)
{
if (is_numeric($str)) {
return floatval($str);
}
if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs)) {
$bytes = floatval($regs[1]);
switch (strtolower($regs[2])) {
case 'g':
case 'gb':
$bytes *= 1073741824;
break;
case 'm':
case 'mb':
$bytes *= 1048576;
break;
case 'k':
case 'kb':
$bytes *= 1024;
break;
}
}
return floatval($bytes);
}
/**
* Make sure the string ends with a slash
*/
function slashify($str)
{
return unslashify($str).'/';
}
/**
* Remove slashes at the end of the string
*/
function unslashify($str)
{
return preg_replace('/\/+$/', '', $str);
}
/**
* Returns number of seconds for a specified offset string.
*
* @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week)
*
* @return int Number of seconds
*/
function get_offset_sec($str)
{
if (preg_match('/^([0-9]+)\s*([smhdw])/i', $str, $regs)) {
$amount = (int) $regs[1];
$unit = strtolower($regs[2]);
}
else {
$amount = (int) $str;
$unit = 's';
}
switch ($unit) {
case 'w':
$amount *= 7;
case 'd':
$amount *= 24;
case 'h':
$amount *= 60;
case 'm':
$amount *= 60;
}
return $amount;
}
/**
* Create a unix timestamp with a specified offset from now.
*
* @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
* @param int $factor Factor to multiply with the offset
*
* @return int Unix timestamp
*/
function get_offset_time($offset_str, $factor=1)
{
return time() + get_offset_sec($offset_str) * $factor;
}
/**
* Truncate string if it is longer than the allowed length.
* Replace the middle or the ending part of a string with a placeholder.
*
* @param string $str Input string
* @param int $maxlength Max. length
* @param string $placeholder Replace removed chars with this
* @param bool $ending Set to True if string should be truncated from the end
*
* @return string Abbreviated string
*/
function abbreviate_string($str, $maxlength, $placeholder='...', $ending=false)
{
$length = mb_strlen($str);
if ($length > $maxlength) {
if ($ending) {
return mb_substr($str, 0, $maxlength) . $placeholder;
}
$placeholder_length = mb_strlen($placeholder);
$first_part_length = floor(($maxlength - $placeholder_length)/2);
$second_starting_location = $length - $maxlength + $first_part_length + $placeholder_length;
$str = mb_substr($str, 0, $first_part_length) . $placeholder . mb_substr($str, $second_starting_location);
}
return $str;
}
/**
* Get all keys from array (recursive).
*
* @param array $array Input array
*
* @return array List of array keys
*/
function array_keys_recursive($array)
{
$keys = array();
if (!empty($array) && is_array($array)) {
foreach ($array as $key => $child) {
$keys[] = $key;
foreach (array_keys_recursive($child) as $val) {
$keys[] = $val;
}
}
}
return $keys;
}
/**
* Remove all non-ascii and non-word chars except ., -, _
*/
function asciiwords($str, $css_id = false, $replace_with = '')
{
$allowed = 'a-z0-9\_\-' . (!$css_id ? '\.' : '');
return preg_replace("/[^$allowed]/i", $replace_with, $str);
}
/**
* Check if a string contains only ascii characters
*
* @param string $str String to check
* @param bool $control_chars Includes control characters
*
* @return bool
*/
function is_ascii($str, $control_chars = true)
{
$regexp = $control_chars ? '/[^\x00-\x7F]/' : '/[^\x20-\x7E]/';
return preg_match($regexp, $str) ? false : true;
}
/**
* Compose a valid representation of name and e-mail address
*
* @param string $email E-mail address
* @param string $name Person name
*
* @return string Formatted string
*/
function format_email_recipient($email, $name = '')
{
$email = trim($email);
if ($name && $name != $email) {
// Special chars as defined by RFC 822 need to in quoted string (or escaped).
if (preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name)) {
$name = '"'.addcslashes($name, '"').'"';
}
return "$name <$email>";
}
return $email;
}
/**
* Format e-mail address
*
* @param string $email E-mail address
*
* @return string Formatted e-mail address
*/
function format_email($email)
{
$email = trim($email);
$parts = explode('@', $email);
$count = count($parts);
if ($count > 1) {
$parts[$count-1] = mb_strtolower($parts[$count-1]);
$email = implode('@', $parts);
}
return $email;
}
/**
* Fix version number so it can be used correctly in version_compare()
*
* @param string $version Version number string
*
* @param return Version number string
*/
function version_parse($version)
{
return str_replace(
array('-stable', '-git'),
array('.0', '.99'),
$version);
}
/**
* mbstring replacement functions
*/
if (!extension_loaded('mbstring'))
{
function mb_strlen($str)
{
return strlen($str);
}
function mb_strtolower($str)
{
return strtolower($str);
}
function mb_strtoupper($str)
{
return strtoupper($str);
}
function mb_substr($str, $start, $len=null)
{
return substr($str, $start, $len);
}
function mb_strpos($haystack, $needle, $offset=0)
{
return strpos($haystack, $needle, $offset);
}
function mb_strrpos($haystack, $needle, $offset=0)
{
return strrpos($haystack, $needle, $offset);
}
}
/**
* intl replacement functions
*/
if (!function_exists('idn_to_utf8'))
{
function idn_to_utf8($domain, $flags=null)
{
static $idn, $loaded;
if (!$loaded) {
$idn = new Net_IDNA2();
$loaded = true;
}
if ($idn && $domain && preg_match('/(^|\.)xn--/i', $domain)) {
try {
$domain = $idn->decode($domain);
}
catch (Exception $e) {
}
}
return $domain;
}
}
if (!function_exists('idn_to_ascii'))
{
function idn_to_ascii($domain, $flags=null)
{
static $idn, $loaded;
if (!$loaded) {
$idn = new Net_IDNA2();
$loaded = true;
}
if ($idn && $domain && preg_match('/[^\x20-\x7E]/', $domain)) {
try {
$domain = $idn->encode($domain);
}
catch (Exception $e) {
}
}
return $domain;
}
}
/**
* Use PHP5 autoload for dynamic class loading
*
* @todo Make Zend, PEAR etc play with this
* @todo Make our classes conform to a more straight forward CS.
*/
function rcube_autoload($classname)
{
$filename = preg_replace(
array(
'/Mail_(.+)/',
'/Net_(.+)/',
'/Auth_(.+)/',
'/^html_.+/',
'/^rcube(.*)/'
),
array(
'Mail/\\1',
'Net/\\1',
'Auth/\\1',
'Roundcube/html',
'Roundcube/rcube\\1'
),
$classname
);
if ($fp = @fopen("$filename.php", 'r', true)) {
fclose($fp);
include_once "$filename.php";
return true;
}
return false;
}
/**
* Local callback function for PEAR errors
*/
function rcube_pear_error($err)
{
error_log(sprintf("%s (%s): %s",
$err->getMessage(),
$err->getCode(),
$err->getUserinfo()), 0);
}
diff --git a/tests/Framework/VCard.php b/tests/Framework/VCard.php
index c23dba844..6eea2c1a4 100644
--- a/tests/Framework/VCard.php
+++ b/tests/Framework/VCard.php
@@ -1,154 +1,154 @@
<?php
/**
* Unit tests for class rcube_vcard
*
* @package Tests
*/
class Framework_VCard extends PHPUnit_Framework_TestCase
{
function _srcpath($fn)
{
- return realpath(dirname(__FILE__) . '/../src/' . $fn);
+ return realpath(__DIR__ . '/../src/' . $fn);
}
function test_parse_one()
{
$vcard = new rcube_vcard(file_get_contents($this->_srcpath('apple.vcf')));
$this->assertTrue($vcard->business, "Identify as business record");
$this->assertEquals("Apple Computer AG", $vcard->displayname, "FN => displayname");
$this->assertEquals("", $vcard->firstname, "No person name set");
}
function test_parse_two()
{
$vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
$this->assertFalse($vcard->business, "Identify as private record");
$this->assertEquals("John Doë", $vcard->displayname, "Decode according to charset attribute");
$this->assertEquals("roundcube.net", $vcard->organization, "Test organization field");
$this->assertCount(2, $vcard->email, "List two e-mail addresses");
$this->assertEquals("roundcube@gmail.com", $vcard->email[0], "Use PREF e-mail as primary");
}
/**
* Make sure MOBILE phone is returned as CELL (as specified in standard)
*/
function test_parse_three()
{
$vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
$vcf = $vcard->export();
$this->assertRegExp('/TEL;CELL:\+987654321/', $vcf, "Return CELL instead of MOBILE (import)");
$vcard = new rcube_vcard();
$vcard->set('phone', '+987654321', 'MOBILE');
$vcf = $vcard->export();
$this->assertRegExp('/TEL;TYPE=CELL:\+987654321/', $vcf, "Return CELL instead of MOBILE (set)");
}
/**
* Backslash escaping test (#1488896)
*/
function test_parse_four()
{
$vcard = "BEGIN:VCARD\nVERSION:3.0\nN:last\\;;first\\\\;middle\\\\\\;\\\\;prefix;\nFN:test\nEND:VCARD";
$vcard = new rcube_vcard($vcard, null);
$vcard = $vcard->get_assoc();
$this->assertEquals("last;", $vcard['surname'], "Decode backslash character");
$this->assertEquals("first\\", $vcard['firstname'], "Decode backslash character");
$this->assertEquals("middle\\;\\", $vcard['middlename'], "Decode backslash character");
$this->assertEquals("prefix", $vcard['prefix'], "Decode backslash character");
}
/**
* Backslash parsing test (#1489085)
*/
function test_parse_five()
{
$vcard = "BEGIN:VCARD\nVERSION:3.0\nN:last\\\\\\a;fir\\nst\nURL:http\\://domain.tld\nEND:VCARD";
$vcard = new rcube_vcard($vcard, null);
$vcard = $vcard->get_assoc();
$this->assertEquals("last\\a", $vcard['surname'], "Decode dummy backslash character");
$this->assertEquals("fir\nst", $vcard['firstname'], "Decode backslash character");
$this->assertEquals("http://domain.tld", $vcard['website:other'][0], "Decode dummy backslash character");
}
/**
* Some Apple vCard quirks (#1489993)
*/
function test_parse_six()
{
$vcard = new rcube_vcard("BEGIN:VCARD\n"
. "VERSION:3.0\n"
. "N:;;;;\n"
. "FN:Apple Computer AG\n"
. "ITEM1.ADR;type=WORK;type=pref:;;Birgistrasse 4a;Wallisellen-Zürich;;8304;Switzerland\n"
. "PHOTO;ENCODING=B:aHR0cDovL3Rlc3QuY29t\n"
. "END:VCARD"
);
$result = $vcard->get_assoc();
$this->assertCount(1, $result['address:work'], "ITEM1.-prefixed entry");
}
function test_import()
{
$input = file_get_contents($this->_srcpath('apple.vcf'));
$input .= file_get_contents($this->_srcpath('johndoe.vcf'));
$vcards = rcube_vcard::import($input);
$this->assertCount(2, $vcards, "Detected 2 vcards");
$this->assertEquals("Apple Computer AG", $vcards[0]->displayname, "FN => displayname");
$this->assertEquals("John Doë", $vcards[1]->displayname, "Displayname with correct charset");
// http://trac.roundcube.net/ticket/1485542
$vcards2 = rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf')));
$this->assertEquals("Iksiñski", $vcards2[0]->surname, "Detect charset in encoded values");
}
function test_import_photo_encoding()
{
$input = file_get_contents($this->_srcpath('photo.vcf'));
$vcards = rcube_vcard::import($input);
$vcard = $vcards[0]->get_assoc();
$this->assertCount(1, $vcards, "Detected 1 vcard");
// ENCODING=b case (#1488683)
$this->assertEquals("/9j/4AAQSkZJRgABAQA", substr(base64_encode($vcard['photo']), 0, 19), "Photo decoding");
$this->assertEquals("Müller", $vcard['surname'], "Unicode characters");
$input = str_replace('ENCODING=b:', 'ENCODING=base64;jpeg:', $input);
$vcards = rcube_vcard::import($input);
$vcard = $vcards[0]->get_assoc();
// ENCODING=base64 case (#1489977)
$this->assertEquals("/9j/4AAQSkZJRgABAQA", substr(base64_encode($vcard['photo']), 0, 19), "Photo decoding");
$input = str_replace('PHOTO;ENCODING=base64;jpeg:', 'PHOTO:data:image/jpeg;base64,', $input);
$vcards = rcube_vcard::import($input);
$vcard = $vcards[0]->get_assoc();
// vcard4.0 "PHOTO:data:image/jpeg;base64," case (#1489977)
$this->assertEquals("/9j/4AAQSkZJRgABAQA", substr(base64_encode($vcard['photo']), 0, 19), "Photo decoding");
}
function test_encodings()
{
$input = file_get_contents($this->_srcpath('utf-16_sample.vcf'));
$vcards = rcube_vcard::import($input);
$this->assertEquals("Ǽgean ĽdaMonté", $vcards[0]->displayname, "Decoded from UTF-16");
}
}
diff --git a/tests/Selenium/bootstrap.php b/tests/Selenium/bootstrap.php
index ed9c2eb32..124a81ef2 100644
--- a/tests/Selenium/bootstrap.php
+++ b/tests/Selenium/bootstrap.php
@@ -1,234 +1,234 @@
<?php
/*
+-----------------------------------------------------------------------+
| tests/Selenium/bootstrap.php |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2009-2014, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Environment initialization script for unit tests |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
if (php_sapi_name() != 'cli')
die("Not in shell mode (php-cli)");
-if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../../') . '/' );
+if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(__DIR__ . '/../../') . '/' );
-define('TESTS_DIR', dirname(__FILE__) . '/');
+define('TESTS_DIR', __DIR__ . '/');
if (@is_dir(TESTS_DIR . 'config')) {
define('RCUBE_CONFIG_DIR', TESTS_DIR . 'config');
}
require_once(INSTALL_PATH . 'program/include/iniset.php');
// Extend include path so some plugin test won't fail
$include_path = ini_get('include_path') . PATH_SEPARATOR . TESTS_DIR . '..';
if (set_include_path($include_path) === false) {
die("Fatal error: ini_set/set_include_path does not work.");
}
$rcmail = rcmail::get_instance('test');
define('TESTS_URL', $rcmail->config->get('tests_url'));
define('TESTS_BROWSER', $rcmail->config->get('tests_browser', 'firefox'));
define('TESTS_USER', $rcmail->config->get('tests_username'));
define('TESTS_PASS', $rcmail->config->get('tests_password'));
define('TESTS_SLEEP', $rcmail->config->get('tests_sleep', 5));
PHPUnit_Extensions_Selenium2TestCase::shareSession(true);
/**
* satisfy PHPUnit
*/
class bootstrap
{
/**
* Wipe and re-initialize (mysql) database
*/
public static function init_db()
{
$rcmail = rcmail::get_instance();
// drop all existing tables first
$db = $rcmail->get_dbh();
$db->query("SET FOREIGN_KEY_CHECKS=0");
$sql_res = $db->query("SHOW TABLES");
while ($sql_arr = $db->fetch_array($sql_res)) {
$table = reset($sql_arr);
$db->query("DROP TABLE $table");
}
// init database with schema
$dsn = parse_url($rcmail->config->get('db_dsnw'));
$db_name = trim($dsn['path'], '/');
if ($dsn['scheme'] == 'mysql' || $dsn['scheme'] == 'mysqli') {
system(sprintf('cat %s %s | mysql -h %s -u %s --password=%s %s',
realpath(INSTALL_PATH . '/SQL/mysql.initial.sql'),
realpath(TESTS_DIR . '/Selenium/data/mysql.sql'),
escapeshellarg($dsn['host']),
escapeshellarg($dsn['user']),
escapeshellarg($dsn['pass']),
escapeshellarg($db_name)
));
}
}
/**
* Wipe the configured IMAP account and fill with test data
*/
public static function init_imap()
{
if (!TESTS_USER)
return false;
// TBD.
}
}
// @TODO: make sure mailbox has some content (always the same) or is empty
// @TODO: plugins: enable all?
/**
* Base class for all tests in this directory
*/
class Selenium_Test extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser(TESTS_BROWSER);
// Set root to our index.html, for better performance
// See https://github.com/sebastianbergmann/phpunit-selenium/issues/217
$baseurl = preg_replace('!/index(-.+)?\.php^!', '', TESTS_URL);
$this->setBrowserUrl($baseurl . '/tests/Selenium');
}
protected function login()
{
$this->go('mail');
$user_input = $this->byCssSelector('form input[name="_user"]');
$pass_input = $this->byCssSelector('form input[name="_pass"]');
$submit = $this->byCssSelector('form input[type="submit"]');
$user_input->value(TESTS_USER);
$pass_input->value(TESTS_PASS);
// submit login form
$submit->click();
// wait after successful login
sleep(TESTS_SLEEP);
}
protected function go($task = 'mail', $action = null)
{
$this->url(TESTS_URL . '?_task=' . $task);
// wait for interface load (initial ajax requests, etc.)
sleep(TESTS_SLEEP);
if ($action) {
$this->click_button($action);
sleep(TESTS_SLEEP);
}
}
protected function get_env()
{
return $this->execute(array(
'script' => 'return rcmail.env;',
'args' => array(),
));
}
protected function get_buttons($action)
{
$buttons = $this->execute(array(
'script' => "return rcmail.buttons['$action'];",
'args' => array(),
));
if (is_array($buttons)) {
foreach ($buttons as $idx => $button) {
$buttons[$idx] = $button['id'];
}
}
return (array) $buttons;
}
protected function get_objects()
{
return $this->execute(array(
'script' => "var i,r = []; for (i in rcmail.gui_objects) r.push(i); return r;",
'args' => array(),
));
}
protected function click_button($action)
{
$buttons = $this->get_buttons($action);
$id = array_shift($buttons);
// this doesn't work for me
$this->byId($id)->click();
}
protected function ajaxResponse($action, $script = '', $button = false)
{
if (!$script && !$button) {
$script = "rcmail.command('$action')";
}
$script =
"if (!window.test_ajax_response) {
window.test_ajax_response_object = {};
function test_ajax_response(response)
{
if (response.response && response.response.action) {
window.test_ajax_response_object[response.response.action] = response.response;
}
}
rcmail.addEventListener('responsebefore', test_ajax_response);
}
window.test_ajax_response_object['$action'] = null;
$script;
";
// run request
$this->execute(array(
'script' => $script,
'args' => array(),
));
if ($button) {
$this->click_button($action);
}
// wait
sleep(TESTS_SLEEP);
// get response
$response = $this->execute(array(
'script' => "return window.test_ajax_response_object['$action'];",
'args' => array(),
));
return $response;
}
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 192997d0d..bf7199c1e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,41 +1,41 @@
<?php
/*
+-----------------------------------------------------------------------+
| tests/bootstrap.php |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2009-2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Environment initialization script for unit tests |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
if (php_sapi_name() != 'cli')
die("Not in shell mode (php-cli)");
-if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
-define('TESTS_DIR', dirname(__FILE__) . '/');
+define('TESTS_DIR', __DIR__ . '/');
if (@is_dir(TESTS_DIR . 'config')) {
define('RCUBE_CONFIG_DIR', TESTS_DIR . 'config');
}
require_once(INSTALL_PATH . 'program/include/iniset.php');
rcmail::get_instance('test')->config->set('devel_mode', false);
// Extend include path so some plugin test won't fail
$include_path = ini_get('include_path') . PATH_SEPARATOR . TESTS_DIR . '..';
if (set_include_path($include_path) === false) {
die("Fatal error: ini_set/set_include_path does not work.");
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Aug 17, 1:05 PM (23 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1256859
Default Alt Text
(133 KB)

Event Timeline