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
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','upload','form_validation');

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

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

/*
|--------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
| When you set this option to TRUE, it will replace ALL dashes with
| underscores in the controller and method URI segments.
|
| 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;
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('userM');
$this->load->library('session');
}

public function index()
{
if($this->session->userdata('username')){
// $dataUser = $this->userM->get_datafoto();
$data = $this->userM->get_profile($this->session->userdata('username'));
$this->load->view('feed',$data);
}else{
redirect('/login');
}
}

public function logout(){
$this->session->sess_destroy();
redirect('/login');
}
}
?>
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('userM');
$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->userM->login($data)) {
$this->session->set_userdata('username', $this->input->post('username'));
redirect('/feed');
} else {
redirect('/login');
}
}
}
?>
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('userM');
$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->userM->edit_profile($_SESSION['username'], $data);
redirect('/profile','refresh');
}
}
?>
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('userM');
$this->load->library('session');
}

public function index()
{
$data = $this->userM->get_profile($this->session->userdata('username'));
$this->load->view('Profile', $data);
}
}
?>
21 changes: 21 additions & 0 deletions application/models/userM.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class UserM extends CI_Model {
public function login($data)
{
$q = $this->db->query("SELECT * FROM `user` WHERE `username`='".$data['username']."' AND `password`='".md5($data['password'])."'");
return $q->num_rows();
}
public function getUser($id)
{
$q = $this->db->query("SELECT * FROM `profile` WHERE `id_profile`='$id'");
return $q;
}
public function updateUser($id, $data)
{
$this->db->where('id_profile', $id);
$this->db->update('profile', $data);

}
}
111 changes: 111 additions & 0 deletions application/views/add_photo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!DOCTYPE html>
<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>add photo | Vietgram</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo base_url('assets/css/styles.css') ?>">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
</head>
<style>
#image-preview{
display:none;
width : 250px;
height : 300px;
}
</style>

<body>
<nav class="navigation">
<div class="navigation__column">
<a href="feed.html">
<img src="<?php echo 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="explore.html" 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="profile.html" 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="<?php echo base_url('assets/images/avatar.jpg')?>" class="edit-profile__avatar" />
</div>
<h4 class="edit-profile__username">serranoarevalo</h4>
</header>
<form action="<?php echo base_url('user/addPhotoAction')?>" method="post" class="edit-profile__form" enctype="multipart/form-data">
<input type="hidden" id="id" value="1">
<div class="form__row">
<label for="caption" class="form__label">Caption:</label>
<textarea name="caption" id="caption"></textarea>
</div>
<div class="form__row">
<label for="photo" class="form__label">Photo:</label>
<input type="file" id="image-source" name="file" onchange="previewImage();"/>
</div>
<div class="form__row">
<label for="preview" id="preview" class="form__label"></label>
<img id="image-preview" alt="image preview"/>
</div>
<input type="submit" id="submit" name="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>
<script>
<script>
function previewImage() {
document.getElementById("image-preview").style.display = "block";
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("image-source").files[0]);
oFReader.onload = function(oFREvent) {
document.getElementById("image-preview").src = oFREvent.target.result;
};
$("#preview").text('Preview:');
};
</html>
Loading