require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Open Agora database. */
$db_agora = &DB::connect($conf['sql']);
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Open the database. */
$params = Horde::getDriverConfig('storage', 'sql');
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:f:',
array('help', 'username=', 'password=', 'fields='));
-$cli = Horde_Cli::singleton();
if (is_a($ret, 'PEAR_Error')) {
$cli->fatal($ret->getMessage());
}
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
// We accept the user name on the command-line.
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(),
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
// We accept the user name on the command-line.
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:lc:g:a:d:k',
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Command line options */
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:g:s:d:kr:zl',
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_CLI::singleton();
// First update the tables
$alter = array("ALTER TABLE ansel_images ADD COLUMN image_latitude VARCHAR(32) NOT NULL DEFAULT ''",
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$sql = 'SELECT image_id, image_original_date, image_uploaded_date FROM ansel_images';
$results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC);
require_once dirname(__FILE__) . '/../../Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$sql = 'SELECT image_id, image_latitude, image_longitude FROM ansel_images_geolocation;';
$results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC);
require_once dirname(__FILE__) . '/lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$sql = 'SELECT image_id, image_latitude, image_longitude FROM ansel_images_geolocation;';
$results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC);
}
// Load the CLI environment.
-Horde_CLI::init();
-$cli = &Horde_CLI::singleton();
+$cli = Horde_Cli::init();
// We accept the user name on the command-line.
require_once 'Console/Getopt.php';
}
// Load the CLI environment.
-Horde_Cli::init();
-$cli = &Horde_Cli::singleton();
+$cli = Horde_Cli::init();
$db = DB::connect($conf['sql']);
if ($db instanceof PEAR_Error) {
// Load the CLI environment - make sure there's no time limit, init some
// variables, etc.
-Horde_Cli::init();
-$cli = Horde_Cli::singleton();
+$cli = Horde_Cli::init();
$horde_authentication = 'none';
require_once dirname(__FILE__) . '/../lib/base.php';
}
// Load the CLI environment.
-Horde_Cli::init();
-$cli = Horde_Cli::singleton();
+$cli = Horde_Cli::init();
// Load Folks.
$folks_authentication = 'none';
}
// Load the CLI environment.
-Horde_Cli::init();
-$cli = Horde_Cli::singleton();
+$cli = Horde_Cli::init();
$db = DB::connect($conf['sql']);
if ($db instanceof PEAR_Error) {
static public function authenticateFailure($app = 'horde', $e = null)
{
if (Horde_Cli::runningFromCLI()) {
- $cli = Horde_Cli::singleton();
+ $cli = new Horde_Cli();
$cli->fatal(_("You are not authenticated."));
}
*/
require 'Horde/Cli.php';
-$cli = Horde_Cli::singleton();
+$cli = new Horde_Cli();
/* Explicit colors */
$cli->writeln($cli->red('Red'));
class Horde_Cli
{
/**
- * Singleton instance
- *
- * @var Horde_Cli
- */
- static protected $_instance;
-
- /**
* Are we running on a console?
*
* @var boolean
);
/**
- * Returns a single instance of the Horde_Cli class.
- */
- static public function singleton()
- {
- if (!isset(self::$_instance)) {
- self::$_instance = new self();
- }
-
- return self::$_instance;
- }
-
- /**
* Detect the current environment (web server or console) and sets
* internal values accordingly.
*
- * The constructor must not be called after init(). Either use the
- * singleton() method to retrieve a Horde_Cli object, or don't call init()
- * statically.
+ * The constructor must not be called after init().
*/
public function __construct()
{
* You must not call init() statically before calling the constructor.
* Either use the singleton() method to retrieve a Horde_Cli object after
* calling init(), or don't call init() statically.
+ *
+ * @return Horde_Cli A Horde_Cli instance.
*/
static public function init()
{
/* Run constructor now because it requires $_SERVER['SERVER_NAME'] to
* be empty if called with a CGI SAPI. */
- $cli = self::singleton();
+ $cli = new self();
@set_time_limit(0);
ob_implicit_flush(true);
if (!defined('STDERR')) {
define('STDERR', fopen('php://stderr', 'r'));
}
+
+ return $cli;
}
/**
* init() will be called after the initialization is completed.
*
* Global variables defined:
- * $registry - Registry object
+ * $cli - Horde_Cli object (if 'cli' is true)
+ * $registry - Horde_Registry object
*
* @param string $app The application to initialize.
* @param array $args Optional arguments:
/* Load the CLI environment - make sure there's no time limit,
* init some variables, etc. */
- Horde_Cli::init();
+ $GLOBALS['cli'] = Horde_Cli::init();
$args['nocompress'] = true;
}
require_once $horde_base . '/lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Make sure there's no compression. */
@ob_end_clean();
*/
public function __construct(ReflectionFunction $method)
{
- Horde_Cli::init();
- $this->_cli = Horde_Cli::singleton();
+ $this->_cli = Horde_Cli::init();
parent::__construct($method);
}
require_once $horde_base . '/lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Check for sessionhandler object. */
$registry->setupSessionHandler();
require_once dirname(__FILE__) . '/horde-base.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$db_lib = 'DB';
$sequence = null;
require_once dirname(__FILE__) . '/horde-base.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true, 'nocompress' => true));
-$cli = Horde_Cli::singleton();
$scope = $cli->prompt(_("Enter value for pref_scope:"));
$name = $cli->prompt(_("Enter value for pref_name:"));
// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
-Horde_Cli::init();
+$GLOBALS['cli'] = Horde_Cli::init();
if (!class_exists('SimpleXMLElement', false)) {
include_once 'Tree/Tree.php';
{
$this->_srcDir = $srcDir;
$packageFile = $this->_srcDir . '/package.xml';
- $cli = &Horde_Cli::singleton();
+ $cli = $GLOBALS['cli'];
if (!is_file($packageFile)) {
$cli->message('No package.xml in ' . $this->_srcDir, 'cli.warning');
break;
default:
- $cli = &Horde_Cli::singleton();
- $cli->message('No handler for tag: ' . $child['name'], 'cli-warning');
+ $GLOBALS['cli']->message('No handler for tag: ' . $child['name'], 'cli-warning');
break;
}
}
break;
default:
- $cli = &Horde_Cli::singleton();
- $cli->message('No handler for tag: ' . $child['name'], 'cli-warning');
+ $GLOBALS['cli']->message('No handler for tag: ' . $child['name'], 'cli-warning');
break;
}
}
}
/* Set up CLI. */
-$cli = Horde_Cli::singleton();
-$cli->init();
+$cli = Horde_Cli::init();
$horde_authentication = 'none';
require_once $horde_base . '/lib/base.php';
// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
-Horde_Cli::init();
-$cli = &Horde_Cli::singleton();
+$cli = Horde_Cli::init();
if (empty($argv[1])) {
$cli->fatal('No file specified on the command line.');
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
// Get a database connection
$db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base');
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if ($argc != 2) {
$cli->message('Too many or too few parameters.', 'cli.error');
$cli->writeln('Usage: import_squirrelmail_prefs.php path-to-squirrelmail-data');
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if ($argc != 2) {
$cli->message('Too many or too few parameters.', 'cli.error');
$cli->writeln('Usage: import_squirrelmail_prefs.php DSN');
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
require_once 'Horde/DataTree.php';
$datatree = DataTree::factory('sql',
/* Set up the CLI environment */
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$config = $GLOBALS['conf']['sql'];
unset($config['charset']);
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$cManager = new Horde_Prefs_CategoryManager();
$apps = $registry->listApps(array('hidden', 'notoolbar', 'active', 'admin'));
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$cli->writeln($cli->yellow("Beginning migration. This may take a very long time to complete."));
$cli->writeln();
$info['job_id'] = (int)substr($file, 9, -4);
}
-$cli = Horde_Cli::singleton();
$fax_info = $cli->readStdin();
$fax_info = explode("\n", $fax_info);
foreach ($fax_info as $line) {
$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true));
/* Store the raw fax postscript data. */
-$cli = Horde_Cli::singleton();
$data = $cli->readStdin();
if (empty($data)) {
Horde::logMessage('No print data received from standard input. Exiting fax submission.', __FILE__, __LINE__, PEAR_LOG_ERR);
}
/* Store the raw fax postscript data. */
-$cli = Horde_Cli::singleton();
$data = $cli->readStdin();
if (empty($data)) {
Horde::logMessage('No print data received from standard input. Exiting fax submission.', __FILE__, __LINE__, PEAR_LOG_ERR);
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('imp', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
-
$c = new Console_Getopt();
$argv = $c->readPHPArgv();
array_shift($argv);
/* Set up the CLI environment */
require_once dirname(__FILE__) . '/../../../lib/Application.php';
Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$config = $GLOBALS['conf']['sql'];
unset($config['charset']);
require_once dirname(__FILE__) . '/../../../lib/Application.php';
Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Initialize storage backends. */
if ($conf['storage']['driver'] != 'sql') {
* Ensure that the base parameters (especially SERVER_NAME) get set for the
* command line.
*/
-$cli = Horde_Cli::singleton();
-$cli->init();
+$cli = Horde_Cli::init();
/**
* Hm, the fact that we need the registry at this point for
Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true, 'user_admin' => true));
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if ($argc != 2) {
$cli->message('Too many or too few parameters.', 'cli.error');
$cli->writeln('Usage: import_squirrelmail_file_abook.php DSN');
require_once dirname(__FILE__) . '/../../Application.php';
Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
-
$config = $GLOBALS['conf']['sql'];
unset($config['charset']);
$db = MDB2::factory($config);
$stmt = $db->prepare('UPDATE kronolith_events SET event_start = ?, event_end = ?, event_recurenddate = ? WHERE event_id = ?');
/* Confirm changes. */
-$cli = Horde_Cli::singleton();
if (!isset($argv[1]) || $argv[1] != '--yes') {
$answer = $cli->prompt('Running this script will convert all existing events to UTC. This conversion is not reversible. Is this what you want?', array('y' => 'Yes', 'n' => 'No'));
if ($answer != 'y') {
Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true));
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if (count($argv) != 3) {
$cli->message('Too many or too few parameters.', 'cli.error');
usage();
/* Set up the CLI environment */
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
-
/* Grab what we need to steal the DB config */
require_once HORDE_BASE . '/config/conf.php';
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$history = Horde_History::singleton();
// Run through every tasklist.
require_once TURBA_BASE . '/lib/Object/Group.php';
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if ($argc != 2) {
$cli->message('Too many or too few parameters.', 'cli.error');
$cli->writeln('Usage: import_squirrelmail_file_abook.php path-to-squirrelmail-data');
require_once TURBA_BASE . '/lib/Object/Group.php';
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if ($argc != 2) {
$cli->message('Too many or too few parameters.', 'cli.error');
$cli->writeln('Usage: import_squirrelmail_file_abook.php DSN');
Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
// Read command line parameters.
-$cli = Horde_Cli::singleton();
if (count($argv) != 3) {
$cli->message('Too many or too few parameters.', 'cli.error');
usage();
/* Set up the CLI environment */
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Grab what we need to steal the DB config */
require_once HORDE_BASE . '/config/conf.php';
/* Set up the CLI environment */
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
/* Grab what we need to steal the DB config */
require_once HORDE_BASE . '/config/conf.php';
// Load Horde and Turba enviroments
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true, 'user_admin' => true));
-$CLI = Horde_Cli::singleton();
$CLI->writeln('This script will turn all entries in the SQL address book into a globally shared address book.');
$CLI->writeln('Make sure you read the script comments and be sure you know what you are doing.');
}
/* Load the command line environment. */
-Horde_Cli::init();
-$cli =& Horde_Cli::singleton();
+$cli = Horde_Cli::init();
/* Load the Whups libraries. */
require_once HORDE_BASE . '/lib/core.php';
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('whups', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
-
// Set server name.
$conf['server']['name'] = $conf['mail']['server_name'];
$conf['server']['port'] = $conf['mail']['server_port'];
}
/* Load the command line environment. */
-Horde_Cli::init();
-$cli = &Horde_Cli::singleton();
+$cli = Horde_Cli::init();
$confirm = $cli->prompt('Are you sure you want to obliterate all Whups data?',
array('n' => 'No', 'y' => 'Yes'));
if (!Horde_Cli::runningFromCli()) {
exit("Must be run from the command line\n");
}
-$cli = &Horde_Cli::singleton();
-$cli->init();
+$cli = Horde_Cli::init();
/* Grab what we need to steal the DB config */
require_once HORDE_BASE . '/config/conf.php';
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$dateFormat = "F j, Y";
$keepHeaders = array('From', 'To', 'Subject', 'Cc', 'Date');
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
-
// Create driver instance.
if ($conf['storage']['driver'] != 'sql') {
exit("You must have an SQL backend configured.\n");
require_once dirname(__FILE__) . '/../lib/Application.php';
Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true));
-$cli = Horde_Cli::singleton();
$debug = false;
$out = 'screen';