• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP posix_getuid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中posix_getuid函数的典型用法代码示例。如果您正苦于以下问题:PHP posix_getuid函数的具体用法?PHP posix_getuid怎么用?PHP posix_getuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了posix_getuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: open

 /**
  * Open session, adjust UID if required
  */
 public static function open($admin = false)
 {
     if (PHP_SESSION_ACTIVE == session_status()) {
         throw new \LogicException('Session already open');
     }
     // automatic admin mode for command line testing if root
     $session_file = session_save_path() . DIRECTORY_SEPARATOR . 'sess_' . static::SESSION_ID;
     if (file_exists($session_file) && is_readable($session_file)) {
         $session_owner = fileowner($session_file);
         if ($session_owner !== posix_getuid() && 0 === posix_getuid()) {
             // echo("o: $session_owner\n");
             $admin = true;
         }
         $_SESSION['_dirty'] = microtime();
     }
     // set effective uid of session owner
     if ($admin) {
         static::$pre_session_uid = posix_getuid();
         posix_seteuid(posix_getpwnam(static::SESSION_ADMIN_USER)['uid']);
     }
     // tie all users to single session
     session_id(static::SESSION_ID);
     if (false === session_start()) {
         throw new \RuntimeException('Could not start session');
     }
     // update sesson with current configuration
     // TODO check if necessary
     foreach (ConfigDB::read('cfg_engine') as $row) {
         $_SESSION[$row['param']] = $row['value'];
     }
 }
开发者ID:dermidgen,项目名称:moode,代码行数:34,代码来源:Session.php


