2024-08-18 23:06:40 -07:00
{{define "condition"}}
< fieldset class = "fld-cndtns" >
< table >
< tr class = "field-cndtn" >
< th > Field/Condition:< / th >
< td >
< select name = "field{{.conditionNo}}" class = "sel-field" >
2024-08-19 16:34:48 -07:00
{{- range $_,$field := .fields -}}
< option value = "{{$field.Value}}" { { if eq $ field . Value $ . condition . Field } } selected { { end } } > {{$field.Text}}< / option >
{{- end -}}
2024-08-18 23:06:40 -07:00
< / select >
< / td >
< / tr >
2024-08-19 16:34:48 -07:00
< tr class = "search-cndtn" { { if not . condition . HasSearchField } } style = "display:none" { { end } } >
2024-08-18 23:06:40 -07:00
< th > Search:< / th >
< td > < input type = "text" name = "search{{.conditionNo}}" value = "{{.condition.Search}}" > < / td >
< / tr >
2024-08-24 15:37:34 -07:00
< tr class = "strmatch-cndtn" { { if not . condition . ShowStringMatchOptions } } style = "display: none" { { end } } >
< th > Match mode< / th >
< td > < select name = "matchmode{{.conditionNo}}" >
< option value = "substr" { { if eq . condition . MatchMode 0 } } selected { { end } } > Substring (case sensitive)< / option >
< option value = "substrci" { { if eq . condition . MatchMode 1 } } selected { { end } } > Substring (not case sensitive)< / option >
< option value = "regex" { { if eq . condition . MatchMode 2 } } selected { { end } } > Regular expression< / option >
< option value = "exact" { { if eq . condition . MatchMode 3 } } selected { { end } } > Exact match< / option >
< / select > < / td >
2024-08-18 23:06:40 -07:00
< / tr >
< tr class = "btns-cndtn" >
< td > < / td >
2024-08-19 16:34:48 -07:00
< td > < a href = "#" class = "rem-cndtn" > Remove condition< / a > < / td >
2024-08-18 23:06:40 -07:00
< / tr >
< / table >
< / fieldset >
{{end -}}
2024-08-26 21:47:41 -07:00
< h2 > {{with .sourcePostID -}}
New filter from post < a href = "{{webPathDir $.sourcePostBoard `res`}}{{$.sourcePostThread}}.html#{{$.sourcePostID}}" > /{{$.sourcePostBoard}}/{{$.sourcePostID}}< / a >
{{- else -}}
{{- if gt $.filter.ID 0}}Edit filter{{else}}New filter{{end -}}
{{- end}}< / h2 >
2024-08-18 23:06:40 -07:00
< form id = "filterform" action = "{{webPath `/manage/filters`}}{{if gt $.filter.ID 0}}?edit={{.ID}}{{end}}" method = "POST" >
2024-08-19 16:34:48 -07:00
{{- if gt $.filter.ID 0}}< input type = "hidden" name = "filterid" value = "{{$.filter.ID}}" > {{end -}}
2024-08-18 23:06:40 -07:00
Filter conditions are checked against a post after the IP is checked against the < a href = "{{webPath `/manage/bans`}}" > ban list< / a > .
2024-08-25 17:46:31 -07:00
The filter action will be executed only if all conditions are met. Tripcode searches do not include the prefix "!". < br / >
For information on the expected regular expression syntax, see < a href = "https://pkg.go.dev/regexp/syntax" > here< / a > (mostly the same as most regular expression implementations with a few changes, e.g. no lookahead/lookbehind).
2024-08-10 01:14:21 -07:00
< table >
< tr >
< th > Conditions< / th >
< td id = "conditions" >
2024-08-18 23:06:40 -07:00
{{- with $.filterConditions -}}
{{range $t,$condition := $.filterConditions -}}
{{template "condition" map "conditionNo" (add $t 1) "condition" $condition "fields" $.fields "filter" $.filter}}
{{end}}
{{- else -}}
{{template "condition" map "conditionNo" 1 "fields" $.fields}}
{{- end -}}
2024-08-10 01:14:21 -07:00
< / td >
2024-08-10 13:15:06 -07:00
< tr >
< td > < / td >
< td > < a href = "#" id = "add-cndtn" > Add condition< / a > < / td >
< / tr >
2024-08-10 01:14:21 -07:00
< / tr >
< tr >
< th > Action< / th >
< td >
< select name = "action" id = "action" >
2024-08-19 16:34:48 -07:00
< option value = "reject" { { if eq $ . filter . MatchAction ` reject ` } } selected { { end } } > Reject post< / option >
< option value = "ban" { { if eq $ . filter . MatchAction ` ban ` } } selected { { end } } > Ban IP< / option >
< option value = "log" { { if eq $ . filter . MatchAction ` log ` } } selected { { end } } > Log match< / option >
2024-08-10 01:14:21 -07:00
< / select >
< / td >
< / tr >
2024-09-05 18:49:20 -07:00
< tr >
< th > < / th >
< td >
2024-09-07 14:36:47 -07:00
< label for = "handleifany" title = "If checked, the filter action will activate if any of the above conditions match an incoming post. Otherwise, all conditions must match" >
< input type = "checkbox" name = "handleifany" id = "handleifany" { { if $ . filter . HandleIfAny } } checked { { end } } > Activate if any condition matches< / label > < br / >
2024-09-05 18:49:20 -07:00
< / td >
< / tr >
2024-08-10 01:14:21 -07:00
< tr >
2024-08-18 23:06:40 -07:00
< th id = "detail" > Reason< / th >
2024-08-19 16:34:48 -07:00
< td > < textarea name = "detail" rows = "5" cols = "35" > {{$.filter.MatchDetail}}< / textarea > < / td >
2024-08-18 23:06:40 -07:00
< / tr >
< tr >
< th id = "note" > Staff Note< / th >
2024-08-19 16:34:48 -07:00
< td > < textarea name = "note" rows = "5" cols = "35" > {{$.filter.StaffNote}}< / textarea > < / td >
2024-08-10 01:14:21 -07:00
< / tr >
< tr >
< th > Board(s):< / th >
< td id = "boardslist" >
2024-10-13 21:53:46 -07:00
If no boards are selected, the filter will be applied to all boards< br / >
2024-08-10 01:14:21 -07:00
{{- range $_,$board := .allBoards -}}
2024-08-19 16:34:48 -07:00
< label for = "applyboard{{$board.ID}}" > /{{$board.Dir}}/ - {{$board.Title}} < input type = "checkbox" name = "applyboard{{$board.ID}}" id = "applyboard{{$board.ID}}"
{{- range $_,$boardID := $.filterBoards -}}
{{if eq $boardID $board.ID}}checked{{end}}
{{- end}}>< / label >
2024-08-10 01:14:21 -07:00
{{- end -}}
< / td >
< / tr >
< / table >
2024-08-18 23:06:40 -07:00
< input type = "submit" name = "dofilter{{if gt $.filter.ID 0}}edit{{else}}add{{end}}" value = "Submit Filter" >
2024-08-28 21:50:39 -07:00
{{with $.cancelURL}}< input type = "button" onclick = "window.location='{{.}}'" value = "Cancel" / > {{end}}
2024-08-10 01:14:21 -07:00
< / form >
2024-08-10 13:15:06 -07:00
< hr / >
2024-08-10 01:14:21 -07:00
< h2 > Filter list< / h2 >
2024-08-11 10:47:39 -07:00
For wordfilters go < a href = "{{webPath `/manage/wordfilters`}}" > here< / a > .
2024-08-11 00:40:45 -07:00
< form action = "{{webPath `/manage/filters`}}" method = "GET" >
2024-08-11 08:40:19 -07:00
Show only filters for: < select name = "boardsearch" id = "boardsearch" >
< option value = "" > All boards< / option >
{{- range $_, $board := $.allBoards}}
< option value = "{{$board.Dir}}" { { if eq $ . boardSearch $ board . Dir } } selected { { end } } > /{{$board.Dir}}/ - {{$board.Title}}< / option >
{{- end -}}
< / select >
2024-08-11 00:40:45 -07:00
< select name = "show" id = "" >
2024-08-19 09:18:14 -07:00
< option value = "active" { { if or ( eq $ . show ` active ` ) ( eq $ . show ` ` ) } } selected { { end } } > Only active< / option >
2024-08-11 00:40:45 -07:00
< option value = "inactive" { { if eq $ . show ` inactive ` } } selected { { end } } > Only inactive< / option >
2024-08-19 09:18:14 -07:00
< option value = "all" { { if eq $ . show ` all ` } } selected { { end } } > All filters< / option >
2024-08-11 00:40:45 -07:00
< / select >
< input type = "submit" value = "Show" >
< / form >
2024-08-10 13:59:18 -07:00
< table class = "mgmt-table filterlist" >
< colgroup >
2024-08-25 16:59:25 -07:00
< col class = "filter-actions" >
2024-08-10 13:59:18 -07:00
< col class = "filter-action" >
< col class = "filter-conditions" >
2024-08-19 09:30:15 -07:00
< col class = "staff-boards" >
2024-08-11 00:40:45 -07:00
< col class = "staff-note" >
< col class = "row-staff" >
< col class = "is-active" >
2024-08-10 13:59:18 -07:00
< col class = "row-date" >
< / colgroup >
< tr >
2024-08-19 09:30:15 -07:00
< th > Actions< / th > < th > Filter action< / th > < th > Conditions< / th > < th > Boards< / th > < th > Staff note< / th > < th > Staff< / th > < th > Is active< / th > < th > Last modified< / th >
2024-08-10 13:59:18 -07:00
< / tr >
2024-08-11 00:40:45 -07:00
{{- range $f, $filter := $.filters -}}
2024-08-19 09:30:15 -07:00
{{$boardsCell := index $.filterTableBoards $f}}
2024-08-10 13:59:18 -07:00
< tr >
2024-08-25 16:59:25 -07:00
< td class = "filter-actions" >
< a href = "{{webPath `/manage/filters`}}?edit={{$filter.ID}}" > Edit< / a > |
< a href = "{{webPath `/manage/filters`}}?{{if $filter.IsActive}}disable{{else}}enable{{end}}={{$filter.ID}}" > {{if $filter.IsActive}}Disable{{else}}Enable{{end}}< / a > |
2024-09-07 15:55:34 -07:00
< a href = "{{webPathDir `/manage/filters/hits/`}}{{$filter.ID}}" > Hits ({{index $.filterHits $f}})< / a >
2024-08-25 16:59:25 -07:00
< / td >
2024-08-11 00:40:45 -07:00
< td > {{index $.actions $filter.MatchAction}}< / td >
< td > {{index $.conditions $f}}< / td >
2024-08-19 09:30:15 -07:00
< td > {{if eq $boardsCell ""}}< i > all boards< / i > {{else}}{{$boardsCell}}{{end}}< / td >
2024-08-11 00:40:45 -07:00
< td > {{$filter.StaffNote}}< / td >
< td > {{index $.staff $f}}< / td >
< td > {{$filter.IsActive}}< / td >
< td > {{formatTimestamp $filter.IssuedAt}}< / td >
2024-08-10 13:59:18 -07:00
< / tr >
2024-08-11 00:40:45 -07:00
{{- end -}}
2024-08-10 01:14:21 -07:00
< / table >