我刚刚从头,、朝 y建造了一个小型的PHP站点。 但是,鉴于其规模,它比我预期的要慢一些。
我有这样的文件/文件:
- articles [folder]
- css [folder]
- html [folder]
- images [folder]
- js [folder]
- photography [folder]
- resources [folder]
- articles.php [file]
- bio.php [file]
- contact.php [file]
- content.php [file]
- favicon.ico
- footer.php [file]
- header.php [file]
- index.php [file]
- photography.php [file]
我的大多数PHP档案都是这样编造的:
<?php
$thisPage="Writing";
include("header.php");
$page = $_GET[ article ];
$file = "articles/".$page.".html";
if(file_exists($file)) {
include($file);
} else {
print "404 Error. Page does not exist";
}
function IsSafeInclude($x) {
if(strpos($x, "/../") !== false || strpos($x, "../") === 0 || strpos($x, "/..") == (strlen($x) - 3) || $x == .. )
return false;
else
return true;
}
//include("html/articles-left.html");
?>
<div id="article-nav-container">
<ul id="article-nav-pg">
<li><a href="articles.php?article=article_name1">1</a></li>
<li><a href="articles.php?article=article_name2">2</a></li>
<li><a href="articles.php?article=article_name3">3</a></li>
<li><a href="articles.php?article=article_name4">4</a></li>
<li><a href="articles.php?article=article_name5">5</a></li>
<li><a href="articles.php?article=article_name6">6</a></li>
</ul>
<script type="text/javascript">
$(document).ready(function() {
var loc = window.location.href; // The URL of the page we re looking at
$( #article-nav-pg a ).each(function() {
if (loc.indexOf(this.href) !== -1) { // If the URL contains the href of the anchor
$(this).addClass( selected ); // Mark it as selected
}
});
});
</script>
</div><!-- end articles nav -->
<p id="left-description"><img src="images/side-descrip-stories.jpg" width="20" height="90" alt="Story Description" /></p>
<?php
include("footer.php");
?>
一些档案中还有直接内部的html代码。 我将赞赏就如何提高我小型的PHP站点的速度提出任何建议。
增 编