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(); }
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; }
/** * 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; }
/** * @return string */ public static function getHostname() { if (!isset(self::$hostname)) { self::$hostname = gethostname() ?: php_uname('n'); } return self::$hostname; }
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']]; }
/** * 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}'"); } } }
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); }
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; }
/** * 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 : ''); }
/** * 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'; } } } }
/** * @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; }
/** * 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); } } }
/** * 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(); }
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; }
protected function _getConsumerId() { if ($this->_consumerId === null) { $this->_consumerId = $this->_queueName . ':' . gethostname() . ':' . getmypid(); } return $this->_consumerId; }
/** * @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"); }
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='******'"; $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; }
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(); }
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); }
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)); } }
public function __construct($appDir, $dataDir = NULL) { $this->sandbox = (require $appDir . '/sandbox.php'); $this->settings = (require $this->sandbox['configDir'] . '/settings.php'); $this->dataDir = $dataDir ?: dirname(dirname(__DIR__)) . '/data'; $_SERVER['SERVER_NAME'] = gethostname(); }
/** * Dump the database * * @museDescription Dumps the current site database into a file in the users home directory * * @return void **/ public function dump() { $tables = App::get('db')->getTableList(); $prefix = App::get('db')->getPrefix(); $excludes = []; $now = new Date(); $exclude = ''; $includes = (array) $this->arguments->getOpt('include-table', []); if (!$this->arguments->getOpt('all-tables')) { $this->output->addLine('Dumping database with all prefixed tables included'); foreach ($tables as $table) { if (strpos($table, $prefix) !== 0 && !in_array(str_replace('#__', $prefix, $table), $includes)) { $excludes[] = Config::get('db') . '.' . $table; } elseif (in_array(str_replace('#__', $prefix, $table), $includes)) { $this->output->addLine('Also including `' . $table . '`'); } } // Build exclude list string $exclude = '--ignore-table=' . implode(' --ignore-table=', $excludes); } else { $this->output->addLine('Dumping database with all tables included'); } // Add save location option $home = getenv('HOME'); $hostname = gethostname(); $filename = tempnam($home, "{$hostname}.mysql.dump." . $now->format('Y.m.d') . ".sql."); // Build command $cmd = "mysqldump -u " . Config::get('user') . " -p'" . Config::get('password') . "' " . Config::get('db') . " --routines {$exclude} > {$filename}"; exec($cmd); // Print out location of file $this->output->addLine('File saved to: ' . $filename, 'success'); }
/** * {@inheritDoc} */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('dizda_cloud_backup'); $rootNode->children()->scalarNode('output_file_prefix')->defaultValue(gethostname())->end()->scalarNode('timeout')->defaultValue(300)->end()->arrayNode('processor')->addDefaultsIfNotSet()->children()->enumNode('type')->values(array('tar', 'zip', '7z'))->defaultValue('tar')->end()->scalarNode('date_format')->defaultValue('Y-m-d_H-i-s')->end()->arrayNode('options')->addDefaultsIfNotSet()->children()->scalarNode('password')->defaultNull()->end()->integerNode('compression_ratio')->defaultValue(6)->min(0)->max(100)->end()->arrayNode('split')->addDefaultsIfNotSet()->children()->booleanNode('enable')->defaultFalse()->end()->integerNode('split_size')->isRequired()->defaultNull()->end()->arrayNode('storages')->prototype('scalar')->end()->isRequired()->requiresAtLeastOneElement()->end()->end()->end()->end()->end()->end()->end()->arrayNode('folders')->prototype('scalar')->end()->end()->arrayNode('cloud_storages')->children()->arrayNode('dropbox')->info('Dropbox account credentials (use parameters in config.yml and store real values in prameters.yml)')->children()->scalarNode('user')->isRequired()->end()->scalarNode('password')->isRequired()->end()->scalarNode('remote_path')->defaultValue('/')->end()->end()->end()->arrayNode('google_drive')->info('Google Drive token name as specified in the Happyr Google Site Authenticator Bundle')->children()->scalarNode('token_name')->isRequired()->end()->scalarNode('remote_path')->defaultValue('/')->end()->end()->end()->arrayNode('cloudapp')->info('CloudApp')->children()->scalarNode('user')->isRequired()->end()->scalarNode('password')->isRequired()->end()->end()->end()->arrayNode('gaufrette')->info('Any gaufrette adapter is supported')->children()->scalarNode('service_name')->isRequired()->end()->end()->end()->end()->end()->arrayNode('databases')->children()->arrayNode('mongodb')->children()->booleanNode('all_databases')->defaultTrue()->end()->scalarNode('database')->defaultNull()->end()->scalarNode('db_host')->defaultValue('localhost')->end()->scalarNode('db_port')->defaultValue(27017)->end()->scalarNode('db_user')->defaultValue(null)->end()->scalarNode('db_password')->defaultValue(null)->end()->end()->end()->arrayNode('mysql')->children()->booleanNode('all_databases')->defaultFalse()->end()->scalarNode('database')->defaultNull()->end()->scalarNode('db_host')->defaultNull()->end()->scalarNode('db_port')->defaultValue(3306)->end()->scalarNode('db_user')->defaultNull()->end()->scalarNode('db_password')->defaultNull()->end()->end()->end()->arrayNode('postgresql')->children()->scalarNode('database')->defaultNull()->end()->scalarNode('db_host')->defaultValue('localhost')->end()->scalarNode('db_port')->defaultValue(5432)->end()->scalarNode('db_user')->defaultNull()->end()->scalarNode('db_password')->defaultNull()->end()->end()->end()->end()->end()->end(); return $treeBuilder; }
/** * Get the resource prefix to add to created resources * * @return string */ public static function getResourcePrefix() { if (!isset($_SERVER['PREFIX']) || $_SERVER['PREFIX'] == 'hostname') { $_SERVER['PREFIX'] = crc32(gethostname()) . rand(0, 10000); } return $_SERVER['PREFIX']; }
/** * {@inheritdoc} */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('oro_crm_campaign'); SettingsBuilder::append($rootNode, ['campaign_sender_email' => ['value' => sprintf('no-reply@%s.example', gethostname())], 'campaign_sender_name' => ['value' => 'Oro']]); return $treeBuilder; }
/** * Register bindings in the container. * * @return void */ public function register() { define('IS_DEMO', gethostname() === 'CryptOffice' ? 1 : 0); $this->app->singleton('Settings', function () { return new \App\Services\Settings(new Setting()); }); }
public static function gethostname() { if (function_exists('gethostname')) { return gethostname(); } return self::_gethostname(); }
function onPacket($sock) { $data = $this->centerSocket->recv(); $req = unserialize($data); if (empty($req['cmd'])) { $this->log("error packet"); return; } if ($req['cmd'] == 'getInfo') { $this->centerSocket->send(serialize(['cmd' => 'putInfo', 'info' => ['hostname' => gethostname(), 'ipList' => swoole_get_local_ip(), 'uname' => php_uname(), 'version' => self::VERSION, 'deviceInfo' => ['cpu' => self::getCpuInfo(), 'mem' => self::getMemInfo(), 'disk' => self::getDiskInfo()]]])); } elseif ($req['cmd'] == 'upgrade') { if (empty($req['url']) or empty($req['hash'])) { $this->log("缺少URL和hash"); } $file = self::downloadPackage($req['url']); if ($file) { $hash = md5($file); //hash对比一致,可以更新 if ($hash == $req['hash']) { //更新phar包 file_put_contents($this->pharFile, $file); $this->log("upgrade to " . $req['version']); //退出进程,等待重新拉起 exit; } } else { $this->log("upgrade failed. Cannot fetch url [{$req['url']}]"); } } }
public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_') { parent::__construct('U.u'); $this->systemName = $systemName ?: gethostname(); $this->extraPrefix = $extraPrefix; $this->contextPrefix = $contextPrefix; }
protected function createJob() { $encryptedToken = self::$kernel->getContainer()->get('syrup.encryptor')->encrypt($this->storageApiToken); /** @var ObjectEncryptor $configEncryptor */ $configEncryptor = self::$kernel->getContainer()->get('syrup.object_encryptor'); return new Job($configEncryptor, ['id' => $this->storageApiClient->generateId(), 'runId' => $this->storageApiClient->generateId(), 'project' => ['id' => '123', 'name' => 'Syrup TEST'], 'token' => ['id' => '123', 'description' => 'fake token', 'token' => $encryptedToken], 'component' => 'syrup', 'command' => 'run', 'params' => [], 'process' => ['host' => gethostname(), 'pid' => getmypid()], 'createdTime' => date('c'), 'lockName' => 'test-' . microtime(true)], null, null, null); }