コード例 #1
0
 public static function getUserLoggedIn()
 {
     if (isset($_SESSION['user'])) {
         $user_id = $_SESSION['user'];
         $user = User::findByID($user_id);
         return $user;
     }
     return null;
 }
 /**
  * Get the current logged in user
  *
  * @return mixed  User object if logged in, null otherwise
  */
 public function getCurrentUser()
 {
     if ($this->_currentUser === null) {
         if (isset($_SESSION['user_id'])) {
             // Cache the object so that in a single request the data is loaded from the database only once.
             $this->_currentUser = User::findByID($_SESSION['user_id']);
         }
     }
     return $this->_currentUser;
 }
 /**
  * Get the current logged in user
  *
  * @return mixed  User object if logged in, null otherwise
  */
 public function getCurrentUser()
 {
     if ($this->_currentUser === null) {
         if (isset($_SESSION['user_id'])) {
             // Cache the object so that in a single request the data is loaded from the database only once.
             $this->_currentUser = User::findByID($_SESSION['user_id']);
         } else {
             // Login from the remember me cookie if set
             $this->_currentUser = $this->_loginFromCookie();
         }
     }
     return $this->_currentUser;
 }
コード例 #4
0
ファイル: index.php プロジェクト: RezNikTaylor/RNK-Redesign
	<h2>Mail</h2>
	<h3>Inbox</h3>

<?php 
getAlerts();
?>

<?php 
if (count($msgs)) {
    ?>
	<table class="table table-hover">
		<tbody>
		<?php 
    foreach ($msgs as $msg) {
        $fromUser = User::findByID($msg->id);
        ?>
			<tr>
				<td><?php 
        echo $fromUser->fullName();
        ?>
</td>
				<td>
					<?php 
        echo substr($msg->message, 0, 30);
        if (strlen($msg->message) > 30) {
            echo "...";
        }
        ?>
				</td>
				<td><?php 
コード例 #5
0
<?php

require_once "models/User.php";
require_once "models/DB.php";
require_once "models/Post.php";
session_start();
if (!isset($_SESSION["user"])) {
    $user = new User();
    $user->username = "******";
} else {
    $user = $_SESSION["user"];
}
if (isset($_GET["post_id"])) {
    $post_id = $_GET["post_id"];
    $_SESSION["post_id"] = $post_id;
    $post = new Post();
    $post->findByID($post_id, $dbh);
    $postAuthor = User::findByID($post->author_id, $dbh);
    $users = User::findAll($dbh);
    require_once "views/comments.php";
} else {
    //no id, no post for you
    require_once "Posts.php";
}
コード例 #6
0
ファイル: loginCheck.php プロジェクト: atomic-apple/gesoffice
<ul class="nav navbar-nav navbar-right">
	<?php 
if ($session->isSignedIn()) {
    $nom = User::findByID($_SESSION['user_id']);
    echo "<li><a>Hello, " . $nom->userName . "</a></li>";
    echo "<li><a href='logout.php'>Log Out</a></li>";
} else {
    echo "<li><a>Not Logged In</a></li>";
}
?>
</ul>
コード例 #7
0
ファイル: message.php プロジェクト: glvv/Keskustelufoorumi
 private static function createNewMessageFromResult($row)
 {
     $author = User::findByID($row['author']);
     return new Message(array('id' => $row['id'], 'author' => $author, 'posted' => $row['posted'], 'message' => $row['message'], 'topic_id' => $row['topic_id']));
 }
コード例 #8
0
<?php

/**
 * User admin - show a user
 */
// Initialisation
require_once '../../includes/init.php';
// Require the user to be logged in before they can see this page.
Auth::getInstance()->requireLogin();
// Require the user to be an administrator before they can see this page.
Auth::getInstance()->requireAdmin();
// Get the user
if (isset($_GET['id'])) {
    $user = User::findByID($_GET['id']);
}
// Show 404 if user not found
if (!isset($user)) {
    header('HTTP/1.0 404 Not Found');
    echo '404 Not Found';
    exit;
}
// Show the page header, then the rest of the HTML
include '../../includes/header.php';
?>

<h1>User</h1>

<p><a href="/admin/users">&laquo; back to list of users</a></p>

<dl>
  <dt>Name</dt>