Advertisement
eduardopaludo

controller_instalar.php

Jul 30th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.73 KB | None | 0 0
  1. <?php if ( ! defined("BASEPATH")) exit("No direct script access allowed");
  2.  
  3. class Instalar extends CI_Controller {
  4.        
  5.     public function __construct(){
  6.         parent::__construct();
  7.     }
  8.  
  9.     public function index(){
  10.         init_painel();
  11.         $this->form_validation->set_rules('url_base', 'URL', 'trim|required|strtolower');
  12.         $this->form_validation->set_rules('chave_seguranca', 'CHAVE DE SEGURANÇA', 'trim|required|strtolower');
  13.         $this->form_validation->set_rules('tempo_sessao', 'TEMPO DA SESSÃO', 'trim|required|numeric');
  14.         $this->form_validation->set_rules('hostname', 'SERVIDOR', 'trim|required');
  15.         $this->form_validation->set_rules('username', 'USUÁRIO', 'trim|required');
  16.         $this->form_validation->set_rules('password', 'SENHA', 'trim');
  17.         $this->form_validation->set_rules('database', 'NOME DO BD', 'trim|required');
  18.         if ($this->form_validation->run()==TRUE):
  19.             //criar arquivos
  20.             $this->load->helper('file');
  21.             $file_config = '<?php  if ( ! defined("BASEPATH")) exit("No direct script access allowed");
  22.                 $config["base_url"] = "'.$this->input->post('url_base').'";
  23.                 $config["index_page"] = "";
  24.                 $config["uri_protocol"] = "AUTO";
  25.                 $config["url_suffix"] = "";
  26.                 $config["language"] = "pt-BR";
  27.                 $config["charset"] = "UTF-8";
  28.                 $config["enable_hooks"] = FALSE;
  29.                 $config["subclass_prefix"] = "RB_";
  30.                 $config["permitted_uri_chars"] = "a-z 0-9~%.:_\-";
  31.                 $config["allow_get_array"]      = TRUE;
  32.                 $config["enable_query_strings"] = FALSE;
  33.                 $config["controller_trigger"]   = "c";
  34.                 $config["function_trigger"]     = "m";
  35.                 $config["directory_trigger"]    = "d";
  36.                 $config["log_threshold"] = 0;
  37.                 $config["log_path"] = "";
  38.                 $config["log_date_format"] = "Y-m-d H:i:s";
  39.                 $config["cache_path"] = "";
  40.                 $config["encryption_key"] = "'.$this->input->post('chave_seguranca').'";
  41.                 $config["sess_cookie_name"]     = "ci_session";
  42.                 $config["sess_expiration"]      = '.$this->input->post('tempo_sessao').';
  43.                 $config["sess_expire_on_close"] = TRUE;
  44.                 $config["sess_encrypt_cookie"]  = TRUE;
  45.                 $config["sess_use_database"]    = FALSE;
  46.                 $config["sess_table_name"]      = "ci_sessions";
  47.                 $config["sess_match_ip"]        = TRUE;
  48.                 $config["sess_match_useragent"] = TRUE;
  49.                 $config["sess_time_to_update"]  = 300;
  50.                 $config["cookie_prefix"]    = "";
  51.                 $config["cookie_domain"]    = "";
  52.                 $config["cookie_path"]      = "/";
  53.                 $config["cookie_secure"]    = FALSE;
  54.                 $config["global_xss_filtering"] = FALSE;
  55.                 $config["csrf_protection"] = FALSE;
  56.                 $config["csrf_token_name"] = "csrf_test_name";
  57.                 $config["csrf_cookie_name"] = "csrf_cookie_name";
  58.                 $config["csrf_expire"] = 7200;
  59.                 $config["compress_output"] = FALSE;
  60.                 $config["time_reference"] = "local";
  61.                 $config["rewrite_short_tags"] = FALSE;
  62.                 $config["proxy_ips"] = "";
  63.             /* End of file config.php */
  64.             /* Location: ./application/config/config.php */
  65.             ';
  66.             write_file('./application/config/config.php', trim($file_config));
  67.            
  68.             $file_bd = '<?php  if ( ! defined("BASEPATH")) exit("No direct script access allowed");
  69.                 $active_group = "default";
  70.                 $active_record = TRUE;
  71.                 $db["default"]["hostname"] = "'.$this->input->post('hostname').'";
  72.                 $db["default"]["username"] = "'.$this->input->post('username').'";
  73.                 $db["default"]["password"] = "'.$this->input->post('password').'";
  74.                 $db["default"]["database"] = "'.$this->input->post('database').'";
  75.                 $db["default"]["dbdriver"] = "mysql";
  76.                 $db["default"]["dbprefix"] = "";
  77.                 $db["default"]["pconnect"] = TRUE;
  78.                 $db["default"]["db_debug"] = TRUE;
  79.                 $db["default"]["cache_on"] = FALSE;
  80.                 $db["default"]["cachedir"] = "";
  81.                 $db["default"]["char_set"] = "utf8";
  82.                 $db["default"]["dbcollat"] = "utf8_general_ci";
  83.                 $db["default"]["swap_pre"] = "";
  84.                 $db["default"]["autoinit"] = TRUE;
  85.                 $db["default"]["stricton"] = FALSE;
  86.             /* End of file database.php */
  87.             /* Location: ./application/config/database.php */
  88.             ';
  89.             write_file('./application/config/database.php', trim($file_bd));
  90.            
  91.             //conectar bd
  92.             $this->load->database();
  93.             $this->db->reconnect();
  94.            
  95.             redirect('instalar/passo');
  96.         endif;
  97.         set_tema('titulo', 'Instalação do sistema');
  98.         set_tema('conteudo', load_modulo('instalar', 'instalar'));
  99.         set_tema('rodape', '');
  100.         load_template();
  101.     }
  102.            
  103.     public function passo(){
  104.         init_painel();
  105.         set_tema('titulo', 'Instalação concluída');
  106.         set_tema('conteudo', load_modulo('instalar', 'passo'));
  107.         set_tema('rodape', '');
  108.         load_template();
  109.     }
  110.    
  111.     public function sucesso(){
  112.         init_painel();
  113.         set_tema('titulo', 'Instalação concluída');
  114.         set_tema('conteudo', load_modulo('instalar', 'sucesso'));
  115.         set_tema('rodape', '');
  116.         load_template();
  117.     }
  118.    
  119. }
  120.  
  121. /* End of file instalar.php */
  122. /* Location: ./application/controllers/instalar.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement