<commit_before><?php
/**
 * LOGIN JOSSO CIP (C) 2016
 *
 * @package	Login
 * @author	<NAME> <<EMAIL>>
 * @copyright	Copyright (c) 2009 - 2016, PUCPR
 * @license	http://opensource.org/licenses/MIT	MIT License
 * @link	http://cip.pucpr.br/about
 * @since	Version v0.15.23
 * @filesource
 */

class login extends CI_Controller {
	function __construct() {
		global $dd, $acao;
		parent::__construct();

		$this -> load -> library("nuSoap_lib");
		$this -> load -> database();
		$this -> load -> library('form_validation');
		$this -> load -> database();
		$this -> load -> helper('form');
		$this -> load -> helper('form_sisdoc');
		$this -> load -> helper('links_users_helper');
		$this -> load -> helper('url');
		$this -> load -> library('session');
		$this -> lang -> load("app", "portuguese");
		date_default_timezone_set('America/Sao_Paulo');

		//$this -> lang -> load("app", "english");
	}

	function cab() {
		/* Carrega classes adicionais */
		$css = array();
		$js = array();
		array_push($css, 'style_cab.css');
		array_push($css, 'form_sisdoc.css');
		array_push($js, 'js_cab.js');
		array_push($js, 'unslider.min.js');

		/* transfere para variavel do codeigniter */
		$data['css'] = $css;
		$data['js'] = $js;

		/* Menu */
		$menus = array();
		array_push($menus, array('CIP', '/cip/'));

		/* Monta telas */
		$this -> load -> view('header/header', $data);
	}

	function ab($id = 0, $chk = '') {
		/* Remover */
		$chk2 = checkpost_link($id);

		if ($chk != $chk2) {
			//echo checkpost_link($id);
			echo 'Erro de Checkpost - ' . $chk2;
			return ('');
		} else {
			$id = UpperCase($id);
			$sql = "select * from logins where us_login = '$id' ";

			$rlt = $this -> db -> query($sql);
			$rlt = $rlt -> result_array();

			/* Login no localizado */
			if (count($rlt) == 0) {
				redirect(base_url('index.php'));
			}
			$line = $rlt[0];

			/* Model */
			$this -> load -> model('usuarios');

			if (count($rlt) > 0) {
				/* Recupera dados */
				$this -> josso_login_pucpr -> cpf = $line['us_cpf'];
				//$this -> josso_login_pucpr -> josso = $line['jossoSession'];
				$this -> josso_login_pucpr -> nome = $line['us_nome'];
				//$this -> josso_login_pucpr -> perfil = $line['us_perfil'];
				$this -> josso_login_pucpr -> id = $line['id_us'];
				$this -> josso_login_pucpr -> cracha = '';
				$this -> josso_login_pucpr -> nomeEmpresa = '';
				$this -> josso_login_pucpr -> nomeFilial = '';
				$this -> josso_login_pucpr -> cracha = $line['us_cracha'];
				$this -> josso_login_pucpr -> us_id = $line['us_id'];
				$this -> josso_login_pucpr -> us_id = $line['us_id'];
				$this -> josso_login_pucpr -> loged = 1;
				$this -> josso_login_pucpr -> josso = date("YmfHis");
				$this -> usuarios -> security_set($line['id_us']);
				$this -> usuarios -> historico_insere($line['us_cpf'], 'ACB');
				$link = base_url('index.php/main');
				redirect($link);
			}
		}
		echo 'ERRO DE ACESSO!';
		exit ;
	}

	function email($id, $chk = '') {
		$this -> cab();
		$this -> load -> model('usuarios');
		$this -> load -> model('mensagens');
		$dados = $this -> usuarios -> le($id);
		$data = array();
		$data['nome'] = $dados['us_nome'];
		$nw = $this -> mensagens -> busca('email_password', $data);
		$txt = $nw['nw_texto'];
		$assunto = $nw['nw_titulo'];
		$fmt = $nw['nw_formato'];
		$link = $this->usuarios->link_acesso($id);
		$link = '<a href="' . $link . '">link de acesso</a><br>ou ' . $link;
		$txt = troca($txt, '$link', $link);

		$this -> load -> view('usuario/view', $dados);

		$para = 1;
		enviaremail_usuario($id, $assunto, $txt, 2);
		$tela = '<font color="green">e-mail enviado com sucesso!</font>';
		$data['content'] = $tela;
		$this -> load -> view('content', $data);
	}

	function ac($id = 0, $chk = '') {
		/* Remover */
		$chk = checkpost_link($id);

		if ($chk != checkpost_link($id)) {
			//echo checkpost_link($id);
		} else {
			$id = round($id);
			$sql = "select * from us_usuario where id_us = " . $id;

			$rlt = $this -> db -> query($sql);
			$rlt = $rlt -> result_array();
			if (count($rlt) == 0) {
				$link = base_url('index.php/login');
			}
			$line = $rlt[0];

			/* Model */
			$this -> load -> model('usuarios');

			if (count($rlt) > 0) {
				/* Recupera dados */
				$this -> usuarios -> security_set($id);
				$this -> usuarios -> historico_insere($line['us_cpf'], 'ACR');
				$link = base_url('index.php/main');
				redirect($link);
			}
		}
		echo 'ERRO DE ACESSO!';
		exit ;
	}

