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
  •  
  •  
  •  
Binary file added ._.editorconfig
Binary file not shown.
Binary file added ._.gitignore
Binary file not shown.
Binary file added ._.htaccess
Binary file not shown.
Binary file added ._application
Binary file not shown.
Binary file added ._assets
Binary file not shown.
Binary file added ._composer.json
Binary file not shown.
Binary file added ._contributing.md
Binary file not shown.
Binary file added ._index.php
Binary file not shown.
Binary file added ._license.txt
Binary file not shown.
Binary file added ._readme.rst
Binary file not shown.
Binary file added ._system
Binary file not shown.
Binary file added ._user_guide
Binary file not shown.
Binary file added ._viegramCI.sql
Binary file not shown.
6 changes: 6 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Options -Multiviews

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L]
Binary file added application._cache
Binary file not shown.
Binary file added application._core
Binary file not shown.
Binary file added application._hooks
Binary file not shown.
Binary file added application._logs
Binary file not shown.
Binary file added application._views
Binary file not shown.
Binary file added application/config/._autoload.php
Binary file not shown.
Binary file added application/config/._config.php
Binary file not shown.
Binary file added application/config/._constants.php
Binary file not shown.
Binary file added application/config/._database.php
Binary file not shown.
Binary file added application/config/._doctypes.php
Binary file not shown.
Binary file added application/config/._foreign_chars.php
Binary file not shown.
Binary file added application/config/._hooks.php
Binary file not shown.
Binary file added application/config/._index.html
Binary file not shown.
Binary file added application/config/._memcached.php
Binary file not shown.
Binary file added application/config/._migration.php
Binary file not shown.
Binary file added application/config/._mimes.php
Binary file not shown.
Binary file added application/config/._profiler.php
Binary file not shown.
Binary file added application/config/._routes.php
Binary file not shown.
Binary file added application/config/._user_agents.php
Binary file not shown.
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');

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

