1 # ===================================================================== 2 # pingSpecial: send trackback pings to special remote XML-RPC servers. 3 # 4 # Copyright (c) 2007,2008 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 # string pingSpecial(string ofile, string service [, string origin,\ 23 # string destination]) 24 # 25 # Supported service names: 26 # 27 # technorati = Technorati, see http://technorati.com/developers/ping/ 28 # 29 # The output file "ofile" must be appended to, not to overwrite stuff 30 # that may already have been written to it by _userproc(_O_REQUEST). 31 # ===================================================================== 32 33 function pingSpecial(ofile,svc,src,dst, len,rpc,tmp) { 34 35 if (ofile !~ /^\/.+/) ofile = "/dev/null" # just in case 36 37 len = 194 # XML-RPC envelope size. 38 39 if (svc == "technorati") { 40 rpc = "weblogUpdates.ping" 41 src = _xmlencode(_rcget("tbl_group.g_descr",1)) 42 tmp = _rcget("TNS_GROUP_HOME",2) 43 if (tmp == _NULL) tmp = _rcget("TNS_GROUP_HOME",1) 44 45 # Currently I prefer to override the actual group 46 # home-page with a safe bet. 47 tmp = "tw-recent-pages" 48 49 dst = _xmlencode(ENVIRON["CSA_RPC_URI"] "/" \ 50 ENVIRON["CSA_LANG"] "/" \ 51 _rcget("cgi.group",1) "/" tmp) 52 53 len += length(rpc src dst) 54 55 print "pbserver=(rpc.technorati.com 80 /rpc/ping)" >> ofile 56 } 57 58 # insert more special service names below as needed. 59 60 # else if ... 61 62 # Technorati does not seem to like being pinged too frequently, 63 # so I ping it at most once per queue run. 64 65 print "if (!~ $technorati done) {\n" \ 66 "if (~ $#pbserver 3) { # need host,port,path\n" \ 67 "{echo POST $pbserver(3) HTTP/1.0\n" \ 68 "echo Host: $pbserver(1)\n" \ 69 "cat <<'EOF'\n" \ 70 "User-Agent: CSA/" ENVIRON["CSA_VERSION"] "\n" \ 71 "Content-Type: text/xml\n" \ 72 "Content-Length: " len "\n\n\n" \ 73 "\n" \ 74 "" rpc "\n" \ 75 "\n\n" src \ 76 "\n\n\n" dst \ 77 "\n\n\n" \ 78 "\nEOF\n}|" \ 79 "nc -w 10 $pbserver(1) $pbserver(2);sleep 1}\n" \ 80 "technorati=done\n}\n" >> ofile 81 } 82 83 # EOF