From: Daniel Gruno Date: Mon, 14 May 2012 10:53:35 +0000 (+0000) Subject: Tidy up examples X-Git-Tag: 2.5.0-alpha~6817 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=478842e1b474dc1737f09138037e738e8612b8b6;p=apache Tidy up examples git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1338145 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/advanced.xml b/docs/manual/rewrite/advanced.xml index 1302e8b4e5..170959ed91 100644 --- a/docs/manual/rewrite/advanced.xml +++ b/docs/manual/rewrite/advanced.xml @@ -256,61 +256,61 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 $| = 1; # split the QUERY_STRING variable -@pairs = split(/&/, $ENV{'QUERY_STRING'}); +@pairs = split( /&/, $ENV{'QUERY_STRING'} ); foreach $pair (@pairs) { -($name, $value) = split(/=/, $pair); -$name =~ tr/A-Z/a-z/; -$name = 'QS_' . $name; -$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; -eval "\$$name = \"$value\""; + ( $name, $value ) = split( /=/, $pair ); + $name =~ tr/A-Z/a-z/; + $name = 'QS_' . $name; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + eval "\$$name = \"$value\""; } -$QS_s = 1 if ($QS_s eq ''); -$QS_n = 3600 if ($QS_n eq ''); -if ($QS_f eq '') { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "<b>ERROR</b>: No file given\n"; -exit(0); +$QS_s = 1 if ( $QS_s eq '' ); +$QS_n = 3600 if ( $QS_n eq '' ); +if ( $QS_f eq '' ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: No file given\n"; + exit(0); } -if (! -f $QS_f) { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "<b>ERROR</b>: File $QS_f not found\n"; -exit(0); +if ( !-f $QS_f ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: File $QS_f not found\n"; + exit(0); } sub print_http_headers_multipart_begin { -print "HTTP/1.0 200 OK\n"; -$bound = "ThisRandomString12345"; -print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; -&print_http_headers_multipart_next; + print "HTTP/1.0 200 OK\n"; + $bound = "ThisRandomString12345"; + print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; + &print_http_headers_multipart_next; } sub print_http_headers_multipart_next { -print "\n--$bound\n"; + print "\n--$bound\n"; } sub print_http_headers_multipart_end { -print "\n--$bound--\n"; + print "\n--$bound--\n"; } sub displayhtml { -local($buffer) = @_; -$len = length($buffer); -print "Content-type: text/html\n"; -print "Content-length: $len\n\n"; -print $buffer; + local ($buffer) = @_; + $len = length($buffer); + print "Content-type: text/html\n"; + print "Content-length: $len\n\n"; + print $buffer; } sub readfile { -local($file) = @_; -local(*FP, $size, $buffer, $bytes); -($x, $x, $x, $x, $x, $x, $x, $size) = stat($file); -$size = sprintf("%d", $size); -open(FP, "<$file"); -$bytes = sysread(FP, $buffer, $size); -close(FP); -return $buffer; + local ($file) = @_; + local ( *FP, $size, $buffer, $bytes ); + ( $x, $x, $x, $x, $x, $x, $x, $size ) = stat($file); + $size = sprintf( "%d", $size ); + open( FP, "<$file" ); + $bytes = sysread( FP, $buffer, $size ); + close(FP); + return $buffer; } $buffer = &readfile($QS_f); @@ -318,30 +318,30 @@ $buffer = &readfile($QS_f); &displayhtml($buffer); sub mystat { -local($file) = $_[0]; -local($time); + local ($file) = $_[0]; + local ($time); -($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file); -return $mtime; + ( $x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime ) = stat($file); + return $mtime; } $mtimeL = &mystat($QS_f); -$mtime = $mtime; -for ($n = 0; $n &lt; $QS_n; $n++) { -while (1) { - $mtime = &mystat($QS_f); - if ($mtime ne $mtimeL) { - $mtimeL = $mtime; - sleep(2); - $buffer = &readfile($QS_f); - &print_http_headers_multipart_next; - &displayhtml($buffer); - sleep(5); - $mtimeL = &mystat($QS_f); - last; +$mtime = $mtime; +for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { + while (1) { + $mtime = &mystat($QS_f); + if ( $mtime ne $mtimeL ) { + $mtimeL = $mtime; + sleep(2); + $buffer = &readfile($QS_f); + &print_http_headers_multipart_next; + &displayhtml($buffer); + sleep(5); + $mtimeL = &mystat($QS_f); + last; + } + sleep($QS_s); } - sleep($QS_s); -} } &print_http_headers_multipart_end; diff --git a/docs/manual/rewrite/rewritemap.xml b/docs/manual/rewrite/rewritemap.xml index 79010f8026..47e247f4d2 100644 --- a/docs/manual/rewrite/rewritemap.xml +++ b/docs/manual/rewrite/rewritemap.xml @@ -416,9 +416,11 @@ this process, or if the script itself is very slow.

If a query returns more than one row, a random row from the result set is used.

- Example + Example + RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s" +