"Change Password" function

Discussion forum for MOD Writers regarding MOD Development.

"Change Password" function

Postby carled » Tue Nov 10, 2009 9:10 am

Hello there. Is there a "user_change" or "password_change" function along the lines of "user_add" please? I use "user_add" in a custom php page in a call from my other site and as users can change their passwords in my main site, when they do this I want to be able to call a php function that will also update the phpbb record... possible?
carled
Registered User
 
Posts: 8
Joined: Mon Jul 27, 2009 8:39 pm

Re: "Change Password" function

Postby carled » Tue Nov 10, 2009 2:59 pm

Surely this is almost the world's easiest question for someone with even a passing knowledge of phpbb? Is it even worth posting questions on here? Is there a better place where I might have a better chance of getting simple questions answered please?
carled
Registered User
 
Posts: 8
Joined: Mon Jul 27, 2009 8:39 pm

Re: "Change Password" function

Postby Lumpy Burgertushie » Wed Nov 11, 2009 5:29 am

wow, you are sure to get help with that attitude. you posted in the wee hours of the morning in most of the US.

now you are back complaining.

calm down and show a little respect for the people around here that offer their help to you for FREE.

Also, if the answer to your question was so easy, you would not need to ask it now would you?

someone will be along shortly to help you out.

be patient.

thanks,
robert
User avatar
Lumpy Burgertushie
Registered User
 
Posts: 51596
Joined: Mon May 02, 2005 3:11 am

Re: "Change Password" function

Postby A_Jelly_Doughnut » Wed Nov 11, 2009 6:43 pm

There is not a change password function along the lines of user_add. You'd have to change it manually with an UPDATE sql query on the phpbb_users table.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish

Celebrating 11 years as a phpBB user
User avatar
A_Jelly_Doughnut
Former Team Member
 
Posts: 34391
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run

Re: "Change Password" function

Postby 3Di » Fri Nov 13, 2009 6:08 am

A_Jelly_Doughnut wrote:You'd have to change it manually with an UPDATE sql query on the phpbb_users table.

Needs also to be mentioned that the phpBB's password hash is md5.
User avatar
3Di
Registered User
 
Posts: 8557
Joined: Mon Apr 04, 2005 11:09 pm
Location: Italia - Germany
Name: Marco

Re: "Change Password" function

Postby ToonArmy » Fri Nov 13, 2009 1:43 pm

3Di wrote:
A_Jelly_Doughnut wrote:You'd have to change it manually with an UPDATE sql query on the phpbb_users table.

Needs also to be mentioned that the phpBB's password hash is md5.

It's not a straight MD5 hash, it's salted for one thing.
Chris SmithBlogGitHub
Image
In a foreign field he lay. Lonely soldier unknown grave. On his dying words he prays. Tell the world of Paschendale.
User avatar
ToonArmy
Former Team Member
 
Posts: 4607
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith

Re: "Change Password" function

Postby carled » Thu Nov 19, 2009 11:08 pm

Yeah but I can just pass in the new password and use "phpbb_hash" before I save it, surely?

Please would someone point me towards a query or function that allows me to read the user ID using the username? Does this exist - a sort of "select user_ID from phpbb_users where username=<username>" query?
carled
Registered User
 
Posts: 8
Joined: Mon Jul 27, 2009 8:39 pm

Re: "Change Password" function

Postby imkingdavid » Thu Nov 19, 2009 11:23 pm

carled wrote:Yeah but I can just pass in the new password and use "phpbb_hash" before I save it, surely?

Please would someone point me towards a query or function that allows me to read the user ID using the username? Does this exist - a sort of "select user_ID from phpbb_users where username=<username>" query?

To get the user's id, you can use $user->data['user_id'] as long as the user class is declared as $user in your script.

As far as hashing the password, you can use phpbb_hash($variable_containing_the_password);

Hope this helps.

(btw, there is a no-bump rule on this site which means that you can't reply to your own topic for 6 hours until someone else does as well, just so you know for future reference!)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
User avatar
imkingdavid
Development Team Member
Development Team Member
 
Posts: 2534
Joined: Sun Jul 26, 2009 7:59 pm
Location: Virginia, US
Name: David King

Re: "Change Password" function

Postby carled » Fri Nov 20, 2009 10:40 am

OK, thanks. I must be missing something here... if I have a custom page I'm doing, then I can't just refer to $user and hope that it will contain the relevant details, can I? I need to load them somehow. All I will have (as I'm coming from a linked database) is the username. Therefore I'll first need to do something like:
(pseudo code) "$user = get_User(<username>)" where "get_user" is some kind of function to read in a user record using just the username?
carled
Registered User
 
Posts: 8
Joined: Mon Jul 27, 2009 8:39 pm

Re: "Change Password" function

Postby imkingdavid » Fri Nov 20, 2009 8:32 pm

Well, to use any of phpBB's functions, you need to include common.php from the forum root. The best way to initialize all of that is to begin your custom file with the following (taken from index.php from the forum root):
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id: index.php 9614 2009-06-18 11:04:54Z nickvergessen $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

Be sure to change ./ to whatever the root path of your board is.
You don't necessarily need to include functions_display.php unless you need those files.

Realize that $user->data[...] will give you the data of the current user. To get data of another user, you will need to query the database like so:
Code: Select all
$sql = 'SELECT * FROM ' . USERS_TABLE . " WHERE username = '$username' ";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
//Now, $user_row['field_name'] contains the value of each of the fields in the database for the user you specify.


I hope this helps. :)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
User avatar
imkingdavid
Development Team Member
Development Team Member
 
Posts: 2534
Joined: Sun Jul 26, 2009 7:59 pm
Location: Virginia, US
Name: David King

Re: "Change Password" function

Postby carled » Fri Nov 20, 2009 11:12 pm

Absolutely brilliant, thanks a million, have it working now!
carled
Registered User
 
Posts: 8
Joined: Mon Jul 27, 2009 8:39 pm

Re: "Change Password" function

Postby imkingdavid » Fri Nov 20, 2009 11:38 pm

carled wrote:Absolutely brilliant, thanks a million, have it working now!

That's good to hear. :) Glad it works for you.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
User avatar
imkingdavid
Development Team Member
Development Team Member
 
Posts: 2534
Joined: Sun Jul 26, 2009 7:59 pm
Location: Virginia, US
Name: David King


Return to [3.0.x] MOD Writers Discussion

Who is online

Users browsing this forum: No registered users and 10 guests