Annotation of win32/dist/config/auto.p, revision 1.4

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.4     ! moko       98: #      $.max_file_size(512*0x400*0x400)
        !            99: #      $.max_loop(100000)
        !           100: #      $.max_array(1000000)
        !           101: #      $.max_recursion(1000)
1.2       moko      102: ]
1.1       misha     103: 
1.3       moko      104: #$HTTPD[
                    105: #      $.mode[threaded]
                    106: #]
                    107: 
1.1       misha     108: $MAIL[
1.3       moko      109:        $.SMTP[localhost]
1.1       misha     110: ]
                    111: 
                    112: 
                    113: @fatal_error[title;subtitle;body]
                    114: $response:status(500)
                    115: $response:content-type[
                    116:        $.value[text/html]
                    117:        $.charset[$response:charset]
                    118: ]
                    119: <html>
                    120: <head><title>$title</title></head>
                    121: <body>
                    122: <h1>^if(def $subtitle){$subtitle;$title}</h1>
                    123: $body
                    124: #for [x] MSIE friendly
                    125: ^for[i](0;512/8){<!-- -->}
                    126: </body>
                    127: </html>
                    128: 
                    129: 
                    130: @unhandled_exception_debug[exception;stack]
                    131: ^fatal_error[Unhandled Exception^if(def $exception.type){ ($exception.type)};$exception.source;
                    132: <pre>^untaint[html]{$exception.comment}</pre>
                    133: ^if(def $exception.file){
1.2       moko      134:        ^untaint[html]{<tt>$exception.file^(${exception.lineno}:$exception.colno^)</tt>}
1.1       misha     135: }
                    136: ^if($stack){
                    137:        <hr/>
                    138:        <table>
                    139:        ^stack.menu{
                    140:                <tr><td>$stack.name</td><td><tt>$stack.file^(${stack.lineno}:$stack.colno^)</tt></td></tr>
                    141:        }
                    142:        </table>
                    143: }
                    144: ]
                    145: 
                    146: 
                    147: @unhandled_exception_release[exception;stack]
                    148: ^fatal_error[Unhandled Exception;;
                    149: 
1.2       moko      150: <p>The server encountered an unhandled exception and was unable to complete your request.</p>
                    151: <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>
                    152: <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     153: 
                    154: ]
                    155: 
                    156: 
                    157: @is_developer[]
                    158: #change mask to your ip address
                    159: $result(def $env:REMOTE_ADDR && ^env:REMOTE_ADDR.match[^^127\.0\.0\.1^$])
                    160: 
                    161: 
                    162: @unhandled_exception[exception;stack]
                    163: #developer? use debug version to see problem details
                    164: ^if(^is_developer[]){
                    165:        ^unhandled_exception_debug[$exception;$stack]
                    166: }{
                    167:        ^if($exception.type eq "file.missing"){
1.3       moko      168: #              $response:location[/404/]
1.4     ! moko      169:                ^httpd:404[]
1.1       misha     170:        }{
                    171:                ^unhandled_exception_release[$exception;$stack]
                    172:        }
                    173: }
                    174: 
                    175: 
1.3       moko      176: @CLASS
                    177: httpd
                    178: 
                    179: @OPTIONS
                    180: partial
                    181: 
                    182: @auto[]
                    183: ^if(-f "/httpd.p"){
                    184:        ^use[/httpd.p]
                    185: }
                    186: 
                    187: @include[filename]
1.2       moko      188: ^use[$filename; $.main(true) ]
1.3       moko      189: ^MAIN:main[]
1.2       moko      190: 
1.3       moko      191: @index[dir][list]
1.2       moko      192: ^fatal_error[Index of $dir;Index of $dir;
                    193:        $list[^file:list[$dir]]
                    194:        ^list.sort{^if($list.dir)[0;1] $list.name}
                    195:        ^list.menu{
                    196:                <a href="$list.name^if($list.dir){/}">^if($list.dir){/}$list.name</a><br/>
                    197:        }
                    198: ]
                    199: $response:status(200)
                    200: 
