Пример #1
0
        $username = isset($_POST['username']) ? $_POST['username'] : null;
        $password = isset($_POST['password']) ? $_POST['password'] : null;
        $error = null;
        if (isset($username) && isset($password)) {
            $user_id = checkPassword($username, $password);
            if ($user_id == -1) {
                $error = "Incorrect username/password.";
            } else {
                addToCookie("user_id", $user_id);
            }
        } else {
            $error = "Username or password is empty.";
        }
        if (isset($error)) {
            echo $error . " Try again!<br />";
        }
        break;
    case "logout":
        unsetCookie("user_id");
        $user_id = -1;
        break;
    default:
        $user_id = loggedInUser();
}
// user is logged in
if ($user_id > 0) {
    echo "Hello " . $users[$user_id]['name'] . "! <br />";
    echo "<a href='" . $_SERVER['PHP_SELF'] . "?action=logout'>Logout</a>";
} else {
    loginForm();
}
Пример #2
0
 public function exitAction()
 {
     setSession('user', null);
     unsetCookie('user');
     redirect(url());
 }
Пример #3
0
 *
 * JonesCMS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * JonesCMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JonesCMS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require_once "include/common.php";
unsetCookie();
include 'header.php';
?>
    <div id="main">
      <div id="pageHeader">
        <h1><span>Logout</span></h1>
      </div>
      <div class="contentBox">
        <p>
          Logged out successfully.
        </p>
      </div>
    </div>
<?php 
include 'footer.php';