Exemple #1
0
 /**
  * constructor
  */
 function __construct()
 {
     //	$include_path = "packages/" . get_include_path( );
     //	set_include_path( $include_path );
     require_once 'Console/Getopt.php';
     $shortOptions = "s:u:p:k:";
     $longOptions = array('site=', 'user', 'pass');
     $getopt = new Console_Getopt();
     $args = $getopt->readPHPArgv();
     array_shift($args);
     list($valid, $this->args) = $getopt->getopt2($args, $shortOptions, $longOptions);
     $vars = array('user' => 'u', 'pass' => 'p', 'key' => 'k', 'site' => 's');
     foreach ($vars as $var => $short) {
         ${$var} = NULL;
         foreach ($valid as $v) {
             if ($v[0] == $short || $v[0] == "--{$var}") {
                 ${$var} = $v[1];
                 break;
             }
         }
         if (!${$var}) {
             die("\nUsage: \$ php5 " . $_SERVER['PHP_SELF'] . " -k key -u user -p password -s yoursite.org\n");
         }
     }
     $this->site = $site;
     $this->key = $key;
     $this->setEnv();
     $this->authenticate($user, $pass);
 }
function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config = CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:k:pre";
    $longOptions = array('name=', 'pass='******'key=', 'prefix=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('name' => 'n', 'pass' => 'p', 'key' => 'k', 'prefix' => 'pre');
    foreach ($vars as $var => $short) {
        ${$var} = NULL;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
    //log the execution of script
    CRM_Core_Error::debug_log_message('NormalizePhone.php');
    // process all phones
    processPhones($config, $prefix);
}
 public function __construct()
 {
     require_once 'Console/Getopt.php';
     define('NO_ARGS', 1);
     define('INVALID_OPTION', 2);
     $args = Console_Getopt::readPHPArgv();
     if (count($args) <= 1) {
         $this->usage(true);
         exit(1);
     }
     if (PEAR::isError($args)) {
         fputs(STDERR, $args->getMessage() . "\n");
         exit(NO_ARGS);
     }
     if ($_SERVER['argv'][0] == $_SERVER['SCRIPT_NAME']) {
         $this->opts = Console_Getopt::getOpt($args, $this->short_opts, $this->long_opts);
     } else {
         $this->opts = Console_Getopt::getOpt2($args, $this->short_opts, $this->long_opts);
     }
     // Are the passed options valid?
     if (PEAR::isError($this->opts)) {
         fputs(STDERR, $this->opts->getMessage() . "\n");
         exit(INVALID_OPTION);
     }
     $this->set_cache();
 }
Exemple #4
0
 /**
  * constructor
  */
 function __construct($authenticate = true)
 {
     //	$include_path = "packages/" . get_include_path( );
     //	set_include_path( $include_path );
     if (!$authenticate) {
         $this->setEnv();
         return;
     }
     require_once 'Console/Getopt.php';
     $shortOptions = "s:u:p:";
     $longOptions = array('site=', 'user', 'pass');
     $getopt = new Console_Getopt();
     $args = $getopt->readPHPArgv();
     array_shift($args);
     list($valid, $this->args) = $getopt->getopt2($args, $shortOptions, $longOptions);
     $vars = array('user' => 'u', 'pass' => 'p', 'site' => 's');
     foreach ($vars as $var => $short) {
         ${$var} = null;
         foreach ($valid as $v) {
             if ($v[0] == $short || $v[0] == "--{$var}") {
                 ${$var} = $v[1];
                 break;
             }
         }
         if (!${$var}) {
             $a = explode('/', $_SERVER["SCRIPT_NAME"]);
             $file = $a[count($a) - 1];
             die("\nUsage: \$cd /your/civicrm/root; \$php5 bin/" . $file . " -u user -p password -s yoursite.org (or default)\n");
         }
     }
     $this->site = $site;
     $this->setEnv();
     $this->authenticate($user, $pass);
 }
Exemple #5
0
 public function getParameters()
 {
     $params = array();
     sgAutoloader::loadFile('Console_Getopt', dirname(__FILE__) . '/vendor/Console/Getopt.php');
     $cg = new Console_Getopt();
     $params = $cg->readPHPArgv();
     array_shift($params);
     return $params;
 }
Exemple #6
0
 /**
  * Constructor will parse specified short and long arguments
  *
  * @access public
  * @param  string   short options specification
  * @param  array    long options specification
  * @param  callback error callback, call this and exit on errors if given
  */
 function __construct($short_options, $long_options = NULL, $usage = NULL)
 {
     // use parent methods for actual parsing, store result internaly
     $argv = parent::readPHPArgv();
     $this->options = parent::getopt($argv, $short_options, $long_options);
     if (PEAR::isError($this->options)) {
         if (!is_null($usage) && is_callable($usage)) {
             call_user_func($usage, $this->options->message);
             exit(3);
         }
     }
 }
  function run(&$root_group)
  {
    $opt_browse_path = false;
    $opt_test_path = false;

    $argv = Console_Getopt::readPHPArgv();
    if (PEAR::isError($argv))
    {
      die('Fatal Error: ' . $argv->getMessage()) . "\n";
    }

    $short_opts = 'ht:b:';
    $long_opts = array('help', 'test=', 'browse=');
    $options = Console_Getopt::getopt($argv, $short_opts, $long_opts);
    if (PEAR::isError($options))
    {
      $this->usage();
    }

    foreach ($options[0] as $option)
    {
      switch ($option[0])
      {
        case 'h':
        case '--help':
          $this->usage();
          break;
        case 't':
        case '--test':
          $opt_test_path = $option[1];
          break;
        case 'b':
        case '--browse':
          $opt_browse_path = $option[1];
          break;
      }
    }

    if ($opt_browse_path)
      $this->browse($opt_browse_path, $root_group);

    if ($opt_test_path)
      $this->perform($opt_test_path, $root_group);

    if(!$opt_browse_path && !$opt_test_path)
      $this->browse('', $root_group);

    exit(0);
  }
function &get_commandline()
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('ini=', 'force==');
    $params = $cg->getopt2($args, $shortOpts, $longOpts);
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
function &get_commandline()
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('ini=', 'help==', 'pid=', 'daemon==');
    $params = $cg->getopt2($args, $shortOpts, $longOpts);
    if (PEAR::isError($params)) {
        echo 'Error: ' . $params->getMessage() . "\n";
        exit(1);
    }
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
 public function __construct()
 {
     $args = Console_Getopt::readPHPArgv();
     if (PEAR::isError($args)) {
         fwrite(STDERR, $args->getMessage() . "\n");
         exit(1);
     }
     // Compatibility between "php script.php" and "./script.php"
     if (realpath($_SERVER['argv'][0]) == __FILE__) {
         $this->options = Console_Getopt::getOpt($args, $this->short_format_config);
     } else {
         $this->options = Console_Getopt::getOpt2($args, $this->short_format_config);
     }
     // Check for invalid options
     if (PEAR::isError($this->options)) {
         fwrite(STDERR, $this->options->getMessage() . "\n");
         $this->help();
     }
     $this->command = array();
     // Loop through the user provided options
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case 'h':
                 help();
                 break;
             case 's':
                 $this->command['syntax'] = $option[1];
                 break;
             case 't':
                 $this->command['transform'] = $option[1];
                 break;
             case 'c':
                 $this->command['config'] = $option[1];
                 break;
         }
     }
     // Loop through the user provided options
     foreach ($this->options[1] as $argument) {
         $this->command['query'] .= ' ' . $argument;
     }
 }
