Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined("BASEPATH")) exit("No direct script access allowed");
- class Passo extends CI_Controller {
- public function __construct(){
- parent::__construct();
- }
- public function index(){
- init_painel();
- $this->form_validation->set_rules('user_nome', 'NOME COMPLETO', 'trim|required|ucwords');
- $this->form_validation->set_rules('user_email', 'EMAIL', 'trim|required|valid_email|strtolower');
- $this->form_validation->set_rules('user_login', 'LOGIN', 'trim|required|min_length[4]|strtolower');
- $this->form_validation->set_rules('user_senha', 'SENHA', 'trim|required|min_length[4]|strtolower');
- if ($this->form_validation->run()==TRUE):
- //criar arquivos
- $this->load->helper('file');
- //criar tabelas
- $sql_bd = "CREATE TABLE IF NOT EXISTS `auditoria` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `usuario` varchar(45) NOT NULL,
- `data_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `operacao` varchar(45) NOT NULL,
- `query` text NOT NULL,
- `observacao` text NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
- $this->db->query($sql_bd);
- $sql_bd = "CREATE TABLE IF NOT EXISTS `midia` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `nome` varchar(45) NOT NULL,
- `descricao` varchar(255) NOT NULL,
- `arquivo` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
- $this->db->query($sql_bd);
- $sql_bd = "CREATE TABLE IF NOT EXISTS `paginas` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `titulo` varchar(255) NOT NULL,
- `slug` varchar(255) NOT NULL,
- `conteudo` longtext NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
- $this->db->query($sql_bd);
- $sql_bd = "CREATE TABLE IF NOT EXISTS `settings` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `nome_config` varchar(255) NOT NULL,
- `valor_config` text NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
- $this->db->query($sql_bd);
- $sql_bd = "CREATE TABLE IF NOT EXISTS `usuarios` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `nome` varchar(100) NOT NULL,
- `email` varchar(100) NOT NULL,
- `login` varchar(45) NOT NULL,
- `senha` varchar(32) NOT NULL,
- `ativo` tinyint(1) NOT NULL DEFAULT '1',
- `adm` tinyint(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
- $criacao_bd = $this->db->query($sql_bd);
- //criar o primeiro usuario
- if ($criacao_bd == TRUE):
- $dados["nome"] = $this->input->post('user_nome');
- $dados["email"] = $this->input->post('user_email');
- $dados["login"] = $this->input->post('user_login');
- $dados["senha"] = md5($this->input->post('user_senha'));
- $dados["adm"] = 1;
- $usuario = $this->db->insert('usuarios', $dados);
- if ($usuario == TRUE) redirect('instalar/sucesso');
- endif;
- endif;
- set_tema('titulo', 'Instalação do sistema');
- set_tema('conteudo', load_modulo('instalar', 'passo'));
- set_tema('rodape', '');
- load_template();
- }
- }
- /* End of file instalar.php */
- /* Location: ./application/controllers/instalar.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement