+ diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000000..8f4b813f533 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php/$1 [L] \ No newline at end of file diff --git a/application/config/autoload.php b/application/config/autoload.php index 7cdc9013c11..2c6cf1a0810 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('session', 'database', 'form_validation','upload'); /* | ------------------------------------------------------------------- @@ -89,7 +89,7 @@ | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('url', 'form','file'); /* | ------------------------------------------------------------------- diff --git a/application/config/config.php b/application/config/config.php index 10315220e04..935013de14e 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = ''; +$config['base_url'] = 'https://localhost/vietgramci/vietgramcifix'; /* |-------------------------------------------------------------------------- @@ -35,7 +35,7 @@ | variable so that it is blank. | */ -$config['index_page'] = 'index.php'; +$config['index_page'] = ''; /* |-------------------------------------------------------------------------- diff --git a/application/config/database.php b/application/config/database.php index 0088ef1403b..1f2b2195d16 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -76,9 +76,9 @@ $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', - 'username' => '', + 'username' => 'root', 'password' => '', - 'database' => '', + 'database' => 'db_vigfix', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/config/routes.php b/application/config/routes.php index 1b45740d7c7..51ae42b83f9 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -49,6 +49,6 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'welcome'; +$route['default_controller'] = 'login'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/controllers/Edit_profile.php b/application/controllers/Edit_profile.php new file mode 100644 index 00000000000..8777682ef5a --- /dev/null +++ b/application/controllers/Edit_profile.php @@ -0,0 +1,30 @@ +load->model('model_IG'); + $this->load->library('session'); + } + + public function index() + { + $this->load->view('edit_profile'); + } + public function editprofile() + { + $data = [ + "name" => $this->input->post('name', true), + "website" => $this->input->post('website', true), + "bio" => $this->input->post('bio', true), + "email" => $this->input->post('email', true), + "phone" => $this->input->post('phone', true), + "gender" => $this->input->post('gender', true), + ]; + $this->model_IG->edit_profile($_SESSION['username'], $data); + redirect('/profile','refresh'); + } +} +?> diff --git a/application/controllers/Feed.php b/application/controllers/Feed.php new file mode 100644 index 00000000000..9aa4f37e10d --- /dev/null +++ b/application/controllers/Feed.php @@ -0,0 +1,28 @@ +load->model('model_IG'); + $this->load->library('session'); + } + + public function index() + { + if($this->session->userdata('username')){ + $data = $this->model_IG->get_profile($this->session->userdata('username')); + $this->load->view('feed',$data); + } + else{ + redirect('/login'); + } + } + + public function logout(){ + $this->session->sess_destroy(); + redirect('/login'); + } +} +?> \ No newline at end of file diff --git a/application/controllers/Login.php b/application/controllers/Login.php new file mode 100644 index 00000000000..36dcb358aba --- /dev/null +++ b/application/controllers/Login.php @@ -0,0 +1,30 @@ +load->model('model_IG'); + $this->load->library('session'); + } + + public function index() + { + $this->load->view('login'); + } + + public function aksi_login(){ + $data['username'] = $this->input->post('username'); + $data['password'] = $this->input->post('password'); + + if($this->model_IG->login($data)) { + $this->session->set_userdata('username', $this->input->post('username')); + redirect('/feed'); + } + else { + redirect('/login'); + } + } +} +?> \ No newline at end of file diff --git a/application/controllers/Profile.php b/application/controllers/Profile.php new file mode 100644 index 00000000000..8b27e0548d1 --- /dev/null +++ b/application/controllers/Profile.php @@ -0,0 +1,18 @@ +load->model('model_IG'); + $this->load->library('session'); + } + + public function index() + { + $data = $this->model_IG->get_profile($this->session->userdata('username')); + $this->load->view('Profile', $data); + } +} +?> \ No newline at end of file diff --git a/application/models/model_IG.php b/application/models/model_IG.php new file mode 100644 index 00000000000..94e00dd8c6b --- /dev/null +++ b/application/models/model_IG.php @@ -0,0 +1,40 @@ +db->where('username', $data['username'])->where('password', $data['password'])->get('user'); + if($query->num_rows() > 0){ + return true; + }else{ + return false; + } + } + public function get_profile($username){ + if($this->db->where('username', $username)){ + return $this->db->get('user')->row_array(); + }else{ + return false; + } + } + public function get_datafoto(){ + $this->db->select('*'); + $this->db->from('user'); + $this->db->join('photo','user.username=user.username','LEFT OUTER'); + $query = $this->db->get(); + return $query->result(); + } + public function edit_profile($username,$data) + { + $data = [ + "name" => $this->input->post('name', true), + "website" => $this->input->post('website', true), + "bio" => $this->input->post('bio', true), + "email" => $this->input->post('email', true), + "phone"=> $this->input->post('phone',true), + "gender" => $this->input->post('gender', true), + ]; + $this->db->where('username', $username); + return $this->db->update('profile', $data); + } +} +?> diff --git a/application/views/edit_profile.php b/application/views/edit_profile.php new file mode 100644 index 00000000000..e4bb2bd189a --- /dev/null +++ b/application/views/edit_profile.php @@ -0,0 +1,132 @@ + + +db->query("select * from photo where username='". $_SESSION['username']. "'"); + $jmlData = $data_photo->num_rows(); + $data = $this->db->get('profile')->row_array(); + foreach($data_photo->result() as $row[]){ + } +?> +
+ + + +
+
+
+
+
+
+
+