Restricted acces

Post Reply
ics01
Posts: 1
Joined: Sat Apr 30, 2022 2:13 pm

Restricted acces

Post by ics01 »

Hello, the WCMS team !

Perhaps this idea do not need a special plugin, but should be implemented in WonderCMS as a simple evolution ? : the ability to grant a restricted access to the entire site, via a simple password (or a couple code/password, but I think a simple password should be enough, as WCMS is not intended to work with different users and specific rights).

Here is a simple code that should be integrated on WCMS'index.html :

Code: Select all

<?php
session_start(); 
if (isset($_SESSION['count']) && ($_SESSION['count'] > 4)) {
	header('Location: https://www.wondercms.com/');
} else {
?> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Texte</title>
<style>
</style>
</head>
<body>
	<?php
	$password = 'motdepasse';
	if ((isset($_POST['password']) && ($_POST['password'])) != $password) {
		if (!isset($_SESSION['count'])) {
			$_SESSION['count'] = 0;
		} else {
			$_SESSION['count']++;
		}
	?> 
<h1>Connexion</h1>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
<p><label for="password">Password</label> <input type="password" title="Please type password" name="password" /></p> 
<p><input type="submit" name="submit" value="Connexion" /></p> 
</form>
	<?php
	} else { ?> 
<p>Here is the text.</p>
<?php 
	}
} 
?>
</body>
</html>
A simple field should be added in parameters to enter password, for example like the image below, and that's all.
2022-04-30_162330.jpg
2022-04-30_162330.jpg (48.46 KiB) Viewed 250 times
Isn't it a good idea ? :idea:

Thanks for your attention.

Etienne, France.
User avatar
wiz
Admin
Posts: 697
Joined: Sat Oct 30, 2010 12:23 am

Re: Restricted acces

Post by wiz »

Hey ics01, this is an interesting take. Is this something you implemented in the theme.php file?
I would suggest wrapping it in an extra statement and checking if the user is logged in instead of counting the session.

How are you liking WonderCMS so far? :)
Post Reply