Announcement

#1 2016-08-25 15:44:31

KungFuJosh
Member
2016-08-21
28

Piwigo and WordPress Login Integration / Bridge

Hi,

In case anybody wants to get the Piwigo and WordPress logins to work together, it works pretty easily without any source code modifications to the scripts.

REQUIREMENTS: You will need to have PHP Version 5.5 or higher, and there is a WordPress plugin called Password bcrypt by Roots that is needed to convert the password hash to a better hash that we can also use to get Piwigo to work.

Step 1. Install both scripts and make sure they work independently.

Step 2. Install Password bcrypt plugin in WordPress. Logout of WordPress and log back in to make sure the password hash is updated in the database.

Step 3. Create a file called config.inc.php in the /local/config folder in your Piwigo install directory.

Step 4. Include the following code in the config.inc.php file:

Code:

// +-----------------------------------------------------------------------+
// | WordPress MODS                                                        |
// +-----------------------------------------------------------------------+

$conf['insensitive_case_logon'] = true;
$conf['users_table'] = 'wp_users';
$conf['external_authentification'] = true;
$conf['user_fields'] = array(
  'id' => 'ID',
  'username' => 'user_login',
  'password' => 'user_pass',
  'email' => 'user_email'
  );
$conf['password_hash'] = create_function('$s', 'return password_hash($s);');
$conf['password_verify'] = 'pwg_password_verify';
$conf['guest_id'] = 2;
$conf['default_user_id'] = $conf['guest_id'];
$conf['browser_language'] = true;
$conf['webmaster_id'] = 1;
$conf['guest_access'] = true;

Step 5. Clean the Piwigo db entries suggested in the config_default.inc.php:

Code:

DELETE FROM `piwigo_user_access`;
DELETE FROM `piwigo_user_cache`;
DELETE FROM `piwigo_user_feed`;
DELETE FROM `piwigo_user_group`;
DELETE FROM `piwigo_sessions`;
DELETE FROM `piwigo_rate`;
DELETE FROM `piwigo_caddie`;
DELETE FROM `piwigo_favorites`;

UPDATE `piwigo_images` SET `rating_score` = NULL;
UPDATE `piwigo_images` SET `added_by` = 1;

I tested this with a WordPress install running bbPress with over 30,000 users and over 200,000 posts from a import/conversion of phpBB3. Everything worked fine, including uploading and approving photos via the Piwigo Community plugin.


Piwigo version: 2.8.2
PHP version: 5.5+ REQUIRED

Last edited by KungFuJosh (2016-08-25 16:14:07)

Offline

 

#2 2016-08-27 21:14:17

eliz82
Member
Romania
2016-04-27
259

Re: Piwigo and WordPress Login Integration / Bridge

Nice, at least with some modification to password hash it's working with Wordpress. You didn't change Piwigo database columns names ?

I just tested bbPress and it seems quite primitive compared to PhpBB3. Is that really a forum software that doesn't support bbcode by default and doesn't have a preview post button? Not even FluxBB used on this site is that bad :)

By the way ... can your bbPress users can create subalbums in their own main album ?

p.s.  I will add bbPress suport in Piwigo2Img soon.

Last edited by eliz82 (2016-08-28 17:51:13)

Offline

 

#3 2016-08-28 00:32:01

KungFuJosh
Member
2016-08-21
28

Re: Piwigo and WordPress Login Integration / Bridge

eliz82 wrote:

Nice, at least with some modification to password hash it's working with Wordpress. You didn't change Piwigo database columns names ?

I just tested bbPress and it seems quite primitive compared to PhpBB3. Is really that a forum software that doesn't support bbcode by default and doesn't have a preview post button? Not even FluxBB used on this site is that bad :)

By the way ... can your bbPress users can create subalbums in their own main album ?

p.s.  I will add bbPress suport in Piwigo2Img soon.

I didn't need to make any script mods at all.

bbPress has plugins for all that other stuff. I've never actually used bbPress before this, I'm just testing it out as an alternative to phpBB.

I've been scratch building with wordpress forever, so customizing for bbPress should be pretty easy if I decide to go that route for the forum. I don't know if I will or not though since my phpBB test install is basically done and 99% customized except for Piwigo sucking with it (without the mods).

I'll check on the sub album thing later, I just switched hosting companies, so I still need to do some server work first.

Offline

 

#4 2016-08-29 08:49:17

eliz82
Member
Romania
2016-04-27
259

Re: Piwigo and WordPress Login Integration / Bridge

eliz82 wrote:

p.s.  I will add bbPress suport in Piwigo2Img soon.

Done. http://piwigo.org/forum/viewtopic.php?p … 68#p164368

Offline

 

#5 2016-11-23 16:21:23

peterpix
Member
2015-06-14
40

Re: Piwigo and WordPress Login Integration / Bridge

Thanks for your response.

I did not search on the issue before I posted today because I looked a few months ago before that post had been added.  I put my post up on the site today in response to the Piwigo email today referring to the new version, which reminded me that I had had this problem, and I thought it would be helpful to post about it in the requests forum. 

I'm glad someone has found a way around the issue.  Unfortunately for me, that fix requires PHP 5.5. My site on which I want Wordpress/Piwigo to work together is on a server running PHP 5.4.  That is because PHP 5.5 breaks the site.  This is something to do with Buddypress.  It is a known issue with some Buddypress sites (see their forum) though no-one seems to have the answer as to why, and unfortunately this issue affects my site for some reason so I am stuck on PHP 5.4.

Is there a solution to the Wordpress/Piwigo login integration that does not require PHP 5.5?

Peter

Last edited by peterpix (2016-11-24 16:25:11)

Offline

 

#6 2016-11-23 17:28:21

KungFuJosh
Member
2016-08-21
28

Re: Piwigo and WordPress Login Integration / Bridge

peterpix wrote:

I'm glad someone has found a way around the issue.  Unfortunately for me, that fix requires PHP 5.5. My site on which I want Wordpress/Piwigo to work together is on a server running PHP 5.4.  That is because PHP 5.5 breaks the site.  This is something to do with Buddypress.  It is a known issue with some Buddypress sites (see their forum) though no-one seems to have the answer as to why, and unfortunately this issue affects my site for some reason so I am stuck on PHP 5.4.

Is there a solution to the Wordpress/Piwigo login integration that does not require PHP 5.5?

Peter

