El error: Notice: Undefined offset: 0 in C:\xampp\htdocs\indicadores\admin\clases\usuarios. class.php on line 41
index.php
Código PHP:
Ver original
include_once("../../clases/usuarios.class.php"); $user = new usuarios(); $valido = $user->validar($_POST['username'], $_POST['pass']); if($valido){ $_SESSION['admin_log'] = true; $_SESSION['nom_usu'] = $valido['nom_usu']; $_SESSION['id_usu'] = $valido['id_usu']; echo 1; }else{ echo 0; }
usuarios.class.php
Código PHP:
La Linea: if($user[0]['pas_usu'] == md5($pass)){Ver original
<?php class usuarios{ private $db; private $modulo; private $modulos; public $table; public $tId; public function __construct(){ include('consultas.class.php'); $this->table = "usuarios"; $this->tId = "id_usu"; $this->db = new Consultas($this->table, $this->tId); ); $this->modulos = new Consultas('per_mod_usu', 'id_per'); ); $this->modulo = new Consultas('modulos', 'id_mod'); ); } public function validar($log, $pass){ $where = "`log_usu` = '$log'"; $user = $this->db->getRecords($where); return $user[0]; }else{ return false; } } public function listar($where = false){ return $this->db->getRecords($where); } public function agregar($nom, $log, $pas, $mail, $franq, $permisos){ $data[] = $nom; $data[] = $log; $data[] = $mail; $data[] = $franq; $this->db->insertRecord($data); $id_usu = $this->db->return_id(); $per[] = $permisos[$i]; $per[] = $id_usu; $per[] = '1'; $this->modulos->insertRecord($per); $per = ""; } return $id_usu; } public function consultar($id){ $result = $this->db->getRecord($id); $permisos = $this->modulos->getRecords("id_usu = $id AND visible=1"); $result[1] = $permisos; return $result; } public function editar($id, $nom, $log, $pas, $mail, $franq, $permisos){ $data[] = $nom; $data[] = $log; $data[] = $pas; $data[] = $mail; $data[] = $franq; $this->db->updateRecord($id,$data); $data = ""; $mod = $this->modulo->getRecords(); foreach($mod as $clave=>$valor){ $temp = true; $per = $this->modulos->getRecords("id_usu = $id AND id_mod = ".$valor['id_mod']); foreach($per as $clv=>$vlr){ foreach($permisos as $c=>$v){ if($v == $valor['id_mod']){ $activar[] = $v; $data[] = ''; $data[] = ''; $data[] = "1"; $this->modulos->updateRecord($vlr['id_per'],$data); $data = ""; $temp = false; } } if($temp){ $desactivar[] = $vlr['id_mod']; $data[] = ''; $data[] = ''; $data[] = "0"; $this->modulos->updateRecord($vlr['id_per'],$data); $data = ""; } } } foreach($permisos as $clv=>$vlr){ $temp = true; foreach($activar as $c=>$v){ if($v == $vlr){ $temp = false; } } if($temp){ $nuevo[] = $vlr; $data[] = $vlr; $data[] = $id; $data[] = "1"; $this->modulos->insertRecord($data); $data = ""; } } } public function borrar($id){ $this->db->deleteRecord($id); $this->modulos->deleteRecords("id_usu=$id"); } public function cambiar_pass($id, $pass){ $data[] = ''; $data[] = ''; $data[] = ''; $data[] = ''; $this->db->updateRecord($id,$data); } } ?>
Consultas.class.php
Código PHP:
Que puede Estar pasando? Ver original
<?php include("mysql.php"); class Consultas { private $link; public $table; public $fields; public $campoId; private $returnSQLResult =true; public function __construct ($table, $campoId){ $this->table =$table; $this->campoId =$campoId; } public function getRecords ($where_str=false, $order_str=false, $count=false, $start=0){ $where =$where_str ? "WHERE $where_str" : ""; $order =$order_str ? "ORDER BY $order_str" : ""; $limit = $count ? "LIMIT $start, $count" : ""; $campos =$this->getAllFields (); $query ="SELECT $campos FROM {$this->table} $where $order $limit"; return $resultado; } public function getRecord ($id){ return $this->getRecords ("{$this->campoId}=$id", false, 1); } public function insertRecord ($data){ $campos =$this->getTableFields (); $sysData =$this->getDefaultValues (); if($sysData){ $sysData .= ","; } $query ="INSERT INTO {$this->table} ($campos) VALUES ($sysData '$data')"; return $this->validateOperation(); } public function return_id(){ } public function updateRecord ($id, $data){ $campos =$this->getEditableFields (true); foreach ($campos as $ind => $campo){ $current_data =$data[$ind]; if($current_data != ""){ } } $query = "UPDATE {$this->table} SET $datos WHERE {$this->campoId}=$id"; return $this->validateOperation (); } public function deleteRecord ($id){ return $this->validateOperation (); } public function deleteRecords ($where){ return $this->validateOperation (); } public function numPag ($where_str=false, $count=0){ $where =$where_str ? "WHERE $where_str" : ""; $query ="SELECT COUNT({$this->campoId}) FROM {$this->table} $where"; return $resultado; } public function sql_direct($consulta){ return $resultado; } private function getFieldsByType ($type=''){ foreach ($this->fields as $field){ $includeField =false; foreach ($types as $t){ if ($field[0] == $t){ } } } return $return; } private function getNameFields ($type){ $fields =$this->getFieldsByType ($type); foreach ($fields as $field){ } return $return; } private function getEditableFields ($asArray=false){ $return =$this->getNameFields ('public'); } private function getTableFields ($asArray=false){ $temp =$this->getNameFields ('private'); foreach($temp as $r)$return[] = $r; $temp =$this->getNameFields ('public'); foreach($temp as $r)$return[] = $r; } private function getAllFields ($asArray=false){ $return =$this->getNameFields ('public|private|system'); } private function getDefaultValues ($asArray=false){ $fields =$this->getFieldsByType ('private'); foreach ($fields as $field){ } } private function validateOperation (){ } private function sql ($consulta){ if ($consQ){ } return $resultado; } }?>