code-igniter-v3-giggi: update release v1
diff --git a/application/controllers/Invite.php b/application/controllers/Invite.php
new file mode 100644
index 0000000..9c98621
--- /dev/null
+++ b/application/controllers/Invite.php
@@ -0,0 +1,95 @@
+<?php
+
+class Invite extends CI_Controller {
+    private function is_valid_file($rel_path = '/', $file_html = 'home.html')
+    {
+        $abs_path = APPPATH.$rel_path.$file_html;
+        if (file_exists($abs_path))
+            return true;
+
+        return false;
+    }
+
+    private function is_post_invalid()
+    {
+        return !$this->form_validation->run();
+    }
+    
+	public function view($file_name = 'invite')
+	{
+        $file_html = $file_name.'.html';
+        if ($this->is_valid_file('views/page/', $file_html))
+        {
+            /* Got to open a connection here as validation may require one */
+            if (!$this->load->database())
+                redirect(base_url('index.html'));
+
+            $this->load->helper(array('form', 'url'));
+            $this->load->library('form_validation');
+
+            $this->form_validation->set_rules('username', 'Username',
+                'required|min_length[5]|max_length[12]|is_unique[users.username]',
+                array(
+                    'required' => 'You must provide a %s',
+                    'min_length' => '%s must be more than 5 chars',
+                    'max_length' => '%s must be less than 12 chars',
+                    'is_unique' => 'This %s already exists'
+                )
+            );
+
+            $this->form_validation->set_rules('password', 'Password', 'required',
+                array('required' => 'You must provide a %s')
+            );
+
+            $this->form_validation->set_rules('passconf', 'Password Confirmation',
+                'required|matches[password]',
+                array(
+                    'required' => 'You must provide a %s',
+                    'matches' => 'Passowrd confirmation didn\'t match'
+                )
+            );
+
+            $this->form_validation->set_rules('email', 'Email', 'required',
+                array('required' => 'You must provide a %s')
+            );
+
+            if ($this->is_post_invalid())
+            {
+                /* Validation errors already set */
+            }
+            else
+            {
+                /* Add backticks on ientifiers */
+                $this->db->protect_identifiers('users', TRUE);
+
+                /* Always use query bindings as they are automatically escaped */
+                $stmt = "INSERT INTO users (username, email, password) VALUES (?, ?, ?)";
+                $data = $this->input->post(array('username', 'email'));
+                $password = $this->input->post('password');
+                $hash_password = password_hash($password, PASSWORD_DEFAULT);
+                $data['password'] = $hash_password;
+
+                if (!$this->db->query($stmt, $data))
+                {
+                    /* Debug:
+                     *
+                     * $error = $this->db->error();
+                     * var_dump($error);
+                     */
+                    $this->form_validation->set_message('submit_msg', 'Didn\'t work, :|');
+                }
+                else
+                { 
+                    $this->form_validation->set_string('Invite succesfully sent');
+                }
+            }
+
+            $this->db->close();
+            $this->load->view('page/'.$file_html);
+        }
+        else 
+        {
+            redirect(base_url('index.html'));
+        }
+	}
+}
diff --git a/application/controllers/Login.php b/application/controllers/Login.php
new file mode 100644
index 0000000..91e1abe
--- /dev/null
+++ b/application/controllers/Login.php
@@ -0,0 +1,112 @@
+<?php
+
+class Login extends CI_Controller {
+    private function is_valid_file($rel_path = '/', $file_html = 'home.html')
+    {
+        $abs_path = APPPATH.$rel_path.$file_html;
+        if (file_exists($abs_path))
+            return true;
+
+        return false;
+    }
+
+    private function is_post_valid()
+    {
+        return $this->form_validation->run();
+    }
+
+    private function is_username_valid($username = NULL, $db_username = NULL)
+    {
+        if (!$username || !$db_username)
+            return false;
+
+        return !strcmp($username, $db_username);
+    }
+
+    private function is_password_valid($password = NULL, $db_password = NULL)
+    {
+        if (!$password || !$db_password)
+            return false;
+
+        return verify_password($password, $db_password);
+    }
+
+    private function is_login_valid($db_username = NULL, $db_password = NULL)
+    {
+        if (!$db_username || !$db_password)
+            return false;
+
+        $username = $this->input->post('username');
+        $password = $this->input->post('password');
+
+        if (!$this->is_username_valid($username, $db_username))
+            return false;
+
+        if (!$this->is_password_valid($password, $db_password))
+            return false;
+
+        return true;
+    }
+
+    public function view($file_name = 'login')
+    {
+        $file_html = $file_name.'.html';
+        if ($this->is_valid_file('views/page/', $file_html))
+        {
+            /* Got to open a connection here as validation may require one */
+            if (!$this->load->database())
+                redirect(base_url('index.html'));
+
+            $this->load->helper(array('form', 'url'));
+            $this->load->library('form_validation');
+
+            $this->form_validation->set_rules('username', 'Username', 'required',
+                array('required' => 'You must provide a %s')
+            );
+
+            $this->form_validation->set_rules('password', 'Password', 'required',
+                array('required' => 'You must provide a %s')
+            );
+
+            if ($this->is_post_valid())
+            {
+                /* Add backticks on ientifiers */
+                $this->db->protect_identifiers('users', TRUE);
+
+                /* Always use query bindings as they are automatically escaped */
+                $stmt = "SELECT FROM users (username, password)";
+                $data = $this->db->query($stmt, $data);
+
+                /* Return an array of row objects, empty array on failure */
+                $db_data = $data->result();
+                if ($db_data && $db_data[0])
+                {
+                    $db_username = $db_data[0]->username;
+                    $db_password = $db_data[0]->password;
+                    if (is_login_valid($db_username, $db_passowrd))
+                    {
+                        /* Initialize session data */
+                        $this->form_validation->set_string('Login successful');
+                    }
+                    else
+                    {
+                        /* Debug:
+                         *
+                         * $error = $this->db->error();
+                         * var_dump($error);
+                         */
+                        $this->form_validation->set_message('submit_msg', 'Didn\'t work, :|');
+                    }
+                }
+            }
+
+            /* Validation errors already set, if any */
+            $this->db->close();
+            $this->load->view('page/'.$file_html);
+        }
+        else
+        {
+            redirect(base_url('index.html'));
+        }
+    }
+}
diff --git a/application/controllers/Pelican.php b/application/controllers/Pelican.php
new file mode 100644
index 0000000..35eeb2d
--- /dev/null
+++ b/application/controllers/Pelican.php
@@ -0,0 +1,42 @@
+<?php
+
+class Pelican extends CI_Controller {
+    private function is_valid_file($rel_path = '/', $file_html = 'home.html')
+    {
+        $abs_path = APPPATH.$rel_path.$file_html;
+        if (file_exists($abs_path))
+            return true;
+
+        return false;
+    }
+
+    public function index()
+    {
+        $this->load->view('index.html');
+    }
+
+    public function view($file_name = 'home')
+    {
+        $file_html = $file_name.'.html';
+        if ($this->is_valid_file('views/blog/', $file_html))
+        {
+            $this->load->view('blog/'.$file_html);
+        }
+        else if ($this->is_valid_file('views/category/', $file_html))
+        {
+            $this->load->view('category/'.$file_html);
+        }
+        else if ($this->is_valid_file('views/page/', $file_html))
+        {
+            $this->load->view('page/'.$file_html);
+        }
+        else if ($this->is_valid_file('views/', $file_html))
+        {
+            $this->load->view($file_html);
+        }
+        else
+        {
+            $this->index();
+        }
+    }
+}
diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php
deleted file mode 100644
index 9213c0c..0000000
--- a/application/controllers/Welcome.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-class Welcome extends CI_Controller {
-
-	/**
-	 * Index Page for this controller.
-	 *
-	 * Maps to the following URL
-	 * 		http://example.com/index.php/welcome
-	 *	- or -
-	 * 		http://example.com/index.php/welcome/index
-	 *	- or -
-	 * Since this controller is set as the default controller in
-	 * config/routes.php, it's displayed at http://example.com/
-	 *
-	 * So any other public methods not prefixed with an underscore will
-	 * map to /index.php/welcome/<method_name>
-	 * @see https://codeigniter.com/user_guide/general/urls.html
-	 */
-	public function index()
-	{
-		$this->load->view('welcome_message');
-	}
-}