/*
| -------------------------------------------------------------------
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:8080/VietgramCI/';

/*
|--------------------------------------------------------------------------
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' => 'viegramCI',
'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;
Binary file added application/controllers/._Edit_profile.php
Binary file not shown.
Binary file added application/controllers/._Explore.php
Binary file not shown.
Binary file added application/controllers/._Feed.php
Binary file not shown.
Binary file added application/controllers/._Login.php
Binary file not shown.
Binary file added application/controllers/._Profile.php
Binary file not shown.
Binary file added application/controllers/._Welcome.php
Binary file not shown.
Binary file added application/controllers/._index.html
Binary file not shown.
32 changes: 32 additions & 0 deletions application/controllers/Edit_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

class edit_profile extends CI_Controller {

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

public function index() {
$username = $this->session->userdata('user');
if ($username) {
$data['profile'] = $this->user->getUser($username);
$this->load->view('view_editprofile',$data);
} else {
redirect('/login');
}
}

public function edit() {
$id = $this->session->userdata('id');
$data['username'] = $this->input->post('username');
$data['name'] = $this->input->post('name');
$data['website'] = $this->input->post('website');
$data['bio'] = $this->input->post('bio');
$data['email'] = $this->input->post('email');
$data['phone'] = $this->input->post('phonenumber');
$data['gender'] = $this->input->post('gender');
$this->user->editUser($id,$data);
redirect('/profile');
}
}
38 changes: 38 additions & 0 deletions application/controllers/Explore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

class explore extends CI_Controller {

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

public function index() {
$id = $this->session->userdata('id');
if ($id) {
$data['users'] = $this->user->getSomeUser($id);
$this->load->view('view_explore',$data);
} else {
redirect('/login');
}
}

public function search() {
$id = $this->session->userdata('id');
$username = $this->input->get('search');
$data['users'] = $this->user->searchUser($username, $id);
$this->load->view('view_explore',$data);
}

public function add($id) {
$data['id_user'] = $this->session->userdata('id');
$data['id_user_follow'] = $id;
$followed = $this->follow->checkFollowing($data);
if (!$followed) {
$this->follow->addFollowing($data);
redirect('/explore');
}

}
}
20 changes: 20 additions & 0 deletions application/controllers/Feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class feed extends CI_Controller {

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

public function index() {
$username = $this->session->userdata('user');
if ($username) {
$data['allPost'] = $this->post->getAllPost();
$this->load->view('view_feed',$data);
} else {
redirect('/login');
}
}
}
27 changes: 27 additions & 0 deletions application/controllers/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

class Login extends CI_Controller {

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

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

public function login(){
$data['username'] = $this->input->post('username');
$data['password'] = $this->input->post('password');
$result = $this->user->login($data);
if ($result) {
$this->session->set_userdata('id',$result->id_user);
$this->session->set_userdata('user',$data['username']);
redirect('/feed');
} else {
$error = array('error_message' => "Username or Password ain't correct");
$this->load->view('view_login', $error);
}
}
}
34 changes: 34 additions & 0 deletions application/controllers/Profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

class profile extends CI_Controller {

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

public function index() {
$id = $this->session->userdata('id');
$username = $this->session->userdata('user');
if ($username) {
$data = array(
'profile' => $this->user->getUser($username),
'post' => $this->post->getPost($id),
'followers' => $this->follow->getFollowers($id),
'following' => $this->follow->getFollowing($id),
'allPost' => $this->post->getUserPost($id)
);
$this->load->view('view_profile',$data);
} else {
redirect('/login');
}
}

public function logout() {
$this->session->sess_destroy();
redirect('/login');
}

}
Binary file added application/core/._index.html
Binary file not shown.
Binary file added application/helpers/._index.html
Binary file not shown.
Binary file added application/hooks/._index.html
Binary file not shown.
Binary file added application/language/._english
Binary file not shown.
Binary file added application/language/._index.html
Binary file not shown.
Binary file added application/language/english/._index.html
Binary file not shown.
Binary file added application/libraries/._index.html
Binary file not shown.
Binary file added application/models/._Follow.php
Binary file not shown.
Binary file added application/models/._Post.php
Binary file not shown.
Binary file added application/models/._User.php
Binary file not shown.
Binary file added application/models/._index.html
Binary file not shown.
28 changes: 28 additions & 0 deletions application/models/Follow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

class follow extends CI_Model {

public function checkFollowing($data) {
$this->db->where('id_user',$data['id_user']);
$this->db->where('id_user_follow',$data['id_user_follow']);
$query = $this->db->get('follow');
return ($query->num_rows() > 0) ? true : false;
}

public function addFollowing($data){
$this->db->insert('follow',$data);
return ($this->db->affected_rows() == 1) ? true : false;
}

public function getFollowing($id) {
$this->db->where('id_user',$id);
$query = $this->db->get('follow');
return $query->num_rows();
}

public function getFollowers($id) {
$this->db->where('id_user_follow',$id);
$query = $this->db->get('follow');
return $query->num_rows();
}
}
20 changes: 20 additions & 0 deletions application/models/Post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class post extends CI_Model {

public function getAllPost() {
$this->db->join('user', 'post.id_user = user.id_user');
return $this->db->get('post')->result();
}

public function getPost($id) {
$this->db->where('id_user',$id);
$query = $this->db->get('post');
return $query->num_rows();
}

public function getUserPost($id) {
$this->db->where('id_user',$id);
return $this->db->get('post')->result();
}
}
45 changes: 45 additions & 0 deletions application/models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

class user extends CI_Model {

public function login($data) {
$this->db->where('username',$data['username']);
$this->db->where('password',$data['password']);
$query = $this->db->get('user');
return ($query->num_rows() > 0) ? $query->row() : false;
}

public function getUser($username) {
$this->db->where('username',$username);
$query = $this->db->get('user');
return ($query->num_rows() > 0) ? $query->row() : false;
}

public function editUser($id, $data) {
$this->db->where('id_user',$id);
$this->db->update('user',$data);
}

public function getSomeUser($id) {
$this->db->select('id_user_follow');
$this->db->where('id_user',$id);
$data = $this->db->get('follow')->result_array();

foreach ($data as $following) {
$id_user_follow[] = $following['id_user_follow'];
}

$this->db->where('id_user !=', $id);
if (!empty($id_user_follow)) {
$this->db->where_not_in('id_user', $id_user_follow);
}
return $this->db->get('user')->result();
}

public function searchUser($username, $id) {
$this->db->where('id_user !=', $id);
$this->db->like('username', $username);
return $this->db->get('user')->result();
}

}
Binary file added application/third_party/._index.html
Binary file not shown.
Binary file added application/views/._errors
Binary file not shown.
Binary file added application/views/._index.html
Binary file not shown.
Binary file added application/views/._view_editprofile.php
Binary file not shown.
Binary file added application/views/._view_explore.php
Binary file not shown.
Binary file added application/views/._view_feed.php
Binary file not shown.
Binary file added application/views/._view_login.php
Binary file not shown.
Binary file added application/views/._view_profile.php
Binary file not shown.
Binary file added application/views/._welcome_message.php
Binary file not shown.
Binary file added application/views/errors._cli
Binary file not shown.
Binary file added application/views/errors._html
Binary file not shown.
Binary file added application/views/errors/._index.html
Binary file not shown.
Binary file added application/views/errors/cli/._error_404.php
Binary file not shown.
Binary file added application/views/errors/cli/._error_db.php
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added application/views/errors/cli/._error_php.php
Binary file not shown.
Binary file added application/views/errors/cli/._index.html
Binary file not shown.
Binary file added application/views/errors/html/._error_404.php
Binary file not shown.
Binary file added application/views/errors/html/._error_db.php
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added application/views/errors/html/._error_php.php
Binary file not shown.
Binary file added application/views/errors/html/._index.html
Binary file not shown.
Loading