本文整理汇总了PHP中getHostName函数的典型用法代码示例。如果您正苦于以下问题:PHP getHostName函数的具体用法?PHP getHostName怎么用?PHP getHostName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getHostName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testItCanGetJobProgressionFromApiInRealLife
public function testItCanGetJobProgressionFromApiInRealLife()
{
// Check for and set required server variables
if (!isset($_SERVER['PARTNER_ID'])) {
$this->markTestSkipped('PARTNER_ID is not available');
}
if (!isset($_SERVER['PARTNER_KEY'])) {
$this->markTestSkipped('PARTNER_KEY is not available');
}
$_SERVER['REMOTE_ADDR'] = getHostByName(getHostName());
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36';
// Instantiate the connection
$config = new Config($_SERVER['PARTNER_ID'], $_SERVER['PARTNER_KEY']);
$connection = new Connection($config);
$action = new JobProgression();
$action->addparam('jobTitle', 'developer');
// Get the response from the API
$response = $connection->call($action);
// Assert proper classes/results are returned
$this->assertEquals('Glassdoor\\ResponseObject\\JobProgressionResponse', get_class($response));
foreach ($response->getJobProgressions() as $progression) {
$this->assertEquals('Glassdoor\\ResponseObject\\JobProgression', get_class($progression));
$this->assertNotNull($progression->getJobTitle());
}
}
示例2: testCurlTransport
public function testCurlTransport()
{
$mail = new Mail();
$mail->setTo('foo@example.com');
$headers = $mail->getHeaders();
$headers->set('To', 'foo@example.com');
$headers->set('X-Foo', 23);
$headers->set('X-Bar', 42);
$headers->set('X-Foo-Bar', 1337);
if (getEnv('TRAVIS')) {
$from = new MailAddress();
$from->setMailbox(getEnv('USER'));
$from->setHostName(getHostName());
$headers->set('From', $from);
$headers->set('Subject', sprintf('%s #%s (%s)', getEnv('TRAVIS_REPO_SLUG'), getEnv('TRAVIS_JOB_NUMBER'), __METHOD__));
$headers->set('Content-Type', 'text/plain');
$mail->push(sprintf("Repository: %s\nJob: %s\nCommit: %s\nCommit-Range: %s\nPHP-Version: %s\n", getEnv('TRAVIS_REPO_SLUG'), getEnv('TRAVIS_JOB_NUMBER'), getEnv('TRAVIS_COMMIT'), getEnv('TRAVIS_COMMIT_RANGE'), getEnv('TRAVIS_PHP_VERSION')));
} else {
$headers->set('From', 'bar@example.com');
$mail->push("Hello World");
}
$credentials = getEnv('MAILTRAP_SMTP_CREDENTIALS');
if (!$credentials) {
$this->markTestSkipped('Credentials for Mailtrap not found!');
}
$credentials = explode(':', $credentials, 2);
$transport = new CurlTransport('mailtrap.io', 2525);
$transport->setCredentials($credentials[0], $credentials[1]);
$transport->sendMail($mail);
# $this->markTestIncomplete('Check sent mail via Mailtrap is not implemented');
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->delete();
$thisIP = getHostByName(getHostName());
$testuser = User::create(array('username' => 'admin', 'email' => 'admin@admin.com', 'password' => Hash::make('admin'), 'created_ip' => $thisIP, 'last_ip' => $thisIP, 'created_by_user_id' => 1));
DB::table('user_permissions')->delete();
UserPermission::create(array('user_id' => $testuser->id, 'solder_full' => true));
}
示例4: getConfigFilename
function getConfigFilename()
{
$variablesScriptPath = $this->installPath . '/variables.php';
if (!file_exists($variablesScriptPath)) {
return null;
}
require_once $variablesScriptPath;
return $this->installPath . '/var/' . getHostName() . '.conf.php';
}
示例5: userLastVisit
protected function userLastVisit($user_id)
{
$model = User::findOrFail($user_id);
date_default_timezone_set("Asia/Dacca");
$date = date('Y-m-d H:i:s', time());
$model->last_visit = $date;
$model->ip_address = getHostByName(getHostName());
$model->save();
}
示例6: getLocalIp
public function getLocalIp()
{
$CI = & get_instance();
$ip = $CI->input->ip_address();
if ($ip == '::1') {
$ip = getHostByName(getHostName());
}
return $ip;
}
示例7: getLocalIp
public static function getLocalIp()
{
if (empty($_SERVER['SERVER_ADDR']) == false) {
return $_SERVER['SERVER_ADDR'];
} else {
if (self::isCLI() == true) {
return getHostName();
} else {
return null;
}
}
}
示例8: setRating
function setRating($objId, $rating, $remoteData = array())
{
global $db, $page, $user;
// checks
if (!is_numeric($rating) || $rating < $this->minValue || $rating > $this->maxValue) {
addError("invalid or empty rating");
return;
}
if (!empty($remoteData)) {
// this rating comes from another node...
// TODO
} elseif ($page->loggedIn()) {
// local rating from registered user
$this->find($objId, $user->id);
$this->set('rate', $rating);
$this->set('host', getHostName());
$this->set('entered', $this->db->getTimestampTz());
if ($this->exists()) {
// change existing rating
$this->update();
} else {
// new rating
$this->set('prog_id', $objId);
$this->set('user_id', $user->id);
$this->set('user_node_id', 0);
$this->create();
}
} else {
// anonymous rating
// TODO: if there was a rating request from the same host within x minutes, then reject
$key = $page->getAuthKey();
if ($key) {
$this->findAnon($objId, $key);
$this->set('rate', $rating);
$this->set('host', getHostName());
$this->set('entered', $this->db->getTimestampTz());
if ($this->exists()) {
// change existing rating
$this->update();
} else {
// new rating
$this->set('prog_id', $objId);
$this->set('auth_key', $key);
$this->create();
}
} else {
addError($page->getlocalized("cannot_rate_no_authkey"));
// or $this->set('problem', 'no_auth_key');
return;
}
}
$this->updateInstant($objId);
}
示例9: hocwp_get_pc_ip
function hocwp_get_pc_ip()
{
$result = '';
if (function_exists('getHostByName')) {
if (version_compare(PHP_VERSION, '5.3', '<') && function_exists('php_uname')) {
$result = getHostByName(php_uname('n'));
} elseif (function_exists('getHostName')) {
$result = getHostByName(getHostName());
}
}
return $result;
}
示例10: DVRUI_HDHRjson
public function DVRUI_HDHRjson()
{
$storageURL = "??";
$myip = getHostByName(getHostName());
$hdhr_data = getJsonFromUrl($this->myhdhrurl);
for ($i = 0; $i < count($hdhr_data); $i++) {
$hdhr = $hdhr_data[$i];
$hdhr_base = $hdhr[$this->hdhrkey_baseURL];
$hdhr_ip = $hdhr[$this->hdhrkey_localIP];
if (!array_key_exists($this->hdhrkey_discoverURL, $hdhr)) {
// Skip this HDHR - it doesn't support the newer HTTP interface
// for DVR
continue;
}
$hdhr_info = getJsonFromUrl($hdhr[$this->hdhrkey_discoverURL]);
if (array_key_exists($this->hdhrkey_storageURL, $hdhr)) {
// this is a record engine!
// Need to confirm it's a valid one - After restart of
// engine it updates my.hdhomerun.com but sometimes the
// old engine config is left behind.
$rEngine = getJsonFromUrl($hdhr[$this->hdhrkey_discoverURL]);
if (strcmp($rEngine[$this->hdhrkey_storageID], $hdhr[$this->hdhrkey_storageID]) != 0) {
//skip, this is not a valid engine
continue;
}
//get the IP address of record engine.
$hdhr_ip = $hdhr[$this->hdhrkey_localIP];
// Split IP and port
if (preg_match('/^(\\d[\\d.]+):(\\d+)\\b/', $hdhr_ip, $matches)) {
$ip = $matches[1];
$port = $matches[2];
// if IP of record engine matches the IP of this server
// return storageURL
if ($ip == $myip) {
$this->storageURL = $hdhr[$this->hdhrkey_storageURL];
continue;
}
}
}
// ELSE we have a tuner
$tuners = 'unknown';
if (array_key_exists($this->hdhrkey_tuners, $hdhr_info)) {
$tuners = $hdhr_info[$this->hdhrkey_tuners];
}
$legacy = 'No';
if (array_key_exists($this->hdhrkey_legacy, $hdhr_info)) {
$legacy = $hdhr_info[$this->hdhrkey_legacy];
}
$hdhr_lineup = getJsonFromUrl($hdhr_info[$this->hdhrkey_lineupURL]);
$this->hdhrlist[] = array($this->hdhrkey_devID => $hdhr[$this->hdhrkey_devID], $this->hdhrkey_modelNum => $hdhr_info[$this->hdhrkey_modelNum], $this->hdhrlist_key_channelcount => count($hdhr_lineup), $this->hdhrkey_baseURL => $hdhr_base, $this->hdhrkey_lineupURL => $hdhr_info[$this->hdhrkey_lineupURL], $this->hdhrkey_modelName => $hdhr_info[$this->hdhrkey_modelName], $this->hdhrkey_auth => $hdhr_info[$this->hdhrkey_auth], $this->hdhrkey_fwVer => $hdhr_info[$this->hdhrkey_fwVer], $this->hdhrkey_tuners => $tuners, $this->hdhrkey_legacy => $legacy, $this->hdhrkey_fwName => $hdhr_info[$this->hdhrkey_fwName]);
}
}
示例11: testItCanGetJobsFromApi
/**
* Integration test with actual API call to the provider.
*/
public function testItCanGetJobsFromApi()
{
if (!getenv('PARTNER_ID')) {
$this->markTestSkipped('PARTNER_ID not set. Real API call will not be made.');
}
$keyword = 'engineering';
$query = new JujuQuery(['k' => $keyword, 'partnerid' => getenv('PARTNER_ID'), 'ipaddress' => getHostByName(getHostName())]);
$client = new JujuProvider($query);
$results = $client->getJobs();
$this->assertInstanceOf('JobApis\\Jobs\\Client\\Collection', $results);
foreach ($results as $job) {
$this->assertEquals($keyword, $job->query);
}
}
示例12: logger
/** this creates a log entry */
function logger($name, $msg = '', $type = 'default')
{
if ($type == 'default') {
$type = $debug_type;
}
if (is_array($msg)) {
ob_start();
//var_dump($msg);
print_r($msg);
$msg = "\n" . ob_get_contents();
ob_end_clean();
}
error_log(getHostName() . ": {$name}: {$msg}", 0);
if ($type == 'now' && headers_sent()) {
echo "<small><pre> Debug: {$name}: {$msg} </pre></small><br>\n";
}
}
示例13: connect
public function connect()
{
$hostname = "localhost";
$username = "root";
$password = "123456";
$_dbsname = "kepe3788_db";
if (getHostByName(getHostName()) != '127.0.1.1') {
$hostname = "103.247.8.138";
$username = "kepe3788_user";
$password = "1234_asdf";
$_dbsname = "kepe3788_db";
}
$this->conn = new mysqli($hostname, $username, $password, $_dbsname);
if ($this->conn->connect_error) {
die("Connection failed: " . $this->conn->connect_error);
}
return $this->conn;
}
示例14: debug
/** this creates a log entry if $debug is true*/
function debug($name, $msg = '', $type = 'default')
{
global $debug, $debug_type;
if ($debug) {
// the $debug_type is set in config.inc.php
if ($type == 'default') {
$type = $debug_type;
}
if (is_array($msg)) {
ob_start();
var_dump($msg);
$msg = "\n" . ob_get_contents();
ob_end_clean();
}
error_log(getHostName() . ": {$name}: {$msg}", 0);
if ($type == 'now' && headers_sent()) {
echo "<small><pre> Debug: {$name}: {$msg} </pre></small><br>\n";
}
}
}
示例15: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
Schema::create('users', function ($table) {
$table->increments('id');
$table->string('username');
$table->string('email');
$table->string('password');
$table->string('created_ip');
$table->string('last_ip')->nullable();
$table->timestamps();
});
/**
* Create Default User
**/
$user = new User();
$user->username = 'admin';
$user->email = 'admin@admin.com';
$user->password = Hash::make('admin');
$user->created_ip = getHostByName(getHostName());
$user->save();
}