本文整理汇总了PHP中Environment::update_env方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::update_env方法的具体用法?PHP Environment::update_env怎么用?PHP Environment::update_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::update_env方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Logger
<?php
require_once 'logger.class.php';
$l = new Logger();
if (!getenv("TONIDO_PROFILE_NAME")) {
putenv("TONIDO_PROFILE_NAME=cli-script");
}
require 'environment.class.php';
$plain_password = substr(md5(time() . getenv("TONIDO_PROFILE_NAME")), 0, 8);
preg_match('/VNC password is: (.+)$/', system('"' . __DIR__ . '\\third-party\\vncpwd.exe" /e:"' . $plain_password . '"'), $matches);
$encrypted_password = $matches[1];
$encrypted_password = preg_replace('/[\\W]/', '', $encrypted_password);
Environment::update_env(array('password' => $plain_password, 'encrypted_password' => $encrypted_password));
$l->log('Generated a new password - plain is ' . $plain_password . ' and encrypted is ' . $encrypted_password);
示例2: json_encode
Service::stop();
Environment::set_env(array("installed" => false, "vnc_port" => 5900, "policy_host" => $_GET['policy_host'], "policy_port" => 1234, "password" => "", "success" => false, "vnc_port_open" => false, "policy_port_open" => false, "encrypted_password" => ""));
$env = Environment::get_env();
$l->log('Attempting to start the service in the following environment: ' . json_encode($env));
Service::start();
$trys = 0;
$success = false;
$vnc_running = false;
$policy_running = false;
while (!$success && $trys < 20) {
if (!$vnc_running) {
$vnc_running = !port_open($env['vnc_port']);
}
if (!$policy_running) {
$policy_running = !port_open($env['policy_port'], $env['policy_host']);
}
if ($vnc_running && $policy_running) {
$success = true;
}
$trys++;
usleep(500000);
}
$env = Environment::get_env();
if ($success) {
$l->log('Service started successfully');
Environment::update_env(array('success' => true));
} else {
$l->log('Service did not start');
Environment::update_env(array('success' => false));
}
print json_encode(Environment::get_env());
示例3:
<?php
require_once 'lib/service.class.php';
require_once 'lib/environment.class.php';
Environment::set_env(Environment::get_env());
Environment::update_env(array('password' => '123', 'test' => 'testing'));
//Service::stop();
//Service::start();
示例4: Logger
<?php
require_once '../lib/logger.class.php';
$l = new Logger();
function port_open($port, $host = '127.0.0.1')
{
$conn = @fsockopen($host, $port, $errno, $errstr, 0.2);
if ($conn) {
fclose($conn);
return false;
}
return true;
}
require '../lib/environment.class.php';
header("Content-type: text/plain");
Environment::default_env(array('installed' => false, 'vnc_port' => 5900, 'policy_host' => '127.0.0.1', 'policy_port' => 1234, 'password' => 'password', 'success' => false));
$env = Environment::get_env();
Environment::update_env(array('vnc_port_open' => port_open($env['vnc_port']), 'policy_port_open' => port_open($env['policy_port'], $env['policy_host'])));
$env = Environment::get_env();
print json_encode($env);
$l->log('Returned the following environment: ' . json_encode($env));
示例5: Logger
<?php
require_once '../lib/logger.class.php';
$l = new Logger();
require 'environment.class.php';
header("Content-type: text/plain");
$key = $_GET['key'];
$value = $_GET['value'];
$l->log('Updating environment: ' . $key . ' => ' . $value);
Environment::update_env(array($key => $value));
$return = array('key' => $key, 'value' => $value);
print json_encode($return);