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
64 changes: 64 additions & 0 deletions application/config/smileys.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------
| SMILEYS
| -------------------------------------------------------------------
| This file contains an array of smileys for use with the emoticon helper.
| Individual images can be used to replace multiple smileys. For example:
| :-) and :) use the same image replacement.
|
| Please see user guide for more info:
| https://codeigniter.com/user_guide/helpers/smiley_helper.html
|
*/
$smileys = array(

// smiley image name width height alt

':-)' => array('grin.gif', '19', '19', 'grin'),
':lol:' => array('lol.gif', '19', '19', 'LOL'),
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
':)' => array('smile.gif', '19', '19', 'smile'),
';-)' => array('wink.gif', '19', '19', 'wink'),
';)' => array('wink.gif', '19', '19', 'wink'),
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
':-S' => array('confused.gif', '19', '19', 'confused'),
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
':long:' => array('longface.gif', '19', '19', 'long face'),
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
':down:' => array('downer.gif', '19', '19', 'downer'),
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
':sick:' => array('sick.gif', '19', '19', 'sick'),
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
'>:(' => array('mad.gif', '19', '19', 'mad'),
':mad:' => array('mad.gif', '19', '19', 'mad'),
'>:-(' => array('angry.gif', '19', '19', 'angry'),
':angry:' => array('angry.gif', '19', '19', 'angry'),
':zip:' => array('zip.gif', '19', '19', 'zipper'),
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
':snake:' => array('snake.gif', '19', '19', 'snake'),
':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
':question:' => array('question.gif', '19', '19', 'question')

);
50 changes: 50 additions & 0 deletions application/controllers/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// Nama: Muhammad Farrel
// NIM: 1301184453
// Kelas: 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');
// Nama: Muhammad Farrel
// NIM: 1301184453
// Kelas: 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');
}
}

}

?>
68 changes: 68 additions & 0 deletions application/models/M_User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// Nama: Muhammad Farrel
// NIM: 1301184453
// Kelas: IF-42-11

class M_User extends CI_Model {

public function checkUser($username, $password) {
return $this->db->get_where('user', [
'username' => $username,
'password' => $password
])->row_array();
}

public function getProfile($username) {
return $this->db->get_where('profile', [
'username' => $username
])->row_array();
}

public function editProfile($data, $username) {
$this->db->where('username', $username);
$this->db->update('profile', $data);
}

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

// Upload Image -----------------------------
public function uploadPhoto() {
$config['upload_path'] = './assets/images/';
$config['allowed_types'] = 'jpg|png|jpeg';
$config['max_size'] = 2048;
$config['remove_spcae'] = TRUE;

$this->load->library('upload', $config);
if ($this->upload->do_upload('image')) {
$result = [
'result' => 'success',
'file' => $this->upload->data(),
'error' => '',
];
return $result;
} else {
$result = [
'result' => 'error',
'file' => '',
'error' => $this->upload->display_errors(),
];
return $result;
}
}

public function saveIntoDatabase($upload) {
$data = [
'url' => $upload['file']['file_name'],
'caption' => $this->input->post('caption'),
'like' => 225,
];
$this->db->insert('photo', $data);
}

}

?>
120 changes: 120 additions & 0 deletions application/views/V_edit-profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>

<!DOCTYPE html>
<!-- Nama: Muhammad Farrel
NIM: 1301184453
Kelas: IF-42-11 -->
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Edit Profile | Vietgram</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?= base_url('assets/css/styles.css'); ?>">
</head>

<body>
<nav class="navigation">
<div class="navigation__column">
<a href="feed.php">
<img src="<?= base_url('assets/images/logo.png'); ?>" />
</a>
</div>
<div class="navigation__column">
<i class="fa fa-search"></i>
<input type="text" placeholder="Search">
</div>
<div class="navigation__column">
<ul class="navigations__links">
<li class="navigation__list-item">
<a href="<?= site_url('User/load_explore') ?>" class="navigation__link">
<i class="fa fa-compass fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="#" class="navigation__link">
<i class="fa fa-heart-o fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="<?= site_url('User') ?>" class="navigation__link">
<i class="fa fa-user-o fa-lg"></i>
</a>
</li>
</ul>
</div>
</nav>
<main id="edit-profile">
<div class="edit-profile__container">
<header class="edit-profile__header">
<div class="edit-profile__avatar-container">
<img src="<?= base_url('assets/images/avatar.jpg'); ?>" class="edit-profile__avatar" />
</div>
<h4 class="edit-profile__username">Edit your profile, <?= $this->session->userdata('username') ?>.</h4>
</header>
<!-- Update Profile -->
<form action="<?= site_url('User/do_editProfile') ?>" method="post" class="edit-profile__form">
<div class="form__row">
<label for="full-name" class="form__label">Name:</label>
<input name="name" id="full-name" type="text" class="form__input" value="<?= $this->session->userdata('name') ?>"/>
</div>
<div class="form__row">
<label for="user-name" class="form__label">Username:</label>
<input name="username" id="user-name" type="text" class="form__input" value="<?= $this->session->userdata('username') ?>"/>
</div>
<div class="form__row">
<label for="website" class="form__label">Website:</label>
<input name="website" id="website" type="url" class="form__input" value="<?= $this->session->userdata('website') ?>"/>
</div>
<div class="form__row">
<label for="bio" class="form__label">Bio:</label>
<textarea name="bio" id="bio"><?= $this->session->userdata('bio') ?></textarea>
</div>
<div class="form__row">
<label for="email" class="form__label">Email:</label>
<input name="email" id="email" type="email" class="form__input" value="<?= $this->session->userdata('email') ?>"/>
</div>
<div class="form__row">
<label for="phone" class="form__label">Phone Number:</label>
<input name="phonenumber" id="phone" type="tel" class="form__input" value="<?= $this->session->userdata('phonenumber') ?>"/>
</div>
<div class="form__row">
<label for="gender" class="form__label">Gender:</label>
<select name="gender" id="gender">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="cant">Can't remember</option>
</select>
</div>
<input type="submit" value="Submit">
</form>
</div>
</main>
<footer class="footer">
<div class="footer__column">
<nav class="footer__nav">
<ul class="footer__list">
<li class="footer__list-item"><a href="#" class="footer__link">About Us</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Support</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Blog</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Press</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Api</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Jobs</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Privacy</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Terms</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Directory</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Language</a></li>
</ul>
</nav>
</div>
<div class="footer__column">
<span class="footer__copyright">© 2017 Vietgram</span>
</div>
</footer>
</body>

</html>
Loading