Example #1
0
<html>
	<head>
		<title>Delete Blog Entry</title>
		<meta charset="UTF-8">
		<style>
			<?php 
MWF_ViewLoader::Load("mod_core_design", "base_css");
?>
		</style>
	</head>
	<body>
		<?php 
MWF_ViewLoader::Load("mod_core_design", "headerbar");
?>
		<?php 
$E = new BlogEngine();
$data = $E->getPost($_GET["POST_ID"]);
?>
		<form action="?mod=mod_adminpage&view=delete_entry_action" method="POST">
			<p>Are you sure to Delete Post #<?php 
echo $data->getPostID();
?>
</p>
			<input type="button" value="Cancel" onClick="javascript:history.back(1);" />
			<input type="submit" value="Confirm Delete" />
			<input type="hidden" name="POST_ID" value="<?php 
echo $data->getPostID();
?>
" />
		</form>
		<div class="blog_post">
Example #2
0
<?php

$Authen = new ExtendedAuthenticationEngine();
$E = new BlogEngine();
if (!$Authen->isLoggedIn()) {
    header("Location: .");
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Welcome To My Blog</title>
		<meta charset="UTF-8">
		<style>
			<?php 
MWF_ViewLoader::Load("mod_core_design", "base_css");
?>
		</style>
	</head>
	<body>
		<?php 
MWF_ViewLoader::Load("mod_core_design", "headerbar");
?>
		<?php 
if ($Authen->isAuthorized(1)) {
    echo '<p><a href="?mod=mod_adminpage&view=add_entry">Create new blog entry</a></p>';
}
?>
		<hr>
<?php 
if (!isset($_GET["page"])) {
<?php

$Authen = new ExtendedAuthenticationEngine();
if (!$Authen->isAuthorized(1)) {
    header('Location: ?mod=mod_adminpage');
    die;
}
$blogengine = new BlogEngine();
$PostData = new PostData(NULL, $_POST["title"], $_POST["data"], NULL);
// New Post Object with Given Data ($_POST)
$success = $blogengine->newPost($PostData);
if (!$success) {
    header('Location: ?mod=mod_adminpage&view=add_entry&success=0');
} else {
    header('Location: ?mod=mod_adminpage');
}
<?php

$Authen = new ExtendedAuthenticationEngine();
if (!$Authen->isAuthorized(3)) {
    header('Location: ?mod=mod_adminpage');
    die;
}
$E = new BlogEngine();
$post = $E->getPost($_POST["POST_ID"]);
$LoginData = $Authen->getLoginData();
if ($LoginData["USER_ID"] != $post->getPostOwner() && !$Authen->isAuthorized(4)) {
    header('Location: ?mod=mod_adminpage');
} else {
    $data = $E->delPost($_POST["POST_ID"]);
    if ($data) {
        header("Location: ?mod=mod_adminpage");
    } else {
        echo "Delete Post Failed";
    }
}
<?php

$Authen = new ExtendedAuthenticationEngine();
if (!$Authen->isAuthorized(2)) {
    header('Location: ?mod=mod_adminpage');
    die;
}
$E = new BlogEngine();
$post = $E->getPost($_POST["POST_ID"]);
$LoginData = $Authen->getLoginData();
if ($LoginData["USER_ID"] != $post->getPostOwner() && !$Authen->isAuthorized(4)) {
    header('Location: ?mod=mod_adminpage');
} else {
    $post->setPostTitle($_POST["title"]);
    $post->setPostData($_POST["data"]);
    $data = $E->setPost($post);
    if ($data) {
        header("Location: ?mod=mod_adminpage");
    } else {
        header("Location: ?mod=mod_adminpage&view=edit_entry&POST_ID=" . $_POST["POST_ID"]);
    }
}