本文整理汇总了PHP中get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_user函数的具体用法?PHP get_current_user怎么用?PHP get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
}
示例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();
}
示例3: removeMenuItems
function removeMenuItems()
{
$current_user = get_current_user();
if ($current_user != 2 || $current_user != 1) {
//something to hide here
}
}
示例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()));
}
示例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);
}
示例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';
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
}
示例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);
}
示例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];
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}