View difference between Paste ID: bGg3nVSs and kWYsJxiq
SHOW: | | - or go back to the newest paste.
1
<?php
2-
class mod_adminenhance extends ModuleHelper {
2+
class mod_adminenhance{
3-
	 private $mypage;
3+
        var $mypage;
4-
	 private $ipfile = '.ht_blacklist';
4+
        var $ipfile, $imgfile, $wordfile;
5-
	 private $imgfile = '.ht_md5list';
5+
 
6-
	 private $wordfile = '.ht_wordlist';
6+
        function mod_adminenhance($PMS){
7-
7+
                $PMS->hookModuleMethod('ModulePage', __CLASS__);
8-
        public function __construct($PMS) {
8+
                $this->mypage = $PMS->getModulePageURL(__CLASS__);
9-
		parent::__construct($PMS);
9+
                $this->ipfile = '.ht_blacklist';
10-
		
10+
		$this->imgfile = '.ht_md5list';
11-
		$this->mypage = $this->getModulePageURL();
11+
                $this->wordfile = '.ht_wordlist';
12-
	}
12+
        }
13-
13+
 
14-
	public function getModuleName() {
14+
        function getModuleName(){
15-
		return $this->moduleNameBuilder('管理工具增強組合包+自改 by dbfox');
15+
                return 'mod_adminenhance : 管理工具增強組合包+自改 by dbfox';
16-
	}
16+
        }
17-
17+
 
18-
	public function getModuleVersionInfo() {
18+
        function getModuleVersionInfo(){
19-
		return '7th.Release.SP(v130305) - 整合mod_siokara強制sage功能(100626)+擋字功能(120819)';
19+
                return '5th.Release.Fin(v100318) - 整合mod_siokara強制sage功能(100626)+擋字功能(120819)';
20-
	}
20+
        }
21-
21+
 
22-
	/* 從資料檔抓出資料 */
22+
        /* 從資料檔抓出資料 */
23-
	private function _parseBlackListFile($fname, $only1st = false) {
23+
        function _parseBlackListFile($fname, $only1st=false){
24-
	    if (!is_file($fname))
24+
                if(!is_file($fname)) return array();
25-
		   return array();
25+
                $l = file($fname);
26-
		
26+
                $r = array(); $autodelno = array();
27-
		$l = file($fname);
27+
                $tmp = '';
28-
		$r = array();
28+
                $now = time();
29-
		$autodelno = array();
29+
                for($i = 0, $len = count($l); $i < $len; $i++){
30-
		$tmp = '';
30+
                        $tmp = explode("\t", rtrim($l[$i]));
31-
		$now = time();
31+
                        if(isset($tmp[3]) && $tmp[3] != '0'){ // 封鎖時段已過
32-
		for ($i = 0, $len = count($l); $i < $len; $i++) {
32+
                                if($tmp[2] + intval($tmp[3]) * 86400 < $now){
33-
			$tmp = explode("\t", rtrim($l[$i]));
33+
                                        $autodelno[] = $i;
34-
			// 封鎖時段已過
34+
                                        continue;
35-
			if (isset($tmp[3]) && $tmp[3] != '0') {
35+
                                }
36-
			        if ($tmp[2] + intval($tmp[3]) * 86400 < $now) {
36+
                        }
37-
					$autodelno[] = $i;
37+
                        $r[] = $only1st ? $tmp[0] : $tmp;
38-
					continue;
38+
                }
39-
				}
39+
                if(count($autodelno)) $this->_arrangeRecord($this->ipfile, $autodelno, ''); // 進行清除動作
40-
			}
40+
                return $r;
41-
			$r[] = $only1st ? $tmp[0] : $tmp;
41+
        }
42-
		}
42+
 
43-
		if (count($autodelno)) {
43+
        /* 重新整理記錄檔內容 (同步進行刪除及新增動作) */
44-
		// 進行清除動作
44+
        function _arrangeRecord($fname, $arrDel, $newline){
45-
		$this->_arrangeRecord($this->ipfile, $autodelno, '');
45+
                $line = is_file($fname) ? file($fname) : array();
46-
		}
46+
                if(is_array($arrDel)) foreach($arrDel as $delid) unset($line[$delid]); // 刪除
47-
		return $r;
47+
                $line = implode('', $line).$newline;
48-
	}
48+
                $fp = fopen($fname, 'w');
49-
49+
                fwrite($fp, $line);
50-
	/* 重新整理記錄檔內容 (同步進行刪除及新增動作) */
50+
                fclose($fp);
51-
	private function _arrangeRecord($fname, $arrDel, $newline) {
51+
        }
52-
		$line = is_file($fname) ? file($fname) : array();
52+
 
53-
		if (is_array($arrDel)) {
53+
        /* 在前端管理顯示 Hostname */
54-
		        foreach($arrDel as $delid)
54+
        function _showHostString(&$arrLabels, $post, $isReply){
55-
				        // 刪除
55+
                $arrLabels['{$NOW}'] .= " <u>{$post['host']}</u>";
56-
						unset($line[$delid]);
56+
        }
57-
			}			
57+
 
58-
		$line = implode('', $line).$newline;
58+
        /* 封鎖黑名單管理頁面插入CSS & JS */
59-
		$fp = fopen($fname, 'w');
59+
        function _hookHeadCSS(&$style, $isReply){
60-
		fwrite($fp, $line);
60+
                $style .= '<style type="text/css">
61-
		fclose($fp);
61+
62-
	}
62+
        height: 150px;
63-
63+
        width: 800px;
64-
	/* 在前端管理顯示 Hostname */
64+
        overflow: auto;
65-
	public function _showHostString(&$arrLabels, $post, $isReply) {
65+
        background: #e9f5ff;
66-
		$arrLabels['{$NOW}'] .= " <u>{$post['host']}</u>";
66+
        border: 1px solid #666;
67-
	}
67+
68-
68+
69-
	/* 封鎖黑名單管理頁面插入CSS & JS */
69+
70-
	public function _hookHeadCSS(&$style, $isReply) {
70+
71-
		$style .= '<style type="text/css">
71+
72
        var op = form.operate.value, ndata = form.newdata.value, nperiod = form.newperiod.value, ndesc = form.newdesc.value;
73-
	height: 150px;
73+
        $.post("'.str_replace('&amp;', '&', $this->mypage).'", {operate: op, newdata: ndata, newperiod: nperiod, newdesc: ndesc, ajax: true}, function(d){
74-
	width: 800px;
74+
                var l, lastno = (l = $("input:checkbox:last", form).get(0)) ? parseInt(l.value) + 1 : 0;
75-
	overflow: auto;
75+
                $("table", form).append(d.replace("#NO#", lastno));
76-
	background: #e9f5ff;
76+
                form.newdata.value = form.newdesc.value = "";
77-
	border: 1px solid #666;
77+
        });
78
        return false;
79
}
80
// ]]>
81
</script>
82
';
83-
	var op = form.operate.value, ndata = form.newdata.value, nperiod = form.newperiod.value, ndesc = form.newdesc.value;
83+
        }
84-
	$.post("'.str_replace('&amp;', '&', $this->getModulePageURL()).'", {operate: op, newdata: ndata, newperiod: nperiod, newdesc: ndesc, ajax: true}, function(d){
84+
 
85-
		var l, lastno = (l = $("input:checkbox:last", form).get(0)) ? parseInt(l.value) + 1 : 0;
85+
        function autoHookRegistBegin(){
86-
		$("table", form).append(d.replace("#NO#", lastno));
86+
                global $BANPATTERN, $BAD_FILEMD5, $BAD_STRING;
87-
		form.newdata.value = form.newdesc.value = "";
87+
                // 載入封鎖黑名單定義檔
88-
	});
88+
                if(is_file($this->ipfile)) $BANPATTERN = array_merge($BANPATTERN, array_map('rtrim', $this->_parseBlackListFile($this->ipfile, true)));
89-
	return false;
89+
                if(is_file($this->imgfile)) $BAD_FILEMD5 = array_merge($BAD_FILEMD5, array_map('rtrim', $this->_parseBlackListFile($this->imgfile, true)));
90
                if(is_file($this->wordfile)) $BAD_STRING = array_merge($BAD_STRING, array_map('rtrim', $this->_parseBlackListFile($this->wordfile, true)));
91
        }
92
 
93
        function autoHookAdminFunction($action, &$param, $funcLabel, &$message){
94-
	}
94+
                global $PIO, $PMS;
95-
95+
                if($action=='add'){
96-
	public function autoHookRegistBegin() {
96+
                        // Manual hook: showing hostname of users
97-
		global $BANPATTERN, $BAD_FILEMD5, $BAD_STRING;
97+
                        $PMS->hookModuleMethod('ThreadPost', array(&$this, '_showHostString'));
98-
		// 載入封鎖黑名單定義檔
98+
                        $PMS->hookModuleMethod('ThreadReply', array(&$this, '_showHostString'));
99-
		if (is_file($this->ipfile)) 
99+
 
100-
		       $BANPATTERN = array_merge($BANPATTERN, array_map('rtrim',
100+
                        $param[] = array('mod_adminenhance_thstop', 'AE: 停止/恢復討論串');
101-
   			           $this->_parseBlackListFile($this->ipfile, true)
101+
                        $param[] = array('mod_adminenhance_thsage', 'AE: 強制SAGE/恢復討論串');
102-
			   ));
102+
                        $param[] = array('mod_adminenhance_banip', 'AE: IP 加到黑名單 (鎖 Class C)');
103-
		if (is_file($this->imgfile))
103+
                        $param[] = array('mod_adminenhance_banimg', 'AE: 圖檔 MD5 加到黑名單');
104-
		       $BAD_FILEMD5 = array_merge($BAD_FILEMD5, array_map('rtrim',
104+
                        return;
105-
			           $this->_parseBlackListFile($this->imgfile, true)
105+
                }
106-
			   ));
106+
 
107-
		if (is_file($this->wordfile))
107+
                switch($funcLabel){
108-
   		       $BAD_STRING = array_merge($BAD_STRING, array_map('rtrim',
108+
                        case 'mod_adminenhance_thstop':
109-
			           $this->_parseBlackListFile($this->wordfile, true)
109+
                                $infectThreads = array();
110-
			   ));
110+
                                foreach($PIO->fetchPosts($param) as $th){
111-
	}
111+
                                        if($th['resto']) continue; // 是回應
112-
112+
                                        $infectThreads[] = $th['no'];
113-
	public function autoHookAdminFunction($action, &$param, $funcLabel, &$message) {
113+
                                        $flgh = $PIO->getPostStatus($th['status']);
114-
		if ($action=='add'){
114+
                                        $flgh->toggle('TS');
115-
			// Manual hook: showing hostname of users
115+
                                        $PIO->setPostStatus($th['no'], $flgh->toString());
116-
			$this->hookModuleMethod('ThreadPost', array(&$this, '_showHostString'));
116+
                                }
117-
			$this->hookModuleMethod('ThreadReply', array(&$this, '_showHostString'));
117+
                                $PIO->dbCommit();
118-
118+
                                $message .= '停止/恢復討論串 (No.'.implode(', ', $infectThreads).') 完成<br />';
119-
			$param[] = array('mod_adminenhance_thstop', 'AE: 停止/恢復討論串');
119+
                                break;
120-
			$param[] = array('mod_adminenhance_thsage', 'AE: 強制SAGE/恢復討論串');
120+
                        case 'mod_adminenhance_thsage':
121-
			$param[] = array('mod_adminenhance_banip', 'AE: IP 加到黑名單 (鎖 Class C)');
121+
                                $infectThreads = array();
122-
			$param[] = array('mod_adminenhance_banimg', 'AE: 圖檔 MD5 加到黑名單');
122+
                                foreach($PIO->fetchPosts($param) as $th){
123-
			return;
123+
                                        if($th['resto']) continue; // 是回應
124-
		}
124+
                                        $infectThreads[] = $th['no'];
125-
125+
                                        $flgh = $PIO->getPostStatus($th['status']);
126-
		$PIO = PMCLibrary::getPIOInstance();
126+
                                        $flgh->toggle('asage');
127-
		switch ($funcLabel) {
127+
                                        $PIO->setPostStatus($th['no'], $flgh->toString());
128-
			case 'mod_adminenhance_thstop':
128+
                                }
129-
				$infectThreads = array();
129+
                                $PIO->dbCommit();
130-
				foreach ($PIO->fetchPosts($param) as $th) {
130+
                                $message .= '強制SAGE/恢復討論串 (No.'.implode(', ', $infectThreads).') 完成<br />';
131-
					if ($th['resto']) continue; // 是回應
131+
                                break;
132-
					$infectThreads[] = $th['no'];
132+
                        case 'mod_adminenhance_banip':
133-
					$flgh = $PIO->getPostStatus($th['status']);
133+
                                $fp = fopen($this->ipfile, 'a');
134-
					$flgh->toggle('TS');
134+
                                foreach($PIO->fetchPosts($param) as $th){
135-
					$PIO->setPostStatus($th['no'], $flgh->toString());
135+
                                        if(($IPaddr = gethostbyname($th['host'])) != $th['host']) $IPaddr .= '/24';
136-
				}
136+
                                        fwrite($fp, $IPaddr."\t\t".time()."\t0\n");
137-
				$PIO->dbCommit();
137+
                                }
138-
				$message .= '停止/恢復討論串 (No.'.implode(', ', $infectThreads).') 完成<br />';
138+
                                fclose($fp);
139-
				break;
139+
                                $message .= 'IP 黑名單更新完成<br />';
140-
			case 'mod_adminenhance_thsage':
140+
                                break;
141-
				$infectThreads = array();
141+
                        case 'mod_adminenhance_banimg':
142-
				foreach ($PIO->fetchPosts($param) as $th){
142+
                                $fp = fopen($this->imgfile, 'a');
143-
					if ($th['resto']) continue; // 是回應
143+
                                foreach($PIO->fetchPosts($param) as $th){
144-
					$infectThreads[] = $th['no'];
144+
                                        if($th['md5chksum']) fwrite($fp, $th['md5chksum']."\n");
145-
					$flgh = $PIO->getPostStatus($th['status']);
145+
                                }
146-
					$flgh->toggle('asage');
146+
                                fclose($fp);
147-
					$PIO->setPostStatus($th['no'], $flgh->toString());
147+
                                $message .= '圖檔黑名單更新完成<br />';
148-
				}
148+
                                break;
149-
				$PIO->dbCommit();
149+
                        default:
150-
				$message .= '強制SAGE/恢復討論串 (No.'.implode(', ', $infectThreads).') 完成<br />';
150+
                }
151-
				break;
151+
        }
152-
			case 'mod_adminenhance_banip':
152+
       
153-
				$fp = fopen($this->ipfile, 'a');
153+
        function autoHookPostInfo(&$postinfo){
154-
				foreach ($PIO->fetchPosts($param) as $th) {
154+
                $postinfo .= "<li>本版因各種原因有鎖關鍵字,請至<a href='".$this->mypage."&amp;action=listwords' rel='_blank'>字詞黑名單一覽</a>查詢。</li>\n";
155-
					if (($IPaddr = gethostbyname($th['host'])) != $th['host'])
155+
        }
156-
					        $IPaddr .= '/24';
156+
 
157-
					fwrite($fp, $IPaddr."\t\t".time()."\t0\n");
157+
        function autoHookLinksAboveBar(&$link, $pageId, $addinfo=false){
158-
				}
158+
                if($pageId == 'admin' && $addinfo == true)
159-
				fclose($fp);
159+
                        $link .= '[<a href="'.$this->mypage.'">封鎖黑名單管理</a>]';
160-
				$message .= 'IP 黑名單更新完成<br />';
160+
        }
161-
				break;
161+
       
162-
			case 'mod_adminenhance_banimg':
162+
                function autoHookThreadPost(&$arrLabels, $post, $isReply){
163-
				$fp = fopen($this->imgfile, 'a');
163+
                global $PIO;
164-
				foreach ($PIO->fetchPosts($param) as $th) {
164+
                $fh = new FlagHelper($post['status']);
165-
					if ($th['md5chksum'])
165+
                if($fh->value('asage')) { // 強制sage
166-
					       fwrite($fp, $th['md5chksum']."\n");
166+
                        if($arrLabels['{$COM}']) $arrLabels['{$WARN_ENDREPLY}'].='<span class="warn_txt">此討論串已被強制sage,可繼續留言但不會浮上去。<br/></span>';
167-
				}
167+
                        else $arrLabels['{$WARN_ENDREPLY}'] = '<span class="warn_txt">此討論串已被強制sage,可繼續留言但不會浮上去。<br/></span>';
168-
				fclose($fp);
168+
                }
169-
				$message .= '圖檔黑名單更新完成<br />';
169+
        }
170-
				break;
170+
       
171-
			default:
171+
        function autoHookThreadReply(&$arrLabels, $post, $isReply){
172-
		}
172+
                $this->autoHookThreadPost($arrLabels, $post, $isReply);
173-
	}
173+
        }
174-
	
174+
       
175-
	public function autoHookPostInfo(&$postinfo){
175+
        function autoHookRegistBeforeCommit(&$name, &$email, &$sub, &$com, &$category, &$age, $dest, $isReply, $imgWH, &$status){
176-
	    $postinfo .= "<li>本版因各種原因有鎖關鍵字,請至<a href='".$this->getModulePageURL()."&amp;action=listwords' rel='_blank'>字詞黑名單一覽</a>查詢。</li>\n";
176+
                global $PIO;
177-
    }
177+
                $fh = new FlagHelper($status);
178-
178+
 
179-
	public function autoHookLinksAboveBar(&$link, $pageId, $addinfo = false) {
179+
                if($isReply) {
180-
		if ($pageId == 'admin' && $addinfo == true)
180+
                        $rpost = $PIO->fetchPosts($isReply); // 強制sage
181-
			$link .= '[<a href="'.$this->getModulePageURL().'">封鎖黑名單管理</a>]';
181+
                        $rfh = new FlagHelper($rpost[0]['status']);
182-
	}
182+
                        if($rfh->value('asage')) $age = false;
183-
	
183+
                }
184-
	public function autoHookThreadPost(&$arrLabels, $post, $isReply){
184+
 
185-
		$fh = new FlagHelper($post['status']);
185+
        }
186-
		if($fh->value('asage')) { // 強制sage
186+
 
187-
			if($arrLabels['{$COM}']) $arrLabels['{$WARN_ENDREPLY}'].='<span class="warn_txt">此討論串已被強制sage,可繼續留言但不會浮上去。<br/></span>';
187+
        function ModulePage(){
188-
			else $arrLabels['{$WARN_ENDREPLY}'] = '<span class="warn_txt">此討論串已被強制sage,可繼續留言但不會浮上去。<br/></span>';
188+
                global $PMS;
189-
		}
189+
               
190-
	}
190+
                if(isset($_GET['action'])) {
191-
	
191+
                        if($_GET['action'] == 'listwords') {
192-
	public function autoHookThreadReply(&$arrLabels, $post, $isReply){
192+
                                $dat = '';
193-
		$this->autoHookThreadPost($arrLabels, $post, $isReply);
193+
                                $dat .= '字詞黑名單一覽<br /><hr />';
194-
	}
194+
                                $dat .= '<table border="0" width="100%"><tr><td>Word</td><td>Description</td></tr>';
195-
	
195+
                               
196-
	public function autoHookRegistBeforeCommit(&$name, &$email, &$sub, &$com, &$category, &$age, $dest, $isReply, $imgWH, &$status){
196+
                                foreach($this->_parseBlackListFile($this->wordfile) as $i => $l){
197-
	    $PIO = PMCLibrary::getPIOInstance();
197+
                                        $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td></tr>'."\n";
198-
		$fh = new FlagHelper($status);
198+
                                }
199-
199+
                               
200-
		if($isReply) {
200+
                                $dat .= '</table>';
201-
			$rpost = $PIO->fetchPosts($isReply); // 強制sage
201+
                                echo $dat;
202-
			$rfh = new FlagHelper($rpost[0]['status']);
202+
                                return;
203-
			if($rfh->value('asage')) $age = false;
203+
                        }
204-
		}
204+
                }
205-
205+
               
206-
	}
206+
                if(!adminAuthenticate('check')) die('[Error] Access Denied.');
207-
207+
 
208-
	public function ModulePage(){
208+
                // 進行新增、刪除等動作
209-
		if(isset($_GET['action'])) {
209+
                if(isset($_POST['operate'])){
210-
			if($_GET['action'] == 'listwords') {
210+
                        $op = $_POST['operate'];
211-
				$dat = '';
211+
                        // 新增資料
212-
				$dat .= '字詞黑名單一覽<br /><hr />';
212+
                        $ndata = isset($_POST['newdata']) ? (get_magic_quotes_gpc() ? stripslashes($_POST['newdata']) : $_POST['newdata']) : ''; // 資料內容
213-
				$dat .= '<table border="0" width="100%"><tr><td>Word</td><td>Description</td></tr>';
213+
                        $nperiod = isset($_POST['newperiod']) ? intval($_POST['newperiod']) : 0; // 封鎖天數
214-
				
214+
                        $ndesc = isset($_POST['newdesc']) ? CleanStr($_POST['newdesc']) : ''; // 註解
215-
				foreach($this->_parseBlackListFile($this->wordfile) as $i => $l){
215+
                        // 刪除資料
216-
					$dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td></tr>'."\n";
216+
                        $del = isset($_POST['del']) ? $_POST['del'] : null;
217-
				}
217+
                        $newline = '';
218-
				
218+
                        $ismodified = ($ndata != '' || $del != null); // 是否需要修改檔案內容
219-
				$dat .= '</table>';
219+
                        if($ismodified){
220-
				echo $dat;
220+
                                switch($op){
221-
				return;
221+
                                        case 'ip':
222-
			}
222+
                                                $file = $this->ipfile;
223-
		}
223+
                                                if($ndata != '') $newline = $ndata."\t".$ndesc."\t".time()."\t".$nperiod."\n";
224-
		
224+
                                                break;
225-
		if(!adminAuthenticate('check')) 
225+
                                        case 'img':
226-
		        die('[Error] Access Denied.');
226+
                                                $file = $this->imgfile;
227-
227+
                                                if($ndata != '') $newline = $ndata."\t".$ndesc."\n";
228-
		// 進行新增、刪除等動作
228+
                                                break;
229-
		if (isset($_POST['operate'])) {
229+
                                        case 'word':
230-
			$op = $_POST['operate'];
230+
                                                $file = $this->wordfile;
231-
			// 新增資料
231+
                                                if($ndata != '') $newline = $ndata."\t".$ndesc."\n";
232-
			
232+
                                                break;
233-
			// 資料內容
233+
                                }
234-
			$ndata = isset($_POST['newdata']) ? 
234+
                                $this->_arrangeRecord($file, $del, $newline); // 同步進行刪除及更新
235-
			(get_magic_quotes_gpc() ? stripslashes($_POST['newdata']) : 
235+
                        }
236-
		            $_POST['newdata']) : ''; 
236+
                        if(isset($_POST['ajax'])){ // AJAX 要求在此即停止,一般要求則繼續印出頁面
237-
			// 封鎖天數		
237+
                                $extend = ($op=='ip') ? '<td>'.date('Y/m/d H:m:s', time())." ($nperiod)</td>" : ''; // IP黑名單資訊比圖檔多
238-
			$nperiod = isset($_POST['newperiod']) ? intval($_POST['newperiod']) : 0;
238+
                                echo '<tr><td>'.htmlspecialchars($ndata).'</td><td>'.$ndesc.'</td>'.$extend.'<td><input type="checkbox" name="del[]" value="#NO#" /></td></tr>';
239-
			 // 註解
239+
                                return;
240-
			$ndesc = isset($_POST['newdesc']) ? CleanStr($_POST['newdesc']) : '';
240+
                        }
241-
			// 刪除資料
241+
                }
242-
			$del = isset($_POST['del']) ? $_POST['del'] : null;
242+
 
243-
			$newline = '';
243+
                $dat = '';
244-
			// 是否需要修改檔案內容
244+
                $PMS->hookModuleMethod('Head', array(&$this, '_hookHeadCSS'));
245-
			$ismodified = ($ndata != '' || $del != null);
245+
                head($dat);
246-
			if ($ismodified) {
246+
                $dat .= '<div class="bar_admin">封鎖黑名單管理</div>
247-
				switch ($op) {
247+
248-
					case 'ip':
248+
<form action="'.$this->mypage.'" method="post">
249-
						$file = $this->ipfile;
249+
250-
						if($ndata != '')
250+
251-
						       $newline = $ndata."\t".$ndesc."\t".time()."\t".$nperiod."\n";
251+
252-
						break;
252+
253-
					case 'img':
253+
254-
						$file = $this->imgfile;
254+
255-
						if($ndata != '')
255+
256-
						       $newline = $ndata."\t".$ndesc."\n";
256+
257-
						break;
257+
258-
					case 'word':
258+
259-
						$file = $this->wordfile;
259+
                foreach($this->_parseBlackListFile($this->ipfile) as $i => $l){
260-
						if($ndata != '')
260+
                        $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td>'.
261-
						       $newline = $ndata."\t".$ndesc."\n";
261+
                        '<td>'.(isset($l[2]) ? date('Y/m/d H:m:s', $l[2]) : '-').(isset($l[3]) ? ' ('.$l[3].')' : ' (0)').'</td>'.
262-
						break;
262+
                        '<td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
263-
				}
263+
                }
264-
				 // 同步進行刪除及更新
264+
                $dat .= '</table>
265-
				$this->_arrangeRecord($file, $del, $newline);
265+
266-
			}
266+
267-
			// AJAX 要求在此即停止,一般要求則繼續印出頁面
267+
268-
			if (isset($_POST['ajax'])) {
268+
269-
			    // IP黑名單資訊比圖檔多
269+
 
270-
				$extend = ($op=='ip') ?
270+
<form action="'.$this->mypage.'" method="post">
271-
				        '<td>'.date('Y/m/d H:m:s', time())." ($nperiod)</td>" : '';
271+
272-
				echo '<tr><td>'.htmlspecialchars($ndata).'</td><td>'.$ndesc.
272+
273-
				        '</td>'.$extend.'<td><input type="checkbox" name="del[]" value="#NO#" /></td></tr>';
273+
274-
				return;
274+
275-
			}
275+
276-
		}
276+
277-
277+
278-
		$dat = '';
278+
279-
		$this->hookModuleMethod('Head', array(&$this, '_hookHeadCSS'));
279+
280-
		head($dat);
280+
281-
		$dat .= '<div class="bar_admin">封鎖黑名單管理</div>
281+
                foreach($this->_parseBlackListFile($this->imgfile) as $i => $l){
282
                        $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td><td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
283-
<form action="'.$this->getModulePageURL().'" method="post">
283+
                }
284
                $dat .= '</table>
285
</div>
286
<input type="submit" value="刪除" />
287
</div>
288
</form>
289
 
290
<form action="'.$this->mypage.'" method="post">
291
<div id="wordconfig"><input type="hidden" name="operate" value="word" />
292
字詞黑名單<br />
293
Word: <input type="text" name="newdata" size="100" />
294-
		foreach ($this->_parseBlackListFile($this->ipfile) as $i => $l) {
294+
295-
			$dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td>'.
295+
296-
			'<td>'.(isset($l[2]) ? date('Y/m/d H:m:s', $l[2]) : '-').(isset($l[3]) ? ' ('.$l[3].')' : ' (0)').'</td>'.
296+
297-
			'<td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
297+
298-
		}
298+
299-
		$dat .= '</table>
299+
300
                foreach($this->_parseBlackListFile($this->wordfile) as $i => $l){
301
                        $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.(isset($l[1]) ? $l[1] : '').'</td><td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
302
                }
303
                $dat .= '</table>
304-
304+
305-
<form action="'.$this->getModulePageURL().'" method="post">
305+
306
</div>
307
</form>
308
 
309
<hr />
310
<div id="help"><pre>
311
說明
312
 
313
Pattern:
314
 
315
可封鎖特定IP/Hostname發文。以使用者的IP位置或Host名稱進行判斷,所以兩種形式都可以使用。
316-
		foreach ($this->_parseBlackListFile($this->imgfile) as $i => $l) {
316+
317-
			    $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.
317+
318-
				        (isset($l[1]) ? $l[1] : '').'</td><td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
318+
 
319-
		}
319+
320-
		$dat .= '</table>
320+
321
範例:
322
127.0.0.1 (127.0.0.1 O;127.0.0.2 X)
323
localhost (localhost O;local X)
324
 
325-
325+
326-
<form action="'.$this->getModulePageURL().'" method="post">
326+
327
範例:
328
192.168.0.* (192.168.0.3 O;192.168.1.3 X)
329
local* (localhost O;remotehost X)
330
 
331
- 正規表達式
332
使用Regular Expression來進行匹配,可作出更多樣、更適合的條件。注意使用時需要使用 / 斜線將表達式括住。
333
範例:
334
/127\.0\.0\.[0-9]{2}/ (127.0.0.28 O;127.0.0.1 X)
335
/^.+\.proxy\.com$/ (gate1.proxy.com O;proxy2.com.tw X)
336-
		foreach ($this->_parseBlackListFile($this->wordfile) as $i => $l){
336+
 
337-
			    $dat .= '<tr><td>'.htmlspecialchars($l[0]).'</td><td>'.
337+
338-
				        (isset($l[1]) ? $l[1] : '').'</td><td><input type="checkbox" name="del[]" value="'.$i.'" /></td></tr>'."\n";
338+
339-
		}
339+
340-
		$dat .= '</table>
340+
341
 
342
Period:
343
 
344
設定封鎖期限,在過期時可以自動刪除解鎖,以天為單位。如果想永久封鎖 (系統不自動回收,需手動解鎖) 則將此值設為 0 (0 表示無期限)。
345-
345+
 
346
Banword:
347
 
348
可封鎖特定字詞發文,只支援以下一種格式:
349-
349+
 
350
- 完全相符
351-
351+
352
範例:
353
果然棒 (果然棒123 O;果然...棒 X)
354
活佛 (信活佛 O;活-佛 X)
355-
355+
356
</div>
357
</div>';
358
                foot($dat);
359
                echo $dat;
360
        }
361-
361+
362
 
363
?>