From dcc4469844f8ce98bd8323b684e40cf64643e5ae Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 10 Sep 2014 10:32:28 -0400
Subject: [PATCH] Don't init output in CLI mode

---
 bin/indexcontacts.sh       |    2 +-
 bin/decrypt.sh             |    2 +-
 bin/cleandb.sh             |    2 +-
 bin/moduserprefs.sh        |    2 +-
 program/include/rcmail.php |    8 +++++---
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/bin/cleandb.sh b/bin/cleandb.sh
index add0393..165d33f 100755
--- a/bin/cleandb.sh
+++ b/bin/cleandb.sh
@@ -30,7 +30,7 @@
 );
 
 // connect to DB
-$RCMAIL = rcmail::get_instance();
+$RCMAIL = rcube::get_instance();
 $db = $RCMAIL->get_dbh();
 $db->db_connect('w');
 
diff --git a/bin/decrypt.sh b/bin/decrypt.sh
index ff7c430..7f83f3a 100755
--- a/bin/decrypt.sh
+++ b/bin/decrypt.sh
@@ -60,7 +60,7 @@
 	die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
 }
 
-$RCMAIL = rcmail::get_instance();
+$RCMAIL = rcube::get_instance();
 
 for ($i = 1; $i < $argc; $i++) {
 	printf("%s\n", $RCMAIL->decrypt($argv[$i]));
diff --git a/bin/indexcontacts.sh b/bin/indexcontacts.sh
index c85a535..df40380 100755
--- a/bin/indexcontacts.sh
+++ b/bin/indexcontacts.sh
@@ -25,7 +25,7 @@
 ini_set('memory_limit', -1);
 
 // connect to DB
-$RCMAIL = rcmail::get_instance();
+$RCMAIL = rcube::get_instance();
 
 $db = $RCMAIL->get_dbh();
 $db->db_connect('w');
diff --git a/bin/moduserprefs.sh b/bin/moduserprefs.sh
index 9bbc885..8a9725f 100755
--- a/bin/moduserprefs.sh
+++ b/bin/moduserprefs.sh
@@ -47,7 +47,7 @@
 $pref_value = $args['delete'] ? null : trim($args[1]);
 
 // connect to DB
-$rcmail = rcmail::get_instance();
+$rcmail = rcube::get_instance();
 
 $db = $rcmail->get_dbh();
 $db->db_connect('w');
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index ece0606..e1a6276 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -116,11 +116,13 @@
             $_SESSION['task'] = $this->task;
         }
 
-        // init output class
-        if (!empty($_REQUEST['_remote']))
+        // init output class (not in CLI mode)
+        if (!empty($_REQUEST['_remote'])) {
             $GLOBALS['OUTPUT'] = $this->json_init();
-        else
+        }
+        else if ($_SERVER['REMOTE_ADDR']) {
             $GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
+        }
 
         // load plugins
         $this->plugins->init($this, $this->task);

--
Gitblit v1.9.1