public function index() { if (!empty($this->usuario)) { redirect(base_url('inicio'), 'redirect'); } //Si esta logueado redirigimos al dashboard $this->load->helper('form'); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Usuario', 'trim|required|max_length[20]'); $this->form_validation->set_rules('password', 'Clave', 'required|max_length[20]'); if ($this->form_validation->run() == FALSE) { $val_err = validation_errors(); set_error($val_err, 'login', true); } else { $username = set_value('username'); $password = set_value('password'); $result = $this->usuarios_model->get(null, $username); if ($result != false && strtolower($result->UsuarioNick) == strtolower($username) && $this->usuarios_model->ComprobarClave($result->UsuarioClave, $password)) { if ($result->UsuarioEstado == 0) { //Usuario inactivo set_error('001', 'login'); } elseif ($result->UsuarioEstado == 2) { set_error('003', 'login'); } else { $this->usuarios_model->setUltimaConex($result->UsuarioId, $result->UsuarioFecha, $result->UsuarioIp); $this->session->set_userdata(array('UsuarioId' => $result->UsuarioId)); redirect(base_url('inicio')); } } else { //Usuario o clave incorrectos set_error('002', 'login'); } } $this->vista('login/inicio', null, 'Iniciar SesiĆ³n'); }
function query($sql, $debug_message = '') { if (class_exists('module_db', false) && is_callable('module_db::query')) { return module_db::query($sql, $debug_message); } //echo ''.$sql.'<br>'; if (_DEBUG_MODE && defined('_DEBUG_SQL') && _DEBUG_SQL) { static $past_queries = array(); if (!isset($past_queries[$sql])) { $past_queries[$sql] = 0; } else { $past_queries[$sql]++; } $sql_debug = $sql; if (strlen($sql_debug) > 60) { $sql_debug = htmlspecialchars(substr($sql_debug, 0, 60)) . '<a href="#" onclick="$(this).hide(); $(\'span\',$(this).parent()).show(); return false;">....</a><span style="display:none">' . htmlspecialchars(substr($sql, 60)) . '</span>'; } else { $sql_debug = htmlspecialchars($sql); } if (class_exists('module_debug', false)) { module_debug::log(array('title' => 'SQL Query', 'file' => 'includes/database.php', 'data' => '(' . ($past_queries[$sql] > 0 ? '<span style="color:#FF0000; font-weight:bold;">' . $past_queries[$sql] . '</span>' : $past_queries[$sql]) . ') ' . $debug_message . $sql_debug, 'important' => $past_queries[$sql] > 0)); } } $res = mysql_query($sql); //or die(mysql_error() . $sql); if (mysql_errno()) { set_error(_l('SQL Error: %s', mysql_error() . ' ' . $sql)); set_error(_l('Try clicking the "Run Manual Upgrades" button to resolve SQL Errors.')); return false; } return $res; }
public function setRolGrupo($Nick) { $data['grupo'] = $this->roles_model->getGrupoInfo(null, $Nick); if (!$data['grupo']) { //Si el grupo no existe o es superior al tuyo redirect(base_url('errores/404/')); } elseif (!$this->compareRangos($data['grupo'])) { set_error("014", 'grupos'); } $roles = $this->roles_model->getRoles(); if (!empty($roles)) { $i = 0; $c = 0; $ci = 0; $Roles = array(); $DRoles = array(); foreach ($roles as $rol) { $i++; if (in_array($rol->RolId, $data['grupo']->URoles)) { //Permisos de grupo $Roles[$rol->CategoriaNombre][] = $rol; } else { //Permisos sin establecer $DRoles["Otros"][$rol->CategoriaNombre][] = $rol; } } } else { set_error("018", 'inicio'); } $data['roles'] = $Roles; $data['droles'] = $DRoles; $bread = array(array("bread" => $Nick, "link" => "grupo/" . $Nick), array("bread" => "Permisos de Grupo")); $this->vista('roles/grupos', $bread, 'Permisos de ' . $Nick, $data, "roles"); }
/** * Displays the errors in a user friendly box */ function show_errors() { $errors = set_error(); if (!empty($errors)) { $errors = implode('<br/>', $errors); show_view('five-notification-error', array('notification' => $errors)); } }
function insere($con, $vol_id) { $sql = "INSERT INTO lacres VALUES (NULL"; $sql .= ", " . $con->quote($vol_id); $sql .= ", " . $con->quote($this->nLacre); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro lacres: ' . $qry->getMessage()); return false; } else { $lacres_id = $con->lastInsertID("lacres", "lacres_id"); } }
function insere($con, $det_id) { $sql = "INSERT INTO infAdProd VALUES (NULL"; $sql .= ", " . $con->quote($det_id); $sql .= ", " . $con->quote($this->infAdProd); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro infAdProd: ' . $qry->getMessage()); return false; } else { $infAdProd_id = $con->lastInsertID("infAdProd", "infAdProd_id"); } }
function insere($con, $infAdic_id) { $sql = "INSERT INTO procRef VALUES (NULL"; $sql .= ", " . $con->quote($infAdic_id); $sql .= ", " . $con->quote($this->nProc); $sql .= ", " . $con->quote($this->indProc); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro procRef: ' . $qry->getMessage()); return false; } else { $procRef_id = $con->lastInsertID("procRef", "procRef_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO exporta VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ", " . $con->quote($this->UFEmbarq); $sql .= ", " . $con->quote($this->xLocEmbarq); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro exporta: ' . $qry->getMessage()); return false; } else { $exporta_id = $con->lastInsertID("exporta", "exporta_id"); } }
function insere($con, $infAdic_id) { $sql = "INSERT INTO obsCont VALUES (NULL"; $sql .= ", " . $con->quote($infAdic_id); $sql .= ", " . $con->quote($this->xCampo); $sql .= ", " . $con->quote($this->xTexto); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro obsCont: ' . $qry->getMessage()); return false; } else { $obsCont_id = $con->lastInsertID("obsCont", "obsCont_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO compra VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ", " . $con->quote($this->xNEmp); $sql .= ", " . $con->quote($this->xPed); $sql .= ", " . $con->quote($this->xCont); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro compra: ' . $qry->getMessage()); return false; } else { $compra_id = $con->lastInsertID("compra", "compra_id"); } }
function insere($con, $transp_id) { $sql = "INSERT INTO veicTransp VALUES (NULL"; $sql .= ", " . $con->quote($transp_id); $sql .= ", " . $con->quote($this->placa); $sql .= ", " . $con->quote($this->UF); $sql .= ", " . $con->quote($this->RNTC); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro veicTransp: ' . $qry->getMessage()); return false; } else { $veicTransp_id = $con->lastInsertID("veicTransp", "veicTransp_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO total VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro total: ' . $qry->getMessage()); return false; } else { $total_id = $con->lastInsertID("total", "total_id"); $this->ICMSTot->insere($con, $total_id); is_object($this->ISSQNtot) ? $this->ISSQNtot->insere($con, $total_id) : null; is_object($this->retTrib) ? $this->retTrib->insere($con, $total_id) : null; } }
function insere($con, $cobr_id) { $sql = "INSERT INTO dup VALUES (NULL"; $sql .= ", " . $con->quote($cobr_id); $sql .= ", " . $con->quote($this->nDup); $sql .= ", " . $con->quote($this->dVenc); $sql .= ", " . $con->quote($this->vDup); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro dup: ' . $qry->getMessage()); return false; } else { $dup_id = $con->lastInsertID("dup", "dup_id"); } }
function insere($con, $DI_id) { $sql = "INSERT INTO adi VALUES (NULL"; $sql .= ", " . $con->quote($DI_id); $sql .= ", " . $con->quote($this->nAdicao); $sql .= ", " . $con->quote($this->nSeqAdic); $sql .= ", " . $con->quote($this->cFabricante); $sql .= ", " . $con->quote($this->vDescDI); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro adi: ' . $qry->getMessage()); return false; } else { $adi_id = $con->lastInsertID("adi", "adi_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO cobr VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro cobr: ' . $qry->getMessage()); return false; } else { $cobr_id = $con->lastInsertID("cobr", "cobr_id"); is_object($this->fat) ? $this->fat->insere($con, $cobr_id) : null; for ($i = 0; $i < count($this->dup); $i++) { $this->dup[$i]->insere($con, $cobr_id); } } }
function insere($con, $cobr_id) { $sql = "INSERT INTO fat VALUES (NULL"; $sql .= ", " . $con->quote($cobr_id); $sql .= ", " . $con->quote($this->nFat); $sql .= ", " . $con->quote($this->vOrig); $sql .= ", " . $con->quote($this->vDesc); $sql .= ", " . $con->quote($this->vLiq); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro fat: ' . $qry->getMessage()); return false; } else { $fat_id = $con->lastInsertID("fat", "fat_id"); } }
function insere($con, $imposto_id) { $sql = "INSERT INTO II VALUES (NULL"; $sql .= ", " . $con->quote($imposto_id); $sql .= ", " . $con->quote($this->vBC); $sql .= ", " . $con->quote($this->vDespAdu); $sql .= ", " . $con->quote($this->vII); $sql .= ", " . $con->quote($this->vIOF); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro II: ' . $qry->getMessage()); return false; } else { $II_id = $con->lastInsertID("II", "II_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO det VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ", " . $con->quote($this->nItem); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro det: ' . $qry->getMessage()); return false; } else { $det_id = $con->lastInsertID("det", "det_id"); $this->prod->insere($con, $det_id); $this->imposto->insere($con, $det_id); is_object($this->infAdProd) ? $this->infAdProd->insere($con, $det_id) : null; } }
/** * Checks if a user has the rights to view this page, is not locked/banned or not logged in * * @param string $name - permission name */ function auth($name) { locked(); // stop blocked people from acessing if (!$this->loggedIn()) { // if not authorised/logged in set_error('Please login to Echelon'); sendLogin(); exit; } if (!$this->reqLevel($name)) { // if users level is less than needed access, deny entry, and cause error set_error('You do not have the correct privilages to view that page'); sendHome(); exit; } }
function insere($con, $prod_id) { $sql = "INSERT INTO arma VALUES (NULL"; $sql .= ", " . $con->quote($prod_id); $sql .= ", " . $con->quote($this->tpArma); $sql .= ", " . $con->quote($this->nSerie); $sql .= ", " . $con->quote($this->nCano); $sql .= ", " . $con->quote($this->descr); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro arma: ' . $qry->getMessage()); return false; } else { $arma_id = $con->lastInsertID("arma", "arma_id"); } }
function insere($con, $imposto_id) { $sql = "INSERT INTO ISSQN VALUES (NULL"; $sql .= ", " . $con->quote($imposto_id); $sql .= ", " . $con->quote($this->vBC); $sql .= ", " . $con->quote($this->vAliq); $sql .= ", " . $con->quote($this->vISSQN); $sql .= ", " . $con->quote($this->cMunFG); $sql .= ", " . $con->quote($this->cListServ); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro ISSQN: ' . $qry->getMessage()); return false; } else { $ISSQN_id = $con->lastInsertID("ISSQN", "ISSQN_id"); } }
function insere($con, $imposto_id) { $sql = "INSERT INTO PISST VALUES (NULL"; $sql .= ", " . $con->quote($imposto_id); $sql .= ", " . $con->quote($this->vBC); $sql .= ", " . $con->quote($this->pPIS); $sql .= ", " . $con->quote($this->qBCProd); $sql .= ", " . $con->quote($this->vAliqProd); $sql .= ", " . $con->quote($this->vPIS); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro PISST: ' . $qry->getMessage()); return false; } else { $PISST_id = $con->lastInsertID("PISST", "PISST_id"); } }
function insere($con, $total_id) { $sql = "INSERT INTO ISSQNtot VALUES (NULL"; $sql .= ", " . $con->quote($total_id); $sql .= ", " . $con->quote($this->vServ); $sql .= ", " . $con->quote($this->vBC); $sql .= ", " . $con->quote($this->vISS); $sql .= ", " . $con->quote($this->vPIS); $sql .= ", " . $con->quote($this->vCOFINS); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro ISSQNtot: ' . $qry->getMessage()); return false; } else { $ISSQNtot_id = $con->lastInsertID("ISSQNtot", "ISSQNtot_id"); } }
/** * Function is responsible for authenticating users and redirecting * them upon a succesful login. * * @param unknown_type $username * @param unknown_type $password * @param unknown_type $remember */ function interal_authentication($username, $password, $remember = false) { //redirect if successful already if (is_user_logged_in()) { redirect(Router::url(array('controller' => 'user', 'action' => 'profile'))); } if (login_has_error()) { return false; } $user = FiveTable::getInstance('user'); if (!$user->authenticate($username, $password)) { set_error($user->getErrors()); login_has_error(1); } else { //success redirect(Router::url(array('controller' => 'user', 'action' => 'profile'))); } }
function insere($con, $prod_id) { $sql = "INSERT INTO med VALUES (NULL"; $sql .= ", " . $con->quote($prod_id); $sql .= ", " . $con->quote($this->nLote); $sql .= ", " . $con->quote($this->qLote); $sql .= ", " . $con->quote($this->dFab); $sql .= ", " . $con->quote($this->dVal); $sql .= ", " . $con->quote($this->vPMC); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro med: ' . $qry->getMessage()); return false; } else { $med_id = $con->lastInsertID("med", "med_id"); } }
function insere($con, $infNFe_id) { $sql = "INSERT INTO dest VALUES (NULL"; $sql .= ", " . $con->quote($infNFe_id); $sql .= ", " . $con->quote($this->CNPJ); $sql .= ", " . $con->quote($this->CPF); $sql .= ", " . $con->quote($this->xNome); $sql .= ", " . $con->quote($this->IE); $sql .= ", " . $con->quote($this->ISUF); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro dest: ' . $qry->getMessage()); return false; } else { $dest_id = $con->lastInsertID("dest", "dest_id"); $this->enderDest->insere($con, $dest_id); } }
function insere($con, $ide_id) { $sql = "INSERT INTO refNF VALUES (NULL"; $sql .= ", " . $con->quote($ide_id); $sql .= ", " . $con->quote($this->cUF); $sql .= ", " . $con->quote($this->AAMM); $sql .= ", " . $con->quote($this->CNPJ); $sql .= ", " . $con->quote($this->mod); $sql .= ", " . $con->quote($this->serie); $sql .= ", " . $con->quote($this->nNF); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro refNF: ' . $qry->getMessage()); return false; } else { $refNF_id = $con->lastInsertID("refNF", "refNF_id"); } }
function insere($con, $transp_id) { $sql = "INSERT INTO retTransp VALUES (NULL"; $sql .= ", " . $con->quote($transp_id); $sql .= ", " . $con->quote($this->vServ); $sql .= ", " . $con->quote($this->vBCRet); $sql .= ", " . $con->quote($this->pICMSRet); $sql .= ", " . $con->quote($this->vICMSRet); $sql .= ", " . $con->quote($this->CFOP); $sql .= ", " . $con->quote($this->cMunFG); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro retTransp: ' . $qry->getMessage()); return false; } else { $retTransp_id = $con->lastInsertID("retTransp", "retTransp_id"); } }
function insere($con, $total_id) { $sql = "INSERT INTO retTrib VALUES (NULL"; $sql .= ", " . $con->quote($total_id); $sql .= ", " . $con->quote($this->vRetPIS); $sql .= ", " . $con->quote($this->vRetCOFINS); $sql .= ", " . $con->quote($this->vRetCSLL); $sql .= ", " . $con->quote($this->vBCIRRF); $sql .= ", " . $con->quote($this->vIRRF); $sql .= ", " . $con->quote($this->vBCRetPrev); $sql .= ", " . $con->quote($this->vRetPrev); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro retTrib: ' . $qry->getMessage()); return false; } else { $retTrib_id = $con->lastInsertID("retTrib", "retTrib_id"); } }
function insere($con, $ide_id) { if (!empty($this->refNFe)) { $sql = "INSERT INTO refNFe VALUES (NULL"; $sql .= ", " . $con->quote($ide_id); $sql .= ", " . $con->quote($this->refNFe); $sql .= ")"; $qry = $con->query($sql); if (MDB2::isError($qry)) { set_error('Erro refNFe: ' . $qry->getMessage()); return false; } else { $refNFe_id = $con->lastInsertID("refNFe", "refNFe_id"); } } else { if (is_object($this->refNF)) { $this->refNF->insere($con, $ide_id); } } }