Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.01 KB | None | 0 0
  1. #!/bin/bash
  2. VER=2.15.1
  3.  
  4. #-[ Script Start ]----------------------------------------------#
  5. # #
  6. # No changes below here unless you want to change some text. #
  7. # #
  8. #---------------------------------------------------------------#
  9.  
  10. ## Read config
  11. if [ -z $config ]; then
  12. config="`dirname $0`/tur-request.conf"
  13. fi
  14. if [ ! -r $config ]; then
  15. echo "Error. Can not read $config"
  16. exit 0
  17. else
  18. . $config
  19. fi
  20.  
  21. if [ -z "$datebin" ]; then
  22. datebin="date"
  23. fi
  24.  
  25. ## Check if we're in glftpd or shell (irc)..
  26. if [ "$FLAGS" ]; then
  27. mode=gl
  28. HOWTOFILL='site reqfilled <number or name>'
  29. if [ "$DONT_SHOW_STATUSANNOUNCE_FROM_GL" = "TRUE" ]; then
  30. unset STATUSANNOUNCE
  31. fi
  32. username="$USER"
  33. BY="$username"
  34. arg1="$1"
  35. else
  36. mode=irc
  37. requests=$glroot$requests
  38. reqfile=$glroot$reqfile
  39. tmp=$glroot$tmp
  40. tuls=$glroot$tuls
  41. passwd=$glroot$passwd
  42. passchk=$glroot$passchk
  43. if [ "$msgsdir" ]; then
  44. msgsdir=$glroot$msgsdir
  45. fi
  46. if [ "$usersdir" ]; then
  47. usersdir="$glroot$usersdir"
  48. fi
  49. if [ "$gllog" ]; then
  50. gllog=$glroot$gllog
  51. fi
  52. if [ "$log" ]; then
  53. log="$glroot$log"
  54. fi
  55. HOWTOFILL='!reqfilled <number or name>'
  56. fi
  57.  
  58. if [ "$filled_dir" ]; then
  59. if [ ! -d "${requests}/${filled_dir}" ]; then
  60. echo "Error: filled_dir (${requests}/${filled_dir}) does not exist."
  61. exit 0
  62. fi
  63.  
  64. filled_dir="$filled_dir/"
  65. fi
  66.  
  67. proc_mainerror() {
  68. echo "Got neither request, reqfilled, reqwipe, status, fix or checkold... quitting."
  69. exit 0
  70. }
  71.  
  72. if [ -z "$1" ]; then
  73. proc_mainerror
  74. fi
  75.  
  76. ## Procedure for logging
  77. proc_log() {
  78. if [ "$log" ]; then
  79. if [ -w "$log" ]; then
  80. echo `$datebin "+%a %b %e %T %Y"` "$@" >> $log
  81. else
  82. if [ "$USER" = "root" ]; then
  83. touch $log
  84. if [ -x "chmod" ]; then
  85. chmod 666 $log
  86. fi
  87. else
  88. logname=`basename $log`
  89. echo "Error: Can not write to $logname. Create and set chmod 666."
  90. fi
  91. fi
  92. fi
  93. }
  94.  
  95. ## Heres where we change those %blabla% into real text.
  96. proc_cookies() {
  97. if [ "$BY" ]; then
  98. OUTPUT=`echo $OUTPUT | sed -e "s/%WHO%/$BY/g"`
  99. fi
  100. if [ "$WHAT" ]; then
  101. OUTPUT=`echo $OUTPUT | sed -e "s/%WHAT%/$WHAT/g"`
  102. fi
  103. if [ "$ACTION" ]; then
  104. OUTPUT=`echo $OUTPUT | sed -e "s/%ACTION%/$ACTION/g"`
  105. fi
  106. if [ "$RELEASE" ]; then
  107. OUTPUT=`echo $OUTPUT | sed -e "s/%RELEASE%/$RELEASE/g"`
  108. fi
  109. if [ "$mode" ]; then
  110. OUTPUT=`echo $OUTPUT | sed -e "s/%MODE%/$mode/g"`
  111. fi
  112. if [ "$name" ]; then
  113. OUTPUT=`echo $OUTPUT | sed -e "s/%NAME%/$name/g"`
  114. fi
  115. if [ "$adddate" ]; then
  116. OUTPUT=`echo $OUTPUT | sed -e "s/%ADDDATE%/$adddate/g"`
  117. fi
  118. if [ "$requesthead" ]; then
  119. OUTPUT=`echo $OUTPUT | sed -e "s/%REQUESTHEAD%/"$requesthead"/g"`
  120. fi
  121. if [ "$filledhead" ]; then
  122. OUTPUT=`echo $OUTPUT | sed -e "s/%FILLEDHEAD%/$filledhead/g"`
  123. fi
  124. if [ "$HOWTOFILL" ]; then
  125. OUTPUT=`echo $OUTPUT | sed -e "s/%HOWTOFILL%/$HOWTOFILL/g"`
  126. fi
  127. if [ "$sitename" ]; then
  128. OUTPUT=`echo $OUTPUT | sed -e "s/%SITENAME%/$sitename/g"`
  129. fi
  130. if [ "$FOR" ]; then
  131. OUTPUT=`echo $OUTPUT | sed -e "s/%FOR%/$FOR/g"`
  132. fi
  133. if [ "$num" ]; then
  134. OUTPUT=`echo $OUTPUT | sed -e "s/%NUM%/$num/g"`
  135. fi
  136. if [ "$REWARD" ]; then
  137. OUTPUT=`echo $OUTPUT | sed -e "s/%REWARD%/$REWARD/g"`
  138. fi
  139. ## Uses = when creating list. Will be replaced by / after the sed (sed dont like /).
  140. if [ "$REWARD_LIST" ]; then
  141. OUTPUT=`echo $OUTPUT | sed -e "s/%REWARDLIST%/$REWARD_LIST/g" | tr '=' '/'`
  142. fi
  143. if [ "$total_files" ]; then
  144. OUTPUT=`echo $OUTPUT | sed -e "s/%REWARD_FILES%/$total_files/g"`
  145. fi
  146. if [ "$total_files" ]; then
  147. OUTPUT=`echo $OUTPUT | sed -e "s/%REWARD_FILES%/$total_files/g"`
  148. fi
  149. if [ "$total_users" ]; then
  150. OUTPUT=`echo $OUTPUT | sed -e "s/%REWARD_USERS%/$total_users/g"`
  151. fi
  152. if [ "$IRCOUTPUT" = "TRUE" -o "$AUTO" = "TRUE" ]; then
  153. OUTPUT=`echo $OUTPUT | sed -e "s/%BOLD%//g"`
  154. OUTPUT=`echo $OUTPUT | sed -e "s/%ULINE%//g"`
  155. else
  156. OUTPUT=`echo $OUTPUT | sed -e "s/%BOLD%//g"`
  157. OUTPUT=`echo $OUTPUT | sed -e "s/%ULINE%//g"`
  158. fi
  159. }
  160.  
  161. ## This is used for a few function to change config settings with spaces so we can egrep em.
  162. ## Example: Setting="ost ost2" -> "^ost$|^ost2$"
  163. ## Needs FIX_LIST as input and returns FIXED_LIST
  164. proc_make_egrep_list() {
  165. for temp_each in $FIX_LIST; do
  166. if [ "$temp_fixed_list" ]; then
  167. temp_fixed_list="$temp_fixed_list|^${temp_each}$"
  168. else
  169. temp_fixed_list="^${temp_each}$"
  170. fi
  171. done
  172. FIXED_LIST="$temp_fixed_list"
  173. unset temp_fixed_list; unset temp_each; unset FIX_LIST
  174. }
  175.  
  176. if [ -z "$tuls" ] && [ "$enable_rewardsystem" = "TRUE" ]; then
  177. echo "ERROR. You have enable_rewardsystem=TRUE but tuls= is not defined."
  178. exit 0
  179. fi
  180. if [ "$enable_rewardsystem" = "TRUE" ] && [ "$do_not_create_dir_until_filled" = "TRUE" ]; then
  181. echo "ERROR. You have enable_rewardsystem=TRUE AND do_not_create_dir_until_filled=TRUE"
  182. echo "This will not work"
  183. exit 0
  184. fi
  185.  
  186. ## Get all arguments into RAWSTRING.
  187. RAWSTRING="`echo "$@" | tr -d '\]' | tr -d '\[' | tr -d '\|' | tr -d '^'`"
  188.  
  189. ## Make initial check. Cant include a /
  190. if [ "$( echo "$RAWSTRING" | grep "\/" )" ]; then
  191. if [ "$mode" = "irc" ]; then
  192. IRCOUTPUT="TRUE"
  193. fi
  194.  
  195. OUTPUT="$NONSTANDARDCHAR"
  196. proc_cookies
  197. echo "$OUTPUT"
  198. exit 0
  199. fi
  200.  
  201. if [ "$mode" = "irc" -a "$1" != "checkold" ]; then
  202. ## If from irc, cut out second word to BY. This is who its from.
  203. BY=`echo "$RAWSTRING" | cut -d ' ' -f2`
  204. ## Remove that one when done.
  205. RAWSTRING=`echo "$RAWSTRING" | sed -e "s/$BY//" | tr -s ' '`
  206. fi
  207.  
  208. ## Check first word. This is the action to take (request, reqfilled etc).
  209. RUN=`echo "$RAWSTRING" | cut -d' ' -f1`
  210. ## Remove run command from RAWSTRING.
  211. RAWSTRING=`echo "$RAWSTRING" | sed -e "s/^$RUN//"`
  212. ## Make it lowercase
  213. RUN="`echo "$RUN" | tr '[:upper:]' '[:lower:]'`"
  214. ## Clear up RAWSTRING from leftover spaces.
  215. RAWSTRING=`echo $RAWSTRING`
  216.  
  217. if [ "$RAWSTRING" = "$RUN" -a "$RUN" = "request" -o "$RAWSTRING" = "" -a "$RUN" = "request" ]; then
  218. if [ "$mode" = "irc" ]; then
  219. if [ "$AUTH_SYSTEM" = "TRUE" ]; then
  220. echo "Usage: /msg botnick !request <username> <password> <request> (-hide) (-for:<username>)"
  221. else
  222. echo "Usage: /msg botnick !request <request> (-hide) (-for:<username>)"
  223. fi
  224. echo "-hide is used to not announce to chan."
  225. echo "-for:<username> is used to specify who the request is for."
  226. else
  227. echo "Usage: site request <request> (-hide) (-for:<username>)"
  228. echo "-hide is used to not announce to chan."
  229. echo "-for:<username> is used to specify who the request is for."
  230. fi
  231. exit 0
  232. fi
  233.  
  234. ## If this is a request, reqdel or reqwipe and we are running from irc, check the username and password.
  235. if [ "$AUTH_SYSTEM" = "TRUE" ]; then
  236. if [ "`echo "$RUN" | egrep "^request$|^reqdel$|^reqwipe$"`" ] && [ "$mode" = "irc" ]; then
  237. username="`echo "$RAWSTRING" | cut -d ' ' -f1`"
  238. userpass="`echo "$RAWSTRING" | cut -d ' ' -f2`"
  239. RAWSTRING="`echo "$RAWSTRING" | cut -d ' ' -f3-`"
  240. if [ "`$passchk "$username" "$userpass" "$passwd"`" != "$passchk_ok" ]; then
  241. echo "Wrong username or password. Use !$1 <username> <password> <request>"
  242. exit 0
  243. fi
  244. ## Use this BY instead of the irc nick to get correct name in .requests file, etc.
  245. BY="$username"
  246. arg1="$1"
  247. fi
  248.  
  249. ## If this is a request, make sure the user has access to run it.
  250. if [ "$RUN" = "request" ]; then
  251. if [ "$request_allowed_flags" ] || [ "$request_allowed_users" ]; then
  252. ALLOWED_TO_REQUEST="FALSE"
  253.  
  254. ## Allowed by flag?
  255. if [ "$request_allowed_flags" ]; then
  256. request_allowed_flags="`echo "$request_allowed_flags" | tr -s ' ' '|'`"
  257. if [ "`grep "^FLAGS " "$usersdir/$username" | cut -d ' ' -f2 | egrep "$request_allowed_flags"`" ]; then
  258. ALLOWED_TO_REQUEST="TRUE"
  259. fi
  260. fi
  261.  
  262. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  263. ## Allowed by user?
  264. if [ "$request_allowed_users" ]; then
  265. FIX_LIST="$request_allowed_users"
  266. proc_make_egrep_list
  267. request_allowed_users="$FIXED_LIST"; unset FIXED_LIST
  268.  
  269. ## Check if username matches.
  270. if [ "`echo "$username" | egrep "$request_allowed_users"`" ]; then
  271. ALLOWED_TO_REQUEST="TRUE"
  272. fi
  273. fi
  274.  
  275. ## No access ?
  276. if [ "$ALLOWED_TO_REQUEST" != "TRUE" ]; then
  277. echo "You do not have access to do new requests."
  278. exit 0
  279. fi
  280. fi
  281. fi
  282. else
  283. ## Disable rewardsystem if AUTH_SYSTEM=FALSE
  284. enable_rewardsystem="FALSE"
  285. fi
  286.  
  287. ## Check if -hide is in RAWSTRING. If so, remove it and set HIDE=TRUE
  288. if [ "`echo "$RAWSTRING" | grep -w "\-hide"`" ]; then
  289. HIDE=TRUE
  290. RAWSTRING=`echo "$RAWSTRING" | sed -e "s/\-hide//"`
  291. else
  292. HIDE=FALSE
  293. fi
  294.  
  295. ## Check if -reward is in RAWSTRING. If so, remove it and set REWARD=amount
  296. ## Only if its a request.
  297. if [ "$RUN" = "request" ] && [ "`echo "$RAWSTRING" | grep " \-reward\:"`" ]; then
  298. if [ "$enable_rewardsystem" != "TRUE" ]; then
  299. echo "Error: -reward: is not enabled."
  300. exit 0
  301. fi
  302.  
  303. ## Check if the user has access to the reward system.
  304. ## If no security is set, automatically allow it. Otherwise, disallow it by
  305. ## default. If its not allowed, it will run the checks further down to enable it.
  306. if [ "$reward_allowed_users" ] || [ "$reward_allowed_flags" ]; then
  307. REWARD_ACCESS="FALSE"
  308. else
  309. REWARD_ACCESS="TRUE"
  310. fi
  311.  
  312. ## Allowed by flag?
  313. if [ "$reward_allowed_flags" ]; then
  314. reward_allowed_flags="`echo "$reward_allowed_flags" | tr -s ' ' '|'`"
  315. if [ "`grep "^FLAGS " "$usersdir/$username" | cut -d ' ' -f2 | egrep "$reward_allowed_flags"`" ]; then
  316. REWARD_ACCESS="TRUE"
  317. fi
  318. fi
  319.  
  320. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  321. ## Allowed by user?
  322. if [ "$reward_allowed_users" ]; then
  323. FIX_LIST="$reward_allowed_users"
  324. proc_make_egrep_list
  325. reward_allowed_users="$FIXED_LIST"; unset FIXED_LIST
  326.  
  327. ## Check if username matches.
  328. if [ "`echo "$username" | egrep "$reward_allowed_users"`" ]; then
  329. REWARD_ACCESS="TRUE"
  330. fi
  331. fi
  332.  
  333. ## No access ?
  334. if [ "$REWARD_ACCESS" != "TRUE" ]; then
  335. echo "You do not have access to use -reward:"
  336. exit 0
  337. fi
  338.  
  339. REWARD_FREE="FALSE"
  340.  
  341. ## No decuction when using -reward:? Check by flag.
  342. if [ "$reward_free_flags" ]; then
  343. reward_free_flags="`echo "$reward_free_flags" | tr -s ' ' '|'`"
  344. if [ "`grep "^FLAGS " "$usersdir/$username" | cut -d ' ' -f2 | egrep "$reward_free_flags"`" ]; then
  345. REWARD_FREE="TRUE"
  346. fi
  347. fi
  348.  
  349. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  350. ## No decuction when using -reward:? Check by username
  351. if [ "$reward_free_users" ]; then
  352. FIX_LIST="$reward_free_users"
  353. proc_make_egrep_list
  354. reward_free_users="$FIXED_LIST"; unset FIXED_LIST
  355.  
  356. ## Check if username matches.
  357. if [ "`echo "$username" | egrep "$reward_free_users"`" ]; then
  358. REWARD_FREE="TRUE"
  359. fi
  360. fi
  361.  
  362. ## Keep going.
  363. for crap in $RAWSTRING; do
  364. if [ "$( echo "$crap" | grep '\-reward\:' )" ]; then
  365. REWARD=`echo $crap | cut -d ':' -f2`
  366. break
  367. fi
  368. done
  369.  
  370. if [ -z "$REWARD" ]; then
  371. echo "You used -reward: but no amount of credits specified that will be rewarded."
  372. exit 0
  373. elif [ "`echo "$REWARD" | tr -d '[:digit:]'`" ]; then
  374. echo "Error. Only use pure MB number in the reward amount."
  375. exit 0
  376. fi
  377.  
  378. if [ "$REWARD_FREE" != "TRUE" ]; then
  379. current_credits_kb="`grep "^CREDITS " "$usersdir/$username" | cut -d ' ' -f2`"
  380. current_credits_mb=$[$current_credits_kb/1024]
  381. if [ -z "$current_credits_mb" ]; then
  382. echo "Internal error. Did not manage to read current credits for $username."
  383. echo "Debug: current_credits_kb: $current_credits_kb"
  384. echo "Debug: current_credits_mb: $current_credits_mb"
  385. exit 0
  386. fi
  387.  
  388. if [ "$current_credits_mb" -lt "$REWARD" ]; then
  389. echo "You do not have ${REWARD}MB credits. Only ${current_credits_mb}MB."
  390. exit 0
  391. fi
  392. fi
  393.  
  394. RAWSTRING=`echo "$RAWSTRING" | sed -e "s/\-reward:$REWARD//"`
  395.  
  396. else
  397. unset REWARD
  398. fi
  399.  
  400. ## Clear up RAWSTRING from start and ending spaces.
  401. RAWSTRING=`echo $RAWSTRING`
  402.  
  403. ## Check if -for: is in RAWSTRING. If so, cut it out and check who its for.
  404. ## Only if its a request.
  405. unset FOR; unset FORLAST
  406.  
  407. if [ "$RUN" = "request" ] && [ "$( echo "$RAWSTRING" | grep '\-for\:' )" ]; then
  408. for crap in $RAWSTRING; do
  409. if [ "$( echo "$crap" | grep '\-for\:' )" ]; then
  410. FOR=`echo $crap | cut -d ':' -f2`
  411. FOR="$BY"
  412. break
  413. fi
  414. done
  415.  
  416. ## Check that FOR isnt empty.
  417. if [ -z "$FOR" ]; then
  418. echo "When using '-for:' then specify a user who its for too."
  419. exit 0
  420. fi
  421.  
  422. RAWSTRING=`echo "$RAWSTRING" | sed -e "s/\-for:$FOR//"`
  423.  
  424. unset FORLAST
  425. fi
  426.  
  427. ## Clear up RAWSTRING again
  428. RAWSTRING=`echo $RAWSTRING`
  429.  
  430. ## DEBUG VALUES. Remove below #'s to only get debug output.
  431. # echo "full : <$@>"
  432. # echo "by : <$BY>"
  433. # echo "action: <$RUN>"
  434. # echo "hide : <$HIDE>"
  435. # echo "for : <$FOR>"
  436. # echo "rel : <$RAWSTRING>"
  437. # echo "reward: <$REWARD>"
  438. # exit 0
  439.  
  440. ## Set request to $WHAT from $RAWSTRING and clear RAWSTRING
  441. WHAT="$RAWSTRING"; unset RAWSTRING
  442.  
  443. ## If this is a reqwipe, make sure the user has access to to that.
  444. if [ "$AUTH_SYSTEM" = "TRUE" ]; then
  445. if [ "$RUN" = "reqwipe" ] && [ "$mode" = "irc" ]; then
  446. ## Set default = no access.
  447. ALLOWED_REQWIPE="FALSE"
  448.  
  449. ## Remake flags. put a | in between. See if they match a userflag.
  450. if [ "$reqwipe_access_flags" ]; then
  451. reqwipe_access_flags="`echo "$reqwipe_access_flags" | tr -s ' ' '|'`"
  452. if [ "`grep "^FLAGS " "$usersdir/$username" | cut -d ' ' -f2 | egrep "$reqwipe_access_flags"`" ]; then
  453. ALLOWED_REQWIPE="TRUE"
  454. fi
  455. fi
  456.  
  457. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  458. if [ "$reqwipe_access_users" ]; then
  459. FIX_LIST="$reqwipe_access_users"
  460. proc_make_egrep_list
  461. reqwipe_access_users="$FIXED_LIST"; unset FIXED_LIST
  462.  
  463. ## Check if username matches.
  464. if [ "`echo "$username" | egrep "$reqwipe_access_users"`" ]; then
  465. ALLOWED_REQWIPE="TRUE"
  466. fi
  467. fi
  468.  
  469. ## Check if its still not allowed. Exit if not.
  470. if [ "$ALLOWED_REQWIPE" = "FALSE" ]; then
  471. echo "You dont have reqwipe access."
  472. exit 0
  473. fi
  474. arg1="$1"
  475. fi
  476.  
  477. ## Check if max number of requests are set. Check it otherwise.
  478. if [ "$RUN" = "request" ] && [ "$max_requests_per_user" ]; then
  479. MAX_REQS_EXCLUDED="FALSE"
  480.  
  481. ## Remake flags. put a | in between. See if they match a userflag.
  482. if [ "$max_requests_ignore_flags" ]; then
  483. max_requests_ignore_flags="`echo "$max_requests_ignore_flags" | tr -s ' ' '|'`"
  484. if [ "`grep "^FLAGS " "$usersdir/$username" | cut -d ' ' -f2 | egrep "$max_requests_ignore_flags"`" ]; then
  485. MAX_REQS_EXCLUDED="TRUE"
  486. fi
  487. fi
  488.  
  489. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  490. if [ "$max_requests_ignore_users" ]; then
  491. for temp_each in $max_requests_ignore_users; do
  492. if [ "$temp_access_users" ]; then
  493. temp_access_users="$temp_access_users|^${temp_each}$"
  494. else
  495. temp_access_users="^${temp_each}$"
  496. fi
  497. done
  498. max_requests_ignore_users="$temp_access_users"
  499. unset temp_access_users
  500.  
  501. ## Check if username matches.
  502. if [ "`echo "$username" | egrep "$max_requests_ignore_users"`" ]; then
  503. MAX_REQS_EXCLUDED="TRUE"
  504. fi
  505. fi
  506.  
  507. if [ "$MAX_REQS_EXCLUDED" = "FALSE" ]; then
  508. user_requests="0"
  509. for rawdata in `cat $reqfile | tr ' ' '~'`; do
  510. if [ "`echo "$rawdata" | grep "by~${username}~("`" ]; then
  511. user_requests=$[$user_requests+1]
  512. fi
  513. done
  514. # echo "Current requests by $username: $user_requests"
  515. if [ "$user_requests" -ge "$max_requests_per_user" ]; then
  516. echo "Sorry, you are only allowed to make $max_requests_per_user requests. You currently have $user_requests requests."
  517. exit 0
  518. fi
  519. fi
  520. fi
  521. fi
  522.  
  523. ## Check if allowspace is FALSE.
  524. if [ "$allowspace" = "FALSE" ]; then
  525. ## If it was, check if theres a space in $WHAT
  526. if [ "$( echo "$WHAT" | grep ' ' )" ]; then
  527. ## If there was a space, check if replacewith is set.
  528. if [ "$replacewith" ]; then
  529. ## If it was, replace all spaces with it.
  530. WHAT=`echo "$WHAT" | tr ' ' "$replacewith"`
  531. else
  532. ## If replacewith is empty, say the NOSPACES error.
  533. if [ "$mode" = "irc" ]; then
  534. IRCOUTPUT="TRUE"
  535. fi
  536.  
  537. OUTPUT="$NOSPACES"
  538. proc_cookies
  539. echo "$OUTPUT"
  540. exit 0
  541. fi
  542. fi
  543. fi
  544.  
  545. ## Verify that $WHAT is set etc. If no argument is given...
  546. proc_verify() {
  547.  
  548. ## Check that $WHAT does not include bad chars..."
  549. if [ "$( echo "$WHAT" | egrep "$badchars" )" ]; then
  550. if [ "$mode" = "irc" ]; then
  551. IRCOUTPUT="TRUE"
  552. fi
  553. OUTPUT="$NONSTANDARDCHAR"
  554. proc_cookies
  555. echo "$OUTPUT"
  556. exit 0
  557. fi
  558.  
  559. if [ -z "$WHAT" -o "$ERROR" = "TRUE" ]; then
  560. if [ "$mode" = "irc" ]; then
  561. IRCOUTPUT="TRUE"
  562. fi
  563. OUTPUT="$NOARGUMENT"
  564. proc_cookies
  565. echo "$OUTPUT"
  566. AUTO="TRUE"
  567. exit 0
  568. fi
  569.  
  570. if [ ! -d "$tmp" ]; then
  571. if [ "$mode" = "irc" ]; then
  572. echo "Error. Cant find $tmp. Create it and set 777 in it."
  573. else
  574. echo "Error. Cant find $glroot$tmp. Create it and set 777 in it."
  575. fi
  576. exit 0
  577. fi
  578. touch "$tmp/testtouch.tmp"
  579. if [ ! -e "$tmp/testtouch.tmp" ]; then
  580. if [ "$mode" = "irc" ]; then
  581. echo "Error. Cant write to $tmp. Check perms."
  582. else
  583. echo "Error. Cant write to $glroot$tmp. Check perms."
  584. fi
  585. exit 0
  586. fi
  587. rm -f $tmp/testtouch.tmp
  588.  
  589. }
  590.  
  591. ## Does the reqfile exist and can we read it?
  592. proc_checkfile() {
  593. if [ ! -e "$reqfile" ]; then
  594. echo "Can not find $reqfile. Create it and set proper perms on it (777)"
  595. exit 0
  596. fi
  597. if [ ! -w "$reqfile" ]; then
  598. echo "Found requestfile, but can not write to it. Set proper perms on it."
  599. exit 0
  600. fi
  601. }
  602.  
  603. ## Reorder reqfile so numbers are in order.
  604. proc_reorder() {
  605. ## Can the reqfile be written to?
  606. if [ ! -w "$reqfile" ]; then
  607. echo "Cant read $reqfile for fix. Create it and/or set perms."
  608. exit 0
  609. fi
  610.  
  611. ## Remove previous file just incase.
  612. if [ -e "$tmp/reorder.tmp" ]; then
  613. rm -f "$tmp/reorder.tmp"
  614. fi
  615.  
  616. ## Count each line in the reqfile to see which number we should put on it.
  617. num=0
  618. for line in `cat $reqfile | tr -s ' ' '^' | tr -d ']' | tr -d '[' | cut -d':' -f2-`; do
  619. num=$[$num+1]
  620. if [ -z "$( echo "$num" | grep ".." )" ]; then
  621. newnum="[ $num:]"
  622. else
  623. newnum="[$num:]"
  624. fi
  625.  
  626. ## Add requests to new reqfile.
  627. echo "$newnum $line" | tr -s '^' ' ' >> $tmp/reorder.tmp
  628. done
  629.  
  630. ## Was any file created? Copy it if so. If not, no requests were found.
  631. if [ -e "$tmp/reorder.tmp" ]; then
  632. cp -f "$tmp/reorder.tmp" "$reqfile"
  633. rm -f "tmp/reorder.tmp"
  634. chmod 666 "$reqfile" >/dev/null 2>&1
  635. else
  636. ## Only say this if fix was run manually. Not when reqfilling etc.
  637. if [ "$name" = "fix" ]; then
  638. echo "No requests to fix was found."
  639. fi
  640. fi
  641. }
  642.  
  643. ## Check for old requests.
  644. proc_checkold() {
  645. if [ "$removedays" ]; then
  646. for line in `cat $reqfile | tr -s ' ' '^'`; do
  647. unset FIRST; unset SECOND; unset THIRD; unset GOTNAME; unset RELEASE
  648. unset SECONDSOLD; unset OLD; unset RELNUMBER; unset return_username
  649. if [ "$line" ]; then
  650. for each in `echo "$line" | tr -s '^' ' '`; do
  651. if [ "$GOTNAME" != "TRUE" ]; then
  652. if [ "$each" = "~" ]; then
  653. GOTNAME=TRUE
  654. else
  655. RELEASE="$each"
  656. fi
  657. fi
  658.  
  659. if [ "$GOT_REQUESTER" != "TRUE" ]; then
  660. if [ "`echo "$each" | grep "^by$"`" ]; then
  661. GOT_REQUESTER="TRUE"
  662. fi
  663. else
  664. return_username="$each"
  665. unset GOT_REQUESTER
  666. fi
  667.  
  668. FIRST="$SECOND"
  669. SECOND="$THIRD"
  670. THIRD="$each"
  671.  
  672. ## Fixes depending on which date format is in the .requests file.
  673. if [ "$FIRST" = "at" ]; then
  674. unset FIRST
  675. fi
  676. if [ "`echo "$THIRD" | grep "^REWARD"`" ]; then
  677. unset THIRD
  678. fi
  679.  
  680. done
  681.  
  682. THIRD="$( echo "$THIRD" | tr -s '-' '/' )"
  683. SECONDSOLD="$( $datebin -d "$FIRST $SECOND $THIRD" +%s )"
  684. SECONDSMAX="$( $datebin -d "-$removedays day" +%s )"
  685.  
  686. if [ "$SECONDSOLD" -lt "$SECONDSMAX" ]; then
  687. REAL_POSITION="$( echo "$line" | cut -d ']' -f1 )]"
  688. RELNUMBER="$( echo "$line" | cut -d ':' -f1 | tr -d '[' | tr -d ']' | tr -d ' ' | tr -d '^' )"
  689. OLD=TRUE
  690.  
  691. ## Any reward offered? Find it, set REWARD to the value and return the credits to the requester.
  692. if [ "`echo "$line" | grep "\^REWARD:.*MB"`" ]; then
  693. temp_line="`echo "$line" | tr -s '^' ' '`"
  694. for each_line in $temp_line; do
  695. if [ "`echo "$each_line" | grep "^REWARD:"`" ]; then
  696. REWARD="`echo "$each_line" | cut -d ':' -f2 | tr -d '[:alpha:]'`"
  697. if [ "$REWARD" ]; then
  698. break
  699. fi
  700. fi
  701. done
  702.  
  703. current_credits_kb="`grep "^CREDITS\ " "$usersdir/$return_username" | cut -d ' ' -f2`"
  704. full_credits="`grep "^CREDITS\ " "$usersdir/$return_username" | cut -d ' ' -f2-`"
  705. add_credits_kb=$[$REWARD*1024]
  706. if [ "$current_credits_kb" ] && [ "$add_credits_kb" ]; then
  707. new_credits_kb=$[$current_credits_kb+add_credits_kb]
  708. if [ "$new_credits_kb" ]; then
  709. # echo "New credits: $new_credits_kb"
  710. NEWVALUES="`echo "$full_credits " | sed -e "s/[0-9]* /$new_credits_kb /"`"
  711. # echo "new values: $NEWVALUES"
  712. grep -v "^CREDITS\ " "$usersdir/$return_username" > "/tmp/${return_username}.tmp"
  713. echo "CREDITS $NEWVALUES" >> "/tmp/${return_username}.tmp"
  714. if [ -e "$usersdir/${return_username}.lock" ]; then
  715. sleep 1
  716. fi
  717. cp -f "/tmp/${return_username}.tmp" "$usersdir/$return_username"
  718. rm -f "/tmp/${return_username}.tmp"
  719. fi
  720. fi
  721.  
  722. fi
  723.  
  724. fi
  725. fi
  726.  
  727. ## This release is too old. Delete it.
  728.  
  729. if [ "$OLD" = "TRUE" ]; then
  730. GOT_OLD_RELEASE="TRUE"
  731. if [ "$gllog" ]; then
  732. mode="gl"
  733. OUTPUT="$STATUSANNOUNCE"
  734. IRCOUTPUT="TRUE"
  735. proc_cookies
  736. proc_output "$OUTPUT $REAL_POSITION $RELEASE has been deleted because its older then $removedays days."
  737. fi
  738. if [ -d "$requests/$requesthead-by."*"-$RELEASE" ]; then
  739. rmdir "$requests/$requesthead-by.*-$RELEASE" >/dev/null 2>&1
  740. fi
  741.  
  742. proc_log "REQDELAUTO: \"crontab deleted $RELEASE - Older then $removedays days.\""
  743. if [ "$REWARD" ]; then
  744. proc_log "REQDELAUTOREWARD: \"Returned $REWARD MB to $return_username\""
  745. fi
  746.  
  747. DEL_NUMBERS="$DEL_NUMBERS $REAL_POSITION"
  748.  
  749. fi
  750.  
  751. done
  752.  
  753. ## Make a new file without the reqfilled ones and copy it over the old one.
  754. if [ "$GOT_OLD_RELEASE" = "TRUE" ]; then
  755. for REAL_POSITION in $DEL_NUMBERS; do
  756. REAL_POSITION="`echo "$REAL_POSITION" | tr '^' ' '`"
  757. grep -vF "$REAL_POSITION" "$reqfile" > $tmp/newreqfile.tmp
  758. cp -f "$tmp/newreqfile.tmp" "$reqfile"
  759. rm -f "$tmp/newreqfile.tmp"
  760. done
  761. ## Reorder new one so numbers are linear.
  762. proc_reorder
  763.  
  764. ## Announce the remaining requests.
  765. if [ "$showonauto" = "TRUE" ]; then
  766. auto="auto"
  767. proc_status
  768. fi
  769. fi
  770.  
  771. fi
  772.  
  773. if [ "$removefdays" ]; then
  774. if [ -d "$requests" ]; then
  775.  
  776. if [ -z "$mustinclude" ]; then
  777. mustinclude="."
  778. fi
  779. if [ -z "$exclude" ]; then
  780. exclude="fejfklJ252452delj"
  781. fi
  782. if [ ! -x "$file_date" ]; then
  783. echo "Was going to check for old requests, but file_date ($file_date) is not executable."
  784. exit 0
  785. fi
  786.  
  787. cd "${requests}/${filled_dir}"
  788. for dir in `ls | grep "$mustinclude" | egrep -v "$exclude"`; do
  789. # echo="checking $dir because its from $reldate"
  790. timestamp=`$file_date $dir`
  791. secsold=`$datebin -d "$timestamp" +%s`
  792. seclimit=`$datebin -d "-$removefdays day" +%s`
  793. if [ "$secsold" -lt "$seclimit" ]; then
  794. reldate=`$datebin -d "$timestamp" +%m%d`
  795. rm -rf "$dir"
  796. IRCOUTPUT="TRUE"
  797. if [ ! -e "$dir" ]; then
  798. if [ "$gllog" ]; then
  799. OUTPUT="$STATUSANNOUNCE"
  800. proc_cookies
  801. LINETOSAY="$OUTPUT Deleting $dir because its from $reldate"
  802. echo `$datebin "+%a %b %e %T %Y"` TURGEN: \"$LINETOSAY\" >> $gllog
  803. unset LINETOSAY
  804. fi
  805. else
  806. if [ "$gllog" ]; then
  807. OUTPUT="$STATUSANNOUNCE"
  808. proc_cookies
  809. LINETOSAY="$OUTPUT Was going to delete $dir because its from $reldate, but seems I couldnt."
  810. echo `$datebin "+%a %b %e %T %Y"` TURGEN: \"$LINETOSAY\" >> $gllog
  811. unset LINETOSAY
  812. fi
  813. fi
  814. fi
  815. done
  816. else
  817. echo "Should have checked for old requests, but $requests wasnt found or not a dir."
  818. fi
  819. fi
  820. }
  821.  
  822. ## Make a request.
  823. proc_request() {
  824. FOR="$BY"
  825. proc_checkfile
  826.  
  827. if [ "$date_format_in_reqfile" = "NEW" ]; then
  828. adddate="`$datebin +%Y'-'%m'-'%d' '%H':'%M`"
  829. elif [ "$date_format_in_reqfile" = "OLD" ]; then
  830. adddate="$( $datebin +%r" "%x | tr -s '/' '-' )"
  831. else
  832. echo "Error in config. date_format_in_reqfile should be set to either NEW or OLD"
  833. exit 0
  834. fi
  835.  
  836. ## Dont mess with these ones.
  837. REQINFILE="%NUM% %WHAT% ~ by %WHO% (%MODE%) for %FOR% at %ADDDATE%"
  838. REQINFILE2="%NUM% %WHAT% ~ by %WHO% (%MODE%) for %FOR% at %ADDDATE%"
  839.  
  840.  
  841. ## If requesthead is set, is there already a dir with this name ?
  842. if [ "$requesthead" ]; then
  843. if [ -d "$requests/"*"-$WHAT" ]; then
  844. if [ "$mode" = "irc" ]; then
  845. IRCOUTPUT="TRUE"
  846. fi
  847. OUTPUT="$ALREADYREQUESTED"
  848. proc_cookies
  849. echo "$OUTPUT"
  850. exit 0
  851. fi
  852. fi
  853.  
  854. ## Is it already requested in file ? This one needs work to recognize . as a char.
  855. if [ "$( cat $reqfile | cut -c5- | grep -w -- "$WHAT " )" ]; then
  856. if [ "$mode" = "irc" ]; then
  857. IRCOUTPUT="TRUE"
  858. fi
  859. OUTPUT="$ALREADYREQUESTED"
  860. proc_cookies
  861. echo "$OUTPUT"
  862. exit 0
  863. else
  864. ## Figure out which number its gonna get.
  865. num=1
  866. for each in `cat $reqfile | tr -s ' ' '^'`; do
  867. num=$[$num+1]
  868. done
  869.  
  870. if [ "$max_requests" ]; then
  871. if [ "`cat $reqfile | wc -l | tr -d ' '`" -ge "$max_requests" ]; then
  872. OUTPUT="$TOOMANYREQUESTS"
  873. proc_cookies
  874. echo "$OUTPUT"
  875. exit 0
  876. fi
  877. fi
  878.  
  879. if [ -z "$( echo "$num" | grep ".." )" ]; then
  880. num="\[0$num:\]"
  881. else
  882. num="\[$num:\]"
  883. fi
  884.  
  885. ## If REWARD is set and REWARD_FREE is not TRUE, check if the user has leech. Dont allow if if so.
  886. if [ "$REWARD" ] && [ "$REWARD_FREE" != "TRUE" ]; then
  887. if [ "`grep "^RATIO\ 0" "$usersdir/$username"`" ]; then
  888. echo "You have leech and can not set a reward unless a siteop approves it in the config."
  889. exit 0
  890. fi
  891. fi
  892.  
  893. ## Announce it unless gllog is empty ( not set ).
  894. if [ "$gllog" ]; then
  895. if [ -w "$gllog" ]; then
  896. if [ "$HIDE" != "TRUE" ]; then
  897. RELEASE="$num $WHAT"
  898.  
  899. if [ "$FOR" ]; then
  900. OUTPUT="$REQANNOUNCE2"
  901. else
  902. OUTPUT="$REQANNOUNCE"
  903. fi
  904. IRCOUTPUT="TRUE"
  905. proc_cookies
  906.  
  907. ## Since this is from private message to bot, we need to write to glftpd.log instead of
  908. ## just echoing it to screen. Otherwise it goes back to private mess and we want to announce
  909. ## when something is requested.
  910. if [ "$mode" = "irc" ]; then
  911. TEMPCHANGE="TRUE"
  912. mode="gl"
  913. fi
  914.  
  915. ## Announce it.
  916. proc_output "$OUTPUT"
  917.  
  918. ## If a reward was added, announce that as well.
  919. if [ "$REWARD" ]; then
  920. OUTPUT="$REQANNOUNCE_REWARD"
  921. proc_cookies
  922. proc_output "$OUTPUT"
  923. fi
  924.  
  925. IRCOUTPUT="FALSE"
  926.  
  927. ## Change back the mode to irc if it was that to start with.
  928. if [ "$TEMPCHANGE" = "TRUE" ]; then
  929. mode="irc"
  930. unset TEMPCHANGE
  931. fi
  932.  
  933. fi
  934. else
  935. echo "Error. Cant write to $gllog. Check paths and perms."
  936. exit 0
  937. fi
  938. fi
  939.  
  940. ## Say "request added". Take output from GLOK. Only from glftpd. irc is handled in botscript.
  941. if [ "$mode" = "gl" ]; then
  942. if [ "$mode" = "irc" ]; then
  943. IRCOUTPUT="TRUE"
  944. fi
  945. OUTPUT="$GLOK"
  946. proc_cookies
  947. echo "$OUTPUT"
  948. fi
  949.  
  950. ## Create the dir.
  951. if [ "$requesthead" ] && [ "$do_not_create_dir_until_filled" != "TRUE" ]; then
  952. mkdir -m777 "$requests/$requesthead-by.$BY-$WHAT"
  953. fi
  954.  
  955. ## Log it.
  956. if [ "$REWARD" ]; then
  957. if [ "$REWARD_FREE" = "TRUE" ]; then
  958. proc_log "REQUEST: \"$BY requested $WHAT with ${REWARD}MB reward (free. No deduction).\""
  959. else
  960. proc_log "REQUEST: \"$BY requested $WHAT with ${REWARD}MB reward.\""
  961. fi
  962. else
  963. proc_log "REQUEST: \"$BY requested $WHAT\""
  964. fi
  965.  
  966. IRCOUTPUT="TRUE"
  967. if [ "$FOR" ]; then
  968. OUTPUT="$REQINFILE2"
  969. else
  970. OUTPUT="$REQINFILE"
  971. fi
  972. proc_cookies
  973.  
  974. if [ "$REWARD" ]; then
  975. echo "$OUTPUT REWARD:${REWARD}MB" >> $reqfile
  976. else
  977. echo "$OUTPUT" >> $reqfile
  978. fi
  979. chmod 666 "$reqfile" >/dev/null 2>&1
  980.  
  981. ## If REWARD is set and REWARD_FREE is not TRUE, remove the MB from the user.
  982. if [ "$REWARD" ] && [ "$REWARD_FREE" != "TRUE" ]; then
  983. REWARD_KB=$[$REWARD*1024]
  984. current_credits="`grep "^CREDITS " "$usersdir/$username" | cut -d ' ' -f2`"
  985.  
  986. full_credits="`grep "^CREDITS " "$usersdir/$username" | cut -d ' ' -f2-`"
  987.  
  988. new_credits=$[$current_credits-$REWARD_KB]
  989. # echo "Will deduct: $REWARD_KB kb"
  990. # echo "Current : $current_credits"
  991. # echo "New credits: $new_credits"
  992.  
  993. NEWVALUES="`echo "$full_credits " | sed -e "s/[0-9]* /$new_credits /"`"
  994. # echo "OLD: $full_credits"
  995. # echo "NEW: $NEWVALUES"
  996. grep -v "^CREDITS " "$usersdir/$username" > "$tmp\$username.tmp"
  997. echo "CREDITS $NEWVALUES" >> "$tmp\$username.tmp"
  998. retries=1
  999. if [ -e "$usersdir/$username.lock" ]; then
  1000. # echo "Found a lockfile on your account. Please hold."
  1001. while [ -e "$usersdir/$username.lock" ]; do
  1002. retries=$[$retries+1]
  1003. sleep 1
  1004. if [ ! -e "$usersdir/$username.lock" ]; then
  1005. break
  1006. fi
  1007. if [ "$retries" -ge "10" ]; then
  1008. rm -f "$usersdir/$username.lock"
  1009. break
  1010. fi
  1011. done
  1012. fi
  1013. cp -f "$tmp\$username.tmp" "$usersdir/$username"
  1014. rm -f "$tmp\$username.tmp"
  1015. fi
  1016.  
  1017. if [ "$showonrequest" = "TRUE" ]; then
  1018. proc_status
  1019. fi
  1020.  
  1021. exit 0
  1022.  
  1023. fi
  1024. } ## End of proc_request.
  1025.  
  1026.  
  1027. proc_reqfilled() {
  1028. proc_checkfile
  1029.  
  1030. if [ -z "$WHAT" ]; then
  1031. echo "Specify the name or number when reqfilling."
  1032. exit 0
  1033. fi
  1034.  
  1035. ## Is it requested? (check by number)
  1036. if [ -z "`echo "$WHAT" | tr -d '[:digit:]'`" ]; then
  1037. if [ -z "$( echo "$WHAT" | grep ".." )" ]; then
  1038. WHATNEW="[ $WHAT:]"
  1039. else
  1040. WHATNEW="[$WHAT:]"
  1041. fi
  1042. fi
  1043.  
  1044. ## By default we pretend it was found in the request list. Will be set to FALSE if its actually not, below.
  1045. REQUEST_FOUND="TRUE"
  1046.  
  1047. if [ -z "`echo "$WHAT" | tr -d '[:digit:]'`" ]; then
  1048. ## Check if requested by number
  1049. if [ -z "$( cat $reqfile | cut -d ':' -f1 | cut -d '~' -f1 | tr -d '[' | tr -d ']' | grep -w -- "$WHAT" )" ]; then
  1050. REQUEST_FOUND="FALSE"
  1051. fi
  1052. else
  1053. ## Check if requested by name
  1054. if [ -z "$( cat $reqfile | cut -d ']' -f2 | cut -d '~' -f1 | cut -c2- | grep -w -- "$WHAT" )" ]; then
  1055. REQUEST_FOUND="FALSE"
  1056. else
  1057.  
  1058. ## It WAS requested by name. Extract the number of the release.
  1059. WHATNEW="$( cat $reqfile | grep "\[[\ |0-9][0-9]:\] $WHAT \~" | cut -d ']' -f1 | head -n1 )"
  1060.  
  1061. if [ -z "$WHATNEW" ]; then
  1062. echo "Internal Error: Found the $WHAT request in the list but failed to extract its number.."
  1063. echo "Use the number instead."
  1064. exit 0
  1065. fi
  1066.  
  1067. ## Add a ] at the end of it.
  1068. WHATNEW="${WHATNEW}]"
  1069. if [ "$mode" = "gl" ]; then
  1070. echo "Request number for $WHAT seems to be: $WHATNEW"
  1071. fi
  1072. fi
  1073. fi
  1074.  
  1075. if [ "$REQUEST_FOUND" = "FALSE" ]; then
  1076. if [ "$mode" = "irc" ]; then
  1077. IRCOUTPUT="TRUE"
  1078. fi
  1079. OUTPUT="$NOTREQUESTED"
  1080. proc_cookies
  1081. echo "$OUTPUT"
  1082. exit 0
  1083. else
  1084.  
  1085. LINETODEL="$( grep -F "${WHATNEW}" "$reqfile" | head -n1 )"
  1086.  
  1087. ## Verify that the number we got from the search really is the correct one.
  1088. if [ "`echo "$LINETODEL" | cut -c1-5`" != "$WHATNEW" ]; then
  1089. echo "Error. Searched for $WHATNEW but got $LINETODEL"
  1090. echo "Aborting. Report this to author."
  1091. exit 0
  1092. else
  1093. if [ "$mode" = "gl" ]; then
  1094. echo "Verified selected row from requests file."
  1095. fi
  1096. fi
  1097.  
  1098. ## Grab who its for (if any) and who made the request.
  1099. if [ "$( echo "$LINETODEL" | grep " for " )" ]; then
  1100. REQUESTFOR=`echo "$LINETODEL" | cut -d ')' -f2 | cut -d ' ' -f3`
  1101. fi
  1102. REQUESTBY=`echo "$LINETODEL" | cut -d '~' -f2- | cut -d ' ' -f3`
  1103.  
  1104. ## Get release name.
  1105. RELEASE=`echo "$LINETODEL" | cut -d ':' -f2 | cut -d '~' -f1 | cut -c2-`
  1106. RELEASE=`echo $RELEASE` ## Clean it up from initial and ending spaces.
  1107.  
  1108. if [ "$enable_rewardsystem" = "TRUE" ]; then
  1109. ## Any reward offered? Find it, set REWARD to the value.
  1110. if [ "`echo "$LINETODEL" | grep "\ REWARD:.*MB"`" ]; then
  1111. for each_line in $LINETODEL; do
  1112. if [ "`echo "$each_line" | grep "^REWARD:"`" ]; then
  1113. REWARD="`echo "$each_line" | cut -d ':' -f2 | tr -d '[:alpha:]'`"
  1114. if [ "$REWARD" ]; then
  1115. break
  1116. fi
  1117. fi
  1118. done
  1119. fi
  1120. fi
  1121.  
  1122. case $name in
  1123. reqfill)
  1124. ## Fix the dir..
  1125. if [ "$requesthead" ] && [ "$do_not_create_dir_until_filled" = "TRUE" ]; then
  1126. mkdir -m777 "$requests/$filledhead-for.$REQUESTFOR-$WHAT"
  1127.  
  1128. if [ "$REWARD" ]; then
  1129. proc_reward
  1130. fi
  1131. elif [ "$requesthead" ]; then
  1132.  
  1133. if [ -d "$requests/$requesthead-by."*"-$WHAT" ]; then
  1134.  
  1135. ## Check that its not empty.
  1136. if [ -z "`ls -1d "$requests/$requesthead-by."*"-$WHAT"`" ]; then
  1137. if [ "$mode" = "gl" ]; then
  1138. echo "$REQFILLEDEMPTY"
  1139. else
  1140. IRCOUTPUT="TRUE"
  1141. OUTPUT="$REQFILLEDEMPTYIRC"
  1142. proc_cookies
  1143. echo "$OUTPUT"
  1144. fi
  1145. exit 0
  1146. fi
  1147.  
  1148. ## If the filled dir already exists, add a number to the end of it.
  1149. if [ -e "$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT" ]; then
  1150. num=0; unset NUMBER; unset NOMOVE
  1151. while [ -e "$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT" ]; do
  1152. num=$[$num+1]
  1153. NUMBER=$num
  1154. if [ "$NUMBER" -gt "20" ]; then
  1155. NOMOVE=TRUE
  1156. break
  1157. fi
  1158. done
  1159. if [ "$NOMOVE" != "TRUE" ]; then
  1160. mv -f "$requests/$requesthead-by."*"-$WHAT" "$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT"
  1161. COMPLETE_REQUEST="$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT"
  1162. fi
  1163. else
  1164. ## All ok, just move the dir.
  1165. mv -f "$requests/$requesthead-by."*"-$WHAT" "$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT"
  1166. COMPLETE_REQUEST="$requests/${filled_dir}$filledhead-for.$REQUESTFOR-$WHAT"
  1167. fi
  1168.  
  1169. if [ "$REWARD" ]; then
  1170. proc_reward
  1171. fi
  1172.  
  1173. else
  1174. if [ "$mode" = "gl" ]; then
  1175. requestname=`basename $requests`
  1176. echo "$requesthead-by.$BY-$WHAT was not found in $requestname. Skipping rename of dir!"
  1177. unset requestname
  1178. fi
  1179. fi
  1180. fi
  1181.  
  1182. if [ "$mode" = "gl" ]; then
  1183. echo "$WHAT : $RELEASE has been filled. Thank you."
  1184. fi
  1185.  
  1186. proc_sendmsg "reqfilled" "Go fetch!"
  1187. ACTION="reqfilled" ## Action for irc announce
  1188. proc_log "REQFILL: \"$BY filled $RELEASE\""
  1189. if [ "$REWARD_LIST" ]; then
  1190. REWARD_LIST_TEMP="`echo "$REWARD_LIST" | tr '=' '/'`"
  1191. proc_log "REQFILLREWARD: \"Rewarded: $total_users users - $total_files files : $REWARD_LIST_TEMP\""
  1192. fi
  1193. ;;
  1194.  
  1195. reqdel)
  1196. if [ "`echo "$BY" | grep -i "^$REQUESTBY$"`" ]; then
  1197. ## Say this to glftpd in either case.
  1198.  
  1199. if [ -d "$requests/$requesthead-by.$BY-$WHAT" ]; then
  1200. rmdir "$requests/$requesthead-by.$BY-$WHAT" >/dev/null 2>&1
  1201. fi
  1202.  
  1203. if [ "$REWARD" ]; then
  1204. COMPLETE_REQUEST="RETURN-$REQUESTBY"
  1205. proc_reward
  1206. fi
  1207.  
  1208. proc_sendmsg "deleted" "Sorry!"
  1209. ACTION="reqdelled" ## Action for irc announce
  1210. proc_log "REQDEL: \"$BY deleted -reqdel- $RELEASE\""
  1211. if [ "$REWARD" ]; then
  1212. proc_log "REQDELREWARD: \"$REWARD MB returned to $REQUESTBY"
  1213. fi
  1214.  
  1215. if [ "$mode" = "gl" ]; then
  1216. echo "$WHAT : $RELEASE has been deleted."
  1217. fi
  1218.  
  1219. else
  1220. echo "Permission denied. $RELEASE requested by $REQUESTBY, not $BY"
  1221. exit 0
  1222. fi
  1223. ;;
  1224.  
  1225. reqwipe)
  1226. if [ -d "$requests/*$WHAT" ]; then
  1227. rm -rf "$requests/*$WHAT"
  1228. else
  1229. echo "Gee, I would love to wipe out $RELEASE, but there is no such dir."
  1230. fi
  1231. if [ "$REWARD" ]; then
  1232. COMPLETE_REQUEST="RETURN-$REQUESTBY"
  1233. proc_reward
  1234. fi
  1235.  
  1236. if [ "$mode" = "gl" ]; then
  1237. echo "Wiped out request for $WHAT"
  1238. fi
  1239.  
  1240. proc_sendmsg "wiped" "Sorry!"
  1241. ACTION="reqwiped" ## Action for irc announce
  1242. proc_log "REQWIPE: \"$BY wiped -reqwipe- $RELEASE\""
  1243. if [ "$REWARD" ]; then
  1244. proc_log "REQWIPEREWARD: \"$REWARD MB returned to $REQUESTBY"
  1245. fi
  1246. ;;
  1247.  
  1248. esac
  1249.  
  1250. ## Make a new file without the reqfilled one and copy it over the old one.
  1251.  
  1252. grep -vF "$WHATNEW" "$reqfile" > $tmp/newreqfile.tmp
  1253. if [ -e "$tmp/newreqfile.tmp" ]; then
  1254. cp -f "$tmp/newreqfile.tmp" "$reqfile"
  1255. rm -f "$tmp/newreqfile.tmp"
  1256. chmod 666 "$reqfile" >/dev/null 2>&1
  1257. else
  1258. echo "Error: $tmp/newreqfile.tmp was not created."
  1259. exit 0
  1260. fi
  1261.  
  1262. ## Reorder new one so numbers are linear.
  1263. proc_reorder
  1264.  
  1265. if [ "$gllog" ]; then
  1266. if [ -w "$gllog" ]; then
  1267. if [ "$HIDE" != "TRUE" ]; then
  1268. IRCOUTPUT="TRUE"
  1269.  
  1270. case $ACTION in
  1271. reqfilled) OUTPUT="$FILLANNOUNCE" ;;
  1272. reqdelled) OUTPUT="$FILLANNOUNCE_DEL" ;;
  1273. reqwiped) OUTPUT="$FILLANNOUNCE_WIPE" ;;
  1274. *) OUTPUT="$FILLANNOUNCE" ;;
  1275. esac
  1276.  
  1277. proc_cookies
  1278.  
  1279. if [ "$mode" = "irc" ] && [ "$MODE" != "reqfilled" ]; then
  1280. TEMPCHANGE="TRUE"
  1281. mode="gl"
  1282. fi
  1283.  
  1284. proc_output "$OUTPUT"
  1285. if [ "$REWARD_LIST" ]; then
  1286. OUTPUT="$FILLANNOUNCE_REWARD"
  1287. proc_cookies
  1288. proc_output "$OUTPUT"
  1289. fi
  1290.  
  1291. IRCOUTPUT="FALSE"
  1292.  
  1293. if [ "$TEMPCHANGE" = "TRUE" ]; then
  1294. mode="irc"
  1295. fi
  1296.  
  1297. fi
  1298. else
  1299. echo "Error. Cant write to $gllog. Check paths and perms."
  1300. exit 0
  1301. fi
  1302. fi
  1303.  
  1304. if [ "$showonfill" = "TRUE" ] && [ "$HIDE" != "TRUE" ]; then
  1305. proc_status
  1306. fi
  1307. fi
  1308. }
  1309.  
  1310. proc_reward() {
  1311. if [ -z "$REWARD" ]; then
  1312. echo "Internal error. Proc_reward did not get a provided REWARD value"
  1313. exit 0
  1314. fi
  1315.  
  1316. if [ -z "$COMPLETE_REQUEST" ]; then
  1317. echo "Internal error. Proc_reward did not get a provided COMPLETE_REQUEST value."
  1318. exit 0
  1319. fi
  1320.  
  1321. ## If the first part of COMPLETE_REQUEST is RETURN (RETURN-username), it will give the full
  1322. ## reward to that guy instead of trying to split it up. Used for reqdel.
  1323. if [ "`echo "$COMPLETE_REQUEST" | cut -d '-' -f1`" = "RETURN" ]; then
  1324. return_username="`echo "$COMPLETE_REQUEST" | cut -d '-' -f2-`"
  1325. # echo "returning creds to requester: $return_username"
  1326. if [ ! -e "$usersdir/$return_username" ]; then
  1327. echo "Was going to return $REWARD MB to $return_username, but that user does not exist."
  1328. else
  1329. REWARD_FREE="FALSE"
  1330. ## No decuction when using -reward:? Check by flag.
  1331. if [ "$reward_free_flags" ]; then
  1332. reward_free_flags="`echo "$reward_free_flags" | tr -s ' ' '|'`"
  1333. if [ "`grep "^FLAGS " "$usersdir/$return_username" | cut -d ' ' -f2 | egrep "$reward_free_flags"`" ]; then
  1334. REWARD_FREE="TRUE"
  1335. fi
  1336. fi
  1337.  
  1338. ## Remake userlist to add ^ $ to each defined user for perfect matches.
  1339. ## No decuction when using -reward:? Check by username
  1340. if [ "$reward_free_users" ]; then
  1341. FIX_LIST="$reward_free_users"
  1342. proc_make_egrep_list
  1343. reward_free_users="$FIXED_LIST"; unset FIXED_LIST
  1344.  
  1345. ## Check if username matches.
  1346. if [ "`echo "$return_username" | egrep "$reward_free_users"`" ]; then
  1347. REWARD_FREE="TRUE"
  1348. fi
  1349. fi
  1350.  
  1351.  
  1352. ## Only return credits if it wasnt free when requesting.
  1353. if [ "$REWARD_FREE" != "TRUE" ]; then
  1354. current_credits_kb="`grep "^CREDITS\ " "$usersdir/$return_username" | cut -d ' ' -f2`"
  1355. full_credits="`grep "^CREDITS\ " "$usersdir/$return_username" | cut -d ' ' -f2-`"
  1356. add_credits_kb=$[$REWARD*1024]
  1357. if [ "$current_credits_kb" ] && [ "$add_credits_kb" ]; then
  1358. new_credits_kb=$[$current_credits_kb+add_credits_kb]
  1359. if [ "$new_credits_kb" ]; then
  1360. # echo "New credits: $new_credits_kb"
  1361. NEWVALUES="`echo "$full_credits " | sed -e "s/[0-9]* /$new_credits_kb /"`"
  1362. # echo "new values: $NEWVALUES"
  1363. grep -v "^CREDITS\ " "$usersdir/$return_username" > "/tmp/${return_username}.tmp"
  1364. echo "CREDITS $NEWVALUES" >> "/tmp/${return_username}.tmp"
  1365. if [ -e "$usersdir/${return_username}.lock" ]; then
  1366. sleep 1
  1367. fi
  1368. cp -f "/tmp/${return_username}.tmp" "$usersdir/$return_username"
  1369. rm -f "/tmp/${return_username}.tmp"
  1370. fi
  1371. fi
  1372. fi
  1373. fi
  1374. else
  1375. if [ ! -d "$COMPLETE_REQUEST" ]; then
  1376. echo "Error. Proc_reward reports that $COMPLETE_REQUEST does not exist. Can not give reward."
  1377. exit 0
  1378. else
  1379. cd "$COMPLETE_REQUEST"
  1380. proc_find_and_give
  1381. fi
  1382. fi
  1383. }
  1384.  
  1385. proc_find_and_give() {
  1386. total_files="0"
  1387. total_users="0"
  1388.  
  1389. # Create list from maindir. New file made here. Others add to it.
  1390. $tuls | tr -d ' ' | egrep -v "::::\.::::|::::\.\.::::|^d" | tr -s ':' ' ' > /tmp/reqlist.tmp
  1391. # echo "Grabbing files from $PWD"
  1392.  
  1393. for each_subdir in `$tuls | grep "^d" | egrep -v "::::\.::::|::::\.\.::::" | tr -d ' ' | tr -s ':' | cut -d ':' -f4`; do
  1394. if [ -d "$each_subdir" ]; then
  1395. cd "$each_subdir"
  1396. # echo "entering $each_subdir"
  1397. $tuls | tr -d ' ' | egrep -v "::::\.::::|::::\.\.::::|^d" | tr -s ':' ' ' >> /tmp/reqlist.tmp
  1398. for each_subdir_2 in `$tuls | grep "^d" | egrep -v "::::\.::::|::::\.\.::::" | tr -d ' ' | tr -s ':' | cut -d ':' -f4`; do
  1399. if [ -d "$each_subdir_2" ]; then
  1400. cd "$each_subdir_2"
  1401. # echo "entering $each_subdir_2"
  1402. $tuls | tr -d ' ' | egrep -v "::::\.::::|::::\.\.::::|^d" | tr -s ':' ' ' >> /tmp/reqlist.tmp
  1403.  
  1404. for each_subdir_3 in `$tuls | grep "^d" | egrep -v "::::\.::::|::::\.\.::::" | tr -d ' ' | tr -s ':' | cut -d ':' -f4`; do
  1405. if [ -d "$each_subdir_3" ]; then
  1406. cd "$each_subdir_3"
  1407. # echo "entering $each_subdir_3"
  1408. $tuls | tr -d ' ' | egrep -v "::::\.::::|::::\.\.::::|^d" | tr -s ':' ' ' >> /tmp/reqlist.tmp
  1409. cd ..
  1410. # echo "jumping back to $PWD"
  1411. fi
  1412. done
  1413. cd ..
  1414. # echo "jumping back to $PWD"
  1415. fi
  1416. done
  1417. cd ..
  1418. # echo "jumping back to $PWD"
  1419. fi
  1420. done
  1421.  
  1422. if [ -e "/tmp/reqlist.tmp" ]; then
  1423. # cat /tmp/reqlist.tmp | sort -k2,2 -n | tr ' ' ':' >> /tmp/reqlist.tmp2
  1424. ## Sort the list
  1425. cat /tmp/reqlist.tmp | sort -k2,2 -n | tr ' ' ':' > /tmp/reqlist.tmp2
  1426. rm -f /tmp/reqlist.tmp
  1427. else
  1428. echo "dummy_so_cat_dosnt_fuck_up" > /tmp/reqlist.tmp2
  1429. fi
  1430.  
  1431. for rawdata in `cat /tmp/reqlist.tmp2`; do
  1432. filename="`echo "$rawdata" | cut -d ':' -f4`"
  1433. if [ "`echo "$filename" | egrep -i "$reward_count"`" ]; then
  1434. total_files=$[$total_files+1]
  1435. uid="`echo "$rawdata" | cut -d ':' -f2`"
  1436. if [ "$last_uid" != "$uid" ]; then
  1437. total_users=$[$total_users+1]
  1438. fi
  1439. # echo "$filename $uid"
  1440. last_uid="$uid"
  1441. fi
  1442. done
  1443. unset last_uid
  1444.  
  1445. user="0"
  1446. for rawdata in `cat /tmp/reqlist.tmp2`; do
  1447. filename="`echo "$rawdata" | cut -d ':' -f4`"
  1448. if [ "`echo "$filename" | egrep -i "$reward_count"`" ]; then
  1449. uid="`echo "$rawdata" | cut -d ':' -f2`"
  1450.  
  1451. ## First user in list get one.
  1452. if [ -z "$last_uid" ]; then
  1453. files_for_uid="1"
  1454. last_uid="$uid"
  1455. else
  1456. if [ "$last_uid" = "$uid" ]; then
  1457. files_for_uid=$[$files_for_uid+1]
  1458. # echo "files for $uid : $files_for_uid"
  1459. else
  1460. # echo "Total files for $last_uid: $files_for_uid"
  1461. proc_reward_uid
  1462. unset last_uid
  1463. files_for_uid=1
  1464. fi
  1465. fi
  1466. last_uid="$uid"
  1467. fi
  1468. done
  1469. # echo "Total files for $uid: $files_for_uid"
  1470. proc_reward_uid
  1471. # echo ""
  1472. # echo "$REWARD_LIST"
  1473. rm -f "/tmp/reqlist.tmp2"
  1474.  
  1475. # echo "total : $total_files"
  1476. # echo "total users: $total_users"
  1477. if [ "$leechers" ]; then
  1478. if [ "$leechers" = "1" ]; then
  1479. total_users="$total_users($leechers leecher)"
  1480. else
  1481. total_users="$total_users($leechers leechers)"
  1482. fi
  1483. fi
  1484. last_subdir="$subdir"
  1485. }
  1486.  
  1487. proc_reward_uid() {
  1488. # echo "uid : $last_uid"
  1489. # echo "files : $files_for_uid"
  1490. # echo "total_files: $total_files"
  1491. # echo "reward : $REWARD"
  1492. total_reward_for_uid=$[$REWARD/$total_files*$files_for_uid]
  1493. # echo "Reward uid : $total_reward_for_uid"
  1494. reward_username="`grep "^.*:.*:${last_uid}:" "$passwd" | cut -d ':' -f1 | head -n1`"
  1495. # echo "username : $reward_username"
  1496.  
  1497. if [ "$reward_username" ]; then
  1498. ## Check if RATIO is not 0 (leech).
  1499. if [ "`grep "^RATIO " "$usersdir/$reward_username" | grep "0"`" ]; then
  1500. if [ -z "$leechers" ]; then
  1501. leechers="1"
  1502. else
  1503. leechers=$[$leechers+1]
  1504. fi
  1505. else
  1506. # echo "Giving $reward_username $total_reward_for_uid MB credits"
  1507. current_credits_kb="`grep "^CREDITS\ " "$usersdir/$reward_username" | cut -d ' ' -f2`"
  1508. full_credits="`grep "^CREDITS\ " "$usersdir/$reward_username" | cut -d ' ' -f2-`"
  1509. add_credits_kb=$[$total_reward_for_uid*1024]
  1510. if [ "$current_credits_kb" ] && [ "$add_credits_kb" ]; then
  1511. new_credits_kb=$[$current_credits_kb+add_credits_kb]
  1512. if [ "$new_credits_kb" ]; then
  1513. # echo "New credits: $new_credits_kb"
  1514. NEWVALUES="`echo "$full_credits " | sed -e "s/[0-9]* /$new_credits_kb /"`"
  1515. # echo "new values: $NEWVALUES"
  1516. grep -v "^CREDITS\ " "$usersdir/$reward_username" > "/tmp/${reward_username}.tmp"
  1517. echo "CREDITS $NEWVALUES" >> "/tmp/${reward_username}.tmp"
  1518. if [ -e "$usersdir/${reward_username}.lock" ]; then
  1519. sleep 1
  1520. fi
  1521. cp -f "/tmp/${reward_username}.tmp" "$usersdir/$reward_username"
  1522. rm -f "/tmp/${reward_username}.tmp"
  1523. fi
  1524. fi
  1525.  
  1526. # echo "current credits: $current_credits_kb"
  1527.  
  1528. # echo ""
  1529. if [ -z "$REWARD_LIST" ]; then
  1530. REWARD_LIST="[ $reward_username=${files_for_uid}F=${total_reward_for_uid}MB ]"
  1531. else
  1532. REWARD_LIST="$REWARD_LIST [ $reward_username=${files_for_uid}F=${total_reward_for_uid}MB ]"
  1533. fi
  1534. fi
  1535. fi
  1536. }
  1537.  
  1538. proc_status() {
  1539. if [ "$auto" = "auto" ]; then
  1540. AUTO=TRUE
  1541. mode="gl"
  1542. fi
  1543.  
  1544. if [ "$mode" = "irc" ]; then
  1545.  
  1546. if [ "`echo "$arg1" | egrep -i "^request$|^reqdel$|^reqwipe$"`" ]; then
  1547. AUTO=TRUE
  1548. mode="gl"
  1549. fi
  1550.  
  1551. IRCOUTPUT="TRUE"
  1552. ## Make HEADER ##
  1553. OUTPUT="$STATUSANNOUNCE"
  1554. proc_cookies
  1555. HEADER="$OUTPUT"
  1556. else
  1557. IRCOUTPUT="FALSE"
  1558. fi
  1559.  
  1560. for each in `cat $reqfile | tr -s ' ' '^'`; do
  1561. FOUNDONE="TRUE"
  1562.  
  1563. ## Header stuff.
  1564. if [ "$SAIDIT" != "TRUE" -a "$STATUSHEAD" != "" -a "$NOHEADFOOT" != "TRUE" -a "$HIDE" != "TRUE" ]; then
  1565. OUTPUT="$STATUSHEAD"
  1566. proc_cookies
  1567. ## If its running 'status auto', always go to irc.
  1568. if [ "$AUTO" = "TRUE" ]; then
  1569. proc_output "$HEADER $OUTPUT"
  1570. else
  1571. echo "$HEADER $OUTPUT"
  1572. fi
  1573. SAIDIT="TRUE"
  1574.  
  1575. fi
  1576.  
  1577. ## Request. One per line in file.
  1578.  
  1579. LINETOSAY=`echo "$each" | tr -s '^' ' '`
  1580. OUTPUT="$LINETOSAY"
  1581. proc_cookies
  1582. if [ "$AUTO" = "TRUE" ]; then
  1583. proc_output "$HEADER $OUTPUT"
  1584. else
  1585. echo "$HEADER $OUTPUT"
  1586. fi
  1587.  
  1588. unset LINETOSAY
  1589. done
  1590. unset SAIDIT
  1591.  
  1592. ## Footer stuff.
  1593. if [ "$FOUNDONE" != "TRUE" -a "$AUTO" != "TRUE" -a "$HIDE" != "TRUE" ]; then
  1594. if [ "$mode" = "irc" ]; then
  1595. IRCOUTPUT="TRUE"
  1596. fi
  1597. OUTPUT="$NOREQUESTS"
  1598. proc_cookies
  1599. if [ "$AUTO" = "TRUE" ]; then
  1600. proc_output "$HEADER $OUTPUT"
  1601. else
  1602. echo "$HEADER $OUTPUT"
  1603. fi
  1604. fi
  1605.  
  1606. if [ "$FOUNDONE" = "TRUE" -a "$TOFILL" != "" -a "$NOHEADFOOT" != "TRUE" -a "$HIDE" != "TRUE" ]; then
  1607. if [ "$mode" = "irc" ]; then
  1608. IRCOUTPUT="TRUE"
  1609. fi
  1610. OUTPUT="$TOFILL"
  1611. proc_cookies
  1612. if [ "$AUTO" = "TRUE" ]; then
  1613. proc_output "$HEADER $OUTPUT"
  1614. else
  1615. echo "$HEADER $OUTPUT"
  1616. fi
  1617. fi
  1618. }
  1619.  
  1620. proc_sendmsg() {
  1621. if [ "$msgsdir" ]; then
  1622. if [ "$REQUESTFOR" ]; then
  1623.  
  1624. if [ -e "$usersdir/$REQUESTFOR" ]; then
  1625. ## -for: was specified. Sending message to that user.
  1626. # echo "--------------------------------------------------------------------------" >> $msgsdir/$REQUESTFOR
  1627. # echo "$RELEASE was requested by $REQUESTBY for you. $BY just $1 it. $2." >> $msgsdir/$REQUESTFOR
  1628. # echo "!HThis message was generated by Tur-Request $VER!0" >> $msgsdir/$REQUESTFOR
  1629. # echo " " >> $msgsdir/$REQUESTFOR
  1630. chmod 666 $msgsdir/$REQUESTFOR >/dev/null 2>&1
  1631. fi
  1632.  
  1633. ## cc is TRUE. Sending a carbon copy to the requester.
  1634. if [ "$cc" = "TRUE" -a "$REQUESTBY" ]; then
  1635. if [ -e "$usersdir/$REQUESTBY" ]; then
  1636. if [ "$BY" != "$REQUESTBY" ]; then
  1637. # echo "--------------------------------------------------------------------------" >> $msgsdir/$REQUESTBY
  1638. # echo "You requested $RELEASE for $REQUESTFOR. This has been $1 by $BY." >> $msgsdir/$REQUESTBY
  1639. # echo "!HThis message was generated by Tur-Request $VER!0" >> $msgsdir/$REQUESTBY
  1640. # echo " " >> $msgsdir/$REQUESTBY
  1641. chmod 666 $msgsdir/$REQUESTBY >/dev/null 2>&1
  1642. fi
  1643. fi
  1644. fi
  1645.  
  1646. else
  1647. ## No -for: was specified. Its for himself.
  1648. if [ "$REQUESTBY" ]; then
  1649. if [ -e "$usersdir/$REQUESTBY" ]; then
  1650. if [ "$REQUESTBY" != "$BY" ]; then
  1651. # echo "--------------------------------------------------------------------------" >> $msgsdir/$REQUESTBY
  1652. # echo "Your request for $RELEASE has been $1 by $BY. $2!" >> $msgsdir/$REQUESTBY
  1653. # echo "!HThis message was generated by Tur-Request $VER!0" >> $msgsdir/$REQUESTBY
  1654. # echo " " >> $msgsdir/$REQUESTBY
  1655. chmod 666 $msgsdir/$REQUESTBY >/dev/null 2>&1
  1656. fi
  1657. fi
  1658. fi
  1659. fi
  1660.  
  1661. fi
  1662. }
  1663.  
  1664. ## Here there be main menu, yar.
  1665. case $RUN in
  1666. request) name="request"; proc_verify; proc_request ;;
  1667. reqfilled) name="reqfill"; proc_verify; proc_reqfilled ;;
  1668. reqdel) name="reqdel"; reqdel=TRUE; proc_verify; proc_reqfilled ;;
  1669. reqwipe) name="reqwipe"; reqwipe=TRUE; proc_verify; proc_reqfilled ;;
  1670. status) name="status"; auto="$2"; proc_status ;;
  1671. fix) name="fix"; proc_reorder ;;
  1672. checkold) name="checkold"; proc_checkfile; proc_checkold ;;
  1673. *) echo "Hm, didnt get any reasonable action (${@}). Dont run this from shell." ;;
  1674. esac
  1675.  
  1676. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement