All pastes #613671 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-11 03:26 UTC
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;
	}



$photo_location  = 'gallery/';
		$unsorted = scandir($photo_location);

        foreach ($unsorted as $filename) {

                if (ereg("jpg", $filename) && !ereg("thumb",$filename)) {

                        $photos[] .= $filename;
                    }
                        
                          if (ereg("jpg", $filename) && !ereg("thumb",$filename)) {

                        $thumbnails[] .= $filename;
                    }
                }

for ($i = 0; $i < (count($photos)); $i++) {
		$photoArray .= '<li><a href="?page_name=viewpic&amp;pic=' . $photos[$i] . '"><img src="' . $photo_location . $thumbnails[$i]. '" alt="" title="&copy; 2007 Calfee Welding, Inc."/><img src="' . $photo_location . $thumbnails[$i]. '" alt="" title="&copy; 2007 Calfee Welding, Inc." class="preview" /></a></li>';	
	}



	$sql = "SELECT * FROM `wwf_template`";
	
	$result = mysql_query($sql) or die(mysql_error());
	
	while($html = mysql_fetch_assoc($result)) {
		
		$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `wwf_page` where `page_name` = '$page_name'"));
		if ($row['page_code'] == null)
			$row['page_code'] = "<h2>Coming soon.</h2>";
		$values = array(
			
						"WWF_CONTENT" => parse($row['page_code'], array(
	"PHOTOS" => $photoArray 
				)),
			"PAGE_TITLE" => $row['page_title']
			"PHOTOS" => $photoArray
							);
		echo parse($html['template_code'], $values);
	}
?>