	function ap($id = 0, $chk = '') {
		/* Remover */
		$chk2 = checkpost_link($id . date("Ymdhi"));

		if ($chk != $chk2) {
			redirect(base_url("index.php/login"));<commit_msg>#at.29.06.2016.b<commit_after><?php
/**
 * LOGIN JOSSO CIP (C) 2016
 *
 * @package	Login
 * @author	<NAME> <<EMAIL>>
 * @copyright	Copyright (c) 2009 - 2016, PUCPR
 * @license	http://opensource.org/licenses/MIT	MIT License
 * @link	http://cip.pucpr.br/about
 * @since	Version v0.15.23
 * @filesource
 */

class login extends CI_Controller {
	function __construct() {
		global $dd, $acao;
		parent::__construct();

		$this -> load -> library("nuSoap_lib");
		$this -> load -> database();
		$this -> load -> library('form_validation');
		$this -> load -> database();
		$this -> load -> helper('form');
		$this -> load -> helper('form_sisdoc');
		$this -> load -> helper('links_users_helper');
		$this -> load -> helper('url');
		$this -> load -> library('session');
		$this -> lang -> load("app", "portuguese");
		date_default_timezone_set('America/Sao_Paulo');

		//$this -> lang -> load("app", "english");
	}

	function cab() {
		/* Carrega classes adicionais */
		$css = array();
		$js = array();
		array_push($css, 'style_cab.css');
		array_push($css, 'form_sisdoc.css');
		array_push($js, 'js_cab.js');
		array_push($js, 'unslider.min.js');

		/* transfere para variavel do codeigniter */
		$data['css'] = $css;
		$data['js'] = $js;

		/* Menu */
		$menus = array();
		array_push($menus, array('CIP', '/cip/'));

		/* Monta telas */
		$this -> load -> view('header/header', $data);
	}

	function ab($id = 0, $chk = '') {
		/* Remover */
		$chk2 = checkpost_link($id);

		if ($chk != $chk2) {
			//echo checkpost_link($id);
			echo 'Erro de Checkpost - ' . $chk2;
			return ('');
		} else {
			$id = UpperCase($id);
			$sql = "select * from logins where us_login = '$id' ";

			$rlt = $this -> db -> query($sql);
			$rlt = $rlt -> result_array();

			/* Login no localizado */
			if (count($rlt) == 0) {
				redirect(base_url('index.php'));
			}
			$line = $rlt[0];

			/* Model */
			$this -> load -> model('usuarios');

			if (count($rlt) > 0) {
				/* Recupera dados */
				$this -> josso_login_pucpr -> cpf = $line['us_cpf'];
				//$this -> josso_login_pucpr -> josso = $line['jossoSession'];
				$this -> josso_login_pucpr -> nome = $line['us_nome'];
				//$this -> josso_login_pucpr -> perfil = $line['us_perfil'];
				$this -> josso_login_pucpr -> id = $line['id_us'];
				$this -> josso_login_pucpr -> cracha = '';
				$this -> josso_login_pucpr -> nomeEmpresa = '';
				$this -> josso_login_pucpr -> nomeFilial = '';
				$this -> josso_login_pucpr -> cracha = $line['us_cracha'];
				$this -> josso_login_pucpr -> us_id = $line['us_id'];
				$this -> josso_login_pucpr -> us_id = $line['us_id'];
				$this -> josso_login_pucpr -> loged = 1;
				$this -> josso_login_pucpr -> josso = date("YmfHis");
				$this -> usuarios -> security_set($line['id_us']);
				$this -> usuarios -> historico_insere($line['us_cpf'], 'ACB');
				$link = base_url('index.php/main');
				redirect($link);
			}
		}
		echo 'ERRO DE ACESSO!';
		exit ;
	}

	function email($id, $chk = '') {
		$this -> cab();
		$this -> load -> model('usuarios');
		$this -> load -> model('mensagens');
		$dados = $this -> usuarios -> le($id);
		$data = array();
		$data['nome'] = $dados['us_nome'];
		$nw = $this -> mensagens -> busca('email_password', $data);
		$txt = $nw['nw_texto'];
		$assunto = $nw['nw_titulo'];
		$fmt = $nw['nw_formato'];
		$link = $this->usuarios->link_acesso($id);
		$link = '<a href="' . $link . '">link de acesso</a><br>ou ' . $link;
		$txt = troca($txt, '$link', $link);

		$this -> load -> view('usuario/view', $dados);

		$para = 1;
		enviaremail_usuario($id, $assunto, $txt, 2);
		$tela = '<font color="green">e-mail enviado com sucesso!</font>';
		$data['content'] = $tela;
		$this -> load -> view('content', $data);
	}

	function ac($id = 0, $chk = '') {
		/* Remover */

		if ($chk != checkpost_link($id)) {
			//echo checkpost_link($id);
		} else {
			$id = round($id);
			$sql = "select * from us_usuario where id_us = " . $id;

			$rlt = $this -> db -> query($sql);
			$rlt = $rlt -> result_array();
			if (count($rlt) == 0) {
				$link = base_url('index.php/login');
			}
			$line = $rlt[0];

			/* Model */
			$this -> load -> model('usuarios');

			if (count($rlt) > 0) {
				/* Recupera dados */
				$this -> usuarios -> security_set($id);
				$this -> usuarios -> historico_insere($line['us_cpf'], 'ACR');
				$link = base_url('index.php/main');
				redirect($link);
			}
		}
		
		$link = base_url('index.php/error');
		redirect($link);
		
		exit ;
	}

	function ap($id = 0, $chk = '') {
		/* Remover */
		$chk2 = checkpost_link($id . date("Ymdhi"));

		if ($chk != $chk2) {
			redirect(base_url("index.php/login"));
{'fraction_non_alphanumeric': 0.22568430163366873, 'fraction_numerical': 0.008222438602185437, 'mean_word_length': 3.123104371097235, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 189, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5303712', 'n_tokens_mistral': 4126, 'n_tokens_neox': 3639, 'n_words': 728}