Andy's Blog » » OSC与SMF 1.03的整合代码

OSC与SMF 1.03的整合代码

这里贴出的是SMF的连接代码,步骤及相关修改参考“OSC与discuz2.5f的整合代码及其步骤

smf.php代码

<?php
 
if($forum_nick!='') {
 
$db_server = 'localhost';
$db_name = 'smf';
$db_user = 'root';
$db_passwd = '11111111';
$db_prefix = '103_';
 
function md5_hmac($data, $key)
{
if (strlen($key) > 64)
$key = pack('H*', md5($key));
$key = str_pad($key, 64, chr(0x00));
 
$k_ipad = $key ^ str_repeat(chr(0x36), 64);
$k_opad = $key ^ str_repeat(chr(0x5c), 64);
 
return md5($k_opad . pack('H*', md5($k_ipad . $data)));
}
 
$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
 
if (!$db_connection)
{
$mysql_error = mysql_error();
 
$db_connection = @mysql_connect($db_server, $db_prefix . $db_user, $db_passwd);
if ($db_connection != false)
{
 
}
}
 
if (!mysql_select_db($db_name, $db_connection))
{
return false;
}
 
 
$query = mysql_query("SELECT COUNT(*) FROM {$db_prefix}members WHERE memberName='$forum_nick'");
 
if(mysql_result($query, 0)) {
 
mysql_close();
 
} else {
 
$result = mysql_query("INSERT INTO {$db_prefix}members (memberName, realName, passwd, emailAddress, ID_GROUP, posts, personalText, avatar, dateRegistered, hideEmail, ID_POST_GROUP)
VALUES ('
" . $forum_nick . "', '" . $forum_nick . "', '" . md5_hmac($password, strtolower($forum_nick)) . "', '" . $email_address . "', 0, '0', '', '', '" . time() . "', '0', '4')");
 
if (!$result)
{
return false;
}
else
{
}
 
}
 
}
 
?>

感谢radnows分享.

Tags:

本文地址: http://www.21andy.com/new/20050831/36.html