source: trunk/identification.php @ 26

Last change on this file since 26 was 26, checked in by z0rglub, 21 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1<?php
2/***************************************************************************
3 *                            identification.php                           *
4 *                            ------------------                           *
5 *   application          : PhpWebGallery 1.3                              *
6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
7 *                                                                         *
8 ***************************************************************************/
9
10/***************************************************************************
11 *                                                                         *
12 *   This program is free software; you can redistribute it and/or modify  *
13 *   it under the terms of the GNU General Public License as published by  *
14 *   the Free Software Foundation;                                         *
15 *                                                                         *
16 ***************************************************************************/
17
18//----------------------------------------------------------- personnal include
19include_once( "./include/init.inc.php" );
20//-------------------------------------------------------------- identification
21$error = array();
22if ( isset( $_POST['login'] ) )
23{
24  $i = 0;
25  // retrieving the encrypted password of the login submitted
26  $query = 'select password';
27  $query.= ' from '.PREFIX_TABLE.'users';
28  $query.= " where username = '".$_POST['login']."';";
29  $row = mysql_fetch_array( mysql_query( $query ) );
30  if( $row['password'] == md5( $_POST['pass'] ) )
31  {
32    $session_id = session_create( $_POST['login'] );
33    $url = 'category.php?id='.$session_id;
34    header( 'Request-URI: '.$url );
35    header( 'Content-Location: '.$url ); 
36    header( 'Location: '.$url );
37    exit();
38  }
39  else
40  {
41    $error[$i++] = $lang['invalid_pwd'];
42  }
43}
44//----------------------------------------------------- template initialization
45$vtp = new VTemplate;
46$handle = $vtp->Open( './template/default/identification.vtp' );
47// language
48$vtp->setGlobalVar( $handle, 'ident_page_title', $lang['ident_page_title'] );
49$vtp->setGlobalVar( $handle, 'ident_title',      $lang['ident_title'] );
50$vtp->setGlobalVar( $handle, 'login',            $lang['login'] );
51$vtp->setGlobalVar( $handle, 'password',         $lang['password'] );
52$vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
53$vtp->setGlobalVar( $handle, 'ident_guest_visit',$lang['ident_guest_visit'] );
54$vtp->setGlobalVar( $handle, 'ident_register',   $lang['ident_register'] );
55$vtp->setGlobalVar( $handle, 'ident_forgotten_password',
56                    $lang['ident_forgotten_password'] );
57// conf
58$vtp->setGlobalVar( $handle, 'mail_webmaster',   $conf['mail_webmaster'] );
59// user
60$vtp->setGlobalVar( $handle, 'user_template',    $user['template'] );
61initialize_template();
62//-------------------------------------------------------------- errors display
63if ( sizeof( $error ) != 0 )
64{
65  $vtp->addSession( $handle, 'errors' );
66  for ( $i = 0; $i < sizeof( $error ); $i++ )
67  {
68    $vtp->addSession( $handle, 'li' );
69    $vtp->setVar( $handle, 'li.li', $error[$i] );
70    $vtp->closeSession( $handle, 'li' );
71  }
72  $vtp->closeSession( $handle, 'errors' );
73}
74//------------------------------------------------------------------ users list
75// retrieving all the users login
76$query = 'select username from '.PREFIX_TABLE.'users;';
77$result = mysql_query( $query );
78if ( mysql_num_rows ( $result ) < $conf['max_user_listbox'] )
79{
80  $vtp->addSession( $handle, 'select_field' );
81  while ( $row = mysql_fetch_array( $result ) )
82  {
83    if ( $row['username'] != 'guest' )
84    {
85      $vtp->addSession( $handle, 'option' );
86      $vtp->setVar( $handle, 'option.option', $row['username'] );
87      $vtp->closeSession( $handle, 'option' );
88    }
89  }
90  $vtp->closeSession( $handle, 'select_field' );
91}
92else
93{
94  $vtp->addSession( $handle, 'text_field' );
95  $vtp->closeSession( $handle, 'text_field' );
96}
97//-------------------------------------------------------------- visit as guest
98if ( $conf['acces'] == "libre" )
99{
100  $vtp->addSession( $handle, 'guest_visit' );
101  $vtp->closeSession( $handle, 'guest_visit' );
102}
103//---------------------------------------------------------------- registration
104if ( $conf['acces'] == "libre" )
105{
106  $vtp->addSession( $handle, 'register' );
107  $vtp->closeSession( $handle, 'register' );
108}
109//----------------------------------------------------------- html code display
110$code = $vtp->Display( $handle, 0 );
111echo $code;
112//------------------------------------------------------------ log informations
113$query = 'insert into '.PREFIX_TABLE.'history';
114$query.= '(date,login,IP,page) values';
115$query.= "('".time()."', '".$user['pseudo'];
116$query.= "','$REMOTE_ADDR','identification');";
117$result = mysql_query( $query );
118?>
Note: See TracBrowser for help on using the repository browser.