Skip to content

Instantly share code, notes, and snippets.

@npardington
Last active December 24, 2015 21:39
Show Gist options
  • Save npardington/6866881 to your computer and use it in GitHub Desktop.
Save npardington/6866881 to your computer and use it in GitHub Desktop.
Bad render example. Used in a blog post about frameworks.
<?php
//we want to know what folder the script resides in (because I don't want to see index.php when I go to the home folder
$relativeLinks = "http://". $_SERVER['HTTP_HOST'] . "/" .substr(dirname($_SERVER['PHP_SELF']), strpos(dirname($_SERVER['PHP_SELF']), "/")+1) ;
//figure out admin links
$links = "";
$dumbLinks = "";
if ($_COOKIE['loggedin'] == "yes") //make sure admins have priority
{
$links = "<li><a href='quiz.php'>Quiz</a></li>
<li><a href='prayerrequests.php'>Prayer Requests</a></li>
<li><a href='admin.php'>Admin</a></li>
<li><a href='responses.php'>Responses</a></li>
<li><a href='email.php'>Email</a></li>";
//not that many links so i don't feel like figuring out why in the world the two different link bars are opposite when they render
//notice the reverse order they have to be in...
$dumbLinks = "<li><a href='email.php'>Email</a></li>
<li><a href='responses.php'>Responses</a></li>
<li><a href='admin.php'>Admin</a></li>
<li><a href='prayerrequests.php'>Prayer Requests</a></li>
<li><a href='quiz.php'>Quiz</a></li>";
$logInOut = "<li><a href='logout.php'>Logout</a></li>";
} else if ($_COOKIE['worker'] == "yes" || $_SESSION['worker'] == "yes" )
{
$dumbLinks = "<li><a href='quiz.php'>Quiz</a></li>
<li><a href='prayerrequests.php'>Prayer Requests</a></li>";
$links = "<li><a href='prayerrequests.php'>Prayer Requests</a></li>
<li><a href='quiz.php'>Quiz</a></li>";
$logInOut = "<li><a href='login.php'>Login</a></li>";
}
else {
$logInOut = "<li><a href='login.php'>Login</a></li>";
}
?>
<!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">
<head>
<title>
<?php
/*----------------
Echo Title
----------------*/
print $title;
?>
</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Taking the Light to a Darkened Community." />
<meta name="keywords" content="Bible club, Bible, see the Lord working, sonpoint, Christian service" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type='text/javascript' src='script/selecting.js'></script>
<script type='text/javascript' src='script/jquery-1.4.min.js'></script>
<script type='text/javascript' src='script/jquery.validate.js'></script>
<script type='text/javascript' src='script/ajax.js'></script>
<script type='text/javascript'>
function checkAnswer(ans) {
if (ans == "<?php echo $kids; ?>") {
location.reload(true);
} else {
document.getElementById('error').innerHTML = "This is not " + ans + ".";
}
}
function toggleName() {
document.addPicForm.fullname.disabled = !document.addPicForm.fullname.disabled;
document.addPicForm.fullname.readOnly = document.addPicForm.fullname.disabled;
document.addPicForm.fullname.value = "";
}
<?php echo $script;?>
</script>
</head>
<body>
<div id="wrap">
<div id="header">
<h1><a href="<?php print $relativeLinks;?>">Agape Bible Club</a></h1>
<h2>Taking the Light to a Darkened Community</h2>
</div>
<div id="menu">
<ul>
<?php
print $logInOut;
print $links;
?>
<li><a href="<?php print $relativeLinks?>">Home</a></li>
</ul>
</div>
<div id="content">
<div class="right">
<?php
print $contentHeading;
/*---------------
Echo heading for body
Needs to be in <h2> tags
Also need the rest of the body
---------------*/
print $content;
?>
<div class="footer">
&copy; 2009 <a href="http://agapebibleclub.com">Agape Bible Club</a> | Designed by <a href="http://www.free-css-templates.com/">Free CSS Templates</a> <?php print $_COOKIE['whoAmI'];?>
</div>
</div>
<div class="left">
<ul>
<li><a href="<?php print $relativeLinks;?>">Home</a></li>
<?php
//why in the world would you print things out backwards?????
print $dumbLinks;
print $logInOut;
?>
</ul>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<script>
$(document).ready(function(){
$("#myvalid").validate({
submitHandler: function() {
var data = $("#myvalid").serialize();
$.post("./ajaxcalls/addworker.php",
data, function(){
document.getElementById("txtFirstName").value = '';
document.getElementById("txtLastName").value = '';
document.getElementById("txtEmail").value = '';
document.getElementById("isLeader").checked = false;
});
return false;
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment