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