hbbs

[archived] bbs.hlirc.net
git clone https://hhvn.uk/hbbs
git clone git://hhvn.uk/hbbs
Log | Files | Refs | README | LICENSE

permissions.sh (1467B)


      1 #!/bin/sh
      2 
      3 check_post_perm(){
      4 	local board="$1"
      5 	local user="$2"
      6 
      7 	[ "$(get_log_time "post-throttle" | grep "^$(date +%H:)" | awk '{print $2}' | grep "^$user$")" != "" ] && {
      8 		[ "$3" != "noprint" ] && error "you have been throttled due to sending $post_limit posts/replies/messages in a minute"
      9 		return 1
     10 	}
     11 
     12 	local whitelist="$(eval "echo \$board_${board}_post_whitelist")"
     13 	[ "$whitelist" = "" ] && return
     14 
     15 	for u in $whitelist
     16 	do
     17 		[ "$u" = "$user" ] && return
     18 	done
     19 
     20 	# this point shouldn't be reached if user has perms
     21 	[ "$3" != "noprint" ] && error "no permission to post new threads on this board"
     22 	return 1
     23 }
     24 
     25 check_reply_perm(){
     26 	local board="$1"
     27 	local user="$2"
     28 
     29 	[ "$(get_log_time "post-throttle" | grep "^$(date +%H:)" | awk '{print $2}' | grep "^$user$")" != "" ] && {
     30 		[ "$3" != "noprint" ] && error "you have been throttled due to sending $post_limit posts/replies/messages in a minute"
     31 		return 1
     32 	}
     33 
     34 	local whitelist="$(eval "echo \$board_${board}_reply_whitelist")"
     35 	[ "$whitelist" = "" ] && return
     36 
     37 	for u in $whitelist
     38 	do
     39 		[ "$u" = "$user" ] && return
     40 	done
     41 
     42 	# this point shouldn't be reached if user has perms
     43 	[ "$3" != "noprint" ] && error "no permission to post replies to this board"
     44 	return 1
     45 }
     46 
     47 check_post_throttle(){
     48 	[ $(get_log_time "post" | grep "^$(date +%H:%M)" | awk '{print $2}' | grep "^$1$" | wc -l) -eq $post_limit ] && \
     49 		error "you have been throttled due to sending $post_limit posts/replies/messages in a minute"
     50 }