1 |
<?php |
2 |
// Load globals |
3 |
require_once ("global_vars.php"); |
4 |
|
5 |
// Includes |
6 |
require_once ("db_connect.php"); |
7 |
require_once ("public_controls.php"); |
8 |
|
9 |
// Cast as integer to be sure |
10 |
$page_id = (int) $page_id; |
11 |
|
12 |
// Error flag |
13 |
$err_code = 0; |
14 |
|
15 |
// Continue only if we now have a valid page |
16 |
if ($page_id > 0 ) { |
17 |
|
18 |
// Check to see if it exists first |
19 |
$exists = 0; |
20 |
$exists = existsRow($con, "page", "page_id", $page_id); |
21 |
|
22 |
if ($exists > 0) { |
23 |
|
24 |
// Build the SQL to extract the static snapshot |
25 |
$sql = "SELECT pageHTML from page WHERE page_id = " . $page_id; |
26 |
$rs = mysql_query($sql, $con); |
27 |
$row = mysql_fetch_array ($rs); |
28 |
|
29 |
// Fetch data |
30 |
$pageHTML = $row["pageHTML"]; |
31 |
|
32 |
// Dump the page |
33 |
if (strlen($pageHTML) > 0) printf("%s", $pageHTML); |
34 |
else $err_code = 1; // No data. Unpublished page? |
35 |
} |
36 |
else $err_code = 2; // Page ID doesn't exist. |
37 |
} |
38 |
|
39 |
else $err_code = 3; // Invalid incoming page ID. |
40 |
|
41 |
|
42 |
// Generic error message. May be customized. |
43 |
if ($err_code > 0) { |
44 |
|
45 |
printf("Page not found..."); |
46 |
|
47 |
} |
48 |
?> |