okay...i am making a CMS for my family's web page. I've got the sessions down, i've got a basic admin panel, i've got a very primitive user membership thingy.
But, what's pissing me off is that everything is getting all mixed together...so I am asking someone to please give me some ideas on file structures for this type of project.
This is what i have now...
[root]
index.php
admin.php
functions.php
template.php
login.php
logout.php
/admin/
/themes/
[admin]
index.php
editblocks.php
editusers.php
editall.php
[themes]
index.php
/default/
/theme2/
[default]
layout.html
images.html
blocks.html
/images/
Everthing in my code seems to fall together in functions.php
<?php
session_start();
if(session_is_registered('username')){
user("logged_in");
} else {
user("logged_out");
}
include("$theme['layout'];");
function style(){
include("$theme['style'];")
}
function user($status){
global $menu;
if($status == "logged_in"){
$menu = "true";
} elseif($status == "logged_out") {
$menu = "false";
} else {
$menu = "false";
}
}
function menucontent(){
global $mcontent;
$logged_in .= "<center><font face=\"verdana\" size=\"2\" color=\"black\">";
$logged_in .= "[:<a href=\"index.php\">Home</a>:] ";
$logged_in .= "[:<a href=\"logout.php\">Logout</a>:] ";
$logged_out .= "<center><font face=\"verdana\" size=\"2\" color=\"black\">";
$logged_out .= "[:<a href=\"index.php\">Home</a>:] ";
$logged_out .= "[:<a href=\"login.php\">Login</a>:]";
if($menu == "true"){
$mcontent = $logged_in;
} elseif($menu == "false"){
$mcontent = $logged_out;
} else {
$mcontent = $logged_out;
}
echo($mcontent);
}
function login(){
echo "<html>",
"<head>",
"<title>Login</title>",
"</head>",
"<body>",
"<form method=\"POST\" action=\"$PHP_SELF\">",
"Username: <input type=\"text\" name=\"username\" size=\"20\" maxlength=\"15\"><br>",
"Password: <input type=\"password\" name=\"password\" size=\"20\" maxlength=\"15\"><br>",
"<input type=\"submit\" value=\"Submit\" name=\"login\">",
"</form>",
"</body>",
"</html>";
}
function myfont($text){
echo "<font face=\"verdana\" color=\"black\" size=\"2\">",
"$text",
"</font>";
}
function error($errortext){
echo "<b><font face=\"verdana\" color=\"red\" size=\"2\">",
"$errortext",
"</b></font>";
}
function mybigfont($bigfont){
echo "<b><font face=\"verdana\" color=\"black\" size=\"2\">",
"$bigfont",
"</ b></font>";
}
function includeblock($block)
{
$blockfile .= "blocks/block_";
$blockfile .= "$block";
$blockfile .= ".php";
if(file_exists("$blockfile")){
echo "<table width=\"150\" border=\"1\" bordercolor=\"black\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr bgcolor=\"#cccccc\"><td>",
mybigfont(" - $block"),
"</td></tr><tr bgcolor=\"#cccccc\"><td>";
include $blockfile;
myfont("This would show the content for the $block block, but I am to lazy to set it up!");
echo "</td></tr></table><br>";
} elseif(!file_exists("$blockfile")){
echo "<table width=\"150\" border=\"1\" bordercolor=\"black\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr bgcolor=\"#cccccc\"><td>",
mybigfont(" - $block"),
"</td></tr><tr bgcolor=\"#cccccc\"><td>",
"<form method=\"post\" action=\"blockeditor.php?action=create\">",
error("Error!"),
myfont("<br>The block: $block doesn't exist or there is an error in the file!"),
"</td></tr></table><br>";
} else {
echo "<table width=\"150\" border=\"1\" bordercolor=\"black\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr bgcolor=\"#cccccc\"><td> - $block</td></tr><tr bgcolor=\"#cccccc\"><td>",
"Error!",
"</td></tr></table><br>";
}
}
?>
I need help also, like with where to put the config type stuff...right now i am not using much sql, but in the end it will be so I need to simplify things...
please help me! 😕