SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | defined('BASEPATH') OR exit('No direct script access allowed');
| |
| 3 | ||
| 4 | class Front extends CI_Controller {
| |
| 5 | //================= BARU | |
| 6 | function check_files(){
| |
| 7 | $directory = dirname(__FILE__); | |
| 8 | $files=dirname(__FILE__).'/assets/images/14.jpg'; | |
| 9 | $d = dir($directory); | |
| 10 | echo"<pre>$directory | $files"; | |
| 11 | echo "Handle: " . $d->handle . "\n"; | |
| 12 | echo "Path: " . $d->path . "\n"; | |
| 13 | while (false !== ($entry = $d->read())) {
| |
| 14 | echo $entry."\n"; | |
| 15 | } | |
| 16 | $d->close(); | |
| 17 | } | |
| 18 | public function __construct() {
| |
| 19 | parent::__construct(); | |
| 20 | } | |
| 21 | ||
| 22 | public function index() {
| |
| 23 | $data = [ | |
| 24 | 'title' => 'Ini halaman edit', | |
| 25 | 'author' => 'Abdurrahman', | |
| 26 | 'date' => date('Y-m-d H:i:s'),
| |
| 27 | 'content' => 'Ini adalah contoh dari penggunaan variable, yakni bypass variable lewat view' | |
| 28 | ]; | |
| 29 | $this->load->view('index', $data);
| |
| 30 | } | |
| 31 | ||
| 32 | public function category_page() {
| |
| 33 | $this->load->view('category_page');
| |
| 34 | } | |
| 35 | ||
| 36 | public function add_article($param=null){
| |
| 37 | if ($param == 'add') {
| |
| 38 | $post = $this->input->post(); | |
| 39 | ||
| 40 | if (!empty($post['title']) && !empty($post['author']) && !empty($post['content'])) {
| |
| 41 | $this->load->model('Post');
| |
| 42 | $data = [ | |
| 43 | 'title' => $post['title'], | |
| 44 | 'author' => $post['author'], | |
| 45 | 'date' => date('Y-m-d'),
| |
| 46 | 'content' => $post['content'] | |
| 47 | ]; | |
| 48 | $this->Post->insert('post', $data);
| |
| 49 | $this->load->view('add_article_done', $data);
| |
| 50 | } else {
| |
| 51 | $this->load->view('add_article_fail', $data);
| |
| 52 | } | |
| 53 | } else {
| |
| 54 | $this->load->view('add_article');
| |
| 55 | } | |
| 56 | } | |
| 57 | ||
| 58 | public function image_lib_test(){
| |
| 59 | $config['image_library'] = 'gd2'; | |
| 60 | $config['source_image'] = dirname(__FILE__).'/assets/images/14.jpg'; | |
| 61 | $config['create_thumb'] = TRUE; | |
| 62 | $config['maintain_ratio'] = TRUE; | |
| 63 | $config['width'] = 75; | |
| 64 | $config['height'] = 50; | |
| 65 | ||
| 66 | var_dump(file_exists($config['source_image'])); | |
| 67 | ||
| 68 | $this->load->library('image_lib', $config);
| |
| 69 | ||
| 70 | if (!$this->image_lib->resize()) {
| |
| 71 | echo $this->image_lib->display_errors(); | |
| 72 | } else {
| |
| 73 | echo 'It Works!'; | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | public function pagination_lib_test(){
| |
| 78 | $this->load->library('pagination');
| |
| 79 | ||
| 80 | $config['base_url'] = base_url('front/pagination_lib_test/hal/');
| |
| 81 | $config['total_rows'] = 200; | |
| 82 | $config['per_page'] = 20; | |
| 83 | ||
| 84 | $this->pagination->initialize($config); | |
| 85 | ||
| 86 | echo $this->pagination->create_links(); | |
| 87 | } | |
| 88 | ||
| 89 | public function login() {
| |
| 90 | $this->load->helper('url');
| |
| 91 | echo '<a href="' . base_url('front/login_success') . '">Klik untuk login</a>';
| |
| 92 | } | |
| 93 | } | |
| 94 | ||
| 95 | ||
| 96 | // public function gets($id) {
| |
| 97 | // echo $id; | |
| 98 | // } | |
| 99 | /* End of file Front.php */ | |
| 100 | /* Location: ./application/controllers/Front.php */ |