本文整理汇总了PHP中gethostname函数的典型用法代码示例。如果您正苦于以下问题:PHP gethostname函数的具体用法?PHP gethostname怎么用?PHP gethostname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gethostname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($args)
{
global $neardBs, $neardCore, $neardConfig, $neardBins, $neardTools, $neardApps, $neardHomepage;
if (file_exists($neardCore->getExec())) {
return;
}
// Start loading
Util::startLoading();
// Refresh hostname
$neardConfig->replace(Config::CFG_HOSTNAME, gethostname());
// Refresh launch startup
$neardConfig->replace(Config::CFG_LAUNCH_STARTUP, Util::isLaunchStartup() ? Config::ENABLED : Config::DISABLED);
// Check browser
$currentBrowser = $neardConfig->getBrowser();
if (empty($currentBrowser) || !file_exists($currentBrowser)) {
$neardConfig->replace(Config::CFG_BROWSER, Vbs::getDefaultBrowser());
}
// Rebuild hosts file
Util::refactorWindowsHosts();
// Process neard.ini
file_put_contents($neardBs->getIniFilePath(), Util::utf8ToCp1252(TplApp::process()));
// Process Console config
TplConsole::process();
// Process Sublimetext config
TplSublimetext::process();
// Process Websvn config
TplWebsvn::process();
// Process Gitlist config
TplGitlist::process();
// Refresh PEAR version cache file
$neardBins->getPhp()->getPearVersion();
// Rebuild alias homepage
$neardHomepage->refreshAliasContent();
}
开发者ID:RobertoMalatesta,项目名称:neard,代码行数:34,代码来源:class.action.reload.php
示例2: generateSshKeys
private function generateSshKeys()
{
$key = $this->rsaMechanism->createKey();
// Replace the placeholder label with a more meaningful one
$key['publicKey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']);
return $key;
}
开发者ID:kenwi,项目名称:core,代码行数:7,代码来源:ajaxcontroller.php
示例3: factory
/**
* Factory method for creating new credentials. This factory method will
* create the appropriate credentials object with appropriate decorators
* based on the passed configuration options.
*
* @param array $config Options to use when instantiating the credentials
*
* @return CredentialsInterface
* @throws InvalidArgumentException If the caching options are invalid
* @throws RuntimeException If using the default cache and APC is disabled
*/
public static function factory($config = array())
{
// Add default key values
foreach (self::getConfigDefaults() as $key => $value) {
if (!isset($config[$key])) {
$config[$key] = $value;
}
}
// Start tracking the cache key
$cacheKey = $config[Options::CREDENTIALS_CACHE_KEY];
// Create the credentials object
if (!$config[Options::KEY] || !$config[Options::SECRET]) {
$credentials = self::createFromEnvironment($config);
// If no cache key was set, use the crc32 hostname of the server
$cacheKey = $cacheKey ?: 'credentials_' . crc32(gethostname());
} else {
// Instantiate using short or long term credentials
$credentials = new static($config[Options::KEY], $config[Options::SECRET], $config[Options::TOKEN], $config[Options::TOKEN_TTD]);
// If no cache key was set, use the access key ID
$cacheKey = $cacheKey ?: 'credentials_' . $config[Options::KEY];
}
// Check if the credentials are refreshable, and if so, configure caching
$cache = $config[Options::CREDENTIALS_CACHE];
if ($cacheKey && $cache) {
$credentials = self::createCache($credentials, $cache, $cacheKey);
}
return $credentials;
}
开发者ID:eSDK,项目名称:esdk_obs_native_php,代码行数:39,代码来源:Credentials.php
示例4: getHostname
/**
* @return string
*/
public static function getHostname()
{
if (!isset(self::$hostname)) {
self::$hostname = gethostname() ?: php_uname('n');
}
return self::$hostname;
}
开发者ID:spryker,项目名称:Library,代码行数:10,代码来源:System.php
示例5: formatProvider
public function formatProvider()
{
$request = new Request('PUT', '/', ['x-test' => 'abc'], Psr7\stream_for('foo'));
$response = new Response(200, ['X-Baz' => 'Bar'], Psr7\stream_for('baz'));
$err = new RequestException('Test', $request, $response);
return [['{request}', [$request], Psr7\str($request)], ['{response}', [$request, $response], Psr7\str($response)], ['{request} {response}', [$request, $response], Psr7\str($request) . ' ' . Psr7\str($response)], ['{request} {response}', [$request], Psr7\str($request) . ' '], ['{req_headers}', [$request], "PUT / HTTP/1.1\r\nx-test: abc"], ['{res_headers}', [$request, $response], "HTTP/1.1 200 OK\r\nX-Baz: Bar"], ['{res_headers}', [$request], 'NULL'], ['{req_body}', [$request], 'foo'], ['{res_body}', [$request, $response], 'baz'], ['{res_body}', [$request], 'NULL'], ['{method}', [$request], $request->getMethod()], ['{url}', [$request], $request->getUri()], ['{target}', [$request], $request->getRequestTarget()], ['{req_version}', [$request], $request->getProtocolVersion()], ['{res_version}', [$request, $response], $response->getProtocolVersion()], ['{res_version}', [$request], 'NULL'], ['{host}', [$request], $request->getHeaderLine('Host')], ['{hostname}', [$request, $response], gethostname()], ['{hostname}{hostname}', [$request, $response], gethostname() . gethostname()], ['{code}', [$request, $response], $response->getStatusCode()], ['{code}', [$request], 'NULL'], ['{phrase}', [$request, $response], $response->getReasonPhrase()], ['{phrase}', [$request], 'NULL'], ['{error}', [$request, $response, $err], 'Test'], ['{error}', [$request], 'NULL'], ['{req_header_x-test}', [$request], 'abc'], ['{req_header_x-not}', [$request], ''], ['{res_header_X-Baz}', [$request, $response], 'Bar'], ['{res_header_x-not}', [$request, $response], ''], ['{res_header_X-Baz}', [$request], 'NULL']];
}
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:7,代码来源:MessageFormatterTest.php
示例6: update_guests
/**
* Cleans up the guest array
* @global array
* @global resource
*/
function update_guests()
{
global $config, $database;
// The time between them
$time_between = time() - $config['user_online_timeout'];
$time = time();
// Clean up the database of old guests
$result = $database->query("DELETE FROM `guests` WHERE `visit` < '{$time_between}'");
// Insert a new one
if (!$_SESSION['logged_in']) {
$bot_check = is_bot($_SERVER["HTTP_USER_AGENT"]);
// Are they a bot or a guest?
if (is_string($bot_check)) {
$type = $bot_check;
} else {
$type = "GUEST";
}
// Grab the hostname
$host = gethostname();
// Check to see if they already exist.
$result = $database->query("SELECT * FROM `guests` WHERE `ip` = '{$host}'");
if ($database->num($result) < 1) {
// Insert them in there.
$database->query("INSERT INTO `guests` (`visit`,`ip`,`type`) VALUES ('{$time}', '{$host}', '{$type}')");
} else {
// Insert them in there.
$database->query("UPDATE `guests` SET `visit` = '{$time}' WHERE `ip` = '{$host}'");
}
}
}
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:35,代码来源:guest_counter.php
示例7: getGeneralDisplay
public function getGeneralDisplay()
{
$time = time();
$configuration = $this->_getConfiguration();
$host = function_exists('gethostname') ? @gethostname() : @php_uname('n');
if (empty($host)) {
$host = empty($_SERVER['SERVER_NAME']) ? $_SERVER['HOST_NAME'] : $_SERVER['SERVER_NAME'];
}
$version = array('Host' => $host);
$version['PHP Version'] = 'PHP ' . (defined('PHP_VERSION') ? PHP_VERSION : '???') . ' ' . (defined('PHP_SAPI') ? PHP_SAPI : '') . ' ' . (defined('PHP_OS') ? ' ' . PHP_OS : '');
$version['Opcache Version'] = empty($configuration['version']['version']) ? '???' : $configuration['version'][$this->_cachePrefix . 'product_name'] . ' ' . $configuration['version']['version'];
$return = array($this->_printTable($version));
$opcache = $this->_getOpCacheInfo();
if (!empty($opcache[2])) {
$opcache[2] = preg_replace('~width="[^"]+"~', 'width="100%"', $opcache[2]);
$return[] = preg_replace('/\\<tr\\>\\<td class\\="e"\\>[^>]+\\<\\/td\\>\\<td class\\="v"\\>[0-9\\,\\. ]+\\<\\/td\\>\\<\\/tr\\>/', '', $opcache[2]);
}
$status = $this->_getStatus();
if (FALSE !== $status) {
$upTime = array();
if (!empty($status[$this->_cachePrefix . 'statistics']['start_time'])) {
$upTime['uptime'] = $this->_timeSince($time, $status[$this->_cachePrefix . 'statistics']['start_time'], 1, '');
}
if (!empty($status[$this->_cachePrefix . 'statistics']['last_restart_time'])) {
$upTime['last_restart'] = $this->_timeSince($time, $status[$this->_cachePrefix . 'statistics']['last_restart_time']);
}
if (!empty($upTime)) {
$return[] = $this->_printTable($upTime);
}
}
return implode(PHP_EOL, $return);
}
开发者ID:brandontamm,项目名称:Magento-OpCache,代码行数:32,代码来源:General.php
示例8: getAttributesInitToken
private function getAttributesInitToken()
{
$hostname = gethostname();
// gocdb-test.esc.rl.ac.uk, goc.egi.eu
// specify location of the Shib Logout handler
\Factory::$properties['LOGOUTURL'] = 'https://' . $hostname . '/Shibboleth.sso/Logout';
$idp = $_SERVER['Shib-Identity-Provider'];
if ($idp == 'https://unity.eudat-aai.fz-juelich.de:8443/saml-idp/metadata' && $_SERVER['distinguishedName'] != null) {
$this->principal = $_SERVER['distinguishedName'];
$this->userDetails = array('AuthenticationRealm' => array('EUDAT_SSO_IDP'));
return;
} else {
if ($idp == 'https://idp.ebi.ac.uk/idp/shibboleth' && $_SERVER['eppn'] != null) {
$this->principal = hash('sha256', $_SERVER['eppn']);
$this->userDetails = array('AuthenticationRealm' => array('UK_ACCESS_FED'));
return;
}
}
// else {
// die('Now go configure this AuthToken file ['.__FILE__.']');
// }
// if we have not set the principle/userDetails, re-direct to our Discovery Service
$target = urlencode("https://" . $hostname . "/portal/");
header("Location: https://" . $hostname . "/Shibboleth.sso/Login?target=" . $target);
die;
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:26,代码来源:ShibAuthToken.php
示例9: __construct
/**
* Create worker
*
* @param Kue $queue
* @param string $type
*/
public function __construct($queue, $type = null)
{
$this->queue = $queue;
$this->type = $type;
$this->client = $queue->client;
$this->id = (function_exists('gethostname') ? gethostname() : php_uname('n')) . ':' . getmypid() . ($type ? ':' . $type : '');
}
开发者ID:coderofsalvation,项目名称:php-kue,代码行数:13,代码来源:Worker.php
示例10: transferZip
/**
* this will transfer the dbBackup zip to dropbox(LEAD-140)
*/
public function transferZip()
{
$root_dir = dirname(__DIR__);
$backUpFolderPath = $root_dir . '/api/dbBackUp';
$host = gethostname();
$db_name = 'mydb';
/*dropbox settings starts here*/
$dropbox_config = array('key' => 'xxxxxxxx', 'secret' => 'xxxxxxxxx');
$appInfo = dbx\AppInfo::loadFromJson($dropbox_config);
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
/*dropbox settings ends here*/
$current_date = date('Y-m-d');
$backUpFileName = $current_date . '_' . $db_name . '.sql.zip';
$fullBackUpPath = $backUpFolderPath . '/' . $backUpFileName;
if (file_exists($backUpFolderPath)) {
$files = scandir($backUpFolderPath);
//retrieve all the files
foreach ($files as $file) {
if ($file == $backUpFileName) {
// file matches with the db back up file created today
/* transfer the file to dropbox*/
$f = fopen($fullBackUpPath, "rb");
$dbxClient->uploadFileChunked("/{$backUpFileName}", dbx\WriteMode::add(), $f);
fclose($f);
echo 'Upload Completed';
}
}
}
}
开发者ID:anuj331991,项目名称:dbbackupandupload,代码行数:34,代码来源:dbDumpTransfer.php
示例11: register
/**
* @param $queueId
* @param $instance
* @return Worker
*/
public function register($queueId, $instance)
{
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
$host = gethostname();
$pid = getmypid();
/** @var Worker $worker */
$worker = $this->getWorker(['queue' => $queueId, 'instance' => $instance, 'host' => $host]);
if ($worker == null) {
$worker = new Worker();
$worker->setHost($host);
$worker->setInstance($instance);
$worker->setQueue($queueId);
$worker->setStatus(Worker::STATUS_IDLE);
$worker->setLastChangeDate(new \Datetime());
$worker->setPid($pid);
} else {
$worker->setStatus(Worker::STATUS_IDLE);
$worker->setLastChangeDate(new \Datetime());
$worker->setPid($pid);
}
$em->persist($worker);
$em->flush();
$this->logger->debug("Registered worker entity", $worker->__toArray());
return $worker;
}
开发者ID:keboola,项目名称:syrup-queue,代码行数:31,代码来源:WorkerManager.php
示例12: _write
/**
* After writing the log entry to the database, conditionally
* send out a notification based on the notification rules.
*
* @param array $event the log event
* @throws Zend_Log_Exception
*/
protected function _write($event)
{
/** @var $event FireGento_Logger_Model_Event */
//preformat the message
$hostname = gethostname() !== false ? gethostname() : '';
$event->setMessage('[' . $hostname . '] ' . $event->getMessage());
if ($this->_db === null) {
throw new Zend_Log_Exception('Database adapter is null');
}
if ($this->_columnMap === null) {
$dataToInsert = $event;
} else {
$dataToInsert = array();
foreach ($this->_columnMap as $columnName => $fieldKey) {
$dataToInsert[$columnName] = $event->getDataUsingMethod($fieldKey);
}
$dataToInsert['advanced_info'] = $this->getAdvancedInfo($event);
}
$this->_db->insert($this->_table, $dataToInsert);
/** @var Varien_Db_Adapter_Pdo_Mysql $db */
$db = $this->_db;
$connection = $db->getConnection();
$lastInsertId = $connection->lastInsertId();
$loggerEntry = Mage::getModel('firegento_logger/db_entry')->load($lastInsertId);
$notificationMap = Mage::helper('firegento_logger')->getEmailNotificationRules();
foreach ($notificationMap as $rule) {
if ($this->_matchRule($rule, $loggerEntry)) {
$this->_sendNotification($rule, $loggerEntry);
}
}
}
开发者ID:kirchbergerknorr,项目名称:firegento-logger,代码行数:38,代码来源:Db.php
示例13: initialize
/**
* Initialize the provider
*
* @return void
*/
public function initialize()
{
// Get current machine hostname
$this->hostname = $hostname = gethostname();
// Bind the Application instance to our class property
$this->app = $app = App::getInstance();
// Bind the configuration path to our class property
$this->configPath = realpath($app->config('config.path'));
// Get the current mode of application, and bind it to our class property
$this->mode = $app->config('mode');
// Override mode configuration
$this->mergeModeConfig();
// Determine if there's array contain local machine name in 'local' array key of the options given
if (isset($this->options['local'])) {
foreach ($this->options['local'] as $host) {
if ($host === $hostname) {
$this->env = 'local';
$this->mergeEnvConfig();
break;
}
}
}
// Determine if there's array contain remote machine name in 'remote' array key of the options given
if (is_null($this->env) and isset($this->options['remote'])) {
foreach ($this->options['remote'] as $host) {
if ($host === $hostname) {
$this->env = 'remote';
$this->mergeEnvConfig();
break;
}
}
}
// Let's merge our own unique configuration based on our hostname
$this->mergeHostConfig();
}
开发者ID:krisanalfa,项目名称:b-comp,代码行数:40,代码来源:VersionProvider.php
示例14: __construct
public function __construct($callDatetime, $callDuration, $chairName, $chairNumber, $clientRef, $company, $confTitle, $dialType, $numDILines, $numDOLines, $schedulerTel, $scheduler, $conferenceType, $bridge, $leadop, $isCancelled, $accountNumber, $resDate)
{
$this->callID = rand(1, 999);
$this->callDatetime = $callDatetime;
$this->callDuration = $callDuration;
$this->chairName = $chairName;
$this->notes = $notes;
$this->chairNumber = $chairNumber;
$this->clientRef = $clientRef;
$this->company = $company;
$this->confTitle = $confTitle;
$this->dialType = $dialType;
$this->numDILines = $numDILines;
$this->numDOLines = $numDOLines;
$this->schedulerTel = $schedulerTel;
$this->scheduler = $scheduler;
$this->conferenceType = $conferenceType;
$this->bridge = $bridge;
$this->leadop = $leadop;
$this->isCancelled = $isCancelled;
$this->accountNumber = $accountNumber;
$this->resDate = $resDate;
$this->takenBy = gethostname();
$this->lastEditedBy = gethostname();
$this->lastEdited = $lastEdited;
}
开发者ID:Redlord1977,项目名称:oocms,代码行数:26,代码来源:reservation.php
示例15: _getConsumerId
protected function _getConsumerId()
{
if ($this->_consumerId === null) {
$this->_consumerId = $this->_queueName . ':' . gethostname() . ':' . getmypid();
}
return $this->_consumerId;
}
开发者ID:packaged,项目名称:queue,代码行数:7,代码来源:AbstractQueueProvider.php
示例16: execute
/**
* @return int
*/
public function execute()
{
$this->_logger->setInstanceName($this->instanceName);
$this->_pidFile = new PidFile("", $this->instanceName);
echo Shell::colourText((new Figlet("speed"))->render("Defero"), Shell::COLOUR_FOREGROUND_GREEN);
echo "\n";
Log::debug("Setting Default Queue Provider to " . $this->queueService);
Queue::setDefaultQueueProvider($this->queueService);
$queue = Queue::getAccessor();
if ($queue instanceof DatabaseQueue) {
$instance = gethostname();
if ($this->instanceName) {
$instance .= ':' . $this->instanceName;
}
$queue->setOwnKey($instance);
}
$priority = (int) $this->priority;
if (in_array($priority, [1, 5, 10, 99])) {
$this->queueName .= $priority;
} else {
throw new \Exception("Invalid priority. Supported values: 1 , 5, 10, 99");
}
Log::info("Starting to consume queue " . $this->queueName);
$queue->consume(new StdQueue($this->queueName), new CampaignConsumer());
Log::info("Exiting Defero Processor");
}
开发者ID:qubes,项目名称:defero,代码行数:29,代码来源:ProcessQueue.php
示例17: OnLogin2
function OnLogin2($filephp)
{
global $CFG, $userid, $gameid;
$username = $_POST['username'];
echo GetHeader('');
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM {$CFG->prefix}users WHERE username='{$username}'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ($row == false) {
ShowFormLogin($filephp, '<b>Λάθος όνομα χρήστη</b>');
die;
}
if ($row['password'] != '') {
if (md5($password) != $row['password']) {
ShowFormLogin($filephp, '<b>Λάθος κωδικός</b>');
die;
}
}
$ip = GetMyIP();
$hostname = gethostname();
$userid = $row['id'];
$gameid = $row['gameid'];
$query = "INSERT INTO {$CFG->prefix}logins(userid,hostname,ip) SELECT {$userid}, '{$hostname}','{$ip}'";
mysql_query($query);
$query = "UPDATE {$CFG->prefix}users SET lastip='{$ip}' WHERE id={$userid}";
mysql_query($query);
$_SESSION['userid'] = $userid;
$_SESSION['gameid'] = $gameid;
}
开发者ID:bdaloukas,项目名称:grandprix,代码行数:31,代码来源:lib.php
示例18: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$className = Utils::getSimpleClassName(get_class($this));
if (substr($className, -4) !== "Task") {
throw new SkrzException(sprintf("Task class name has to end with 'Task', class: '%s'.", $className));
}
$taskLogDirectory = $this->container->getParameter("kernel.logs_dir");
$this->log->pushHandler(new RotatingFileHandler($taskLogDirectory . "/" . $className . ".log", $this->rotatingLogMaxFiles));
try {
$this->log->info("Task {$className} started.");
$startTime = microtime(true);
$this->work();
$endTime = microtime(true);
$this->log->info(sprintf("Task {$className} terminated with success in %.3fs.", $endTime - $startTime));
} catch (\Exception $e) {
if ($this->container->has("service.alert")) {
// FIXME: do not rely on hostname
/** @var AlertServiceInterface $alertService */
$alertService = $this->container->get("service.alert");
$alertService->sendEmailToAdmin($this->devEmail, "[" . gethostname() . "]: Task " . get_class($this) . " failed with exception: " . $e->getMessage(), $e->getMessage() . "\n\n" . $e->getTraceAsString());
}
$this->log->emergency("Task terminated with exception. " . get_class($e) . ": " . $e->getMessage() . "\n\n" . $e->getTraceAsString());
}
$this->log->popHandler();
}
开发者ID:skrz,项目名称:stack,代码行数:27,代码来源:AbstractTask.php
示例19: post
public function post(Request $request)
{
$rules = array('datetime' => 'required', 'txncode' => 'required', 'entrytype' => 'required');
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
$respone = array('code' => '400', 'status' => 'error', 'message' => 'Error on validation');
} else {
$employee = Employee::with('branch')->where('rfid', '=', $request->input('rfid'))->get();
if (!isset($employee[0])) {
// employee does not exist having the RFID submitted
$respone = array('code' => '401', 'status' => 'error', 'message' => 'Invalid RFID: ' . $request->input('rfid'), 'data' => '');
} else {
$timelog = new Timelog();
//$timelog->employeeid = $request->get('employeeid');
$timelog->employeeid = $employee[0]->id;
$timelog->datetime = $request->input('datetime');
$timelog->txncode = $request->input('txncode');
$timelog->entrytype = $request->input('entrytype');
//$timelog->terminalid = $request->get('terminalid');
$timelog->terminal = gethostname();
$timelog->id = strtoupper(Timelog::get_uid());
if ($timelog->save()) {
$respone = array('code' => '200', 'status' => 'success', 'message' => 'Record saved!');
$datetime = explode(' ', $timelog->datetime);
$txncode = $timelog->txncode == 'to' ? 'Time Out' : 'Time In';
$data = array('empno' => $employee[0]->code, 'lastname' => $employee[0]->lastname, 'firstname' => $employee[0]->firstname, 'middlename' => $employee[0]->middlename, 'position' => $employee[0]->position, 'date' => $datetime[0], 'time' => $datetime[1], 'txncode' => $timelog->txncode, 'txnname' => $txncode, 'branch' => $employee[0]->branch->code, 'timelogid' => $timelog->id);
$respone['data'] = $data;
} else {
$respone = array('code' => '400', 'status' => 'error', 'message' => 'Error on saving locally!');
}
}
}
return json_encode($respone);
}
开发者ID:jrsalunga,项目名称:gi-tk,代码行数:34,代码来源:TimelogController.php
示例20: generateKeyPair
public function generateKeyPair()
{
$comment = "godeploy@" . gethostname();
$filename = sys_get_temp_dir() . "/ssh_keygen_pair" . md5(microtime());
$ds = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "a"));
$cmd = 'ssh-keygen -t rsa -C "' . $comment . '" ';
$pid = proc_open($cmd, $ds, $pipes);
if (is_resource($pid)) {
fwrite($pipes[0], "{$filename}\n");
fwrite($pipes[0], "\n");
fwrite($pipes[0], "\n");
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($pid);
} else {
throw new GD_Exception("Failed to start ssh-keygen to generate ssh key pair.");
}
if ($return_value == 0) {
$id_rsa = file_get_contents($filename);
$id_rsa_pub = file_get_contents($filename . ".pub");
unlink($filename);
unlink($filename . ".pub");
$this->setPrivateKey($id_rsa);
$this->setPublicKey($id_rsa_pub);
$this->setComment($comment);
$this->setSSHKeyTypesId(1);
} else {
throw new GD_Exception("Failed to generate ssh key pair: " . nl2br($output));
}
}
开发者ID:rodrigorm,项目名称:godeploy,代码行数:31,代码来源:SSHKey.php
注:本文中的gethostname函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论