Changeset 57
- Timestamp:
- 03/01/08 19:57:01 (10 months ago)
- Location:
- trunk/awkbot/src
- Files:
-
- 2 modified
-
awkpaste.awk (modified) (4 diffs)
-
mysql.awk (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/awkbot/src/awkpaste.awk
r56 r57 3 3 #import <cgi-lib.awk> 4 4 #import <config.awk> 5 #import <tempfile.awk> 5 6 #import <awkbot_db_mysql.awk> 6 7 7 8 BEGIN { 8 9 cgi_params(query) 9 cgi_headers("text/ plain")10 cgi_headers("text/html") 10 11 11 12 config_load("etc/awkbot.conf") … … 19 20 subject = paste["subject"] 20 21 content = paste["content"] 22 link = sprintf("%s?id=%d", config("paste.cgi"), id) 21 23 22 gsub(/\\n/, "\n", content) 24 gsub(/\r\\n/, "\n", content) 25 gsub(/\\\t/, "\t", content) 26 gsub(/\\\\/, "\\", content) # Outcoming escapes 23 27 } 24 28 else { … … 32 36 # This has synchronization issues...but what the hell, this is awk 33 37 id = awkbot_db_paste_last() 38 link = sprintf("%s?id=%d", config("paste.cgi"), id) 34 39 35 40 if (id) { 36 printf("say %s %s pasted %s at %s ?id=%s\n", \41 printf("say %s %s pasted %s at %s\n", \ 37 42 config("paste.channel"), nick, subject,\ 38 config("paste.cgi"), id) >> stream43 link) >> stream 39 44 40 45 close(stream) … … 42 47 } 43 48 49 workfile = tempfile("paste") 50 template = workfile ".html" 44 51 45 print "Id:", id 46 print "Nick:", nick 47 print "Subject:", subject 48 print content 52 print content > workfile 53 close(workfile) 54 55 system("vim -i NONE -c \"syn on\" -c \"set syntax=awk\" -c \"set nu\"" \ 56 " -c TOhtml -c wq -c q " workfile " &> /dev/null") 57 58 while (getline content < template) { 59 print content 60 61 # Ghetto little thing to inject a title 62 if (content ~ /<body/) { 63 print "<h1>AWK Paste:", "<a href=\"" link "\"/>" id "</a></h1>" 64 print "<p><b>Nick:", nick, "<br/>" 65 print "Subject:", subject, "<br/>" 66 print "</b></p><hr/>" 67 } 68 } 69 close(template) 70 71 # print "Id:", id 72 # print "Nick:", nick 73 # print "Subject:", subject 74 # print content 75 76 system("rm " workfile) 77 system("rm " template) 49 78 } -
trunk/awkbot/src/mysql.awk
r39 r57 111 111 112 112 function mysql_quote (string, result) { 113 result = gensub("([^\\\\])'", "\\1\\\\'", "g", string) 113 gsub(/\\/, "\\\\", string) 114 result = gensub(/(['\''"])/, "\\\\\\1", "g", string) 114 115 return "'" result "'" 115 116 }