id = $id; $this->password = $password; $this->paramkey = "pwd-fence-$id"; } function isAuthenticated() { return (isset($_GET[$this->paramkey]) && $_GET[$this->paramkey] == $this->password); } function failedToAuthenticate() { return (isset($_GET[$this->paramkey]) && $_GET[$this->paramkey] != $this->password); } function printAnchor() { print ''; print ''; } function printMiniForm() { // Print small inline "login/logut" form, Heribert style if( $this->failedToAuthenticate()) { ?> Passwort falsch, bitte nochmal probieren: printLoginForm(); } else if($this->isAuthenticated()) { $this->printLogoutForm(); } else { $this->printLoginForm(); } } function printLoginForm() { ?>
isAuthenticated()) { // buffer (thus hide) content ob_start(); } } function end() { if(!$this->isAuthenticated()) { // delete buffer content, thus hide content ob_end_clean(); } } } /** * Simpler Passwortschutz im Sinne einer "Barriere", die inmitten einer * t29-Seite stehen kann. * Prinzipiell ist dieser Passwortschut wirkungsvoll, sofern HTTPS * verwendet wird. Die primitive Übermittlung per GET (oder POST) * sorgt aber dafür, dass die Benutzererfahrung schwach ist (das * Passwort wird etwa plain-text in der URL angezeigt oder ein einfaches * Neuladen einer ansonsten statischen Seite führt stets zu den POST- * Warnungen). * * In der Praxis auf t29 ist dieser Passwortschutz allerdings schon alleine * deswegen völlig wirkungslos, weil die Files alle öffentlich per * SVN einsehbar sind. Aber Heribert wollte es ja so. Ist nur ein * Demonstrator. * * Beispiel einer verwenden Seite gibt es weiter unten. * **/ class t29PasswordBarrier { public $password; public $paramkey = 't29-pwd-barrier'; function __construct($password=Null) { $this->password = $password; } function isAuthenticated() { return (isset($_GET[$this->paramkey]) && $_GET[$this->paramkey] == $this->password); } function failedToAuthenticate() { return (isset($_GET[$this->paramkey]) && $_GET[$this->paramkey] != $this->password); } function printAuthForm() { $failed = $this->failedToAuthenticate(); ?>Den Text hier kann jeder lesen
isAuthenticated()) { $barriere->printAuthForm(); return; } else { $barriere->printSuccessForm(); } ?> Den hier kann man nur lesen, wenn man an der Barriere vorbei ist. */