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> <!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 <?php
// Setting variables // Setting variables
$_site = "Not Done My Website"; $_site = "Not Done My Website";
@ -26,7 +29,7 @@
<div class="creation"> <div class="creation">
<h3>Variables for web page</h3> <h3>Variables for web page</h3>
<!-- Most of the magic takes place in make.php - look there -->
<form action="make.php" method="POST"> <form action="make.php" method="POST">
<div id="var">Site name: <input type="text" name="sname" placeholder="Not Done My Website"> <div id="var">Site name: <input type="text" name="sname" placeholder="Not Done My Website">
</div> </div>

View file

@ -5,34 +5,38 @@
$pcolour = $_POST['pcolour']; $pcolour = $_POST['pcolour'];
$scolour = $_POST['scolour']; $scolour = $_POST['scolour'];
$template = fopen("template/template.html", "r+"); $template = fopen("template/template.html", "r+"); // Change this if you have a custom template filename
$tempContents = fread($template, filesize("template/template.html")); $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"); $keywords = array("rep_PCOLOUR", "rep_SCOLOUR", "rep_SNAME", "rep_URL", "rep_DEVNAME");
$replacement = array($pcolour, $scolour, $sname, $surl, $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); fclose($template);
/* /* Debug stuff
echo "<?php ";
echo "$sname "; echo "$sname ";
echo "$surl "; echo "$surl ";
echo "$devname "; echo "$devname ";
echo "$pcolour "; echo "$pcolour ";
echo "$scolour "; echo "$scolour ";
echo "?> ";
*/ */
echo $contents; echo $contents; // Echo out the generated page
$indexfile = fopen("index.html", "w"); /* Not actually needed but may need to reuse this code later on
fwrite($indexfile, NULL); *
fclose($indexfile); * $indexfile = fopen("index.html", "w");
* fwrite($indexfile, NULL);
* fclose($indexfile);
*
*/
header('Content-Type: text/plain'); header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename=index.html'); 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> <!DOCTYPE html>
<!-- Very simple webpage that scales decently -->
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -41,7 +42,7 @@
</div> </div>
<br /> <br />
<div class="content"> <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> </div>
</body> </body>
</html> </html>