Example #1
0
        if ($rs) {
            redirect('index.php/sample');
        }
        break;
        /* Edit data */
    /* Edit data */
    case 'edit':
        $id = Segment(4);
        $data['book'] = $findOrFail('books', ['id' => $id]);
        View('books.edit', $data);
        break;
        /* Process update data */
    /* Process update data */
    case 'update':
        $id = input('_id');
        $parse = ['title' => input('_title'), 'year' => input('_year'), 'author' => input('_author')];
        $rs = $updateData('books', $parse, ['id' => $id]);
        if ($rs) {
            redirect('index.php/sample');
        }
        break;
        /* Delete data */
    /* Delete data */
    default:
        $id = Segment(3);
        $rs = $delData('books', ['id' => $id]);
        if ($rs) {
            redirect('index.php/sample');
        }
        break;
}
Example #2
0
<?php

defined('ENGPATH') or exit('Forbbiden');
/**
* @author Dwi Hujianto <*****@*****.**>
* @package Engine / Router
*/
$getUri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$controller = explode('/', $getUri);
if (isset($controller[2]) && strlen($controller[2]) > 0) {
    $path = APP . 'modules/' . Segment(2) . '.php';
    if (file_exists($path)) {
        require_once $path;
    } else {
        show_404();
    }
} else {
    if (isset($default_page)) {
        if (file_exists(APP . 'modules/' . $default_page . '.php')) {
            require_once APP . 'modules/' . $default_page . '.php';
        } else {
            error_msg('Halaman pertama tidak ditemukan');
        }
    } else {
        error_msg('Halaman pertama belum ditentukan');
    }
}