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

E-mail: