Topic: integration with coppermine, wordpress, punbb, dokuwiki
I've been having a problem with integrating those. I'm wanting to make a login script first and worry about the registration and administration later.. I've gotten a lot of the code out of the respective programs.
Here's my code.
<?php
$expirein = time() + 31536000;
/* for wordpress */
//require_once( dirname(__FILE__) . '/users/login-functions.php' );
//$rooot = dirname(__FILE__);
//require_once( dirname(__FILE__) . '/wp-config.php');
/* for punbb */
define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';
define('PUN_TURN_OFF_MAINT', 1);
define('PUN_QUIET_VISIT', 1);
?>
<html>
<title>login</title>
<head>
</head>
<body>
<div id="loginform">
login
<form method="POST" action="login.php">
<label>username: </label>
<input type="text" name="usern" value="" /><br />
<label>password: </label>
<input type="password" name="passw" value="" /><br />
<input type="submit" name="lin" value="login" />
</form>
</div>
</body>
</html>
<?php
$username = $_POST['usern'];
$password = $_POST['passw'];
$passhashmd5 = md5($password);
$passhashsha1 = sha1($password);
function wp_setcookienews($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
if ( !$already_md5 )
$password = md5( md5($password) ); // Double hash the password in the cookie.
if ( empty($home) )
$cookiepath = COOKIEPATH;
else
$cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
if ( empty($siteurl) ) {
$sitecookiepath = SITECOOKIEPATH;
$cookiehash = COOKIEHASH;
} else {
$sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
$cookiehash = md5($siteurl);
}
if ( $remember )
$expire = time() + 31536000;
else
$expire = 0;
setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN);
if ( $cookiepath != $sitecookiepath ) {
setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN);
}
}
function pun_setcookieforum($user_id, $password_hash, $expire)
{
global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $cookie_seed;
// Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6)
// @header('P3P: CP="CUR ADM"');
if (version_compare(PHP_VERSION, '5.2.0', '>='))
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true);
else
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path.'; HttpOnly', $cookie_domain, $cookie_secure);
}
/* now here are the stuff that actually set the cookies. */
pun_setcookieforum($username, $passhashsha1, $expirein);
wp_setcookienews($username, $password, $already_md5 = false, $home = '', $siteurl = '');
?>
My Wordpress logs in correctly, but punbb won't. I've looked at the cookies that were made by the original login script (for punbb) and the difference that i see is that the real one has the number "2" instead of the word "admin" (which is made my my own code.). Any suggestions?
Edit: I know that so far, I only have wordpress and punbb in the script. I'll work on those when punbb and wordpress work together.