source: trunk/identification.php @ 402

Last change on this file since 402 was 402, checked in by z0rglub, 20 years ago

code refactoring

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
RevLine 
[2]1<?php
[354]2// +-----------------------------------------------------------------------+
[362]3// |                          identification.php                           |
[354]4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
[362]6// | branch        : BSF (Best So Far)                                     |
[354]7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-03-29 22:40:21 +0000 (Mon, 29 Mar 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 402 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
[2]27
[402]28//--------------------------------------------------------------------- include
[364]29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[345]31
[2]32//-------------------------------------------------------------- identification
[45]33$errors = array();
[2]34if ( isset( $_POST['login'] ) )
35{
36  // retrieving the encrypted password of the login submitted
[87]37  $query = 'SELECT password';
[345]38  $query.= ' FROM '.USERS_TABLE;
[365]39  $query.= " WHERE username = '".$_POST['username']."';";
[2]40  $row = mysql_fetch_array( mysql_query( $query ) );
[375]41  if( $row['password'] == md5( $_POST['password'] ) )
[2]42  {
[365]43    $session_id = session_create( $_POST['username'] );
[2]44    $url = 'category.php?id='.$session_id;
[402]45    redirect( $url );
[9]46    header( 'Request-URI: '.$url );
47    header( 'Content-Location: '.$url ); 
48    header( 'Location: '.$url );
[2]49    exit();
50  }
51  else
52  {
[45]53    array_push( $errors, $lang['invalid_pwd'] );
[2]54  }
55}
56//----------------------------------------------------- template initialization
[345]57//
58// Start output of page
59//
60$title = $lang['ident_page_title'];
[369]61include(PHPWG_ROOT_PATH.'include/page_header.php');
[345]62
[365]63$template->set_filenames( array('identification'=>'identification.tpl') );
64
[402]65$template->assign_vars(
66  array(
67    'MAIL_ADMIN' => $conf['mail_webmaster'],
68   
69    'L_TITLE' => $lang['ident_title'],
70    'L_USERNAME' => $lang['login'],
71    'L_PASSWORD' => $lang['password'],
72    'L_LOGIN' => $lang['submit'],
73    'L_GUEST' => $lang['ident_guest_visit'],
74    'L_REGISTER' => $lang['ident_register'],
75    'L_FORGET' => $lang['ident_forgotten_password'], 
76   
77    'T_STYLE' => $user['template'],
78   
79    'F_LOGIN_ACTION' => add_session_id('identification.php')
80    ));
[2]81//-------------------------------------------------------------- errors display
[87]82if ( sizeof( $errors ) != 0 )
[2]83{
[365]84  $template->assign_block_vars('errors',array());
85  for ( $i = 0; $i < sizeof( $errors ); $i++ )
[2]86  {
[365]87    $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
[2]88  }
89}
[365]90
[2]91//-------------------------------------------------------------- visit as guest
[104]92if ( $conf['access'] == 'free' )
[2]93{
[365]94  $template->assign_block_vars('free_access',array());
[2]95}
96//----------------------------------------------------------- html code display
[365]97$template->pparse('identification');
[369]98include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]99?>
Note: See TracBrowser for help on using the repository browser.