Пример #1
0
<?php

require_once 'githubConfig.php';
#require_once('githubApi.php');
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    if (isset($_GET['code'])) {
        $git = new githubApi($config);
        $git->getUserDetails();
        $_SESSION['github_data'] = $git->getAllUserDetails();
        header("location: home.php");
    } else {
        $url = "https://github.com/login/oauth/authorize?client_id=" . $config['client_id'] . "&redirect_uri=" . $config['redirect_url'] . "&scope=user";
        header("Location: {$url}");
    }
}
Пример #2
0
<?php

denyBots();
require_once __DIR__ . '/githubApi.php';
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/db.php';
$db = new db();
$repos = new githubApi();
$contributors = new githubApi();
$repositories = array();
$projects_query_data = array();
$contributors_query_data = array();
$parameters = getGetVars();
$result = $repos->requestData('repo', 'find', $parameters);
do {
    foreach ($result['repositories'] as $id => $repo) {
        $repositories[] = array_merge($repo, array('contributors' => requestContributors($contributors, $repo['owner'], $repo['name'])));
        if (haveEnoughRepos($repositories)) {
            break;
        }
    }
    $result = $repos->nextPage();
} while ($repos->hasMorePages() && !haveEnoughRepos($repositories));
foreach ($repositories as $id => $repository) {
    $projects_query_data[] = implodeDataForQuery(array('id' => $id, 'name' => $repository['name'], 'description' => $repository['description'], 'owner' => $repository['owner'], 'homepage' => $repository['homepage'], 'watchers' => $repository['watchers'], 'forks' => $repository['forks'], 'stargazers' => $repository['followers']));
    foreach ($repository['contributors'] as $contributor) {
        $contributors_query_data[] = implodeDataForQuery(array('id' => isset($contributor['id']) ? $contributor['id'] : 0, 'contributor_name' => isset($contributor['login']) ? $contributor['login'] : $contributor['name'], 'project_id' => $id));
    }
}
initializeTables($db);
$db->query('INSERT INTO `projects` (`id`, `name`, `description`, `owner`, `homepage`, `watchers`, `forks`, `stargazers`) VALUES ' . implode(', ', $projects_query_data) . ';');