CS fixes, tabs to spaces

pull/6806/head
Aleksander Machniak 6 years ago
parent f7b4ce0412
commit 8e63309203

@ -27,5 +27,3 @@ else
$days = 7; $days = 7;
rcmail_utils::db_clean($days); rcmail_utils::db_clean($days);
?>

@ -5,42 +5,42 @@ VERSION='2.4.8'
COMPILER_URL="https://github.com/yui/yuicompressor/releases/download/v${VERSION}/yuicompressor-${VERSION}.zip" COMPILER_URL="https://github.com/yui/yuicompressor/releases/download/v${VERSION}/yuicompressor-${VERSION}.zip"
do_shrink() { do_shrink() {
rm -f "$2" rm -f "$2"
java -jar $JAR_DIR/yuicompressor.jar -v -o "$2" "$1" java -jar $JAR_DIR/yuicompressor.jar -v -o "$2" "$1"
} }
if [ ! -w "$JAR_DIR" ]; then if [ ! -w "$JAR_DIR" ]; then
JAR_DIR=$PWD JAR_DIR=$PWD
fi fi
if java -version >/dev/null 2>&1; then if java -version >/dev/null 2>&1; then
: :
else else
echo "Java not found. Please ensure that the 'java' program is in your PATH." echo "Java not found. Please ensure that the 'java' program is in your PATH."
exit 1 exit 1
fi fi
if [ ! -r "$JAR_DIR/yuicompressor.jar" ]; then if [ ! -r "$JAR_DIR/yuicompressor.jar" ]; then
if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
wget "$COMPILER_URL" -O "/tmp/$$.zip" wget "$COMPILER_URL" -O "/tmp/$$.zip"
elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
curl -L "$COMPILER_URL" -o "/tmp/$$.zip" curl -L "$COMPILER_URL" -o "/tmp/$$.zip"
else else
echo "Please download $COMPILER_URL and extract compiler.jar to $JAR_DIR/." echo "Please download $COMPILER_URL and extract compiler.jar to $JAR_DIR/."
exit 1 exit 1
fi fi
(cd $JAR_DIR && unzip "/tmp/$$.zip" && mv "yuicompressor-${VERSION}.jar" "yuicompressor.jar") (cd $JAR_DIR && unzip "/tmp/$$.zip" && mv "yuicompressor-${VERSION}.jar" "yuicompressor.jar")
rm -f "/tmp/$$.zip" rm -f "/tmp/$$.zip"
fi fi
# compress single file from argument # compress single file from argument
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
CSS_FILE="$1" CSS_FILE="$1"
echo "Shrinking $CSS_FILE" echo "Shrinking $CSS_FILE"
minfile=`echo $CSS_FILE | sed -e 's/\.css$/\.min\.css/'` minfile=`echo $CSS_FILE | sed -e 's/\.css$/\.min\.css/'`
do_shrink "$CSS_FILE" "$minfile" do_shrink "$CSS_FILE" "$minfile"
exit exit
fi fi
DIRS="$PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/*" DIRS="$PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/*"

@ -55,11 +55,11 @@ define('INSTALL_PATH', realpath(__DIR__ .'/..') . '/');
require INSTALL_PATH . 'program/include/clisetup.php'; require INSTALL_PATH . 'program/include/clisetup.php';
if ($argc < 2) { if ($argc < 2) {
die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n"); die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
} }
$RCMAIL = rcube::get_instance(); $RCMAIL = rcube::get_instance();
for ($i = 1; $i < $argc; $i++) { for ($i = 1; $i < $argc; $i++) {
printf("%s\n", $RCMAIL->decrypt($argv[$i])); printf("%s\n", $RCMAIL->decrypt($argv[$i]));
}; };

@ -24,5 +24,3 @@ require_once INSTALL_PATH.'program/include/clisetup.php';
ini_set('memory_limit', -1); ini_set('memory_limit', -1);
rcmail_utils::indexcontacts(); rcmail_utils::indexcontacts();
?>

@ -37,5 +37,3 @@ if (!file_exists($opts['dir'])) {
} }
rcmail_utils::db_init($opts['dir']); rcmail_utils::db_init($opts['dir']);
?>

@ -136,5 +136,3 @@ if (strtolower($input) == 'y') {
else { else {
echo "Update cancelled. See ya!\n"; echo "Update cancelled. See ya!\n";
} }
?>

@ -6,54 +6,54 @@ LANG_IN='ECMASCRIPT5'
CLOSURE_COMPILER_URL='http://dl.google.com/closure-compiler/compiler-latest.zip' CLOSURE_COMPILER_URL='http://dl.google.com/closure-compiler/compiler-latest.zip'
do_shrink() { do_shrink() {
rm -f "$2" rm -f "$2"
# copy the first comment block with license information for LibreJS # copy the first comment block with license information for LibreJS
grep -q '@lic' $1 && sed -n '/\/\*/,/\*\// { p; /\*\//q; }' $1 > $2 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 java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --language_in="$3" >> $2
} }
if [ ! -d "$JS_DIR" ]; then if [ ! -d "$JS_DIR" ]; then
echo "Directory $JS_DIR not found." echo "Directory $JS_DIR not found."
exit 1 exit 1
fi fi
if [ ! -w "$JAR_DIR" ]; then if [ ! -w "$JAR_DIR" ]; then
JAR_DIR=$PWD JAR_DIR=$PWD
fi fi
if java -version >/dev/null 2>&1; then if java -version >/dev/null 2>&1; then
: :
else else
echo "Java not found. Please ensure that the 'java' program is in your PATH." echo "Java not found. Please ensure that the 'java' program is in your PATH."
exit 1 exit 1
fi fi
if [ ! -r "$JAR_DIR/compiler.jar" ]; then if [ ! -r "$JAR_DIR/compiler.jar" ]; then
if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
wget "$CLOSURE_COMPILER_URL" -O "/tmp/$$.zip" wget "$CLOSURE_COMPILER_URL" -O "/tmp/$$.zip"
elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
curl "$CLOSURE_COMPILER_URL" -o "/tmp/$$.zip" curl "$CLOSURE_COMPILER_URL" -o "/tmp/$$.zip"
else else
echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/." echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/."
exit 1 exit 1
fi fi
unzip -p "/tmp/$$.zip" "*.jar" > "$JAR_DIR/compiler.jar" unzip -p "/tmp/$$.zip" "*.jar" > "$JAR_DIR/compiler.jar"
rm -f "/tmp/$$.zip" rm -f "/tmp/$$.zip"
fi fi
# compress single file from argument # compress single file from argument
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
JS_DIR=`dirname "$1"` JS_DIR=`dirname "$1"`
JS_FILE="$1" JS_FILE="$1"
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
LANG_IN="$2" LANG_IN="$2"
fi fi
echo "Shrinking $JS_FILE" echo "Shrinking $JS_FILE"
minfile=`echo $JS_FILE | sed -e 's/\.js$/\.min\.js/'` minfile=`echo $JS_FILE | sed -e 's/\.js$/\.min\.js/'`
do_shrink "$JS_FILE" "$minfile" "$LANG_IN" do_shrink "$JS_FILE" "$minfile" "$LANG_IN"
exit exit
fi fi
DIRS="$PWD/../program/js $PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/* $PWD/../plugins/managesieve/codemirror/lib" DIRS="$PWD/../program/js $PWD/../skins/* $PWD/../plugins/* $PWD/../plugins/*/skins/* $PWD/../plugins/managesieve/codemirror/lib"

@ -19,6 +19,5 @@ OUTPUTFORMAT=HTML
TEMPLATE=responsive-twig TEMPLATE=responsive-twig
# make documentation # make documentation
$BIN_PHPDOC -d $PATH_PROJECT,$PATH_FRAMEWORK -t $PATH_DOCS --title "$TITLE" --defaultpackagename $PACKAGES \ $BIN_PHPDOC -d $PATH_PROJECT,$PATH_FRAMEWORK -t $PATH_DOCS --title "$TITLE" \
--template=$TEMPLATE --defaultpackagename $PACKAGES --template=$TEMPLATE

@ -63,5 +63,3 @@ if ($args['config']) {
} }
rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']); rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']);
?>

@ -21,89 +21,84 @@ require_once INSTALL_PATH.'program/include/clisetup.php';
function print_usage() function print_usage()
{ {
print "Usage: msgexport -h imap-host -u user-name -m mailbox name\n"; print "Usage: msgexport -h imap-host -u user-name -m mailbox name\n";
print "--host IMAP host\n"; print "--host IMAP host\n";
print "--user IMAP user name\n"; print "--user IMAP user name\n";
print "--mbox Folder name, set to '*' for all\n"; print "--mbox Folder name, set to '*' for all\n";
print "--file Output file\n"; print "--file Output file\n";
} }
function vputs($str) function vputs($str)
{ {
$out = $GLOBALS['args']['file'] ? STDOUT : STDERR; $out = $GLOBALS['args']['file'] ? STDOUT : STDERR;
fwrite($out, $str); fwrite($out, $str);
} }
function progress_update($pos, $max) function progress_update($pos, $max)
{ {
$percent = round(100 * $pos / $max); $percent = round(100 * $pos / $max);
vputs(sprintf("%3d%% [%-51s] %d/%d\033[K\r", $percent, @str_repeat('=', $percent / 2) . '>', $pos, $max)); vputs(sprintf("%3d%% [%-51s] %d/%d\033[K\r", $percent, @str_repeat('=', $percent / 2) . '>', $pos, $max));
} }
function export_mailbox($mbox, $filename) function export_mailbox($mbox, $filename)
{ {
global $IMAP; global $IMAP;
$IMAP->set_folder($mbox); $IMAP->set_folder($mbox);
$index = $IMAP->index($mbox, null, 'ASC'); $index = $IMAP->index($mbox, null, 'ASC');
$count = $index->count(); $count = $index->count();
$index = $index->get(); $index = $index->get();
vputs("Getting message list of {$mbox}..."); vputs("Getting message list of {$mbox}...");
vputs("$count messages\n"); vputs("$count messages\n");
if ($filename) if ($filename) {
{ if (!($out = fopen($filename, 'w'))) {
if (!($out = fopen($filename, 'w'))) vputs("Cannot write to output file\n");
{ return;
vputs("Cannot write to output file\n"); }
return; vputs("Writing to $filename\n");
} }
vputs("Writing to $filename\n"); else {
} $out = STDOUT;
else }
$out = STDOUT;
for ($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; $i++) $headers = $IMAP->get_message_headers($index[$i]);
{ $from = current(rcube_mime::decode_address_list($headers->from, 1, false));
$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, sprintf("From %s %s UID %d\n", $from['mailto'], $headers->date, $headers->uid)); fwrite($out, "\n\n\n");
$IMAP->get_raw_body($headers->uid, $out);
fwrite($out, "\n\n\n"); progress_update($i+1, $count);
}
progress_update($i+1, $count); vputs("\ncomplete.\n");
}
vputs("\ncomplete.\n"); if ($filename) {
fclose($out);
if ($filename) }
fclose($out);
} }
// get arguments // get arguments
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file'); $opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX'); $args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
if ($_SERVER['argv'][1] == 'help') if ($_SERVER['argv'][1] == 'help') {
{ print_usage();
print_usage(); exit;
exit;
} }
else if (!$args['host']) else if (!$args['host']) {
{ vputs("Missing required parameters.\n");
vputs("Missing required parameters.\n"); print_usage();
print_usage(); exit;
exit;
} }
// prompt for username if not set // prompt for username if not set
if (empty($args['user'])) if (empty($args['user'])) {
{ vputs("IMAP user: ");
vputs("IMAP user: "); $args['user'] = trim(fgets(STDIN));
$args['user'] = trim(fgets(STDIN));
} }
// prompt for password // prompt for password
@ -112,45 +107,39 @@ $args['pass'] = rcube_utils::prompt_silent("Password: ");
// parse $host URL // parse $host URL
$a_host = parse_url($args['host']); $a_host = parse_url($args['host']);
if ($a_host['host']) if ($a_host['host']) {
{ $host = $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_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);
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
} }
else else {
{ $host = $args['host'];
$host = $args['host']; $imap_port = 143;
$imap_port = 143;
} }
// instantiate IMAP class // instantiate IMAP class
$IMAP = new rcube_imap(null); $IMAP = new rcube_imap(null);
// try to connect to IMAP server // try to connect to IMAP server
if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) {
{ vputs("IMAP login successful.\n");
vputs("IMAP login successful.\n");
$filename = null; $filename = null;
$mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : array($args['mbox']); $mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : array($args['mbox']);
foreach ($mailboxes as $mbox) foreach ($mailboxes as $mbox) {
{ if ($args['file'])
if ($args['file']) $filename = preg_replace('/\.[a-z0-9]{3,4}$/i', '', $args['file']) . asciiwords($mbox) . '.mbox';
$filename = preg_replace('/\.[a-z0-9]{3,4}$/i', '', $args['file']) . asciiwords($mbox) . '.mbox'; else if ($args['mbox'] == '*')
else if ($args['mbox'] == '*') $filename = asciiwords($mbox) . '.mbox';
$filename = asciiwords($mbox) . '.mbox';
if ($args['mbox'] == '*' && in_array(strtolower($mbox), array('junk','spam','trash'))) if ($args['mbox'] == '*' && in_array(strtolower($mbox), array('junk','spam','trash'))) {
continue; continue;
}
export_mailbox($mbox, $filename); export_mailbox($mbox, $filename);
} }
} }
else else {
{ vputs("IMAP login failed.\n");
vputs("IMAP login failed.\n");
} }
?>

