Example #1
0
/**
 * Récupère la liste de tous les sites à analyser.
 * 
 * @param array $listeSourcesSupportees La liste des sites déclarés comme analysables.
 * @return array Un tableau contenant tous les sites à analyser sous la forme :
 * <pre>
 * [
 *   'vgOrg' => 
 *     [
 *       0 => '59'
 *       1 => '62'
 *     ]
 *   'sbdCom' => 
 *     [
 *       0 => '59-nord/l/lille'
 *       1 => '62-pas-de-calais/l/le-touquet-paris-plage'
 *     ]
 * ]
 * </pre>
 */
function getSources($listeSourcesSupportees)
{
    $listeSources = array();
    // récupération des sources et des paramètres associés
    foreach ($_GET as $codeSrc => $paramsSrc) {
        // si le paramètre est présent dans la liste des sites supportés
        if (in_array($codeSrc, array_keys($listeSourcesSupportees))) {
            // alors on l'ajoute à la liste des sources à analyser
            $listeSources[$codeSrc] = $paramsSrc;
        }
    }
    // vérification de la présence d'au moins une source
    if (empty($listeSources)) {
        echo "Aucune source n'a été paramétrée. Les sources supportées sont [" . implode(', ', array_keys($listeSourcesSupportees)) . "].";
        printUsage();
        exit - 1;
    }
    $listeRetour = array();
    // validation des paramètres des sites à analyser
    foreach ($listeSources as $codeSrc => $paramsSrcText) {
        $paramsSrcArray = explode("|", $paramsSrcText);
        foreach ($paramsSrcArray as $param) {
            if (!preg_match($listeSourcesSupportees[$codeSrc]["pattern"], $param)) {
                echo "Le paramètre [" . $param . "] n'est pas au format attendu.";
                printUsage();
                exit - 1;
            } else {
                // ajout de la source à la liste des pages à analyser
                $listeRetour[$codeSrc] = $paramsSrcArray;
            }
        }
    }
    return $listeRetour;
}
Example #2
0
function printHelp()
{
    printUsage();
    print '  [params] can be one of the following:' . PHP_EOL;
    print '  create:app [[appName]]' . PHP_EOL;
    print '  create:module [moduleName] [[appName]]' . PHP_EOL;
    print '  create:action [actionType:actionName] [moduleName] [[appName]]' . PHP_EOL;
}
/**
 * Parses (and checks some) command line arguments
 */
function parseArguments()
{
    global $checkOptions, $cmdargs, $checksEnabled, $periods, $periodsEnabled, $argc, $argv;
    if ($argc == 1) {
        printUsage(true);
        exit(STATUS_UNKNOWN);
    }
    $i = 1;
    while ($i < $argc) {
        if ($argv[$i][0] != '-') {
            $i++;
            continue;
        }
        switch ($argv[$i][1]) {
            case 'V':
                printVersion();
                exit(STATUS_OK);
                break;
            case 'v':
                $cmdargs['log_level'] = LOG__VERBOSE;
                $i++;
                break;
            case 'd':
                $cmdargs['log_level'] = LOG__DEBUG;
                $i++;
                break;
            case 'c':
                $cmdargs['community'] = $argv[$i + 1];
                $i++;
                break;
            case 'h':
                $cmdargs['host'] = $argv[$i + 1];
                $i++;
                break;
            case 'p':
                $cmdargs['port'] = $argv[$i + 1];
                $i++;
                break;
            case '?':
                printHelp();
                exit(STATUS_OK);
                break;
            default:
                if (!isset($argv[$i + 1]) || substr($argv[$i + 1], 0, 1) == '-') {
                    $cmdargs[substr($argv[$i], 2)] = true;
                } else {
                    $cmdargs[substr($argv[$i], 2)] = $argv[$i + 1];
                }
                $i++;
                break;
        }
    }
}
    print "-";
} else {
    print $forms;
}
?>
</td>
</tr>
<tr>
	<td valign="top"><strong><?php 
