Exemple #1
0
$url = $_SERVER['REQUEST_URI'];
$url = substr($url, strlen(SUBDIR . INDEX));
$url = str_replace(array("/index.php"), "", $url);
$url = str_replace(array("?", "&"), "/", $url);
$array_uri = preg_split('[\\/]', $url, -1, PREG_SPLIT_NO_EMPTY);
// ambil controller
if (isset($array_uri[0])) {
    $uri['controller'] = str_replace(array("-"), "_", $array_uri[0]);
    unset($array_uri[0]);
} else {
    $uri['controller'] = DEFAULT_CONTROLLER;
}
// ambil action/fungsi/method
if (isset($array_uri[1])) {
    $uri['request'] = $array_uri[1];
    $uri['method'] = str_replace(array("-"), "_", $array_uri[1]);
    if (in_array($uri['method'], array("db", "query", "insert", "update", "delete", "escape", "loadController", "loadView", "loadModel"))) {
        die("mohon ubah nama aksi <b>{$uri['method']}</b> di <b>class {$uri['controller']}</b>, karena penamaan fungsi ini digunakan oleh sistem framework<br />--ratno");
    }
    unset($array_uri[1]);
} else {
    $uri['method'] = DEFAULT_ACTION;
}
// ambil parameter
foreach ($array_uri as $item_uri) {
    $arr_tmp = explode(":", str_replace("=", ":", $item_uri));
    $uri['var'][$arr_tmp[0]] = $arr_tmp[1];
}
$app = new application($uri);
$app->init();
$app->controller($uri['controller']);
Exemple #2
0
<?php

define('ROOT_PATH', '../');
define('CURSCRIPT', 'fetch');
define('FETCH', true);
$cache_list = array('setting', 'channels', 'cate', 'shop');
include ROOT_PATH . 'inc/class/application.class.php';
application::init();
$api = new api();
$api->init();
header("Content-Type: text/json");
header("KissyIoDataType:json");
header('Content-Type: text/html; charset=' . CHARSET);
class api
{
    function json($arr)
    {
        global $_G;
        if ($_G['json_status']) {
            return false;
        }
        $_G['json_status'] = true;
        if (!isset($arr['status'])) {
            $arr['status'] = 'error';
        }
        $arr[tae] = TAE ? 1 : 0;
        $arr['domain'] = $_SERVER['HTTP_HOST'];
        echo json_encode($arr);
    }
    function init()
    {