I had it running with BuddyPress and no issues on PHP 5.6 and maybe PHP 7.0 (I don't remember, but probably tested on both). I didn't like BP compared to phpBB, so I didn't develop further than that at all. AFAIK BuddyPress has been testing with php 7 for about a year.

You could look for other solutions for implementing different password hashing. I don't know if you'll find anything that works with 5.4, but you won't know if you don't try. The only thing that matters is you get both scripts on the same type so they can both read the passwords.

You could potentially write a plugin to make WP work with a standard MD5 hash, but that seems like a lot of work for less security.

Thanks,
Josh

Offline

 

#7 2016-11-25 18:33:39

eliz82
Member
Romania
2016-04-27
259

Re: Piwigo and WordPress Login Integration / Bridge

peterpix wrote:

I'm glad someone has found a way around the issue.  Unfortunately for me, that fix requires PHP 5.5.

What issue , what fix ? External authentication is a future of Piwigo not a fix.
The "issue" is that community plugin is buggy and give errors if the external software have the same database columns names like Piwigo. Luckily this is not the case for Wordpress.

KungFuJosh used a plugin to change the hash function because maybe was to lazy or didn't have the knowledge to determine the default password hash function of wordpress.
Unfortunately that wordpress plugin that change password hash is using some PHP 5.5 functions, maybe this one is not using https://wordpress.org/plugins/wp-hash-password/ you can try it if you want. Or then just determine the password hash of wordpress 4.x, maybe the guys from Wordpress tech support can help you. Or maybe is other plugins that use other hash algorithm that you can use.

Offline

 

#8 2016-11-25 19:36:41

KungFuJosh
Member
2016-08-21
28

Re: Piwigo and WordPress Login Integration / Bridge

eliz82 wrote:

peterpix wrote:

I'm glad someone has found a way around the issue.  Unfortunately for me, that fix requires PHP 5.5.

What issue , what fix ? External authentication is a future of Piwigo not a fix.
The "issue" is that community plugin is buggy and give errors if the external software have the same database columns names like Piwigo. Luckily this is not the case for Wordpress.

KungFuJosh used a plugin to change the hash function because maybe was to lazy or didn't have the knowledge to determine the default password hash function of wordpress.
Unfortunately that wordpress plugin that change password hash is using some PHP 5.5 functions, maybe this one is not using https://wordpress.org/plugins/wp-hash-password/ you can try it if you want. Or then just determine the password hash of wordpress 4.x, maybe the guys from Wordpress tech support can help you. Or maybe is other plugins that use other hash algorithm that you can use.

Thanks for the insulting response, but you're clearly ignorant here. WordPress' authentication system is proprietary, and significantly less secure than bcrypt.

While the plugin you chose does use bcrypt, the plugin itself hasn't been updated in 2 years, and isn't tested for compatibility with the latest WordPress version. It also doesn't list the PHP requirements, so he'd still be testing at risk.

bcrypt is a built in function of PHP 5.5+, so chances are the plugin is relying on that.

I would never tell anybody to use an outdated plugin, especially regarding security. You're basically suggesting that he opens his site to lazy hackers.

A word of advice, if you don't know what you're talking about, don't feel the need to say anything.

Offline

 

#9 2016-11-26 08:39:56

eliz82
Member
Romania
2016-04-27
259

Re: Piwigo and WordPress Login Integration / Bridge

So if a software is more then 2 years old you accusing it for being non-secure without any proof, and you are so cocky about it.
"It also doesn't list the PHP requirements, so he'd still be testing at risk" ... what risk ? the risk to give a PHP error "the function is not defined"?
Pfff

KungFuJosh wrote:

A word of advice, if you don't know what you're talking about, don't feel the need to say anything.

coming from you this is a real joke

Offline

 

#10 2016-11-26 11:38:39

flop25
Piwigo Team
2006-07-06
6965

Re: Piwigo and WordPress Login Integration / Bridge

bcrypt is by far not mandatory ; Wordpress and Piwigo relies on the same phpass library. Piwigo makes 13 hashing loops [Github] Piwigo file include/functions_user.inc.php@L1015 while Wordpress does 8 https://github.com/WordPress/WordPress/ … .php#L2124

About the bcrypt "lad" https://twitter.com/nacin/status/711047671725871104

And stop being touchy here guys


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#11 2016-11-26 14:49:22

KungFuJosh
Member
2016-08-21
28

Re: Piwigo and WordPress Login Integration / Bridge

eliz82 wrote:

So if a software is more then 2 years old you accusing it for being non-secure without any proof, and you are so cocky about it.
"It also doesn't list the PHP requirements, so he'd still be testing at risk" ... what risk ? the risk to give a PHP error "the function is not defined"?
Pfff

KungFuJosh wrote:

A word of advice, if you don't know what you're talking about, don't feel the need to say anything.

coming from you this is a real joke

I don't know why you have a bug up your ass, I've never done anything but help you. Grow up.

Offline

 

#12 2016-11-26 14:58:34

KungFuJosh
Member
2016-08-21
28

Re: Piwigo and WordPress Login Integration / Bridge

flop25 wrote:

bcrypt is by far not mandatory ; Wordpress and Piwigo relies on the same phpass library. Piwigo makes 13 hashing loops [Github] Piwigo file include/functions_user.inc.php@L1015 while Wordpress does 8 https://github.com/WordPress/WordPress/ … .php#L2124

About the bcrypt "lad" https://twitter.com/nacin/status/711047671725871104

And stop being touchy here guys

Not mandatory, but bcrypt is certainly superior.

Why doesn't anybody from Piwigo answer things on the Requests section? I have a thread there from August about improving compatibility, and it's been ignored the whole time. I'm the only one that has replied to my own thread.

Offline

 

#13 2019-02-19 23:04:34

tooleyweeds
Member
2019-01-26
6

Re: Piwigo and WordPress Login Integration / Bridge

Thank you, KungFuJosh, for offering the code and the database cleanup needed to achieve a single login for WP and Piwigo.

I have a working WP installation (jeffersoncityjays1967.com) with the Password bcrypt plugin installed.  My Piwigo installation (jeffersoncityjays1967.com/photos) worked until I attempted to implement KungFuJosh's solution to integrate it with WP. 

Piwigo 2.9.4
PHP:  5.6.30

I have added the suggested code from KungFuJosh to a /local/config/config.inc.php file in my Piwigo installation.  I made one change to that code, because my WP user login information is in another database separate from my Piwigo database:  in $conf['users_table'] = 'wp_users';  I changed 'wp_users' to 'MyWPDatabase.wp_users'.  I also used cPanel to give Piwigo access to MyWPDatabase.

Then I used the SQL tab in phpMyAdmin to perform the DELETEs and UPDATEs recommended in the authentication section of Piwigo's include/config_default.inc.php file.

I am now roadblocked by the warnings and errors shown below when I try to access my Piwigo gallery.

I will appreciate any insight into what I need to fix.

Warning: array_merge(): Argument #1 is not an array in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/functions_user.inc.php on line 392

Warning: Invalid argument supplied for foreach() in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/functions_user.inc.php on line 394

Notice: Undefined index: id in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/functions_user.inc.php on line 420

Notice: Undefined index: status in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/functions_user.inc.php on line 420


Warning:  [mysql error 1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

SELECT cat_id
  FROM piwigo_user_access
  WHERE user_id =
; in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/dblayer/functions_mysqli.inc.php on line 845


Fatal error: Call to a member function fetch_assoc() on a non-object in /home4/MyUser/public_html/jeffersoncityjays1967.com/photos/include/dblayer/functions_mysqli.inc.php on line 906

Offline

 

#14 2019-02-20 00:10:07

flop25
Piwigo Team
2006-07-06
6965

Re: Piwigo and WordPress Login Integration / Bridge

I did search and I don't find what's wrong here
You will have to debug by adding some print_r to check the values of the variables starting from there [Github] Piwigo file include/functions_user.inc.php@L392


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#15 2019-02-20 01:10:52

tooleyweeds
Member
2019-01-26
6

Re: Piwigo and WordPress Login Integration / Bridge

Thank you.  I appreciate your attention to my problem.

Is $conf['users_table'] = 'MyWPDatabase.wp_users'  the correct way for me to refer to my WP table containing the user login information?  Or should I include a schema (dbo) between the database name and the table name?

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact