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 IF NOT EXISTS `usuarios` ( | |
`codigo` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, | |
`nome` VARCHAR(50) NOT NULL, | |
`email` VARCHAR(100) NOT NULL, | |
`senha` VARCHAR(70) NOT NULL, | |
`ativo` CHAR(1) NOT NULL DEFAULT '1', | |
`cadastro` DATETIME NOT NULL | |
) ENGINE = MyISAN | |
DEFAULT CHARACTER SET = 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 | |
require_once "src/Sys/Conexao.php"; | |
use Sys\Conexao; | |
try { | |
$conexao = new Conexao("localhost", "sistema_login", "root", ""); | |
$conexao->executar("INSERT INTO usuarios (nome, email, senha, cadastro) VALUES (?, ?, ?, ?)", array('Administrador', 'admin@gmail.com', md5('123'), date('Y-m-d'))); | |
} catch (\PDOException $ex) { |
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 | |
namespace Sys; | |
class Conexao { | |
private static $pdo; | |
/** | |
* @param string $servidor |
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 | |
namespace Sys; | |
class Sessao | |
{ | |
public function __construct() { | |
if (!isset($_SESSION)) | |
session_start(); |
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 | |
namespace Sys; | |
class ValidacaoException extends \Exception {} |
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 | |
namespace Sys; | |
class Usuario | |
{ | |
const ATIVO = 1; | |
const INVATIVO = 0; | |
/** |
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 | |
require_once "src/Sys/Conexao.php"; | |
require_once "src/Sys/Sessao.php"; | |
require_once "src/Sys/Usuario.php"; | |
require_once "src/Sys/ValidacaoException.php"; | |
use Sys\Conexao; | |
use Sys\Sessao; | |
use Sys\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
<?php | |
require_once "src/Sys/Sessao.php"; | |
use Sys\Sessao; | |
$sessao = new Sessao(); | |
if ($sessao->existe('usuario_logado')) { | |
$usuario = $sessao->ler('usuario_logado'); |
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 | |
// Test cards | |
$cards = array( | |
'378282246310005', // American Express | |
'371449635398431', // American Express | |
'5078601870000127985', // Aura | |
'5078601800003247449', // Aura | |
'30569309025904', // Diners Club | |
'38520000023237', // Diners Club |
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
const { reduce } = require('lodash'); | |
const replaceMap = { | |
'a': '[àáâãäå]', | |
'b': '[ß]', | |
'c': '[ç]', | |
'e': '[èéêë]', | |
'i': '[ìíîï]', | |
'o': '[ðñòóôõöø]', | |
's': '[$]', |
OlderNewer