+ From 1b36e0f6cb2312a9e1087ab283550b86aeb93c31 Mon Sep 17 00:00:00 2001 From: adiyasaniastya <57404366+adiyasaniastya@users.noreply.github.com> Date: Sat, 18 Apr 2020 23:11:37 +0700 Subject: [PATCH 01/10] Add files via upload --- application/config/autoload.php | 4 ++-- application/config/config.php | 4 ++-- application/config/database.php | 4 ++-- application/config/routes.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) 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; From a35c07fa345f3a8adc802aed1b4e1474d834bcf7 Mon Sep 17 00:00:00 2001 From: adiyasaniastya <57404366+adiyasaniastya@users.noreply.github.com> Date: Sat, 18 Apr 2020 23:21:50 +0700 Subject: [PATCH 02/10] Add files via upload --- application/controllers/Edit_profile.php | 30 ++++++++++++++++++++++++ application/controllers/Feed.php | 28 ++++++++++++++++++++++ application/controllers/Login.php | 30 ++++++++++++++++++++++++ application/controllers/Profile.php | 18 ++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 application/controllers/Edit_profile.php create mode 100644 application/controllers/Feed.php create mode 100644 application/controllers/Login.php create mode 100644 application/controllers/Profile.php diff --git a/application/controllers/Edit_profile.php b/application/controllers/Edit_profile.php new file mode 100644 index 00000000000..04c11dbec6f --- /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), + "nohp" => $this->input->post('nohp', true), + "gender" => $this->input->post('gender', true), + ]; + $this->model_IG->edit_profile($_SESSION['username'], $data); + redirect('/profile','refresh'); + } +} +?> \ No newline at end of file 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 From d2f47d0025a14316162d21bb94df3895c7fb4a35 Mon Sep 17 00:00:00 2001 From: adiyasaniastya <57404366+adiyasaniastya@users.noreply.github.com> Date: Sat, 18 Apr 2020 23:22:42 +0700 Subject: [PATCH 03/10] Add files via upload --- application/models/model_IG.php | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 application/models/model_IG.php diff --git a/application/models/model_IG.php b/application/models/model_IG.php new file mode 100644 index 00000000000..96f2f616cb1 --- /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), + "nohp" => $this->input->post('nohp', true), + "gender" => $this->input->post('gender', true), + ]; + $this->db->where('username', $username); + return $this->db->update('profile', $data); + } +} +?> \ No newline at end of file From 20252dcd97bb7839b95a2d7487996e9a276b00b6 Mon Sep 17 00:00:00 2001 From: adiyasaniastya <57404366+adiyasaniastya@users.noreply.github.com> Date: Sat, 18 Apr 2020 23:23:31 +0700 Subject: [PATCH 04/10] Add files via upload --- application/views/edit_profile.php | 132 +++++++++++++++++++++++++ application/views/feed.php | 134 ++++++++++++++++++++++++++ application/views/login.php | 78 +++++++++++++++ application/views/profile.php | 127 ++++++++++++++++++++++++ application/views/welcome_message.php | 13 +-- 5 files changed, 472 insertions(+), 12 deletions(-) create mode 100644 application/views/edit_profile.php create mode 100644 application/views/feed.php create mode 100644 application/views/login.php create mode 100644 application/views/profile.php 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[]){ + } +?> +
+ + + +
+
+
+
+
+
+
+