Updated code with comments and cleaned up some stuff

This commit is contained in:
Gabriel Simmer 2015-08-26 17:27:52 -07:00
parent e19a343a57
commit 2af6f908ce
3 changed files with 22 additions and 14 deletions

View file

@ -1,4 +1,7 @@
<!DOCTYPE html>
<!-- Not Done My Website (c) 2015 Gabriel Simmer
This is still being worked on so make sure to git pull
from time to time! -->
<?php
// Setting variables
$_site = "Not Done My Website";
@ -26,7 +29,7 @@
<div class="creation">
<h3>Variables for web page</h3>
<!-- Most of the magic takes place in make.php - look there -->
<form action="make.php" method="POST">
<div id="var">Site name: <input type="text" name="sname" placeholder="Not Done My Website">
</div>

View file

@ -5,34 +5,38 @@
$pcolour = $_POST['pcolour'];
$scolour = $_POST['scolour'];
$template = fopen("template/template.html", "r+");
$tempContents = fread($template, filesize("template/template.html"));
$template = fopen("template/template.html", "r+"); // Change this if you have a custom template filename
$tempContents = fread($template, filesize("template/template.html")); //Read frin tge file
// Keywords for replacement - see README
$keywords = array("rep_PCOLOUR", "rep_SCOLOUR", "rep_SNAME", "rep_URL", "rep_DEVNAME");
$replacement = array($pcolour, $scolour, $sname, $surl, $devname);
// ---
$contents = str_replace($keywords, $replacement, $tempContents);
$contents = str_replace($keywords, $replacement, $tempContents); // Replace the contents of the variable
fclose($template);
/*
echo "<?php ";
/* Debug stuff
echo "$sname ";
echo "$surl ";
echo "$devname ";
echo "$pcolour ";
echo "$scolour ";
echo "?> ";
*/
echo $contents;
echo $contents; // Echo out the generated page
$indexfile = fopen("index.html", "w");
fwrite($indexfile, NULL);
fclose($indexfile);
/* Not actually needed but may need to reuse this code later on
*
* $indexfile = fopen("index.html", "w");
* fwrite($indexfile, NULL);
* fclose($indexfile);
*
*/
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename=index.html');
readfile("index.html");
readfile("index.html"); // Make the client download the file as a .html :)
?>

View file

@ -1,4 +1,5 @@
<!DOCTYPE html>
<!-- Very simple webpage that scales decently -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -41,7 +42,7 @@
</div>
<br />
<div class="content">
<p>rep_URL is being worked on by rep_DEVNAME!</p>
<p>rep_URL is being worked on by rep_DEVNAME!</p> <!-- See README for keywords -->
</div>
</body>
</html>