2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2005-01-08 00:10:51 +01:00
|
|
|
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-07 12:50:26 +01:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
2004-02-07 20:36:44 +01:00
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
// customize appearance of the site for a user
|
2004-12-03 17:30:12 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
$userdata = array();
|
2005-04-25 23:35:10 +02:00
|
|
|
if (defined('IN_ADMIN') and IN_ADMIN and isset($_GET['user_id']))
|
2005-01-20 00:36:43 +01:00
|
|
|
{
|
|
|
|
$userdata = getuserdata(intval($_GET['user_id']));
|
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
elseif (defined('IN_ADMIN') and isset($_POST['submit']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-03 17:30:12 +01:00
|
|
|
$userdata = getuserdata(intval($_POST['userid']));
|
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
elseif (!defined('IN_ADMIN') or !IN_ADMIN)
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
|
|
|
define('PHPWG_ROOT_PATH','./');
|
|
|
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
|
|
|
check_login_authorization(false);
|
2004-12-28 20:12:57 +01:00
|
|
|
$userdata = $user;
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
//------------------------------------------------------ update & customization
|
2004-12-28 20:12:57 +01:00
|
|
|
$infos = array('nb_image_line', 'nb_line_page', 'language',
|
|
|
|
'maxwidth', 'maxheight', 'expand', 'show_nb_comments',
|
|
|
|
'recent_period', 'template', 'mail_address');
|
|
|
|
|
2003-07-21 21:47:14 +02:00
|
|
|
$errors = array();
|
2004-12-28 20:12:57 +01:00
|
|
|
if (isset($_POST['submit']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2003-07-21 21:47:14 +02:00
|
|
|
$int_pattern = '/^\d+$/';
|
2004-12-28 20:12:57 +01:00
|
|
|
|
|
|
|
if ($_POST['maxwidth'] != ''
|
|
|
|
and (!preg_match($int_pattern, $_POST['maxwidth'])
|
|
|
|
or $_POST['maxwidth'] < 50))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
array_push($errors, $lang['maxwidth_error']);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
if ($_POST['maxheight']
|
|
|
|
and (!preg_match($int_pattern, $_POST['maxheight'])
|
|
|
|
or $_POST['maxheight'] < 50))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
array_push($errors, $lang['maxheight_error']);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2003-07-21 21:47:14 +02:00
|
|
|
// periods must be integer values, they represents number of days
|
2004-07-09 23:00:00 +02:00
|
|
|
if (!preg_match($int_pattern, $_POST['recent_period'])
|
|
|
|
or $_POST['recent_period'] <= 0)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
array_push($errors, $lang['periods_error']);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if mail_address has changed
|
|
|
|
if (!isset($userdata['mail_address']))
|
|
|
|
{
|
|
|
|
$userdata['mail_address'] = '';
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
|
2004-12-28 20:12:57 +01:00
|
|
|
if ($_POST['mail_address'] != @$userdata['mail_address'])
|
2004-12-02 16:42:57 +01:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
if ($user['status'] == 'admin')
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
$mail_error = validate_mail_address($_POST['mail_address']);
|
|
|
|
if (!empty($mail_error))
|
|
|
|
{
|
|
|
|
array_push($errors, $mail_error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!empty($_POST['password']))
|
2004-12-02 16:42:57 +01:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
array_push($errors, $lang['reg_err_pass']);
|
2004-12-02 16:42:57 +01:00
|
|
|
}
|
|
|
|
else
|
2004-12-28 20:12:57 +01:00
|
|
|
{
|
|
|
|
// retrieving the encrypted password of the login submitted
|
|
|
|
$query = '
|
|
|
|
SELECT password
|
|
|
|
FROM '.USERS_TABLE.'
|
|
|
|
WHERE id = \''.$userdata['id'].'\'
|
|
|
|
;';
|
|
|
|
$row = mysql_fetch_array(pwg_query($query));
|
|
|
|
if ($row['password'] == md5($_POST['password']))
|
|
|
|
{
|
|
|
|
$mail_error = validate_mail_address($_POST['mail_address']);
|
|
|
|
if (!empty($mail_error))
|
|
|
|
{
|
|
|
|
array_push($errors, $mail_error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
array_push($errors, $lang['reg_err_pass']);
|
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
2004-12-02 16:42:57 +01:00
|
|
|
}
|
|
|
|
|
2004-02-02 01:55:18 +01:00
|
|
|
// password must be the same as its confirmation
|
2004-12-28 20:12:57 +01:00
|
|
|
if (!empty($_POST['use_new_pwd'])
|
|
|
|
and $_POST['use_new_pwd'] != $_POST['passwordConf'])
|
|
|
|
{
|
|
|
|
array_push($errors, $lang['reg_err_pass']);
|
|
|
|
}
|
|
|
|
|
2004-12-03 17:30:12 +01:00
|
|
|
// We check if we are in the admin level
|
2004-12-28 20:12:57 +01:00
|
|
|
if (isset($_POST['user_delete']))
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
|
|
|
if ($_POST['userid'] > 2) // gallery founder + guest
|
|
|
|
{
|
|
|
|
delete_user($_POST['userid']);
|
|
|
|
}
|
|
|
|
else
|
2004-12-28 20:12:57 +01:00
|
|
|
{
|
|
|
|
array_push($errors, $lang['user_err_modify']);
|
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
|
|
|
|
2004-12-28 20:12:57 +01:00
|
|
|
// We check if we are in the admin level
|
|
|
|
if (isset($_POST['status']) and $_POST['status'] <> $userdata['status'])
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
if ($_POST['userid'] > 2) // gallery founder + guest
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
|
|
|
array_push($infos, 'status');
|
|
|
|
}
|
|
|
|
else
|
2004-12-28 20:12:57 +01:00
|
|
|
{
|
|
|
|
array_push($errors, $lang['user_err_modify']);
|
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
|
|
|
|
if (count($errors) == 0)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
$query = '
|
|
|
|
UPDATE '.USERS_TABLE.'
|
|
|
|
SET ';
|
|
|
|
$is_first = true;
|
|
|
|
foreach ($infos as $i => $info)
|
|
|
|
{
|
|
|
|
if (!$is_first)
|
|
|
|
{
|
|
|
|
$query.= '
|
|
|
|
, ';
|
|
|
|
}
|
|
|
|
$is_first = false;
|
|
|
|
|
2003-07-21 21:47:14 +02:00
|
|
|
$query.= $info;
|
2003-05-09 14:42:42 +02:00
|
|
|
$query.= ' = ';
|
2004-12-28 20:12:57 +01:00
|
|
|
if ($_POST[$info] == '')
|
|
|
|
{
|
|
|
|
$query.= 'NULL';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$query.= "'".$_POST[$info]."'";
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
$query.= '
|
|
|
|
WHERE id = '.$_POST['userid'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2004-12-28 20:12:57 +01:00
|
|
|
if (!empty($_POST['use_new_pwd']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
$query = '
|
|
|
|
UPDATE '.USERS_TABLE.'
|
|
|
|
SET password = \''.md5($_POST['use_new_pwd']).'\'
|
|
|
|
WHERE id = '.$_POST['userid'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// redirection
|
2004-12-28 20:12:57 +01:00
|
|
|
if (!defined('IN_ADMIN') or !IN_ADMIN)
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
2004-12-28 20:12:57 +01:00
|
|
|
$url = PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING'];
|
|
|
|
redirect(add_session_id($url));
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
2004-12-28 20:12:57 +01:00
|
|
|
else
|
|
|
|
{
|
2004-12-03 17:30:12 +01:00
|
|
|
redirect(add_session_id(PHPWG_ROOT_PATH.'admin.php?page=profile'));
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2004-12-03 17:30:12 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | page header and options |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
$url_action = PHPWG_ROOT_PATH;
|
|
|
|
if (!defined('IN_ADMIN'))
|
|
|
|
{
|
|
|
|
$title= $lang['customize_page_title'];
|
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|
|
|
$url_action .='profile.php';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$url_action .='admin.php?page=profile';
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
//----------------------------------------------------- template initialization
|
2004-12-03 17:30:12 +01:00
|
|
|
$template->set_filenames(array('profile_body'=>'profile.tpl'));
|
2004-12-28 20:12:57 +01:00
|
|
|
|
2005-04-25 23:35:10 +02:00
|
|
|
$expand = ($userdata['expand'] == 'true') ? 'EXPAND_TREE_YES':'EXPAND_TREE_NO';
|
2005-02-13 20:53:07 +01:00
|
|
|
|
2005-04-25 23:35:10 +02:00
|
|
|
$nb_comments =
|
|
|
|
($userdata['show_nb_comments'] == 'true') ? 'NB_COMMENTS_YES':'NB_COMMENTS_NO';
|
2004-12-28 20:12:57 +01:00
|
|
|
|
2005-04-25 23:35:10 +02:00
|
|
|
$template->assign_vars(
|
|
|
|
array(
|
|
|
|
'USERNAME'=>$userdata['username'],
|
|
|
|
'USERID'=>$userdata['id'],
|
|
|
|
'EMAIL'=>@$userdata['mail_address'],
|
|
|
|
'LANG_SELECT'=>language_select($userdata['language'], 'language'),
|
|
|
|
'NB_IMAGE_LINE'=>$userdata['nb_image_line'],
|
|
|
|
'NB_ROW_PAGE'=>$userdata['nb_line_page'],
|
|
|
|
'STYLE_SELECT'=>style_select($userdata['template'], 'template'),
|
|
|
|
'RECENT_PERIOD'=>$userdata['recent_period'],
|
|
|
|
'MAXWIDTH'=>@$userdata['maxwidth'],
|
|
|
|
'MAXHEIGHT'=>@$userdata['maxheight'],
|
2005-01-20 00:36:43 +01:00
|
|
|
|
2005-04-25 23:35:10 +02:00
|
|
|
$expand=>'checked="checked"',
|
|
|
|
$nb_comments=>'checked="checked"',
|
|
|
|
|
|
|
|
'L_TITLE' => $lang['customize_title'],
|
|
|
|
'L_REGISTRATION_INFO' => $lang['register_title'],
|
|
|
|
'L_PREFERENCES' => $lang['preferences'],
|
|
|
|
'L_USERNAME' => $lang['login'],
|
|
|
|
'L_EMAIL' => $lang['mail_address'],
|
|
|
|
'L_CURRENT_PASSWORD' => $lang['password'],
|
|
|
|
'L_CURRENT_PASSWORD_HINT' => $lang['password_hint'],
|
|
|
|
'L_NEW_PASSWORD' => $lang['new_password'],
|
|
|
|
'L_NEW_PASSWORD_HINT' => $lang['new_password_hint'],
|
|
|
|
'L_CONFIRM_PASSWORD' => $lang['reg_confirm'],
|
|
|
|
'L_CONFIRM_PASSWORD_HINT' => $lang['confirm_password_hint'],
|
|
|
|
'L_LANG_SELECT'=>$lang['language'],
|
|
|
|
'L_NB_IMAGE_LINE'=>$lang['nb_image_per_row'],
|
|
|
|
'L_NB_ROW_PAGE'=>$lang['nb_row_per_page'],
|
|
|
|
'L_STYLE_SELECT'=>$lang['theme'],
|
|
|
|
'L_RECENT_PERIOD'=>$lang['recent_period'],
|
|
|
|
'L_EXPAND_TREE'=>$lang['auto_expand'],
|
|
|
|
'L_NB_COMMENTS'=>$lang['show_nb_comments'],
|
|
|
|
'L_MAXWIDTH'=>$lang['maxwidth'],
|
|
|
|
'L_MAXHEIGHT'=>$lang['maxheight'],
|
|
|
|
'L_YES'=>$lang['yes'],
|
|
|
|
'L_NO'=>$lang['no'],
|
|
|
|
'L_SUBMIT'=>$lang['submit'],
|
|
|
|
'L_RESET'=>$lang['reset'],
|
|
|
|
'L_RETURN' => $lang['home'],
|
|
|
|
'L_RETURN_HINT' => $lang['home_hint'],
|
|
|
|
|
|
|
|
'F_ACTION'=>add_session_id($url_action),
|
|
|
|
));
|
|
|
|
|
|
|
|
if (!defined('IN_ADMIN') or !IN_ADMIN)
|
|
|
|
{
|
|
|
|
$url_return = PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING'];
|
|
|
|
$template->assign_vars(array('U_RETURN' => add_session_id($url_return)));
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
2005-04-25 23:35:10 +02:00
|
|
|
//------------------------------------------------------------- user management
|
|
|
|
if (defined('IN_ADMIN') and IN_ADMIN)
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
2005-04-25 23:35:10 +02:00
|
|
|
$status_select = '<select name="status">';
|
|
|
|
$status_select .='<option value = "guest" ';
|
|
|
|
if ($userdata['status'] == 'guest')
|
2004-12-28 20:12:57 +01:00
|
|
|
{
|
2005-04-25 23:35:10 +02:00
|
|
|
$status_select .= 'selected="selected"';
|
2004-12-28 20:12:57 +01:00
|
|
|
}
|
2005-04-25 23:35:10 +02:00
|
|
|
$status_select .='>'.$lang['user_status_guest'] .'</option>';
|
|
|
|
$status_select .='<option value = "admin" ';
|
|
|
|
if ($userdata['status'] == 'admin')
|
2004-12-28 20:12:57 +01:00
|
|
|
{
|
2005-04-25 23:35:10 +02:00
|
|
|
$status_select .= 'selected="selected"';
|
2004-12-28 20:12:57 +01:00
|
|
|
}
|
2005-04-25 23:35:10 +02:00
|
|
|
$status_select .='>'.$lang['user_status_admin'] .'</option>';
|
|
|
|
$status_select .='</select>';
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'admin',
|
|
|
|
array(
|
|
|
|
'L_ADMIN_USER'=>$lang['user_management'],
|
|
|
|
'L_STATUS'=>$lang['user_status'],
|
|
|
|
'L_DELETE'=>$lang['user_delete'],
|
|
|
|
'L_DELETE_HINT'=>$lang['user_delete_hint'],
|
|
|
|
'STATUS'=>$status_select
|
|
|
|
));
|
2004-12-03 17:30:12 +01:00
|
|
|
}
|
|
|
|
// +-----------------------------------------------------------------------+
|
2005-02-13 20:53:07 +01:00
|
|
|
// | errors display |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
if (count($errors) != 0)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('errors',array());
|
|
|
|
foreach ($errors as $error)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('errors.error', array('ERROR'=>$error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-12-03 17:30:12 +01:00
|
|
|
// | html code display |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-12-28 20:12:57 +01:00
|
|
|
if (defined('IN_ADMIN') and IN_ADMIN)
|
2004-12-03 17:30:12 +01:00
|
|
|
{
|
|
|
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'profile_body');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-25 23:35:10 +02:00
|
|
|
$template->assign_block_vars('profile',array());
|
2005-01-13 11:18:49 +01:00
|
|
|
$template->parse('profile_body');
|
2004-12-03 17:30:12 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
|
|
|
}
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|