Esempio n. 1
0
 public static function GetArrVal($arr)
 {
     if (self::$console_activated === "true" || self::$external_logs === "true") {
         $get_args_info = check_args(__FUNCTION__);
         $get_nb_arg_sent = func_num_args();
         self::$fct_nb_args = $get_args_info[0];
         self::$fct_nb_args_need = $get_args_info[1];
         $args_validity = self::check_arg_validity($arr, $get_nb_arg_sent, self::$fct_nb_args_need);
         if ($args_validity == true) {
             if (is_array($arr)) {
                 //♪Conversion du tableau PHP en JSON
                 $arr = json_encode($arr);
                 self::write_log("print", $arr);
             } else {
                 //♪Ce n'est pas un tableau
                 self::errors(2, __FUNCTION__, self::$fct_nb_args_need);
             }
         } else {
             self::errors(5, __FUNCTION__, self::$fct_nb_args_need);
         }
     }
 }
#!/usr/bin/php
<?php 
require_once 'cliCommon.php';
require_once 'dbConnect.php';
ini_set('display_errors', 1);
ini_set('ERROR_REPORTING', E_WARNING);
error_reporting(E_ALL);
$args = array('input_file' => '');
$switches = array();
check_args($argc, $argv, $args, $switches);
//$host = 'localhost';
// Open input and output files
$inputFile = fopen($args['input_file'], 'r');
if ($inputFile === FALSE) {
    die("Could not open input file.\n");
    exit;
}
$db = connectToDb();
if (!$db) {
    die('Could not connect to database.\\n');
}
// Parse CSV input into fields line by line
while (($line = fgetcsv($inputFile, 0, '|')) !== FALSE) {
    foreach ($line as $key => $element) {
        $line[$key] = pg_escape_string($element);
    }
    $bannerId = $line[0];
    if ($bannerId == '') {
        continue;
    }
    $firstName = $line[2];
Esempio n. 3
0
//define ('cue_encoding', 'ISO-8859-1');
define('N', "\n");
define('T', "\t");
define('R', "\r");
print '[ ' . script_name . ' ]' . N . N;
// current dir (in use if not defined custom)
$pwd = getcwd();
// $path = dirname(__FILE__);
// for function check_args
$allowed_args = array('/^-h$/', '/^-v$/', '/^-vv$/', '/^-r$/', '/^-f$/', '/^-ro$/', '/^-nl$/', '/^-tl$/', '/^-sf$/', '/^-st$/', '/^[\\w\\/~\\.а-я].*$/iu');
// for function search_ext
$dany_folders = array('.', '..');
// for function search name on last.fm
$hide_realese_info = 'remaster|антология';
$args = get_args();
check_args();
$target = isset($args['path']) ? $args['path'] : $pwd;
$recurs = isset($args['-r']);
printvv(N . 'Путь к папке: ' . $target . N . N);
printvv(N . 'Рекурсивно: ' . ($recurs ? 'Да' : 'Нет') . N . N);
$apes = search_ext('ape', $target, $recurs);
printvv('Найдены файлы:' . N);
var_dump_vv($apes);
foreach ($apes as $ape_file) {
    printv(N);
    printv('Обрабатываем файл: ' . $ape_file . N);
    /*if (($cue = search_cue($ape_file)))
    	{
    		printv(N);
    		printv('Найден файл: ' . $cue . N);*/
    if (!isset($args['-ro'])) {
Esempio n. 4
0
function doit()
{
    global $argv;
    global $url, $token, $host, $service, $state, $output, $type, $checktype, $usestdin;
    global $delim;
    $type = "host";
    // get and check command line args
    check_args(parse_argv($argv));
    /*
    echo "URL=$url\n";
    echo "TOKEN=$token\n";
    echo "TYPE=$type\n";
    echo "CHECKTYPE=$checktype\n";
    echo "HOST=$host\n";
    echo "SERVICE=$service\n";
    echo "STATE=$state\n";
    echo "OUTPUT=".$output."\n";
    */
    $hostchecks = array();
    $servicechecks = array();
    // process single check from command line
    if ($host != "") {
        // service check
        if ($service != "") {
            $newc = array("hostname" => $host, "servicename" => $service, "state" => $state, "output" => $output);
            $servicechecks[] = $newc;
        } else {
            $newc = array("hostname" => $host, "state" => $state, "output" => $output);
            $hostchecks[] = $newc;
        }
    }
    // use read from stdin
    if ($usestdin != "") {
        //echo "READING FROM STDIN\n";
        while ($buf = rtrim(fgets(STDIN), "\n")) {
            //echo "READ: $buf\n";
            $parts = explode("\t", $buf);
            //print_r($parts);
            $fields = count($parts);
            // host check
            if ($fields == 3) {
                $hostname = $parts[0];
                $state = $parts[1];
                $output = $parts[2];
                $newc = array("hostname" => $hostname, "state" => $state, "output" => $output);
                $hostchecks[] = $newc;
            } else {
                if ($fields == 4) {
                    $hostname = $parts[0];
                    $servicename = $parts[1];
                    $state = $parts[2];
                    $output = $parts[3];
                    $newc = array("hostname" => $hostname, "servicename" => $servicename, "state" => $state, "output" => $output);
                    $servicechecks[] = $newc;
                }
            }
        }
    }
    // craft the XML to send
    $checkresultopts = "";
    $checkresultopts = " checktype='" . $checktype . "'";
    $xml = "<?xml version='1.0'?> \r\n<checkresults>\r\n";
    foreach ($hostchecks as $hc) {
        $hostname = $hc["hostname"];
        $state = $hc["state"];
        $output = $hc["output"];
        $xml .= "\r\n\t<checkresult type='host' " . $checkresultopts . ">\r\n\t\t<hostname>" . htmlentities($hostname) . "</hostname>\r\n\t\t<state>" . $state . "</state>\r\n\t\t<output>" . htmlentities($output) . "</output>\r\n\t</checkresult>\r\n\t\t";
    }
    foreach ($servicechecks as $sc) {
        $hostname = $sc["hostname"];
        $servicename = $sc["servicename"];
        $state = $sc["state"];
        $output = $sc["output"];
        $xml .= "\r\n\t<checkresult type='service' " . $checkresultopts . ">\r\n\t\t<hostname>" . htmlentities($hostname) . "</hostname>\r\n\t\t<servicename>" . htmlentities($servicename) . "</servicename>\r\n\t\t<state>" . $state . "</state>\r\n\t\t<output>" . htmlentities($output) . "</output>\r\n\t</checkresult>\r\n\t\t";
    }
    $xml .= "\r\n</checkresults>\r\n";
    //echo "XML=\n$xml\n";
    //exit();
    // build url
    $theurl = $url . "/?token=" . $token . "&cmd=submitcheck&XMLDATA=" . urlencode($xml);
    //echo "URL=$theurl\n";
    // send data to NRDP
    $opts = array("method" => "post", "timeout" => 30, "return_info" => true);
    $result = load_url($theurl, $opts);
    //echo "RESULT=\n";
    //print_r($result);
    exit(0);
}
            print_log('Link        : ' . $xml['Links']['Link'], '+', 1, false);
            print_log('Delete Link : ' . $xml['Links']['DelLink'], '+', 1, false);
            print_log('---------------------------------------------------------------------------', '+', 1, true);
        } else {
            if (array_key_exists('Error', $xml)) {
                print_log('Cannot compile uploaded file. (Reason: ' . $xml['Error'] . '). Exit', 'do_get_links', 0, true);
            } else {
                print_log('Invalid responds. (Reason: unknown XML). Exit', 'do_get_links', 0, true);
            }
        }
    } else {
        print_log('Invalid responds. Exit', 'do_get_links', 0, true);
    }
}
if (!empty($argv[1])) {
    $filepath = $argv[1];
}
if (check_args()) {
    if (!file_exists($filepath)) {
        print_log('File is not exists. Exit.', '', 0, true);
    }
    $chkpath = str_split($filepath);
    if ($chkpath[0] != '/') {
        print_log('Path must be an absolute/full path. Exit.', 'check_path', 0, true);
    }
    remove_link();
    create_link();
    get_auth();
} else {
    print_log('Must be execute with \'path filename\' arguments. Exit.', 'check_args', 0, true);
}
Esempio n. 6
0
<?php

