You've already forked codeigniter_test
first commit
This commit is contained in:
105
application/controllers/admin.php
Normal file
105
application/controllers/admin.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
class Admin extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('M_admin');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
if($this->auth->CI->session->userdata('is_log_in'))
|
||||
{
|
||||
$this->load->view('admin/template/header');
|
||||
$this->load->view('admin/template/sidebar');
|
||||
$this->load->view('admin/dashboard');
|
||||
//echo $this->auth->CI->session->userdata('nama');
|
||||
}else
|
||||
{
|
||||
$this->load->view('admin/login');
|
||||
}
|
||||
}
|
||||
|
||||
function login_auth()
|
||||
{
|
||||
$username = $this->input->post('username');
|
||||
$password = $this->input->post('password');
|
||||
$success = $this->auth->do_login($username,$password);
|
||||
if($success)
|
||||
{
|
||||
// lemparkan ke halaman index user
|
||||
redirect('admin');
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['login_info'] = "Maaf, username dan password salah!";
|
||||
$this->load->view('admin/login',$data);
|
||||
}
|
||||
}
|
||||
function logout()
|
||||
{
|
||||
//$this->auth->CI->session->unset_userdata();
|
||||
$this->auth->CI->session->sess_destroy();
|
||||
redirect('admin');
|
||||
}
|
||||
|
||||
//admin function
|
||||
|
||||
//add_post
|
||||
function add_post()
|
||||
{
|
||||
$data['judul'] = 'Add Post';
|
||||
$this->load->view('admin/template/header');
|
||||
$this->load->view('admin/template/sidebar');
|
||||
$this->load->view('admin/add_post',$data);
|
||||
}
|
||||
|
||||
function save_post()
|
||||
{
|
||||
$this->M_admin->save_post();
|
||||
redirect('admin/list_post','refresh');
|
||||
}
|
||||
|
||||
//list all post
|
||||
function list_post()
|
||||
{
|
||||
$data['judul'] = 'List Post';
|
||||
$data['listpost'] = $this->M_admin->get_post_all();
|
||||
$this->load->view('admin/template/header');
|
||||
$this->load->view('admin/template/sidebar');
|
||||
$this->load->view('admin/post',$data);
|
||||
}
|
||||
|
||||
//edit post
|
||||
function edit($id)
|
||||
{
|
||||
$data['judul']='Edit Page';
|
||||
$data['edit']=$this->M_admin->edit_post($id);
|
||||
$this->load->view('admin/template/header');
|
||||
$this->load->view('admin/template/sidebar');
|
||||
$this->load->view('admin/edit_post',$data);
|
||||
}
|
||||
function save_edit_post()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$judul = $this->input->post('judul');
|
||||
$isi = $this->input->post('isi');
|
||||
|
||||
$data['judul'] = 'Update Data Codeigniter';
|
||||
$data['edit'] = $this->M_admin->save_edit_post($id, $judul, $isi);
|
||||
echo ("<SCRIPT LANGUAGE='JavaScript'>
|
||||
window.alert('Succesfully Updated')
|
||||
</SCRIPT>");
|
||||
redirect('admin/list_post','refresh');
|
||||
}
|
||||
|
||||
//delete
|
||||
function delete($id)
|
||||
{
|
||||
$id = $this->M_admin->delete_post($id);
|
||||
|
||||
redirect('admin/list_post');
|
||||
}
|
||||
}
|
37
application/controllers/blog.php
Normal file
37
application/controllers/blog.php
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Blog extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('M_post');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->model('M_post');
|
||||
$this->db->select('*');
|
||||
$this->db->from('post');
|
||||
$getData = $this->db->get('');
|
||||
$a = $getData->num_rows();
|
||||
$config['base_url'] = base_url().'/blog/index'; //set the base url for pagination
|
||||
$config['total_rows'] = $a; //total rows
|
||||
$config['per_page'] = '5'; //the number of per page for pagination
|
||||
$config['uri_segment'] = '3'; //see from base_url. 3 for this case
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'judul' => 'Another Web',
|
||||
'daftarpost' => $this->M_post->get_post_all($config['per_page'],$this->uri->segment(3))
|
||||
);
|
||||
$this->load->view('blog/vIndex',$data);
|
||||
}
|
||||
|
||||
function post($id)
|
||||
{
|
||||
$data['judul']='Page';
|
||||
$data['edit']=$this->M_post->edit_post($id);
|
||||
$this->load->view('blog/vSingle',$data);
|
||||
}
|
||||
}
|
21
application/controllers/blog_post.php
Normal file
21
application/controllers/blog_post.php
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Post extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('M_post');
|
||||
}
|
||||
|
||||
function index($id)
|
||||
{
|
||||
$data['judul']='Page';
|
||||
$data['edit']=$this->M_post->edit_post($id);
|
||||
//$this->load->view('template/header');
|
||||
//$this->load->view('single',$data);
|
||||
//$this->load->view('template/footer');
|
||||
$this->load->view('single',$data);
|
||||
}
|
||||
}
|
10
application/controllers/index.html
Normal file
10
application/controllers/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
13
application/controllers/index.php
Normal file
13
application/controllers/index.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
class Index extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->view('index');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user