Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Front extends CI_Controller {
- //================= BARU
- function check_files(){
- $directory = dirname(__FILE__);
- $files=dirname(__FILE__).'/assets/images/14.jpg';
- $d = dir($directory);
- echo"<pre>$directory | $files";
- echo "Handle: " . $d->handle . "\n";
- echo "Path: " . $d->path . "\n";
- while (false !== ($entry = $d->read())) {
- echo $entry."\n";
- }
- $d->close();
- }
- public function __construct() {
- parent::__construct();
- }
- public function index() {
- $data = [
- 'title' => 'Ini halaman edit',
- 'author' => 'Abdurrahman',
- 'date' => date('Y-m-d H:i:s'),
- 'content' => 'Ini adalah contoh dari penggunaan variable, yakni bypass variable lewat view'
- ];
- $this->load->view('index', $data);
- }
- public function category_page() {
- $this->load->view('category_page');
- }
- public function add_article($param=null){
- if ($param == 'add') {
- $post = $this->input->post();
- if (!empty($post['title']) && !empty($post['author']) && !empty($post['content'])) {
- $this->load->model('Post');
- $data = [
- 'title' => $post['title'],
- 'author' => $post['author'],
- 'date' => date('Y-m-d'),
- 'content' => $post['content']
- ];
- $this->Post->insert('post', $data);
- $this->load->view('add_article_done', $data);
- } else {
- $this->load->view('add_article_fail', $data);
- }
- } else {
- $this->load->view('add_article');
- }
- }
- public function image_lib_test(){
- $config['image_library'] = 'gd2';
- $config['source_image'] = dirname(__FILE__).'/assets/images/14.jpg';
- $config['create_thumb'] = TRUE;
- $config['maintain_ratio'] = TRUE;
- $config['width'] = 75;
- $config['height'] = 50;
- var_dump(file_exists($config['source_image']));
- $this->load->library('image_lib', $config);
- if (!$this->image_lib->resize()) {
- echo $this->image_lib->display_errors();
- } else {
- echo 'It Works!';
- }
- }
- public function pagination_lib_test(){
- $this->load->library('pagination');
- $config['base_url'] = base_url('front/pagination_lib_test/hal/');
- $config['total_rows'] = 200;
- $config['per_page'] = 20;
- $this->pagination->initialize($config);
- echo $this->pagination->create_links();
- }
- public function login() {
- $this->load->helper('url');
- echo '<a href="' . base_url('front/login_success') . '">Klik untuk login</a>';
- }
- }
- // public function gets($id) {
- // echo $id;
- // }
- /* End of file Front.php */
- /* Location: ./application/controllers/Front.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement