コード例 #1
0
 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();
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
ファイル: login_multi_ip.php プロジェクト: microlefes/Game
<?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]) {
コード例 #4
0
        $m_token_digest .= $config->get_salt_field();
        // produce the signature and append to the tokenized string
        $signature = hash_hmac($config->get_algo(), rtrim($m_token_digest, $config->get_field_delimiter()), $this->h2b($config->get_key()));
        return $m_token . 'hmac=' . $signature;
    }
}
// CLI Parameter Control
if (!empty($argc) && strstr($argv[0], basename(__FILE__))) {
    // bring in getopt and define some exit codes
    require_once 'Console/Getopt.php';
    define('NO_ARGS', 10);
    define('INVALID_OPTION', 11);
    // parse args to opts
    $args = Console_Getopt::readPHPArgv();
    $long_opts = array('help', 'window=', 'start-time=', 'ip=', 'acl=', 'session-id=', 'payload=', 'url=', 'salt=', 'field-delimiter=', 'acl-delimiter=', 'algo=', 'key=', 'debug', 'escape-early');
    $opts = Console_Getopt::getOpt($args, 'h', $long_opts);
    // Check the options are valid
    if (PEAR::isError($opts)) {
        fwrite(STDERR, $opts->getMessage() . "\n");
        exit(INVALID_OPTION);
    }
    if (!empty($opts[0])) {
        $c = new Akamai_EdgeAuth_Config();
        $g = new Akamai_EdgeAuth_Generate();
        foreach ($opts[0] as $o) {
            if ($o[0] == '--help') {
                //@TODO
                print "php akamai_token_v2.php [options]\n";
                print "ie.\n";
                print "php akamai_token_v2.php --start=now --window=86400\n";
                print "\n";
コード例 #5
0
ファイル: phail.php プロジェクト: Bergdahls/YetiForceCRM
#!@prefix@/bin/php -Cq
<?php 
/**
* PHAIL - stands for PHP Mail
* @author Tomas V.V.Cox <*****@*****.**>
*/
require_once 'Mail.php';
require_once 'Mail/mime.php';
require_once 'Console/Getopt.php';
$argv = Console_Getopt::readPHPArgv();
$opts = Console_Getopt::getOpt($argv, 'f:c:s:t:a:b:');
if (PEAR::isError($opts)) {
    usage($opts->getMessage());
}
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$mime =& new Mail_Mime();
foreach ($opts[0] as $opt) {
    $param = $opt[1];
    switch ($opt[0]) {
        case 'f':
            $headers['From'] = $param;
            break;
        case 'c':
            $headers['Cc'] = $param;
            break;
        case 's':
            $headers['Subject'] = $param;
            break;
        case 't':
            $to = $param;
            break;
コード例 #6
0
ファイル: phpcli.php プロジェクト: bruno/openaustralia-app
    ini_set('magic_quotes_runtime', FALSE);
    define('STDIN', fopen('php://stdin', 'r'));
    define('STDOUT', fopen('php://stdout', 'w'));
    define('STDERR', fopen('php://stderr', 'w'));
    register_shutdown_function(create_function('', 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;'));
}
require_once 'Console/Getopt.php';
define('SUCCESS', 0);
define('PROBLEM', 1);
define('NO_ARGS', 10);
define('INVALID_OPTION', 11);
$args = Console_Getopt::readPHPArgv();
if (PEAR::isError($args)) {
    fwrite(STDERR, $args->getMessage() . "\n");
    exit(NO_ARGS);
}
$options = Console_Getopt::getOpt($args, $short_opts, $long_opts);
if (PEAR::isError($options)) {
    fwrite(STDERR, $options->getMessage() . "\n");
    exit(INVALID_OPTION);
}
require_once 'error.php';
/* error display to standard error */
function err_display_stderr($num, $str, $file, $line, $context)
{
    $stderr = fopen('php://stderr', 'w');
    fwrite($stderr, "{$file}:{$line}\n{$str}\n");
    fclose($stderr);
}
err_set_handler_display('err_display_stderr');
err_set_handler_log(null);
コード例 #7
0
ファイル: example_api_base.php プロジェクト: rboyatt/mahara
 *   command line help text
 */
function help_text()
{
    return "\n    Options are:\n        --username     - Web Services simple authentication username\n        --password     - Web Services simple authentication password\n        --bausername   - basic authentication username to get past basic auth\n        --bapassword   - basic authentication password to get past basic auth\n        --servicegroup - service group as specified in webservice configuration that contains the necessary functions to call\n        --url          - the URL of the Web Service to call eg: http://your.mahara.local.net/webservice/soap/server.php\n    ";
}
//fetch arguments
$args = Console_Getopt::readPHPArgv();
//checking errors for argument fetching
if (PEAR::isError($args)) {
    error_log('Invalid arguments (1): ' . help_text());
    exit(1);
}
// remove stderr/stdout redirection args
$args = preg_grep('/2>&1/', $args, PREG_GREP_INVERT);
$console_opt = Console_Getopt::getOpt($args, 'u:p:l:s:', array('username='******'password='******'url=', 'servicegroup=', 'bausername='******'bapassword='******'Invalid arguments (2): ' . help_text());
    exit(1);
}
// must supply at least one arg for the action to perform
if (count($args) <= 2) {
    error_log('Invalid arguments: you must atleast specify --username and --password' . help_text());
    exit(1);
}
/**
 * Get and check interactive parameters
 *
 * @param string $param
 * @param string $default
 */
コード例 #8
0
ファイル: startup.php プロジェクト: michaelprem/phc
<?php

/*
 * phc -- the open source PHP compiler
 * See doc/license/README.license for licensing information
 *
 * Handle command line parameters
 */
require_once "Console/Getopt.php";
require_once "Console/ProgressBar.php";
$cg = new Console_Getopt();
$argv = $cg->readPHPArgv();
$getopt = $cg->getOpt($cg->readPHPArgv(), "lvVshnpicqO:Dr", array("long", "verbose", "valgrind", "support", "help", "number", "no-progress", "installed", "clean", "quick", "one", "debug", "reduce"));
if ($getopt instanceof PEAR_Error) {
    die("Command line error: {$getopt->message}\n");
}
list($opts, $arguments) = $getopt;
foreach ($opts as $opt) {
    if ($opt[1] == NULL) {
        $options[$opt[0]] = "";
    } else {
        $options[$opt[0]] = $opt[1];
    }
}
$opt_verbose = isset($options["v"]);
$opt_long = isset($options["l"]);
$opt_valgrind = isset($options["V"]);
$opt_support = isset($options["s"]);
$opt_numbered = isset($options["n"]);
$opt_help = isset($options["h"]);
$opt_no_progress_bar = isset($options["p"]);