虽然国内建站在论坛方面首先考虑discuz(php),phpwind(php)和dvbbs(asp)。但是在国外使用phpbb还是比较多。
虽然以前前一直没用过也没听过phpbb,自然也没什么兴趣去看他的代码。但是前天的CMS课上,老师给我们4个小时的时间做一个给phpbb批量添加用户的脚本。
使用方法,修改相应的数据库连接代码,然后把这个文件方上服务器就可以了。上传文件用excel另存csv就可以了
添加单个用户
<div id="_mcePaste"><?php
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
if($username&&$password&&$email){
$bd = mysql_connect("localhost", "root", "root") or die('Connessione fallita' . mysql_error());
mysql_select_db('phpbb') or die('Selezione Database' . mysql_error());
$pass = md5($password);
$now = time();
$check=mysql_query("SELECT * FROM users WHERE username='$username' OR user_email='$email'") or die(mysql_error());
if(!mysql_fetch_array($check)){
$sql = "INSERT INTO `users` (`user_type`, `group_id`, `user_permissions`, `user_perm_from`, `user_ip`, `user_regdate`, `username`, `username_clean`, `user_password`, `user_passchg`, `user_pass_convert`, `user_email`, `user_email_hash`, `user_birthday`, `user_lastvisit`, `user_lastmark`, `user_lastpost_time`, `user_lastpage`, `user_last_confirm_key`, `user_last_search`, `user_warnings`, `user_last_warning`, `user_login_attempts`, `user_inactive_reason`, `user_inactive_time`, `user_posts`, `user_lang`, `user_timezone`, `user_dst`, `user_dateformat`, `user_style`, `user_rank`, `user_colour`, `user_new_privmsg`, `user_unread_privmsg`, `user_last_privmsg`, `user_message_rules`, `user_full_folder`, `user_emailtime`, `user_topic_show_days`, `user_topic_sortby_type`, `user_topic_sortby_dir`, `user_post_show_days`, `user_post_sortby_type`, `user_post_sortby_dir`, `user_notify`, `user_notify_pm`, `user_notify_type`, `user_allow_pm`, `user_allow_viewonline`, `user_allow_viewemail`, `user_allow_massemail`, `user_options`, `user_avatar`, `user_avatar_type`, `user_avatar_width`, `user_avatar_height`, `user_sig`, `user_sig_bbcode_uid`, `user_sig_bbcode_bitfield`, `user_from`, `user_icq`, `user_aim`, `user_yim`, `user_msnm`, `user_jabber`, `user_website`, `user_occ`, `user_interests`, `user_actkey`, `user_newpasswd`, `user_form_salt`, `user_new`, `user_reminded`, `user_reminded_time`) VALUES
(0, 2, 0x3030303030303030303036787271656977770a6931636a796f3030303030300a716c61713532303030303030, 0, '127.0.0.1', $now, '$username', '$username', '$pass', $now, 0, '$email', 282589336312, '', $now, $now, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 1.00, 0, 'D M d, Y g:i a', 1, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'b3926a7717a7ca0d', 1, 0, 0);";
mysql_query($sql);
echo "Success<br/>";
}else{
echo "Failed! username or email used<br/>";
}
}
?>
<html>
<head>
<title>Add user</title>
</head>
<body>
<form action="#" method="post">
<label>username:<input name="username"/></label>
<label>password:<input type="password" name="password"/></label>
<label>email:<input name="email"/></label>
<input type="submit" value="submit"/>
</form>
<a href="adduser.php">Ajouter un compte</a>
<a href="addusers.php">Ajouter multi comptes</a>
</body>
</html></div>
使用csv文件批量添加用户
<?php
$csv=$_FILES["csv"];
if($csv&&$csv["type"]=="text/csv"){
$list=file($csv["tmp_name"]);
if($list){
$bd = mysql_connect("localhost", "root", "root") or die('Connessione fallita' . mysql_error());
mysql_select_db('phpbb') or die('Selezione Database' . mysql_error());
foreach($list as $value){
list($username,$password,$email)=explode(";",$value);
if($username&&$password&&$email){
addusers($username,$password,$email);
}
unset($username,$password,$email);
}
echo "success";
}
}
function addusers($username,$password,$email){
$pass = md5($password);
$now = time();
$check=mysql_query("SELECT * FROM users WHERE username='$username' OR user_email='$email'") or die(mysql_error());
if(!mysql_fetch_array($check)){
mysql_query("INSERT INTO `users` (`user_type`, `group_id`, `user_permissions`, `user_perm_from`, `user_ip`, `user_regdate`, `username`, `username_clean`, `user_password`, `user_passchg`, `user_pass_convert`, `user_email`, `user_email_hash`, `user_birthday`, `user_lastvisit`, `user_lastmark`, `user_lastpost_time`, `user_lastpage`, `user_last_confirm_key`, `user_last_search`, `user_warnings`, `user_last_warning`, `user_login_attempts`, `user_inactive_reason`, `user_inactive_time`, `user_posts`, `user_lang`, `user_timezone`, `user_dst`, `user_dateformat`, `user_style`, `user_rank`, `user_colour`, `user_new_privmsg`, `user_unread_privmsg`, `user_last_privmsg`, `user_message_rules`, `user_full_folder`, `user_emailtime`, `user_topic_show_days`, `user_topic_sortby_type`, `user_topic_sortby_dir`, `user_post_show_days`, `user_post_sortby_type`, `user_post_sortby_dir`, `user_notify`, `user_notify_pm`, `user_notify_type`, `user_allow_pm`, `user_allow_viewonline`, `user_allow_viewemail`, `user_allow_massemail`, `user_options`, `user_avatar`, `user_avatar_type`, `user_avatar_width`, `user_avatar_height`, `user_sig`, `user_sig_bbcode_uid`, `user_sig_bbcode_bitfield`, `user_from`, `user_icq`, `user_aim`, `user_yim`, `user_msnm`, `user_jabber`, `user_website`, `user_occ`, `user_interests`, `user_actkey`, `user_newpasswd`, `user_form_salt`, `user_new`, `user_reminded`, `user_reminded_time`) VALUES
(0, 2, 0x3030303030303030303036787271656977770a6931636a796f3030303030300a716c61713532303030303030, 0, '127.0.0.1', $now, '$username', '$username', '$pass', $now, 0, '$email', 282589336312, '', $now, $now, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 1.00, 0, 'D M d, Y g:i a', 1, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'b3926a7717a7ca0d', 1, 0, 0);");
}
}
?>
<html>
<head>
<title>Ajouter multi comptes</title>
</head>
<body>
<form action="#" method="post" enctype="multipart/form-data">
<label>csv:<input type="file" name="csv"/></label>
<input type="submit" value="submit"/>
</form>
<a href="adduser.php">Ajouter un compte</a>
<a href="addusers.php">Ajouter multi comptes</a>
</body>
</html>