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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .gitattributes

This file was deleted.

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]
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

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('database', 'session', 'form_validation');

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

/*
| -------------------------------------------------------------------
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'] = 'http://localhost/vietgram/';

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

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions application/config/constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

// $root = "http://localhost/Codeigniter/";
// $constant['base_url'] = $root;
// define('')

/*
|--------------------------------------------------------------------------
| Display Debug backtrace
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_1301180294',
'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'] = 'Auth';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
5 changes: 5 additions & 0 deletions application/config/user_agents.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
'meizu' => 'Meizu',
'huawei' => 'Huawei',
'xiaomi' => 'Xiaomi',
'oppo' => 'Oppo',
'vivo' => 'Vivo',
'infinix' => 'Infinix',

// Operating Systems
'android' => 'Android',
Expand Down
51 changes: 51 additions & 0 deletions application/controllers/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

// Maulana Irfan Firdian
// 1301180294
// IF-42-11

class Auth extends CI_Controller {

function __construct()
{
parent::__construct();
$this->load->model('M_User');
}

public function index() {
$this->form_validation->set_rules('username', 'Username', 'required|trim');
$this->form_validation->set_rules('password', 'Password', 'required|trim');

if ($this->form_validation->run() == FALSE) {
$this->load->view('V_login');
} else {
$this->_do_login();
}
}

private function _do_login() {
$username = $this->input->post('username');
$password = $this->input->post('password');

$user = $this->M_User->checkUser($username, $password);

// if user avail
if ($user) {
$profile = $this->M_User->getProfile($user['username']);

$this->session->set_userdata($profile);
redirect('User');
} else {
redirect('Auth');
}
}

public function do_logout() {
$this->session->unset_userdata('username');
redirect('Auth');
}

}

?>
88 changes: 88 additions & 0 deletions application/controllers/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// Maulana Irfan Firdian
// 1301180294
// IF-42-11

class User extends CI_Controller {

public function __construct()
{
parent::__construct();

if (!$this->session->userdata('username')) {
redirect('Auth');
}

$this->load->model('M_User');
}

public function index() {
$this->load->view('V_profile');
}

public function load_explore() {
$this->load->view('V_explore');
}

public function load_feed() {
$this->load->view('V_feed');
}

public function load_editProfile() {
$this->load->view('V_edit-profile');
}

public function load_uploadPhoto() {
$this->load->view('V_upload-photo');
}

public function do_editProfile() {
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('username', 'Username', 'required|trim');
$this->form_validation->set_rules('website', 'Website', 'required|trim');
$this->form_validation->set_rules('bio', 'Bio', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|trim');
$this->form_validation->set_rules('phonenumber', 'Phonenumber', 'required|trim');
$this->form_validation->set_rules('gender', 'Username', 'required');

$username = $this->session->userdata('username');

$dataProfile = [
'name' => $this->input->post('name'),
'username' => $this->input->post('username'),
'website' => $this->input->post('website'),
'bio' => $this->input->post('bio'),
'email' => $this->input->post('email'),
'phonenumber' => $this->input->post('phonenumber'),
'gender' => $this->input->post('gender')
];

$dataUser = [
'username' => $this->input->post('username'),
'email' => $this->input->post('email')
];

$this->M_User->editProfile($dataProfile, $username);
$this->M_User->editUser($dataUser, $username);
$this->session->set_userdata($dataProfile);
redirect('User');
}

public function do_uploadPhoto() {
$data = [];

$upload = $this->M_User->uploadPhoto();

if ($upload['result'] == 'success') {
$this->M_User->saveIntoDatabase($upload);
redirect('User');
} else {
$data['message'] = $upload['error'];
redirect('User/load_uploadPhoto');
}
}

}

?>
25 changes: 0 additions & 25 deletions application/controllers/Welcome.php

This file was deleted.

11 changes: 0 additions & 11 deletions application/controllers/index.html

This file was deleted.

Loading