ob_implicit_flush(true);
define('FRAMEWORK_ROOT', substr(__FILE__, 0, -24) . 'framework' . DIRECTORY_SEPARATOR);
$project_types = array('web');
$argmap = array('name' => array('short' => 'n', 'required' => true), 'path' => array('short' => 'p', 'required' => true), 'type' => array('short' => 't', 'default' => 'web', 'required' => true), 'charset' => array('short' => 'c', 'default' => 'utf-8', 'required' => true), 'deploydir' => array('short' => 'd', 'default' => array('web' => './www'), 'required' => true));
$input_args = get_args();
$args = check_args($input_args, $argmap);
if (!is_dir($args['path'])) {
    throw new Exception(sprintf('%s isn\'t a dir', $args['path']));
}
$project_dir = trim($args['path'], '/\\') . DIRECTORY_SEPARATOR . $args['name'] . DIRECTORY_SEPARATOR;
if (is_dir($project_dir)) {
    throw new Exception(sprintf('%s is already existed', $project_dir));
}
if (!mkdir($project_dir)) {
    throw new Exception(sprintf('can\'t create dir %s', $project_dir));
}
if (!in_array($args['type'], $project_types)) {
    throw new Exception(sprintf('incognizant project type %s', $args['type']));
}
$deploydir = is_array($args['deploydir']) ? $args['deploydir'][$args['type']] : $args['deploydir'];
$deploydir = 0 === strpos($deploydir, './') ? $project_dir . substr($deploydir, 2) : $deploydir;
$deploydir = trim($deploydir, '/\\') . DIRECTORY_SEPARATOR;
if (is_dir($deploydir)) {
    throw new Exception(sprintf('%s is already existed', $deploydir));
}
if (!mkdir($deploydir)) {
    throw new Exception(sprintf('can\'t create deploy dir %s', $deploydir));
}
copy_dir("./template/{$args['type']}/project", $project_dir);