Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class user
- {
- private $nick;
- private $pass;
- private $name;
- private $age;
- private $email;
- private $ip;
- private $config = file($_SERVER["DOCUMENT_ROOT"]."/system/config/db.txt");
- private $dbhost = $config[0];
- private $dbuser = $config[1];
- private $dbpass = $config[2];
- private $dbtable = $config[3];
- private $mysql = new mysqli($dbhost,$dbuser,$dbpass,$dbtable);
- public function set($params = [])
- {
- foreach($params as $key => $value){
- if (isset($this->$key)) $this->$key = $value;
- }
- }
- public function add()
- {
- $nick = $this->nick;
- $date = time();
- $email = $this->email;
- $ip = $this->ip;
- $pass = md5($date.$this->pass.$ip);
- $query = "INSERT `user` (`nick`,`pass`,`email`,`ip_reg`,`date_reg`,`ip_last`,`date_last`) VALUES ('$nick','$pass','$email','$ip','$date','$ip','$date')";
- if ($this->mysql->query($query)) return true;
- return false;
- }
- public function update($params = [])
- {
- for ($i = 0; $i < count($params); $i++)
- {
- $query = "";
- $param = $params[$i];
- $value = @$this->$param;
- if (!empty($value))
- {
- $query = "UPDATE `user` SET `$param` = '$value'";
- }
- else
- {
- $error[$param] = $value;
- }
- $this->mysql->query($query);
- }
- if (count($error) < 1) return ["status"=>"success"];
- return ["status"=>"unsuccess","errors"=>$error];
- }
- //add new user functions here
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement