+ diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000000..9e25198b5a4 --- /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..9d1691d7a59 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/ci_anang/'; /* |-------------------------------------------------------------------------- @@ -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..3d45a25cb13 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' => 'instagram', '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/config/user_agents.php b/application/config/user_agents.php index c4429aac55f..c1581e5cd3f 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -152,11 +152,6 @@ 'open web' => 'Open Web', 'openweb' => 'OpenWeb', 'meizu' => 'Meizu', - 'huawei' => 'Huawei', - 'xiaomi' => 'Xiaomi', - 'oppo' => 'Oppo', - 'vivo' => 'Vivo', - 'infinix' => 'Infinix', // Operating Systems 'android' => 'Android', diff --git a/application/controllers/Add.php b/application/controllers/Add.php new file mode 100644 index 00000000000..cc5dd950c28 --- /dev/null +++ b/application/controllers/Add.php @@ -0,0 +1,18 @@ +load->model('viet_gram_model'); + $this->load->library('session'); + } + + public function index() + { + $data = $this->viet_gram_model->get_profile($this->session->userdata('username')); + $this->load->view('add', $data); + } +} +?> \ No newline at end of file diff --git a/application/controllers/Edit_profile.php b/application/controllers/Edit_profile.php new file mode 100644 index 00000000000..35be35e7437 --- /dev/null +++ b/application/controllers/Edit_profile.php @@ -0,0 +1,30 @@ +load->model('viet_gram_model'); + $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->viet_gram_model->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..42cdbfef06a --- /dev/null +++ b/application/controllers/Feed.php @@ -0,0 +1,28 @@ +load->model('viet_gram_model'); + $this->load->library('session'); + } + + public function index() + { + if($this->session->userdata('username')){ + // $dataUser = $this->model_IG->get_datafoto(); + $data = $this->viet_gram_model->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/Profile.php b/application/controllers/Profile.php new file mode 100644 index 00000000000..77503153fef --- /dev/null +++ b/application/controllers/Profile.php @@ -0,0 +1,18 @@ +load->model('viet_gram_model'); + $this->load->library('session'); + } + + public function index() + { + $data = $this->viet_gram_model->get_profile($this->session->userdata('username')); + $this->load->view('Profile', $data); + } +} +?> \ No newline at end of file diff --git a/application/controllers/Uploadphot.php b/application/controllers/Uploadphot.php new file mode 100644 index 00000000000..fabb0afd542 --- /dev/null +++ b/application/controllers/Uploadphot.php @@ -0,0 +1,18 @@ +load->model('viet_gram_model'); + $this->load->library('session'); + } + + public function index() + { + $data = $this->viet_gram_model->get_profile($this->session->userdata('username')); + $this->load->view('Uploadphot', $data); + } +} +?> \ No newline at end of file diff --git a/application/controllers/login.php b/application/controllers/login.php new file mode 100644 index 00000000000..4f92ef29964 --- /dev/null +++ b/application/controllers/login.php @@ -0,0 +1,28 @@ +load->model('viet_gram_model'); + $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->viet_gram_model->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/models/viet_gram_model.php b/application/models/viet_gram_model.php new file mode 100644 index 00000000000..abbe1bcf405 --- /dev/null +++ b/application/models/viet_gram_model.php @@ -0,0 +1,67 @@ +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); + } + + function tambahPhoto($data) + { + + $caption = htmlspecialchars($data['caption']); + $ekstensi_allowed = array('png', 'jpg', 'jpeg', 'svg'); + $gambar = $_FILES['gambar']['name']; + $x = explode('.', $gambar); + $ekstensi = strtolower(end($x)); + $ukuran = $_FILES['gambar']['size']; + $file_tmp = $_FILES['gambar']['tmp_name']; + + + if (in_array($ekstensi, $ekstensi_allowed) === true) { + if ($ukuran < 1044070) { + move_uploaded_file($file_tmp, 'images/' . $gambar); + $query = "INSERT INTO photo VALUES('','$gambar','$caption')"; + mysqli_query($koneksi, $query); + } else { + echo ''; + } + } else { + echo ''; + } + } + +} +?> \ No newline at end of file diff --git a/application/views/add.php b/application/views/add.php new file mode 100644 index 00000000000..3cd75104d5a --- /dev/null +++ b/application/views/add.php @@ -0,0 +1,124 @@ + + +db->query("select * from photo where username='". $_SESSION['username']. "'"); + $jumInfo = $dataPhoto->num_rows(); + $data = $this->db->get('profile')->row_array(); + foreach($dataPhoto->result() as $row[]){ + } + +?> + + + + +
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+