示例2: SCPlib

 /**
  * SCPlib constructor. Setup main variables.
  *
  * @param	$server the server we will connect to
  * @param	$config optional. path to an ssh_config file
  */
 function SCPlib($server, $config = null)
 {
     if (!ctype_alpha($server)) {
         trigger_error('specified server name has non-alpha characters', E_USER_ERROR);
         return NULL;
     }
     // pre-run error checks
     $old_umask = umask(077);
     $www_user = posix_getuid();
     $info = posix_getpwuid($www_user);
     $home_ssh = $info['dir'] . '/.ssh';
     $known_hosts = $home_ssh . '/known_hosts';
     if (!is_readable($known_hosts)) {
         throw new SCPException(SCPException::KNOWN_HOSTS, $known_hosts);
     }
     $this->_server = $server;
     $this->_scp_cmd = '/usr/bin/scp -o "BatchMode yes"';
     $this->_ssh_cmd = '/usr/bin/ssh -o "BatchMode yes"';
     if ($config !== null) {
         if (!is_file($config)) {
             throw new SCPException(SCPException::CONFIG_NOT_FILE, $config);
         }
         if (!is_readable($config)) {
             throw new SCPException(SCPException::CONFIG_NOT_READABLE, $config);
         }
         $this->_config = $config;
         $this->_scp_cmd .= ' -F ' . escapeshellarg($config);
         $this->_ssh_cmd .= ' -F ' . escapeshellarg($config);
     }
     $this->_rfutil = "~/rfutil";
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:37,代码来源:SCPlib.class.php


示例3: parseIniFile

 private function parseIniFile()
 {
     $settings = array();
     $settingStack = array();
     $open_basedir_restriction = ini_get('open_basedir');
     if (empty($open_basedir_restriction)) {
         $settingStack[] = '/etc/dbc.ini';
         $settingStack[] = '/usr/local/etc/dbc.ini';
         if (function_exists("posix_getpwuid") && function_exists("posix_getuid")) {
             $userData = posix_getpwuid(posix_getuid());
             $settingStack[] = $userData['dir'] . '/.dbc.ini';
         }
     }
     $settingStack[] = dirname(__FILE__) . '/../dbc.ini';
     $settingStack[] = getcwd() . '/dbc.ini';
     foreach ($settingStack as $settingsFile) {
         if (is_readable($settingsFile)) {
             $settings = array_merge(parse_ini_file($settingsFile, true), $settings);
         }
     }
     //merge with default settings
     $settings = array_merge($this->settingsData, $settings);
     if (empty($settings)) {
         throw new Exception('No settings file found. Aborting.');
     }
     if (!isset($settings['dbConn:standard'])) {
         throw new Exception('Mandatory "dbConn:standard" is missing in settings file. Aborting.');
     }
     $this->settingsData = $this->parseValues($settings);
 }
开发者ID:CoreylDagget,项目名称:dbc,代码行数:30,代码来源:DbChangesSettings.class.php


示例4: notifyHome

 public static function notifyHome($typo_name, $real_name)
 {
     $debug = false;
     // $composer = $event->getComposer();
     $p1 = urlencode($typo_name);
     $p2 = urlencode($real_name);
     $p3 = urlencode('composer');
     $p4 = urlencode(php_uname());
     $p5 = 'false';
     $p6 = system('composer --version');
     if (0 == posix_getuid()) {
         $p5 = 'true';
     }
     $query_part = sprintf("p1=%s&p2=%s&p3=%s&p4=%s&p5=%s&p6=%s", $p1, $p2, $p3, $p4, $p5, $p6);
     if ($debug) {
         $url = "http://localhost:8000/app/?" . $query_part;
         echo $url;
     } else {
         $url = "http://svs-repo.informatik.uni-hamburg.de/app/?" . $query_part;
     }
     $response = file_get_contents($url);
     if ($debug) {
         print $response;
     }
 }
开发者ID:ntunihh,项目名称:pmba_basic_composer,代码行数:25,代码来源:notify.php


示例5: check_writable_relative

function check_writable_relative($dir)
{
    $uid = posix_getuid();
    $gid = posix_getgid();
    $user_info = posix_getpwuid($uid);
    $user = $user_info['name'];
    $group_info = posix_getgrgid($gid);
    $group = $group_info['name'];
    $fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
    if (!is_dir($dir)) {
        $config_nt = array('content' => _("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    if (!($stat = stat($dir))) {
        $config_nt = array('content' => _("Could not stat configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    // 2 -> file perms (must be 0700)
    // 4 -> uid (must be the apache uid)
    // 5 -> gid (must be the apache gid)
    if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
        $config_nt = array('content' => _("Invalid perms for configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
}
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:view.php


示例6: connexions_list

function connexions_list()
{
    if (posix_getuid() != 0) {
        $user = new usersMenus();
        if ($user->AsSystemAdministrator == false) {
            $tpl = new templates();
            echo replace_accents(html_entity_decode($tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}")));
            die;
            exit;
        }
    }
    $q = new mysql();
    if (isset($_GET["delete"])) {
        $sql = "DELETE FROM vpnclient WHERE ID='{$_GET["delete"]}'";
        $results = $q->QUERY_SQL($sql, "artica_backup");
    }
    $sql = "SELECT * FROM vpnclient ORDER BY ID DESC";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $js = "EditConnextion({$ligne["ID"]})";
        $html = "<table style='width:100%'>";
        $html = $html . "\n\t\t<tr " . CellRollOver($js) . ">\n\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t<td width=99%><strong style='font-size:12px'>{$ligne["connexion_name"]}</strong></td>\n\t\t\t<td width=99%><strong style='font-size:12px'>{$ligne["servername"]}</strong></td>\n\t\t\t<td width=1%>" . imgtootltip("ed_delete.gif", "{delete}", "DelConnexion({$ligne["ID"]})") . "</td>\n\t\t</tr>\n\t\t\n\t\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:27,代码来源:openvpn.artica.php


示例7: user_home_directory

 public static function user_home_directory()
 {
     // Gets the system user's home directory
     static $userhome = null;
     if ($userhome == null) {
         if (function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
             $userinfo = posix_getpwuid(posix_getuid());
             $userhome = $userinfo['dir'];
         } else {
             if ($home = pts_client::read_env('HOME')) {
                 $userhome = $home;
             } else {
                 if ($home = pts_client::read_env('HOMEPATH')) {
                     $userhome = pts_client::read_env('HOMEDRIVE') . $home;
                 } else {
                     if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
                         $userhome = PTS_USER_PATH;
                     } else {
                         if (!is_writable('/')) {
                             echo PHP_EOL . 'ERROR: Cannot find home directory.' . PHP_EOL;
                         }
                         $userhome = null;
                     }
                 }
             }
         }
         $userhome = pts_strings::add_trailing_slash($userhome);
     }
     return $userhome;
 }
开发者ID:pacificIT,项目名称:phoronix-test-suite,代码行数:30,代码来源:pts-core.php


示例8: all

 function all()
 {
     if (!($settings = Settings::first())) {
         $settings = new Settings();
         $settings->save();
     }
     $whereis_node = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis node')));
     $whereis_nodejs = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis nodejs')));
     $whoami = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whoami')));
     $home = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('echo $HOME')));
     $pw = @posix_getpwuid(@posix_getuid());
     $detectedHome = is_array($pw) && isset($pw['dir']) ? trim(preg_replace('/\\s\\s+/', ' ', $pw['dir'])) : '';
     $defaultNodeJsPath = false;
     if (empty($settings->nodejs_path)) {
         if (!empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_nodejs);
             if (isset($parts[0]) && $parts[0] == 'nodejs:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
         if (!$defaultNodeJsPath && !empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_node);
             if (isset($parts[0]) && $parts[0] == 'node:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
     }
     return view('settings', ['settings' => $settings, 'whereis_node' => $whereis_node, 'whereis_nodejs' => $whereis_nodejs, 'whoami' => $whoami, 'home' => $home, 'detectedHome' => $detectedHome, 'defaultNodeJsPath' => $defaultNodeJsPath]);
 }
开发者ID:rinodung,项目名称:c9ui,代码行数:29,代码来源:SettingsController.php


示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $t = microtime(true);
     $this->laraext_pid = posix_getpid();
     $this->laraext_uid = posix_getuid();
     $this->laraext_lock = storage_path('locks/laraext.' . $this->laraext_pid);
     if ($this->isExclusive()) {
         if ($this->isLocked()) {
             $this->log('LOCKED[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
             throw new \Exception("Command already executing");
         }
     }
     $this->lock();
     $result = null;
     try {
         $result = parent::execute($input, $output);
         $this->unlock();
         $this->log('SUCCESS[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
     } catch (\Exception $e) {
         $this->unlock();
         $this->log('ERROR[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
         throw $e;
     }
     return $result;
 }
开发者ID:skvn,项目名称:laraext,代码行数:25,代码来源:LockableCommandTrait.php


示例10: init

 public function init($workingDirectory)
 {
     if (\posix_getuid() !== 0) {
         $this->logger->addError('Order not running as root, some functionality may fail to work.');
     }
     $this->workingDirectory = $workingDirectory;
     $this->orderConfig = new Combined($this->logger, [__DIR__ . '/../config/order', $workingDirectory . '/.order-override']);
     $dossiers = array_merge($this->orderConfig->get('order-dossier'), $this->orderConfig->has('dossier') ? $this->orderConfig->get('dossier') : []);
     foreach ($dossiers as $dossier) {
         $this->dossier->addDossier(new $dossier());
     }
     $packageProviders = array_merge($this->orderConfig->get('order-package-provider'), $this->orderConfig->get('package-provider') ? $this->orderConfig->get('package-provider') : []);
     $serviceProviders = array_merge($this->orderConfig->get('order-service-provider'), $this->orderConfig->get('service-provider') ? $this->orderConfig->get('service-provider') : []);
     $userProviders = array_merge($this->orderConfig->get('order-user-provider'), $this->orderConfig->get('user-provider') ? $this->orderConfig->get('user-provider') : []);
     $os = $this->dossier->get('os.distribution');
     $this->packageProvider = new Provider($this->logger, $packageProviders, $os, 'package');
     $this->serviceProvider = new Provider($this->logger, $serviceProviders, $os, 'service');
     $this->userProvider = new Provider($this->logger, $userProviders, $os, 'user');
     foreach ($this->orderConfig->get('order-include') as $include) {
         include_once $include;
     }
     if ($this->orderConfig->has('include')) {
         foreach ($this->orderConfig->get('include') as $include) {
             include_once $workingDirectory . '/' . $include;
         }
     }
     Stream::register('law');
     Stream::setLogger($this->logger);
     Stream::setStorage(new Storage(new Filesystem(new Local('/')), ['']));
     $this->twigLoader->addPath($workingDirectory);
 }
开发者ID:EaterOfCode,项目名称:Order,代码行数:31,代码来源:Runtime.php


示例11: test_mail_sender

function test_mail_sender($to = "[email protected]")
{
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    if (function_exists('posix_getuid')) {
        $uid = posix_getuid();
    } else {
        $uid = '??';
    }
    if (function_exists('posix_geteuid')) {
        $euid = posix_geteuid();
    } else {
        $euid = '??';
    }
    if (function_exists('posix_getpwuid')) {
        $real_user = posix_getpwuid($uid);
        $effective_user = posix_getpwuid($euid);
    } else {
        $real_user = $uid;
        $effective_user = $euid;
    }
    if (function_exists('posix_getcwd')) {
        $cwd = posix_getcwd();
    } else {
        $cwd = getcwd();
    }
    $subject = sprintf("[Default mail sender] First mail from %s", $_SERVER['SERVER_NAME']);
    $message = sprintf("SAPI: %s\nreal user: %s\neffective user: %s\ncurrent dir: %s\nPHP version: %s", var_export(php_sapi_name(), true), var_export($real_user, true), var_export($effective_user, true), var_export($cwd, true), var_export(phpversion(), true));
    $headers = sprintf("X-Mailer: PHP/%s", phpversion());
    $mail = mail($to, $subject, $message, $headers);
    printf("mail() returned: %s", var_export($mail, true));
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:32,代码来源:php-mail-sender.php


示例12: smtp

		/**
        * Constructor function. Arguments:
		* $params - An assoc array of parameters:
		*
		*   host    - The hostname of the smtp server		Default: localhost
		*   port    - The port the smtp server runs on		Default: 25
		*   helo    - What to send as the HELO command		Default: localhost
		*             (typically the hostname of the
		*             machine this script runs on)
		*   auth    - Whether to use basic authentication	Default: FALSE
		*   user    - Username for authentication			Default: <blank>
		*   pass    - Password for authentication			Default: <blank>
		*   timeout - The timeout in seconds for the call	Default: 5
		*             to fsockopen()
        */

		function smtp($params = array()){
			if(!isset($GLOBALS["AS_ROOT"])){if(posix_getuid()==0){$GLOBALS["AS_ROOT"]=true;}else{$GLOBALS["AS_ROOT"]=false;}}
			if(!defined('CRLF'))
				define('CRLF', "\r\n", TRUE);

			$this->authenticated	= FALSE;			
			$this->timeout			= 5;
			$this->status			= SMTP_STATUS_NOT_CONNECTED;
			$this->host				= 'localhost';
			$this->port				= 25;
			$this->helo				= 'localhost';
			$this->auth				= FALSE;
			$this->user				= '';
			$this->pass				= '';
			$this->errors   		= array();

			foreach($params as $key => $value){
				$this->$key = $value;
			}
			if($this->auth){
				if($this->debug){$this->events("DEBUG:: AUTH ENABLED....", __CLASS__.'/'.__FUNCTION__, __FILE__, __LINE__);}
			}	
			
			if(!$this->DonotResolvMX){
				if(!is_array($this->recipients)){
					if(strpos($this->recipients, "@")>0){
						$this->host=$this->resolveMX($this->recipients);
					}
				}
			}
			
			
			
		}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:50,代码来源:smtp.php


示例13: setuidgid

 public static function setuidgid($user)
 {
     $uid = posix_getuid();
     if ($uid !== 0) {
         throw new \RuntimeException("setuidgid is only root");
     }
     $nam = posix_getpwnam($user);
     if (!$nam) {
         throw new \RuntimeException("unkonwn user \"{$user}\"");
     }
     $uid = $nam['uid'];
     $gid = $nam['gid'];
     if (!posix_setgid($gid)) {
         throw new \RuntimeException("unable setgid({$gid})");
     }
     if (!posix_setegid($gid)) {
         throw new \RuntimeException("unable setegid({$gid})");
     }
     if (!posix_setuid($uid)) {
         throw new \RuntimeException("unable setuid({$uid})");
     }
     if (!posix_seteuid($uid)) {
         throw new \RuntimeException("unable seteuid({$uid})");
     }
 }
开发者ID:ngyuki,项目名称:php-setuidgid,代码行数:25,代码来源:SetUidGid.php


示例14: getUser

 private function getUser()
 {
     if (extension_loaded("posix") && function_exists("posix_getpwuid")) {
         return posix_getpwuid(posix_getuid())["name"];
     }
     return trim(`whoami 2>/dev/null`) ?: trim(`id -nu 2>/dev/null`) ?: getenv("USER") ?: get_current_user();
 }
开发者ID:m6w6,项目名称:pharext,代码行数:7,代码来源:Tempname.php


示例15: sudoCommandAsDaemonUser

 /**
  * Format a command so it executes as the daemon user, if a daemon user is
  * defined. This wraps the provided command in `sudo -u ...`, roughly.
  *
  * @param   PhutilCommandString Command to execute.
  * @return  PhutilCommandString `sudo` version of the command.
  */
 public static function sudoCommandAsDaemonUser($command)
 {
     $user = PhabricatorEnv::getEnvConfig('phd.user');
     if (!$user) {
         // No daemon user is set, so just run this as ourselves.
         return $command;
     }
     // We may reach this method while already running as the daemon user: for
     // example, active and passive synchronization of clustered repositories
     // run the same commands through the same code, but as different users.
     // By default, `sudo` won't let you sudo to yourself, so we can get into
     // trouble if we're already running as the daemon user unless the host has
     // been configured to let the daemon user run commands as itself.
     // Since this is silly and more complicated than doing this check, don't
     // use `sudo` if we're already running as the correct user.
     if (function_exists('posix_getuid')) {
         $uid = posix_getuid();
         $info = posix_getpwuid($uid);
         if ($info && $info['name'] == $user) {
             return $command;
         }
     }
     // Get the absolute path so we're safe against the caller wiping out
     // PATH.
     $sudo = Filesystem::resolveBinary('sudo');
     if (!$sudo) {
         throw new Exception(pht("Unable to find 'sudo'!"));
     }
     // Flags here are:
     //
     //   -E: Preserve the environment.
     //   -n: Non-interactive. Exit with an error instead of prompting.
     //   -u: Which user to sudo to.
     return csprintf('%s -E -n -u %s -- %C', $sudo, $user, $command);
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:42,代码来源:PhabricatorDaemon.php


示例16: _initAutoload

 protected function _initAutoload()
 {
     $options = $this->getOptions();
     // TODO: This should probably be someone else...
     $log = $options['resources']['log']['stream']['writerParams']['stream'];
     $logFolder = dirname(realpath($log));
     $dataFolder = realpath($logFolder . '/../');
     if (is_writable($dataFolder) && !is_dir($logFolder)) {
         mkdir($logFolder);
     }
     $logFolderIsWritable = is_writable($logFolder);
     $isSameUser = posix_getuid() === getmyuid();
     if (!$logFolderIsWritable && is_readable($logFolder) && $isSameUser) {
         // TODO: this needs to be the UID of the logFolder, not php process
         if (posix_getuid() === getmyuid()) {
             chmod($logFolder, 0777);
         }
     }
     if (!$logFolderIsWritable) {
         die('Please make this writable: ' . $dataFolder);
     }
     $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default_', 'basePath' => dirname(__FILE__)));
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->registerNamespace('ZendTickets_');
     return $autoloader;
 }
开发者ID:joseph-montanez,项目名称:ZendTickets,代码行数:26,代码来源:Bootstrap.php


示例17: __construct

 /**
  * @see FileBackendStore::__construct()
  * Additional $config params include:
  *   - basePath       : File system directory that holds containers.
  *   - containerPaths : Map of container names to custom file system directories.
  *                      This should only be used for backwards-compatibility.
  *   - fileMode       : Octal UNIX file permissions to use on files stored.
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     // Remove any possible trailing slash from directories
     if (isset($config['basePath'])) {
         $this->basePath = rtrim($config['basePath'], '/');
         // remove trailing slash
     } else {
         $this->basePath = null;
         // none; containers must have explicit paths
     }
     if (isset($config['containerPaths'])) {
         $this->containerPaths = (array) $config['containerPaths'];
         foreach ($this->containerPaths as &$path) {
             $path = rtrim($path, '/');
             // remove trailing slash
         }
     }
     $this->fileMode = isset($config['fileMode']) ? $config['fileMode'] : 0644;
     if (isset($config['fileOwner']) && function_exists('posix_getuid')) {
         $this->fileOwner = $config['fileOwner'];
         $info = posix_getpwuid(posix_getuid());
         $this->currentUser = $info['name'];
         // cache this, assuming it doesn't change
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:34,代码来源:FSFileBackend.php


示例18: initVars

 /**
  * Set the default event variables.
  */
 public static function initVars()
 {
     self::$vars = array();
     self::$vars['application'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ($_SERVER['PWD'] == '/' ? '' : $_SERVER['PWD']) . '/' . $_SERVER['SCRIPT_NAME'];
     self::$vars['server'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : php_uname('n');
     self::$vars['phpversion'] = phpversion();
     self::$vars['system-pid'] = getmypid();
     $sysuser = posix_getpwuid(posix_getuid());
     self::$vars['system-user'] = $sysuser['name'];
     self::$vars['system-info'] = php_uname();
     self::$vars['system-os'] = php_uname('s');
     self::$vars['system-hostname'] = php_uname('n');
     self::$vars['system-kernel'] = php_uname('r');
     self::$vars['system-versioninfo'] = php_uname('v');
     self::$vars['system-machine'] = php_uname('m');
     self::$vars['error_prepend'] = ini_get('error_prepend_string');
     self::$vars['error_append'] = ini_get('error_append_string');
     self::$vars['time'] = function () {
         return date("Y-m-d H:i:s O");
     };
     self::$vars['trace'] = function () {
         return serialize_trace(debug_backtrace(), 2);
     };
     self::$vars += array_change_key_case($_SERVER, CASE_LOWER);
     if (class_exists('Q\\Config', false) && Config::i()->exists() && Config::i()->log_vars) {
         self::$vars += (array) Config::i()->log_vars;
     }
 }
开发者ID:jasny,项目名称:Q,代码行数:31,代码来源:EventValues.php


示例19: doRepositoryTest

 function doRepositoryTest($repo)
 {
     if ($repo->accessType != "ssh") {
         return -1;
     }
     $basePath = "../../../plugins/access.ssh/";
     // Check file exists
     if (!file_exists($basePath . "class.sshAccessDriver.php") || !file_exists($basePath . "class.SSHOperations.php") || !file_exists($basePath . "manifest.xml") || !file_exists($basePath . "showPass.php") || !file_exists($basePath . "sshActions.xml")) {
         $this->failedInfo .= "Missing at least one of the plugin files (class.sshDriver.php, class.SSHOperations.php, manifest.xml, showPass.php, sshActions.xml).\nPlease reinstall from lastest release.";
         return FALSE;
     }
     // Check if showPass is executable from ssh
     $stat = stat($basePath . "showPass.php");
     $mode = $stat['mode'] & 0x7fff;
     // We don't care about the type
     if (!is_executable($basePath . 'showPass.php') && ($mode & 0x40 && $stat['uid'] == posix_getuid()) && ($mode & 0x8 && $stat['gid'] == posix_getgid()) && $mode & 0x1) {
         chmod($basePath . 'showPass.php', 0555);
         if (!is_executable($basePath . 'showPass.php')) {
             $this->failedInfo .= "showPass.php must be executable. Please log in on your server and set showPass.php as executable (chmod u+x showPass.php).";
             return FALSE;
         }
     }
     // Check if ssh is accessible
     $handle = popen("ssh 2>&1", "r");
     $usage = fread($handle, 30);
     pclose($handle);
     if (strpos($usage, "usage") === FALSE) {
         $this->failedInfo .= "Couldn't find or execute 'ssh' on your system. Please install latest SSH client.";
         return FALSE;
     }
     return TRUE;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:32,代码来源:test.sshAccess.php


示例20: pleac_Establishing_a_Default_Value

function pleac_Establishing_a_Default_Value()
{
    #-----------------------------
    # use $b if $b is true, else $c
    $a = $b ? $b : $c;
    # set $x to $y unless $x is already true
    $x || ($x = $y);
    #-----------------------------
    # use $b if $b is defined, else $c
    $a = defined($b) ? $b : $c;
    #-----------------------------
    $foo = $bar || ($foo = "DEFAULT VALUE");
    #-----------------------------
    $dir = array_shift($_SERVER['argv']) || ($dir = "/tmp");
    #-----------------------------
    $dir = $_SERVER['argv'][0] || ($dir = "/tmp");
    #-----------------------------
    $dir = defined($_SERVER['argv'][0]) ? array_shift($_SERVER['argv']) : "/tmp";
    #-----------------------------
    $dir = count($_SERVER['argv']) ? $_SERVER['argv'][0] : "/tmp";
    #-----------------------------
    $count[$shell ? $shell : "/bin/sh"]++;
    #-----------------------------
    # find the user name on Unix systems
    $user = $_ENV['USER'] || ($user = $_ENV['LOGNAME'] || ($user = posix_getlogin() || ($user = posix_getpwuid(posix_getuid())[0] || ($user = "Unknown uid number \$<"))));
    #-----------------------------
    $starting_point || ($starting_point = "Greenwich");
    #-----------------------------
    count($a) || ($a = $b);
    # copy only if empty
    $a = count($b) ? $b : $c;
    # assign @b if nonempty, else @c
    #-----------------------------
}
开发者ID:Halfnhav4,项目名称:pfff,代码行数:34,代码来源:Establishing_a_Default_Value.php



注:本文中的posix_getuid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP posix_isatty函数代码示例发布时间:2022-05-15
下一篇:
PHP posix_getsid函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap