Login integration WP & Zen

Hi,

I unluckily tried to apply the methos explained at Tutorial: WordPress and ZenPhoto login integration' (http://www.zenphoto.org/support/topic.php?id=40) to integrate WP and Zen under one unique user+pass. So I did my own from the opposite approach: I tweaked (yes, sorry) the Zen auth_zp.php file.

In case anyone is interested I copy the code below (without much explanation. Investigate a bit, please) which works for me. I don't allow visitors to register at my WP website so I don't need to identify what role the logged user is. You don't need either the Zen login form anymore for the user login control is taken by WP and the admin (for both WP and Zen) has to go through the WP login page.

The code for zen/zp.php file (take it as a working drought, please):

/*
if (isset($_COOKIE['zenphoto_auth'])) {
$saved_auth = $_COOKIE['zenphoto_auth'];
$check_auth = md5(zp_conf("adminuser").zp_conf("adminpass"));
if ($saved_auth == $check_auth) {
*/
if (file_exists('../../wp-config.php')) {require_once('../../wp-config.php');} //hip
else if (file_exists('../wp-config.php')) {require_once('../wp-config.php');}
else {die('I\'m such a nerd that couldn\'t find it!');}

global $user_ID;
if("" == $user_ID) { echo ("you are logged out"); } //logged out -> do whatever you wish. Usually a redirect.
else { $_zp_loggedin = true; } //logged in -> let it go!

/*
} else {
// Clear the cookie
setcookie("zenphoto_auth", "", time()-368000, $cookiepath);
}
} else {
// Handle the login form.
if (isset($_POST['login']) && isset($_POST['user']) && isset($_POST['pass'])) {
$user = $_POST['user'];
$pass = $_POST['pass'];
$redirect = $_POST['redirect'];
if ($user == zp_conf("adminuser") && $pass == zp_conf("adminpass")) {
// Correct auth info. Set the cookie.
setcookie("zenphoto_auth", md5($user.$pass), time()+5184000, $cookiepath);
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . WEBPATH . $redirect);
$_zp_loggedin = true;
} else {
// Clear the cookie, just in case
setcookie("zenphoto_auth", "", time()-368000, $cookiepath);
$error = true;
}
}
}
*/

Have a good day,
hip

Comments

  • hip, do I replace the contents or do I add this to the auth_zp.php file?
  • hip Member
    It is a replacement to the comented (/* */) lines I include in my code.

    Sorry it's not too clear nor documented at all, but I lack time at this moment. I have some improvements on the code thet I'll post later on (in a few days, maybe before).

    Have a good day,
    hip
  • hip Member
    Too much hacking, finally, to post it as a re-usable solution, sorry. Though I may answer any question about it or even give the hacking away.

    It's no problem to me but not recommended. :-(

    Have a good day,
    hip
  • Hi Hip, why are you saying that it's not recommended? Does it have to change databases a lot?
Sign In or Register to comment.