source: trunk/identification.php @ 45

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

optional cookie identification

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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$errors = array();
22if ( isset( $_POST['login'] ) )
23{
24  // retrieving the encrypted password of the login submitted
25  $query = 'select password';
26  $query.= ' from '.PREFIX_TABLE.'users';
27  $query.= " where username = '".$_POST['login']."';";
28  $row = mysql_fetch_array( mysql_query( $query ) );
29  if( $row['password'] == md5( $_POST['pass'] ) )
30  {
31    $session_id = session_create( $_POST['login'] );
32    $url = 'category.php?id='.$session_id;
33    header( 'Request-URI: '.$url );
34    header( 'Content-Location: '.$url ); 
35    header( 'Location: '.$url );
36    exit();
37  }
38  else
39  {
40    array_push( $errors, $lang['invalid_pwd'] );
41  }
42}
43//----------------------------------------------------- template initialization
44$vtp = new VTemplate;
45$handle = $vtp->Open( './template/default/identification.vtp' );
46// language
47$vtp->setGlobalVar( $handle, 'ident_page_title', $lang['ident_page_title'] );
48$vtp->setGlobalVar( $handle, 'ident_title',      $lang['ident_title'] );
49$vtp->setGlobalVar( $handle, 'login',            $lang['login'] );
50$vtp->setGlobalVar( $handle, 'password',         $lang['password'] );
51$vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
52$vtp->setGlobalVar( $handle, 'ident_guest_visit',$lang['ident_guest_visit'] );
53$vtp->setGlobalVar( $handle, 'ident_register',   $lang['ident_register'] );
54$vtp->setGlobalVar( $handle, 'ident_forgotten_password',
55                    $lang['ident_forgotten_password'] );
56// conf
57$vtp->setGlobalVar( $handle, 'mail_webmaster',   $conf['mail_webmaster'] );
58// user
59$vtp->setGlobalVar( $handle, 'user_template',    $user['template'] );
60initialize_template();
61//-------------------------------------------------------------- errors display
62if ( sizeof( $error ) != 0 )
63{
64  $vtp->addSession( $handle, 'errors' );
65  foreach ( $errors as $error ) {
66    $vtp->addSession( $handle, 'li' );
67    $vtp->setVar( $handle, 'li.li', $error );
68    $vtp->closeSession( $handle, 'li' );
69  }
70  $vtp->closeSession( $handle, 'errors' );
71}
72//------------------------------------------------------------------ users list
73// retrieving all the users login
74$query = 'select username from '.PREFIX_TABLE.'users;';
75$result = mysql_query( $query );
76if ( mysql_num_rows ( $result ) < $conf['max_user_listbox'] )
77{
78  $vtp->addSession( $handle, 'select_field' );
79  while ( $row = mysql_fetch_array( $result ) )
80  {
81    if ( $row['username'] != 'guest' )
82    {
83      $vtp->addSession( $handle, 'option' );
84      $vtp->setVar( $handle, 'option.option', $row['username'] );
85      $vtp->closeSession( $handle, 'option' );
86    }
87  }
88  $vtp->closeSession( $handle, 'select_field' );
89}
90else
91{
92  $vtp->addSession( $handle, 'text_field' );
93  $vtp->closeSession( $handle, 'text_field' );
94}
95//-------------------------------------------------------------- visit as guest
96if ( $conf['acces'] == "libre" )
97{
98  $vtp->addSession( $handle, 'guest_visit' );
99  $vtp->closeSession( $handle, 'guest_visit' );
100}
101//---------------------------------------------------------------- registration
102if ( $conf['acces'] == "libre" )
103{
104  $vtp->addSession( $handle, 'register' );
105  $vtp->closeSession( $handle, 'register' );
106}
107//----------------------------------------------------------- html code display
108$code = $vtp->Display( $handle, 0 );
109echo $code;
110//------------------------------------------------------------ log informations
111$query = 'insert into '.PREFIX_TABLE.'history';
112$query.= '(date,login,IP,page) values';
113$query.= "('".time()."', '".$user['pseudo'];
114$query.= "','$REMOTE_ADDR','identification');";
115$result = mysql_query( $query );
116?>
Note: See TracBrowser for help on using the repository browser.