コード例 #1
0
ファイル: log_config.php プロジェクト: stgrandet/logkafka
function main()
{
    // Check Env
    CommandLineUtils::checkRequiredExtentions();
    // Options
    $helpOpt = new Option(null, 'help');
    $helpOpt->setDescription('Print usage information.');
    $zookeeper_connectOpt = new Option(null, 'zookeeper_connect', Getopt::REQUIRED_ARGUMENT);
    $zookeeper_connectOpt->setDescription('REQUIRED: 
                          The connection string for the zookeeper connection in the form
                          "host1:port1,host2:port2,host3:port3/chroot/path", The "/chroot/path" of connection string 
                          *MUST* be the same as of the kafka server. Multiple URLS can be given to allow fail-over.');
    $createOpt = new Option(null, 'create');
    $createOpt->setDescription('Create a new config.');
    $deleteOpt = new Option(null, 'delete');
    $deleteOpt->setDescription('Delete a config');
    $listOpt = new Option(null, 'list');
    $listOpt->setDescription('List all available configs.');
    $monitorOpt = new Option(null, 'monitor');
    $monitorOpt->setDescription('Monitor all available configs.');
    $logkafka_idOpt = new Option(null, 'logkafka_id', Getopt::REQUIRED_ARGUMENT);
    $logkafka_idOpt->setDescription('The logkafka_id which holds log files');
    $logkafka_idOpt->setValidation(function ($value) {
        $ret = AdminUtils::isLogkafkaIdValid($value);
        return $ret['valid'];
    });
    $log_pathOpt = new Option(null, 'log_path', Getopt::REQUIRED_ARGUMENT);
    $log_pathOpt->setDescription('The log file path, like "/usr/local/apache2/logs/access_log.%Y%m%d"');
    $log_pathOpt->setValidation(function ($value) {
        $ret = AdminUtils::isFilePathValid($value);
        return $ret['valid'];
    });
    $topicOpt = new Option(null, 'topic', Getopt::REQUIRED_ARGUMENT);
    $topicOpt->setDescription('The topic of messages to be sent.');
    $topicOpt->setValidation(function ($value) {
        return AdminUtils::isTopicValid($value);
    });
    $partitionOpt = new Option(null, 'partition', Getopt::REQUIRED_ARGUMENT);
    $partitionOpt->setDescription('The partition of messages to be sent.' . '-1 : random' . 'n(>=0): partition n');
    $partitionOpt->setDefaultValue('-1');
    $partitionOpt->setValidation(function ($value) {
        return is_numeric($value);
    });
    $keyOpt = new Option(null, 'key', Getopt::REQUIRED_ARGUMENT);
    $keyOpt->setDescription('The key of messages to be sent.');
    $keyOpt->setDefaultValue('');
    $keyOpt->setValidation(function ($value) {
        return is_string($value);
    });
    $requiredAcksOpt = new Option(null, 'required_acks', Getopt::REQUIRED_ARGUMENT);
    $requiredAcksOpt->setDescription('Required ack number');
    $requiredAcksOpt->setDefaultValue('1');
    $requiredAcksOpt->setValidation(function ($value) {
        return is_numeric($value);
    });
    $compression_codecOpt = new Option(null, 'compression_codec', Getopt::REQUIRED_ARGUMENT);
    $compression_codecOpt->setDescription("Optional compression method of messages: " . implode(", ", AdminUtils::$COMPRESSION_CODECS));
    $compression_codecOpt->setDefaultValue('none');
    $compression_codecOpt->setValidation(function ($value) {
        return AdminUtils::isCompressionCodecValid($value);
    });
    $batchsizeOpt = new Option(null, 'batchsize', Getopt::REQUIRED_ARGUMENT);
    $batchsizeOpt->setDescription('The batch size of messages to be sent');
    $batchsizeOpt->setDefaultValue('1000');
    $batchsizeOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value > 0;
    });
    $follow_lastOpt = new Option(null, 'follow_last', Getopt::REQUIRED_ARGUMENT);
    $follow_lastOpt->setDescription('If set to "false", when restarting logkafka process, 
                          the log_path formatted with current time will be collect;
                          If set to "true", when restarting logkafka process, the last 
                          collecting file will be collected continually');
    $follow_lastOpt->setDefaultValue('true');
    $follow_lastOpt->setValidation(function ($value) {
        return in_array($value, array('true', 'false'));
    });
    $message_timeout_msOpt = new Option(null, 'message_timeout_ms', Getopt::REQUIRED_ARGUMENT);
    $message_timeout_msOpt->setDescription('Local message timeout. This value is only enforced locally 
                          and limits the time a produced message waits for successful delivery. 
                          A time of 0 is infinite.');
    $message_timeout_msOpt->setDefaultValue('0');
    $message_timeout_msOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value >= 0;
    });
    $regex_filter_patternOpt = new Option(null, 'regex_filter_pattern', Getopt::REQUIRED_ARGUMENT);
    $regex_filter_patternOpt->setDescription("Optional regex filter pattern, the messages matching this pattern will be dropped");
    $regex_filter_patternOpt->setDefaultValue('');
    $regex_filter_patternOpt->setValidation(function ($value) {
        return AdminUtils::isRegexFilterPatternValid($value);
    });
    $lagging_max_bytesOpt = new Option(null, 'lagging_max_bytes', Getopt::REQUIRED_ARGUMENT);
    $lagging_max_bytesOpt->setDescription("log lagging max bytes, the monitor will alarm according to this setting");
    $lagging_max_bytesOpt->setDefaultValue('');
    $lagging_max_bytesOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value >= 0;
    });
    $rotate_lagging_max_secOpt = new Option(null, 'rotate_lagging_max_sec', Getopt::REQUIRED_ARGUMENT);
    $rotate_lagging_max_secOpt->setDescription("log rotatiion lagging max seconds, the monitor will alarm according to this setting");
    $rotate_lagging_max_secOpt->setDefaultValue('');
    $rotate_lagging_max_secOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value >= 0;
    });
    $monitorNameOpt = new Option(null, 'monitor_name', Getopt::REQUIRED_ARGUMENT);
    $monitorNameOpt->setDescription("the monitor name");
    $monitorNameOpt->setDefaultValue('');
    $monitorNameOpt->setValidation(function ($value) {
        return AdminUtils::isMonitorNameValid($value);
    });
    $monitor_interval_msOpt = new Option(null, 'monitor_interval_ms', Getopt::REQUIRED_ARGUMENT);
    $monitor_interval_msOpt->setDescription("the monitor checking interval");
    $monitor_interval_msOpt->setDefaultValue('');
    $monitor_interval_msOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value >= 1000;
    });
    $monitor_max_countOpt = new Option(null, 'monitor_max_count', Getopt::REQUIRED_ARGUMENT);
    $monitor_max_countOpt->setDescription("the monitor checking max count, if setting it to 0, the monitor will keep checking");
    $monitor_max_countOpt->setDefaultValue('');
    $monitor_max_countOpt->setValidation(function ($value) {
        return is_numeric($value) && (int) $value >= 0;
    });
    $validOpt = new Option(null, 'valid', Getopt::REQUIRED_ARGUMENT);
    $validOpt->setDescription('Enable now or not');
    $validOpt->setDefaultValue('true');
    $validOpt->setValidation(function ($value) {
        return in_array($value, array('true', 'false'));
    });
    $parser = new Getopt(array($zookeeper_connectOpt, $createOpt, $deleteOpt, $listOpt, $monitorOpt, $logkafka_idOpt, $log_pathOpt, $topicOpt, $partitionOpt, $keyOpt, $requiredAcksOpt, $compression_codecOpt, $batchsizeOpt, $follow_lastOpt, $message_timeout_msOpt, $regex_filter_patternOpt, $lagging_max_bytesOpt, $rotate_lagging_max_secOpt, $monitorNameOpt, $monitor_interval_msOpt, $monitor_max_countOpt, $validOpt));
    try {
        $parser->parse();
        // Error handling and --help functionality omitted for brevity
        $createOptVal = 0;
        $deleteOptVal = 0;
        $listOptVal = 0;
        $monitorOptVal = 0;
        if ($parser["create"]) {
            $createOptVal = 1;
        }
        if ($parser["delete"]) {
            $deleteOptVal = 1;
        }
        if ($parser["list"]) {
            $listOptVal = 1;
        }
        if ($parser["monitor"]) {
            $monitorOptVal = 1;
        }
    } catch (UnexpectedValueException $e) {
        echo "Error: " . $e->getMessage() . "\n";
        echo $parser->getHelpText();
        exit(1);
    }
    // actions
    $actions = $createOptVal + $deleteOptVal + $listOptVal + $monitorOptVal;
    if ($actions != 1) {
        CommandLineUtils::printUsageAndDie($parser, "Command must include exactly one action: --create, --delete, --list or --monitor");
    }
    // check args
    checkArgs($parser);
    // create admin utils
    $adminUtils = new AdminUtils($parser['zookeeper_connect']);
    $adminUtils->init();
    $adminUtils->checkZkState();
    // create monitor
    if ($monitorOptVal) {
        try {
            $monitor = createMonitor($parser['monitor_name']);
        } catch (Exception $e) {
            echo "Caught Exception ('{$e->getMessage()}')\n{$e}\n";
            exit(1);
        }
    } else {
        $monitor = NULL;
    }
    $adminUtils->setMonitor($monitor);
    try {
        if ($parser['create']) {
            createConfig($adminUtils, $parser);
        } else {
            if ($parser['delete']) {
                deleteConfig($adminUtils, $parser);
            } else {
                if ($parser['list']) {
                    listConfig($adminUtils, $parser);
                } else {
                    if ($parser['monitor']) {
                        monitorConfig($adminUtils, $parser);
                    }
                }
            }
        }
    } catch (LogConfException $e) {
        echo "Caught LogConfException ('{$e->getMessage()}')\n{$e}\n";
    } catch (Exception $e) {
        echo "Caught Exception ('{$e->getMessage()}')\n{$e}\n";
    }
}
コード例 #2
0
ファイル: import.php プロジェクト: alex63530/thelia
    $brands = createBrands($faker, $con);
    $folders = createFolders($faker, $con);
    $contents = createContents($faker, $folders, $con);
    $categories = createCategories($faker, $con);
    echo "creating templates\n";
    $template = new \Thelia\Model\Template();
    $template->setLocale('fr_FR')->setName('template de démo')->setLocale('en_US')->setName('demo template')->save($con);
    $at = new Thelia\Model\AttributeTemplate();
    $at->setTemplate($template)->setAttribute($color)->save($con);
    $ft = new Thelia\Model\FeatureTemplate();
    $ft->setTemplate($template)->setFeature($material)->save($con);
    echo "end creating templates\n";
    createProduct($faker, $categories, $brands, $contents, $template, $color, $material, $con);
    createCustomer($faker, $con);
    // set some config key
    createConfig($faker, $folders, $contents, $con);
    $con->commit();
} catch (Exception $e) {
    echo "error : " . $e->getMessage() . "\n";
    $con->rollBack();
}
function createProduct($faker, $categories, $brands, $contents, $template, $attribute, $feature, $con)
{
    echo "start creating products\n";
    $fileSystem = new \Symfony\Component\Filesystem\Filesystem();
    if (($handle = fopen(THELIA_ROOT . '/setup/import/products.csv', "r")) !== FALSE) {
        $row = 0;
        while (($data = fgetcsv($handle, 100000, ";")) !== FALSE) {
            $row++;
            if ($row == 1) {
                continue;
コード例 #3
0
function check_for_class_name($line)
{
    global $config;
    global $red;
    global $black;
    global $phpfunc;
    global $classNode;
    global $topNode;
    if (!preg_match("/class\\s*({$phpfunc})\\s*extends\\s*({$phpfunc})/", $line, $matches)) {
        return false;
    }
    $classNode = createConfigGroup($matches[1], "Configuration for the class '" . $matches[1] . "'");
    $topNode->appendChild($classNode);
    $valNode = createConfig('extends', 'The class this form extends', $matches[2]);
    $classNode->appendChild($valNode);
    return true;
}
コード例 #4
0
ファイル: install.php プロジェクト: revcozmo/ProQuiz
function processSetup()
{
    global $i, $c;
    $i = 0;
    $c = 0;
    // Database Connectivity Checking
    if ($error = checkDb($_POST)) {
        $_SESSION['ERROR'][$i]['type'] = 'Done';
        $_SESSION['ERROR'][$i]['reason'] = 'Connected to Database';
        $i++;
        $c++;
    } else {
        $_SESSION['ERROR'][$i]['type'] = 'Error';
        $_SESSION['ERROR'][$i]['reason'] = 'Error Connecting to Database :' . mysql_error();
        $i++;
    }
    // Database Name Check
    if ($error = selectDb($_POST)) {
        $_SESSION['ERROR'][$i]['type'] = 'Done';
        $_SESSION['ERROR'][$i]['reason'] = 'Selected Database "' . $_POST['db_name'] . '"';
        $i++;
        $c++;
    } else {
        $_SESSION['ERROR'][$i]['type'] = 'Error';
        $_SESSION['ERROR'][$i]['reason'] = 'Error Selecting Database :' . mysql_error();
        $i++;
    }
    // Creating Tables
    if ($error = createTables($_POST)) {
        $_SESSION['ERROR'][$i]['type'] = 'Done';
        $_SESSION['ERROR'][$i]['reason'] = 'Tables Created Successfully';
        $i++;
        $c++;
    } else {
        $_SESSION['ERROR'][$i]['type'] = 'Error';
        $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Tables :' . mysql_error();
        $i++;
    }
    // Sample Questions
    if ($_POST['sample_qstn'] == 'yes') {
        if ($error = insertSQstn($_POST)) {
            $_SESSION['ERROR'][$i]['type'] = 'Done';
            $_SESSION['ERROR'][$i]['reason'] = 'Sample Questions inserted Successfully';
            $i++;
        } else {
            $_SESSION['ERROR'][$i]['type'] = 'Error';
            $_SESSION['ERROR'][$i]['reason'] = 'Error Inserting Sample Questions :' . mysql_error();
            $i++;
        }
    }
    // Creating Admin Account
    if ($error = createAdmin($_POST)) {
        $_SESSION['ERROR'][$i]['type'] = 'Done';
        $_SESSION['ERROR'][$i]['reason'] = 'Admin Account Created Successfully';
        $i++;
        $c++;
    } else {
        $_SESSION['ERROR'][$i]['type'] = 'Error';
        $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Admin Account :' . mysql_error();
        $i++;
    }
    // Creating Mail Settings
    if ($error = addMailSett($_POST)) {
        $_SESSION['ERROR'][$i]['type'] = 'Done';
        $_SESSION['ERROR'][$i]['reason'] = 'Mail Settings Updated Successfully';
        $i++;
    } else {
        $_SESSION['ERROR'][$i]['type'] = 'Error';
        $_SESSION['ERROR'][$i]['reason'] = 'Error Updating Mail Settings :' . mysql_error();
        $i++;
    }
    // Create Config File
    if ($c >= 4) {
        if ($error = createConfig($_POST)) {
            $_SESSION['ERROR'][$i]['type'] = 'Done';
            $_SESSION['ERROR'][$i]['reason'] = 'Config File Created Successfully';
            $mail = new PHPMailer();
            PQmail($mail, $_POST);
            $i++;
            $c++;
        } else {
            $_SESSION['ERROR'][$i]['type'] = 'Error';
            $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Config File ';
            $i++;
        }
    }
}
コード例 #5
0
ファイル: fm-install.php プロジェクト: pclemot/facileManager
/**
 * Processes installation.
 *
 * @since 1.0
 * @package facileManager
 * @subpackage Installer
 */
function processSetup()
{
    extract($_POST);
    $link = @mysql_connect($dbhost, $dbuser, $dbpass);
    if (!$link) {
        exit(displaySetup(_('Could not connect to MySQL.<br />Please check your credentials.')));
    } else {
        $db_selected = @mysql_select_db($dbname, $link);
        if (mysql_error() && strpos(mysql_error(), 'Unknown database') === false) {
            exit(displaySetup(mysql_error()));
        }
        if ($db_selected) {
            $tables = @mysql_query(sanitize('SHOW TABLES FROM ' . $dbname . ';'), $link);
            @mysql_close($link);
            if (@mysql_num_rows($tables)) {
                exit(displaySetup(_('Database already exists and contains one or more tables.<br />Please choose a different name.')));
            }
        }
    }
    require_once ABSPATH . 'fm-modules/facileManager/install.php';
    createConfig();
}
コード例 #6
0
ファイル: setup.php プロジェクト: NovuForum/NovuForum
          <input type="hidden" name="setup" value="complete">
          <button type="submit" class="btn btn-block btn-success">Start NovuForum</button>
        </div>
      </form>
    </div>
  </div>
</div>
<?php 
    } else {
        ?>
  <?php 
        if (isset($_POST['mysqlhost'], $_POST['mysqldaba'], $_POST['mysqluser'], $_POST['mysqlpass'])) {
            //error_log(getcwd(), 0);
            $mysql = array("host" => $_POST['mysqlhost'], "daba" => $_POST['mysqldaba'], "user" => $_POST['mysqluser'], "pass" => $_POST['mysqlpass']);
            $_SESSION['setup_mysqldata'] = $mysql;
            createConfig($mysql);
            header('Location: /?mysql=1');
        }
        ?>
  <div class="container">
    <div class="panel panel-default panel-fullpage">
      <div class="panel-body">
        <h1 class="page-header text-center">Setup <s>---</s> NovuForum</h1>
        <?php 
        if ($_SESSION['setup_mysql']) {
            ?>
<div class="alert alert-danger">Could not connect to MySQL Host<br><?php 
            echo $_SESSION['setup_mysql_error'];
            ?>
</div><?php 
            $_SESSION['setup_mysql'] = false;
コード例 #7
0
ファイル: login.php プロジェクト: TauThickMi/manager
    if (IS_CONFIG_UPDATE || IS_CONFIG_ERROR) {
        @unlink(REALPATH . '/' . PATH_CONFIG);
    }
    if (IS_CONFIG_UPDATE) {
        echo '<div class="notice_info">Cấu hình cập nhật sẽ đưa về mặc định</div>';
    } else {
        if (IS_CONFIG_ERROR) {
            echo '<div class="notice_failure">Cấu hình bị lỗi sẽ đưa về mặc định</div>';
        } else {
            if (!is_file(REALPATH . '/' . PATH_CONFIG)) {
                echo '<div class="notice_info">Cấu hình không tồn tại nó sẽ được tạo</div>';
            }
        }
    }
    if (!is_file(REALPATH . '/' . PATH_CONFIG)) {
        if (createConfig()) {
            echo '<div class="notice_info">Tài khoản: <strong>' . LOGIN_USERNAME_DEFAULT . '</strong>, Mật khẩu: <strong>' . LOGIN_PASSWORD_DEFAULT . '</strong></div>';
        } else {
            echo '<div class="notice_failure">Tạo cấu hình thất bại, hãy thử lại</div>';
        }
    }
    echo '<div class="list">
<form action="login.php" method="post">
<span class="bull">&bull;</span>Tên đăng nhập:<br/>
<input type="text" name="username" value="" size="18"/><br/>
<span class="bull">&bull;</span>Mật khẩu:<br/>
<input type="password" name="password" value="" size="18"/><br/>
<input type="submit" name="submit" value="Đăng nhập"/>
</form>
</div>';
    include_once 'footer.php';
コード例 #8
0
ファイル: install.php プロジェクト: fengyeno/fille
/**
 *  Downloads PayPal PHP SDK dependencies based on your composer.json file
 */
define('DS', DIRECTORY_SEPARATOR);
define('COMPOSER_FILE', 'composer.json');
// name of the bootstrap file in custom installation
define('BOOTSTRAP_FILE', 'PPBootStrap.php');
// name of the SDK configuration file
define('CONFIGURATION_FILE', 'sdk_config.ini');
// URL from where the composer.json is downloaded if not present
define('COMPOSER_URL', 'https://raw.github.com/paypal/merchant-sdk-php/stable-php5.3/samples/composer.json');
// Flag to control whether composer should be used for installation
$useComposer = false;
init($useComposer);
createAutoload();
createConfig(CONFIGURATION_FILE);
createBootStrap(BOOTSTRAP_FILE);
echo "Installation successful";
exit(0);
function init($useComposer)
{
    // download if composer.json is not present
    if (!file_exists(COMPOSER_FILE)) {
        $fp = fopen(COMPOSER_FILE, "w");
        curlExec(COMPOSER_URL, $fp);
        fclose($fp);
    }
    // check if composer is installed
    if ($useComposer) {
        @exec('composer', $output, $status);
        if ($status == 0) {
コード例 #9
0
ファイル: log_config.php プロジェクト: hjxhjh/logkafka
function main()
{
    // Check Env
    CommandLineUtils::checkRequiredExtentions();
    // Options
    $helpOpt = new Option(null, 'help');
    $helpOpt->setDescription('Print usage information.');
    $zookeeperOpt = new Option(null, 'zookeeper', Getopt::REQUIRED_ARGUMENT);
    $zookeeperOpt->setDescription('REQUIRED: The connection string for the zookeeper connection in the form host:port.' . 'Multiple URLS can be given to allow fail-over.');
    $createOpt = new Option(null, 'create');
    $createOpt->setDescription('Create a new config.');
    $deleteOpt = new Option(null, 'delete');
    $deleteOpt->setDescription('Delete a config');
    $listOpt = new Option(null, 'list');
    $listOpt->setDescription('List all available configs.');
    $hostnameOpt = new Option(null, 'hostname', Getopt::REQUIRED_ARGUMENT);
    $hostnameOpt->setDescription('The hostname of machine which holds log files');
    $log_pathOpt = new Option(null, 'log_path', Getopt::REQUIRED_ARGUMENT);
    $log_pathOpt->setDescription('The log file path, like "/usr/local/apache2/logs/access_log.%Y%m%d"');
    $log_pathOpt->setValidation(function ($value) {
        $ret = AdminUtils::isFilePathValid($value);
        return $ret['valid'];
    });
    $topicOpt = new Option(null, 'topic', Getopt::REQUIRED_ARGUMENT);
    $topicOpt->setDescription('The topic of messages to be sent.');
    $topicOpt->setValidation(function ($value) {
        return AdminUtils::isTopicValid($value);
    });
    $partitionOpt = new Option(null, 'partition', Getopt::REQUIRED_ARGUMENT);
    $partitionOpt->setDescription('The partition of messages to be sent.' . '-1 : random' . 'n(>=0): partition n');
    $partitionOpt->setDefaultValue(-1);
    $partitionOpt->setValidation(function ($value) {
        return is_numeric($value);
    });
    $keyOpt = new Option(null, 'key', Getopt::REQUIRED_ARGUMENT);
    $keyOpt->setDescription('The key of messages to be sent.');
    $keyOpt->setDefaultValue('');
    $keyOpt->setValidation(function ($value) {
        return is_string($value);
    });
    $requiredAcksOpt = new Option(null, 'required_acks', Getopt::REQUIRED_ARGUMENT);
    $requiredAcksOpt->setDescription('Required ack number');
    $requiredAcksOpt->setDefaultValue(1);
    $requiredAcksOpt->setValidation(function ($value) {
        return is_numeric($value);
    });
    $compression_codecOpt = new Option(null, 'compression_codec', Getopt::REQUIRED_ARGUMENT);
    $compression_codecOpt->setDescription("Optional compression method of messages: " . implode(", ", AdminUtils::$COMPRESSION_CODECS));
    $compression_codecOpt->setDefaultValue('none');
    $compression_codecOpt->setValidation(function ($value) {
        return AdminUtils::isCompressionCodecValid($value);
    });
    $batchsizeOpt = new Option(null, 'batchsize', Getopt::REQUIRED_ARGUMENT);
    $batchsizeOpt->setDescription('The batch size of messages to be sent');
    $batchsizeOpt->setDefaultValue(1000);
    $batchsizeOpt->setValidation(function ($value) {
        return is_numeric($value) && $value > 0;
    });
    $follow_lastOpt = new Option(null, 'follow_last', Getopt::REQUIRED_ARGUMENT);
    $follow_lastOpt->setDescription('If set to "false", when restarting logkafka process, 
                          the log_path formatted with current time will be collect;
                          If set to "true", when restarting logkafka process, the last 
                          collecting file will be collected continually');
    $follow_lastOpt->setDefaultValue('true');
    $follow_lastOpt->setValidation(function ($value) {
        return in_array($value, array('true', 'false'));
    });
    $message_timeout_msOpt = new Option(null, 'message_timeout_ms', Getopt::REQUIRED_ARGUMENT);
    $message_timeout_msOpt->setDescription('Local message timeout. This value is only enforced locally 
                          and limits the time a produced message waits for successful delivery. 
                          A time of 0 is infinite.');
    $message_timeout_msOpt->setDefaultValue(0);
    $message_timeout_msOpt->setValidation(function ($value) {
        return is_numeric($value) && $value >= 0;
    });
    $validOpt = new Option(null, 'valid', Getopt::REQUIRED_ARGUMENT);
    $validOpt->setDescription('Enable now or not');
    $validOpt->setDefaultValue('true');
    $validOpt->setValidation(function ($value) {
        return in_array($value, array('true', 'false'));
    });
    $parser = new Getopt(array($zookeeperOpt, $createOpt, $deleteOpt, $listOpt, $hostnameOpt, $log_pathOpt, $topicOpt, $partitionOpt, $keyOpt, $requiredAcksOpt, $compression_codecOpt, $batchsizeOpt, $follow_lastOpt, $message_timeout_msOpt, $validOpt));
    try {
        $parser->parse();
        // Error handling and --help functionality omitted for brevity
        $listOptVal = 0;
        $createOptVal = 0;
        $deleteOptVal = 0;
        if ($parser["list"]) {
            $listOptVal = 1;
        }
        if ($parser["create"]) {
            $createOptVal = 1;
        }
        if ($parser["delete"]) {
            $deleteOptVal = 1;
        }
    } catch (UnexpectedValueException $e) {
        echo "Error: " . $e->getMessage() . "\n";
        echo $parser->getHelpText();
        exit(1);
    }
    // actions
    $actions = $listOptVal + $createOptVal + $deleteOptVal;
    if ($actions != 1) {
        CommandLineUtils::printUsageAndDie($parser, "Command must include exactly one action: --list, --create, or --delete");
    }
    // check args
    checkArgs($parser);
    $zkClient = new Zookeeper($parser['zookeeper']);
    AdminUtils::checkZkState($zkClient);
    try {
        if ($parser['create']) {
            createConfig($zkClient, $parser);
        } else {
            if ($parser['delete']) {
                deleteConfig($zkClient, $parser);
            } else {
                if ($parser['list']) {
                    listConfig($zkClient, $parser);
                }
            }
        }
    } catch (LogConfException $e) {
        echo "Caught LogConfException ('{$e->getMessage()}')\n{$e}\n";
    } catch (Exception $e) {
        echo "Caught Exception ('{$e->getMessage()}')\n{$e}\n";
    }
}
コード例 #10
0
ファイル: script.php プロジェクト: alexinteam/joomla3
 function execute()
 {
     $message = $this->message;
     $status = $this->status;
     $sourcePath = $this->sourcePath;
     //create default easy blog config
     if (!configExist()) {
         if (!createConfig()) {
             $message[] = 'Warning : The system encounter an error when it tries to create default config. Please kindly configure your Easy Blog manually.';
         }
     }
     //update Db columns first before proceed.
     updateEasyBlogDBColumns();
     //check if need to create default category
     if (!blogCategoryExist()) {
         if (!createBlogCategory()) {
             $message[] = 'Warning : The system encounter an error when it tries to create default blog categories. Please kindly create the categories manually.';
         }
     }
     //check if need to create sample post
     if (!postExist()) {
         if (!createSamplePost()) {
             $message[] = 'Warning : The system encounter an error when it tries to create some sample post.';
         }
     }
     //check if twitter table exist.
     if (twitterTableExist()) {
         //migrate twitter data if the table exist
         if (!twitterTableMigrate()) {
             $message[] = 'Warning : The system encounter an error when it tries to migrate your social share data to a new table. Please kindly migrate the data manually.';
         } else {
             if (!twitterTableRemove()) {
                 $message[] = 'Warning : The system encounter an error when it tries to remove the unused twitter table. Please kindly remove the table manually.';
             }
         }
     }
     //truncate the table before recreating the default acl rules.
     if (!truncateACLTable()) {
         $message[] = 'Fatal Error : The system encounter an error when it tries to truncate the acl rules table. Please kindly check your database permission and try again.';
         $status = false;
     }
     //update acl rules
     if (!updateACLRules()) {
         $message[] = 'Fatal Error : The system encounter an error when it tries to create the ACL rules. Please kindly check your database permission and try again.';
         $status = false;
     } else {
         //update user group acl rules
         if (!updateGroupACLRules()) {
             $message[] = 'Fatal Error : The system encounter an error when it tries to create the user groups ACL rules. Please kindly check your database permission and try again.';
             $status = false;
         }
     }
     //install default plugin.
     if (!installDefaultPlugin($sourcePath)) {
         $message[] = 'Warning : The system encounter an error when it tries to install the user plugin. Please kindly install the plugin manually.';
     }
     if (!copyMediaFiles($sourcePath)) {
         $message[] = 'Warning: The system could not copy files to Media folder. Please kindly check the media folder permission.';
         $status = false;
     }
     // migrating stream records from old JS to JS 2.8
     migrateJomSocialStreamNameSpace();
     if ($status) {
         $message[] = 'Success : Installation Completed. Thank you for choosing Easy Blog.';
     }
     $this->message = $message;
     $this->status = $status;
     return $status;
 }
コード例 #11
0
ファイル: setting.php プロジェクト: TauThickMi/M
 if (strlen($username) < 3) {
     echo '<div class="notice_failure">Tên đăng nhập phải lớn hơn 3 ký tự</div>';
 } else {
     if (!empty($passwordO) && getPasswordEncode($passwordO) != $configs['password']) {
         echo '<div class="notice_failure">Mật khẩu cũ không đúng</div>';
     } else {
         if (!empty($passwordO) && (empty($passwordN) || empty($verifyN))) {
             echo '<div class="notice_failure">Để thay đổi mật khẩu hãy nhập đủ hai mật khẩu</div>';
         } else {
             if (!empty($passwordO) && $passwordN != $verifyN) {
                 echo '<div class="notice_failure">Hai mật khẩu không giống nhau</div>';
             } else {
                 if (!empty($passwordO) && strlen($passwordN) < 5) {
                     echo '<div class="notice_failure">Mật khẩu phải lớn hơn 5 ký tự</div>';
                 } else {
                     if (createConfig($username, !empty($passwordN) ? getPasswordEncode($passwordN) : $configs['password'], $pageList, $pageFileEdit, $pageFileEditLine, $pageDatabaseListRows, false)) {
                         include PATH_CONFIG;
                         $username = $configs['username'];
                         $passwordO = null;
                         $passwordN = null;
                         $verifyN = null;
                         $pageList = $configs['page_list'];
                         $pageFileEdit = $configs['page_file_edit'];
                         $pageFileEditLine = $configs['page_file_edit_line'];
                         $pageDatabaseListRows = addslashes($_POST['page_database_list_rows']);
                         echo '<div class="notice_succeed">Lưu thành công</div>';
                     } else {
                         echo '<div class="notice_failure">Lưu thất bại</div>';
                     }
                 }
             }