今天BTV导航网的小编为你讲一下Discuz 完美集成进现有系统(整合游戏玩家和版面增删相关的内容。
最近的一次应用是基本完成了业务系统,需要整合Discuz进去作为交流版块使用。于是,涉及到用户系统的整合和版面的增删操作。UCenter提供了API进行用户的增删管理,自然可以用,但为了保证用户id的统一性,暴力地绕过了UCenter API,而采用直接操作数据库的方式来完成用户增删,当然版面的增删也是操作数据库来完成。 1、增加用户到Discuz和UCenter的代码
代码如下:
$uid = 100; // 用户编号
$username = "maple"; // 用户名
$password = "mypassword"; // 用户密码
$salt = md5((string)rand()); // 随机字符用于加密
$password = md5(md5($pwd) . $salt); // 加密后的密码
$groupid = 10; // 用户组编号
$timestamp = time(); // 时间戳
$bbsemail = "[email protected]"; // 注册邮箱,不能重复
execute_sql("INSERT INTO cdb_members (uid, username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, showemail, newsletter, invisible, timeoffset) VALUES ('$uid', '$username', '$salt', '$password', '0', '0', '$groupid', 'Manual Acting', '$timestamp', '$timestamp', '$timestamp', '0', '0', '$bbsemail', '0000-00-00', '0', '0', '0', '0', '0', 'H:i', '1', '1', '0', '8')");
execute_sql("INSERT INTO cdb_memberfields (uid) VALUES ('$uid')");
execute_sql("INSERT INTO `cdb_uc_members` SET uid='$uid', username='$username', password='$password', email='$bbsemail', regip='Manual Acting', regdate='$timestamp', salt='$salt'");
2、在Discuz和UCenter中删除用户的代码
$uid = 100; // 用户编号
$username = "maple"; // 用户名
$password = "mypassword"; // 用户密码
$salt = md5((string)rand()); // 随机字符用于加密
$password = md5(md5($pwd) . $salt); // 加密后的密码
$groupid = 10; // 用户组编号
$timestamp = time(); // 时间戳
$bbsemail = "[email protected]"; // 注册邮箱,不能重复
execute_sql("INSERT INTO cdb_members (uid, username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, showemail, newsletter, invisible, timeoffset) VALUES ('$uid', '$username', '$salt', '$password', '0', '0', '$groupid', 'Manual Acting', '$timestamp', '$timestamp', '$timestamp', '0', '0', '$bbsemail', '0000-00-00', '0', '0', '0', '0', '0', 'H:i', '1', '1', '0', '8')");
execute_sql("INSERT INTO cdb_memberfields (uid) VALUES ('$uid')");
execute_sql("INSERT INTO `cdb_uc_members` SET uid='$uid', username='$username', password='$password', email='$bbsemail', regip='Manual Acting', regdate='$timestamp', salt='$salt'");
2、在Discuz和UCenter中删除用户的代码
代码如下:
$uid = 100; // 要删除的用户编号
execute_sql("DELETE FROM `cdb_members` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_memberfields` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_uc_members` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_uc_memberfields` WHERE uid=$uid");
3、在Discuz中增加版面并设置版主的代码
$uid = 100; // 要删除的用户编号
execute_sql("DELETE FROM `cdb_members` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_memberfields` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_uc_members` WHERE uid=$uid");
execute_sql("DELETE FROM `cdb_uc_memberfields` WHERE uid=$uid");
3、在Discuz中增加版面并设置版主的代码
代码如下:
$uid = 100; // 版主用户编号
$fid = 100; // 版面编号,需要保证不与现有版面编号重复
$forum_name = "Test Forum"; // 版面名称
execute_sql("INSERT INTO `cdb_forums` (`fid`, `fup`, `type`, `name`, `status`, `displayorder`, `styleid`, `threads`, `posts`, `todayposts`, `lastpost`, `allowsmilies`, `allowhtml`, `allowbbcode`, `allowimgcode`, `allowmediacode`, `allowanonymous`, `allowshare`, `allowpostspecial`, `allowspecialonly`, `alloweditrules`, `allowfeed`, `recyclebin`, `modnewposts`, `jammer`, `disablewatermark`, `inheritedmod`, `autoclose`, `forumcolumns`, `threadcaches`, `alloweditpost`, `simple`, `modworks`, `allowtag`, `allowglobalstick`) VALUES
('$fid', 3, 'forum', '$forum_name', 1, 0, 0, 0, 0, 0, '', 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1);");
execute_sql("INSERT INTO `cdb_forumfields` (`fid`, `description`, `password`, `icon`, `postcredits`, `replycredits`, `getattachcredits`, `postattachcredits`, `digestcredits`, `redirect`, `attachextensions`, `formulaperm`, `moderators`, `rules`, `threadtypes`, `threadsorts`, `viewperm`, `postperm`, `replyperm`, `getattachperm`, `postattachperm`, `keywords`, `supe_pushsetting`, `modrecommend`, `tradetypes`, `typemodels`, `threadplugin`, `extra`) VALUES ('$fid', '', '', '', '', '', '', '', '', '', '', 'a:5:{i:0;s:0:\"\";i:1;s:0:\"\";s:5:\"medal\";N;s:7:\"message\";s:0:\"\";s:5:\"users\";s:0:\"\";}', '', '', '', '', ' 9 10 11 12 13 14 15 20 21 16 17 18 19 1 2 3 4 5 6 7 8 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', '', '', 'a:8:{s:4:\"open\";s:1:\"0\";s:3:\"num\";i:10;s:8:\"imagenum\";i:5;s:10:\"imagewidth\";i:200;s:11:\"imageheight\";i:150;s:9:\"maxlength\";i:0;s:9:\"cachelife\";i:900;s:8:\"dateline\";i:0;}', '', '', 'N;', 'a:1:{s:9:\"namecolor\";s:0:\"\";}');");
execute_sql("UPDATE cdb_members SET adminid='3' WHERE uid='$uid'");
execute_sql("INSERT INTO cdb_moderators (uid, fid, inherited) VALUES ('$uid', '$fid', '1')");
4、在Discuz中删除版面并取消版主管理权限的代码
$uid = 100; // 版主用户编号
$fid = 100; // 版面编号,需要保证不与现有版面编号重复
$forum_name = "Test Forum"; // 版面名称
execute_sql("INSERT INTO `cdb_forums` (`fid`, `fup`, `type`, `name`, `status`, `displayorder`, `styleid`, `threads`, `posts`, `todayposts`, `lastpost`, `allowsmilies`, `allowhtml`, `allowbbcode`, `allowimgcode`, `allowmediacode`, `allowanonymous`, `allowshare`, `allowpostspecial`, `allowspecialonly`, `alloweditrules`, `allowfeed`, `recyclebin`, `modnewposts`, `jammer`, `disablewatermark`, `inheritedmod`, `autoclose`, `forumcolumns`, `threadcaches`, `alloweditpost`, `simple`, `modworks`, `allowtag`, `allowglobalstick`) VALUES
('$fid', 3, 'forum', '$forum_name', 1, 0, 0, 0, 0, 0, '', 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1);");
execute_sql("INSERT INTO `cdb_forumfields` (`fid`, `description`, `password`, `icon`, `postcredits`, `replycredits`, `getattachcredits`, `postattachcredits`, `digestcredits`, `redirect`, `attachextensions`, `formulaperm`, `moderators`, `rules`, `threadtypes`, `threadsorts`, `viewperm`, `postperm`, `replyperm`, `getattachperm`, `postattachperm`, `keywords`, `supe_pushsetting`, `modrecommend`, `tradetypes`, `typemodels`, `threadplugin`, `extra`) VALUES ('$fid', '', '', '', '', '', '', '', '', '', '', 'a:5:{i:0;s:0:\"\";i:1;s:0:\"\";s:5:\"medal\";N;s:7:\"message\";s:0:\"\";s:5:\"users\";s:0:\"\";}', '', '', '', '', ' 9 10 11 12 13 14 15 20 21 16 17 18 19 1 2 3 4 5 6 7 8 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', ' 20 21 1 2 3 ', '', '', 'a:8:{s:4:\"open\";s:1:\"0\";s:3:\"num\";i:10;s:8:\"imagenum\";i:5;s:10:\"imagewidth\";i:200;s:11:\"imageheight\";i:150;s:9:\"maxlength\";i:0;s:9:\"cachelife\";i:900;s:8:\"dateline\";i:0;}', '', '', 'N;', 'a:1:{s:9:\"namecolor\";s:0:\"\";}');");
execute_sql("UPDATE cdb_members SET adminid='3' WHERE uid='$uid'");
execute_sql("INSERT INTO cdb_moderators (uid, fid, inherited) VALUES ('$uid', '$fid', '1')");
4、在Discuz中删除版面并取消版主管理权限的代码
代码如下:
$uid = 100; // 要删除版面的版主用户编号
$fid = 100; // 要删除的版面编号
execute_sql("DELETE FROM cdb_forums WHERE fid='$fid'");
execute_sql("DELETE FROM cdb_forumfields WHERE fid='$fid'");
execute_sql("DELETE FROM cdb_moderators WHERE fid='$fid'");
execute_sql("UPDATE cdb_members SET adminid='0' WHERE uid='$uid'");
直接操作数据库的好处是业务逻辑简单,操作方便,与现有系统整合容易;缺点就是很流氓很暴力,需要保证操作数据的有效性,如增加的版面的fid要保证唯一。
$uid = 100; // 要删除版面的版主用户编号
$fid = 100; // 要删除的版面编号
execute_sql("DELETE FROM cdb_forums WHERE fid='$fid'");
execute_sql("DELETE FROM cdb_forumfields WHERE fid='$fid'");
execute_sql("DELETE FROM cdb_moderators WHERE fid='$fid'");
execute_sql("UPDATE cdb_members SET adminid='0' WHERE uid='$uid'");
直接操作数据库的好处是业务逻辑简单,操作方便,与现有系统整合容易;缺点就是很流氓很暴力,需要保证操作数据的有效性,如增加的版面的fid要保证唯一。
通过对Discuz 完美集成进现有系统(整合游戏玩家和版面增删的详细介绍,希望对你有所帮助,我们提供了更多和Discuz 完美集成进现有系统(整合用户和版面增删类似的相关内容推荐,可以你更全面的帮助你解决问题。我们BTV85网址导航还提供网址收录服务,你可以注册提交你的网站信息,帮你引导搜索引擎蜘蛛,同时还有网站SEO优化交流微信群,里面很多SEO高手和大咖,加友链,可以免费进群。
-
223084
网站
- 16453
小程序
-
25975
文章
-
253
会员
热门网站
- 百度一下 www.baidu.com
- 爱去小说网_TXT小说下载_TXT电子书免费下载_无弹窗免费小说阅读网-爱奇电子书 www.27dzs.com
- 情感论坛-寻觅爱情 www.xunmii.com
- 豌豆荚官网 www.wandoujia.com
- 仙踪林 www.rbt.com.cn
- 伊甸园(Eden)网站 www.ydybt.net
- 樱桃网 www.yingtao.me
- 学习库 www.xuexiku.com.cn
- HDMV高品质1080p高清MV下载 www.hdmv.cc
- CC漫画网 bbs.4gdm.com
最新入驻小程序
热门文章
- 智能查询域名的10个国外网站 04-29
- 通信大数据行程卡在哪查看 疫情防控行程卡二维码在哪里(图文) 11-25
- 头条号短视频搬运玩法,3分钟学会全套操作,人人可操作月入数千(视频教程) 06-29
- 咸鱼之王遗迹探险典韦关打法阵容攻略 10-10
- 利用百度地图标注项目进行赚钱,新手也能日入千元(视频教程) 06-29
- 新手可学会的快手手势舞教程,纯原创连续输出热门短视频(视频教程) 06-28
- 快手零粉丝也能赚钱,多种变现手法帮你零基础轻松月入50000+(视频课程) 06-29
- 树敌研习社抖音无人直播4.0:动态音频打造原创主播,无人直播实现24小时带货超牛逼技术(视频教程) 06-29
- btv新闻频道在线直播观看-btv北京新闻回放 11-25
- 抖音直播新玩法:直播间实时转播技术(云递联盟雷神0908课程)(视频教程+软件) 06-29