本文整理汇总了PHP中user::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP user::instance方法的具体用法?PHP user::instance怎么用?PHP user::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
function tearDown()
{
parent :: tearDown();
$user =& user :: instance();
$user->logout();
}
示例2: run
function run(&$filter_chain, &$request, &$response)
{
debug :: add_timing_point('locale filter started');
if(!$node = map_request_to_node($request))
{
define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
$locale =& locale :: instance();
$locale->setlocale();
$filter_chain->next();
return;
}
if($object_locale_id = site_object :: get_locale_by_id($node['object_id']))
define('CONTENT_LOCALE_ID', $object_locale_id);
else
define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
$user = user :: instance();
if($user_locale_id = $user->get_locale_id())
define('MANAGEMENT_LOCALE_ID', $user_locale_id);
else
define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
debug :: add_timing_point('locale filter finished');
$locale =& locale :: instance();
$locale->setlocale();
$filter_chain->next();
}
示例3: instance
function _login_user($id, $groups)
{
$user =& user :: instance();
$user->_set_id($id);
$user->_set_groups($groups);
}
示例4: tearDown
function tearDown()
{
$this->_clean_up();
$user =& user::instance();
$user->logout();
$this->object->tally();
}
示例5: write
function write($log_file_data, $string)
{
$log_dir = $log_file_data[0];
$log_name = $log_file_data[1];
$file_name = $log_dir . $log_name;
if (!is_dir($log_dir)) {
fs::mkdir($log_dir, 0775, true);
}
$oldumask = @umask(0);
$file_existed = @file_exists($file_name);
$log_file = @fopen($file_name, 'a');
if ($log_file) {
$time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
$notice = '[ ' . $time . " ]\n";
$user =& user::instance();
if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
$notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
}
$notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
@fwrite($log_file, $notice);
@fclose($log_file);
if (!$file_existed) {
@chmod($file_name, 0664);
}
@umask($oldumask);
$result = true;
} else {
@umask($oldumask);
$result = false;
debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
}
return $result;
}
示例6: _valid_perform
function _valid_perform(&$request, &$response)
{
$login = $this->dataspace->get('login');
$password = $this->dataspace->get('password');
$locale_id = $this->dataspace->get('locale_id');
$autologin = $this->dataspace->get('autologin');
$user_object =& site_object_factory::create($this->user_object_class_name);
if ($user_object->login($login, $password, $locale_id)) {
if ($autologin) {
$user =& user::instance();
$user->configure_autologin();
}
$request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
if ($redirect = $this->dataspace->get('redirect')) {
$this->_login_redirect($redirect, $response);
return;
} elseif (isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), '/root/login') === false) {
$response->redirect($_SERVER['HTTP_REFERER']);
return;
} else {
$response->redirect('/');
return;
}
}
$request->set_status(REQUEST_STATUS_FAILURE);
}
示例7: _login_to_chat
function _login_to_chat($nickname)
{
$db =& db_factory::instance();
$time = time();
$sql = "SELECT id, nickname FROM chat_user";
$db->sql_exec($sql);
$chat_users = $db->get_array('id');
$user =& user::instance();
if ($user->is_logged_in()) {
foreach ($chat_users as $data) {
if ($data['nickname'] == $nickname) {
session::set('chat_user_id', $data['id']);
$sql = "UPDATE chat_user \r\n\t\t\t\t\t\t\t\t\tSET time={$time},\r\n\t\t\t\t\t\t\t\t\thost= '{$_SERVER['REMOTE_ADDR']}',\r\n\t\t\t\t\t\t\t\t\tdeleted=0\r\n\t\t\t\t\t\t\t\t WHERE id={$data['id']}";
$db->sql_exec($sql);
return $data['id'];
}
}
} else {
foreach ($chat_users as $data) {
if ($data['nickname'] == $nickname) {
return false;
}
}
}
$sql = "INSERT INTO chat_user (nickname, time, host, deleted) \r\n\t\t\t\t\t values ('{$nickname}', {$time}, '{$_SERVER['REMOTE_ADDR']}', 0)";
$db->sql_exec($sql);
$id = $db->get_sql_insert_id();
chat_user::_set_session_chat_user_id($id);
return true;
}
示例8: _init_dataspace
function _init_dataspace()
{
$data['identifier'] = md5(rand());
$user =& user::instance();
$data['sender'] = $user->get_login();
$data['sender_email'] = $user->get_email();
$this->dataspace->import($data);
}
示例9: _update_log
function _update_log($node_id, $action, $status_code)
{
$ip_register =& $this->_get_ip_register();
$referer_register =& $this->_get_referer_register();
$uri_register =& $this->_get_uri_register();
$user =& user::instance();
$this->db->sql_insert('sys_stat_log', array('ip' => $ip_register->get_client_ip(), 'time' => $this->get_register_time_stamp(), 'node_id' => $node_id, 'stat_referer_id' => $referer_register->get_referer_page_id(), 'stat_uri_id' => $uri_register->get_uri_id(), 'user_id' => $user->get_id(), 'session_id' => session_id(), 'action' => $action, 'status' => $status_code));
}
示例10: instance
function _changing_own_password()
{
$object_data = $this->_load_object_data();
$user =& user :: instance();
return ($object_data['id'] == $user->get_id()) ? true : false;
}
示例11: test_user_in_groups
function test_user_in_groups()
{
$user =& user::instance();
$user->login('vasa', 1);
$this->assertTrue($user->is_in_groups(array(0 => 'members', 'admins')));
$this->assertFalse($user->is_in_groups(array(0 => 'members', 'operators')));
$this->assertFalse($user->is_in_groups(array(0 => 'members')));
$this->assertTrue($user->is_in_groups(array(0 => 'visitors')));
}
示例12: _init_dataspace
function _init_dataspace()
{
$user =& user::instance();
if (!$user->is_logged_in()) {
return;
}
$data = array('name' => $user->get_name() . ' ' . $user->get_lastname(), 'email' => $user->get_email());
$this->dataspace->import($data);
}
示例13: _valid_perform
function _valid_perform()
{
$locale_id = $this->dataspace->get('locale_id');
if (!locale::is_valid_locale_id($locale_id)) {
return new close_popup_response(RESPONSE_STATUS_FAILURE);
}
$user =& user::instance();
$user->set_locale_id($locale_id);
return new close_popup_response(RESPONSE_STATUS_SUCCESS);
}
示例14: _init_dataspace
function _init_dataspace(&$request)
{
parent::_init_dataspace($request);
$data = $this->dataspace->export();
$user =& user::instance();
if (empty($data['comment_author'])) {
$data['comment_author'] = $user->get_login();
}
if (empty($data['comment_author_email'])) {
$data['comment_author_email'] = $user->get_email();
}
$this->dataspace->import($data);
}
示例15: run
function run(&$filter_chain, &$request, &$response)
{
debug::add_timing_point('jip filter started');
$fetcher =& fetcher::instance();
$fetcher->set_jip_status(false);
$user =& user::instance();
if ($user->is_logged_in()) {
$ini =& get_ini('jip_groups.ini');
if ($user->is_in_groups(array_keys($ini->get_group('groups')))) {
$fetcher->set_jip_status(true);
}
}
debug::add_timing_point('jip filter done');
$filter_chain->next();
}