print T_("Word usage in this synset:");
?>
</strong></td>
	<td valign="top">
		<?php 
if ($auth->auth["uid"] == "nobody") {
    printUsage();
} else {
    buttons();
}
?>
	</td>
</tr>
<tr>
	<td valign="top"><strong><?php 
print T_("Antonym:");
?>
</strong></td>
	<td>
	<?php 
$antonym_array = getAntonym($db, uservar('wmid'));
$antonym_word = "";
Example #5
0
                 $help = true;
                 break;
             case "--userstats":
                 $userstats = true;
                 break;
         }
     }
 }
 if ($style) {
     $storage->style_check = true;
 }
 if ($warnings) {
     $storage->warnings = true;
 }
 if ($help || $option_errors) {
     printUsage($argv);
 } else {
     $files = recursive_listdir($dir);
     $storage->processCode($files);
     if ($least_empty) {
         topTenEmpty($storage->codes);
     }
     if ($top_lines) {
         topTenLines($storage->codes);
     }
     if ($least_comments) {
         topTenComments($storage->codes);
     }
     if ($changes) {
         printChanges($storage->codes);
     }
/**
* Prints the supplied string to "standard error" (STDERR) instead of the "standard output" (STDOUT) stream
*
* @param string	$source_csv_filename		The CSV import file containing the asset attribute and metadata field specifications
* @param string	$asset_type_code			The Matrix asset type code or the assets which are to be created
* @param object	$parent_id					The asset ID of the parent asset under which the new assets are to reside
* @param int	$schema_id					The asset ID of the Metadata Schema to associate with the new assets
* @param array	$metadata_mapping			A structure containing Supplied Field Name to Metadata Field asset ID associations
* @param array	$attribute_mapping			A structure containing Supplied Field Name to Asset Attribute Name associations
* @param boolean$new_assets_live			When set to TRUE, assets created during the import will be set to 'Live'
* @param string $unique_record_field		The CSV field to be treated as a primary identifier for editing and deletion purposes
* @param string $record_modification_field	The CSV field to determine whether the associated record is to be (A)dded, (E)dited, or (D)eleted
* @param array	$ignore_fields				The fields for the ignoring
*
* @return array
* @access public
*/
function importAssets($source_csv_filename, $asset_type_code, $parent_id, $schema_id, array $metadata_mapping, array $attribute_mapping, $new_assets_live = FALSE, $unique_record_field = '', $record_modification_field = '', array $ignore_fields = array())
{
    $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
    $num_assets_imported = 0;
    $num_assets_modified = 0;
    $num_assets_deleted = 0;
    $csv_fd = fopen($source_csv_filename, 'r');
    if (!$csv_fd) {
        printUsage();
        printStdErr("* The supplied CSV import file was not found\n\n");
        fclose($csv_fd);
        exit(-6);
    }
    $parent_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($parent_id);
    if (!$parent_asset->id) {
        printUsage();
        printStdErr("* The specified parent asset was not found\n\n");
        exit(-7);
    }
    $header_line = TRUE;
    $headers = array();
    $trash = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('trash_folder');
    $root_folder = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_folder');
    // Set to true if temporary trash folder is created, where all the assets to be deleted are moved to
    $temp_trash_folder = FALSE;
    while (($data = fgetcsv($csv_fd, 0, ',')) !== FALSE) {
        $num_fields = count($data);
        $asset_spec = array();
        foreach ($data as $key => $val) {
            if ($header_line) {
                $headers[$key] = trim($val);
            } else {
                $asset_spec[$headers[$key]] = $val;
            }
        }
        if ($header_line) {
            $header_line = FALSE;
        } else {
            // If a Record Modification Field was specified, we also require that a Unique Field was specified for the import
            // These two fields must be present in the CSV file for us to Edit and Delete existing assets. Otherwise, we'll just add
            $record_handling = IMPORT_ADD_RECORD;
            if (!empty($unique_record_field) && !empty($record_modification_field) && isset($asset_spec[$unique_record_field]) && isset($asset_spec[$record_modification_field])) {
                $record_modification_state = strtoupper($asset_spec[$record_modification_field]);
                switch ($record_modification_state) {
                    case 'D':
                        $record_handling = IMPORT_DELETE_RECORD;
                        break;
                    case 'E':
                        $record_handling = IMPORT_EDIT_RECORD;
                        break;
                }
                // Okey dokey, let's find the existing asset as we are either performing an (E)dit or (D)elete operation...
                // Also try to find an existing asset as we may be unfortunately performing an (A)dd that matches the unique
                // identifier, in which case we are probably intending to (E)dit the existing matching asset
                $existing_asset_id = 0;
                // Our search is limited to the exact asset type used for the import, and the parent root node (and children) specified
                // The unique field may be either one to be assigned to an attribute or to a metadata field
                $search_field = '';
                $search_value = '';
                if (isset($metadata_mapping[$unique_record_field])) {
                    $search_type = 'metadata';
                    $search_field = $metadata_mapping[$unique_record_field];
                    $search_value = $asset_spec[$unique_record_field];
                }
                if (isset($attribute_mapping[$unique_record_field])) {
                    $search_type = 'attribute';
                    $search_field = $attribute_mapping[$unique_record_field];
                    $search_value = $asset_spec[$unique_record_field];
                }
                $search = array($search_type => array('field' => $search_field, 'value' => $search_value));
                $existing_assets = findAsset($parent_id, $asset_type_code, $search);
                if (count($existing_assets) > 1) {
                    // Multiple matching assets - skip
                    echo "\n*\t* The record for '" . $search_value . "' matched multiple existing assets. Cannot determine how to proceed - continuing to the next record.\n";
                    continue;
                }
                $existing_asset_id = reset($existing_assets);
                // If it is an (E)dit request and the asset was not found, then let's make it an (A)dd instead
                if (empty($existing_assets) && $record_handling == IMPORT_EDIT_RECORD) {
                    echo "\n*\t* The following 'Edit' request for '" . $search_value . "' has been changed to 'Add' as there is not an existing matching asset\n";
                    $record_handling = IMPORT_ADD_RECORD;
                }
                // If it's there and we wanted to (A)dd, then make it an (E)dit instead
                if ($existing_asset_id > 0 && $record_handling == IMPORT_ADD_RECORD) {
                    echo "\n*\t* The following 'Add' request for '" . $search_value . "' has been changed to 'Edit' as this asset already exists.\n";
                    $record_handling = IMPORT_EDIT_RECORD;
                }
                // If it is a (D)elete request and the asset was not found, then skip this record gracefully
                if (empty($existing_assets) && $record_handling == IMPORT_DELETE_RECORD) {
                    echo "\n*\t* Deletion request for asset with unique field value '" . $search_value . "' was aborted due to a missing matching asset. Continuing to the next record.\n";
                    continue;
                }
                if ($record_handling == IMPORT_DELETE_RECORD) {
                    // Deletify
                    echo '- Deleting asset';
                    $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($existing_asset_id);
                    if ($asset) {
                        // Create temporary trash folder, if not already created
                        if (!$temp_trash_folder) {
                            $GLOBALS['SQ_SYSTEM']->am->includeAsset('folder');
                            $temp_trash_folder = new Folder();
                            $temp_trash_folder->setAttrValue('name', 'temp_trash_folder');
                            $link_array = array('asset' => $root_folder, 'value' => '', 'link_type' => SQ_LINK_TYPE_1);
                            $linkid = $temp_trash_folder->create($link_array);
                            // If cannot create the temporary trash folder then we cannot delete any asset
                            if (!$linkid) {
                                echo "\n*\t* Deletion request for asset with unique field value '" . $search_value . "' was aborted due to unable to create temporary trash folder. Continuing to the next record.\n";
                                $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
                                continue;
                            }
                        }
                        // Move the asset to the temporary trash folder
                        $asset_linkid_old = $GLOBALS['SQ_SYSTEM']->am->getLinkByAsset($parent_id, $asset->id);
                        $linkid = $GLOBALS['SQ_SYSTEM']->am->moveLink($asset_linkid_old['linkid'], $temp_trash_folder->id, SQ_LINK_TYPE_1, -1);
                        // If cannot move the asset to temporary trash folder then it cannot be deleted
                        if (!$linkid) {
                            echo "\n*\t* Deletion request for asset with unique field value '" . $search_value . "' was aborted due to unable to move this asset to temporary trash folder. Continuing to the next record.\n";
                            $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
                            continue;
                        }
                        echo $search_value . ',' . $existing_asset_id . ",D\n";
                        $num_assets_deleted++;
                    }
                    // End if asset
                } else {
                    if ($record_handling == IMPORT_EDIT_RECORD) {
                        // Editise
                        // Ok we are editing - has the user specified fields to ignore at this point? If so, let's eliminificate
                        foreach ($ignore_fields as $ignore_field_name => $val) {
                            if (isset($asset_spec[$ignore_field_name])) {
                                unset($asset_spec[$ignore_field_name]);
                            }
                        }
                        echo '- Modifying asset with unique field value';
                        editAsset($existing_asset_id, $asset_spec, $attribute_mapping, $metadata_mapping, $schema_id);
                        echo $search_value . ',' . $existing_asset_id . ",E\n";
                        $num_assets_modified++;
                    }
                }
            }
            if ($record_handling == IMPORT_ADD_RECORD) {
                $asset_info = createAsset($asset_spec, $asset_type_code, $parent_asset, $schema_id, $metadata_mapping, $attribute_mapping);
                $asset_id = 0;
                if (is_array($asset_info)) {
                    $asset_id = reset($asset_info);
                }
                if ($asset_id) {
                    // Ok see if we need to set it live
                    if ($new_assets_live) {
                        $new_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($asset_id);
                        $new_asset->processStatusChange(SQ_STATUS_LIVE);
                        $GLOBALS['SQ_SYSTEM']->am->forgetAsset($new_asset);
                    }
                    echo key($asset_info) . ',' . $asset_id . ",A\n";
                    $num_assets_imported++;
                }
            }
        }
    }
    // End while
    fclose($csv_fd);
    $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
    // Now actually delete all the assets moved to "temporary purge folder" by purging this folder
    if ($temp_trash_folder && $GLOBALS['SQ_SYSTEM']->am->trashAsset($temp_trash_folder->id)) {
        $trash_folder = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('trash_folder');
        $trash_linkid = $GLOBALS['SQ_SYSTEM']->am->getLinkByAsset($trash_folder->id, $temp_trash_folder->id);
        if (isset($trash_linkid['linkid']) && $trash_linkid['linkid'] > 0) {
            $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
            $vars = array('purge_root_linkid' => $trash_linkid['linkid']);
            $errors = $hh->freestyleHipo('hipo_job_purge_trash', $vars);
            if (!empty($errors)) {
                $error_msg = '';
                foreach ($errors as $error) {
                    $error_msg .= ' * ' . $error['message'];
                }
                echo "Following errors occured while deleting asset(s):\n{$error_msg}\n";
            }
        }
    }
    $status_report = array('num_added' => $num_assets_imported, 'num_modified' => $num_assets_modified, 'num_deleted' => $num_assets_deleted);
    return $status_report;
}
    printUsage("ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.");
}
//FROM PARENT ID
$FROM_PARENT_ID = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : '';
if (empty($FROM_PARENT_ID)) {
    printUsage('ERROR: You need to provide the from-parent-id as the second argument');
}
//TO PARENT ID
$TO_PARENT_ID = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : '';
if (empty($TO_PARENT_ID)) {
    printUsage('ERROR: You need to provide the to-parent-id as the third argument');
}
//ASSET_TYPE
$ASSET_TYPE = isset($_SERVER['argv'][4]) ? $_SERVER['argv'][4] : '';
if (empty($ASSET_TYPE)) {
    printUsage('ERROR: You need to enter the asset_type as the fourth argument');
}
require_once $SYSTEM_ROOT . '/core/include/init.inc';
//LINK_TYPE
$LINK_TYPE = isset($_SERVER['argv'][5]) ? $_SERVER['argv'][5] : SQ_SC_LINK_SIGNIFICANT;
$root_user =& $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user');
// log in as root
if (!$GLOBALS['SQ_SYSTEM']->setCurrentUser($root_user)) {
    echo "ERROR: Failed login in as root user\n";
    exit;
}
moveAssets($FROM_PARENT_ID, $TO_PARENT_ID, $ASSET_TYPE, $LINK_TYPE);
$GLOBALS['SQ_SYSTEM']->restoreCurrentUser();
echo "Finish moving assets!\n";
/**
 * Move all assets under a parent asset to a new parent asset 
Example #8
0
function cliWatchDir($tpath = "", $username = "")
{
    global $cfg;
    if (isset($tpath) && $tpath != "" && isset($username) && $username != "") {
        if (is_dir($tpath)) {
            $cfg['user'] = $username;
            $watchDir = checkDirPathString($tpath);
            if ($dirHandle = opendir($tpath)) {
                while (false !== ($file = readdir($dirHandle))) {
                    if (strtolower(substr($file, -8)) == ".torrent") {
                        $file_name = stripslashes($file);
                        $file_name = str_replace(array("'", ","), "", $file_name);
                        $file_name = cleanFileName($file_name);
                        echo "Injecting and Starting " . $watchDir . $file . " as " . $file_name . " for user " . $cfg['user'] . "...";
                        if (is_file($watchDir . $file) && copy($watchDir . $file, $cfg["torrent_file_path"] . $file_name)) {
                            @unlink($watchDir . $file);
                            chmod($cfg["torrent_file_path"] . $file_name, 0644);
                            AuditAction($cfg["constants"]["file_upload"], $file_name);
                            // init stat-file
                            injectTorrent($file_name);
                            // file-prio
                            if ($cfg["enable_file_priority"]) {
                                include_once "setpriority.php";
                                // Process setPriority Request.
                                setPriority($file_name);
                            }
                            // queue
                            if ($cfg["AllowQueing"]) {
                                $_REQUEST['queue'] = 'on';
                            } else {
                                $_REQUEST['queue'] = 'off';
                            }
                            // start
                            include_once "ClientHandler.php";
                            $clientHandler = ClientHandler::getClientHandlerInstance($cfg);
                            $clientHandler->startTorrentClient($file_name, 0);
                            // just 2 secs..
                            sleep(2);
                            if ($clientHandler->status == 3) {
                                // hooray
                                echo " done\n";
                            } else {
                                // start failed
                                echo "\n ERROR : " . $clientHandler->messages . "\n";
                            }
                        } else {
                            echo "\n ERROR: File could not be found or could not be copied: " . $watchDir . $file . "\n";
                        }
                    }
                }
                closedir($dirHandle);
            }
        } else {
            echo "ERROR: " . $tpath . " is not a dir.\n";
            exit;
        }
    } else {
        printUsage();
    }
    exit;
}
Example #9
0
 * Prepare the PHP completions/docs for TextMate
 *
 * Usage: php generate.php <lang>
 * Example: php generate.php en
 *
 * This script will produce/modify the following files:
 *  - Support/functions.plist
 *  - Support/function-docs/<lang>.txt
 *  - Preferences/Completions.tmPreferences
 *  - Syntaxes/PHP.plist
 */
if (2 !== $argc) {
    printUsage('Must specify a two-letter language code (e.g., "en")');
} else {
    if (2 !== strlen($argv[1])) {
        printUsage('Language must be a two-letter code (e.g., "en")');
    }
}
$lang = strtolower($argv[1]);
$excludeSections = array('basic.other.geoip', 'basic.other.judy', 'basic.other.parsekit', 'basic.other.yaml', 'basic.php.apd', 'basic.php.bcompiler', 'basic.php.inclued', 'basic.php.runkit', 'basic.php.wincache', 'basic.session.msession', 'basic.session.session-pgsql', 'basic.text.bbcode', 'basic.text.ssdeep', 'basic.vartype.classkit', 'compression.lzf', 'compression.rar', 'creditcard.mcve', 'creditcard.spplus', 'crypto.crack', 'database.vendors.cubrid', 'database.vendors.dbase', 'database.vendors.dbplus', 'database.vendors.fbsql', 'database.vendors.filepro', 'database.vendors.ibm-db2', 'database.vendors.ifx', 'database.vendors.ingres', 'database.vendors.maxdb', 'database.vendors.msql', 'database.vendors.ovrimos', 'database.vendors.paradox', 'fileprocess.file.dio', 'fileprocess.file.inotify', 'fileprocess.file.xattr', 'fileprocess.file.xdiff', 'fileprocess.process.expect', 'fileprocess.process.libevent', 'international.fribidi', 'remote.auth.kadm5', 'remote.auth.radius', 'remote.mail.cyrus', 'remote.mail.mailparse', 'remote.mail.vpopmail', 'remote.other.chdb', 'remote.other.fam', 'remote.other.gearman', 'remote.other.gupnp', 'remote.other.hw', 'remote.other.hwapi', 'remote.other.java', 'remote.other.mqseries', 'remote.other.net-gopher', 'remote.other.nis', 'remote.other.notes', 'remote.other.ssh2', 'remote.other.stomp', 'remote.other.svn', 'remote.other.tcpwrap', 'remote.other.yaz', 'search.mnogosearch', 'search.solr', 'utilspec.audio.id3', 'utilspec.audio.openal', 'utilspec.cmdline.ncurses', 'utilspec.cmdline.newt', 'utilspec.image.cairo', 'utilspec.nontext.fdf', 'utilspec.nontext.gnupg', 'utilspec.nontext.ming', 'utilspec.nontext.pdf', 'utilspec.nontext.ps', 'utilspec.nontext.rpmreader', 'utilspec.nontext.swf', 'utilspec.windows.printer', 'utilspec.windows.w32api', 'utilspec.windows.win32ps', 'utilspec.windows.win32service', 'webservice.oauth', 'xml.qtdom');
/**
 * List of new->old sections, to ease with transition
 */
