本文整理汇总了PHP中user_logged_in函数的典型用法代码示例。如果您正苦于以下问题:PHP user_logged_in函数的具体用法?PHP user_logged_in怎么用?PHP user_logged_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_logged_in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*
* @return void
*/
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('info', 'Controller Class Initialized');
user_logged_in();
//echo $user_type = $this->session->userdata['department'];
$valid_method = get_restricted_department();
$user_type = strtolower($this->session->userdata['department']);
if(in_array($user_type, $valid_method)) {
user_authentication($user_type);
}
}
示例2: content
function content()
{
if (!user_logged_in()) {
return must_log_in();
}
$user = fetch_one_or_none('users', 'id', user_logged_in());
if (!array_key_exists('token', $_GET) || !$_GET['token'] || $_GET['token'] != sha1($user->new_email_address)) {
$errors[] = 'Invalid reset token';
}
# This can happen if two accounts try to change address at similar times.
if (count($errors) == 0 && count(fetch_all('users', 'email_address', $user->new_email_address))) {
$errors[] = "A user with this email address already exists";
}
if (count($errors) == 0) {
update_all('users', array('email_address' => $user->new_email_address, 'new_email_address' => null), 'id', user_logged_in());
?>
<h2>Address changed</h2>
<p>Your email address has been changed to
<tt><?php
esc($user->new_email_address);
?>
</tt>.</p>
<?php
return;
}
page_header('Address verification failed');
show_error_list($errors);
}
示例3: content
function content()
{
if (!user_logged_in()) {
return must_log_in();
}
$user = fetch_one_or_none('users', 'id', user_logged_in());
$errors = array();
if (array_key_exists('change', $_POST)) {
if (!isset($_POST['email']) || !$_POST['email']) {
$errors[] = "Please enter an email address";
} else {
$email = $_POST['email'];
if ($email && !validate_email_address($email)) {
$errors[] = "Invalid email address";
}
if (count($errors) == 0 && count(fetch_all('users', 'email_address', $email))) {
$errors[] = "A user with this email address already exists";
}
if (count($errors) == 0) {
update_all('users', array('new_email_address' => $email), 'id', user_logged_in());
send_email_change_email($email, $user->name);
?>
<p>We have sent an email to your new address requesting that you
confirm that change of address.</p>
<?php
return;
}
}
}
$fields = array();
page_header('Change email address');
show_error_list($errors);
?>
<form method="post" action="" accept-charset="UTF-8">
<div class="fieldrow">
<div class="field">
<label>Current address:</label>
<div><tt><?php
esc($user->email_address);
?>
</tt></div>
</div>
</div>
<div class="fieldrow">
<?php
text_field($fields, 'email', 'New address');
?>
</div>
<div class="fieldrow">
<input type="submit" name="change" value="Change"/>
</div>
</form>
<?php
}
示例4: require_login
function require_login($target_page = 'login.php')
{
if (!user_logged_in()) {
$src = strtolower(basename($_SERVER['PHP_SELF']));
if (!in_array($src, array('login.php'))) {
header('Location:' . $target_page);
}
}
}
示例5: content
function content()
{
global $config;
if (!user_logged_in()) {
return must_log_in();
}
$errors = array();
if (!array_key_exists('id', $_GET)) {
$errors[] = 'No user ID';
}
if (count($errors) == 0) {
$user = fetch_one_or_none('users', 'id', $_GET['id']);
if (!$user) {
$errors[] = 'No such user';
}
if (!$user->date_verified) {
$errors[] = 'User has not yet been verified';
}
if ($user->date_approved) {
$errors[] = 'User has already been approved';
}
}
if (count($errors)) {
page_header("Error approving account");
show_error_list($errors);
return;
}
if (!$user->date_approved) {
update_all('users', array('date_approved' => date('Y-m-d H:i:s'), 'approved_by' => user_logged_in()), 'id', $user->id);
}
$root = 'http://' . $config['domain'] . $config['http_path'];
$msg = "Your " . $config['title'] . " account has been approved. " . "To log in, please follow \n" . "the following link:\n" . "\n" . " {$root}account/login\n" . "\n";
mail(sprintf('"%s" <%s>', $user->name, $user->email_address), $config['title'] . " account approved", $msg) or die('Unable to send email');
register_user_rdf($user);
page_header("Account approved");
?>
<p>Thank you for approving <?php
esc($user->name);
?>
's account.</p>
<?php
}
示例6: menu
function menu()
{
global $config;
$root = $config['http_path'];
?>
<ul>
<li><a href="<?php
esc($root);
?>
">Home</a></li>
<?php
if (user_logged_in()) {
?>
<li><a href="<?php
esc($root);
?>
files">Files</a></li>
<li><a href="<?php
esc($root);
?>
account">Account</a></li>
<li><a href="<?php
esc($root);
?>
account/logout">Log out</a></li>
<?php
} else {
?>
<li><a href="<?php
esc($root);
?>
account/register">Register</a></li>
<li><a href="<?php
esc($root);
?>
account/login">Log in</a></li>
<?php
}
?>
</ul>
<?php
}
示例7: content
function content()
{
if (!user_logged_in()) {
return must_log_in();
}
$errors = array();
if (array_key_exists('upload', $_POST)) {
if (!array_key_exists('file', $_FILES) || filesize($_FILES['file']['tmp_name']) == 0) {
$errors[] = 'Please supply a file';
}
if (count($errors) == 0) {
preg_match('/\\.([^\\/.]+)$/', $_FILES['file']['name'], $matches);
$file_id = do_upload($_FILES['file']['tmp_name'], $_FILES['file']['type'], $matches[1], $_FILES['file']['size']);
page_header('File uploaded');
?>
<?php
return;
}
}
page_header('Upload file');
show_error_list($errors);
?>
<form enctype="multipart/form-data" action="" method="post">
<div class="fieldrow">
<div>
<label for="file">Select an image
<span class="label-extra">(size limit: 8MB)</span></label>
<input id="file" name="file" type="file" />
</div>
</div>
<div class="fieldrow">
<input type="submit" name="upload" value="Upload" />
</div>
</form>
<?php
}
示例8: content
function content()
{
if (!user_logged_in()) {
return must_log_in();
}
$files = fetch_wol('*', 'files', sprintf("user_id=%d", user_logged_in()));
if (count($files) == 0) {
?>
<p>You have not <a href="upload">uploaded</a> any files.</p>
<?php
return;
}
?>
<table class="data">
<?php
foreach ($files as $f) {
?>
<tr><td class="file-id"><a href="<?php
esc($f->id . '.' . $f->extension);
?>
"><?php
esc(sprintf("%06d", $f->id));
?>
</a></td>
<td><?php
esc(date_format('Y-m-d H:i:s', $f->date_uploaded));
?>
</td>
<td><?php
esc(format_size($f->length));
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
示例9: render_graph_new
/**
* Render the HTML on the page necessary for rendering a graph to the user.
*
* @param $graph = array(
* 'graph_type' => $id,
* 'width' => 8,
* 'height' => 4,
* 'page_order' => 0,
* 'days' => $days,
* 'id' => 0,
* 'arg0_resolved' => $name,
* 'delta' => $delta,
* 'public' => true,
* 'no_technicals' => true,
* );
* @param $include_user_hash if true, include user_id and user_hash in the graph data, necessary for
* graphs that require user authentication; default is false
*/
function render_graph_new($graph, $include_user_hash = false)
{
global $_rendered_graph_contents;
if (!$_rendered_graph_contents) {
// calculate the relevant text for outofdate indicators
$title = "";
if (user_logged_in()) {
$user = get_user(user_id());
$plural_hours = plural("hour", user_is_new($user) ? get_site_config('refresh_queue_hours_premium') : get_premium_value($user, "refresh_queue_hours"));
if ($user['is_first_report_sent']) {
$title = t("This graph will take up to :hours to be updated with recently added or removed accounts.", array(':hours' => $plural_hours));
} else {
if ($user['has_added_account']) {
$title = t("As a new user, it will take up to :hours for this graph to be populated with initial data.", array(':hours' => $plural_hours));
} else {
$title = t("You need to add some account data for this graph to display.");
}
}
}
?>
<div id="graph_contents_template" style="display:none;">
<div class="graph_headings">
<h1 class="h1"></h1>
<h2 class="h2"></h2>
<h2 class="graph_title">
<a href=""></a>
</h2>
<span class="outofdate" style="display:none;" title="<?php
echo htmlspecialchars($title);
?>
"></span>
<span class="subheading"></span>
<span class="last-updated"></span>
<ul class="graph_controls">
<li class="move_up"><a><?php
echo ht("Move up");
?>
</a></li>
<li class="move_down"><a><?php
echo ht("Move down");
?>
</a></li>
<li class="remove"><a><?php
echo ht("Remove");
?>
</a></li>
<li class="edit"><a><?php
echo ht("Edit");
?>
</a></li>
</ul>
<div class="edit_target" style="display:none;">
<ul class="graph_edit_controls">
<li class="close"><a><?php
echo ht("Close");
?>
</a></li>
</ul>
</div>
</div>
<div class="graph-target"><span class="status_loading"><?php
echo ht("Loading...");
?>
</span></div>
<div class="graph_extra extra" style="display:none;"><a href="#"></a></span></div>
<div class="admin-stats-wrapper hide-admin"><span class="admin-stats render_time"></span></div>
</div>
<div id="graph_table_template" class="overflow_wrapper extra-text-container" style="display:none;">
<table class="standard graph_table">
</table>
</div>
<?php
}
if (user_logged_in()) {
$user = get_user(user_id());
$graph['can_be_edited'] = !($user['graph_managed_type'] == 'auto' && isset($graph['is_managed']) && $graph['is_managed']);
}
if (isset($graph['page_id']) && isset($graph['id'])) {
$graph['move_up_link'] = url_for('profile', array('page' => $graph['page_id'], 'move_up' => $graph['id']));
$graph['move_down_link'] = url_for('profile', array('page' => $graph['page_id'], 'move_down' => $graph['id']));
$graph['remove_link'] = url_for('profile', array('page' => $graph['page_id'], 'remove' => $graph['id']));
}
//.........这里部分代码省略.........
示例10: header
<?php
require_once 'config.php';
require_once 'auth.php';
require_once 'verify_lib.php';
header("Content-Type: application/json");
if ($https && !isset($_SERVER['HTTPS'])) {
// We're using mod_rewrite .htaccess for HTTPS redirect; this shouldn't happen
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
exit;
}
if (!user_logged_in()) {
exit(json_encode(array('error' => 'not_logged_in')));
}
if (!isset($_POST['email']) || !isset($_POST['new_password']) || !isset($_POST['old_password'])) {
exit(json_encode(array('error' => 'invalid_parameters')));
}
$user = get_viewer_id();
$old_password = $_POST['old_password'];
$new_password = $_POST['new_password'];
$email = $_POST['email'];
$result = $conn->query("SELECT username, email, hash FROM users WHERE id=\"{$user}\"");
$user_row = $result->fetch_assoc();
if (!$user_row) {
exit(json_encode(array('error' => 'internal_error')));
}
if (!password_verify($old_password, $user_row['hash'])) {
exit(json_encode(array('error' => 'invalid_credentials')));
}
$change_email = "";
if ($user_row['email'] !== $email) {
示例11: array
<?php
/**
* This page displays historical data publically.
*/
require __DIR__ . "/../layout/graphs.php";
require __DIR__ . "/../layout/templates.php";
$messages = array();
$errors = array();
$historical_graphs = graph_types_public();
$permitted_days = get_permitted_days();
$permitted_deltas = get_permitted_deltas();
$days = isset($permitted_days[require_get('days', false)]) ? $permitted_days[require_get('days')]['days'] : 45;
$delta = isset($permitted_deltas[require_get('delta', false)]) ? require_get('delta') : '';
$user = user_logged_in() ? get_user(user_id()) : false;
$id = require_get("id", false);
if ($id && isset($historical_graphs[$id])) {
// we're displaying a specific graph
$name = require_get('name', false);
$title = $name;
// if we've got a name, then we want to get the title too
if (isset($historical_graphs[$id]['title_callback'])) {
$callback = $historical_graphs[$id]['title_callback'];
$title = $callback($id, $title);
}
$heading = $historical_graphs[$id]["heading"] . ($title ? ": " . $title : "");
page_header(t("Historical Data: :heading", array(':heading' => $heading)), "page_historical", array('jsapi' => true));
$graph = array('graph_type' => $id, 'width' => 8, 'height' => 4, 'page_order' => 0, 'days' => $days, 'id' => 0, 'arg0_resolved' => $name, 'delta' => $delta, 'public' => true, 'no_technicals' => true);
$extra_args = $name ? array("name" => $name) : array();
$extra_args['id'] = $id;
$extra_args['days'] = $days;
示例12: deleteMyCookie
if (isset($_POST['mode']) and $_POST['mode'] == 'login') {
require $pathToFiles . 'bb_func_login.php';
}
if ($loginError == 0) {
if (isset($_GET['mode']) and $_GET['mode'] == 'logout') {
deleteMyCookie();
if (isset($metaLocation)) {
$meta_relocate = "{$main_url}/{$indexphp}";
echo ParseTpl(makeUp($metaLocation));
exit;
} else {
header("Location: {$main_url}/{$startIndex}");
exit;
}
}
user_logged_in();
if ($user_id != 0 and isset($langu) and $langu = str_replace(array('.', '/', '\\'), '', $langu) and file_exists($pathToFiles . "lang/{$langu}.php")) {
$lang = $langu;
} elseif ($user_id == 0 and isset($_GET['setlang']) and $setlang = str_replace(array('.', '/', '\\'), '', $_GET['setlang']) and file_exists($pathToFiles . "lang/{$setlang}.php")) {
$lang = $setlang;
$indexphp .= 'setlang=' . $setlang . '&';
}
if ($user_id > 0 and !isset($_COOKIE[$cookiename . '_csrfchk'])) {
setCSRFCheckCookie();
}
include $pathToFiles . "lang/{$lang}.php";
$actEnable = isset($GLOBALS['user_activity']) ? $GLOBALS['user_activity'] : 1;
$actTrue = ($actEnable == -1 and ($action == 'prefs' or $action == 'editprefs' or $action == 'confirmpasswd'));
if ($actEnable == 0 or $actEnable != 1 and !$actTrue) {
$forb = 2;
} else {
示例13: json_decode
if (isset($_COOKIE['nvsa_session'])) {
$kp_session = (array) json_decode(base64_decode($_COOKIE['nvsa_session']));
if (!isset($logged_in_user)) {
$logged_in_user = new NVSA_USER($session_db, $kp_session);
}
$qry = "INSERT INTO `wb-user-meta` (user_id,meta_key,meta_value) VALUES ('" . $logged_in_user->ID() . "','last_accessed', CURRENT_TIMESTAMP)" . "ON DUPLICATE KEY UPDATE meta_value=CURRENT_TIMESTAMP;";
$session_db->query($qry);
}
// note: tuck all echo statments away so they cannot accidentally fire
// when this file is included. Only available upon "Action" request
if (isset($_POST['action']) && $_POST['action'] !== '') {
// if attempting to login
if ($_POST['action'] == 'login') {
// if ( user_logged_in(true)==true )
// $_SESSION['session_id'] = $mySession->session_lock;
$json['logged_in'] = user_logged_in(true);
$json['login_html'] = get_login_link();
// there is no else because the login_error would be set in the function user_logged_in
echo json_encode($json);
} elseif ($_POST['action'] == 'logout') {
if (logged_out() == true) {
$json['login_html'] = get_login_link();
}
echo json_encode($json);
}
// end if login
}
// end if action set
} else {
ob_start();
echo "<p>";
示例14: is_admin
/**
* Is the current user an administrator?
* Once called, may cached across the length of the script.
*
* @return true if admin, false if not. always returns false if NO_SESSION is defined
*/
function is_admin()
{
if (defined('NO_SESSION')) {
// a sessionless request can never be admin
return false;
}
if (!user_logged_in()) {
return false;
}
$q = db()->prepare("SELECT * FROM user_properties WHERE id=?");
$q->execute(array(user_id()));
$user = $q->fetch();
return $user['is_admin'];
}
示例15: protect_page
function protect_page()
{
if (user_logged_in() === false) {
header('Location: protected.php');
exit;
}
}