コード例 #1
0
ファイル: api.php プロジェクト: CoreylDagget/dbc
 * Created by JetBrains PhpStorm.
 * User: georgroesch
 * Date: 04.09.12
 * Time: 21:30
 */
//be as verbose as possible
error_reporting(E_ALL | E_STRICT);
if (!defined('DBC_EXECUTION_MODE')) {
    define('DBC_EXECUTION_MODE', 'web');
}
$return = array('status' => 'ok');
spl_autoload_register(function ($class) {
    require_once dirname(__FILE__) . '/lib/' . $class . '.class.php';
});
try {
    $settings = DbChangesSettings::getInstance();
    $changeFactory = new ChangeFactory($settings, new CacheFactory($settings));
    if (!isset($_REQUEST['action'])) {
        throw new Exception('No action given.');
    }
    $command = $_REQUEST['action'];
    if (isset($_REQUEST['cli_args']) && DBC_EXECUTION_MODE == 'cli') {
        $_REQUEST = $_REQUEST['cli_args'];
    }
    $className = 'Action' . ucfirst($command);
    if (!file_exists(dirname(__FILE__) . '/lib/' . $className . '.class.php')) {
        throw new Exception('Class "' . $className . '" does not exist.');
    }
    if (!is_readable(dirname(__FILE__) . '/lib/' . $className . '.class.php')) {
        throw new Exception('Class "' . $className . '" is not readable.');
    }