Code Search for Developers
 
 
  

loginAction.php from Brim at Krugle


Show loginAction.php syntax highlighted

<?php

require_once ('framework/realm/Realm.php');
require_once "framework/util/databaseConnection.php";
include ('framework/sql/authQueries.php');

/**
 * This file is part of the Brim project.
 * The brim-project is located at the following
 * location: {@link http://www.brim-project.org/ http://www.brim-project.org/}
 *
 * <pre> Enjoy :-) </pre>
 *
 * @author Barry Nauta - July 2003
 * @package org.brim-project.plugins.framework
 *
 * @copyright [brim-project.org] - Copyright (c) 2003 - 2006 Barry Nauta
 *
 * @license http://opensource.org/licenses/gpl-license.php
 * The GNU Public License
 */

if (isset($_POST['submit']))
{
	//
	// Check whether we would like to signup
	//
	if (isset ($_POST['signUp']))
	{
		global $db, $queries;
		session_start ();
		$_SESSION['signupUsername'] = $_POST['username'];
		$_SESSION['signupPassword'] = $_POST['password'];
		header ("Location: signup.php");
		exit;
	}
	//
	// Check for username and password on POST
	//
	if(!$_POST['username'] | !$_POST['password'])
	{
		$message='msg_provideUsernameAndPassword';
		Header ("Location: login.php?message=".$message);
		exit;
	}
	//
	// Query the database
	//
	$query = sprintf ($queries ['getUsernamePassword'], $_POST['username']);
	$result = $db->Execute($query);
	$dbUsername = trim ($result->fields[0]);
	//
	// Check username
	//
	if ($result == null || $dbUsername == null || $dbUsername == ""
		|| $dbUsername != $_POST['username'])
	{
		$message='msg_unknownUser';
		Header ("Location: login.php?message=".$message);
		exit;
	}
        //
        // Check password
        //
	$theRealm = new Realm ();
	$realm = $theRealm->getInstance();
	$authenticated = $realm->authenticate($_POST['username'],$_POST['password']);
        if (!$authenticated)
        {
		$message='msg_incorrectPassword';
		Header ("Location: login.php?message=".$message);
		exit;
	}
	//
	// Update last login
	///
	$date = date('Y-m-d H:i:s');
	$query = sprintf ($queries['updateLogin'], $date, $_POST['username']);
	$result = $db->Execute($query)
		or die ("Oops, could not update last login information");
	$db->Close ();
	//
	// Start the session
	///
session_start ();
	$_SESSION['brimUsername'] = $_POST['username'];

        $isAdmin = $realm->isMemberOf($_POST['username'],'admin');
        if ($isAdmin)
        {
                $_SESSION['brimUserIsAdmin'] = 'true';
        }
	else
        {
                $_SESSION['brimUserIsAdmin'] = 'false';
        }

	//
	// Only set a cookie if the user has requested it
	///
	if (isset ($_POST['rememberMe']))
	{
		//
		// Build up cookie information
		///
		$cookieId = 'Brim';
		$cookieValue = "username=".$_SESSION['brimUsername'].
			"&password=".$_POST['password'];
		$cookieExpire = time() + 365*24*3600; //365 days
		$cookiePath = "";
		$cookieDomain = "";
		$cookieSecure = 0;
		//
		// And actually set the cookie
		///
		if (!setCookie ($cookieId, $cookieValue, $cookieExpire,
			$cookiePath, $cookieDomain, $cookieSecure))
		{
			die ("Problem setting cookie");
		}
	}
	//
	// Forward to the index page
	//
	Header ('Location: index.php');
	exit;
}
?>




See more files for this project here

Brim

BRIM is a MVC framework, written in PHP and based on items with a hierarchical relationship. The list of plugins make BRIM a Information Manager with plugins like bookmarks, a calendar, contacts tasks, notes, RSS etc. The application is multilingual.

Project homepage: http://sourceforge.net/projects/brim
Programming language(s): JavaScript,PHP,SQL
License: other

  documentation/
    css/
      brim.css
      index.php
    pics/
      background.jpg
      design.png
      feet_booby.jpg
      index.php
      mvc.gif
      question_booby.gif
      question_booby.jpg
      shadow.gif
      shadow2.gif
      shadowAlpha.png
      sleeping_booby.jpg
      treeback.jpg
      white_boobies.jpg
    booby2brim_changes.txt
    changelog.txt
    coding_conventions.html
    contributions.html
    design.html
    directory_structure.html
    faq.html
    gpl.html
    how_to_enable_calendar_reminders_per_email.html
    how_to_enable_calendar_reminders_per_email.txt
    how_to_write_a_template.html
    how_to_write_a_template.txt
    index.php
    installation_guide.html
    mvc.html
    security.html
    todo.txt
    uninstall.html
    upgrade_guide.html
    used_versions.txt
    which_package.html
  ext/
    File/
      IMC/
        Build/
          vCard.php
        Parse/
          vCalendar.php
          vCard.php
        Build.php
        Parse.php
      IMC.php
    Savant/
      Savant/
        docs/
          README
          index.php
        filters/
          Savant_Filter_colorizeCode.php
          Savant_Filter_trimwhitespace.php
          index.php
        plugins/
          Savant_Plugin_ahref.php
          Savant_Plugin_checkbox.php
          Savant_Plugin_checkboxes.php
          Savant_Plugin_cycle.php
          Savant_Plugin_dateformat.php
          Savant_Plugin_image.php
          Savant_Plugin_input.php
          Savant_Plugin_javascript.php
          Savant_Plugin_modify.php
          Savant_Plugin_options.php
          Savant_Plugin_radios.php
          Savant_Plugin_stylesheet.php
          Savant_Plugin_textarea.php
          index.php
        Filter.php
        Plugin.php
        index.php
      Savant.php
      index.php
    adodb/
      contrib/
      datadict/
      drivers/
      lang/
      pear/
      perf/
      session/
      xsl/
      adodb-csvlib.inc.php
    jQuery/
    javascript/
    overlib/
    simpletest/
    JSON.php
    PEAR.php
    index.php
    json.js
    package.xml
  framework/
  plugins/
  templates/
  tools/
  AboutController.php
  AdminController.php
  BookmarkController.php
  BookmarkSidebarController.php
  HelpController.php
  PluginController.php
  PreferenceController.php
  README.txt
  SearchController.php
  SysinfoController.php
  TranslateController.php
  UPGRADE.txt
  UserController.php
  brim.php
  favicon.ico
  index.php
  install.php
  login.php
  loginAction.php
  logout.php
  lostPassword.php
  lostPasswordAction.php
  signup.php
  signupAction.php
  test.php