Code: Select all
//control.php
<?php
# this is the control page. the page that allows the user tomake new pages, delete old pages, etc
session_start(); # sessions call to enable sessions
session_register('dbuser'); # make sure the db user is in the session on this page
session_register('dbpw'); # make sure the db pw is in the session on this page
include('/home/joshua/aislin/funcs.php'); # functions
include('/home/joshua/aislin/vars.php'); # universal variables
if(($dbpw!='')&&($dbuser!='')){ # if we're logged in
switch($_POST['disp']){ # what page do we display?
case 'page': # create a new page/update a pre-existing page/delete a page
$page=pgstrt('control-page', $css, $javascript); # start the page
$page.=<<<END
END;
break;
case 'gallery': # create/modify/delete a gallery/picture
$page=pgstrt('control-gallery', $css, $javascript); # start the page
$page.=<<<END
END;
break;
case 'blog': # create/modify/delete a blog entry or comment
$page=pgstrt('control-blog', $css, $javascript); # start the page
$page.=<<<END
END;
break;
default:
$page=pgstrt('control-', $css, $javascript); # start the page
$page.=<<<END
<h1>Which section of your site would you like to manipulate?</h1>
<form action="{$_SERVER['PHP_SELF']}" method="POST">
<p>
<select id="disp" name="disp">
<option value="page"></option>
<option value="gallery"></option>
<option value="blog"></option>
</select>
<br /><input type="submit" value="Adjust Selected Section">
</p>
<p>Click <a href="saveres.php" target="_blank">here</a> to save/restore the database.</p>
</form>
END;
break;
}
}else{ # create login page
$page=pgstrt('control-login', $css, $javascript); # start the page
$page.=<<<END
<h1>You Need to Login to Access the Control Panels</h1>
<form action="{$_SERVER['PHP_SELF']}" method="POST">
<p>Your Login Username: <input id="user" name="user" type="text">
<br />Your Password: <input id="pw" name="pw" type="password">
<br /><input type="submit" value="Log Me In">
</p>
</form>
END;
}
$page.=pgnd(); # close the page
echo $page; # give user the page
?>
//funcs.php
<?php
# this is a functions file to be included to other pages
function pgstrt($what, $css, $javascript){ # pagestart -- starts a page
include('/home/joshua/aislin/vars.php');
switch($what){
case 'control-login': $title='Control Panel -- Login Page'; break;
case 'control-page': $title='Control Panel -- Page Editing'; break;
case 'control-gallery': $title='Control Panel -- Gallery Editing'; break;
case 'control-blog': $title='Control Panel -- Blog Editing'; break;
case 'control-': $title='Control Panel -- '; break;
case 'welcome':
default: $title='Welcome to Aislin''s Corner'; break;
}
$pagehead=<<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
$metas
<title>$title</title>
<style type="text/css">
<!--
$css
-->
</style>
<script type="text/javascript">
<!--
$javascript
-->
</script>
</head>
<body>
END;
echo $pagehead;
}
function pgnd(){ # pageend -- ends a page
include('/home/joshua/aislin/vars.php');
$pageclose=<<<END
<p style="font-size:.8em;font-family:arial;text-align:center;text-decoration:none;">Page coded and copyrighted by Desired Creations LLC</p>
</body>
</html>
END;
echo $pageclose;
}
?>
// vars.php
<?php
# variables file -- db section is something that should be PRIVATE.
$metas=' <meta name="Author" content="Pages coded by Desired Creations LLC" />
<meta name="Description" content="Home Pages of Crystal ''Aislin'' Barnard" />
<meta name="Keywords" content="" />';
# db section. advisable to make this server only readable. not required
$dbname='aislin'; # name of db to connect to
$dbhost='localhost'; # host on which the db is
?>