本文整理汇总了PHP中meta_refresh函数的典型用法代码示例。如果您正苦于以下问题:PHP meta_refresh函数的具体用法?PHP meta_refresh怎么用?PHP meta_refresh使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了meta_refresh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_tool
/**
* Run the tool
*/
function run_tool()
{
global $db, $template;
$step = request_var('step', 0);
// Select the batch
$sql = 'SELECT user_id, user_email, user_email_hash
FROM ' . USERS_TABLE;
$result = $db->sql_query_limit($sql, $this->batch_size, $step * $this->batch_size);
$batch = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
if (!$batch) {
trigger_error('UPDATE_EMAIL_HASHES_COMPLETE');
}
foreach ($batch as $userrow) {
$new_hash = phpbb_email_hash($userrow['user_email']);
if ($userrow['user_email_hash'] == $new_hash) {
// Skip if the hash hasn't changed
continue;
}
// Update the field
$sql = 'UPDATE ' . USERS_TABLE . " SET user_email_hash = '" . $new_hash . "'\n\t\t\t\tWHERE user_id = " . $userrow['user_id'];
$db->sql_query($sql);
}
meta_refresh(0, append_sid(STK_INDEX, array('c' => 'support', 't' => 'update_email_hashes', 'submit' => true, 'step' => ++$step)));
$template->assign_var('U_BACK_TOOL', false);
trigger_error('UPDATE_EMAIL_HASHES_NOT_COMPLETE');
}
示例2: main
function main($id, $mode)
{
global $config, $db, $user, $table_prefix, $auth, $template, $phpbb_root_path, $phpEx;
define('TABLE_PREFIX', $table_prefix);
require_once 'class_ulogin.php';
$uLogin = new uLogin($db);
if ($config['require_activation'] == USER_ACTIVATION_DISABLE) {
trigger_error('UCP_REGISTER_DISABLE');
}
if (!($user_id = $uLogin->auth())) {
$user_id = $uLogin->register();
}
if ($user_id) {
$session = $user->session_create($user_id, 0, 1);
}
if (!$session) {
page_header($user->lang['LOGIN'], false);
$template->set_filenames(array('body' => 'login_body.html'));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}"));
page_footer();
exit;
}
$redirect = request_var('redirect', "{$phpbb_root_path}index.{$phpEx}");
$message = $user->lang['LOGIN_REDIRECT'];
$l_redirect = $redirect === "{$phpbb_root_path}index.{$phpEx}" || $redirect === "index.{$phpEx}" ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE'];
$redirect = reapply_sid($redirect);
if (defined('IN_CHECK_BAN') && $session['user_row']['user_type'] != USER_FOUNDER) {
return false;
}
$redirect = meta_refresh(3, $redirect);
trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>'));
}
示例3: base
public function base()
{
$note = utf8_normalize_nfc($this->request->variable('note', '', true));
$submit = isset($_POST['submit']) ? true : false;
$error = array();
// check if user s logged in, since this page can be used only after registration...
if (!$this->user->data['is_registered']) {
login_box($this->helper->route('vinny_usersnotes_controller'));
}
// ... and also this is not for bots (especially for bad ones :)
if ($this->user->data['is_bot']) {
redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
}
$s_action = $this->helper->route('vinny_usersnotes_controller');
$s_hidden_fields = '';
add_form_key('postform');
// create a template variables
$this->template->assign_vars(array('S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : ''));
if ($submit) {
/*if(!check_form_key('postform'))
{
trigger_error('FORM_INVALID');
}*/
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_note = "' . $note . '"
WHERE user_id = ' . $this->user->data['user_id'];
$this->db->sql_query($sql);
meta_refresh(3, $this->helper->route('vinny_usersnotes_controller'));
trigger_error(sprintf($this->user->lang['NOTES_SAVED'], $this->helper->route('vinny_usersnotes_controller')));
}
// create a template variables
$this->template->assign_vars(array('NOTE' => $this->user->data['user_note']));
$this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['NOTES']));
return $this->helper->render('notes.html', $this->user->lang['NOTES']);
}
示例4: main
function main($id, $mode)
{
global $db, $user, $template, $auth, $phpbb_container;
$forbidden_forums = $auth->acl_getf('!f_read', true);
$forbidden_forums = array_unique(array_keys($forbidden_forums));
$controller = $phpbb_container->get('sheer.postbookmark.helper');
$controller->get_bookmarks(false, $forbidden_forums);
if (isset($_POST['unbookmark'])) {
$s_hidden_fields = array('unbookmark' => 1);
$topics = isset($_POST['t']) ? array_keys(request_var('t', array(0 => 0))) : array();
$url = $this->u_action;
if (!sizeof($topics)) {
trigger_error('NO_BOOKMARKS_SELECTED');
}
foreach ($topics as $topic_id) {
$s_hidden_fields['t'][$topic_id] = 1;
}
if (confirm_box(true)) {
$sql = 'DELETE FROM ' . POSTS_BOOKMARKS_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
AND ' . $db->sql_in_set('post_id', $topics);
$db->sql_query($sql);
meta_refresh(3, $url);
$message = $user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
trigger_error($message);
} else {
confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields));
}
}
$template->assign_vars(array('S_HIDDEN_FIELDS' => isset($s_hidden_fields) ? $s_hidden_fields : '', 'S_UCP_ACTION' => $this->u_action));
$this->tpl_name = 'ucp_postbookmark_body';
}
示例5: run_tool
/**
* Run tool.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function run_tool()
{
$type = $this->request->variable('type', 'queue');
$start = $this->request->variable('start', 0);
$continue_start = null;
switch ($type) {
case 'queue':
$continue_start = $this->sync_queue_topics($start);
if ($continue_start === null) {
$type = 'contrib';
$continue_start = 0;
}
break;
case 'contrib':
$continue_start = $this->sync_contrib_topics($start);
break;
}
if ($continue_start !== null) {
$params = array('tool' => 'rebuild_topic_urls', 'type' => $type, 'submit' => 1, 'hash' => generate_link_hash('manage'), 'start' => $continue_start);
meta_refresh(2, $this->controller_helper->route('phpbb.titania.administration.tool', $params));
}
$msg = $continue_start !== null ? 'PLEASE_WAIT_FOR_TOOL' : 'DONE';
$this->template->assign_vars(array('MESSAGE_TEXT' => $this->user->lang($msg), 'MESSAGE_TITLE' => $this->user->lang('INFORMATION')));
return $this->controller_helper->render('message_body.html', $msg);
}
示例6: run_tool
/**
* Run Tool
*
* Does the actual stuff we want the tool to do after submission
*/
function run_tool()
{
global $db, $template;
$part = request_var('part', 0);
$limit = 500;
$i = 0;
$sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE;
$result = $db->sql_query_limit($sql, $limit, ($part * $limit));
while ($row = $db->sql_fetchrow($result))
{
$i++;
$username_clean = utf8_clean_string($row['username']);
if ($username_clean != $row['username_clean'])
{
$db->sql_query('UPDATE ' . USERS_TABLE . " SET username_clean = '$username_clean' WHERE user_id = {$row['user_id']}");
}
}
$db->sql_freeresult($result);
if ($i == $limit)
{
meta_refresh(0, append_sid(STK_INDEX, 't=reclean_usernames&submit=1&part=' . (++$part)));
$template->assign_var('U_BACK_TOOL', false);
trigger_error('RECLEAN_USERNAMES_NOT_COMPLETE');
}
else
{
trigger_error('RECLEAN_USERNAMES_COMPLETE');
}
}
示例7: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template, $phpbb_container;
if (!$config['allow_password_reset']) {
trigger_error($user->lang('UCP_PASSWORD_RESET_DISABLED', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'));
}
$username = request_var('username', '', true);
$email = strtolower(request_var('email', ''));
$submit = isset($_POST['submit']) ? true : false;
if ($submit) {
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'\n\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_EMAIL_USER');
}
if ($user_row['user_type'] == USER_IGNORE) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] == USER_INACTIVE) {
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
trigger_error('ACCOUNT_DEACTIVATED');
} else {
trigger_error('ACCOUNT_NOT_ACTIVATED');
}
}
// Check users permissions
$auth2 = new \phpbb\auth\auth();
$auth2->acl($user_row);
if (!$auth2->acl_get('u_chgpasswd')) {
trigger_error('NO_AUTH_PASSWORD_REMINDER');
}
$server_url = generate_board_url();
// Make password at least 8 characters long, make it longer if admin wants to.
// gen_rand_string() however has a limit of 12 or 13.
$user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
// For the activation key a random length between 6 and 10 will do.
$user_actkey = gen_rand_string(mt_rand(6, 10));
// Instantiate passwords manager
$passwords_manager = $phpbb_container->get('passwords.manager');
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\tWHERE user_id = " . $user_row['user_id'];
$db->sql_query($sql);
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$messenger->template('user_activate_passwd', $user_row['user_lang']);
$messenger->set_addresses($user_row);
$messenger->anti_abuse_headers($config, $user);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']), 'PASSWORD' => htmlspecialchars_decode($user_password), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
$messenger->send($user_row['user_notify_type']);
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
trigger_error($message);
}
$template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword')));
$this->tpl_name = 'ucp_remind';
$this->page_title = 'UCP_REMIND';
}
示例8: run_tool
function run_tool()
{
global $config, $db, $template;
$step = request_var('step', 0);
$begin = $this->_batch_size * $step;
// Get the batch
$sql = 'SELECT attach_id, physical_filename
FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query_limit($sql, $this->_batch_size, $begin);
$batch = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
if (empty($batch)) {
// Nothing to do
trigger_error('RESYNC_ATTACHMENTS_FINISHED');
}
$delete_ids = array();
foreach ($batch as $row) {
// Does the file still exists?
$path = PHPBB_ROOT_PATH . $config['upload_path'] . "/{$row['physical_filename']}";
if (file_exists($path)) {
// Yes, next please!
continue;
}
$delete_ids[] = $row['attach_id'];
}
// Run all the queries
if (!empty($delete_ids)) {
$db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', $delete_ids));
}
// Next step
$template->assign_var('U_BACK_TOOL', false);
meta_refresh(3, append_sid(STK_INDEX, array('c' => 'admin', 't' => 'resync_attachments', 'step' => ++$step, 'submit' => true)));
trigger_error('RESYNC_ATTACHMENTS_PROGRESS');
}
示例9: handle_gb_post_delete
/**
* Do the various checks required for removing posts as well as removing it
*/
function handle_gb_post_delete($post_id, &$post_data, &$guestbook)
{
global $user, $db, $auth, $config;
global $phpbb_root_path, $phpEx;
// If moderator removing post or user itself removing post, present a confirmation screen
if ($auth->acl_get('m_gb_delete') || $post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('u_gb_delete') && ($post_data['post_time'] > time() - $config['delete_time'] * 60 || !$config['delete_time'])) {
$s_hidden_fields = build_hidden_fields(array('p' => $post_id, 'gbmode' => 'delete'));
if (confirm_box(true)) {
$data = array('post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id']);
$next_post_id = gb_delete_post($post_id, $data, $guestbook);
$post_username = $post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username']) ? $post_data['post_username'] : $post_data['username'];
add_log('mod', 0, 0, 'LOG_GB_DELETE_POST', $post_username);
$member = $guestbook->getmember();
$meta_info = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $member['user_id']);
unset($member);
$message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_PROFILE'], '<a href="' . $meta_info . '">', '</a>');
meta_refresh(3, $meta_info);
trigger_error($message);
} else {
confirm_box(false, 'DELETE_POST', $s_hidden_fields);
}
redirect(append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . request_var('u', 0)));
}
// If we are here the user is not able to delete - present the correct error message
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('u_gb_delete')) {
trigger_error('DELETE_OWN_POSTS');
}
trigger_error('USER_CANNOT_DELETE');
}
示例10: run_tool
/**
* Run Tool
*
* Does the actual stuff we want the tool to do after submission
*/
function run_tool()
{
global $db, $template, $user, $phpbb_root_path, $phpEx;
$part = request_var('part', 0);
$limit = 500;
$i = 0;
$sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE;
$result = $db->sql_query_limit($sql, $limit, $part * $limit);
while ($row = $db->sql_fetchrow($result)) {
$i++;
$username_clean = $db->sql_escape(utf8_clean_string($row['username']));
if ($username_clean != $row['username_clean']) {
$sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE . ' WHERE username_clean LIKE \'' . $username_clean . '\'';
$res = $db->sql_query_limit($sql, 1);
$duplicate = $db->sql_fetchrow($res);
$db->sql_freeresult($res);
if (!empty($duplicate)) {
$url = append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&mode=overview&u=' . $duplicate['user_id'] . '&sid=' . $user->data['session_id']);
$problem = append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&mode=overview&u=' . $row['user_id'] . '&sid=' . $user->data['session_id']);
trigger_error(sprintf($user->lang['USER_ALREADY_EXISTS'], $duplicate['username'], $url, $row['username'], $problem), E_USER_WARNING);
}
$db->sql_query('UPDATE ' . USERS_TABLE . " SET username_clean = '{$username_clean}' WHERE user_id = {$row['user_id']}");
}
}
$db->sql_freeresult($result);
if ($i == $limit) {
meta_refresh(0, append_sid(STK_INDEX, 't=reclean_usernames&submit=1&part=' . ++$part));
$template->assign_var('U_BACK_TOOL', false);
trigger_error('RECLEAN_USERNAMES_NOT_COMPLETE');
} else {
trigger_error('RECLEAN_USERNAMES_COMPLETE');
}
}
示例11: set_personal_settings
protected function set_personal_settings()
{
if ($this->request->is_set_post('submit')) {
$gallery_settings = array('watch_own' => $this->request->variable('watch_own', false), 'watch_com' => $this->request->variable('watch_com', false), 'user_allow_comments' => $this->request->variable('allow_comments', false));
$additional_settings = array();
/**
* Event set personal settings
*
* @event phpbbgallery.core.ucp.set_settings_submit
* @var array additional_settings array of additional settings
* @since 1.2.0
*/
$vars = array('additional_settings');
extract($this->dispatcher->trigger_event('phpbbgallery.core.ucp.set_settings_submit', compact($vars)));
$gallery_settings = array_merge($gallery_settings, $additional_settings);
if (!$this->config['phpbb_gallery_allow_comments'] || !$this->config['phpbb_gallery_comment_user_control']) {
unset($gallery_settings['user_allow_comments']);
}
$this->gallery_user->set_user_id($this->user->data['user_id']);
$this->gallery_user->update_data($gallery_settings);
meta_refresh(3, $this->u_action);
trigger_error($this->user->lang['WATCH_CHANGED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'));
}
/**
* Event no submit personal settings
*
* @event phpbbgallery.core.ucp.set_settings_nosubmit
* @since 1.2.0
*/
$this->dispatcher->dispatch('phpbbgallery.core.ucp.set_settings_nosubmit');
$this->template->assign_vars(array('S_PERSONAL_SETTINGS' => true, 'S_UCP_ACTION' => $this->u_action, 'L_TITLE' => $this->user->lang['UCP_GALLERY_SETTINGS'], 'L_TITLE_EXPLAIN' => $this->user->lang['WATCH_NOTE'], 'S_WATCH_OWN' => $this->gallery_user->get_data('watch_own'), 'S_WATCH_COM' => $this->gallery_user->get_data('watch_com'), 'S_ALLOW_COMMENTS' => $this->gallery_user->get_data('user_allow_comments'), 'S_COMMENTS_ENABLED' => $this->config['phpbb_gallery_allow_comments'] && $this->config['phpbb_gallery_comment_user_control']));
}
示例12: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
$user_id = request_var('u', 0);
$key = request_var('k', '');
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = {$user_id}";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] != USER_INACTIVE && !$user_row['user_newpasswd']) {
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
trigger_error('ALREADY_ACTIVATED');
}
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL || $user_row['user_actkey'] != $key) {
trigger_error('WRONG_ACTIVATION');
}
$update_password = $user_row['user_newpasswd'] ? true : false;
if ($update_password) {
$sql_ary = array('user_actkey' => '', 'user_password' => $user_row['user_newpasswd'], 'user_newpasswd' => '', 'user_pass_convert' => 0, 'user_login_attempts' => 0);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql);
}
if (!$update_password) {
include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
user_active_flip('activate', $user_row['user_id']);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_actkey = ''\n\t\t\t\tWHERE user_id = {$user_row['user_id']}";
$db->sql_query($sql);
}
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
$messenger->to($user_row['user_email'], $user_row['username']);
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username'])));
$messenger->send($user_row['user_notify_type']);
$message = 'ACCOUNT_ACTIVE_ADMIN';
} else {
if (!$update_password) {
$message = $user_row['user_inactive_reason'] == INACTIVE_PROFILE ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
} else {
$message = 'PASSWORD_ACTIVATED';
}
}
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
trigger_error($user->lang[$message]);
}
示例13: markpostunread
/**
* Action for route /markpostunread/{return_forum_id}/{unread_post_id}
*
* Marks a post unread and displays a redirect message
*/
public function markpostunread($return_forum_id, $unread_post_id)
{
$this->user->add_lang_ext('kasimi/markpostunread', 'common');
$this->core->mark_unread_post($return_forum_id, $unread_post_id);
$return_index = append_sid($this->core->root_path . 'index.' . $this->core->php_ext);
$return_forum = append_sid($this->core->root_path . 'viewforum.' . $this->core->php_ext, 'f=' . $return_forum_id);
meta_refresh(3, $return_forum);
return $this->helper->message('MARKPOSTUNREAD_REDIRECT_FORMAT', array($this->user->lang('MARKPOSTUNREAD_MARKED_UNREAD'), sprintf($this->user->lang('RETURN_FORUM'), '<a href="' . $return_forum . '">', '</a>'), sprintf($this->user->lang('RETURN_INDEX'), '<a href="' . $return_index . '">', '</a>')));
}
示例14: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
$username = request_var('username', '', true);
$email = strtolower(request_var('email', ''));
$submit = isset($_POST['submit']) ? true : false;
if ($submit) {
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE user_email = '" . $db->sql_escape($email) . "'\n\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_EMAIL_USER');
}
if ($user_row['user_type'] == USER_IGNORE) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] == USER_INACTIVE) {
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
trigger_error('ACCOUNT_DEACTIVATED');
} else {
trigger_error('ACCOUNT_NOT_ACTIVATED');
}
}
// Check users permissions
$auth2 = new auth();
$auth2->acl($user_row);
if (!$auth2->acl_get('u_chgpasswd')) {
trigger_error('NO_AUTH_PASSWORD_REMINDER');
}
$server_url = generate_board_url();
$key_len = 54 - strlen($server_url);
$key_len = max(6, $key_len);
// we want at least 6
$key_len = $config['max_pass_chars'] ? min($key_len, $config['max_pass_chars']) : $key_len;
// we want at most $config['max_pass_chars']
$user_actkey = substr(gen_rand_string(10), 0, $key_len);
$user_password = gen_rand_string(8);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\tWHERE user_id = " . $user_row['user_id'];
$db->sql_query($sql);
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$messenger->template('user_activate_passwd', $user_row['user_lang']);
$messenger->to($user_row['user_email'], $user_row['username']);
$messenger->im($user_row['user_jabber'], $user_row['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']), 'PASSWORD' => htmlspecialchars_decode($user_password), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
$messenger->send($user_row['user_notify_type']);
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
trigger_error($message);
}
$template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword')));
$this->tpl_name = 'ucp_remind';
$this->page_title = 'UCP_REMIND';
}
示例15: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
$user_id = request_var('u', 0);
$key = request_var('k', '');
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey
FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = {$user_id}";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] != USER_INACTIVE && !$user_row['user_newpasswd']) {
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
trigger_error('ALREADY_ACTIVATED');
}
if ($user_row['user_actkey'] != $key) {
trigger_error('WRONG_ACTIVATION');
}
$update_password = $user_row['user_newpasswd'] ? true : false;
if ($update_password) {
$sql_ary = array('user_type' => USER_NORMAL, 'user_actkey' => '', 'user_password' => $user_row['user_newpasswd'], 'user_newpasswd' => '');
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql);
}
if (!$update_password) {
include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// Now we need to demote the user from the inactive group and add him to the registered group
user_active_flip($user_row['user_id'], $user_row['user_type'], '', $user_row['username'], true);
// Update last username
update_last_username();
set_config('num_users', $config['num_users'] + 1, true);
}
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
$messenger->replyto($config['board_contact']);
$messenger->to($user_row['user_email'], $user_row['username']);
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig'])));
$messenger->send($user_row['user_notify_type']);
$message = 'ACCOUNT_ACTIVE_ADMIN';
} else {
$message = !$update_password ? 'ACCOUNT_ACTIVE' : 'PASSWORD_ACTIVATED';
}
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
trigger_error($user->lang[$message]);
}