本帖最后由 gamedos 于 2009-9-21 16:44 编辑
【2009-09-21】 修改
添加了定期清除数据的方法,
修改方法:
把这个- } elseif($action == 'attachcredit') {
复制代码 if语句块换成下面的
- } elseif($action == 'attachcredit') {
- if($formhash != FORMHASH) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $aid = intval($aid);
- $attach = $db->fetch_first("SELECT tid, filename FROM {$tablepre}attachments WHERE aid='$aid'");
- $thread = $db->fetch_first("SELECT fid FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'");
- $forum = $db->fetch_first("SELECT getattachcredits FROM {$tablepre}forumfields WHERE fid='$thread[fid]'");
- $getattachcredits = $forum['getattachcredits'] ? unserialize($forum['getattachcredits']) : $creditspolicy['getattach'];
- $jm_uidlist = $db->result($db->query("SELECT uidlist FROM {$tablepre}attachments_once WHERE aid='$aid'"),0);
- $last_time = $db->result($db->query("SELECT dateline FROM {$tablepre}attachments_once WHERE aid='$aid'"),0);
- $clear_db_day = 30;//删除数据库记录的周期,单位天
- $clear_db = true;//是否定期清楚数据库的开关,值为true启用,值为false关闭
- if(empty($last_time)) $last_time = 0;
- if(empty($jm_uidlist)) $jm_uidlist = '|';
- if(strpos($jm_uidlist,$discuz_uid)>0){//check uid in uidlist
- $ck = substr(md5($aid.$timestamp.md5($authkey)), 0, 8);
- $key = md5($aid.md5($authkey).$timestamp);
- $policymsg = $p = '';
- foreach($getattachcredits as $id => $policy) {
- $policy = 0;
- $policymsg .= $p.($extcredits[$id]['img'] ? $extcredits[$id]['img'].' ' : '').$extcredits[$id]['title'].' '.$policy.' '.$extcredits[$id]['unit'];
- $p = ', ';
- }
- }else{
- checklowerlimit($getattachcredits, -1);
- $jm_uidlist .= "|$discuz_uid";
- $db->query("REPLACE INTO {$tablepre}attachments_once (aid, uidlist, dateline)
- VALUES ('$aid', '$jm_uidlist','$timestamp')");
- updatecredits($discuz_uid, $getattachcredits, -1);
-
- $ck = substr(md5($aid.$timestamp.md5($authkey)), 0, 8);
- $key = md5($aid.md5($authkey).$timestamp);
-
- $policymsgs = $p = '';
- foreach($getattachcredits as $id => $policy) {
- $policymsg .= $p.($extcredits[$id]['img'] ? $extcredits[$id]['img'].' ' : '').$extcredits[$id]['title'].' '.$policy.' '.$extcredits[$id]['unit'];
- $p = ', ';
- }
- }
- if($clear_db){
- if(($timestamp-$last_time)>($clear_db_day*86400)){
- $jm_uidlist = "|$discuz_uid";
- $db->query("UPDATE {$tablepre}attachments_once SET uidlist='$jm_uidlist',dateline='$timestamp' WHERE aid='$aid'");
- }
- }
- $sidauth = rawurlencode(authcode($sid, 'ENCODE', $authkey));
- showmessage('attachment_credit', "attachment.php?aid=$aid&k=$key&t=$timestamp&ck=$ck&sid=$sidauth", '', 1);
- }
复制代码 说明
- $clear_db_day = 30;//删除数据库记录的周期,单位天
- $clear_db = true;//是否定期清楚数据库的开关,值为true启用,值为false关闭
复制代码 这2个参数可以设置清楚数据周期和启动开关。
不会修改的朋友, 重新下载一下这个下面的附件吧。 |