1 # ===================================================================== 2 # blogger.setTemplate.awk: Blogger API 1.0 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,a,tmp) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 bloggerAuth() # BloggerAPI 30 31 # target group 32 split(_request("2_1",1),a,".") 33 34 # Handle numeric page specification. 35 if (a[2] == _NULL && (a[1]/=1)) { 36 tmp = ENVIRON["CSA_ROOT"] "/var/nodes/" \ 37 substr(a[1],1,1) "/" substr(a[1],2,1) "/" \ 38 substr(a[1],3,1) "/" a[1] 39 40 getline value < tmp; close(tmp) 41 split(value,a,"/") 42 _rcset("cgi.numeric","on") # tell the caller. 43 } 44 45 if (_LANG[a[1]] != _NULL) _rcset("CSA_LANG",a[1]) 46 47 # group must not be null and it may not contain the 48 # unescaped ``.'' character. 49 50 if (value != _NULL && value !~ /\./) { 51 _rcset("cgi.group",unixify(value)) 52 _rcset("cgi.group.literal",value) 53 } 54 55 # Large templates are treated like attachments by CSA, not 56 # to bloat the underlying shell script environment. 57 58 if (_request("5_1",1,_O_UPNAME) == "5_1" && \ 59 (value=_request("5_1",1,_O_ATTACH)) != "/dev/null") 60 _rcset("cgi.tpl.file",value) 61 62 # Small templates are saved in a scalar value. 63 else if ((value=_request("5_1",1)) != _NULL) 64 _rcset("cgi.tpl.text",value) 65 66 if (tolower(value=_request("6_1",1)) == "archiveindex") 67 _rcset("cgi.tpl","ta") 68 69 # The following test is necessary since the address could, 70 # at least in theory, have been set to any string by the 71 # remote user, due to how it is handled to cope with stunnel(8) 72 # and the lack of transproxy support in kernel 2.4.x. 73 74 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 75 value = ENVIRON["REMOTE_ADDR"] 76 else value = "0.0.0.0" 77 78 _rcset("REMOTE_ADDR",value) 79 } 80 81 else { # response. 82 83 # generic template conditionals. 84 85 ifsections() 86 } 87 } 88 89 # EOF