Integrating punbb and wordpress. and programming

I’m wanting to make my own login script (programmed in PHP) but I suck at programming. I’ve read many books on it, but I haven’t actually practiced it. Anyway, the login script recreates some functions (copied directly from the respective programs, but with a modified name) as well as includes the config files.

Here’s my code

$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);



<div id="loginform">
<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" />


$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;
$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;
$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);
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 = '');


With the above code, Wordpress login works perfectly, but PunBB doesn’t work. I looked at the cookies formed, and basically, while the real script (punbb’s login) has the number 2 in it, the one that i make has my username “admin” instead of that number 2. Otherwise, everything is the same.

I know that i’ve posted this into both punbb and wordpress forums, but… they seem to be ignoring me…

Please point out any programming problems and also how to fix them if you can.

My directories are as follows:

/home/httpd/html/wordpress <---- my wordpress directory (my login.php file is located here)
/home/httpd/html/wordpress/forums <---- my punbb directory.



I know that I’m currently not using a unified user table… I’m later going to make a register.php script that would fill in the correct tables with the correct data.