$sectionEquivalents = array('basic.other.misc' => 'basic_functions', 'basic.other.spl' => 'php_spl', 'basic.other.stream' => 'streamsfuncs', 'basic.php.outcontrol' => 'output', 'basic.text.pcre' => 'php_pcre', 'basic.text.regex' => 'ereg', 'basic.text.strings' => 'string', 'compression.bzip2' => 'bz2', 'compression.zip' => 'php_zip', 'database.abstract.uodbc' => 'php_odbc', 'database.vendors.ibase' => 'interbase', 'database.vendors.mssql' => 'php_mssql', 'fileprocess.file.filesystem' => 'file', 'math.bc' => 'bcmath', 'remote.mail.imap' => 'php_imap', 'remote.other.ftp' => 'php_ftp', 'utilspec.server.apache' => 'php_apache', 'xml.dom' => 'php_dom');
define('PHP_DOC_DIR', __DIR__ . '/.phpdoc');
if (!is_dir(PHP_DOC_DIR)) {
    mkdir(PHP_DOC_DIR);
}
chdir(PHP_DOC_DIR);
if (!is_dir('doc-base')) {
    runCmd('svn checkout http://svn.php.net/repository/phpdoc/doc-base/trunk ./doc-base');
Example #10
0
try {
    $opts = new Zend_Console_Getopt(array('help|h' => 'Displays usage information.', 'overwrite|o' => 'Overwrite any existing config files.', 'preserve|p' => 'Keep any existing config files.', 'no-db|n' => 'Turn off database install.', 'reinstall|r' => 'Force a fresh install of this Airtime Version'));
    $opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
    print $e->getMessage() . PHP_EOL;
    printUsage($opts);
    exit(1);
}
if (isset($opts->h)) {
    printUsage($opts);
    exit(1);
}
// The current version is already installed.
if (isset($version) && $version != false && $version == AIRTIME_VERSION && !isset($opts->r)) {
    echo "Airtime {$version} is already installed." . PHP_EOL;
    printUsage($opts);
    exit(1);
}
// A previous version exists - if so, upgrade.
if (isset($version) && $version != false && $version < AIRTIME_VERSION && !isset($opts->r)) {
    echo "Airtime version {$version} found." . PHP_EOL;
    require_once "airtime-upgrade.php";
    //Make sure to exit with non-zero error code so that airtime-install
    //shell script does not continue with installing pypo, show-recorder,
    //media-monitor etc.
    exit(2);
}
if ($version === false) {
    echo "A version of Airtime older than 1.7.0 detected, please upgrade to 1.7.0 first.\n";
    echo "You will then be able to upgrade to 1.9.0 using this installer.\n";
    exit(3);
Example #11
0
function printUsage($error = null)
{
    echo "PoC Migration tool (ivasilchev) \n";
    echo $error;
    echo "Usage : migrate < up | down > <migration name> \n";
    echo "Example: migrate up special-days \n";
    echo "\n";
    exit;
}
if ($argc < 3) {
    printUsage("Not enough paramteres");
}
if (in_array($argv[1], ['up', 'down']) == false) {
    echo "------{$argv[2]}-----";
    printUsage("Error: Invalid parameter - migration step must be 'up' or 'down'");
}
if (in_array($argv[2], array_keys($aliases)) == false) {
    printUsage("Error: Unknown migration alias " . $argv[3] . "\n" . "Available migrations: " . implode(',', array_keys($aliases)));
}
$migration = new $aliases[$argv[2]]['class']();
$executor = new Executor(include_once 'dbconfig.php');
switch ($argv[1]) {
    case 'up':
        $executor->executeUp($migration);
        break;
    case 'down':
        $executor->executeDown($migration);
        break;
    default:
        exit('Unexpected input for migration type :' . $argv[1]);
}
Example #12
0
function tailSpecificLog($key)
{
    global $log_files;
    if (isKeyValid($key)) {
        echo "Tail {$key} log";
        pcntl_exec(exec("which tail"), array("-F", $log_files[$key]));
        pcntl_wait($status);
    } else {
        printUsage();
    }
}
Example #13
0
/**
 * Parses (and checks some) command line arguments
 */
function parseArguments()
{
    global $checkOptions, $cmdargs, $checksEnabled, $periods, $periodsEnabled, $argc, $argv;
    if ($argc == 1) {
        printUsage(true);
        exit(STATUS_UNKNOWN);
    }
    $i = 1;
    while ($i < $argc) {
        if ($argv[$i][0] != '-') {
            $i++;
            continue;
        }
        //disabling or enabling checks
        if (substr($argv[$i], 2, 8) == 'disable-' || substr($argv[$i], 2, 7) == 'enable-') {
            $op = substr($argv[$i], 2, 7) == "disable" ? 0 : 1;
            $check = $op ? substr($argv[$i], 9) : substr($argv[$i], 10);
            if ($check == "all") {
                foreach ($checkOptions as $key => $check) {
                    $checksEnabled[$key] = $op;
                }
            } else {
                if (in_array($check, $checkOptions)) {
                    $checksEnabled[$checkOptions[$check]] = $op;
                } else {
                    _log(sprintf("ERR: Unknown option %s. Use help for more details.", $argv[$i]), LOG__ERROR);
                    exit(STATUS_UNKNOWN);
                }
            }
            $i++;
            continue;
        }
        if (substr($argv[$i], 2) == "help") {
            $argv[$i] = '-h';
        }
        switch ($argv[$i][1]) {
            case 'V':
                printVersion();
                exit(STATUS_OK);
                break;
            case 'v':
                $cmdargs['log_level'] = LOG__VERBOSE;
                $i++;
                break;
            case 'd':
                $cmdargs['log_level'] = LOG__DEBUG;
                $i++;
                break;
            case 'c':
                $cmdargs['configFile'] = $argv[$i + 1];
                if (isset($argv[$i + 2])) {
                    $periodsEnabled = array();
                    while (isset($argv[$i + 2])) {
                        if (in_array($argv[$i + 2], $periods)) {
                            $periodsEnabled[] = $argv[$i + 2];
                            $i++;
                        } else {
                            if ($argv[$i + 2][0] != "-") {
                                _log("Bad period provided. Use help for more details.", LOG__ERROR);
                                exit(STATUS_UNKNOWN);
                            } else {
                                break;
                            }
                        }
                    }
                }
                $i++;
                break;
            case 'h':
            case '?':
                printHelp();
                exit(STATUS_OK);
                break;
            default:
                $i++;
        }
    }
    //check the configuration file
    if (!file_exists($cmdargs['configFile']) || !is_readable($cmdargs['configFile'])) {
        _log(sprintf("Configuration file [%s] does not exist or cannot be read.", $cmdargs['configFile']), LOG__ERROR);
        exit(STATUS_UNKNOWN);
    }
}
Example #14
0
     * @return array
     */
    public function getClassesStats()
    {
        return $this->_aStats;
    }
}
function printUsage($arg)
{
    echo 'Usage: php ' . basename($arg) . ' MetricsXml' . PHP_EOL;
    echo '    MetricsXml    - Metrics in PDepend xml format' . PHP_EOL;
    echo PHP_EOL;
    die("");
}
if (!isset($argv["1"]) || !$argv["1"]) {
    printUsage($argv["0"]);
}
$sMetricsXml = $argv["1"];
try {
    $oMetrics = new Metrics($sMetricsXml);
    if ($oMetrics->isExistingMetricsFile()) {
        $oMetrics->read();
        echo "Total Avg ccn\t= " . round($oMetrics->getTotalAverageCCN(), 3) . " (max: " . $oMetrics->getMaxCCN() . ")" . PHP_EOL;
        echo "Total Avg crap\t= " . round($oMetrics->getTotalAverageCrapIndex(), 3) . " (max: " . $oMetrics->getMaxCrapIndex() . ")" . PHP_EOL;
        echo "Total Avg NPath\t= " . round($oMetrics->getTotalAverageNPath(), 3) . " (max: " . $oMetrics->getMaxNPath() . ")" . PHP_EOL;
        echo "Total LLOC\t= " . $oMetrics->getTotalLLOC() . " (max: " . $oMetrics->getMaxLLOC() . ")" . PHP_EOL . PHP_EOL;
        $aStats = $oMetrics->getClassesStats();
        foreach ($aStats as $sClass => $aClass) {
            echo "Total for {$sClass}" . PHP_EOL;
            echo "\tAvg ccn \t= " . round($aClass['stat']['cnn'], 3) . " (max: " . $aClass['max']['cnn'] . ")" . PHP_EOL;
            echo "\tAvg crap\t= " . round($aClass['stat']['crap'], 3) . " (max: " . $aClass['max']['crap'] . ")" . PHP_EOL;