1.3       moko      201: # option can be method, URL or text/code
                    202: @option[option]
                    203: $result[^if($option is junction){^option[]}(^option.match[$cfg.parser]){^include[$option]}{$option}]
1.2       moko      204: 
1.3       moko      205: @file[filename]
                    206: $result[^if(^filename.match[$cfg.parser]){^include[$filename]}{$response:body[ $.file[$filename] $.name[] ]}]
1.2       moko      207: 
1.3       moko      208: @log[filename;detail][now;line]
1.2       moko      209: $now[^date::now[]]
                    210: $line[$env:REMOTE_ADDR [^now.sql-string[]] "$request:method $request:uri"$detail^#0A]
                    211: ^line.save[append;$filename]
                    212: 
1.3       moko      213: @404[]
1.2       moko      214: $response:status[404]
                    215: The requested URL was not found on this server.
                    216: 
1.3       moko      217: @config[result]
                    218: 
                    219: @preprocess[return]
1.2       moko      220: 
                    221: 
1.3       moko      222: @main[result][basic]
                    223: 
                    224: #$request:document-root[/website/folder]
                    225: 
                    226: $cfg[^config[
                    227:        $.parser[\.(html)^$]
1.2       moko      228:        $.index[index.html]
                    229: #      $.autoindex(true)
1.3       moko      230:        $.404[$404]
                    231: #      $.404[/404.html]
                    232: #      $.fix-trailing-slash(true)
                    233: #      $.auth[ $.url[^^/\.?admin/] $.login[admin] $.password[change me] $.realm[site administration] ]
1.2       moko      234:        $.deny[(/\.ht[^^/]+|\.p|\.cfg)^$]
                    235:        $.403[Permission denied]
                    236:        $.memory(64000)
1.3       moko      237: #      $.log[/access.log]
                    238: ]]
1.2       moko      239: 
                    240: $response:server[Parser$env:PARSER_VERSION]
                    241: $response:date[^date::now[]]
                    242: $response:connection[close]
                    243: $uri[^request:uri.match[\?.*][]{}]
                    244: $uri[^string:unescape[uri;$uri; $.charset[UTF-8] ]]
                    245: 
1.3       moko      246: ^if(def $cfg.log){
                    247:        ^log[$cfg.log]
1.2       moko      248: }
1.3       moko      249: ^if(def $cfg.memory && $status:memory.ever_allocated_since_compact > $cfg.memory){
1.2       moko      250:        ^memory:compact[]
                    251: }
                    252: 
1.3       moko      253: ^if(def $cfg.auth.url && ^uri.match[$cfg.auth.url]){
                    254:        $basic[$cfg.auth.login:$cfg.auth.password]
1.2       moko      255:        ^if($env:HTTP_AUTHORIZATION ne "Basic ^basic.base64[]"){
1.3       moko      256:                $response:WWW-Authenticate[Basic realm="$cfg.auth.realm"]
                    257:                $response:status[401]
                    258:                ^return[Authorization Required]
1.2       moko      259:        }
1.3       moko      260:        $env:REMOTE_USER[$cfg.auth.login]
1.2       moko      261: }
                    262: 
1.3       moko      263: ^if(def $cfg.deny && ^uri.match[$cfg.deny]){
1.2       moko      264:        $response:status[403]
1.3       moko      265:        ^return[^option[$cfg.403]]
                    266: }(def $cfg.[fix-trailing-slash] && ^uri.match[^^[^^.]+[^^/.]^$]){
                    267:        ^return[$response:location[$uri/^if(def $request:query){?^taint[as-is;$request:query]}]]
                    268: }
                    269: 
                    270: ^preprocess{^return[]}
                    271: 
                    272: ^if(def $cfg.index && -f "$uri/$cfg.index"){
                    273:        $result[^file[$uri/$cfg.index]]
                    274: }($cfg.autoindex && -d "$uri"){
                    275:        $result[^index[$uri]]
1.2       moko      276: }(-f $uri){
1.3       moko      277:        $result[^file[$uri]]
1.2       moko      278: }{
1.3       moko      279:        $result[^option[$cfg.404]]
1.2       moko      280: }

E-mail: