Show spam aliases #
This commit is contained in:
33
data/web/rc/bin/cleandb.sh
Executable file
33
data/web/rc/bin/cleandb.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| bin/cleandb.sh |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2010-2015, 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(__DIR__ . '/..') . '/' );
|
||||
|
||||
require INSTALL_PATH.'program/include/clisetup.php';
|
||||
|
||||
if (!empty($_SERVER['argv'][1]))
|
||||
$days = intval($_SERVER['argv'][1]);
|
||||
else
|
||||
$days = 7;
|
||||
|
||||
rcmail_utils::db_clean($days);
|
||||
|
||||
?>
|
62
data/web/rc/bin/cssshrink.sh
Executable file
62
data/web/rc/bin/cssshrink.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
PWD=`dirname "$0"`
|
||||
JAR_DIR='/tmp'
|
||||
VERSION='2.4.8'
|
||||
COMPILER_URL="https://github.com/yui/yuicompressor/releases/download/v${VERSION}/yuicompressor-${VERSION}.zip"
|
||||
|
||||
do_shrink() {
|
||||
rm -f "$2"
|
||||
java -jar $JAR_DIR/yuicompressor.jar -v -o "$2" "$1"
|
||||
}
|
||||
|
||||
if [ ! -w "$JAR_DIR" ]; then
|
||||
JAR_DIR=$PWD
|
||||
fi
|
||||
|
||||
if java -version >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
echo "Java not found. Please ensure that the 'java' program is in your PATH."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -r "$JAR_DIR/yuicompressor.jar" ]; then
|
||||
if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
|
||||
wget "$COMPILER_URL" -O "/tmp/$$.zip"
|
||||
elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
|
||||
curl "$COMPILER_URL" -o "/tmp/$$.zip"
|
||||
else
|
||||
echo "Please download $COMPILER_URL and extract compiler.jar to $JAR_DIR/."
|
||||
exit 1
|
||||
fi
|
||||
(cd $JAR_DIR && unzip "/tmp/$$.zip" && mv "yuicompressor-${VERSION}.jar" "yuicompressor.jar")
|
||||
rm -f "/tmp/$$.zip"
|
||||
fi
|
||||
|
||||
# compress single file from argument
|
||||
if [ $# -gt 0 ]; then
|
||||
CSS_FILE="$1"
|
||||
|
||||
echo "Shrinking $CSS_FILE"
|
||||
minfile=`echo $CSS_FILE | sed -e 's/\.css$/\.min\.css/'`
|
||||
do_shrink "$CSS_FILE" "$minfile"
|
||||
exit
|
||||
fi
|
||||
|
||||
DIRS="$PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/*"
|
||||
# default: compress application scripts
|
||||
for dir in $DIRS; do
|
||||
for file in $dir/*.css; do
|
||||
echo "$file" | grep -e '.min.css$' >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
continue
|
||||
fi
|
||||
if [ ! -f "$file" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Shrinking $file"
|
||||
minfile=`echo $file | sed -e 's/\.css$/\.min\.css/'`
|
||||
do_shrink "$file" "$minfile"
|
||||
done
|
||||
done
|
67
data/web/rc/bin/decrypt.sh
Executable file
67
data/web/rc/bin/decrypt.sh
Executable file
@@ -0,0 +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(__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]));
|
||||
};
|
125
data/web/rc/bin/deluser.sh
Executable file
125
data/web/rc/bin/deluser.sh
Executable file
@@ -0,0 +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(__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 = rcube::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";
|
||||
}
|
||||
}
|
||||
|
97
data/web/rc/bin/dumpschema.sh
Executable file
97
data/web/rc/bin/dumpschema.sh
Executable file
@@ -0,0 +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(__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);
|
||||
|
||||
?>
|
39
data/web/rc/bin/gc.sh
Executable file
39
data/web/rc/bin/gc.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/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(__DIR__ . '/..') . '/' );
|
||||
|
||||
require INSTALL_PATH.'program/include/clisetup.php';
|
||||
|
||||
$rcmail = rcube::get_instance();
|
||||
|
||||
$session_driver = $rcmail->config->get('session_storage', 'db');
|
||||
$session_lifetime = $rcmail->config->get('session_lifetime', 0) * 60 * 2;
|
||||
|
||||
// Clean expired SQL sessions
|
||||
if ($session_driver == 'db' && $session_lifetime) {
|
||||
$db = $rcmail->get_dbh();
|
||||
$db->query("DELETE FROM " . $db->table_name('session')
|
||||
. " WHERE changed < " . $db->now(-$session_lifetime));
|
||||
}
|
||||
|
||||
// Clean caches and temp directory
|
||||
$rcmail->gc();
|
29
data/web/rc/bin/indexcontacts.sh
Executable file
29
data/web/rc/bin/indexcontacts.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/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(__DIR__ . '/..') . '/' );
|
||||
|
||||
require_once INSTALL_PATH.'program/include/clisetup.php';
|
||||
ini_set('memory_limit', -1);
|
||||
|
||||
rcmail_utils::indexcontacts();
|
||||
|
||||
?>
|
42
data/web/rc/bin/initdb.sh
Executable file
42
data/web/rc/bin/initdb.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| bin/initdb.sh |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2010-2015, The Roundcube Dev Team |
|
||||
| Copyright (C) 2010-2015, 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: |
|
||||
| Create database schema |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
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'])) {
|
||||
rcube::raise_error("Database schema directory not specified (--dir).", false, true);
|
||||
}
|
||||
|
||||
// Check if directory exists
|
||||
if (!file_exists($opts['dir'])) {
|
||||
rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
|
||||
}
|
||||
|
||||
rcmail_utils::db_init($opts['dir']);
|
||||
|
||||
?>
|
106
data/web/rc/bin/installto.sh
Executable file
106
data/web/rc/bin/installto.sh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| bin/installto.sh |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2014-2016, 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(__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') {
|
||||
echo "Copying files to target location...";
|
||||
|
||||
// Save a copy of original .htaccess file (#1490623)
|
||||
if (file_exists("$target_dir/.htaccess")) {
|
||||
$htaccess_copied = copy("$target_dir/.htaccess", "$target_dir/.htaccess.orig");
|
||||
}
|
||||
|
||||
$dirs = array('program','installer','bin','SQL','plugins','skins');
|
||||
if (is_dir(INSTALL_PATH . 'vendor') && !is_file(INSTALL_PATH . 'composer.json')) {
|
||||
$dirs[] = 'vendor';
|
||||
}
|
||||
foreach ($dirs as $dir) {
|
||||
// @FIXME: should we use --delete for all directories?
|
||||
$delete = in_array($dir, array('program', 'installer')) ? '--delete ' : '';
|
||||
$command = "rsync -aC --out-format \"%n\" " . $delete . INSTALL_PATH . "$dir/* $target_dir/$dir/";
|
||||
if (!system($command, $ret) || $ret > 0) {
|
||||
rcube::raise_error("Failed to execute command: $command", false, true);
|
||||
}
|
||||
}
|
||||
foreach (array('index.php','.htaccess','config/defaults.inc.php','composer.json-dist','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL') as $file) {
|
||||
$command = "rsync -a --out-format \"%n\" " . INSTALL_PATH . "$file $target_dir/$file";
|
||||
if (file_exists(INSTALL_PATH . $file) && (!system($command, $ret) || $ret > 0)) {
|
||||
rcube::raise_error("Failed to execute command: $command", false, true);
|
||||
}
|
||||
}
|
||||
|
||||
// remove old (<1.0) .htaccess file
|
||||
@unlink("$target_dir/program/.htaccess");
|
||||
echo "done.";
|
||||
|
||||
// Inform the user about .htaccess change
|
||||
if (!empty($htaccess_copied)) {
|
||||
if (file_get_contents("$target_dir/.htaccess") != file_get_contents("$target_dir/.htaccess.orig")) {
|
||||
echo "\n!! Old .htaccess file saved as .htaccess.orig !!";
|
||||
}
|
||||
else {
|
||||
@unlink("$target_dir/.htaccess.orig");
|
||||
}
|
||||
}
|
||||
|
||||
echo "\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";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
?>
|
75
data/web/rc/bin/jsshrink.sh
Executable file
75
data/web/rc/bin/jsshrink.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
PWD=`dirname "$0"`
|
||||
JS_DIR="$PWD/../program/js"
|
||||
JAR_DIR='/tmp'
|
||||
LANG_IN='ECMASCRIPT5'
|
||||
CLOSURE_COMPILER_URL='http://dl.google.com/closure-compiler/compiler-latest.zip'
|
||||
|
||||
do_shrink() {
|
||||
rm -f "$2"
|
||||
# copy the first comment block with license information for LibreJS
|
||||
grep -q '@lic' $1 && sed -n '/\/\*/,/\*\// { p; /\*\//q; }' $1 > $2
|
||||
java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --language_in="$3" >> $2
|
||||
}
|
||||
|
||||
if [ ! -d "$JS_DIR" ]; then
|
||||
echo "Directory $JS_DIR not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w "$JAR_DIR" ]; then
|
||||
JAR_DIR=$PWD
|
||||
fi
|
||||
|
||||
if java -version >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
echo "Java not found. Please ensure that the 'java' program is in your PATH."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -r "$JAR_DIR/compiler.jar" ]; then
|
||||
if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
|
||||
wget "$CLOSURE_COMPILER_URL" -O "/tmp/$$.zip"
|
||||
elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
|
||||
curl "$CLOSURE_COMPILER_URL" -o "/tmp/$$.zip"
|
||||
else
|
||||
echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/."
|
||||
exit 1
|
||||
fi
|
||||
(cd $JAR_DIR && unzip -p "/tmp/$$.zip" "*.jar" > "$JAR_DIR/compiler.jar")
|
||||
rm -f "/tmp/$$.zip"
|
||||
fi
|
||||
|
||||
# compress single file from argument
|
||||
if [ $# -gt 0 ]; then
|
||||
JS_DIR=`dirname "$1"`
|
||||
JS_FILE="$1"
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
LANG_IN="$2"
|
||||
fi
|
||||
|
||||
echo "Shrinking $JS_FILE"
|
||||
minfile=`echo $JS_FILE | sed -e 's/\.js$/\.min\.js/'`
|
||||
do_shrink "$JS_FILE" "$minfile" "$LANG_IN"
|
||||
exit
|
||||
fi
|
||||
|
||||
DIRS="$PWD/../program/js $PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/* $PWD/../plugins/managesieve/codemirror/lib"
|
||||
# default: compress application scripts
|
||||
for dir in $DIRS; do
|
||||
for file in $dir/*.js; do
|
||||
echo "$file" | grep -e '.min.js$' >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
continue
|
||||
fi
|
||||
if [ ! -f "$file" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Shrinking $file"
|
||||
minfile=`echo $file | sed -e 's/\.js$/\.min\.js/'`
|
||||
do_shrink "$file" "$minfile" "$LANG_IN"
|
||||
done
|
||||
done
|
24
data/web/rc/bin/makedoc.sh
Executable file
24
data/web/rc/bin/makedoc.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
TITLE="Roundcube Webmail"
|
||||
PACKAGES="Webmail"
|
||||
|
||||
INSTALL_PATH="`dirname $0`/.."
|
||||
PATH_PROJECT=$INSTALL_PATH/program/include
|
||||
PATH_FRAMEWORK=$INSTALL_PATH/program/lib/Roundcube
|
||||
PATH_DOCS=$INSTALL_PATH/doc/phpdoc
|
||||
BIN_PHPDOC="`/usr/bin/which phpdoc`"
|
||||
|
||||
if [ ! -x "$BIN_PHPDOC" ]
|
||||
then
|
||||
echo "phpdoc not found: $BIN_PHPDOC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTPUTFORMAT=HTML
|
||||
TEMPLATE=responsive-twig
|
||||
|
||||
# make documentation
|
||||
$BIN_PHPDOC -d $PATH_PROJECT,$PATH_FRAMEWORK -t $PATH_DOCS --title "$TITLE" --defaultpackagename $PACKAGES \
|
||||
--template=$TEMPLATE
|
||||
|
68
data/web/rc/bin/moduserprefs.sh
Executable file
68
data/web/rc/bin/moduserprefs.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| bin/moduserprefs.sh |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2012-2015, 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(__DIR__ . '/..') . '/' );
|
||||
|
||||
require_once INSTALL_PATH.'program/include/clisetup.php';
|
||||
|
||||
function print_usage()
|
||||
{
|
||||
print "Usage: moduserprefs.sh [options] pref-name [pref-value]\n";
|
||||
print "Options:\n";
|
||||
print " --user=user-id User ID in local database\n";
|
||||
print " --config=path Location of additional configuration file\n";
|
||||
print " --delete Unset the given preference\n";
|
||||
print " --type=type Pref-value type: int, bool, string\n";
|
||||
}
|
||||
|
||||
|
||||
// get arguments
|
||||
$args = rcube_utils::get_opt(array(
|
||||
'u' => 'user',
|
||||
'd' => 'delete:bool',
|
||||
't' => 'type',
|
||||
'c' => 'config',
|
||||
));
|
||||
|
||||
if ($_SERVER['argv'][1] == 'help') {
|
||||
print_usage();
|
||||
exit;
|
||||
}
|
||||
else if (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) {
|
||||
print "Missing required parameters.\n";
|
||||
print_usage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$pref_name = trim($args[0]);
|
||||
$pref_value = $args['delete'] ? null : trim($args[1]);
|
||||
|
||||
if ($pref_value === null) {
|
||||
$args['type'] = null;
|
||||
}
|
||||
|
||||
if ($args['config']) {
|
||||
$rcube = rcube::get_instance();
|
||||
$rcube->config->load_from_file($args['config']);
|
||||
}
|
||||
|
||||
rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']);
|
||||
|
||||
?>
|
143
data/web/rc/bin/msgexport.sh
Executable file
143
data/web/rc/bin/msgexport.sh
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
?>
|
113
data/web/rc/bin/msgimport.sh
Executable file
113
data/web/rc/bin/msgimport.sh
Executable file
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
?>
|
271
data/web/rc/bin/update.sh
Executable file
271
data/web/rc/bin/update.sh
Executable file
@@ -0,0 +1,271 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| bin/update.sh |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2010-2015, 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(__DIR__ . '/..') . '/' );
|
||||
|
||||
require_once INSTALL_PATH . 'program/include/clisetup.php';
|
||||
|
||||
// get arguments
|
||||
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept:bool'));
|
||||
|
||||
// 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";
|
||||
$success = rcmail_utils::db_update(INSTALL_PATH . 'SQL', 'roundcube', $opts['version'],
|
||||
array('errors' => true));
|
||||
}
|
||||
|
||||
// update composer dependencies
|
||||
if (is_file(INSTALL_PATH . 'composer.json') && is_readable(INSTALL_PATH . 'composer.json-dist')) {
|
||||
$composer_data = json_decode(file_get_contents(INSTALL_PATH . 'composer.json'), true);
|
||||
$composer_template = json_decode(file_get_contents(INSTALL_PATH . 'composer.json-dist'), true);
|
||||
$comsposer_json = null;
|
||||
|
||||
// update the require section with the new dependencies
|
||||
if (is_array($composer_data['require']) && is_array($composer_template['require'])) {
|
||||
$composer_data['require'] = array_merge($composer_data['require'], $composer_template['require']);
|
||||
|
||||
// remove obsolete packages
|
||||
$old_packages = array(
|
||||
'pear/mail_mime',
|
||||
'pear/mail_mime-decode',
|
||||
'pear/net_smtp',
|
||||
'pear/net_sieve',
|
||||
'pear-pear.php.net/net_sieve',
|
||||
);
|
||||
foreach ($old_packages as $pkg) {
|
||||
if (array_key_exists($pkg, $composer_data['require'])) {
|
||||
unset($composer_data['require'][$pkg]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the repositories section with the new dependencies
|
||||
if (is_array($composer_template['repositories'])) {
|
||||
if (!is_array($composer_data['repositories'])) {
|
||||
$composer_data['repositories'] = array();
|
||||
}
|
||||
|
||||
foreach ($composer_template['repositories'] as $repo) {
|
||||
$rkey = $repo['type'] . preg_replace('/^https?:/', '', $repo['url']) . $repo['package']['name'];
|
||||
$existing = false;
|
||||
foreach ($composer_data['repositories'] as $k => $_repo) {
|
||||
if ($rkey == $_repo['type'] . preg_replace('/^https?:/', '', $_repo['url']) . $_repo['package']['name']) {
|
||||
// switch to https://
|
||||
if (isset($_repo['url']) && strpos($_repo['url'], 'http://') === 0)
|
||||
$composer_data['repositories'][$k]['url'] = 'https:' . substr($_repo['url'], 5);
|
||||
$existing = true;
|
||||
break;
|
||||
}
|
||||
// remove old repos
|
||||
else if (strpos($_repo['url'], 'git://git.kolab.org') === 0) {
|
||||
unset($composer_data['repositories'][$k]);
|
||||
}
|
||||
else if ($_repo['type'] == 'package' && $_repo['package']['name'] == 'Net_SMTP') {
|
||||
unset($composer_data['repositories'][$k]);
|
||||
}
|
||||
}
|
||||
if (!$existing) {
|
||||
$composer_data['repositories'][] = $repo;
|
||||
}
|
||||
}
|
||||
|
||||
$composer_data['repositories'] = array_values($composer_data['repositories']);
|
||||
}
|
||||
|
||||
// use the JSON encoder from the Composer package
|
||||
if (is_file('composer.phar')) {
|
||||
include 'phar://composer.phar/src/Composer/Json/JsonFile.php';
|
||||
$comsposer_json = \Composer\Json\JsonFile::encode($composer_data);
|
||||
}
|
||||
// PHP 5.4's json_encode() does the job, too
|
||||
else if (defined('JSON_PRETTY_PRINT')) {
|
||||
$comsposer_json = json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
else {
|
||||
$success = false;
|
||||
$comsposer_json = null;
|
||||
}
|
||||
|
||||
// write updated composer.json back to disk
|
||||
if ($comsposer_json && is_writeable(INSTALL_PATH . 'composer.json')) {
|
||||
$success &= (bool)file_put_contents(INSTALL_PATH . 'composer.json', $comsposer_json);
|
||||
}
|
||||
else {
|
||||
echo "WARNING: unable to update composer.json!\n";
|
||||
echo "Please replace the 'require' section in your composer.json with the following:\n";
|
||||
|
||||
$require_json = '';
|
||||
foreach ($composer_data['require'] as $pkg => $ver) {
|
||||
$require_json .= sprintf(' "%s": "%s",'."\n", $pkg, $ver);
|
||||
}
|
||||
|
||||
echo ' "require": {'."\n";
|
||||
echo rtrim($require_json, ",\n");
|
||||
echo "\n }\n\n";
|
||||
}
|
||||
|
||||
echo "NOTE: Update dependencies by running `php composer.phar update --no-dev`\n";
|
||||
}
|
||||
|
||||
// index contacts for fulltext searching
|
||||
if ($opts['version'] && version_compare(version_parse($opts['version']), '0.6.0', '<')) {
|
||||
rcmail_utils::indexcontacts();
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
?>
|
122
data/web/rc/bin/updatecss.sh
Executable file
122
data/web/rc/bin/updatecss.sh
Executable file
@@ -0,0 +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(__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;
|
||||
}
|
||||
|
||||
?>
|
42
data/web/rc/bin/updatedb.sh
Executable file
42
data/web/rc/bin/updatedb.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/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(__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);
|
||||
}
|
||||
|
||||
rcmail_utils::db_update($opts['dir'], $opts['package'], $opts['version'], array('errors' => true));
|
||||
|
||||
?>
|
Reference in New Issue
Block a user