<?php if(!class_exists('PhpBasic')) exit('<h4>Direct access not allowed "'.__FILE__.'"</h4>');
/*
This class uses PhpBasic Framework.
You can download the framework at "http://phpbasic.netau.net/".
*/
class auth_controller extends AppController {
protected function Page_Load(){
self::OptionExplicit();
$this->Import('System.Auth');
$this->Import('System.Url');
$this->Con = mysql_pconnect('localhost','root','add123');
mysql_select_db('db_sample',$this->Con);
$this->auth =new Auth();
$this->auth->SetAuth('users','username','password')->ConnectTo($this->Con);
}
protected function Index_Path($e){
if(!$this->auth->IsSignIn()){
print "<a href='".PathUrl("Auth/Signup")."'>Signup</a>";
}else{
print "<a href='".PathUrl("Auth/Signout")."'>Signout</a>";
print "<h1>welcome \"".$this->auth->UserLog()."\"</h1> Time-in: \"".$this->auth->TimeLog()."\"";
print "<p>";
print "</p>";
}
$this->View(DEFAULT_PG);
}
protected function Signup_path($e){
$this->auth->If_SignIn_Goto(PathUrl("Auth"));
$var = array();
if(Post('username')!==FALSE && Post('password')!==FALSE){
$return = $this->auth->Signin(Post('username'),md5(Post('password')),Post('remember'));
if(!$this->auth->IsSignIn()){
print $return;
}else{
print $return;
URL::Redirect(PathUrl("Auth"));
}
}
$this->View('signup',$var);
}
protected function Signout_path($e){
$this->auth->Signout();
Url::Redirect(PathUrl("Auth"));
}
}
# PHP_END_FILE
|