Re: Sugestions for auth
| From: | Yavor Shahpasov | Date: | Tue, 05 Nov 2002 17:05:52 +0000 |
| Subject: | Re: Sugestions for auth | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10483@lists.php.net to get a copy of this message | ||
Patch was stripped here it is in the email i hope iit is usable
--- Auth.php.orig 2002-11-04 14:41:39.000000000 -0200
+++ Auth.php 2002-11-05 19:22:07.000000000 -0200
@@ -298,13 +298,67 @@
session_start();
$this->assignData();
-
+ // Check for urls which require login
+ $this->checkRequiredUrl();
if (!$this->checkAuth()) {
$this->login();
}
}
// }}}
+
+
+ /**
+ * Initializes the required urls with a single or an array of urls for
which login is required
+ *
+ * @access public
+ * @return void
+ * @param mixed An array of urls to force login for.
+ */
+ function setRequiredUrl($requiredurls=array()){
+ if(is_array($requiredurls)){
+ $this->requiredurls = $requiredurls;
+ }
+ else{
+ $this->requiredurls = array($requiredurls);
+ }
+ }
+
+ /**
+ *
+ *
+ * @access public
+ * @return void
+ * @param string A string url to match against
+ */
+ function addRequiredUrl($url){
+ if(is_array($url)){
+ $this->requiredurls = array_merge($this->requiredurls, $url);
+ }
+ else{
+ $this->requiredurls[] = $url;
+ }
+ }
+
+ /**
+ *
+ *
+ * @access private
+ * @return bool
+ */
+ function checkRequiredUrl(){
+ // Make this the default behaviour ??? and ignore initial param
+ //$this->showLogin = false;
+ foreach($this->requiredurls as $url){
+ if(stristr($_SERVER['PHP_SELF'], $url)){
+ $this->showLogin = true;
+ return(true);
+ }
+ }
+ return(false);
+ }
+
+
// {{{ login()
/**