Exemple #1
0
 public function __construct($app)
 {
     $this->app = $app;
     $this->login = $this->app->user_config["github"]["login"];
     $this->token = $this->app->user_config["github"]["token"];
     self::$labels = $this->curl_request("repos/Thierno-EEC/vroom/labels");
 }
Exemple #2
0
<?php

header('Content-type: text/html; charset=UTF-8');
require 'vendor/autoload.php';
require 'classes/issue.php';
require 'classes/github_api.php';
$app = new \Slim\Slim();
include 'config.php';
$app->get('/', function () use($app) {
    $gha = new GithubApi($app);
    $issues = $gha->parseToTestIssues();
    $closed_issues = $gha->parseClosedBugs();
    $app->render('../views/issues.php', array('issues' => $issues));
});
$app->get('/books/:id', function ($id) {
    echo $id;
});
$app->get('books', function ($id) {
    echo "books";
});
$app->run();
}
//
// main part
$res = array();
try {
    if ($is_auth_request) {
        $github_api = new GithubApi($config['github']);
        $github_api->auth();
    }
    if ($pull && $rep) {
        $config['github']['variables']['token'] = @file_get_contents($config['github']['token_file']);
        if ($config['github']['variables']['token']) {
            $config['github']['variables']['pull'] = $pull;
            $config['github']['variables']['repo'] = $rep;
            // Retrieve required data from GitHub
            $github_api = new GithubApi($config['github']);
            $pull_request = $github_api->getPullRequest();
            $diff = $github_api->getPullRequestDiff();
            $prepared_diff = $github_api->getFilesRawContent($pull_request, $diff);
            // Transfer data to CsWrapper
            $csWrapper = new CsWrapper();
            $csWrapper->cswSetStandard($config['cs']['standard']);
            foreach ($prepared_diff as $file => $data) {
                $csWrapper->cswAddCode($file, $data['content'], array_keys($data['lines']));
            }
            // Execute checks
            $data = $csWrapper->cswExecute();
            // Generate full HTML report for changed lines
            $html_report_object = new CsHtmlReport($data, false);
            $res['content'] = $html_report_object->generateFullPageHTML('Code Style Report for pull request ' . $pull . ' in ' . $rep);
        } else {
<?php

ini_set('display_errors', 'on');
ini_set('errors_reporting', ~E_ALL);
$res = array();
if (isset($_REQUEST['code'])) {
    $code = filterCode($_REQUEST['code']);
    if ($code) {
        $root = dirname(__FILE__) . '/';
        require_once "{$root}include/githubapi/GithubApi.php";
        require_once "{$root}config.php";
        $config['github']['variables']['code'] = $code;
        @unlink($config['github']['token_file']);
        $res = array('result' => 'ok');
        try {
            $github_api = new GithubApi($config['github']);
            $token = array('token' => $github_api->authGetToken());
            file_put_contents($config['github']['token_file'], $token);
        } catch (Exception $e) {
            $res = array('error' => 'Fatal error. ' . $e->getMessage());
        }
    } else {
        $res = array('error' => 'Invalid request');
    }
}
header('Content-Type: application/json');
echo json_encode($res);
exit;
function filterCode($code)
{
    return preg_replace('~[^A-Za-z0-9]~', '', substr(trim($code), 0, 32));