Sorry, $file's source only shown "; echo ($start && $stop) ? "between $start and $stop" : ($start ? "after $start" : "before $stop"); echo ".

\n"; } if ($return) { return ob_get_clean(); } else { ob_end_flush(); } } /** show_source_after: Call show_source if after a selected date, else show a 'denied' message. * @param $file (string) the name of the file to show the source of. * @param $start (string) when the file should start showing, in a format `strtotime` understands ('Y-m-D' or 'Y-m-D H:m') * @param $return (boolean) Return a string, rather than printing directly to stdout? * @see show_source_between show_source_until */ function show_source_after( $file, $start, $return=false ) { return show_source_between($file,$start,null,$return); } /** show_source_between: Call show_source if after a selected date, else show a 'denied' message. * @param $file (string) The name of the file to show the source of. * @param $stop (string) When the file should stop showing, in a format `strtotime` understands ('Y-m-D' or 'Y-m-D H:m') * @param $return (boolean) Return a string, rather than printing directly to stdout? * @see show_source_between show_source_after */ function show_source_until( $file, $stop, $return=false ) { return show_source_between($file,null,$stop,$return); } /* collapseWhitespace: * @param $str THe string to collapse. * @return A string like `$str`, except each block of horizontal-whitespace collapsed to a single (ordinary) space. * Each vertical-whitespace normalized to '\n', and whitespace around the \n trimmed away. */ function collapseWhitespace( $str ) { return trim( preg_replace( '/\h+/', ' ', preg_replace( '/(\h*\v\h*)+/', "\n", $str ) ) ); } /** Test that the actual-output-string is as expected. * @param $act (string) The actual result from a test-case. * @param $exp (string) The expected *prefix* from a test-case. * If the test fails, an error message is printed. * If the test passes, output is only printed if SHOW_SUCCESSFUL_TEST_OUTPUT. */ function test( $act, $exp ) { if ($act===$exp) { // Test passed. if (SHOW_SUCCESSFUL_TEST_OUTPUT) { echo "."; } } else { echo "test failed: '$act' doesn't match '$exp'."; } } /** Test that the actual-output-string is as expected, up to whitespace. * @param $act (string) The actual result from a test-case. * @param $exp (string) The expected *prefix* from a test-case. * If the test fails, an error message is printed. * If the test passes, output is only printed if SHOW_SUCCESSFUL_TEST_OUTPUT. * @see collapseWhitespace */ function testUpToWhitespace( $act, $exp ) { test( collapseWhitespace($act), collapseWhitespace($exp) ); } /* debug: string -> None * A wrapper for writing to stderr (so we can easily enable/disable it as needed). */ function debug($msg) { $stderr = fopen('php://stderr', 'w'); fwrite($stderr,">>> $msg\n"); fclose($stderr); } ?>