@ -21,11 +21,11 @@ require_once INSTALL_PATH.'program/include/clisetup.php';
function print_usage() function print_usage()
{ {
print "Usage: msgimport -h imap-host -u user-name -m mailbox -f message-file\n"; print "Usage: msgimport -h imap-host -u user-name -m mailbox -f message-file\n";
print "--host IMAP host\n"; print "--host IMAP host\n";
print "--user IMAP user name\n"; print "--user IMAP user name\n";
print "--mbox Target mailbox\n"; print "--mbox Target mailbox\n";
print "--file Message file to upload\n"; print "--file Message file to upload\n";
} }
@ -33,94 +33,80 @@ function print_usage()
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file'); $opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX'); $args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
if ($_SERVER['argv'][1] == 'help') if ($_SERVER['argv'][1] == 'help') {
{ print_usage();
print_usage(); exit;
exit;
} }
else if (!($args['host'] && $args['file'])) else if (!($args['host'] && $args['file'])) {
{ print "Missing required parameters.\n";
print "Missing required parameters.\n"; print_usage();
print_usage(); exit;
exit;
} }
else if (!is_file($args['file'])) else if (!is_file($args['file'])) {
{ rcube::raise_error("Cannot read message file.", false, true);
rcube::raise_error("Cannot read message file.", false, true);
} }
// prompt for username if not set // prompt for username if not set
if (empty($args['user'])) if (empty($args['user'])) {
{ //fwrite(STDOUT, "Please enter your name\n");
//fwrite(STDOUT, "Please enter your name\n"); echo "IMAP user: ";
echo "IMAP user: "; $args['user'] = trim(fgets(STDIN));
$args['user'] = trim(fgets(STDIN));
} }
// prompt for password // prompt for password
if (empty($args['pass'])) if (empty($args['pass'])) {
{ $args['pass'] = rcube_utils::prompt_silent("Password: ");
$args['pass'] = rcube_utils::prompt_silent("Password: ");
} }
// parse $host URL // parse $host URL
$a_host = parse_url($args['host']); $a_host = parse_url($args['host']);
if ($a_host['host']) if ($a_host['host']) {
{ $host = $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_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);
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
} }
else else {
{ $host = $args['host'];
$host = $args['host']; $imap_port = 143;
$imap_port = 143;
} }
// instantiate IMAP class // instantiate IMAP class
$IMAP = new rcube_imap(null); $IMAP = new rcube_imap(null);
// try to connect to IMAP server // try to connect to IMAP server
if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) {
{ print "IMAP login successful.\n";
print "IMAP login successful.\n"; print "Uploading messages...\n";
print "Uploading messages...\n";
$count = 0;
$count = 0; $message = $lastline = '';
$message = $lastline = '';
$fp = fopen($args['file'], 'r');
$fp = fopen($args['file'], 'r'); while (($line = fgets($fp)) !== false) {
while (($line = fgets($fp)) !== false) if (preg_match('/^From\s+-/', $line) && $lastline == '') {
{ if (!empty($message)) {
if (preg_match('/^From\s+-/', $line) && $lastline == '') if ($IMAP->save_message($args['mbox'], rtrim($message)))
{ $count++;
if (!empty($message)) else
{ rcube::raise_error("Failed to save message to {$args['mbox']}", false, true);
if ($IMAP->save_message($args['mbox'], rtrim($message))) $message = '';
$count++; }
else continue;
rcube::raise_error("Failed to save message to {$args['mbox']}", false, true); }
$message = '';
} $message .= $line;
continue; $lastline = rtrim($line);
} }
$message .= $line; if (!empty($message) && $IMAP->save_message($args['mbox'], rtrim($message)))
$lastline = rtrim($line); $count++;
}
// upload message from file
if (!empty($message) && $IMAP->save_message($args['mbox'], rtrim($message))) if ($count)
$count++; print "$count messages successfully added to {$args['mbox']}.\n";
else
// upload message from file print "Adding messages failed!\n";
if ($count)
print "$count messages successfully added to {$args['mbox']}.\n";
else
print "Adding messages failed!\n";
} }
else else {
{ rcube::raise_error("IMAP login failed.", false, true);
rcube::raise_error("IMAP login failed.", false, true);
} }
?>

@ -104,4 +104,3 @@ Please download it from http://getcomposer.org/download/ or with
} }
echo "\n"; echo "\n";

@ -271,5 +271,3 @@ else {
echo "This instance of Roundcube is not yet configured!\n"; 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"; echo "Open http://url-to-roundcube/installer/ in your browser and follow the instuctions.\n";
} }
?>

@ -117,5 +117,3 @@ function get_files($dir)
return $files; return $files;
} }
?>

@ -37,5 +37,3 @@ if (empty($opts['package'])) {
} }
rcmail_utils::db_update($opts['dir'], $opts['package'], $opts['version'], array('errors' => true)); rcmail_utils::db_update($opts['dir'], $opts['package'], $opts['version'], array('errors' => true));
?>

Loading…
Cancel
Save