Posts Tagged ‘php’

老discuz直接升级至discuz x2

星期一, 三月 12th, 2012

我这个是discuz 6.1吧。大概。。
版本忘记了。。
是gbk版本。
老论坛。在我17岁那年玩的
由于当时未满18.。随便上网 搜了个身份正。。拿去 beian了。
后来beian重申。。
哪能记得当时用的谁的。。。
就这样。。 beian被取消了。。
无奈啊。

现在放国外服务器上 挂着吧。

似乎转换有点麻烦
决定一个个 表的手工转换

INSERT INTO `qphome`.`cdb_ucenter_members` (`uid`, `username`, `password`, `email`, `myid`, `myidkey`, `regip`, `regdate`, `lastloginip`, `lastlogintime`, `salt`, `secques`) SELECT 	uid,username,password,email,myid,myidkey,regip,regdate,lastloginip,lastlogintime,salt,secques 
FROM  `qphome_old`.`uc_members` 
 
 
 
 
	INSERT INTO `qphome`.`cdb_forum_thread` (`tid`,`fid`,`typeid`,`sortid`,`readperm`,`price`,`author`,`authorid`,`subject`,`dateline`,`lastpost`,`lastposter`,`views`,`replies`,`displayorder`,`highlight`,`digest`,`rate`,`special`,`attachment`,`moderated`,`closed`) SELECT `tid`,`fid`,`typeid`,`sortid`,`readperm`,`price`,`author`,`authorid`,`subject`,`dateline`,`lastpost`,`lastposter`,`views`,`replies`,`displayorder`,`highlight`,`digest`,`rate`,`special`,`attachment`,`moderated`,`closed` FROM `qphome_old`.`cdb_threads`
 
 
		INSERT INTO `qphome`.`cdb_forum_forum` (`fid`,`fup`,`type`,`name`,`status`,`displayorder`,`styleid`,`threads`,`posts`,`todayposts`,`lastpost`,`allowsmilies`) SELECT `fid`,`fup`,'forum' AS `type`,`name`,`status`,`displayorder`,`styleid`,`threads`,`posts`,`todayposts`,`lastpost`,`allowsmilies` FROM `qphome_old.cdb_forums`
 
 
				INSERT INTO `qphome`.`cdb_forum_post` (`pid`,`fid`,`tid`,`first`,`author`,`authorid`,`subject`,`dateline`,`message`,`useip`,`invisible`,`anonymous`,`usesig`,`htmlon`,`bbcodeoff`,`smileyoff`,`parseurloff`,`attachment`,`rate`,`ratetimes`,`status`	)
				SELECT `pid`,`fid`,`tid`,`first`,`author`,`authorid`,`subject`,`dateline`,`message`,`useip`,`invisible`,`anonymous`,`usesig`,`htmlon`,`bbcodeoff`,`smileyoff`,`parseurloff`,`attachment`,`rate`,`ratetimes`,`status`	 FROM `qphome_old`.`cdb_posts`
 
INSERT INTO `qphome`.`cdb_common_member`
	(`uid`,`email`,`username`,`password`,`adminid`,`groupid`,`groupexpiry`,`extgroupids`,`regdate`,`credits`,`timeoffset`,`accessmasks`	)
	SELECT `uid`,`email`,`username`,`password`,`adminid`,`groupid`,`groupexpiry`,`extgroupids`,`regdate`,`credits`,`timeoffset`,`accessmasks` FROM `qphome_old`.`cdb_members`
 
 
 
 
INSERT INTO `qphome`.`cdb_forum_forumfield`(
`fid`,`description`,`password`,`icon`,`moderators`,`rules`,`threadtypes`,`threadsorts`,`viewperm`,`postperm`,`replyperm`,`getattachperm`,`postattachperm`,`keywords`,`supe_pushsetting`,`formulaperm`,`modrecommend`	
	) SELECT `fid`,`description`,`password`,`icon`,`moderators`,`rules`,`threadtypes`,`threadsorts`,`viewperm`,`postperm`,`replyperm`,`getattachperm`,`postattachperm`,`keywords`,`supe_pushsetting`,`formulaperm`,`modrecommend`	
