This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Base extends CI_Controller { | |
/** | |
* Carrega a home | |
*/ | |
public function Index() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `tokens` ( | |
`token` mediumtext | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
$autoload['packages'] = array(); | |
$autoload['libraries'] = array('database'); | |
$autoload['drivers'] = array(); | |
$autoload['helper'] = array('url'); | |
$autoload['config'] = array(); | |
$autoload['language'] = array(); | |
$autoload['model'] = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
$route['default_controller'] = 'Base'; | |
$route['404_override'] = ''; | |
$route['translate_uri_dashes'] = FALSE; | |
$route['generate-token'] = "Base/GenerateToken"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
$active_group = 'default'; | |
$query_builder = TRUE; | |
$db['default'] = array( | |
'dsn' => '', | |
'hostname' => 'host', | |
'username' => 'usuario', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div> | |
<h1>Tokens únicos com CodeIgniter</h1> | |
</div> | |
<p><a href="<?=base_url('generate-token')?>" title="Clique aqui para gerar um token único">Clique aqui</a> para gerar um token único.</p> | |
<?php if($tokens): ?> | |
<h3>Outros tokens gerados</h3> | |
<ul> | |
<?php foreach($tokens as $tk): ?> | |
<li><?=$tk->token?></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div> | |
<h1>Tokens únicos com CodeIgniter</h1> | |
</div> | |
<h2>Seu token</h2> | |
<p><?=$token?></p> | |
<p><a href="<?=base_url('generate-token')?>" title="Clique aqui para gerar outro token único">Clique aqui</a> para gerar outro token único.</p> | |
<?php if($tokens): ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Tokens_model extends CI_Model{ | |
/** | |
* Function SaveToken | |
* | |
* Salva o token gerado no banco de dados | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Base extends CI_Controller { | |
function __construct(){ | |
parent::__construct(); | |
$this->load->model("Tokens_model"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gera o name e o hash para o campo hidden | |
$data['csrf'] = array( | |
'name' => $this->security->get_csrf_token_name(), | |
'hash' => $this->security->get_csrf_hash() | |
); | |
// Passa os valores para a view | |
$this->load->view('view', $data); |