source: trunk/identification.php @ 354

Last change on this file since 354 was 354, checked in by gweltas, 20 years ago

Migration of common.php in the include directory to fit the new coding rules

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                           identification.php                                |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : 1.4                                                   |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-02-07 19:36:44 +0000 (Sat, 07 Feb 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 354 $
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// +-----------------------------------------------------------------------+
27
28//----------------------------------------------------------- include
29$phpwg_root_path = './';
30include_once( $phpwg_root_path.'include/common.inc.php' );
31
32//-------------------------------------------------------------- identification
33$errors = array();
34if ( isset( $_POST['login'] ) )
35{
36  // retrieving the encrypted password of the login submitted
37  $query = 'SELECT password';
38  $query.= ' FROM '.USERS_TABLE;
39  $query.= " WHERE username = '".$_POST['login']."';";
40  $row = mysql_fetch_array( mysql_query( $query ) );
41  if( $row['password'] == md5( $_POST['pass'] ) )
42  {
43    $session_id = session_create( $_POST['login'] );
44    $url = 'category.php?id='.$session_id;
45    header( 'Request-URI: '.$url );
46    header( 'Content-Location: '.$url ); 
47    header( 'Location: '.$url );
48    exit();
49  }
50  else
51  {
52    array_push( $errors, $lang['invalid_pwd'] );
53  }
54}
55//----------------------------------------------------- template initialization
56//
57// Start output of page
58//
59$title = $lang['ident_page_title'];
60include('include/page_header.php');
61
62$handle = $vtp->Open( './template/default/identification.vtp' );
63// language
64$vtp->setGlobalVar( $handle, 'ident_title',      $lang['ident_title'] );
65$vtp->setGlobalVar( $handle, 'login',            $lang['login'] );
66$vtp->setGlobalVar( $handle, 'password',         $lang['password'] );
67$vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
68$vtp->setGlobalVar( $handle, 'ident_guest_visit',$lang['ident_guest_visit'] );
69$vtp->setGlobalVar( $handle, 'ident_register',   $lang['ident_register'] );
70$vtp->setGlobalVar( $handle, 'ident_forgotten_password',
71                    $lang['ident_forgotten_password'] );
72// conf
73$vtp->setGlobalVar( $handle, 'mail_webmaster',   $conf['mail_webmaster'] );
74// user
75$vtp->setGlobalVar( $handle, 'user_template',    $user['template'] );
76initialize_template();
77//-------------------------------------------------------------- errors display
78if ( sizeof( $errors ) != 0 )
79{
80  $vtp->addSession( $handle, 'errors' );
81  foreach ( $errors as $error ) {
82    $vtp->addSession( $handle, 'li' );
83    $vtp->setVar( $handle, 'li.li', $error );
84    $vtp->closeSession( $handle, 'li' );
85  }
86  $vtp->closeSession( $handle, 'errors' );
87}
88//------------------------------------------------------------------ users list
89// retrieving all the users login
90$query = 'select username from '.USERS_TABLE.';';
91$result = mysql_query( $query );
92if ( mysql_num_rows ( $result ) < $conf['max_user_listbox'] )
93{
94  $vtp->addSession( $handle, 'select_field' );
95  while ( $row = mysql_fetch_array( $result ) )
96  {
97    if ( $row['username'] != 'guest' )
98    {
99      $vtp->addSession( $handle, 'option' );
100      $vtp->setVar( $handle, 'option.option', $row['username'] );
101      $vtp->closeSession( $handle, 'option' );
102    }
103  }
104  $vtp->closeSession( $handle, 'select_field' );
105}
106else
107{
108  $vtp->addSession( $handle, 'text_field' );
109  $vtp->closeSession( $handle, 'text_field' );
110}
111//-------------------------------------------------------------- visit as guest
112if ( $conf['access'] == 'free' )
113{
114  $vtp->addSession( $handle, 'guest_visit' );
115  $vtp->closeSession( $handle, 'guest_visit' );
116}
117//---------------------------------------------------------------- registration
118if ( $conf['access'] == 'free' )
119{
120  $vtp->addSession( $handle, 'register' );
121  $vtp->closeSession( $handle, 'register' );
122}
123//----------------------------------------------------------- html code display
124$code = $vtp->Display( $handle, 0 );
125echo $code;
126include('include/page_tail.php');
127?>
Note: See TracBrowser for help on using the repository browser.