"pdf-o-matic.php": //// "$Id: pdf-o-matic.php,v 1.25.2.5 2005/03/16 16:01:38 mike Exp $"//// Convert a web page to PDF, or show a form to get the URL...//// Copyright 2001-2004 by Easy Software Products. This code may be// freely used, and distributed under the terms of the HTMLDOC// software license.//// HTML functions for HTMLDOC pages...//// This include file contains the following functions://// htmldoc_header($title = "")// htmldoc_footer()//// Both just put out a standard web page header (
)// and trailer () - provide your own implementation// if you use this script, e.g.://// function// htmldoc_header($title = "") // I - Title string// {// print("PDF-o-matic is a simple PHP script " ."(view source) " ."that uses HTMLDOC to convert the web page of your choice. " ."Enter a URL to be converted to PDF and click on the " ."Make PDF! button:
\n" ."\n"); print("Please make sure that your HTML code is error free and that all " ."the elements are supported with HTMLDOC. " ."Chapter 6 of the HTMLDOC " ."Users Manual lists the elements that are supported.
\n"); print("| Server: | " ."Dual 2.4GHz Xeon with 2GB RAM running Linux | " ."
|---|---|
| Status: | "); system("ps -A | awk '{print $4}' | grep htmldoc | wc -l"); print("copies of HTMLDOC running System load average = "); system("uptime | awk '{printf(\"%.2f\", ($10 + $11 + $12) / 3)}'"); print(" |
\"pdf-o-matic.php\":\n"); highlight_file("pdf-o-matic.php"); print("\n" ."\n" ."\n");}else if (array_key_exists("URL", $_GET)){ // Yes, see if the URL is a valid URL and not a filename (security...) $url = $_GET["URL"]; $options = ""; if (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") $self = "https://$_SERVER[HTTP_HOST]$PHP_SELF"; else $self = "http://$_SERVER[HTTP_HOST]$PHP_SELF"; if (bad_url($url)) { // Write the standard header... htmldoc_header("PDF-o-matic"); // Show a form for the URL... show_form(); // Show an error message... print("Error!
\n" ."\"$url\" is not a valid URL. Unable to process!
\n"); // Show the standard footer... htmldoc_footer(); } else if (array_key_exists("HTTP_REFERER", $_SERVER) && $self != $_SERVER["HTTP_REFERER"]) { // Write the standard header... htmldoc_header("PDF-o-matic"); // Show an error message - no remote linking! print("Error!
\n" ."PDF-o-matic was linked from a remote site, which is " ."not allowed.
\n"); // Show the standard footer... htmldoc_footer(); } else topdf($url, "--header t.D --footer ./. --size letter --left 0.5in");}else{ // Write the standard header... htmldoc_header("PDF-o-matic"); // Show a form for the URL... show_form(); // Show the standard footer... htmldoc_footer();}?>