le he estado dando vueltas a este array pero por mas que me lo plantee no consigo dar con la forma en la que funciona
Les agradeceria que me lo explicaran.
Necesito que me expliquen solo la función user
éste es el array:
Código PHP:
Ver original
function user($key){ switch($key){ case "id": $value = $this->user[0]; break; case "name": $value = $this->user[1]; break; case "password": $value = $this->user[2]; break; case "rank": $value = $this->user[3]; break; case "birth": $value = $this->user[5]; break; case "figure": $value = $this->user[6]; break; case "sex": $value = $this->user[7]; break; case "mission": $value = $this->user[8]; break; case "credits": $value = $this->user[9]; break; case "tickets": $value = $this->user[10]; break; case "ticket_sso": $value = $this->user[11]; break; default: $value = $GLOBALS['serverdb']->result($GLOBALS['serverdb']->query("SELECT ".$key." FROM ".PREFIX."users WHERE id = '".$this->user[0]."' LIMIT 1")); break; } return $value; }
y ésta es la class completa:
Código PHP:
Ver original
class HoloUser { var $id = 0; var $name = "Guest"; var $password = null; var $logged_in = false; var $ip = null; var $time = null; var $error = 0; var $banned; var $user = array('0','Guest','null','0',null,null,null,null,null,null,null,null,null); function HoloUser($name,$password,$updateuser=false,$rememberme=null){ $data = new index_sql; $date = HoloDate(); $this->error = 1; return false; } if($GLOBALS['serverdb']->num_rows($data->select1($name, $password)) < 1){ $this->error = 2; return false; } $id = $GLOBALS['serverdb']->result($data->select1($name, $password)); if($this->IsUserBanned($id) == true){ $row = $GLOBALS['serverdb']->fetch_row($GLOBALS['core']->select2($id)); $this->banned['reason'] = $row[0]; $this->banned['expire'] = $row[1]; $this->error = 3; return false; } $this->ip = $_SERVER['REMOTE_ADDR']; if($rememberme == "true"){ $token = GenerateTicket("remember"); $GLOBALS['serverdb']->query("UPDATE ".PREFIX."users SET remember_token = '".$token."' WHERE id = '".$id."' LIMIT 1"); } if($updateuser == true){ $this->updateUser($id); } $this->user = $GLOBALS['serverdb']->fetch_row($GLOBALS['core']->select3($id)); $this->id = $id; $this->name = $this->user("name"); $this->figure = $this->user("figure"); $this->password = $password; $this->logged_in = true; } return true; } function destroy(){ return true; } function refresh(){ $GLOBALS['user'] = new HoloUser($this->name,$this->password); $_SESSION['user'] = $GLOBALS['user']; return true; } function user($key){ switch($key){ case "id": $value = $this->user[0]; break; case "name": $value = $this->user[1]; break; case "password": $value = $this->user[2]; break; case "rank": $value = $this->user[3]; break; case "birth": $value = $this->user[5]; break; case "figure": $value = $this->user[6]; break; case "sex": $value = $this->user[7]; break; case "mission": $value = $this->user[8]; break; case "credits": $value = $this->user[9]; break; case "tickets": $value = $this->user[10]; break; case "ticket_sso": $value = $this->user[11]; break; default: $value = $GLOBALS['serverdb']->result($GLOBALS['serverdb']->query("SELECT ".$key." FROM ".PREFIX."users WHERE id = '".$this->user[0]."' LIMIT 1")); break; } return $value; } }
Muchas gracias