1 # ===================================================================== 2 # editPage.awk: RPC I/O function for rpclib/editPage. 3 # 4 # Copyright (c) 2007,2008,2009,2010 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # void _userproc(int mode) 23 # ===================================================================== 24 25 function _userproc(mode, value,tmp) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 # target group 30 value = _request("1",1) 31 32 # group must not be null and it may not contain the 33 # unescaped ``.'' character. 34 35 if (value != _NULL && value !~ /\./) { 36 _rcset("cgi.group",unixify(value)) 37 _rcset("cgi.group.literal",value) 38 } 39 40 # target page within group. 41 value = _request("2",1) 42 43 # page name must be at least 2-character long. 44 if (length(value) > 1) { 45 _rcset("cgi.page.literal",value) 46 value = unixify(value,1) 47 _rcset("cgi.page",value) 48 } 49 50 # optional author name. 51 if ((value=_request("twauthor",1)) != _NULL) { 52 gsub(/[\t\r\n<>]+/," ",value) 53 _rcset("cgi.author",substr(_strip(value,_O_MIDDLE),1,32)) 54 } 55 56 # Page revision (ISO date) 57 value = _request("3",1) 58 sub(/\+[0-9]+$/,_NULL,value) # Remove TZ if any. 59 if (_isdate(value) == _TRUE) _rcset("cgi.revision",value) 60 61 # The following test is necessary since the address could, 62 # at least in theory, have been set to any string by the 63 # remote user, due to how it is handled to cope with stunnel(8) 64 # and the lack of transproxy support in kernel 2.4.x. 65 66 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 67 value = ENVIRON["REMOTE_ADDR"] 68 else value = "0.0.0.0" 69 70 _rcset("REMOTE_ADDR",value) 71 } 72 73 else { # response. 74 75 # set generic template conditionals. 76 ifsections() 77 78 # Default page title to page name and set page subcat name if any. 79 80 value = tmp = _rcget("tpl.var.tw.page",1) 81 82 if ((tmp=getcat(tmp)) != _NULL) { 83 _response("tpl.var.tw.page.subcat",tmp) 84 sub(/[^.]+\./,_NULL,value) 85 _html("show","tpl.if.tw.subcat","tpl.fi.tw.subcat") 86 } else _html("hide","tpl.if.tw.subcat","tpl.fi.tw.subcat") 87 88 _response("tpl.var.html.title",value) 89 90 # Strip leading and trailing commas from group names. 91 value = _rcget("tbl_page.p_allow",1) 92 sub(/^,+/,"",value); sub(/,+$/,"",value) 93 _response("tpl.var.tw.allow",value) 94 95 value = _rcget("tbl_page.p_link",1) 96 _response("tpl.var.tw.link",value) 97 } 98 } 99 100 # EOF