Exemple #11
0
function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config =& CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:s:e:k:";
    $longOptions = array('name=', 'pass='******'key=', 'start=', 'end=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('start' => 's', 'end' => 'e', 'name' => 'n', 'pass' => 'p', 'key' => 'k');
    foreach ($vars as $var => $short) {
        ${$var} = null;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(true, $name, $pass);
    // check that we have a geocodeMethod
    if (empty($config->geocodeMethod)) {
        echo ts('Error: You need to set a mapping provider under Global Settings');
        exit;
    }
    $config->userFramework = 'Soap';
    $config->userFrameworkClass = 'CRM_Utils_System_Soap';
    $config->userHookClass = 'CRM_Utils_Hook_Soap';
    // we have an exclusive lock - run the mail queue
    processContacts($config, $start, $end);
}
 public function executeDoctrineCli($arguments = array(), $options = array())
 {
     try {
         DoctrinePluginConfiguration::init();
     } catch (Exception $e) {
         sgCLI::error($e->getMessage());
         return false;
     }
     // spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     spl_autoload_register(array('Doctrine', 'extensionsAutoload'));
     $settings = sgConfiguration::get('settings.DoctrinePlugin');
     $settings['generate_models_options']['suffix'] = '.class.php';
     $config = array('data_fixtures_path' => DoctrinePluginConfiguration::getPath('fixtures'), 'models_path' => DoctrinePluginConfiguration::getPath('models'), 'migrations_path' => DoctrinePluginConfiguration::getPath('mogrations'), 'sql_path' => DoctrinePluginConfiguration::getPath('sql'), 'yaml_schema_path' => DoctrinePluginConfiguration::getPath('schema'), 'generate_models_options' => $settings['generate_models_options']);
     $cg = new Console_Getopt();
     $params = $cg->readPHPArgv();
     $params[0] .= ' ' . $params[1];
     unset($params[1]);
     $params = array_merge($params);
     $cli = new DoctrinePluginCli($config);
     $cli->run($params);
 }
Exemple #13
0
function &get_commandline($more_longopts = array())
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('user='******'ini=', 'password='******'host=', 'db=', 'port=', 'help==', 'verbose==', 'method=', 'gearman=', 'inlist=', 'between=', 'directory=', 'push_where', 'inlist_merge_threshold==', 'inlist_merge_size==', 'coord_engine==', 'schema=', 'batch');
    $longOpts = array_merge($longOpts, $more_longopts);
    @($params = $cg->getopt2($args, $shortOpts, $longOpts));
    if (@PEAR::isError($params)) {
        echo 'Error: ' . $params->getMessage() . "\n";
        exit(1);
    }
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
Exemple #14
0
/**
 * This script parses MIME messages and deactivates users with returned emails.
 *
 * Copyright 2008-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Duck <*****@*****.**>
 * @package Folks
 */
function usage()
{
    $argv = Console_Getopt::readPHPArgv();
    $cmd = basename($argv[0]);
    echo <<<EOU
Usage: {$cmd} [options]

This script parses MIME messages and deactivates users with returned emails.

Options:
    -h, --help           Give this help.
    -u, --username       A user to send notificatons with.
        --mail-host      The IMAP/POP3 server to get the messages from.
                         Defaults to "localhost".
        --mail-user      The user name for the mail server.
        --mail-pass      The password for the mail server.
        --mail-port      The mail server port. Defaults to "143".
        --mail-protocol  The mail server protocol. Defaults to "imap/notls".
        --mail-folder    The folder on the mail server. Defaults to "INBOX".

EOU;
}
Exemple #15
0
 /**
  *
  */
 public function getParams()
 {
     $short_opts = 'hdcsl';
     $long_opts = array('help', 'debug', 'compress', 'strict', 'lexdebug');
     $console = new Console_Getopt();
     $args = $console->readPHPArgv();
     $opts = $console->getopt($args, $short_opts, $long_opts);
     if (PEAR::isError($opts)) {
         echo $opts->getMessage() . PHP_EOL;
         $this->usage(1);
     }
     foreach ($opts[0] as $opt) {
         if ($opt[0] === '--help' || $opt[0] === 'h') {
             $this->usage();
         }
         if ($opt[0] === '--debug' || $opt[0] === 'd') {
             SmartCSS::$debug = true;
         }
         if ($opt[0] === '--compress' || $opt[0] === 'c') {
             SmartCSS::$compress = true;
         }
         if ($opt[0] === '--strict' || $opt[0] === 's') {
             SmartCSS::$strict = true;
         }
         if ($opt[0] === '--lexdebug' || $opt[0] === 'l') {
             SmartCSS::$lexdebug = true;
         }
     }
     if (empty($opts[1])) {
         $this->usage();
     }
     $filename = $opts[1][0];
     if (empty($filename)) {
         $this->usage();
     }
     return $filename;
 }
Exemple #16
0
/**
 * Main functions. Just decides what mode we are in and calls the
 * appropriate methods.
 */
function main()
{
    global $info, $config;
    $args = Console_Getopt::readPHPArgv();
    if (count($args) < 2) {
        print_usage_info();
    }
    if (substr($args[1], 0, 1) == "-" || substr($args[1], 0, 1) == "/") {
        print "invalid parameter " . $args[2] . "\n";
        print_usage_info();
    }
    if (substr($args[1], -4) == ".php") {
        // mode 2: create zombie app
        if (!file_exists($args[1])) {
            die("config file " . $args[1] . " does not exist\n");
        }
        read_config_file($args[1]);
        $outdir = ZOMBIE_BASE . '/../' . Horde_String::lower($config['app']);
        if (is_dir($outdir) && $args[2] != "-f") {
            print "Directory {$outdir} already exists.\nUse -f flag to force overwrite\n";
            exit;
        }
        $n = $config['app'];
        print "Creating Horde Application {$n} in directory " . Horde_String::lower($n) . "\n";
        transform($outdir);
        print "\nHorde Application '{$n}' successfully written. Where to go from here:\n" . "1) Paste content of {$n}/registry.stub to horde/config/registry.php.\n" . "   After that, the {$n} should be working!\n" . "2) Replace {$n}.gif with proper application icon\n" . "3) Ensure conf.php is not world-readable as it may contain password data.\n" . "4) Start playing around and enhancing your new horde application. Enjoy!\n";
    } else {
        // mode 1: create config file
        parse_options($args);
        print "creating config file for table " . $config['table'] . "\n";
        create_table_info();
        enhance_info();
        print "writing config file to " . $config['file'] . "\n";
        dump_config_file();
    }
}
$dumpstats = 0;
$randomdata = 0;
$dumpconfig = '';
$defines = array();
$daemon = 0;
$daemon_args = "";
// **************************************************************************************
// THIS IS THE ONE LINE IN HERE YOU MIGHT HAVE TO CHANGE!
$rrdtool = "/usr/bin/rrdtool";
// (on Windows, use / instead of \ in pathnames - c:/rrdtool/bin/rrdtool.exe for example)
// **************************************************************************************
// initialize object
$cg = new Console_Getopt();
$short_opts = '';
$long_opts = array("version", "help", "image-uri=", "base-href=", "config=", "output=", "debug", "uberdebug", "stats", "define=", "no-data", "randomdata", "htmloutput=", "dumpafter", "bulge", "sizedebug", "dumpconfig=", "daemon=");
$args = $cg->readPHPArgv();
$ret = $cg->getopt($args, $short_opts, $long_opts);
if (PEAR::isError($ret)) {
    die("Error in command line: " . $ret->getMessage() . "\n (try --help)\n");
}
$gopts = $ret[0];
$options_output = array();
if (sizeof($gopts) > 0) {
    foreach ($gopts as $o) {
        switch ($o[0]) {
            case '--config':
                $configfile = $o[1];
                break;
            case '--htmloutput':
                $htmlfile = $o[1];
                break;
Exemple #18
0
 public function processArgs()
 {
     if ($this->processed) {
         return;
     }
     $this->processed = true;
     @(require_once "Console/Getopt.php");
     if (!class_exists('Console_Getopt')) {
         $this->usage('Please install the PEAR Console_Getopt package');
     }
     $cg = new Console_Getopt();
     $t_args = $cg->readPHPArgv();
     array_shift($t_args);
     $args = array();
     while (count($t_args) > 0) {
         $arg = array_shift($t_args);
         list($key, $val) = array_pad(explode('=', $arg), 2, '');
         if (strlen($key) == 0) {
             $this->usage("Bad argument {$key}");
         }
         if (substr($key, 0, 2) == '--') {
             if (strlen($key) < 3) {
                 $this->usage("Bad argument {$key}");
             }
             $key = substr($key, 2);
             if ($key == 'help') {
                 $this->usage();
             }
         } else {
             if ($key[0] == '-') {
                 if (strlen($key) < 2) {
                     $this->usage("Bad argument {$key}");
                 }
                 $key = substr($key, 1);
                 if ($key == 'h') {
                     $this->usage();
                 }
             } else {
                 $this->arg_files[] = $arg;
                 continue;
             }
         }
         if (strlen($val) == 0) {
             $this->usage("Bad value [{$val}] for argument {$key}");
         }
         $processor = 'processArg_' . $key;
         if ($this->_hasMethod($processor)) {
             $this->setValue($key, $this->{$processor}($val));
         } else {
             if (array_key_exists($key, $this->booleans)) {
                 if ($val == '0' || is_string($val) && strlen($val) > 0 && strtoupper(substr($val, 0, 1)) == 'F') {
                     $this->booleans[$key] = false;
                 } else {
                     if ($val == '1' || is_string($val) && strlen($val) > 0 && strtoupper(substr($val, 0, 1)) == 'T') {
                         $this->booleans[$key] = true;
                     }
                 }
             } else {
                 $this->setValue($key, $val);
             }
         }
     }
 }
Exemple #19
0
 /**
  * Gets the options and parameters from the command arguments
  *
  * Extracts the command arguments. Tidies the options.
  * Builds the help/usage text.
  *
  * @param  array   $config      the command configuration
  * @param  boolean $toLongNames Converts options names to long names if true,
  *                              e.g. "align", or to short names if false,
  *                              e.g. "A", default is true
  * @param  boolean $asKeys      return options with the names used as array
  *                              keys if true, or leave them as returned by
  *                              Console_Getopt::doGetopt(), default is true
  * @param  integer $version     Console_Getopt::doGetopt version
  * @return array   the options and parameters
  * @access public
  * @static
  */
 public static function getopt($config = array(), $toLongNames = true, $asKeys = true, $version = 2)
 {
     $getopt = new self();
     // silently ignore invalid configuration arrays, defaults the absent ones to empty arrays
     $default = array_combine($getopt->configKeys, array_fill(0, count($getopt->configKeys), array()));
     $config = array_intersect_key($config, $default);
     $config = array_merge($default, $config);
     // extracts the command arguments, including the command name
     $args = Console_Getopt::readPHPArgv();
     $command = array_shift($args);
     // tidies the options, sets the short and long options, and calls getopt
     $config['options'] = $getopt->tidyOptions($config['options']);
     $options = Console_Getopt::doGetopt($version, $args, $getopt->shortOptions, $getopt->longOptions);
     // a syntax error, prints out the error message
     PEAR::isError($options) and exit($options->getMessage());
     // tidies the arguments
     $options[0] = $getopt->tidyArgs($options[0], $toLongNames, $asKeys);
     // a request for help/usage, prints the command usage
     $options[0] == 'help' and exit(implode("\n", $getopt->setHelp($config, $command)));
     return $options;
 }
Exemple #20
0
 public function callAsCLI()
 {
     $console = new Console_Getopt();
     $args = $console->readPHPArgv();
     return PEAR::isError($args) ? false : true;
 }
function main()
{
    global $just_show;
    $shortopts = "hn";
    $cg = new Console_Getopt();
    $dirs = $cg->readPHPArgv();
    array_shift($dirs);
    /* Trash $0, the name of the script */
    $ret = $cg->getopt2($dirs, $shortopts, $longopts);
    if (PEAR::isError($ret)) {
        echo $ret->getMessage(), "\n\n";
        usage();
    }
    list($opts, $dirs) = $ret;
    foreach ($opts as $opt) {
        list($o, $val) = $opt;
        switch ($o) {
            case 'h':
                usage(true);
                break;
            case 'n':
                $just_show = true;
                break;
            default:
                echo "Unknown option: {$o}\n\n";
                usage(true);
        }
    }
    if (count($dirs) == 0) {
        usage();
    }
    foreach ($dirs as $dir) {
        run_files($dir);
    }
}
 /**
  * Parses the command line options.
  *
  * @return array
  */
 protected function parseOptions()
 {
     Stagehand_LegacyError_PEARError::enableConversion();
     $oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT & ~E_NOTICE);
     Stagehand_LegacyError_PHPError::enableConversion(error_reporting());
     try {
         $argv = Console_Getopt::readPHPArgv();
         array_shift($argv);
         $parsedOptions = Console_Getopt::getopt2($argv, $this->shortOptions, $this->longOptions);
     } catch (Stagehand_LegacyError_PEARError_Exception $e) {
         Stagehand_LegacyError_PHPError::disableConversion();
         error_reporting($oldErrorReportingLevel);
         Stagehand_LegacyError_PEARError::disableConversion();
         throw new $this->exceptionClass(preg_replace('/^Console_Getopt: /', '', $e->getMessage()));
     } catch (Exception $e) {
         Stagehand_LegacyError_PHPError::disableConversion();
         error_reporting($oldErrorReportingLevel);
         Stagehand_LegacyError_PEARError::disableConversion();
         throw $e;
     }
     Stagehand_LegacyError_PHPError::disableConversion();
     error_reporting($oldErrorReportingLevel);
     Stagehand_LegacyError_PEARError::disableConversion();
     return $parsedOptions;
 }
    require_once $cacti_base . '/include/config.php';
} else {
    die("Couldn't find a usable Cacti config - check the first few lines of " . __FILE__ . "\n");
}
require_once 'Weathermap.class.php';
require_once 'Console/Getopt.php';
$reverse = 0;
$inputfile = '';
$outputfile = '';
$converted = 0;
$candidates = 0;
$totaltargets = 0;
$getopt = new Console_Getopt();
$short_opts = '';
$long_opts = array('help', 'input=', 'output=', 'debug');
$args = $getopt->readPHPArgv();
$ret = $getopt->getopt($args, $short_opts, $long_opts);
if (PEAR::isError($ret)) {
    die('Error in command line: ' . $ret->getMessage() . "\n (try --help)\n");
}
$gopts = $ret[0];
if (count($gopts) > 0) {
    foreach ($gopts as $o) {
        switch ($o[0]) {
            case '--debug':
                $weathermap_debugging = true;
                break;
            case '--input':
                $inputfile = $o[1];
                break;
            case '--output':
Exemple #24
0
#!/usr/bin/env php
<?php 
$php = "php";
set_include_path("test/framework/external/" . PATH_SEPARATOR . "test/framework/" . get_include_path());
require_once "lib/header.php";
require_once "Console/Getopt.php";
require_once "Reduce.php";
$cg = new Console_Getopt();
$command_line = join(" ", $cg->readPHPArgv());
$opt_result = $cg->getopt($cg->readPHPArgv(), "vhc:rdDf:i:UuF:ZP:m:p:");
if (!is_array($opt_result)) {
    die($opt_result->message . "\n");
}
list($opts, $arguments) = $opt_result;
$opt_verbose = 0;
$opt_help = false;
$opt_command = "";
$opt_main_command = "";
$opt_pass = "******";
$opt_xml = NULL;
$opt_interpret = false;
$opt_dont_upper = false;
$opt_upper = false;
$opt_failure = false;
$opt_zero = true;
$opt_phc_prefix = ".";
foreach ($opts as $opt) {
    switch ($opt[0]) {
        case 'h':
            $opt_help = true;
            break;
Exemple #25
0
<?php

/*
 * login_multi_ip.php - Finding users logging in using the same IP
 * Copyright (c) 2005  Marcus Lunzenauer
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */
/***** COMMAND LINE *****/
// include PEAR::Console_Getopt
require_once 'Console/Getopt.php';
// check for command line options
$options = Console_Getopt::getOpt(Console_Getopt::readPHPArgv(), 'dht:');
if (PEAR::isError($options)) {
    multiip_usage();
    exit(1);
}
// check for options
$debugFlag = FALSE;
$time_intervall = 12;
foreach ($options[0] as $option) {
    // option h
    if ('h' == $option[0]) {
        multiip_usage();
        exit(1);
        // option d
    } else {
        if ('d' == $option[0]) {
Exemple #26
0
    print "   -h            : this information\n";
    print "   -p path       : set template path\n";
    print "   -e            : evaluate templates\n";
    print "   -j json       : parse json file and pass as context to evaluation\n";
    print "   -c name       : compile to class name\n";
    print "   --disable-lambdas : disable lambdas for compilation\n";
    print "   --disable-indentation : disable indentation for compilation\n";
    print "   --include-partials : include partials directly as code\n";
    print "   --beautify     : beautify generated code\n";
}
if (defined('STDIN')) {
    error_reporting(E_ALL);
    ini_set('xdebug.max_nesting_level', 10000);
    require_once 'Console/Getopt.php';
    $o = new Console_Getopt();
    $argv = $o->readPHPArgv();
    /* check we are not included by someone */
    if (realpath($argv[0]) != realpath(__FILE__)) {
        return;
    }
    function filenameToFunctionName($filename)
    {
        $name = basename($filename);
        $name = preg_replace('/\\.[^\\.]*$/', '_', $name);
        $name = preg_replace('/[^a-zA-Z0-9]/', '_', $name);
        return $name;
    }
    function _getopt($opts, $name)
    {
        if (array_key_exists($name, $opts)) {
            return $opts[$name];
@ini_set('magic_quotes_runtime', false);
$_PEAR_PHPDIR = '#$%^&*';
set_error_handler('error_handler');
$pear_package_version = "@pear_version@";
require_once 'PEAR.php';
require_once 'PEAR/Frontend.php';
require_once 'PEAR/Config.php';
require_once 'PEAR/Command.php';
require_once 'Console/Getopt.php';
PEAR_Command::setFrontendType('CLI');
$all_commands = PEAR_Command::getCommands();
// remove this next part when we stop supporting that crap-ass PHP 4.2
if (!isset($_SERVER['argv']) && !isset($argv) && !isset($HTTP_SERVER_VARS['argv'])) {
    die('ERROR: either use the CLI php executable, or set register_argc_argv=On in php.ini');
}
$argv = Console_Getopt::readPHPArgv();
// fix CGI sapi oddity - the -- in pear.bat/pear is not removed
if (php_sapi_name() != 'cli' && isset($argv[1]) && $argv[1] == '--') {
    unset($argv[1]);
    $argv = array_values($argv);
}
$progname = PEAR_RUNTYPE;
if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
    array_shift($argv);
    $options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");
} else {
    $options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV");
}
if (PEAR::isError($options)) {
    usage($options);
}
Exemple #28
0
 /**
  * Parses command line into command line arguments array.
  *          
  * @return array
  */
 protected static function handleArguments()
 {
     $arguments = array();
     $shortopts = 'v::h::';
     $longopts = array('certreq', 'delete', 'export', 'genkey', 'help', 'import', 'keyclone', 'list', 'alias==', 'file==', 'keypass==', 'Crypt_KeyStore==', 'storepass==', 'dest==', 'new==');
     try {
         $con = new Console_Getopt();
         $args = $con->readPHPArgv();
         array_shift($args);
         $options = $con->getopt2($args, $shortopts, $longopts);
         if (!is_array($options)) {
             echo "Failed to parse command line arguments:\n";
             echo $options;
             exit(1);
         }
         if (count($options[0]) == 0 || self::hasOption('--help', $options) || self::hasOption('h', $options)) {
             self::showHelp();
             exit(1);
         }
     } catch (RuntimeException $e) {
         echo "Failed to parse command line arguments:\n";
         echo $e->getMessage() . "\n";
         exit(1);
     }
     foreach (self::$_cmds as $cmd => $cmdFunc) {
         if (self::hasOption("--" . $cmd, $options)) {
             $arguments['command'] = $cmd;
             break;
         }
     }
     foreach (self::$_cmdopts as $cmdopt) {
         if (self::hasOption("--" . $cmdopt, $options)) {
             $arguments[$cmdopt] = self::getOptionValue("--" . $cmdopt, $options);
         }
     }
     return $arguments;
 }
    exit(1);
}
if (!defined('SQ_SYSTEM_ROOT')) {
    define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
}
require_once $SYSTEM_ROOT . '/core/include/init.inc';
// firstly let's check that we are OK for the version
if (version_compare(PHP_VERSION, SQ_REQUIRED_PHP_VERSION, '<')) {
    trigger_error('<i>' . SQ_SYSTEM_LONG_NAME . '</i> requires PHP Version ' . SQ_REQUIRED_PHP_VERSION . '.<br/> You may need to upgrade.<br/> Your current version is ' . PHP_VERSION, E_USER_ERROR);
}
// only use console stuff if we're running from the command line
require_once 'Console/Getopt.php';
$shortopt = '';
$longopt = array('package=');
$con = new Console_Getopt();
$args = $con->readPHPArgv();
array_shift($args);
$options = $con->getopt($args, $shortopt, $longopt);
if (is_array($options[0])) {
    $package_list = get_console_list($options[0]);
}
// check to see if the default/ tech email in main.inc are provided and are correct
// for more info see bug report 5804 Default and Tech Emails shouldnt break install
require_once SQ_FUDGE_PATH . '/general/www.inc';
$SQ_CONF_DEFAULT_EMAIL = SQ_CONF_DEFAULT_EMAIL;
if (!empty($SQ_CONF_DEFAULT_EMAIL) && !valid_email($SQ_CONF_DEFAULT_EMAIL)) {
    echo "Value '{$SQ_CONF_DEFAULT_EMAIL}' configued for 'SQ_CONF_DEFAULT_EMAIL' in main.inc is not valid.\nPlease fix it and try running the script again.\n";
    exit(1);
}
$SQ_CONF_TECH_EMAIL = SQ_CONF_TECH_EMAIL;
if (!empty($SQ_CONF_TECH_EMAIL) && !valid_email($SQ_CONF_TECH_EMAIL)) {
Exemple #30
0
function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config =& CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:s:e:k:g:parse";
    $longOptions = array('name=', 'pass='******'key=', 'start=', 'end=', 'geocoding=', 'parse=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('start' => 's', 'end' => 'e', 'name' => 'n', 'pass' => 'p', 'key' => 'k', 'geocoding' => 'g', 'parse' => 'ap');
    foreach ($vars as $var => $short) {
        ${$var} = null;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(true, $name, $pass);
    // do check for geocoding.
    $processGeocode = false;
    if (empty($config->geocodeMethod)) {
        if ($geocoding == 'true') {
            echo ts('Error: You need to set a mapping provider under Global Settings');
            exit;
        }
    } else {
        $processGeocode = true;
        // user might want to over-ride.
        if ($geocoding == 'false') {
            $processGeocode = false;
        }
    }
    // do check for parse street address.
    require_once 'CRM/Core/BAO/Preferences.php';
    $parseAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Preferences::valueOptions('address_options'), false);
    $parseStreetAddress = false;
    if (!$parseAddress) {
        if ($parse == 'true') {
            echo ts('Error: You need to enable Street Address Parsing under Global Settings >> Address Settings.');
            exit;
        }
    } else {
        $parseStreetAddress = true;
        // user might want to over-ride.
        if ($parse == 'false') {
            $parseStreetAddress = false;
        }
    }
    // don't process.
    if (!$parseStreetAddress && !$processGeocode) {
        echo ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
        exit;
    }
    $config->userFramework = 'Soap';
    $config->userFrameworkClass = 'CRM_Utils_System_Soap';
    $config->userHookClass = 'CRM_Utils_Hook_Soap';
    // we have an exclusive lock - run the mail queue
    processContacts($config, $processGeocode, $parseStreetAddress, $start, $end);
}