So I started making the code changes to allow passwords then I went to the dentist and had a tooth pulled. After I have been under pain pills hallucinating about evil
ducks
taking over the world. Just not a state of mind to code in. ^.^;;
I am feeling better now so here is what I came up with. As for the allowing the Mys admin to set the password, I will see how much work it will take to edit those pages.
As with any Mod remember to Back Up Your Site And Database!
first sql command add a place for the password.
Code:
ALTER TABLE `adopts_content` ADD `content_password` VARCHAR( 32 ) NOT NULL
then open inc/functions.php find
PHP Code:
function getsitecontent($page) {
$query = "SELECT * FROM ".$GLOBALS['prefix']."content WHERE page = '$page'";
$result = @runquery($query);
$num = @mysql_num_rows($result);
$title=@mysql_result($result,0,"title");
$content=@mysql_result($result,0,"content");
$title = stripslashes($title);
$content = stripslashes($content);
$value[content] = $content;
$value[title] = $title;
return $value;
}
replace it with
PHP Code:
function getsitecontent($page) {
$query = "SELECT * FROM ".$GLOBALS['prefix']."content WHERE page = '$page'";
$result = @runquery($query);
$num = @mysql_num_rows($result);
//first check if their is any results if yes then pull the data
if($num>0){
$title=@mysql_result($result,0,"title");
$content=@mysql_result($result,0,"content");
$password=@mysql_result($result,0,"content_password");
$title = stripslashes($title);
$content = stripslashes($content);
$value['content'] = $content;
$value['title'] = $title;
$value['password'] = $password;
return $value;
}
else{
return FALSE;
}
}
then replace your pages.php with this
PHP Code:
<?php
include("inc/functions.php");
include("inc/bbcode.php");
//***************//
// START SCRIPT //
//***************//
// Grab the page from the get parameter
if (isset($_GET['page'])){
$page = $_GET['page'];
}
else{
$page = '';
}
//get the password if it has been sent
if (isset($_GET['password'])){
$password = $_GET['password'];
$password = secure($password); //secure has all ready ran on all of the get variables but I want to make sure it was called.
}
else{
$password = '';
}
//check if their was sent a page if no then just set pagecontent to false
if($page !=''){
$pagecontent = getsitecontent($page);
}
else{
$pagecontent = FALSE;
}
if($pagecontent != FALSE){
//now check if a password has been set for the page
if ($pagecontent['password'] == ''){
$article_title = $pagecontent['title'];
$article_content = $pagecontent['content'];
$article_content = bbconvert($article_content); // BBCODE conversion
$article_content = nl2br($article_content); // New line breaks
}
else if ($pagecontent['password'] != '' && $password !=''){
//their is both a password set and a password sumited check if they match
if($password == $pagecontent['password']){
//display content
$article_title = $pagecontent['title'];
$article_content = $pagecontent['content'];
$article_content = bbconvert($article_content); // BBCODE conversion
$article_content = nl2br($article_content); // New line breaks
}
else{
$article_title = "Password incorrect";
$article_content = "The password you have submitted is incorrect.";
}
}
else{
//their is a password set
$article_title = "Password required";
$article_content = '<form name="form" method="get" action="'.$_SERVER['PHP_SELF'].'">
<input name="page" type="hidden" id="page" value="'.$page.'">
<p><label for="password">Password:</label>
<br /><input type="password" title="Enter your password" name="password" /></p>
<p><input type="submit" name="Submit" value="Login" /></p>
</form>';
}
}
else{
// Page does not exist...
$article_title = "404 Page Not Found";
$article_content = "The page you are looking for cannot be found on this site.
It is possible that it never existed or that the site admin deleted it.";
}
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, '');//this page is not using the date so I removed it to stop Notice
?>