www.webdeveloper.com
Results 1 to 8 of 8

Thread: Maintaining Large Websites (input wanted)

  1. #1
    Join Date
    May 2014
    Posts
    13

    Exclamation Maintaining Large Websites (input wanted)

    There is a debate regards to the best way to maintain a large website with 10,000 + web pages (school related) how to maintain the site to allow global changes (header, menu, footer).

    All of the pages are currently designed in htm built using Dreamweaver template. The downfall of maintaining the site using this system is that when you make changes to Templates (Master or nested) templates on Dreamweaver, you have to upload every file on the site using the template.

    I am looking for other alternatives (if possible how to maintain the site with global change option) keeping the htm file extension.

    Ideas? If you would prefer to use serverside includes such as asp, php, or shtml do share, and tell me why.

  2. #2
    Join Date
    May 2014
    Posts
    631
    Well, that's why a CMS is used for a lot of sites -- generally what I've been doing lately on sites that are pretty much static content is instead of using a database driven CMS, I use what's called a "poor man's system" -- mine is actually pretty complex as it uses the 'one index to rule them all' using a htaccess whitelist and a real templating system...

    But you could easily do a dirt simple one using PHP by simply having:

    template.php
    Code:
    <?php
    
    function template_header(
    	$pageTitle = false,
    	$keywords = false,
    	$description = false
    ) {
    
    	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html
    	xmlns="http://www.w3.org/1999/xhtml"
    	lang="en"
    	xml:lang="en"
    ><head>
    
    <meta
    	http-equiv="Content-Type"
    	content="text/html; charset=utf-8"
    />
    
    <meta
    	http-equiv="Content-Language"
    	content="en"
    />
    
    <meta
    	name="viewport"
    	content="width=device-width; initial-scale=1.0"
    />';
    
    	if ($keywords) echo '
    	
    <meta
    	name="keywords"
    	content="', $keywords, '"
    />';
    
    	if ($description) echo '
    	
    <meta
    	name="description"
    	content="', $description, '"
    />';
    
    	
    
    echo '
    
    <link
    	type="text/css"
    	rel="stylesheet"
    	href="screen.css"
    	media="screen,projection,tv"
    />
    
    <title>
    	', ($pageTitle ? $pageTitle . ' - ' : ''), ' Site Title
    </title>
    
    </head><body>
    
    <div id="top" class="widthWrapper">
    
    	<h1>
    		Site Title
    		<span><!-- image replacement --></span>
    	</h1>
    
    	<ul id="mainMenu">
    		<li><a href="#">Home</a></li>
    		<li><a href="#">Forums</a></li>
    		<li><a href="#">FAQ</a></li>
    		<li><a href="#">ContactUs</a></li>
    	</ul>
    
    	<hr /><!-- remove if content starts with numbered heading -->
    
    	<div id="contentWrapper"><div id="content">';
    	// using double-wrapper for fluid content-first columns
    	
    } // template_header
    
    function template_footer($extrasFile = false) {
    	echo '
    	<!-- #content, #contentWrapper --></div></div>
    	
    	<div id="extras">';
    	
    	// any static / common to all pages sidebar stuff here
    	
    	if ($extrasFile) include($extrasFile . '.php');
    	
    	echo '
    	<!-- #extras --></div>
    	
    	<div id="footer">
    		Disclaimer / Other footer stuff here
    	<!-- #footer --></div>
    	
    <!-- #top.widthWrapper --></div>
    		
    } // template_footer
    
    ?>
    Which contains all the code that is common to every page. You then for example would have a 'index.php' like this:

    index.php:
    Code:
    <?php require_once('template.php'); template_header(
    	false, // don't show "pageTitle - Site title"
    	'seven,or,eight,words,that,exist,in,body', // keywords
    	'A short natural language description describing the site'
    ); ?>
    
    <h2>Content goes here</h2>
    <p>
    	This is where your page unique content would go!
    </p>
    
    <?php template_footer('normalExtras'); ?>
    The 'normalExtras.php' file would simply be the content you have in your sidebars. I do it as separate files so that sub-pages can have their own unique sidebar content instead of the same as every page.

    If for example, you had your FAQ:

    faq.php
    Code:
    <?php require_once('template.php'); template_header(
    	'Frequently Asked Questions', 
    	'frequently, questions, one, two, three', // keywords
    	'Frequently asked questions about "describe the site's purpose here"'
    ); ?>
    
    <h2>Frequently Asked Questions</h2>
    
    <h3>Question one?</h3>
    <p>
    	Answer to question one.
    </p>
    
    <h3>Question two?</h3>
    <p>
    	Answer to question two.
    </p>
    
    <h3>Question three?</h3>
    <p>
    	Answer to question three.
    </p>
    
    <?php template_footer('normalExtras.php'); ?>
    That's in essence a very basic poor mans -- and can easily be done in PHP, ASP, PERL -- even SHTML (an Apache only built-in SSI system)

    As to keeping the HTML extension, I'd set up a 301 "moved permanently" redirect handler to point at the new versions of the pages. A "one index to rule them all" system might be better suited to handling that -- particularly since you could then use a rewriterule to use "friendly" uri's... so instead of "/faq.html" it would just be "/faq". No extension needed. You could even keep the HTML extension if you parsed $_SERVER['request_uri'] server-side instead of trying to use some fancy htaccess parsing.

    For example, in .htaccess I usually use this:
    Code:
    RewriteEngine On
    RewriteRule !\.(gif|jpg|png|css|js|txt|ico|zip|gz|rar|pdf|xml|wav|mp3|mp4|mpg|flv|swf|mkv|ogg|avi|webm|woff|svg|eot|ttf)$ index.php
    It's a whitelist -- any file extension not on that list is routed to my index.php -- I use that one single index.php to parse $_SERVER thus:

    Code:
    <?php
    
    // define('TESTING', 1);
    
    define('CONTENT_ENCODING', 
    	(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) ? 'x-gzip' :
    	(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) ? 'gzip' :
    	false
    );
    
    define('CONTENT_ENCODING', false);
    
    if (CONTENT_ENCODING) {
    	ob_start();
    	ob_implicit_flush(0);
    	register_shutdown_function(function() { 
    		header('Content-Encoding: ' . CONTENT_ENCODING);
    		$contents = ob_get_contents();
    		ob_end_clean();
    		echo "\x1f\x8b\x08\x00\x00\x00\x00\x00",
    			substr(gzcompress($contents, 6), 0, -4);
    	});
    }
    
    function cleanPath($path) {
    	return trim(str_replace(['\\','%5C'],'/',$path),'/');
    }
    
    function bomb($title, $message) {
    	template_header('ERROR - ' . $title);
    	echo '
    		<div id="fatalError">
    			<h2>
    				',$title,'
    			</h2>
    			<p>',$message,'</p>
    			<p><strong>EXECUTION HALTED</strong></p>
    		<!-- #fatalError --></div>';
    	template_footer();
    	die;
    }
    
    final class request {
    	private static $data = [];
    	public static function value($index = 0, $clean = false) {
    		if ($index === true) { $index = 0; $clean = true; }
    		if (count(self::$data) == 0) {
    			$path = cleanPath(parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH));
    			if (strpos($path,'..')) bomb('hackingDetected', 'uptreeFail');
    			$path = substr($path, strlen(HTTP_ROOT) - 1);
    			self::$data = empty($path) ? ['default'] : explode('/',$path);
    			foreach (self::$data as &$p) $p = urldecode($p);
    		}
    		return isset(self::$data[$index]) ? (
    			$clean ? cleanName(self::$data[$index]) : self::$data[$index]
    		) : false;
    	}
    } // class request
    
    define('SCRIPT_FILENAME',cleanPath($_SERVER['SCRIPT_FILENAME']));
    define('HTTP_ROOT',str_ireplace('index.php','',$_SERVER['PHP_SELF']));
    define('LOCAL_ROOT',str_ireplace('index.php','',SCRIPT_FILENAME));
    define('HTTP_THEME', HTTP_ROOT . 'theme/');
    require_once('theme/index.template.php');
    require_once(
    	is_file($targetFile = 'statics/' . request::value() . '.php') ?
    	$targetFile :
    	'statics/404.php'
    );
    
    ?>
    That's actually lifted right straight from one of my sites. "cleanPath" strips out all slashes preventing loads from anywhere but /statics...

    /theme/index.template.php is pretty much identical to the above template.php

    /statics/default.php would be the default/home page, what would normally be a index.php or index.html

    The cute part is, that with the above system in place, you could make:

    /statics/faq.html.php

    ... and your url to that file would actually work as http://www.yoursite.uri/faq.html

    Kind of what you are looking for?
    Java is to JavaScript as Ham is to Hamburger.

  3. #3
    Join Date
    May 2014
    Posts
    13
    Now that is interesting. I have always just used the php extension name but then again, I have always built the site first using php (includes) or other.

    This does answer my question regards to our concerns keeping the html extension for the pages. However, I have to keep in mind regards to google search, search, and people that have already bookmarked the html pages. Every page would need the php (include) command line meaning, saving every page as .php. So if the htaccess file, do you have to add every single page or just index?

    As for the CMS, they have chosen one, which they build the template into the system. There is a lot of discussion using xml and sxlm working with the html extension pages. I have to say, that is out of my league, I have never actually seen this system in action. My hope is, that the CMS will allow global changes even with the pages as htm extension. So far I believe it does.



    Quote Originally Posted by deathshadow View Post
    Well, that's why a CMS is used for a lot of sites -- generally what I've been doing lately on sites that are pretty much static content is instead of using a database driven CMS, I use what's called a "poor man's system" -- mine is actually pretty complex as it uses the 'one index to rule them all' using a htaccess whitelist and a real templating system...

    But you could easily do a dirt simple one using PHP by simply having:

    template.php
    Code:
    <?php
    
    function template_header(
    	$pageTitle = false,
    	$keywords = false,
    	$description = false
    ) {
    
    	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html
    	xmlns="http://www.w3.org/1999/xhtml"
    	lang="en"
    	xml:lang="en"
    ><head>
    
    <meta
    	http-equiv="Content-Type"
    	content="text/html; charset=utf-8"
    />
    
    <meta
    	http-equiv="Content-Language"
    	content="en"
    />
    
    <meta
    	name="viewport"
    	content="width=device-width; initial-scale=1.0"
    />';
    
    	if ($keywords) echo '
    	
    <meta
    	name="keywords"
    	content="', $keywords, '"
    />';
    
    	if ($description) echo '
    	
    <meta
    	name="description"
    	content="', $description, '"
    />';
    
    	
    
    echo '
    
    <link
    	type="text/css"
    	rel="stylesheet"
    	href="screen.css"
    	media="screen,projection,tv"
    />
    
    <title>
    	', ($pageTitle ? $pageTitle . ' - ' : ''), ' Site Title
    </title>
    
    </head><body>
    
    <div id="top" class="widthWrapper">
    
    	<h1>
    		Site Title
    		<span><!-- image replacement --></span>
    	</h1>
    
    	<ul id="mainMenu">
    		<li><a href="#">Home</a></li>
    		<li><a href="#">Forums</a></li>
    		<li><a href="#">FAQ</a></li>
    		<li><a href="#">ContactUs</a></li>
    	</ul>
    
    	<hr /><!-- remove if content starts with numbered heading -->
    
    	<div id="contentWrapper"><div id="content">';
    	// using double-wrapper for fluid content-first columns
    	
    } // template_header
    
    function template_footer($extrasFile = false) {
    	echo '
    	<!-- #content, #contentWrapper --></div></div>
    	
    	<div id="extras">';
    	
    	// any static / common to all pages sidebar stuff here
    	
    	if ($extrasFile) include($extrasFile . '.php');
    	
    	echo '
    	<!-- #extras --></div>
    	
    	<div id="footer">
    		Disclaimer / Other footer stuff here
    	<!-- #footer --></div>
    	
    <!-- #top.widthWrapper --></div>
    		
    } // template_footer
    
    ?>
    Which contains all the code that is common to every page. You then for example would have a 'index.php' like this:

    index.php:
    Code:
    <?php require_once('template.php'); template_header(
    	false, // don't show "pageTitle - Site title"
    	'seven,or,eight,words,that,exist,in,body', // keywords
    	'A short natural language description describing the site'
    ); ?>
    
    <h2>Content goes here</h2>
    <p>
    	This is where your page unique content would go!
    </p>
    
    <?php template_footer('normalExtras'); ?>
    The 'normalExtras.php' file would simply be the content you have in your sidebars. I do it as separate files so that sub-pages can have their own unique sidebar content instead of the same as every page.

    If for example, you had your FAQ:

    faq.php
    Code:
    <?php require_once('template.php'); template_header(
    	'Frequently Asked Questions', 
    	'frequently, questions, one, two, three', // keywords
    	'Frequently asked questions about "describe the site's purpose here"'
    ); ?>
    
    <h2>Frequently Asked Questions</h2>
    
    <h3>Question one?</h3>
    <p>
    	Answer to question one.
    </p>
    
    <h3>Question two?</h3>
    <p>
    	Answer to question two.
    </p>
    
    <h3>Question three?</h3>
    <p>
    	Answer to question three.
    </p>
    
    <?php template_footer('normalExtras.php'); ?>
    That's in essence a very basic poor mans -- and can easily be done in PHP, ASP, PERL -- even SHTML (an Apache only built-in SSI system)

    As to keeping the HTML extension, I'd set up a 301 "moved permanently" redirect handler to point at the new versions of the pages. A "one index to rule them all" system might be better suited to handling that -- particularly since you could then use a rewriterule to use "friendly" uri's... so instead of "/faq.html" it would just be "/faq". No extension needed. You could even keep the HTML extension if you parsed $_SERVER['request_uri'] server-side instead of trying to use some fancy htaccess parsing.

    For example, in .htaccess I usually use this:
    Code:
    RewriteEngine On
    RewriteRule !\.(gif|jpg|png|css|js|txt|ico|zip|gz|rar|pdf|xml|wav|mp3|mp4|mpg|flv|swf|mkv|ogg|avi|webm|woff|svg|eot|ttf)$ index.php
    It's a whitelist -- any file extension not on that list is routed to my index.php -- I use that one single index.php to parse $_SERVER thus:

    Code:
    <?php
    
    // define('TESTING', 1);
    
    define('CONTENT_ENCODING', 
    	(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) ? 'x-gzip' :
    	(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) ? 'gzip' :
    	false
    );
    
    define('CONTENT_ENCODING', false);
    
    if (CONTENT_ENCODING) {
    	ob_start();
    	ob_implicit_flush(0);
    	register_shutdown_function(function() { 
    		header('Content-Encoding: ' . CONTENT_ENCODING);
    		$contents = ob_get_contents();
    		ob_end_clean();
    		echo "\x1f\x8b\x08\x00\x00\x00\x00\x00",
    			substr(gzcompress($contents, 6), 0, -4);
    	});
    }
    
    function cleanPath($path) {
    	return trim(str_replace(['\\','%5C'],'/',$path),'/');
    }
    
    function bomb($title, $message) {
    	template_header('ERROR - ' . $title);
    	echo '
    		<div id="fatalError">
    			<h2>
    				',$title,'
    			</h2>
    			<p>',$message,'</p>
    			<p><strong>EXECUTION HALTED</strong></p>
    		<!-- #fatalError --></div>';
    	template_footer();
    	die;
    }
    
    final class request {
    	private static $data = [];
    	public static function value($index = 0, $clean = false) {
    		if ($index === true) { $index = 0; $clean = true; }
    		if (count(self::$data) == 0) {
    			$path = cleanPath(parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH));
    			if (strpos($path,'..')) bomb('hackingDetected', 'uptreeFail');
    			$path = substr($path, strlen(HTTP_ROOT) - 1);
    			self::$data = empty($path) ? ['default'] : explode('/',$path);
    			foreach (self::$data as &$p) $p = urldecode($p);
    		}
    		return isset(self::$data[$index]) ? (
    			$clean ? cleanName(self::$data[$index]) : self::$data[$index]
    		) : false;
    	}
    } // class request
    
    define('SCRIPT_FILENAME',cleanPath($_SERVER['SCRIPT_FILENAME']));
    define('HTTP_ROOT',str_ireplace('index.php','',$_SERVER['PHP_SELF']));
    define('LOCAL_ROOT',str_ireplace('index.php','',SCRIPT_FILENAME));
    define('HTTP_THEME', HTTP_ROOT . 'theme/');
    require_once('theme/index.template.php');
    require_once(
    	is_file($targetFile = 'statics/' . request::value() . '.php') ?
    	$targetFile :
    	'statics/404.php'
    );
    
    ?>
    That's actually lifted right straight from one of my sites. "cleanPath" strips out all slashes preventing loads from anywhere but /statics...

    /theme/index.template.php is pretty much identical to the above template.php

    /statics/default.php would be the default/home page, what would normally be a index.php or index.html

    The cute part is, that with the above system in place, you could make:

    /statics/faq.html.php

    ... and your url to that file would actually work as http://www.yoursite.uri/faq.html

    Kind of what you are looking for?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    You can configure your web server to run *.htm/*.html pages as PHP: the .php suffix is just a standard convention, but by no means is it mandatory (or necessarily even desirable).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    May 2014
    Posts
    13
    I did google this, and I wish I had known this. Do you know if this can also be done with ASP? I couldn't find anything.

    Quote Originally Posted by NogDog View Post
    You can configure your web server to run *.htm/*.html pages as PHP: the .php suffix is just a standard convention, but by no means is it mandatory (or necessarily even desirable).

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    I would assume so, but have never tried. ASP usually (always?) runs under Windows Server, and I have no practical experience with it, just Apache.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    May 2014
    Posts
    13
    I am a Linux server and PHP fan myself. Unfortunately, the school uses Windows Server which isn't too bad, not my preference but have limited knowledge and practice in ASP. I have always just used PHP.

    I did google, I did not see any options of using ASP without saving the pages as ASP and running it at HTML.

    Quote Originally Posted by NogDog View Post
    I would assume so, but have never tried. ASP usually (always?) runs under Windows Server, and I have no practical experience with it, just Apache.

  8. #8
    Join Date
    May 2014
    Posts
    631
    It IS theoretically possible to run ASP.NET files on Apache -- even on linux -- using the MONO library. There's an apache module you can add called "mod_mono" that allows it to work. Mono lags slightly behind bleeding edge .NET, but M$ has actually been supporting Mono (mostly to get Silverlight over to other platforms) so that gap has narrowed a lot.

    Note that's .NET versions, not old-school ASP. Old-school ASP compiled to actual binaries, so you'd have to like tie-in WINE or something. .NET compiles to something akin to p-code, so in theory it's portable since it's not actually native code.

    Though really at that point, I'd use server-side Java... which is another option. Both Java and .NET runtimes are basically p-code interpreters. Those of you who call them a "virtual machine" can inhale my nether regions -- we didn't call it that with Pascal in the '70's so in the words of my generation... That's as stupid as the re-re's who call XML a "machine readable format"; which invokes a response akin to relating a tale of being inverted over a Mig-29 to Kelly McGillis.

    Though I'd just go with PHP -- PHP makes good glue. It's a lousy general computing language but that's not what it was built to do. All PHP is really for is gluing together bits of markup and database operations. Doing complex computing with it, or even getting fancy with processing the markup just isn't what it does well.

    See "templating engines" like smarty -- PHP is a templating engine, so what in the name of the infernal is with people making templating engines IN it?!? (again though, usually the people using that nonsense don't know enough about HTML and CSS to be making templates in the first place)

    Really though, what makes me like PHP over other options is that it's available on just about every host I've ever heard of (Windows, Linux or OSX) and is RIDICULOUSLY WELL DOCUMENTED

    Those two things greatly outweigh any objections I have to how PHP works (like encouraging insecure scope practices, the stupid 'php tags', etc). That over the past four to six years most of my objections (the insecure mysql_ functions, sql connections global in scope, lack of proper object modes) have effectively disappeared (in theory, too bad most people are still crapping out bad outdated code) hasn't hurt matters much. It's maturing into a much better language.

    Though it's going to be fun when PHP 6 drops and people run around like chickens with their heads cut off since so many people are still effectively sleazing out PHP 4 like it's still 2004.
    Java is to JavaScript as Ham is to Hamburger.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles