Example #1
0
function genCast($func, $indent)
{
    global $current_server;
    $funcname = $func->name;
    $async = @$func->async;
    $args_set = parseArgs(@$func->args);
    // decode args
    $arg_count = count($args_set);
    if ($arg_count) {
        $argsType = getArgsType($funcname);
        echo "{$indent}{$argsType} _args;\n";
        echo "{$indent}const bool _fOk = cerl::getMailBody(_ar, _args);\n\n";
        echo "{$indent}CERL_ASSERT(_fOk && \"{$current_server}::_handle_cast - {$funcname}\");\n";
        echo "{$indent}if (_fOk)\n";
    } else {
        echo "{$indent}NS_CERL_IO::check_vt_null(_ar);\n";
    }
    $indent2 = $arg_count ? $indent . "\t" : $indent;
    echo "{$indent2}{$funcname}(caller";
    if ($arg_count == 1) {
        echo ", _args";
    } else {
        foreach ($args_set as $var => $tp) {
            echo ", _args.{$var}";
        }
    }
    echo ");\n";
}
Example #2
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['source']) || !is_string($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --source=... [...]

Parameters:

--source            Repository id ('*' for all, separate multiple sources
                    with commas)
--exclude           Repository id's to exclude when using '*' for source
                    (separate multiple sources with commas)
--from              Override harvesting start date
--until             Override harvesting end date
--all               Harvest from beginning (overrides --from)
--verbose           Enable verbose output
--override          Override initial resumption token
                    (e.g. to resume failed connection)
--reharvest[=date]  This is a full reharvest, delete all records that were not
                    received during the harvesting (or were modified before [date]).
                    Implies --all.
--config.section.name=value
                    Set configuration directive to given value overriding any
                    setting in recordmanager.ini
--lockfile=file     Use a lock file to avoid executing the command multiple times in
                    parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $from = isset($params['from']) ? $params['from'] : null;
        if (isset($params['all']) || isset($params['reharvest'])) {
            $from = '-';
        }
        foreach (explode(',', $params['source']) as $source) {
            $manager->harvest($source, $from, isset($params['until']) ? $params['until'] : null, isset($params['override']) ? urldecode($params['override']) : '', isset($params['exclude']) ? $params['exclude'] : null, isset($params['reharvest']) ? $params['reharvest'] : '');
        }
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
Example #3
0
/**
 * Main function 
 * 
 * @param string[] $argv Program parameters
 * 
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    if (!isset($params['input']) || !isset($params['output'])) {
        echo "Usage: splitlog --input=... --output=...\n\n";
        echo "Parameters:\n\n";
        echo "--input             A harvest debug log file\n";
        echo "--output            A file mask for output (e.g. output%d.xml)\n";
        echo "--verbose           Enable verbose output\n\n";
        exit(1);
    }
    $fh = fopen($params['input'], 'r');
    $out = null;
    $count = 0;
    $inResponse = false;
    $emptyLines = 2;
    while ($line = fgets($fh)) {
        $line = chop($line);
        if (!$line) {
            ++$emptyLines;
            continue;
        }
        //echo "Empty: $emptyLines, $inResponse, line: '$line'\n";
        if ($emptyLines >= 2 && $line == 'Request:') {
            fgets($fh);
            fgets($fh);
            $inResponse = true;
            $emptyLines = 0;
            ++$count;
            $filename = sprintf($params['output'], $count);
            echo "Creating file '{$filename}'\n";
            if ($out) {
                fclose($out);
            }
            $out = fopen($filename, 'w');
            if ($out === false) {
                die("Could not open output file\n");
            }
            continue;
        }
        $emptyLines = 0;
        if ($inResponse) {
            fputs($out, $line . "\n");
        }
    }
    if ($out) {
        fclose($out);
    }
    echo "Done.\n";
}
Example #4
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['search'])) {
        echo <<<EOT
Usage: {$argv['0']} --search=...

Parameters:

--search=[regexp]   Search for a string in data sources and list the data source id's


EOT;
        exit(1);
    }
    $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
    if (!empty($params['search'])) {
        $manager->searchDataSources($params['search']);
    }
}
Example #5
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['file']) || empty($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --file=... --source=... [...]

Parameters:

--file              The file or wildcard pattern of files of records
--source            Source ID
--verbose           Enable verbose output
--config.section.name=value
                   Set configuration directive to given value overriding any
                   setting in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $manager->loadFromFile($params['source'], $params['file']);
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
Example #6
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['file'])) {
        echo <<<EOT
Usage: {$argv['0']} --file=... [...]

Parameters:

--file=...          The file for records
--deleted=...       The file for deleted record IDs
--from=...          From date where to start the export
--verbose           Enable verbose output
--quiet             Quiet, no output apart from the data
--skip=...          Skip x records to export only a "representative" subset
--source=...        Export only the given source(s)
                    (separate multiple sources with commas)
--single=...        Export single record with the given id
--xpath=...         Export only records matching the XPath expression
--config.section.name=...
                    Set configuration directive to given value overriding
                    any setting in recordmanager.ini
--sortdedup         Sort export file by dedup id
--dedupid=...       deduped = Add dedup id's to records that have duplicates
                    always  = Always add dedup id's to the records
                    Otherwise dedup id's are not added to the records


EOT;
        exit(1);
    }
    $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
    $manager->quiet = isset($params['quiet']) ? $params['quiet'] : false;
    $manager->exportRecords($params['file'], isset($params['deleted']) ? $params['deleted'] : '', isset($params['from']) ? $params['from'] : '', isset($params['skip']) ? $params['skip'] : 0, isset($params['source']) ? $params['source'] : '', isset($params['single']) ? $params['single'] : '', isset($params['xpath']) ? $params['xpath'] : '', isset($params['sortdedup']) ? $params['sortdedup'] : false, isset($params['dedupid']) ? $params['dedupid'] : '');
}
Example #7
0
function processArgType($func, $indent)
{
    $name = $func->name;
    $args_set = parseArgs(@$func->args);
    $i = count($args_set);
    if ($i == 0) {
        return;
    } else {
        if ($i == 1) {
            foreach ($args_set as $var => $type) {
                $typename = mapType($type, "");
                $argsTyName = getArgsType($name);
                echo "\n{$indent}typedef {$typename} {$argsTyName};\n";
            }
        } else {
            echo "\n{$indent}typedef struct {\n";
            foreach ($args_set as $var => $type) {
                $typename = mapType($type, "");
                echo "{$indent}\t{$typename} {$var};\n";
            }
            $argsTyName = getArgsType($name);
            echo "{$indent}} {$argsTyName};\n";
        }
    }
}
Example #8
0
             case 1:
                 /* cut off function as second part of input string and keep rest for further parsing */
                 $function = trim(substr($input_string, 0, $pos));
                 $input_string = trim(strchr($input_string, ' ')) . ' ';
                 break;
             case 2:
                 /* take the rest as parameter(s) to the function stripped off previously */
                 $parameters = trim($input_string);
                 break 2;
         }
     } else {
         break;
     }
     $i++;
 }
 if (!parseArgs($parameters, $parameter_array)) {
     cacti_log("WARNING: Script Server count not parse '{$parameters}' for {$function}", false, 'PHPSVR');
     fputs(STDOUT, "U\n");
     continue;
 }
 if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
     cacti_log("DEBUG: PID[{$pid}] CTR[{$ctr}] INC: '" . basename($include_file) . "' FUNC: '" . $function . "' PARMS: '" . $parameters . "'", false, 'PHPSVR');
 }
 /* validate the existance of the function, and include if applicable */
 if (!function_exists($function)) {
     if (file_exists($include_file)) {
         /* quirk in php on Windows, believe it or not.... */
         /* path must be lower case */
         if ($config['cacti_server_os'] == 'win32') {
             $include_file = strtolower($include_file);
         }
Example #9
0
function genCtor($class_name, $ctor, $indent)
{
    echo "\n";
    echo "{$indent}";
    if (!count($ctor) || !@$ctor->args) {
        echo "explicit ";
    }
    //echo "${class_name}(cerl::Fiber self";
    echo "{$class_name}(";
    if (count($ctor)) {
        $args = parseArgs(@$ctor->args);
        $i = 0;
        foreach ($args as $var => $tp) {
            if ($i == 0) {
                $typename = mapType($tp, "&");
                echo "const {$typename} {$var}";
            } else {
                $typename = mapType($tp, "&");
                echo ", const {$typename} {$var}";
            }
            $i = $i + 1;
        }
    }
    //echo ")\n${indent}\t: self(_me)\n";
    echo ")\n";
    echo "{$indent}{\n{$indent}}\n";
}
Example #10
0
 /**
  * add extra's, buttons, drop downs, etc. 
  *
  * @author Paul Whitehead
  * @return object
  */
 private function structureAddon($type = 'prepend')
 {
     if (!is_array($this->input[$type]) or empty($this->input[$type])) {
         return $this;
     }
     //combine our arugments
     $addon = parseArgs($this->input[$type], $this->addon_defaults);
     //check if we want a drop down box
     //if options have not been provided
     if (!is_array($this->input[$type]['options']) or empty($this->input[$type]['options'])) {
         //check for the need to do anything
         if (is_array($this->input[$type]) and !empty($this->input[$type])) {
             $this->form_build[] = '<' . $addon['type'] . ' class="add-on">' . $addon['value'] . '</' . $addon['type'] . '>';
         }
         //if we have options
     } else {
         $this->form_build[] = '<div class="btn-group">';
         $this->form_build[] = '<button class="btn dropdown-toggle" data-toggle="dropdown">' . $addon['value'];
         $this->form_build[] = '<span class="caret"></span></button>';
         $this->form_build[] = '<ul class="dropdown-menu">';
         foreach ($this->input[$type]['options'] as $key => $value) {
             //check if a divider is requested
             if ($key == 'divider' and $value === true) {
                 $this->form_build[] = '<li class="divider"></li>';
                 continue;
             }
             //check is we just have a simple string or value
             if (!is_array($value)) {
                 $this->form_build[] = $key;
                 continue;
             }
             $this->form_build[] = '<li><a ' . $this->attrKeyValue($value, array('icon')) . '>' . $value['title'] . '</a></li>';
             continue;
         }
         $this->form_build[] = '</ul>';
         $this->form_build[] = '</div>';
     }
     return $this;
 }
Example #11
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../lib/bootstrap.php';
ini_set('xdebug.max_nesting_level', 3000);
// Disable XDebug var_dump() output truncation
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
ini_set('xdebug.var_display_max_depth', -1);
list($operations, $files, $attributes) = parseArgs($argv);
/* Dump nodes by default */
if (empty($operations)) {
    $operations[] = 'dump';
}
if (empty($files)) {
    showHelp("Must specify at least one file.");
}
$lexer = new PhpParser\Lexer\Emulative(array('usedAttributes' => array('startLine', 'endLine', 'startFilePos', 'endFilePos')));
$parser = new PhpParser\Parser($lexer);
$dumper = new PhpParser\NodeDumper();
$prettyPrinter = new PhpParser\PrettyPrinter\Standard();
$serializer = new PhpParser\Serializer\XML();
$traverser = new PhpParser\NodeTraverser();
$traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver());
foreach ($files as $file) {
    if (strpos($file, '<?php') === 0) {
        $code = $file;
        echo "====> Code {$code}\n";
    } else {
        if (!file_exists($file)) {
            die("File {$file} does not exist.\n");
        }
Example #12
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
/* @var dbx\Client $client */
/* @var string $sourcePath */
/* @var string $dropboxPath */
list($client, $sourcePath, $dropboxPath) = parseArgs("upload-file", $argv, array(array("source-path", "A path to a local file or a URL of a resource."), array("dropbox-path", "The path (on Dropbox) to save the file to.")));
$pathError = dbx\Path::findErrorNonRoot($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$size = null;
if (\stream_is_local($sourcePath)) {
    $size = \filesize($sourcePath);
}
$fp = fopen($sourcePath, "rb");
$metadata = $client->uploadFile($dropboxPath, dbx\WriteMode::add(), $fp, $size);
fclose($fp);
print_r($metadata);
Example #13
0
//define("DBF_HOST", "localhost");
//define("DBF_USER", "ipplan");
//define("DBF_NAME", "ipplan");
//define("DBF_PASSWORD", "ipplan99");
// define the nmap command for normal scan
define("NMAP_CMD", "-sP -PE -q -n -oG");
// define the nmap command for scan with dns lookup
define("NMAP_CMDH", "-sP -PE -q -R -v -oG");
require_once "../adodb/adodb.inc.php";
require_once "../config.php";
$timestamp = FALSE;
$hostnames = FALSE;
$audit = FALSE;
// Set Defaults
// $options["h"]=TRUE;
parseArgs($argv, $options);
// options will be $options["FLAG"] (if not argument is given like -h the
// $options["h"] will be set to bolean true
if (isset($options["a"]) && $options["a"] == TRUE) {
    $audit = TRUE;
}
if (isset($options["time"]) && $options["time"] == TRUE) {
    $timestamp = TRUE;
}
if (isset($options["hostnames"]) && $options["hostnames"] == TRUE) {
    $hostnames = TRUE;
}
if (!isset($options["q"])) {
    if (!empty($_REQUEST)) {
        echo "<br>Mmm, this is a command line utility not to be executed via a web browser! Try the -q option\n";
        exit(1);
Example #14
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['func']) || !is_string($params['func'])) {
        echo <<<EOT
Usage: {$argv['0']} --func=... [...]

Parameters:

--func             renormalize|deduplicate|updatesolr|dump|dumpsolr|markdeleted
                   |deletesource|deletesolr|optimizesolr|count|checkdedup|comparesolr
                   |purgedeleted|markdedup
--source           Source ID to process (separate multiple sources with commas)
--all              Process all records regardless of their state (deduplicate,
                   markdedup)
                   or date (updatesolr)
--from             Override the date from which to run the update (updatesolr)
--single           Process only the given record id (deduplicate, updatesolr, dump)
--nocommit         Don't ask Solr to commit the changes (updatesolr)
--field            Field to analyze (count)
--force            Force deletesource to proceed even if deduplication is enabled for
                   the source
--verbose          Enable verbose output for debugging
--config.section.name=value
                   Set configuration directive to given value overriding any setting
                   in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)
--comparelog       Record comparison output file. N.B. The file will be overwritten
                   (comparesolr)
--dumpprefix       File name prefix to use when dumping records (dumpsolr). Default
                   is "dumpsolr".
--mapped           If set, use values only after any mapping files are processed when
                   counting records (count)
--daystokeep=days  How many last days to keep when purging deleted records
                   (purgedeleted)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $sources = isset($params['source']) ? $params['source'] : '';
        $single = isset($params['single']) ? $params['single'] : '';
        $noCommit = isset($params['nocommit']) ? $params['nocommit'] : false;
        // Solr update, compare and dump can handle multiple sources at once
        if ($params['func'] == 'updatesolr' || $params['func'] == 'dumpsolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $dumpPrefix = $params['func'] == 'dumpsolr' ? isset($params['dumpprefix']) ? $params['dumpprefix'] : 'dumpsolr' : '';
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, '', $dumpPrefix);
        } elseif ($params['func'] == 'comparesolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, isset($params['comparelog']) ? $params['comparelog'] : '-');
        } else {
            foreach (explode(',', $sources) as $source) {
                switch ($params['func']) {
                    case 'renormalize':
                        $manager->renormalize($source, $single);
                        break;
                    case 'deduplicate':
                    case 'markdedup':
                        $manager->deduplicate($source, isset($params['all']) ? true : false, $single, $params['func'] == 'markdedup');
                        break;
                    case 'dump':
                        $manager->dumpRecord($single);
                        break;
                    case 'deletesource':
                        $manager->deleteRecords($source, isset($params['force']) ? $params['force'] : false);
                        break;
                    case 'markdeleted':
                        $manager->markDeleted($source);
                        break;
                    case 'deletesolr':
                        $manager->deleteSolrRecords($source);
                        break;
                    case 'optimizesolr':
                        $manager->optimizeSolr();
                        break;
                    case 'count':
                        $manager->countValues($source, isset($params['field']) ? $params['field'] : null, isset($params['mapped']) ? $params['mapped'] : false);
                        break;
                    case 'checkdedup':
                        $manager->checkDedupRecords();
                        break;
                    case 'purgedeleted':
                        if (!isset($params['force']) || !$params['force']) {
                            echo <<<EOT
Purging of deleted records means that any further Solr updates don't include
deletions. Use the --force parameter to indicate that this is ok. No records
have been purged.

EOT;
                            exit(1);
                        }
                        $manager->purgeDeletedRecords(isset($params['daystokeep']) ? intval($params['daystokeep']) : 0);
                        break;
                    default:
                        echo 'Unknown func: ' . $params['func'] . "\n";
                        exit(1);
                }
            }
        }
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
Example #15
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
/* @var dbx\Client $client */
/* @var string $dropboxPath */
list($client, $dropboxPath) = parseArgs("link", $argv, array(array("dropbox-path", "The path (on Dropbox) to create a link for.")));
$pathError = dbx\Path::findError($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$link = $client->createShareableLink($dropboxPath);
print $link . "\n";
Example #16
0
                } else {
                    $chars = str_split(substr($arg, 1));
                    foreach ($chars as $char) {
                        $key = $char;
                        $out[$key] = isset($out[$key]) ? $out[$key] : true;
                    }
                }
            } else {
                $out[] = $arg;
            }
        }
    }
    return $out;
}
// Get the passed args.
$options = parseArgs($argv);
// Specify --env= in the cron, otherwise it will be set to production by default.
// Then unset the value so it doesn't get in the way of building the li3 command.
$env = isset($options['env']) ? $options['env'] : 'production';
if (isset($options['env'])) {
    unset($options['env']);
}
// This script is meant to be in the root of the application.
// If it is not, then --path= must be passed with the full path to the app.
$li3_app_path = isset($options['path']) ? $options['path'] : __DIR__;
if (isset($options['path'])) {
    unset($options['path']);
}
// This can be helpful if you want to test the call before putting it in crontab.
// Just call the same command you'd set in cron with --verbose passed and you'll see output.
$verbose = isset($options['verbose']) ? true : false;
Example #17
0
    $assid = $incident[0]['assignment_group'];
    $callid = $incident[0]['caller_id'];
    $location = $incident[0]['location'];
    //EDIT KA SCS Assignment Group, SCS Category and SCS Subcagetory
    $params = array('sys_id' => "{$sysid}", 'comments' => "{$message}", 'description' => 'Aspera API Creation Site', 'location' => "{$location}", 'category' => "Support", 'u_scs_category' => 'Data Transfer', 'u_scs_subcategory' => 'Run Service', 'assignment_group' => "{$assid}", 'caller_id' => "{$callid}");
    try {
        $result = $inc->update($params);
    } catch (Exception $e) {
        echo 'Exception: ' . $e->getMessage() . "\n";
        exit(4);
    }
}
/*
*      MAIN
*/
$cmdinput = parseArgs($argv);
if (isset($cmdinput['create'])) {
    $create = $cmdinput['create'];
    // no email sent with create argument default to scs
    if ($create == 1) {
        $create = '*****@*****.**';
    }
    $sysid = newIncident($create);
    print "{$sysid}\n";
} elseif (isset($cmdinput['update']) && isset($cmdinput['attach'])) {
    $update = $cmdinput['update'];
    $payload = $cmdinput['attach'];
    Attachment($update, $payload);
} elseif (isset($cmdinput['update']) && !isset($cmdinput['attach']) && isset($cmdinput['message'])) {
    $update = $cmdinput['update'];
    $message = $cmdinput['message'];
Example #18
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
list($client, $cursor) = parseArgs("delta", $argv, array(), array(array("cursor", "The cursor returned by the previous delta call (optional).")));
$deltaPage = $client->getDelta($cursor);
$numAdds = 0;
$numRemoves = 0;
foreach ($deltaPage["entries"] as $entry) {
    list($lcPath, $metadata) = $entry;
    if ($metadata === null) {
        echo "- {$lcPath}\n";
        $numRemoves++;
    } else {
        echo "+ {$lcPath}\n";
        $numAdds++;
    }
}
echo "Num Adds: {$numAdds}\n";
echo "Num Removes: {$numRemoves}\n";
echo "Has More: " . $deltaPage["has_more"] . "\n";
echo "Cursor: " . $deltaPage["cursor"] . "\n";
Example #19
0
function serializeArgsType($namespace, $func, $indent)
{
    global $cpp_keywords, $derived_types, $typeset, $current_server;
    $args = @$func->args;
    //there is not args anymore
    if (!$args) {
        return;
    }
    $args_set = parseArgs(@$func->args);
    $argsTyName = getArgsType($func->name);
    if (count($args_set) == 1) {
        return;
    }
    $tp_name = "{$current_server}::{$argsTyName}";
    if (@$derived_types[$current_server][$argsTyName]) {
        return;
    }
    //there are args here
    //put
    echo "{$indent}\nCERL_IO_BEGIN_PUTTER({$namespace}::{$argsTyName})\n";
    $indent2 = $indent . "\t";
    foreach ($args as $arg) {
        $var_member = "val.{$arg->name}";
        echo "{$indent2}NS_CERL_IO::put(os, {$var_member});\n";
    }
    echo "{$indent}CERL_IO_END_PUTTER()\n";
    //get
    echo "\n";
    echo "{$indent}CERL_IO_BEGIN_GETTER({$namespace}::{$argsTyName})\n";
    $indent2 = $indent . "\t";
    $indent3 = $indent2 . "\t";
    echo "{$indent2}return ";
    $i = 0;
    foreach ($args as $arg) {
        $var_member = "val.{$arg->name}";
        if ($i++ == 0) {
            echo "NS_CERL_IO::get(is, {$var_member})";
        } else {
            echo "\n{$indent3}&& NS_CERL_IO::get(is, {$var_member})";
        }
    }
    echo ";\n";
    echo "{$indent}CERL_IO_END_GETTER()\n";
    //copy
    //printPODTYPE($args);
    $podTrue = true;
    echo "\n{$indent}template <class AllocT>\n";
    echo "{$indent}inline void copy(AllocT& alloc, {$namespace}::{$argsTyName}& dest, const {$namespace}::{$argsTyName}& src)\n";
    echo "{$indent}{\n";
    echo "{$indent2}dest = src;\n";
    foreach ($args as $arg) {
        if (!isPOD($arg->type)) {
            echo "{$indent2}NS_CERL_IO::copy(alloc, dest.{$arg->name}, src.{$arg->name});\n";
            $podTrue = false;
        }
    }
    echo "{$indent}}\n";
    if ($podTrue) {
        echo "{$indent}CERL_PODTYPE({$namespace}::{$argsTyName}, true);\n";
    } else {
        echo "{$indent}CERL_PODTYPE({$namespace}::{$argsTyName}, false);\n";
    }
    //dump
    echo "\ntemplate<class LogT>\n";
    echo "inline void dump(LogT& log, const {$namespace}::{$argsTyName}& args)\n";
    echo "{\n";
    echo "\tNS_CERL_IO::dump(log, '{');\n";
    $i = 0;
    foreach ($args as $var) {
        if ($i++ == 0) {
            echo "\tNS_CERL_IO::dump(log, args.{$var->name});\n";
        } else {
            echo "\tNS_CERL_IO::dump(log, \", \");\n";
            echo "\tNS_CERL_IO::dump(log, args.{$var->name});\n";
        }
    }
    echo "\tNS_CERL_IO::dump(log, '}');\n";
    echo "}\n";
}
Example #20
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
list($client, $dropboxPath, $localPath) = parseArgs("download-file", $argv, array(array("dropbox-path", "The path of the file (on Dropbox) to download."), array("local-path", "The local path to save the downloaded file contents to.")));
$pathError = dbx\Path::findErrorNonRoot($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$metadata = $client->getFile($dropboxPath, fopen($localPath, "wb"));
if ($metadata === null) {
    fwrite(STDERR, "File not found on Dropbox.\n");
    die;
}
print_r($metadata);
echo "File contents written to \"{$localPath}\"\n";
Example #21
0
<?php

require __DIR__ . '/../lib/bootstrap.php';
ini_set('xdebug.max_nesting_level', 3000);
// Disable XDebug var_dump() output truncation
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
ini_set('xdebug.var_display_max_depth', -1);
list($operations, $files) = parseArgs($argv);
/* Dump nodes by default */
if (empty($operations)) {
    $operations[] = 'dump';
}
if (empty($files)) {
    showHelp("Must specify at least one file.");
}
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative());
$dumper = new PhpParser\NodeDumper();
$prettyPrinter = new PhpParser\PrettyPrinter\Standard();
$serializer = new PhpParser\Serializer\XML();
$traverser = new PhpParser\NodeTraverser();
$traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver());
foreach ($files as $file) {
    if (strpos($file, '<?php') === 0) {
        $code = $file;
        echo "====> Code {$code}\n";
    } else {
        if (!file_exists($file)) {
            die("File {$file} does not exist.\n");
        }
        $code = file_get_contents($file);
<?php

require_once __DIR__ . "/../../../autoload.php";
require_once __DIR__ . "/functions.php";
use Terah\Utils\StringUtils;
$argv = parseArgs($_SERVER);
if (!defined("STDERR")) {
    die("Only on cli please.");
}
class MyPdo extends \PDO
{
}
$class = new ReflectionClass($argv['class']);
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
foreach (generateMethodDocs($methods, '') as $line) {
    echo $line;
}
/**
 * @param ReflectionMethod[] $methods
 * @param string $flags
 * @param string $prefix
 * @return array
 */
function generateMethodDocs($methods, $flags, $prefix = '')
{
    $lines = [];
    foreach ($methods as $method) {
        $doc = $method->getDocComment();
        $doc = $doc ? explode("\n", $doc) : [];
        $return = '';
        foreach ($doc as $line) {
                    $currentTemplate->fullPath = '';
                    $currentTemplate->fullPath = $template->scalarValue;
                    // view file may have an extension; if it has an extension use that; otherwise use the default (.php)
                    if (stripos($currentTemplate->fullPath, '.') === FALSE) {
                        $currentTemplate->fullPath .= '.php';
                    }
                    // not using realpath() so that Triumph can know that a template file has not yet been created
                    // or the programmer has a bug in the project.
                    $currentTemplate->fullPath = \opstring\replace($currentTemplate->fullPath, '/', DIRECTORY_SEPARATOR);
                    $currentTemplate->fullPath = \opstring\replace($currentTemplate->fullPath, '\\', DIRECTORY_SEPARATOR);
                    $currentTemplate->fullPath = $sourceDir . 'app' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $currentTemplate->fullPath;
                    $allTemplates[] = $currentTemplate;
                }
                // argument 2 is an array of template variables
                if (isset($variableCalls[$call->functionArguments[1]])) {
                    $variableCall = $variableCalls[$call->functionArguments[1]];
                    $arrayKeys = $callStackTable->getArrayKeys($scope, $variableCall->destinationVariable);
                    foreach ($arrayKeys as $key) {
                        // add the siguil here; editor expects us to return variables
                        $currentTemplate->variables[] = '$' . $key;
                    }
                    $allTemplates[count($allTemplates) - 1] = $currentTemplate;
                }
            }
        }
    }
    return $allTemplates;
}
// start running this script
parseArgs();
Example #24
0
$defaultRecipient = "*****@*****.**";
$defaultSender = "*****@*****.**";
$defaultSenderName = "Your Name";
//SMTP server identifiers
$username = "******";
$password = "******";
$host = "ssl://smtp.yourhost.com";
$port = 465;
$redirectURL = "http://pagetoloadaftersendingemail.com";
//Main
if (isset($_POST['input']) && !empty($_POST['input']) || isset($_GET['input']) && !empty($_GET['input'])) {
    require "phpmailer/class.phpmailer.php";
    if (isset($_POST['input'])) {
        $params = parseArgs($_POST['input']);
    } else {
        $params = parseArgs(utf8_decode($_GET['input']));
    }
    $recipientName = "";
    $bOK = true;
    foreach ($params as $key => $value) {
        switch ((string) $key) {
            case '0':
                $subject = $value;
                break;
            case 'r':
                $recipients = $value;
                break;
            case 'm':
                $message = $value;
                break;
            default:
Example #25
0
<?php

// >> Получаем параметры из консоли в виде: --username=логинадмин --password=парольадмин --multiply=умножитьначисло --divide=делитьначисло
$arguments = parseArgs($_SERVER, $_REQUEST);
$admin['username'] = $admin['password'] = '';
// логин/пароль
if (isset($arguments['username']) && isset($arguments['password'])) {
    $admin['username'] = $arguments['username'];
    $admin['password'] = $arguments['password'];
}
// умножить
if (isset($arguments['multiply'])) {
    $from_console['multiply'] = $arguments['multiply'];
}
// делить
if (isset($arguments['divide'])) {
    $from_console['divide'] = $arguments['divide'];
}
// если параметры пусты, то ставим по умолчанию
if (($admin['username'] == '' || $admin['username'] == '1') && ($admin['password'] == '' || $admin['password'] == '1')) {
    $admin['username'] = '******';
    $admin['password'] = '******';
}
// << Получаем параметры из консоли
// >> Подключаем
define('MODX_API_MODE', true);
if (file_exists(dirname(dirname(dirname(dirname(__FILE__)))) . '/index.php')) {
    require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/index.php';
} else {
    require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/index.php';
}
Example #26
0
                }
            }
        }
    }
    return $arguments;
}
try {
    if (empty($_SERVER['argv'][1])) {
        throw new Exception('Please specify the environment');
    }
    if (getenv('NO_COLOR')) {
        Est_CliOutput::$active = false;
    }
    $env = $_SERVER['argv'][1];
    $settingsFile = empty($_SERVER['argv'][2]) ? '../settings/settings.csv' : $_SERVER['argv'][2];
    $processor = new Est_Processor($env, $settingsFile, parseArgs());
    try {
        $res = $processor->apply();
        $processor->printResults();
    } catch (Exception $e) {
        $processor->printResults();
        echo "\n\n\n";
        echo Est_CliOutput::getColoredString('ERROR: Stopping execution because an error has occured!', 'red') . "\n";
        echo Est_CliOutput::getColoredString("Detail: {$e->getMessage()}", 'red') . "\n";
        echo "Trace:\n{$e->getTraceAsString()}\n";
        exit(1);
    }
} catch (Exception $e) {
    echo "\n" . Est_CliOutput::getColoredString("ERROR: {$e->getMessage()}", 'red') . "\n\n";
    echo "\nERROR: {$e->getMessage()}\n";
    exit(1);
Example #27
0
</form>
</body>
</html>
<?php 
    if (!isset($_POST['submit'])) {
        //This die() is to stop the rest of the script being loaded if the form has not yet been submitted and they're using gui. It looks bad but you should leave it here.
        die;
    }
}
//End form
require_once ROOT_PATH . '/base/load.php';
if (isGUI) {
    $argv = $_POST;
} else {
    $argv = parseArgs($argv);
}
Banner();
CheckRequirement();
Config::handle($argv);
if (Config::get('help')) {
    Help();
    exit;
}
if (Config::get('version')) {
    check_version();
    exit;
}
if (Config::get('upgrade')) {
    download();
    exit;
    if (isset($_POST['areaCode']) && $_POST['areaCode'] != "") {
        $optArgs->setAreaCode($_POST['areaCode']);
    }
    if (isset($_POST['country']) && $_POST['country'] != "") {
        $optArgs->setCountry($_POST['country']);
    }
    if (isset($_POST['latitude']) && $_POST['latitude'] != "") {
        $optArgs->setLatitude($_POST['latitude']);
    }
    if (isset($_POST['longitude']) && $_POST['longitude'] != "") {
        $optArgs->setLongitude($_POST['longitude']);
    }
    return $optArgs;
}
$arr = null;
try {
    envinit();
    $adsService = new ADSService(getFqdn(), getFileToken());
    $category = $_POST['category'];
    $optArgs = parseArgs();
    $result = $adsService->getAdvertisement($category, $userAgent, $udid, $optArgs);
    if ($result === null) {
        $arr = array('success' => true, 'text' => 'No Ads were returned');
    } else {
        $arr = array('success' => true, 'tables' => array(array('caption' => 'Ads Response:', 'headers' => array('Type', 'ClickUrl'), 'values' => array(array($result->getAdsType(), $result->getClickUrl())))));
    }
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Example #29
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
list($client, $dropboxPath) = parseArgs("get-metadata", $argv, array(array("dropbox-path", "The path (on Dropbox) that you want metadata for.")));
$pathError = dbx\Path::findError($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$metadata = $client->getMetadataWithChildren($dropboxPath);
if ($metadata === null) {
    fwrite(STDERR, "No file or folder at that path.\n");
    die;
}
// If it's a folder, remove the 'contents' list from $metadata; print that stuff out after.
$children = null;
if ($metadata['is_dir']) {
    $children = $metadata['contents'];
    unset($metadata['contents']);
}
print_r($metadata);
if ($children !== null && count($children) > 0) {
    print "Children:\n";
    foreach ($children as $child) {
        $name = dbx\Path::getName($child['path']);
        if ($child['is_dir']) {
            $name = "{$name}/";
        }
        // Put a "/" after folder names.
        print "- {$name}\n";
Example #30
0
<?php

/**
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 * @author        Terry Cullen - terry@terah.com.au
 */
require_once __DIR__ . "/../../../autoload.php";
require_once __DIR__ . "/functions.php";
require_once __DIR__ . "../src/Inflector.php";
use Terah\FluentPdoModel\Inflector;
$params = parseArgs($_SERVER);
function generateModel($table, $allColumns, $foreignKeys, $modelsPath)
{
    $columns = $allColumns[$table];
    $params = ['table' => $table, 'class_name' => Inflector::classify($table), 'validations' => generateValidationRules($columns), 'columns' => getPrettyColumns($columns), 'display_col' => getDisplayColumn($columns), 'auto_joins' => !empty($foreignKeys['foreign_keys'][$table]) ? getAutoJoins($foreignKeys['foreign_keys'][$table], $allColumns) : ''];
    $output = renderTemplate($params);
    //$associations  = '';//static::generateAssociations($table, $foreignKeys, $columns);
    $file = $modelsPath . $params['class_name'] . '.php';
    $keep = file_exists($file) ? StringUtils::between('//START', '//END', file_get_contents($file)) : '';
    $keep = trim($keep);
    $tpl = str_replace('//START//END', "//START\n\n\t{$keep}\n\n    //END", $output);
    FileUtils::createDirectoriesAndSaveFile($file, $tpl);
}
function generateValidationRules($columns)
{
    $rules = [];