本文整理汇总了PHP中getenv函数的典型用法代码示例。如果您正苦于以下问题:PHP getenv函数的具体用法?PHP getenv怎么用?PHP getenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
public function find()
{
if (defined('HHVM_VERSION') && false !== ($hhvm = getenv('PHP_BINARY'))) {
return $hhvm;
}
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
return PHP_BINARY;
}
if ($php = getenv('PHP_PATH')) {
if (!is_executable($php)) {
return false;
}
return $php;
}
if ($php = getenv('PHP_PEAR_PHP_BIN')) {
if (is_executable($php)) {
return $php;
}
}
$dirs = array(PHP_BINDIR);
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$dirs[] = 'C:\\xampp\\php\\';
}
return $this->executableFinder->find('php', false, $dirs);
}
示例2: setUp
protected function setUp()
{
parent::setUp();
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable in some environments');
}
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
\OC_User::deleteUser($userName);
\OC_User::createUser($userName, $userName);
}
// main test user
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
$this->objectStorage = new ObjectStoreToTest($config['arguments']);
$config['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($config);
}
示例3: getBuddy
/**
* @return Buddy
*/
public static function getBuddy()
{
if (!self::$buddy) {
self::$buddy = new Buddy(['accessToken' => getenv('TOKEN_ALL')]);
}
return self::$buddy;
}
示例4: client
/**
* @return Client
*/
protected function client()
{
if ($this->client === null) {
$this->client = new Client(['apiKey' => getenv('REBILLY_API_KEY'), 'baseUrl' => getenv('REBILLY_API_HOST')]);
}
return $this->client;
}
示例5: postLogin
public function postLogin(Request $request)
{
$this->validate($request, ['username' => 'required', 'password' => 'required']);
$credentials = $request->only('username', 'password', 'active');
$employee = Employee::where('username', $credentials['username'])->where('active', true)->first();
if ($employee != null && password_verify($credentials['password'], $employee->password)) {
if (!$employee->isadmin) {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} else {
$ip = getenv('REMOTE_ADDR');
}
$host = gethostbyaddr($ip);
$ipAddress = 'Address : ' . $ip . ' Host : ' . $host;
$count = Ipaddress::where('ip', $ip)->count();
$today = date("Y-m-d");
if ($count == 0 || $employee->loginstartdate == null || $today < date('Y-m-d', strtotime($employee->loginstartdate)) || $employee->loginenddate != null && $today > date('Y-m-d', strtotime($employee->loginenddate))) {
return view('errors.permissiondenied', ['ipAddress' => $ipAddress]);
}
if ($employee->branchid == null) {
return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => 'บัญชีเข้าใช้งานของคุณยังไม่ได้ผูกกับสาขา โปรดติดต่อหัวหน้า หรือผู้ดูแล']);
}
}
if ($this->auth->attempt($credentials, $request->has('remember'))) {
return redirect()->intended($this->redirectPath());
}
} else {
return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => $this->getFailedLoginMessage()]);
}
}
示例6: configureMailer
public function configureMailer()
{
$mail = new \PHPMailer();
// $mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = getenv('EMAIL_SMTP');
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = getenv('EMAIL_FROM');
// SMTP username
$mail->Password = getenv('EMAIL_FROM_PASSWORD');
// SMTP password
$mail->SMTPSecure = getenv('EMAIL_SMTP_SECURITY');
// Enable TLS encryption, `ssl` also accepted
$mail->Port = getenv('EMAIL_SMTP_PORT');
// TCP port to connect to
//From myself to myself (alter reply address)
$mail->setFrom(getenv('EMAIL_FROM'), getenv('EMAIL_FROM_NAME'));
$mail->addAddress(getenv('EMAIL_TO'), getenv('EMAIL_TO_NAME'));
$mail->isHTML(true);
// Set email format to HTML
return $mail;
}
示例7: trec_destruct
/**
* Destructor cleanup for a test record
*
* @param Doctrine_Record $proto
* @param string $uuid
*/
function trec_destruct($proto, $uuid = null)
{
if (!$uuid) {
if (isset($proto->my_uuid)) {
$uuid = $proto->my_uuid;
} else {
return;
// nothing to delete
}
}
// setup table vars
$vars = trec_get_vars($proto);
$tbl = $proto->getTable();
$name = get_class($proto);
$conn = $tbl->getConnection();
// look for stale record
$stale = $tbl->findOneBy($vars['UUID_COL'], $uuid);
if ($stale && $stale->exists()) {
if (getenv('AIR_DEBUG')) {
diag("delete()ing stale {$name}: {$uuid}");
}
try {
// ACTUALLY ... don't turn off key checks, to get cascading deletes
// $conn->execute('SET FOREIGN_KEY_CHECKS = 0');
$stale->delete();
// $conn->execute('SET FOREIGN_KEY_CHECKS = 1');
} catch (Exception $err) {
diag($err);
}
}
// put UUID back on the stack
$vars['UUIDS'][] = $uuid;
}
示例8: hasColorSupport
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
*/
protected function hasColorSupport()
{
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
return function_exists('posix_isatty') && @posix_isatty($this->stream);
}
示例9: bindTextDomain
public function bindTextDomain($domain, $path = '')
{
$file = $path . '/' . getenv('LANG') . '/LC_MESSAGES/' . $domain . '.ini';
if (file_exists($file)) {
$this->translations = parse_ini_file($file);
}
}
示例10: __construct
public function __construct($apikey = null)
{
if (!$apikey) {
$apikey = getenv('MANDRILL_APIKEY');
}
if (!$apikey) {
$apikey = $this->readConfigs();
}
if (!$apikey) {
throw new Mandrill_Error('You must provide a Mandrill API key');
}
$this->apikey = $apikey;
$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_USERAGENT, 'Mandrill-PHP/1.0.32');
curl_setopt($this->ch, CURLOPT_POST, true);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->ch, CURLOPT_HEADER, false);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 600);
$this->root = rtrim($this->root, '/') . '/';
$this->templates = new Mandrill_Templates($this);
$this->exports = new Mandrill_Exports($this);
$this->users = new Mandrill_Users($this);
$this->rejects = new Mandrill_Rejects($this);
$this->inbound = new Mandrill_Inbound($this);
$this->tags = new Mandrill_Tags($this);
$this->messages = new Mandrill_Messages($this);
$this->whitelists = new Mandrill_Whitelists($this);
$this->internal = new Mandrill_Internal($this);
$this->urls = new Mandrill_Urls($this);
$this->webhooks = new Mandrill_Webhooks($this);
$this->senders = new Mandrill_Senders($this);
}
示例11: getIP
function getIP()
{
if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
} else {
if (!empty($_SERVER["REMOTE_ADDR"])) {
$ip = $_SERVER["REMOTE_ADDR"];
} else {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
} else {
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} else {
if (getenv("REMOTE_ADDR")) {
$ip = getenv("REMOTE_ADDR");
} else {
$ip = "Unknown";
}
}
}
}
}
}
return $ip;
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$collection = uniqid('collection-');
self::$client = new Client(getenv('ORCHESTRATE_API_KEY'));
$kvPutOp = new KvPutOperation(self::$collection, uniqid(), json_encode(["name" => "Nick"]));
$kvObject = self::$client->execute($kvPutOp);
}
示例13: fire
/**
* 计算黑水值
* Execute the console command.
* @return mixed
*/
public function fire()
{
$i = 0;
$black_water_val = (int) getenv('BLACK_WATER');
while (true) {
$result = UserBase::where('user_id', '>', $i)->orderBy('user_id', 'asc')->limit($this->limit)->get()->toArray();
if (empty($result)) {
break;
}
foreach ($result as $value) {
$user_login_log = UserLoginLog::where('user_id', $value['user_id'])->where('date', date('Ymd', strtotime('-1 day')))->first();
if (empty($user_login_log)) {
$user_black_water = new UserBlackWater();
$user_black_water_result = $user_black_water->where('user_id', $value['user_id'])->first();
if (empty($user_black_water_result)) {
$user_black_water->user_id = $value['user_id'];
$user_black_water->black_water = $black_water_val;
$user_black_water->save();
} else {
$user_black_water->where('user_id', $value['user_id'])->update(['black_water' => $user_black_water_result->black_water + $black_water_val]);
}
}
$i = $value['user_id'];
}
}
}
示例14: setUp
public function setUp()
{
$this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
$this->projectdir = $this->tmpdir . '/project';
$this->reposdir = $this->tmpdir . '/repos';
$this->reposurl = 'file:///' . $this->reposdir;
$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->tmpdir);
$this->filesystem->mkdir($this->projectdir);
$svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
$svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
if (!file_exists($svnadminbin)) {
$this->markTestSkipped(sprintf('%s not found', $svnadminbin));
}
if (!file_exists($svnbin)) {
$this->markTestSkipped(sprintf('%s not found', $svnbin));
}
$svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
$svnadmin->create(basename($this->reposdir));
$svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
$svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
$svn->setHead(new Reference('2.1', Reference::TAG));
$svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
$svn->setHead(new Reference('feature1', Reference::BRANCH));
$svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
$content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
$content = str_replace('{{ repository.url }}', $this->reposurl, $content);
file_put_contents($this->projectdir . '/conveyor.yml', $content);
chdir($this->projectdir);
}
示例15: IPnya
function IPnya()
{
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP')) {
$ipaddress = getenv('HTTP_CLIENT_IP');
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
} else {
if (getenv('HTTP_X_FORWARDED')) {
$ipaddress = getenv('HTTP_X_FORWARDED');
} else {
if (getenv('HTTP_FORWARDED_FOR')) {
$ipaddress = getenv('HTTP_FORWARDED_FOR');
} else {
if (getenv('HTTP_FORWARDED')) {
$ipaddress = getenv('HTTP_FORWARDED');
} else {
if (getenv('REMOTE_ADDR')) {
$ipaddress = getenv('REMOTE_ADDR');
} else {
$ipaddress = 'IP Tidak Dikenali';
}
}
}
}
}
}
return $ipaddress;
}