本文整理汇总了PHP中get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_user函数的具体用法?PHP get_current_user怎么用?PHP get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onScriptShutDown
/**
* This function will be called when the script terminates
*/
function onScriptShutDown()
{
global $apiKey;
$error = error_get_last();
$error = is_array($error) ? $error : array('type' => -1);
// check to see if an error actually occurred
if (in_array($error['type'], array(E_PARSE, E_ERROR))) {
// get the error message
$message = $error['message'];
// I'm simulating the backtrace because we are in the context of a shutdown handler.
// If we were in the context of a script that had not terminated (say, in the catch
// block of a try/catch control structure), then we could use PHP's built-in
// debug_backtrace. See http://php.net/manual/en/function.debug-backtrace.php
$backtrace = array(array('line' => $error['line'], 'file' => $error['file'], 'class' => 'example.php', 'function' => 'onScriptShutDown'));
// We may also add session specific information in our tracking call.
// This info is optional, but encouraged.
$session = array('user' => get_current_user(), 'title' => 'Running the Airbrake PHP client', 'date' => date('Y-m-d H:i:s'));
// Create a new tracker, bound to the passed-in API key
$notifier = new AirbrakeNotifier($apiKey);
// Track the error. Note that this call will log messages
// to the error console if AirbrakeNotifier::$debugMode is true
$noticeId = $notifier->notify($message, 'ShutdownError', $backtrace, $session);
if ($noticeId) {
die("Your error has been successfully logged, verify by visiting your Airbrake dashboard. Notice ID {$noticeId}\r\n");
}
}
}
开发者ID:nortron,项目名称:airbrake-php-client,代码行数:30,代码来源:example.php
示例2: 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
示例3: removeMenuItems
function removeMenuItems()
{
$current_user = get_current_user();
if ($current_user != 2 || $current_user != 1) {
//something to hide here
}
}
开发者ID:jycr753,项目名称:dms-template-theme,代码行数:7,代码来源:functions.php
示例4: testAdapterConfig
public function testAdapterConfig()
{
$config = new Config(array('database' => $GLOBALS['dbname'], 'driver' => 'pgsql'), $this->basePath, 2);
$config = $config->getAdapterConfig();
$strAuthor = $config->author;
$this->assertTrue($strAuthor == ucfirst(get_current_user()));
}
开发者ID:pedro151,项目名称:orm-generator,代码行数:7,代码来源:ConfigTest.php
示例5: __construct
/**
* Constructs storage object and creates storage directory
*
* @param string $dir directory name to store data files in
* @throws Zend_OpenId_Exception
*/
public function __construct($dir = null)
{
if ($dir === null) {
$tmp = getenv('TMP');
if (empty($tmp)) {
$tmp = getenv('TEMP');
if (empty($tmp)) {
$tmp = "/tmp";
}
}
$user = get_current_user();
if (is_string($user) && !empty($user)) {
$tmp .= '/' . $user;
}
$dir = $tmp . '/openid/provider';
}
$this->_dir = $dir;
if (!is_dir($this->_dir)) {
if (!@mkdir($this->_dir, 0700, 1)) {
throw new Zend_OpenId_Exception("Cannot access storage directory {$dir}", Zend_OpenId_Exception::ERROR_STORAGE);
}
}
if (($f = fopen($this->_dir . '/assoc.lock', 'w+')) === null) {
throw new Zend_OpenId_Exception('Cannot create a lock file in the directory ' . $dir, Zend_OpenId_Exception::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir . '/user.lock', 'w+')) === null) {
throw new Zend_OpenId_Exception('Cannot create a lock file in the directory ' . $dir, Zend_OpenId_Exception::ERROR_STORAGE);
}
fclose($f);
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:37,代码来源:File.php
示例6: index
function index()
{
require APP . 'webroot/configuration.php';
//get CURRENT SpaceBukkit version
$c_sb = $sbconf['app_version'];
$app = $sbconf['app'];
//get LATEST SpaceBukkit version
$filename = 'http://dl.nope.bz/sb/build/build.xml';
$l_sb = simplexml_load_file($filename);
$json = json_encode($l_sb);
$l_sb = json_decode($json, TRUE);
//Redirect if no new version is avaible
if ($app >= $l_sb["BUILD"]["APP"]) {
$this->redirect(array('controller' => 'Dash', 'action' => 'index'));
}
$this->set('title_for_layout', __('Updating SpaceBukkit'));
$this->set('current', $c_sb);
$this->set('latest', $l_sb["BUILD"]["VERSION"]);
$this->set('changelog', $l_sb["BUILD"]["CHANGELOG"]);
$command = '';
if (PHP_OS !== 'WINNT') {
$user = exec('whoami');
if (get_current_user() == $user) {
$chown = true;
} else {
$chown = false;
$command = 'chown -R ' . $user . ' ' . ROOT;
}
} else {
$chown = true;
}
$this->set('owner', array($chown, $command));
$this->layout = 'update';
}
开发者ID:Tim-NL,项目名称:SpaceBukkitPanel,代码行数:34,代码来源:UpdateController.php
示例7: normalize
/**
* A normal Unix pathname contains no duplicate slashes and does not end
* with a slash. It may be the empty string.
*
* Check that the given pathname is normal. If not, invoke the real
* normalizer on the part of the pathname that requires normalization.
* This way we iterate through the whole pathname string only once.
*/
function normalize($strPathname)
{
if (!strlen($strPathname)) {
return;
}
// Resolve home directories. We assume /home is where all home
// directories reside, b/c there is no other way to do this with
// PHP AFAIK.
if ($strPathname[0] === "~") {
if ($strPathname[1] === "/") {
// like ~/foo => /home/user/foo
$strPathname = "/home/" . get_current_user() . substr($strPathname, 1);
} else {
// like ~foo => /home/foo
$pos = strpos($strPathname, "/");
$name = substr($strPathname, 1, $pos - 2);
$strPathname = "/home/" . $name . substr($strPathname, $pos);
}
}
$n = strlen($strPathname);
$prevChar = 0;
for ($i = 0; $i < $n; $i++) {
$c = $strPathname[$i];
if ($prevChar === '/' && $c === '/') {
return self::normalizer($strPathname, $n, $i - 1);
}
$prevChar = $c;
}
if ($prevChar === '/') {
return self::normalizer($strPathname, $n, $n - 1);
}
return $strPathname;
}
开发者ID:halfer,项目名称:Meshing,代码行数:41,代码来源:UnixFileSystem.php
示例8: __construct
/**
* Constructs storage object and creates storage directory
*
* @param string $dir directory name to store data files in
* @throws Zend_OpenId_Exception
*/
public function __construct($dir = null)
{
if (is_null($dir)) {
$tmp = getenv('TMP');
if (empty($tmp)) {
$tmp = getenv('TEMP');
if (empty($tmp)) {
$tmp = "/tmp";
}
}
$user = get_current_user();
if (is_string($user) && !empty($user)) {
$tmp .= '/' . $user;
}
$dir = $tmp . '/openid/provider';
}
$this->_dir = $dir;
if (!is_dir($this->_dir)) {
if (!@mkdir($this->_dir, 0700, 1)) {
throw new Zend_OpenId_Exception(
"Cannot access storage directory $dir",
Zend_OpenId_Exception::ERROR_STORAGE);
}
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:File.php
示例9: setup_roles
/**
* Setup the current role, and (if set) setup the new role and capabilities.
*
* @since 0.2.0
* @access private
*/
function setup_roles()
{
global $current_user;
if (!$current_user) {
$current_user = get_current_user();
}
if (!$this->current_role) {
$this->current_role = array_shift($current_user->roles);
}
if (!$this->new_role) {
// If this POST variable exists, the current user just changed the drop-down
if (isset($_POST['rqc'])) {
// If the POST value is "default", then just turn it off
if ($_POST['rqc'] == 'default') {
$this->new_role = false;
delete_user_meta($current_user->ID, 'rqc_current_role');
return;
}
// Set the new role to the POST value and update the meta
$this->new_role = $_POST['rqc'];
update_user_meta($current_user->ID, 'rqc_current_role', $this->new_role);
}
// Otherwise, grab the role from the current user meta
$role = get_user_meta($current_user->ID, 'rqc_current_role', true);
$this->new_role = $role;
if ($role = get_role($this->new_role)) {
$this->new_role_caps = $role->capabilities;
}
}
}
开发者ID:joelworsham,项目名称:role-quick-changer,代码行数:36,代码来源:role-quick-changer.php
示例10: dump
/**
* Dump live informations from extender process (if in daemon mode and pcntl installed)
*
* @param int $timestamp_absolute
* @param itn $parent_pid
* @param int $completed_processes
* @param itn $failed_processes
*/
public static final function dump($timestamp_absolute, $parent_pid, $completed_processes, $failed_processes, $paused)
{
$statusfile = EXTENDER_CACHE_FOLDER . self::$statusfile;
$data = array("RUNNING" => $paused ? 0 : 1, "STARTED" => $timestamp_absolute, "TIME" => microtime(true) - $timestamp_absolute, "PARENTPID" => $parent_pid, "COMPLETED" => $completed_processes, "FAILED" => $failed_processes, "CPUAVG" => sys_getloadavg(), "MEM" => memory_get_usage(true), "MEMPEAK" => memory_get_peak_usage(true), "USER" => get_current_user(), "NICENESS" => function_exists('pcntl_getpriority') ? pcntl_getpriority() : "UNDEFINED");
$content = serialize($data);
return file_put_contents($statusfile, $content);
}
开发者ID:comodojo,项目名称:extender.framework,代码行数:15,代码来源:Status.php
示例11: remove_ENGR_dirs
private function remove_ENGR_dirs($path)
{
$pattern = '/\\/nfs.*public_html(.*)/';
preg_match($pattern, $path, $matches);
$user = get_current_user();
return '/~' . $user . $matches[1];
}
开发者ID:jensbodal,项目名称:movie-tv-database,代码行数:7,代码来源:ENGRhelper.php
示例12: __construct
/**
* Constructor
*
* @param string nick
* @param string realname default NULL (defaults to nickname)
* @param string username default NULL (defaults to current username)
* @param string hostname default 'localhost'
*/
public function __construct($nick, $realname = NULL, $username = NULL, $hostname = 'localhost')
{
$this->nick = $nick;
$this->realname = $realname ? $realname : $nick;
$this->username = $username ? $username : get_current_user();
$this->hostname = $hostname;
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:IRCUser.class.php
示例13: verify_token
/**
* Allows you to do things before any output has been sent to the browser.
* This means you can redirect to a remote site, another page etc if need be.
*/
function verify_token()
{
// Generate a fake token and store it for this example
$token = sha1(time() . mt_rand(0, 1000) . time());
$meta = array('time' => time(), 'user' => get_current_user());
$this->store_token($token, $meta);
}
开发者ID:justinshreve,项目名称:keyring,代码行数:11,代码来源:example.php
示例14: getConfigTreeBuilder
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('transporter');
$rootNode->isRequired()->children()->scalarNode('host')->isRequired()->end()->scalarNode('path')->isRequired()->end()->scalarNode('port')->defaultNull()->end()->scalarNode('user')->defaultValue(get_current_user())->end()->scalarNode('pass')->defaultNull()->end()->end();
return $treeBuilder;
}
开发者ID:webcreate,项目名称:conveyor,代码行数:7,代码来源:DefaultTransporterConfiguration.php
示例15: __construct
function __construct()
{
$this->S['YourIP'] = @$_SERVER['REMOTE_ADDR'];
$domain = $this->OS() ? $_SERVER['SERVER_ADDR'] : @gethostbyname($_SERVER['SERVER_NAME']);
$this->S['DomainIP'] = @get_current_user() . ' - ' . $_SERVER['SERVER_NAME'] . '(' . $domain . ')';
$this->S['Flag'] = empty($this->sysInfo['win_n']) ? @php_uname() : $this->sysInfo['win_n'];
$os = explode(" ", php_uname());
$oskernel = $this->OS() ? $os[2] : $os[1];
$this->S['OS'] = $os[0] . '内核版本:' . $oskernel;
$this->S['Language'] = getenv("HTTP_ACCEPT_LANGUAGE");
$this->S['Name'] = $this->OS() ? $os[1] : $os[2];
$this->S['Email'] = $_SERVER['SERVER_ADMIN'];
$this->S['WebEngine'] = $_SERVER['SERVER_SOFTWARE'];
$this->S['WebPort'] = $_SERVER['SERVER_PORT'];
$this->S['WebPath'] = $_SERVER['DOCUMENT_ROOT'] ? str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) : str_replace('\\', '/', dirname(__FILE__));
$this->S['ProbePath'] = str_replace('\\', '/', __FILE__) ? str_replace('\\', '/', __FILE__) : $_SERVER['SCRIPT_FILENAME'];
$this->S['sTime'] = date('Y-m-d H:i:s');
$this->sysInfo = $this->GetsysInfo();
//var_dump($this->sysInfo);
$CPU1 = $this->GetCPUUse();
sleep(1);
$CPU2 = $this->GetCPUUse();
$data = $this->GetCPUPercent($CPU1, $CPU2);
$this->CPU_Use = $data['cpu0']['user'] . "%us, " . $data['cpu0']['sys'] . "%sy, " . $data['cpu0']['nice'] . "%ni, " . $data['cpu0']['idle'] . "%id, " . $data['cpu0']['iowait'] . "%wa, " . $data['cpu0']['irq'] . "%irq, " . $data['cpu0']['softirq'] . "%softirq";
if (!$this->OS()) {
$this->CPU_Use = '目前只支持Linux系统';
}
$this->hd = $this->GetDisk();
$this->NetWork = $this->GetNetWork();
}
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:30,代码来源:check.php
示例16: __construct
public function __construct($argv)
{
$this->verbose = $this->verbose == true ? true : false;
$argv[] = '-clean';
$argv[] = '';
$this->args = $argv;
// get the systems username and set the home dir.
$this->user = get_current_user();
$this->home = '/home/' . $this->user . '/';
foreach ($this->args as $location => $args) {
$chars = str_split($args);
if ($chars[0] === '-') {
$tmp = explode('-', $args);
$function = end($tmp);
unset($tmp);
// this does a check to make sure we can only
// run public functions via this constructor.
$check = new ReflectionMethod($this, $function);
if (!$check->isPublic()) {
continue;
}
$this->{$function}($argv[++$location]);
}
}
}
开发者ID:ErdMutter92,项目名称:linux-file-sweaper,代码行数:25,代码来源:main.php
示例17: formatEventTitle
/**
* Formats the events title with variables as stated in the src/config/config.php
*
* @param string $branchName
* @param string $applicationName
* @param string $connectionName
* @param string $eventTitle
* @return string
*/
private function formatEventTitle($branchName, $applicationName, $connectionName, $eventTitle)
{
$pattern = ['(:user)', '(:branch)', '(:repo)', '(:conn)'];
$replacements = [':user' => get_current_user(), ':branch' => $branchName, ':repo' => $applicationName, ':conn' => $connectionName];
$eventTitle = preg_replace($pattern, $replacements, $eventTitle);
return $eventTitle;
}
开发者ID:peak-adventure-travel,项目名称:rocketeer-flowdock,代码行数:16,代码来源:RocketeerFlowdockMessage.php
示例18: __construct
/**
* Constructs storage object and creates storage directory
*
* @param string $dir directory name to store data files in
* @throws Zend_OpenId_Exception
*/
public function __construct($dir = null)
{
if ($dir === null) {
$tmp = getenv('TMP');
if (empty($tmp)) {
$tmp = getenv('TEMP');
if (empty($tmp)) {
$tmp = "/tmp";
}
}
$user = get_current_user();
if (is_string($user) && !empty($user)) {
$tmp .= '/' . $user;
}
$dir = $tmp . '/openid/consumer';
}
$this->_dir = $dir;
if (!is_dir($this->_dir)) {
if (!@mkdir($this->_dir, 0700, 1)) {
/**
* @see Zend_OpenId_Exception
*/
require_once 'Zend/OpenId/Exception.php';
throw new Zend_OpenId_Exception(
'Cannot access storage directory ' . $dir,
Zend_OpenId_Exception::ERROR_STORAGE);
}
}
if (($f = fopen($this->_dir.'/assoc.lock', 'w+')) === null) {
/**
* @see Zend_OpenId_Exception
*/
require_once 'Zend/OpenId/Exception.php';
throw new Zend_OpenId_Exception(
'Cannot create a lock file in the directory ' . $dir,
Zend_OpenId_Exception::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir.'/discovery.lock', 'w+')) === null) {
/**
* @see Zend_OpenId_Exception
*/
require_once 'Zend/OpenId/Exception.php';
throw new Zend_OpenId_Exception(
'Cannot create a lock file in the directory ' . $dir,
Zend_OpenId_Exception::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir.'/nonce.lock', 'w+')) === null) {
/**
* @see Zend_OpenId_Exception
*/
require_once 'Zend/OpenId/Exception.php';
throw new Zend_OpenId_Exception(
'Cannot create a lock file in the directory ' . $dir,
Zend_OpenId_Exception::ERROR_STORAGE);
}
fclose($f);
}
开发者ID:nhp,项目名称:shopware-4,代码行数:65,代码来源:File.php
示例19: createRunId
/**
* Create unique run ID
*
* @return string
*/
public static function createRunId()
{
$random = uniqid(true) . mt_rand();
if (function_exists('openssl_random_pseudo_bytes')) {
$random .= openssl_random_pseudo_bytes(1024);
}
return hash('sha512', $random . microtime(true) . getmypid() . get_current_user());
}
开发者ID:lstrojny,项目名称:phpunit-clever-and-smart,代码行数:13,代码来源:Util.php
示例20: getCurrentUser
/**
* Get Current User
*
* @return string
*/
public static function getCurrentUser()
{
$processUser = posix_getpwuid(posix_geteuid());
if (true === isset($processUser['name'])) {
return $processUser['name'];
}
return get_current_user();
}
开发者ID:pmdevelopment,项目名称:tool-bundle,代码行数:13,代码来源:SystemUtility.php
注:本文中的get_current_user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论