Annotation of parser3/etc/auto.p.in, revision 1.3
1.3 ! moko 1: #$Id: auto.p.in,v 1.2 2020/12/09 15:36:45 moko Exp $
1.1 moko 2:
3: @conf[filespec]
4: $confdir[^file:dirname[$filespec]]
5: $charsetsdir[$confdir/charsets]
6: $sqldriversdir[$confdir/lib]
7:
8: $CHARSETS[
9: # $.cp866[$charsetsdir/cp866.cfg]
10: # $.koi8-r[$charsetsdir/koi8-r.cfg]
11: # $.koi8-u[$charsetsdir/koi8-u.cfg]
12: # $.windows-1250[$charsetsdir/windows-1250.cfg]
13: # $.windows-1251[$charsetsdir/windows-1251.cfg]
14: # $.windows-1254[$charsetsdir/windows-1254.cfg]
15: # $.windows-1257[$charsetsdir/windows-1257.cfg]
16: # $.x-mac-cyrillic[$charsetsdir/x-mac-cyrillic.cfg]
17: ]
18:
19: #change your client libraries paths to those on your system
20: $SQL[
21: $.drivers[^table::create{protocol driver client
22: mysql $sqldriversdir/libparser3mysql.@dll_extension@ libmysqlclient.@dll_extension@
23: #sqlite $sqldriversdir/libparser3sqlite.@dll_extension@ libsqlite3.@dll_extension@
24: #pgsql $sqldriversdir/libparser3pgsql.@dll_extension@ libpq.@dll_extension@
25: #oracle $sqldriversdir/libparser3oracle.@dll_extension@ libclntsh.@dll_extension@
26: }]
27: ]
28:
29: #for ^file::load[name;user-name] mime-type autodetection
30: $MIME-TYPES[^table::create{ext mime-type
31: 7z application/x-7z-compressed
32: avi video/x-msvideo
33: bmp image/bmp
34: css text/css
35: cvs text/csv
36: doc application/msword
37: docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
38: dtd application/xml-dtd
39: gif image/gif
40: gz application/x-gzip
41: htm text/html
42: html text/html
43: ico image/x-icon
44: jpeg image/jpeg
45: jpg image/jpeg
46: js application/javascript
47: json application/json
48: log text/plain
49: mov video/quicktime
50: mp3 audio/mpeg
51: mp4 video/mp4
52: mpg video/mpeg
53: mpeg video/mpeg
54: mts application/metastream
55: otf font/otf
56: pdf application/pdf
57: png image/png
58: ppt application/powerpoint
59: rar application/vnd.rar
60: rdf application/rdf+xml
61: rss application/rss+xml
62: rtf application/rtf
63: svg image/svg+xml
64: tar application/x-tar
65: tgz application/x-gzip
66: tif image/tiff
67: tiff image/tiff
68: ttf font/ttf
69: txt text/plain
70: wav audio/x-wav
71: xls application/vnd.ms-excel
72: xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
73: xml text/xml
74: xsl text/xml
75: webm video/webm
76: webp image/webp
77: woff font/woff
78: woff2 font/woff2
79: zip application/zip
80: }]
81:
82: $LIMITS[
83: $.post_max_size(10*0x400*0x400)
84: ]
85:
86: #$MAIL[
87: # $.sendmail[your sendmail command goes here]
88: # these are tried when no 'sendmail' specified:
89: # /usr/sbin/sendmail -t -i -f postmaster
90: # /usr/lib/sendmail -t -i -f postmaster
91: #]
92:
93:
94: @fatal_error[title;subtitle;body]
95: $response:status(500)
96: $response:content-type[
97: $.value[text/html]
98: $.charset[$response:charset]
99: ]
100: <html>
101: <head><title>$title</title></head>
102: <body>
103: <h1>^if(def $subtitle){$subtitle;$title}</h1>
104: $body
105: #for [x] MSIE friendly
106: ^for[i](0;512/8){<!-- -->}
107: </body>
108: </html>
109:
110:
111: @unhandled_exception_debug[exception;stack]
112: ^fatal_error[Unhandled Exception^if(def $exception.type){ ($exception.type)};$exception.source;
113: <pre>^untaint[html]{$exception.comment}</pre>
114: ^if(def $exception.file){
115: ^untaint[html]{<tt>$exception.file^(${exception.lineno}:$exception.colno^)</tt>}
116: }
117: ^if($stack){
118: <hr/>
119: <table>
120: ^stack.menu{
121: <tr><td>$stack.name</td><td><tt>$stack.file^(${stack.lineno}:$stack.colno^)</tt></td></tr>
122: }
123: </table>
124: }
125: ]
126:
127:
128: @unhandled_exception_release[exception;stack]
129: ^fatal_error[Unhandled Exception;;
130:
131: <p>The server encountered an unhandled exception and was unable to complete your request.</p>
132: <p>Please contact the server administrator, $env:SERVER_ADMIN and inform them of the time the error occurred, and anything you might have done that may have caused the error.</p>
133: <p>More information about this error may be available in the Parser error log or in debug version of unhandled_exception.</p>
134:
135: ]
136:
137:
138: @is_developer[]
139: #change mask to your ip address
140: $result(def $env:REMOTE_ADDR && ^env:REMOTE_ADDR.match[^^127\.0\.0\.1^$])
141:
142:
143: @unhandled_exception[exception;stack]
144: #developer? use debug version to see problem details
145: ^if(^is_developer[]){
146: ^unhandled_exception_debug[$exception;$stack]
147: }{
148: ^if($exception.type eq "file.missing"){
149: # ^log404[]
150: # ^location[/404/]
151: $response:status(404)
152: }{
153: ^unhandled_exception_release[$exception;$stack]
154: }
155: }
156:
157:
1.2 moko 158: @httpd-include[filename]
159: ^use[$filename; $.main(true) ]
160: ^main[]
161:
162: @httpd-index[dir][list]
163: ^fatal_error[Index of $dir;Index of $dir;
164: $list[^file:list[$dir]]
165: ^list.sort{^if($list.dir)[0;1] $list.name}
166: ^list.menu{
167: <a href="$list.name^if($list.dir){/}">^if($list.dir){/}$list.name</a><br/>
168: }
169: ]
170: $response:status(200)
171:
172: @httpd-option[option]
173: $result[^if($option is junction){^option[]}(^option.match[$httpd.parser]){^httpd-include[$option]}{$option}]
174:
175: @httpd-file[filename]
176: $result[^if(^filename.match[$httpd.parser]){^httpd-include[$filename]}{$response:body[ $.file[$filename] $.name[] ]}]
177:
178: @httpd-log[filename;detail][now;line]
179: $now[^date::now[]]
180: $line[$env:REMOTE_ADDR [^now.sql-string[]] "$request:method $request:uri"$detail^#0A]
181: ^line.save[append;$filename]
182:
183: @httpd-404[]
1.3 ! moko 184: $response:status[404]
1.2 moko 185: The requested URL was not found on this server.
186:
187:
188: @httpd-main[][uri;basic]
189:
190: $httpd[
191: $.parser[(\.html^$)]
192: $.index[index.html]
193: # $.autoindex(true)
194: $.404[$httpd-404]
195: # $.404[/_doc.html]
196: $.auth[ $.url[^^/\.?admin/] $.login[admin] $.password[test] $.realm[site administration] ]
197: $.deny[(/\.ht[^^/]+|\.p|\.cfg)^$]
198: $.403[Permission denied]
199: $.memory(64000)
200: $.log[/access.log]
201: ]
202:
203: $response:server[Parser$env:PARSER_VERSION]
204: $response:date[^date::now[]]
205: $response:connection[close]
206: $uri[^request:uri.match[\?.*][]{}]
207: $uri[^string:unescape[uri;$uri; $.charset[UTF-8] ]]
208:
209: ^if(def $httpd.log){
210: ^httpd-log[$httpd.log]
211: }
212: ^if(def $httpd.memory && $status:memory.ever_allocated_since_compact > $httpd.memory){
213: ^memory:compact[]
214: }
215:
216: ^if(def $httpd.auth.url && ^uri.match[$httpd.auth.url]){
217: $basic[$httpd.auth.login:$httpd.auth.password]
218: ^if($env:HTTP_AUTHORIZATION ne "Basic ^basic.base64[]"){
219: $response:WWW-Authenticate[Basic realm="$httpd.auth.realm"]
220: ^return[$response:status[401]]
221: }
222: $env:REMOTE_USER[$httpd.auth.login]
223: }
224:
225: ^if(def $httpd.deny && ^uri.match[$httpd.deny]){
1.3 ! moko 226: $response:status[403]
1.2 moko 227: $result[^httpd-option[$httpd.403]]
228: }(def $httpd.index && -f "$uri/$httpd.index"){
229: $result[^httpd-file[$uri/$httpd.index]]
230: }($httpd.autoindex && -d "$uri"){
231: $result[^httpd-index[$uri]]
232: }(-f $uri){
233: $result[^httpd-file[$uri]]
234: }{
235: # $form:request[^uri.mid(1)]
236: $result[^httpd-option[$httpd.404]]
237: }
238:
239:
1.1 moko 240: @auto[]
241: #source/client charsets
242: $request:charset[utf-8]
243: $response:charset[utf-8]
244:
245: $response:content-type[
246: $.value[text/html]
247: $.charset[$response:charset]
248: ]
249:
250: #$SQL.connect-string[mysql://user:pass@host/db?charset=utf8]
251: #$SQL.connect-string[sqlite://db]
252: #$SQL.connect-string[pgsql://user:pass@host/db]
253: #$SQL.connect-string[odbc://DSN=datasource^;UID=user^;PWD=password]
E-mail: