$output = array(); exec("which notify-send", $output); if (!empty($output[0]) && file_exists(trim($output[0]))) { define("WPS_LIBNOTIFY_PATH", trim($output[0])); } // Timezone date_default_timezone_set('UTC'); // HOME if (empty($_SERVER['HOME'])) { echo Colours::fg('brown') . "Warning: " . Colours::fg("white") . "Unable to find a HOME environment variable. Paths containing ~ may not be found .\n"; } // // Parse and validate arguments // // If the user specified invalid options, this will not return $options = parse_arguments($argv); // Emit help, if required, and then exit if (isset($options['h']) || isset($options['help'])) { usage(); } // Capture the path to WordPress, if given if (!empty($argv[0])) { $options['wp-root'] = $argv[0]; } // Is there a mime.types file? if (!file_exists($options['mime-file'])) { $local_fallback = dirname(__FILE__) . '/etc/mime.types'; if (!file_exists($options['mime-file'])) { die_with_error("Unable to find file {$options['mime-file']}, and failed to load fallback", "You can obtain the most recent mime file here:\n\n http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types\n\nInstruct Whippet to use this file using the --mime-file argument, or save it to /etc/mime.types"); } else { $options['mime-file'] = $local_fallback;
} /** * Builds a file path with the appropriate directory separator. * * @param ...$segments Unlimited number of path segments. * * @return The file path built from the path segments. */ function build_path(...$segments) { return join(DIRECTORY_SEPARATOR, $segments); } /* * Main script */ if (parse_arguments() === false) { print_usage(); echo PHP_EOL; print_help(); exit(1); } // Check that source exists and is readable if (!file_exists($path) || !is_readable($path)) { error_log('[ERROR] The given path does not exist or cannot be read.'); exit(1); } $csvexporter = null; // Determine whether source is a file or a directory if (is_file($path)) { try { $csvexporter = new CSVExporter($format, $nodefile, $relfile);
function parse_arguments($args) { $arguments = new stdClass(); $arguments->flags = array(); $arguments->file = null; foreach ($args as $arg) { if (strpos($arg, '--') === 0) { list($flag_name, $flag_value) = explode('=', substr($arg, 2)); $arguments->flags[$flag_name] = $flag_value; } else { $arguments->file = $arg; } } return $arguments; } $arguments = parse_arguments(array_slice($argv, 1)); $input = isset($arguments->file) ? file($arguments->file) : file('php://stdin'); if (empty($input)) { die('No input given.'); } if (!isset($arguments->flags['format'])) { die('No input format specified.'); } if (!isset($arguments->flags['table'])) { die('Please specify a table with --table=<table name>'); } if (!isset($arguments->flags['types'])) { die('Please specify the column data types with --types=ssii..'); } $table = $arguments->flags['table']; if ($arguments->flags['format'] !== 'tsv') {
* Title: Application for download (with auth) files from Bitrix sites * Author: Aleksandr Novikov * Email: pwsdotru@gmail.com * WWW: http://pwsdotru.com/ * GIT: https://github.com/pwsdotru/bitrix_downloader */ define("VERSION", "1.0"); define("APP_NAME", "Bitrix Downloader"); error_reporting(E_ALL); $params = array("v|version" => "Display version and exit", "h|help" => "Display this help message", "d|debug" => "Display debug information", "u|user=USERNAME" => "Username for login to site", "p|password=PASSWORD" => "Password for user", "o|out=FILE" => "Filename for save file"); $script_filename = basename($argv[0]); //Run without parameters if ($argc <= 1) { show_banner($script_filename, $params); } else { $arguments = parse_arguments($argv, $keys = parse_keys($params)); if ($arguments && is_array($arguments) && count($arguments) > 0) { if (isset($arguments["h"]) || isset($arguments["help"])) { show_banner($script_filename, $params, false); } elseif (isset($arguments["v"]) || isset($arguments["version"])) { show_version(); } } else { show_banner($script_filename, $params); } } exit; /** * FUNCTIONS */ /**
-p <remote_pass> The password for the remote server -c <local_path> The path to the local collection, e.g. /username/home/ note that any part of the local URL up to and including 'caldav.php' should be omitted. Other Options: -w remote If set to 'remote' and changes are seen in both calendars, the remote server will 'win' the argument. Any other value and the default will apply in that the changes on the local server will prevail. -i Sync inwards only. -o Sync outwards only EOUSAGE; exit(0); } parse_arguments(); if (!isset($args->url)) { usage(); } if (!isset($args->user)) { usage(); } if (!isset($args->pass)) { usage(); } if (!isset($args->local_collection_path)) { usage(); } if (!preg_match('{/$}', $args->local_collection_path)) { $args->local_collection_path .= '/'; }
} else { if (in_array($status, array(0, Generator::$NEW_TABLE)) || $opts["force"] === true) { foreach ($sql as $line) { $orm::get_db()->exec($line); } echo "Up to date." . PHP_EOL; } else { switch ($status) { case Generator::$FIELD_MOD: echo "One of fields modified. Use --force if you really want to modify it." . PHP_EOL; break; } } } } $opts = parse_arguments($argv); if (array_key_exists("help", $opts)) { echo "AutoParis scheme generator, version 0.1" . PHP_EOL . PHP_EOL; echo "--sql - display only sql" . PHP_EOL; echo "--model=[MODEL] - process only MODEL" . PHP_EOL; echo "--force - force update" . PHP_EOL; echo PHP_EOL . "http://shadowprince.github.com/autoparis" . PHP_EOL; } else { if (array_key_exists("model", $opts)) { update_model($opts["model"], ORM, $opts); } else { foreach (lookup_models() as $model) { update_model($model, ORM, $opts); echo PHP_EOL; } }