Example #1
0
function register_all_route($data)
{
    $filtered = register_route($data, array('post', 'page'));
    return $filtered;
}
Example #2
0
    return true;
}
register_route('GET', 'repos', 'api_get_repos');
register_route('GET', 'repos/files/raw/(.+)', 'api_get_repo_files_raw');
register_route('GET', 'repos/files/(.+)', 'api_get_repo_files');
register_route('GET', 'repos/targets/(.+)', 'api_get_repo_targets');
register_route('GET', 'temps', 'api_get_temps');
register_route('POST', 'temps/create', 'api_post_temp_create');
register_route('GET', 'temps/([0-9]+)', 'api_get_temp');
register_route('GET', 'temps/files/([0-9]+)/(.+)', 'api_get_temp_file');
register_route('POST', 'temps/files/update/([0-9]+)', 'api_post_temp_files_update');
register_route('POST', 'temps/files/upload/([0-9]+)', 'api_post_temp_files_upload');
register_route('POST', 'temps/files/delete/([0-9]+)/(.+)', 'api_post_temp_files_delete');
register_route('POST', 'temps/make/([0-9]+)/?(.*)', 'api_post_temp_make');
register_route('POST', 'temps/commit/([0-9]+)', 'api_post_temp_commit');
register_route('POST', 'temps/push/([0-9]+)', 'api_post_temp_push');
register_route('POST', 'temps/switch_repo/([0-9]+)', 'api_post_temp_switch_repo');
register_route('POST', 'temps/delete/([0-9]+)', 'api_post_temp_delete');
register_route('GET', 'projects', 'api_get_projects');
register_route('POST', 'projects/create/(.+)', 'api_post_project_create');
register_route('POST', 'projects/update/(.+)', 'api_post_project_create');
register_route('POST', 'projects/delete/(.+)', 'api_post_project_delete');
$query = $_SERVER['QUERY_STRING'];
// use the first URL argument for the router
$pos = strpos($query, '&');
if ($pos !== false) {
    $query = substr($query, 0, $pos);
}
// return JSON by default
@header('Content-type: application/json; charset=utf-8');
echo json_encode(route($_SERVER['REQUEST_METHOD'], $query));
Example #3
0
 *	@return true if sucessful, false if not
 */
function github_add_webhook($github_access_token, $github_repo)
{
    $client = new OAuth2\Client(config('github_client_id'), config('github_client_secret'));
    $client->setAccessToken($github_access_token);
    $client->setAccessTokenType(OAuth2\Client::ACCESS_TOKEN_TOKEN);
    $client->setCurlOption(CURLOPT_USERAGENT, config('github_useragent'));
    $param = array('name' => 'web', 'active' => true, 'events' => array('push'), 'config' => array('url' => base_url() . 'github.php?push', 'content_type' => 'form'));
    $response = $client->fetch('https://api.github.com/repos/' . $github_repo . '/hooks', json_encode($param), 'POST');
    if (!isset($response['code']) || $response['code'] !== 201) {
        return false;
    } else {
        return true;
    }
}
register_route('GET', 'auth', 'github_get_auth');
/* invoked by GitHub */
register_route('GET', 'auth_callback=?', 'github_get_auth_callback');
register_route('POST', 'repo', 'github_post_repo');
/* invoked by GitHub webhook */
register_route('POST', 'push=?', 'github_post_push');
$query = $_SERVER['QUERY_STRING'];
// use the first URL argument for the router
$pos = strpos($query, '&');
if ($pos !== false) {
    $query = substr($query, 0, $pos);
}
// return JSON by default
@header('Content-type: application/json; charset=utf-8');
echo json_encode(route($_SERVER['REQUEST_METHOD'], $query));