13 protected $log=array();
14 protected $status=array();
16 public function __construct()
18 parent::__construct(database::host,database::name,database::user,database::pass);
19 $this->
log[
'server']=$_SERVER[
'SERVER_NAME'];
20 $this->
log[
'request']=$_SERVER[
'REQUEST_URI'];
21 $this->
log[
'port']=$_SERVER[
'REMOTE_PORT'];
22 $this->
log[
'agent']=$_SERVER[
'HTTP_USER_AGENT'];
23 $this->
log[
'referer']=$_SERVER[
'HTTP_REFERER'];
24 $this->
log[
'external_ip']=$_SERVER[
'REMOTE_ADDR'];
26 'called'=>$_POST[
'atype'],
27 'date'=>date(
'Y-m-d'),
30 $this->
log[
'database']=array(
'host'=>database::host,
31 'name'=>database::name,
32 'user'=>database::user,
33 'pass'=>database::pass);
59 $this->createTable(
"users");
60 $email=$this->output(
"`function`='superemail'",
"`id` ASC",1);
61 $name=$this->output(
"`function`='superuser'",
"`id` ASC",1);
62 $pass=$this->output(
"`function`='superpass'",
"`id` ASC",1);
63 $this->
createSuperUser($email[
'line'][0][0],$name[
'line'][0][0],$pass[
'line'][0][0]);
80 final public function editPerm($login=null,$perm=null)
84 if((is_numeric($perm))&&($perm<=1111))
86 $this->
set(
"perm",$perm);
87 $this->update(
"`login`=".$this->
log[
'user']);
88 unset($this->
log[
'perm']);
89 $this->
log[
'perm']=$perm;
90 return $this->
log[
'perm'];
99 $this->
set(
"perm",$perm);
100 $this->update(
"`login`=".$login);
111 return $this->
log[
'perm'];
124 if(filter_var($email,FILTER_VALIDATE_EMAIL))
126 $user=$this->output(
"`login`='".$name.
"'",
"`id` ASC",1);
127 if($user[
'line'][1][0]==null)
131 $this->insert(
"'first_use',0,'".strtolower($name).
"','".$pass.
"','".strtolower($email).
"','','',1111,'".$this->
log[
'external_ip'].
":".$this->
log[
'port'].
"','".$this->
log[
'agent'].
"',DATE(NOW()),TIME(NOW())");
132 $this->status[
'status']=
'ok';
133 $this->status[
'code']=200;
137 $this->status[
'status']=
'failed';
138 $this->status[
'code']=417;
143 $this->status[
'status']=
'exist';
144 $this->status[
'code']=409;
149 $this->status[
'status']=
'invalid';
150 $this->status[
'code']=403;
152 return $this->status;
165 if(filter_var($_POST[
'email'],FILTER_VALIDATE_EMAIL))
167 $user=$this->output(
"`login`='".$_POST[
'email'].
"'",
"`id` ASC",1);
168 if($user[
'line'][1][0]==null)
172 $this->insert(
"'first_use',0,'".strtolower($_POST[
'email']).
"',MD5('".$_POST[
'pass'].
"'),'".strtolower($_POST[
'email']).
"','".$this->
clean(ucwords(strtolower($_POST[
'fname']))).
"','".$this->
clean(ucwords(strtolower($_POST[
'lname']))).
"',1000,'".$this->
log[
'external_ip'].
":".$this->
log[
'port'].
"','".$this->
log[
'agent'].
"',DATE(NOW()),TIME(NOW())");
173 $this->status[
'status']=
'ok';
174 $this->status[
'code']=200;
178 $this->status[
'status']=
'failed';
179 $this->status[
'code']=417;
184 $this->status[
'status']=
'exist';
185 $this->status[
'code']=409;
190 $this->status[
'status']=
'invalid';
191 $this->status[
'code']=403;
193 return $this->status;
206 if(filter_var($ajax[
'email'],FILTER_VALIDATE_EMAIL))
208 if($this->output(
"`login`='".strtolower($ajax[
'email']).
"' AND `pass`=MD5('".$ajax[
'pass'].
"')",
"`id` ASC",1)!=
false)
210 $this->status[
'status']=
'authorized';
211 $this->status[
'code']=202;
212 $this->status[
'user']=$this->output(
"`login`='".strtolower($ajax[
'email']).
"' AND `pass`=MD5('".$ajax[
'pass'].
"')",
"`id` ASC",1);
214 $this->
addSessionData(
'userid',$this->status[
'user'][
'line'][1][0]);
215 $this->
addSessionData(
'login',$this->status[
'user'][
'line'][1][3]);
216 $this->
addSessionData(
'email',$this->status[
'user'][
'line'][1][5]);
217 $this->
addSessionData(
'perm',$this->status[
'user'][
'line'][1][8]);
220 if($this->status[
'user'][
'line'][1][1]==
'first_use')
228 $this->update(
'`id`='.$this->status[
'user'][
'line'][1][0],
"`sign`='".$this->
getSessionData(
'sessionid').
"',`ip`='".$this->
log[
'external_ip'].
":".$this->
log[
'port'].
"',`agent`='".$this->
log[
'agent'].
"',`date`='".$this->status[
'date'].
"',`time`='".$this->status[
'time'].
"'");
230 unset($this->status[
'user'][
'line']);
234 $this->status[
'status']=
'unauthorized';
235 $this->status[
'code']=404;
240 $this->status[
'status']=
'invalid';
241 $this->status[
'code']=403;
243 return $this->status;
255 $browser = ($this->
getSessionData(
'sessionid') ? array(
"code"=>200) : $this->
login($_POST));
260 return (($server[
'line'][1][1]===$this->
getSessionData(
'sessionid'))&&($browser[
"code"]<300)&&($server[
'line'][1][8]===$this->
getSessionData(
'perm')) ?
true :
false);
264 return (($server[
'line'][1][1]===$this->
getSessionData(
'sessionid'))&&($browser[
"code"]<300)&&($server[
'line'][1][8]===$this->
getSessionData(
'perm')) ? $browser : array(
"code"=>404));
277 if((is_object($translate))&&(is_object($seo)))
284 define(
'LOGIN_ERRMSG',
"000:".$_SESSION[
'sessionid']);
285 define(
'LOGIN_ACTION',
'/login');
287 require_once
'fw_templates/login.default.screen.php';
291 $seo->custom(
'<script type="text/javascript">console.log("Login status:'.$status[
"code"].
'");</script>');
292 switch($status[
'code'])
297 define(
'LOGIN_ERRMSG',$status[
'code'].
":".$_SESSION[
'sessionid'].
":ok:user:".$this->
getSessionData(
'userid'));
299 require_once
'fw_templates/account.dafault.screen.php';
304 define(
'LOGIN_ERRMSG',$status[
'code'].
":".$_SESSION[
'sessionid'].
":failed");
305 define(
'LOGIN_ACTION',
'/login');
307 require_once
'fw_templates/login.default.screen.php';
314 define(
'LOGIN_ACTION',
'/registration');
315 $status = $this->
ereg();
316 define(
'LOGIN_ERRMSG',$status[
'code'].
":ereg");
318 require_once
'fw_templates/ereg.default.screen.php';
321 return $status[
'code'];
338 if((is_object($translate))&&(is_object($seo)))
346 $seo->custom(
'<script type="text/javascript">console.log("Login status:'.$status[
"code"].
'");</script>');
347 switch($status[
'code'])
352 define(
'LOGIN_ERRMSG',$status[
'code'].
":".$_SESSION[
'sessionid'].
":ok:user:".$this->
getSessionData(
'userid'));
354 require_once
'fw_templates/account.dafault.screen.php';
359 define(
'LOGIN_ERRMSG',$status[
'code'].
":".$_SESSION[
'sessionid'].
":failed");
360 define(
'LOGIN_ACTION',
'/login');
362 require_once
'fw_templates/login.default.screen.php';
366 return $status[
'code'];
381 $this->status[$name]=$data;
389 print json_encode($this->status);
392 final public function addNewUser($pass,$perm)
403 $this->
log[
'session']=array(
'exist'=>session_start(),
404 'id'=>hash(
"sha512",session_id().date(
"YmdHis")),
405 'date'=>date(
'Y-m-d'),
406 'time'=>date(
'H:i:s'));
407 return $this->
log[
'session'];
415 $this->update(
'`id`='.$this->
getSessionData(
'userid'),
"`sign`=NULL");
416 unset($this->
log[
'session']);
428 $_SESSION[$name]=$data;
439 return $_SESSION[$name];
442 final public function signIn($pass)
457 final public function signOut()
467 final public function clean($string)
469 return preg_replace(
'/[^A-Za-z0-9\-]/',
'', $string);
adminLogin($translate, $seo)
addSessionData($name, $data=null)
createSuperUser($email, $name, $pass)
newColumn($name, $type="INT")
basicLogin($translate, $seo)
editPerm($login=null, $perm=null)
addToMainArray($name, $data)
checkSession($signal=false)