rendered paste body<?php
header("content-type: text/html; charset=utf-8");
require_once "./dbconnect.php";
//require_once "./news.php";
//require_once "./ann.php";
$page_name = $_GET['page_name'];
if ($page_name == null)
$page_name = "index";
function parse($code, $vals) {
$results = array();
preg_match_all("/\{(\w+)\}/i", $code, $results, PREG_SET_ORDER);
for ($i=0; $i<count($results); $i++ )
$code = str_replace($results[$i][0], $vals[$results[$i][1]], $code);
return $code;
}
function dirscan($dir) {
$dh = opendir($dir);
while (false !== ($filenam = readdir($dh))) {
$files[] = $filenam;
}
}
$photo_location = 'gallery/images';
$unsorted = dirscan($photo_location);
foreach ($unsorted as $filename) {
if (!ereg("thumb",$filename) && ereg("jpg",$filename)) {
$photo_files[] .= $filename;
}
if (ereg("thumb",$filename)) {
$photo_thumb_files[] .= $filename;
}
}
for ($i = 0; $i < (count($photo_files)); $i++) {
$photo_photoArray .= '<li><a href="?page_name=viewpic&pic=' . $photo_files[$i] . '"><img src="' . $photo_location . $photo_thumb_files[$i]. '" alt="" title="© 2007 Calfee Welding, Inc." /><img src="' . $photo_location . $photo_thumb_files[$i]. '" alt="" title="© 2007 Calfee Welding, Inc." class="preview" /></a></li>';
if (!file_exists($photo_location . $photo_thumb_files[$i])) {
$photo_photoArray .= '<li><a href="?page_name=viewpic&pic=' . $photo_files[$i] . '"><img src="' . $photo_location . $photo_files[$i]. '" alt="" title="© 2007 Calfee Welding, Inc." /><img src="' . $photo_location . $photo_files[$i]. '" alt="" title="© 2007 Calfee Welding, Inc." class="preview" /></a></li>';
}
}
$sql = "SELECT * FROM `twh_template` WHERE `is_admin`='0'";
$user_menu_query = "SELECT * FROM `twh_template` WHERE `is_admin`='1' AND `template_id`='9'";
$user_menu_assoc = mysql_query($user_menu_query) or die('There was an error in your query.' . mysql_error());
$user_menu_result = mysql_fetch_assoc($user_menu_assoc);
$twhMenu = $user_menu_result['template_code'];
$result = mysql_query($sql) or die(mysql_error());
$dateToday = date("F j, Y");
$url = htmlspecialchars($_SERVER['REQUEST_URI']);
while($html = mysql_fetch_assoc($result)) {
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `twh_page` WHERE `page_name` = '$page_name'"));
$values = array(
"TWH_CONTENT" => parse($row['page_code'], array(
"DATE" => $dateToday,
"PHOTOS" => $photo_photoArray)),
"TWH_MENU" => $twhMenu,
"PAGE_TITLE" => $row['page_title']
);
echo parse($html['template_code'], $values);
}
?>