Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
4 changes: 2 additions & 2 deletions application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array();
$autoload['libraries'] = array('session', 'database', 'form_validation','upload');

/*
| -------------------------------------------------------------------
Expand Down Expand Up @@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array();
$autoload['helper'] = array('url', 'form','file');

/*
| -------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';

/*
|--------------------------------------------------------------------------
Expand All @@ -35,7 +35,7 @@
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
$config['index_page'] = '';

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'username' => 'root',
'password' => '',
'database' => '',
'database' => 'instagram',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
Expand Down
2 changes: 1 addition & 1 deletion application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 0 additions & 5 deletions application/config/user_agents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
18 changes: 18 additions & 0 deletions application/controllers/Add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class add extends CI_Controller {

function __construct(){
parent::__construct();
$this->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);
}
}
?>
30 changes: 30 additions & 0 deletions application/controllers/Edit_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Edit_profile extends CI_Controller {

function __construct(){
parent::__construct();
$this->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');
}
}
?>
28 changes: 28 additions & 0 deletions application/controllers/Feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class feed extends CI_Controller {

function __construct(){
parent::__construct();
$this->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');
}
}
?>
18 changes: 18 additions & 0 deletions application/controllers/Profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Profile extends CI_Controller {

function __construct(){
parent::__construct();
$this->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);
}
}
?>
18 changes: 18 additions & 0 deletions application/controllers/Uploadphot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class uploadphot extends CI_Controller {

function __construct(){
parent::__construct();
$this->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);
}
}
?>
28 changes: 28 additions & 0 deletions application/controllers/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {

function __construct(){
parent::__construct();
$this->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');
}
}
}
?>
67 changes: 67 additions & 0 deletions application/models/viet_gram_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
class viet_gram_model extends CI_Model{

public function login($data) {
$query = $this->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 '<script>File Terlalu Besar</script>';
}
} else {
echo '<script>Your Format be Denied!</script>';
}
}

}
?>
Loading