Annotation of win32/dist.x64/config/auto.p, revision 1.3

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

E-mail: