Advertisement
eduardopaludo

controller_passo.php

Jul 30th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.17 KB | None | 0 0
  1. <?php if ( ! defined("BASEPATH")) exit("No direct script access allowed");
  2.  
  3. class Passo extends CI_Controller {
  4.        
  5.     public function __construct(){
  6.         parent::__construct();
  7.     }
  8.  
  9.     public function index(){
  10.         init_painel();
  11.        
  12.         $this->form_validation->set_rules('user_nome', 'NOME COMPLETO', 'trim|required|ucwords');
  13.         $this->form_validation->set_rules('user_email', 'EMAIL', 'trim|required|valid_email|strtolower');
  14.         $this->form_validation->set_rules('user_login', 'LOGIN', 'trim|required|min_length[4]|strtolower');
  15.         $this->form_validation->set_rules('user_senha', 'SENHA', 'trim|required|min_length[4]|strtolower');
  16.         if ($this->form_validation->run()==TRUE):
  17.             //criar arquivos
  18.             $this->load->helper('file');
  19.             //criar tabelas
  20.             $sql_bd = "CREATE TABLE IF NOT EXISTS `auditoria` (
  21.               `id` int(11) NOT NULL AUTO_INCREMENT,
  22.               `usuario` varchar(45) NOT NULL,
  23.               `data_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  24.               `operacao` varchar(45) NOT NULL,
  25.               `query` text NOT NULL,
  26.               `observacao` text NOT NULL,
  27.               PRIMARY KEY (`id`)
  28.             ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;";
  29.             $this->db->query($sql_bd);
  30.            
  31.             $sql_bd = "CREATE TABLE IF NOT EXISTS `midia` (
  32.               `id` int(11) NOT NULL AUTO_INCREMENT,
  33.               `nome` varchar(45) NOT NULL,
  34.               `descricao` varchar(255) NOT NULL,
  35.               `arquivo` varchar(255) NOT NULL,
  36.               PRIMARY KEY (`id`)
  37.             ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;";
  38.             $this->db->query($sql_bd);
  39.            
  40.             $sql_bd = "CREATE TABLE IF NOT EXISTS `paginas` (
  41.               `id` int(11) NOT NULL AUTO_INCREMENT,
  42.               `titulo` varchar(255) NOT NULL,
  43.               `slug` varchar(255) NOT NULL,
  44.               `conteudo` longtext NOT NULL,
  45.               PRIMARY KEY (`id`)
  46.             ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;";
  47.             $this->db->query($sql_bd);
  48.            
  49.             $sql_bd = "CREATE TABLE IF NOT EXISTS `settings` (
  50.               `id` int(11) NOT NULL AUTO_INCREMENT,
  51.               `nome_config` varchar(255) NOT NULL,
  52.               `valor_config` text NOT NULL,
  53.               PRIMARY KEY (`id`)
  54.             ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;";
  55.             $this->db->query($sql_bd);
  56.            
  57.             $sql_bd = "CREATE TABLE IF NOT EXISTS `usuarios` (
  58.               `id` int(11) NOT NULL AUTO_INCREMENT,
  59.               `nome` varchar(100) NOT NULL,
  60.               `email` varchar(100) NOT NULL,
  61.               `login` varchar(45) NOT NULL,
  62.               `senha` varchar(32) NOT NULL,
  63.               `ativo` tinyint(1) NOT NULL DEFAULT '1',
  64.               `adm` tinyint(1) NOT NULL DEFAULT '0',
  65.               PRIMARY KEY (`id`)
  66.             ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;";
  67.             $criacao_bd = $this->db->query($sql_bd);
  68.            
  69.             //criar o primeiro usuario
  70.             if ($criacao_bd == TRUE):
  71.                 $dados["nome"] = $this->input->post('user_nome');
  72.                 $dados["email"] = $this->input->post('user_email');
  73.                 $dados["login"] = $this->input->post('user_login');
  74.                 $dados["senha"] = md5($this->input->post('user_senha'));
  75.                 $dados["adm"] = 1;
  76.                 $usuario = $this->db->insert('usuarios', $dados);
  77.                 if ($usuario == TRUE) redirect('instalar/sucesso');
  78.             endif;
  79.         endif;
  80.         set_tema('titulo', 'Instalação do sistema');
  81.         set_tema('conteudo', load_modulo('instalar', 'passo'));
  82.         set_tema('rodape', '');
  83.         load_template();
  84.     }
  85.  
  86. }
  87.  
  88. /* End of file instalar.php */
  89. /* Location: ./application/controllers/instalar.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement