171 lines
4.6 KiB
PHP
Executable File
171 lines
4.6 KiB
PHP
Executable File
<?php
|
|
#########################################################
|
|
# #
|
|
# Functions to handle users for pae.co.at #
|
|
# written by benjamin ramey #
|
|
# bsr@rameydesign.net #
|
|
# #
|
|
# best viewed with: #
|
|
# resolution = 1280x960 #
|
|
# tab = 4 spaces #
|
|
# indent = 8 spaces #
|
|
# #
|
|
###################################################################################################### central brains of users processing
|
|
# parameters: none
|
|
# returns: nothing
|
|
function users_switchboard()
|
|
{
|
|
global $_CMDS;
|
|
|
|
switch($_CMDS['query'][0])
|
|
{
|
|
case 'login':
|
|
if(empty($_POST['username']) or empty($_POST['password'])) {
|
|
include 'html/html_header.php';
|
|
users_display_login_form();
|
|
include 'html/html_footer.php';
|
|
}
|
|
else { users_login(); }
|
|
break;
|
|
case 'logout':
|
|
users_logout();
|
|
break;
|
|
case 'panel':
|
|
if($_SESSION['_loggedin']) {
|
|
include 'functions/flow_usercontrolpanel.php';
|
|
}
|
|
else {
|
|
include 'html/html_header.php';
|
|
users_display_login_form();
|
|
include 'html/html_footer.php';
|
|
}
|
|
break;
|
|
# SCHEDULE adding/editing/deleting
|
|
case 'addschedule':
|
|
schedule_add($_POST);
|
|
include 'flow_usercontrolpanel.php';
|
|
break;
|
|
case 'editschedule':
|
|
if(isset($_POST['doediting']))
|
|
{
|
|
schedule_edit($_POST);
|
|
include 'functions/flow_usercontrolpanel.php';
|
|
}
|
|
else
|
|
{
|
|
include 'functions/flow_editschedule.php';
|
|
}
|
|
break;
|
|
case 'deleteschedule':
|
|
schedule_delete($_POST);
|
|
include 'flow_usercontrolpanel.php';
|
|
break;
|
|
# EVENTS adding/editing/deleting
|
|
case 'addevent':
|
|
events_add($_POST);
|
|
include 'flow_usercontrolpanel.php';
|
|
break;
|
|
case 'editevent':
|
|
if(isset($_POST['doediting']))
|
|
{
|
|
events_edit($_POST);
|
|
include 'functions/flow_usercontrolpanel.php';
|
|
}
|
|
else
|
|
{
|
|
include 'functions/flow_editevent.php';
|
|
}
|
|
break;
|
|
case 'deleteevent':
|
|
events_delete($_POST);
|
|
include 'flow_usercontrolpanel.php';
|
|
break;
|
|
default:
|
|
users_display_login_form();
|
|
break;
|
|
}
|
|
}
|
|
|
|
###################################################################################################### attempts to log a user in
|
|
# parameters: none
|
|
# returns: nothing
|
|
function users_login()
|
|
{
|
|
global $_CONFIG,$_PATH_PREFIX,$_LANG;
|
|
$lopw_users = file($_CONFIG['user_lopw_file']);
|
|
$phrase = file_get_contents($_CONFIG['phrase_file']);
|
|
$username = $_POST['username'];
|
|
$password = $_POST['password'];
|
|
$user_digest = sha1($password.$username.$phrase);
|
|
$_SESSION['_loggedin'] = 0;
|
|
|
|
foreach($lopw_users as $user) {
|
|
list($name,$digest,$user_type) = explode(':',$user);
|
|
if($name == $username and $user_digest == $digest) {
|
|
$_SESSION['_loggedin'] = 1;
|
|
$_SESSION['_usertype'] = $user_type;
|
|
}
|
|
}
|
|
|
|
if($_SESSION['_loggedin']) {
|
|
header("Location: $_PATH_PREFIX/$_LANG/user/panel");
|
|
}
|
|
else {
|
|
include 'html/html_header.php';
|
|
errors_collect('No such username/password combination exists.','HIGH');
|
|
errors_display();
|
|
users_display_login_form();
|
|
include 'html/html_footer.php';
|
|
}
|
|
}
|
|
|
|
###################################################################################################### attempts to log a user out
|
|
# parameters: none
|
|
# returns: nothing
|
|
function users_logout()
|
|
{
|
|
global $_LOGIN,$_LANG;
|
|
$_SESSION['_loggedin'] = 0;
|
|
|
|
include 'html/html_header.php';
|
|
print "
|
|
<div class='page_subtitle'>{$_LOGIN['logout_success_title']}</div>
|
|
<div class='page_content'>
|
|
{$_LOGIN['logout_success_msg']}
|
|
<br /> <br />
|
|
<a href='/pae.php/{$_LANG}/user/login'>{$_LOGIN['loginagain']}?</a>
|
|
</div>";
|
|
include 'html/html_footer.php';
|
|
}
|
|
|
|
###################################################################################################### displays the login form
|
|
# parameters: none
|
|
# returns: nothing
|
|
function users_display_login_form()
|
|
{
|
|
global $_WORDS,$_LANG;
|
|
?>
|
|
<div class='page_subtitle'>Login</div>
|
|
<div class='page_content'>
|
|
<form action='/pae.php/<?php echo $_LANG ?>/user/login' method='post'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'><?php echo $_WORDS['username'] ?>:</td>
|
|
<td><input type='text' name='username' size='20' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'><?php echo $_WORDS['password'] ?>:</td>
|
|
<td><input type='password' name='password' size='20' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'> </td>
|
|
<td><input type='submit' value='<?php echo $_WORDS['login'] ?>' /></td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
?>
|