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);
?>

@ -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";
} }
?>

@ -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']);
?>

@ -53,20 +53,18 @@ function export_mailbox($mbox, $filename)
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"); vputs("Cannot write to output file\n");
return; return;
} }
vputs("Writing to $filename\n"); vputs("Writing to $filename\n");
} }
else else {
$out = STDOUT; $out = STDOUT;
}
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++) {
{
$headers = $IMAP->get_message_headers($index[$i]); $headers = $IMAP->get_message_headers($index[$i]);
$from = current(rcube_mime::decode_address_list($headers->from, 1, false)); $from = current(rcube_mime::decode_address_list($headers->from, 1, false));
@ -78,30 +76,27 @@ function export_mailbox($mbox, $filename)
} }
vputs("\ncomplete.\n"); vputs("\ncomplete.\n");
if ($filename) if ($filename) {
fclose($out); 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));
} }
@ -112,14 +107,12 @@ $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;
} }
@ -128,29 +121,25 @@ else
$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");
} }
?>

@ -33,46 +33,39 @@ 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;
} }
@ -81,8 +74,7 @@ else
$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";
@ -90,12 +82,9 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
$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 (preg_match('/^From\s+-/', $line) && $lastline == '') if (!empty($message)) {
{
if (!empty($message))
{
if ($IMAP->save_message($args['mbox'], rtrim($message))) if ($IMAP->save_message($args['mbox'], rtrim($message)))
$count++; $count++;
else else
@ -118,9 +107,6 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
else else
print "Adding messages failed!\n"; 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