Ejemplo n.º 1
0
 public function index()
 {
     $step = $this->input->get('step');
     if (!$step) {
         $data['title'] = "Overview";
         $this->load->view('install/header', $data);
         $this->load->view('install/home', $data);
         $this->load->view('install/footer');
     } elseif ($step == 1) {
         $data['title'] = "Database Configuration";
         $this->form_validation->set_rules('database_hostname', 'Hostname', 'trim|required');
         $this->form_validation->set_rules('database_username', 'Username', 'trim|required');
         $this->form_validation->set_rules('database_name', 'Database Name', 'trim|required');
         $this->form_validation->set_rules('table_prefix', 'Table Prefix', 'trim|required');
         if ($this->form_validation->run() === TRUE) {
             $db = array('database_hostname' => $this->input->post('database_hostname'), 'database_username' => $this->input->post('database_username'), 'database_password' => $this->input->post('database_password'), 'database_name' => '', 'table_prefix' => $this->input->post('table_prefix'));
             if (write_database_config($db)) {
                 $this->load->model('install_model');
                 if ($this->install_model->create_database($this->input->post('database_name'))) {
                     $db = array('database_hostname' => $this->input->post('database_hostname'), 'database_username' => $this->input->post('database_username'), 'database_password' => $this->input->post('database_password'), 'database_name' => $this->input->post('database_name'), 'table_prefix' => $this->input->post('table_prefix'));
                     write_database_config($db);
                     $this->install_model->create_tables($this->input->post('database_name'));
                     $this->install_model->insert_site_data($this->input->post('database_name'));
                 }
             }
             redirect('install?step=2');
         }
         $this->load->view('install/header', $data);
         $this->load->view('install/step1', $data);
         $this->load->view('install/footer');
     } elseif ($step == 2) {
         $this->load->model('install_model');
         $data['title'] = "User Creation";
         $validation_rules = array(array('field' => 'user_name', 'label' => 'Username', 'rules' => 'trim|required|alpha_numeric|min_length[5]|max_length[20]|is_unique[users.user_name]'), array('field' => 'user_display_name', 'label' => 'Display Name', 'rules' => 'trim|required'), array('field' => 'user_email', 'label' => 'Email', 'rules' => 'trim|required|valid_email|is_unique[users.user_email]'), array('field' => 'user_password', 'label' => 'Password', 'rules' => 'trim|required|min_length[5]'), array('field' => 'confirm_user_password', 'label' => 'Confirm Password', 'rules' => 'trim|required|min_length[5]|matches[user_password]'));
         $this->form_validation->set_rules($validation_rules);
         if ($this->form_validation->run() === TRUE) {
             $this->install_model->insert_user_data();
             redirect('install?step=finish');
         }
         $this->load->view('install/header', $data);
         $this->load->view('install/step2', $data);
         $this->load->view('install/footer');
     } elseif ($step == "finish") {
         $data['title'] = "Finish";
         write_install_lock();
         $this->load->view('install/header', $data);
         $this->load->view('install/finish', $data);
         $this->load->view('install/footer');
     }
 }
Ejemplo n.º 2
0
                    echo "Could not connect to the server or select the database (Open Blog)!<br /><br /><a href=\"javascript:history.go(-1)\">&lsaquo;&lsaquo; Back</a>";
                } else {
                    mysql_connect($database['wordpress']['hostname'], $database['wordpress']['username'], $database['wordpress']['password']) or die(mysql_error());
                    mysql_select_db($database['wordpress']['name']) or die(mysql_error());
                    $data = get_data($database['wordpress']['prefix']);
                    mysql_close();
                    mysql_connect($database['openblog']['hostname'], $database['openblog']['username'], $database['openblog']['password']) or die(mysql_error());
                    mysql_select_db($database['openblog']['name']) or die(mysql_error());
                    create_new_tables($database['openblog']['prefix']);
                    insert_data($database['wordpress']['prefix'], $database['openblog']['prefix'], $data);
                    // write the main config file
                    if ($blog['enable_seo_urls'] == TRUE) {
                        write_main_config($blog['url'], TRUE);
                    } else {
                        write_main_config($blog['url'], FALSE);
                        // delete the .htaccess file
                        unlink('../.htaccess');
                    }
                    // write the database config file
                    write_database_config($database['openblog']['hostname'], $database['openblog']['username'], $database['openblog']['password'], $database['openblog']['name'], $database['openblog']['prefix']);
                    mysql_close();
                    echo 'You have successfully migrated from Wordpress to Open Blog.<br /><br />
			Before you can start using your blog, you must delete the <strong>install/</strong> directory.<br /><br />
			When you are done, go to your <a href="' . $blog['url'] . '" target="_blank">blog home page</a>.';
                }
            }
        }
    }
} else {
    header("Location: index.php");
}