コード例 #1
0
ファイル: webapp.php プロジェクト: bgarrels/cxldemo
            $response = array("success" => true, "totalCount" => $webapp->getCount($params), "rows" => $webapp->getData($params));
            $webapp->output($response);
            break;
        default:
            //Perform action on class
            try {
                $webapp->{$action}($id);
            } catch (Exception $e) {
            }
    }
}
/**
 * Here start webapplication
 */
if (!isset($_REQUEST["action"])) {
    return;
}
$action = $_REQUEST["action"];
$id = isset($_REQUEST["id"]) ? $_REQUEST["id"] : null;
$webapp = new WebApp();
if (isset($id) && $webapp->authorized("{$action}.{$id}", "guest") || $webapp->authorized("{$action}", "guest")) {
    //Check if action can be done as guest
    doAction($webapp, $action, $id);
} elseif (!$webapp->authenticate()) {
    //Check if there is an authentication header
    $webapp->output(array('controlerAuthentication' => 'required'));
} elseif (isset($id) && $webapp->authorized("{$action}.{$id}") || $webapp->authorized("{$action}")) {
    //Check if action can be done as guest
    doAction($webapp, $action, $id);
}
$webapp->output(array('controlerError' => "Unknown or unauthorized action {$action}.{$id}", 'info' => "action", 'action' => "{$action}", 'id' => "{$id}"));