I am new at this so please be patient. I need a very simple snippet to have one "login" page that redirects to a number of different "classroom" pages based on the login info. The problem that I currently have is that I cannot figure out how to pull the page id out of the array of information. (example: [[OnlineClassroomProtect?login1=name1|40&login2=name2|50]])
How do I get this to redirect to page 50 when "name2" is entered?
As you can see by the code below my temporary fix was to match the classroom names to pages with a furl specified. (I know it's ugly...but it works for the moment.)
Any help is greatly appriciated.
Thanks in advance,
Jared
// Based on the SimplePasswordProtect snippet.
// usage (sample for 2 classrooms):
// insert in the login page (25=login page & 40,50=classroom pages): [[OnlineClassroomProtect?login1=name|40&login2=name|50]]
// insert in the content page [[OnlineClassroomProtect?pageid=40&loginpage=25]]
session_start();
session_register('authenticated');
$currentpage=$etomite->documentObject['id'];
if(!isset($loginpage)) $loginpage=$currentpage;
// login form
$passwordform = "";
$passwordform .= '<p>This is a protected area of the website.
';
$passwordform .= 'What Classroom would you like to enter?
';
$passwordform .= '<form action="[~'.$loginpage.'~]" method="post">';
$passwordform .= 'Classroom:
<input type="text" name="post_classroom" />';
$passwordform .= '<input type="submit" value="Go" />';
$passwordform .= '</form></p>';
if(isset($pageid)) {
// logged in with right pageid
if($_SESSION['authenticated']) return "";
// not logged in and current page is not loginpage
if($loginpage!=$currentpage) {
Header('Location: '.$etomite->rewriteUrls('[~'.$loginpage.'~]'));
exit;
//return "??";
}
// not logged in and this is login page
return "<hr />".$_SESSION['authenticated']." :: ".$pageid."<hr />".$passwordform;
}
// Reading the list of classroom
for($i=1;$i<=100;$i++) {
if(isset(${'login'.$i})) {
list($k1,$v)=split("\|",${'login'.$i});
$login[$k1]=$v;
} else break;
}
if(!isset($login)) return 'not enough parameters';
// login ***Ugly Hack***
if($_POST['post_classroom']) {
if($login[$_POST['post_classroom']]) {
$_SESSION['authenticated']=$login[$_POST['post_classroom']];
Header('Location: '.$etomite->rewriteUrls('[~'.$_POST['post_classroom'].'~]'));
exit;
} else {
sleep(2);
return "<p>Sorry, that Classroom is unavailable or does not exist.
Click <a href='[~$loginpage~]'>HERE</a> to go back.</p>";
}
}
// if logged in
if($_SESSION['authenticated']) {
session_destroy();
Header('Location: '.$etomite->rewriteUrls('[~'.$loginpage.'~]'));
exit;
// login form
} else {
return $passwordform;
}