FROM `qphome_old`.`cdb_forumfields`
 
 
UPDATE  `qphome`.`cdb_forum_forum` SET  `fup` =  '10' WHERE  `cdb_forum_forum`.`fid` IN(11,12,13,14);
UPDATE  `qphome`.`cdb_forum_forum` SET  `fup` =  '83' WHERE  `cdb_forum_forum`.`fid` IN(84,85,86,87,88,89,90,91,92,93,104,105);
 
 
 
 
				INSERT INTO `qphome`.`cdb_common_member_profile`(
	`uid`,`realname`,`gender`,`birthyear`,`birthmonth`,`birthday`,`alipay`,`icq`,`qq`,`yahoo`,`msn`,`taobao`,`site`,`bio`
 
		)(
		SELECT f.uid,'' AS `realname`,m.`gender`,YEAR(m.`bday`) AS `birthyear`,MONTH(m.`bday`) AS `birthmonth`,DAY(m.`bday`) AS `birthday`,f.`alipay`,f.`icq`,f.`qq`,f.`yahoo`,f.`msn`,f.`taobao`,f.`site`,f.`bio`
 
FROM		`qphome_old`.`cdb_memberfields` AS f LEFT JOIN `qphome_old`.`cdb_members` AS m ON f.`uid`=m.`uid`
		)
 
 
 
			INSERT INTO `qphome`.`cdb_common_member_count`(
 
	`uid`,`extcredits1`,`extcredits2`,`extcredits3`,`extcredits4`,`extcredits5`,`extcredits6`,`extcredits7`,`extcredits8`,`posts`,`threads`,`digestposts`,`views`,`oltime`
 
	) SELECT  `uid`,`extcredits1`,`extcredits2`,`extcredits3`,`extcredits4`,`extcredits5`,`extcredits6`,`extcredits7`,`extcredits8`,`posts`,`threads`,`digestposts`,`pageviews` AS `views`,`oltime`
	FROM `qphome_old`.`cdb_members` 
 
 
 
				INSERT INTO `qphome`.`cdb_common_member_status`(
 
					`uid`,`regip`,`lastip`,`lastvisit`,`lastactivity`,`lastpost`
					)
					SELECT `uid`,`regip`,`lastip`,`lastvisit`,`lastactivity`,`lastpost`  	FROM `qphome_old`.`cdb_members` 
 
 
 
INSERT INTO `cdb_ucenter_pm_lists`
(authorid, pmtype, subject, members, min_max, dateline,lastmessage) 
SELECT * FROM (SELECT msgfromid AS authorid, 1 AS pmtype, '' AS subject, 2 AS members, 
CONCAT(LEAST(msgfromid,msgtoid),'_',GREATEST(msgfromid,msgtoid)) AS min_max, dateline, 
CONCAT('a:3:{s:12:"lastauthorid";s:',LENGTH(msgfromid),':"',msgfromid,'";s:10:"lastauthor";s:',LENGTH(msgfrom),':"',msgfrom,'";s:11:"lastsummary";s:',LENGTH(message),':"',LEFT(IF(LENGTH(subject) > 0 AND STRCMP(subject, message), CONCAT(subject, '\r\n', message), message),150),'";}') AS lastmessage
FROM `uc_pms` 
WHERE related = 1 ORDER BY dateline DESC) AS tmp GROUP BY min_max;
 
 
 
 
INSERT INTO `cdb_ucenter_pm_members` (plid, uid, isnew, lastupdate) SELECT plid, SUBSTRING_INDEX(min_max, '_', 1), 0, 0 FROM `cdb_ucenter_pm_lists`;
INSERT INTO `cdb_ucenter_pm_members` (plid, uid, isnew, lastupdate) SELECT plid, SUBSTRING_INDEX(min_max, '_', -1), 0, 0 FROM `cdb_ucenter_pm_lists`;
 
ALTER TABLE  `cdb_ucenter_pm_indexes` ADD  `pmidold` INT NULL;
 
 
 
 
INSERT INTO `cdb_ucenter_pm_indexes` (plid, pmidold) SELECT l.plid, p.pmid FROM `uc_pms` p LEFT JOIN `cdb_ucenter_pm_lists` l ON CONCAT(LEAST(p.msgfromid, p.msgtoid), '_', GREATEST(p.msgfromid, p.msgtoid)) = l.min_max WHERE p.related = 1;
 
 
 
 
INSERT INTO `cdb_ucenter_pm_messages_0` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 0;
INSERT INTO `cdb_ucenter_pm_messages_1` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 1;
INSERT INTO `cdb_ucenter_pm_messages_2` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 2;
INSERT INTO `cdb_ucenter_pm_messages_3` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 3;
INSERT INTO `cdb_ucenter_pm_messages_4` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 4;
INSERT INTO `cdb_ucenter_pm_messages_5` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 5;
INSERT INTO `cdb_ucenter_pm_messages_6` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 6;
INSERT INTO `cdb_ucenter_pm_messages_7` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 7;
INSERT INTO `cdb_ucenter_pm_messages_8` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 8;
INSERT INTO `cdb_ucenter_pm_messages_9` (pmid, plid, authorid, message, delstatus, dateline) SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message), CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus, IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `cdb_ucenter_pm_indexes` i LEFT JOIN `uc_pms` p ON i.pmidold = p.pmid LEFT JOIN `cdb_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 9;
 
 
 
 
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_0` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 0 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_1` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 1 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_2` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 2 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_3` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 3 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_4` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 4 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_5` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 5 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_6` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 6 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_7` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 7 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_8` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 8 AND m.plid = msg.plid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, dateline FROM `cdb_ucenter_pm_messages_9` ORDER BY dateline DESC) msg SET m.lastdateline = msg.dateline WHERE m.plid % 10 = 9 AND m.plid = msg.plid;
 
 
 
 
 
 
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_0` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 0 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_0` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 0 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_1` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 1 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_1` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 1 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_2` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 2 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_2` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 2 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_3` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 3 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_3` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 3 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_4` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 4 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_4` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 4 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_5` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 5 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_5` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 5 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_6` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 6 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_6` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 6 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_7` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 7 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_7` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 7 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_8` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 8 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_8` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 8 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_9` WHERE delstatus IN (0,1) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 9 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1), l.authorid) = m.uid;
UPDATE `cdb_ucenter_pm_members` m, (SELECT plid, COUNT(*) AS pmnum FROM `cdb_ucenter_pm_messages_9` WHERE delstatus IN (0,2) GROUP BY plid) msg, `cdb_ucenter_pm_lists` l SET m.pmnum = msg.pmnum WHERE m.plid % 10 = 9 AND m.plid = msg.plid AND m.plid = l.plid AND IF(SUBSTRING_INDEX(l.min_max, '_', 1) = l.authorid, l.authorid, SUBSTRING_INDEX(l.min_max, '_', -1)) = m.uid;
 
 
 
 
 
 
ALTER TABLE `cdb_ucenter_pm_indexes`
  DROP `pmidold`;

另外 discuz 的附件表 分表了
分成一个索引表
cdb_forum_attachment
还有0-9的附件详情表
cdb_forum_attachment_$1

根据 tid决定的最后一位决定存放的表

用php处理下把

<?php
	header("Content-Type:text/html;charset=UTF-8");
require_once './include/common.inc.php';
$query=$db->query("select a.*,f.description from `cdb_attachments` as a left join `cdb_attachmentfields` as f on a.aid=f.aid  limit 9999999");
$a=0;
while($r=$db->fetch_array($query)){
	$tableid=substr($r['tid'],-1);
	$at[]=array('aid'=>$r['aid'],	'tid'=>$r['tid'],'pid'=>$r['pid'],'uid'=>$r['uid'],'tableid'=>$tableid,'downloads'=>$r['downloads']);
	$atb[$tableid][]=array(
	'aid'=>$r['aid'],
	'tid'=>$r['tid'],
	'pid'=>$r['pid'],
	'uid'=>$r['uid'],
	'dateline'=>$r['dateline'],
	'filename'=>daddslashes($r['filename']),
	'filesize'=>$r['filesize'],
	'attachment'=>$r['attachment'],
	'remote'=>0,
	'description'=>daddslashes($r['description']),
	'readperm'=>$r['readperm'],
	'price'=>$r['price'],
	'isimage'=>$r['isimage'],
	'width'=>$r['width'],
	'thumb'=>$r['thumb'],
	'picid'=>$r['picid'],
	);
	$a++;
	$atcount[$tableid]++;
	}
	echo "数量 :$a     \r\n";
$db->query("TRUNCATE TABLE `cdb_forum_attachment`");
	$sql="INSERT INTO `cdb_forum_attachment` (`aid`, `tid`, `pid`, `uid`, `tableid`, `downloads`) VALUES";
	foreach($at as $a){
		$sql.="('{$a['aid']}','{$a['tid']}','{$a['pid']}','{$a['uid']}','{$a['tableid']}','{$a['downloads']}'),";
		}
	$sql=substr($sql,0,-1);	
	$db->query($sql);
	for($i=0;$i<10;$i++){
			$db->query("TRUNCATE TABLE `cdb_forum_attachment_$i`");
$sql="INSERT INTO `discuz_new`.`cdb_forum_attachment_$i` (`aid`, `tid`, `pid`, `uid`, `dateline`, `filename`, `filesize`, `attachment`, `remote`, `description`, `readperm`, `price`, `isimage`, `width`, `thumb`, `picid`) VALUES ";
	foreach($atb[$i] as $a){
		$sql.="('{$a['aid']}','{$a['tid']}','{$a['pid']}','{$a['uid']}','{$a['dateline']}','{$a['filename']}','{$a['filesize']}','{$a['attachment']}','{$a['remote']}','{$a['description']}','{$a['readperm']}','{$a['price']}','{$a['isimage']}','{$a['width']}','{$a['thumb']}','{$a['picid']}'),";
		}
	$sql=substr($sql,0,-1);	
	//echo $sql;		
	$db->query($sql);
		echo "已完成 表 $i 共有  {$atcount[$i]} 条记录 \r\n";
		}
 
?>

只要熟悉 表结构。这些挺容易操作的
用这样的方法 可以把任意一个论坛系统自由的转来转去。

php邮件发送类推荐 PHPMailer:smtp法

星期四, 五月 26th, 2011

这里说明下 我用的是SMTP 其他方法的请继续 GOOGLE
刚拿到的时候 测试了下发信 无异常 支持HTML
但是SMTP 发送的过程中 需要先于SMTP 服务器建立连接 然后发信
这个过程可能需要1-3秒 可能会导致网页响应较长时间
所以呢. 我们建立一个表用于存放发送的邮件队列
每次发送邮件是将 邮件内容加入表中
然后 用CRON 每分钟检查下表 若存在 则 队列发送
目前在起哄网上使用中.用于发送EMAIL认证邮件

 
--
-- 表的结构 `qlj_sendmail`
--
 
CREATE TABLE IF NOT EXISTS `qlj_sendmail` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `email` VARCHAR(50) DEFAULT NULL,
  `subject` VARCHAR(120) DEFAULT NULL,
  `body` text,
  `error` tinyint(1) NOT NULL DEFAULT '0',
  `dateline` INT(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
#!/usr/local/php/bin/php -q
<?php
include_once('mysql.class.php');
include_once('class.phpmailer.php');
$mail                = new PHPMailer();
$db = new DB;
$db->connect('', '', '', '');
$mail->IsSMTP(); 
	$mail->Host = "";  //SMTP服务器
	$mail->Username = "no-reply@qihoon.com";  
	$mail->Password = "";    
	$mail->FromName =  "起哄网信使";   
	$mail->SMTPAuth = true;          
	$mail->From = $mail->Username;
	$mail->CharSet = "utf8";           
	$mail->Encoding = "base64"; 
	$mail->AddAddress($sendto_email);  
$result=$db->query("SELECT id,email,subject,body FROM `qlj_sendmail` where error='0' LIMIT 0 , 30");
if($db->num_rows($result)<1) exit(); 
while ($row =$db->fetch_array($result)) {
$mail->AltBody ="text/html"; 
$mail->Subject = $row['subject'];
$mail->MsgHTML($row['body']);
  $mail->AddAddress($row["email"], $row["full_name"]);
  if(!$mail->Send()) {
    //$errorid[]=array(id=>$row['id'],error=>$mail->ErrorInfo);//本来想记录出错信息的.但是表是INT 不浪费字段了.
	  $errid[]=$row['id'];
  } else {
     $okid[]=$row['id'];
  }
  $mail->ClearAddresses();
}
if(count($okid)>0){
	$sok=implode(',',$okid);
	$db->query("delete from `qlj_sendmail` where id in($sok) ;");
	}
	if(count($errid)>0){
	$serr=implode(',',$errid);
	$db->query("update `qlj_sendmail` set error='1' where id in($serr) ;");
	}
?>

最后在 CRONTAB中 加入 每分钟的计划任务
*/1 * * * * /usr/local/php/bin/php /home/yingouqlj/send_mail.php

参考官方实例.

php延时更新点击数[文件缓存]

星期三, 三月 9th, 2011

想法来源

用户积分增加

列入 用户访问空间时增加1分

用户首次登陆增加10分

那么每次操作都要insert一次

这显然很浪费

如果可以缓存一次性写入那么就可以降低MYSQL的压力了

像上面的情况我只要一次性增加11分即可

在THINKPHP中找到了方法

下面代码转载自THINKPHP(advmodel.class.php)

setLazyInc($field,$condition='',$step=1,$lazyTime=0) { //缓存累加
        if(empty($condition) && isset($this->options['where']))
            $condition   =  $this->options['where'];
        if(empty($condition)) { // 没有条件不做任何更新
            return false;
        }
        if($lazyTime>0) {// 延迟写入
            $guid =  md5($this->name.'_'.$field.'_'.serialize($condition));
            $step = $this->lazyWrite($guid,$step,$lazyTime);
            if(false === $step ) return true; // 等待下次写入
        }
        return $this->setField($field,array('exp',$field.'+'.$step),$condition);
    }
 
function lazyWrite($guid,$step,$lazyTime) {   
        if(false !== ($value = F($guid))) { // 存在缓存写入数据
            if(time()>F($guid.'_time')+$lazyTime) {
                // 延时更新时间到了,删除缓存数据 并实际写入数据库
                F($guid,NULL);
                F($guid.'_time',NULL);
                return $value+$step;
            }else{
                // 追加数据到缓存
                F($guid,$value+$step);
                return false;
            }
        }else{ // 没有缓存数据
            F($guid,$step);
            // 计时开始
            F($guid.'_time',time());
            return false;
        }
    }

上面有个 FUNCTION F 在FACTIONS.PHP

// 快速文件数据读取和保存 针对简单类型数据 字符串、数组
function F($name,$value='',$path=DATA_PATH) { //修改$path为自己的缓存路径
    static $_cache = array();
    $filename   =   $path.$name.'.php';
    if('' !== $value) {
        if(is_null($value)) {
            // 删除缓存
            return unlink($filename);
        }else{
            // 缓存数据
            $dir   =  dirname($filename);
            // 目录不存在则创建
            if(!is_dir($dir))  mkdir($dir);
            return file_put_contents($filename,"<?php\nreturn ".var_export($value,true).";\n?>");
        }
    }

调用方法

setLazyDec($field,$condition='',$step=1,$lazyTime=0) 
//根据需要 自己修改吧我加入了table 等多个
function lazyaddint($table,$field,$condition='',$num=1,$ltime=0)
//调用方法 更具实际需要修改吧
lazyaddint('表明','字段名',"WHERE条件",增加数量,缓存时间);

此方法 会在缓存目录中创建2个临时文件

//07e8c1b06dbdc4f282bf7bf9311a1fce_time.php
<?php
return 1299602761;
?>
 
//07e8c1b06dbdc4f282bf7bf9311a1fce.php
<?php
return 21;
?>

根据时间超过 设定的时间就写入数据库
此方法已经适用无问题
感觉方法不太好.. 期待MEMCACHED的方式

smarty cache缓存的使用

星期四, 五月 20th, 2010

机器实在太老了。。
在增加到8W条文章
TAG表已经增加到了30多万条了
10 个表 总计 415,762
在我那个老电脑上。。(p4 1.6 256内存)
很快。。内存不足了。。只剩下4MB剩余内存
于是TAOBAO上买了个 512的SDRAM
(更多…)

php+mysql模仿android中短信界面的效果

星期二, 四月 13th, 2010

十分喜欢android的短信
像 QQ一样。。
缺点是。。 发消息也想QQ一样。。。
一条接一条。。 钱也一条接一条的扣。。
哈哈
现在大部分网站的短信都类似于 GMAIL 一样。或者说。跟论坛主题一样。 。 一个贴。。后面回复。。
改变下模式。。做自己喜欢的效果。。
(更多…)

php 全角转半角

星期二, 三月 30th, 2010

找了几个函数
目前用的是第一个,虽然。。。不是很帅。。但是还是比较准的

/**  
 *  将一个字串中含有全角的数字字符、字母、空格或'%+-()'字符转换为相应半角字符  
 *  
 * @access  public  
 * @param   string       $str         待转换字串  
 *  
 * @return  string       $str         处理后字串  
 */  
function make_semiangle($str)   
{   
    $arr = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4',   
                 '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9',   
                 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E',   
                 'F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J',   
                 'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O',   
                 'P' => 'P', 'Q' => 'Q', 'R' => 'R', 'S' => 'S', 'T' => 'T',   
                 'U' => 'U', 'V' => 'V', 'W' => 'W', 'X' => 'X', 'Y' => 'Y',   
                 'Z' => 'Z', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd',   
                 'e' => 'e', 'f' => 'f', 'g' => 'g', 'h' => 'h', 'i' => 'i',   
                 'j' => 'j', 'k' => 'k', 'l' => 'l', 'm' => 'm', 'n' => 'n',   
                 'o' => 'o', 'p' => 'p', 'q' => 'q', 'r' => 'r', 's' => 's',   
                 't' => 't', 'u' => 'u', 'v' => 'v', 'w' => 'w', 'x' => 'x',   
                 'y' => 'y', 'z' => 'z',   
                 '(' => '(', ')' => ')', '〔' => '[', '〕' => ']', '【' => '[',   
                 '】' => ']', '〖' => '[', '〗' => ']', '“' => '[', '”' => ']',   
                 '‘' => '[', '’' => ']', '{' => '{', '}' => '}', '《' => '<',   
                 '》' => '>',   
                 '%' => '%', '+' => '+', '—' => '-', '-' => '-', '~' => '-',   
                 ':' => ':', '。' => '.', '、' => ',', ',' => '.', '、' => '.',   
                 ';' => ',', '?' => '?', '!' => '!', '…' => '-', '‖' => '|',   
                 '”' => '"', '’' => '`', '‘' => '`', '|' => '|', '〃' => '"',   
                 ' ' => ' ');   
 
    return strtr($str, $arr);   
}

另外还有一个
看起来很帅的代码
不过貌似有问题
虽然全角是转半角了
但是有部分中文字也出错了貌似。

function &StrToDBC($str,$Encode='GBK'){
 if($Encode!='UTF8')$str=mb_convert_encoding($str,'UTF-8',$Encode);
 $ret='';
 for($i=0;$s1=$str[$i],$i<strlen($str);$i++){
  if(($c=ord($s1))&0x80){
   $s2=$str[++$i];
   $s3=$str[++$i];
   $c=(($c&0xF)<<12)|((ord($s2)&0x3F)<<6)|(ord($s3)&0x3F);
   if($c==12288){
    $ret.=' ';
   }elseif($c>65280&&$c<65375){
    $c-=65248;
    $ret.=chr($c);
   }else{
    $ret.=$s1.$s2.$s3;
   }
  }else{
   $ret.=$str[$i];
  }
 }

PHP时间变成几秒前,几分前,几小时前,几天前SNS模式

星期五, 三月 19th, 2010

最近模仿UCHOME的DOING
我寸在MYSQL的时间都是unix时间。
(更多…)

php jquery ajax中文乱码

星期二, 三月 16th, 2010

PHP发送中文、Ajax接收
只需在php顶部加入一句:

header('Content-type: text/html;charset=GB2312');

xmlHttp会正确解析其中的中文。

Ajax发送中文、PHP接收
这个比较复杂:
Ajax中先用encodeURIComponent对要提交的中文进行编码
PHP中:

$view=iconv( 'UTF-8', 'gb2312//IGNORE' , $_POST['view']);

PHP使用reCAPTCHA作为验证码来保护您的网站

星期一, 三月 15th, 2010

CAPTCHA,其全称是“全自动区分计算机和人类的图灵测试”(completely automated public Turing test to tell computers and humans apart)。
现在通过使用 Google免费的reCAPTCHA服务,您可以轻松地在您自己的网站上利用这项技术。
首先
我们需要申请一个 KEY
类似于GOOGLE MAP的API KEY一样
在reCAPTCHA网站注册一个API key(免费)。并记录下你的private key和 public key。
https://admin.recaptcha.net/accounts/signup/
然后去GOOGLE CODE 下载类库
http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest

调用类

require_once('recaptchalib.php');
$publickey = "..."; // you got this from the signup page
echo recaptcha_get_html($publickey);

验证部分

require_once('recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
 
if (!$resp->is_valid) {
  die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
       "(reCAPTCHA said: " . $resp->error . ")");
}

官方还提供了一个 EXAMPLE

<html>
  <body>
    <form action="" method="post">
<?php
 
require_once('recaptchalib.php');
$publickey = "...";
$privatekey = "...";
 
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
 
# are we submitting the page?
if ($_POST["submit"]) {
  $resp = recaptcha_check_answer ($privatekey,
                                  $_SERVER["REMOTE_ADDR"],
                                  $_POST["recaptcha_challenge_field"],
                                  $_POST["recaptcha_response_field"]);
 
  if ($resp->is_valid) {
    echo "You got it!";
    # in a real application, you should send an email, create an account, etc
  } else {
    # set the error code so that we can display it. You could also use
    # die ("reCAPTCHA failed"), but using the error message is
    # more user friendly
    $error = $resp->error;
  }
}
echo recaptcha_get_html($publickey, $error);
?>
    <br/>
    <input type="submit" name="submit" value="submit" />
    </form>
  </body>
</html>

DISCUZ的中文分词for php

星期六, 一月 30th, 2010

需要用中文分词来获取TAG
找了DISCUZ的觉得不错,是在线的,不需要本地的词库

<?php    
 
//强制使用字符集    
 
@header('Content-Type: text/html; charset=gbk');    
 
$subjectenc =$_POST['subject'];
 
 
 
$messageenc = preg_replace($_POST['message']);
 
 
$data = @implode('', file("http://keyword.discuz.com/related_kw.html?title=$subjectenc&content=$messageenc&ics=gbk&ocs=gbk")); 
 
if($data) {    
 
$parser = xml_parser_create();//建立一个 XML 解析器    
 
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);    
 
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);    
 
xml_parse_into_struct($parser, $data, $values, $index);//将 XML 数据解析到数组中    
 
xml_parser_free($parser);    
 
$kws = array();    
 
foreach($values as $valuearray) {    
 
  if(in_array($valuearray['tag'],array('kw','ekw'))) {   //kw ekw是什么意思?    
 
    $kws[] = iconv('utf-8','gbk',$valuearray['value']);//编码转换    
 
   }    
 
}}    
 
//最后出来的是数组.    
 
print_r($kws);    
 
?>