Exemplo n.º 1
0
<?php

date_default_timezone_set('America/Los_Angeles');
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once '../../master/libraries/common.php';
require_once 'config.php';
require_once '../../master/Slim/Slim.php';
require_once '../../master/3scale/ThreeScaleClient.php';
require_once '../../master/client/GitHubClient.php';
require_once '../../master/parse/index.php';
$gclient = new GitHubClient();
$gclient->setCredentials($guser, $gpass);
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
// Incoming Keys
$request = $app->request();
$Params = $request->params();
//var_dump($_GET);
if (isset($Params['appid'])) {
    $appid = $Params['appid'];
} else {
    $appid = "";
}
if (isset($Params['appkey'])) {
    $appkey = $Params['appkey'];
} else {
    $appkey = "";
}
$client = new ThreeScaleClient($three_scale_provider_key);
//echo "appid: " . $appid . "<br />";
Exemplo n.º 2
0
<?php

require_once dirname(__DIR__) . '/config.php';
require_once __DIR__ . '/github-php-client-master/client/GitHubClient.php';
$repos = array('civicrm/civicrm-core', 'civicrm/civicrm-packages', 'civicrm/civicrm-drupal', 'civicrm/civicrm-wordpress', 'civicrm/civicrm-joomla');
// Initialize database and prepared statements
$dbh = new PDO('mysql:dbname=' . DBNAME . ';host=' . DBHOST, DBUSER, DBPASS);
$stm_c = $dbh->prepare("\n  INSERT INTO github_commit (repository, hash, author_login, author_date, committer_login, committer_date, message)\n  VALUES (:repository, :hash, :author_login, :author_date, :committer_login, :committer_date, :message);\n");
$stm_u = $dbh->prepare("\n  INSERT INTO github_user (id, login, name, company, email, location, avatar_url)\n  VALUES (:id, :login, :name, :company, :email, :location, :avatar_url)\n  ON DUPLICATE KEY UPDATE\n     id=:id, login=:login, name=:name, company=:company, email=:email, location=:location, avatar_url=:avatar_url;\n");
// Initialize GitHub
$client = new GitHubClient();
$client->setCredentials(GITHUB_USERNAME, GITHUB_PASSWORD);
// Loop over each repository
$users = array();
foreach ($repos as $repo) {
    echo "Repository {$repo} ...";
    $new_commits = 0;
    $stm_c->bindParam(':repository', $repo);
    // Get last commit date in database
    $result = $dbh->query("SELECT MAX(author_date) FROM github_commit WHERE repository='{$repo}';")->fetch();
    // Get commits from GitHub
    $parts = explode('/', $repo);
    $client->setPage();
    // reinitialize the results pager
    $commits = $client->repos->commits->listCommitsOnRepository($parts[0], $parts[1], null, null, null, $result[0]);
    // Loop over each commit (paged)
    while (sizeof($commits)) {
        foreach ($commits as $commit) {
            /* @var $commit GitHubCommit */
            // Write commit to database
            $stm_c->bindParam(':hash', $commit->getSha());
Exemplo n.º 3
0
 private static function client()
 {
     $client = new GitHubClient();
     $client->setCredentials(GITHUB_USER, GITHUB_PASS);
     return $client;
 }
Exemplo n.º 4
0
 public function git_upload($file)
 {
     require_once __root__ . '/SimpleVers/system/github/client/GitHubClient.php';
     $owner = $this->owner;
     $repo = $this->github_repo;
     $username = $this->github_user;
     $password = $this->github_pass;
     $tag_name = basename($file);
     $target_commitish = 'master';
     $name = $this->name;
     $body = $this->description;
     $draft = false;
     $prerelease = false;
     $client = new GitHubClient();
     $client->setDebug(false);
     $client->setCredentials($username, $password);
     try {
         $release = $client->repos->releases->create($owner, $repo, $tag_name, $target_commitish, $name, $body, $draft, $prerelease);
         $releaseId = $release->getId();
         $filePath = $file;
         $contentType = 'application/php';
         $name = basename($file);
         try {
             $client->repos->releases->assets->upload($owner, $repo, $releaseId, $name, $contentType, $filePath);
             echo "<img src='/SimpleVers/interface/images/success.png'><h2>File successfully uploaded.</h2>";
         } catch (Exception $e) {
             echo "Error: " . $e;
         }
     } catch (Exception $e) {
         echo "<img src='/SimpleVers/interface/images/cloud.png'><h2>This file seems to be already uploaded.</h2>";
     }
 }
Exemplo n.º 5
0
 * @since Boilerplate 1.0
 */
$data = Timber::get_context();
$pi = new TimberPost();
$data['post'] = $pi;
$data['body_class'] .= ' page-' . $pi->post_name;
$template_file = 'page.twig';
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css')) {
    $data['post']->css_file = $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css';
}
$contribs = TimberHelper::transient('timber-contribs', function () {
    require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/tan-tan-kanarek/github-php-client/client/GitHubClient.php';
    $client = new GitHubClient();
    $auth = file_get_contents(__DIR__ . '/auth.json');
    $auth = json_decode($auth);
    $client->setCredentials($auth->github->user, $auth->github->pass);
    $contribs = $client->repos->listContributors('jarednova', 'timber', array('per_page' => 100));
    $extra = count($contribs) % 6;
    $total = count($contribs) - $extra;
    $contribs = TimberHelper::array_truncate($contribs, $total);
    $ret = array();
    foreach ($contribs as $contrib) {
        $obj = new stdClass();
        $obj->login = $contrib->getLogin();
        $obj->avatar_url = $contrib->getAvatarUrl();
        $ret[] = $obj;
    }
    return $ret;
}, 1200);
$data['contribs'] = $contribs;
Timber::render(array('custom/page-' . $pi->post_name . '.twig', 'page-' . $pi->post_name . '.twig', 'page.twig'), $data);
Exemplo n.º 6
0
 public function reuploadRelease()
 {
     require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/client/GitHubClient.php';
     $client = new GitHubClient();
     $client->setDebug(true);
     $client->setAuthType(GitHubClient::GITHUB_AUTH_TYPE_BASIC);
     $client->setCredentials('daviddeutsch', trim(file_get_contents(__DIR__ . '/../github-oauth.token')));
     foreach (glob(__DIR__ . '/tmp/*.zip') as $path) {
         $file = $path;
     }
     $release = $client->repos->releases->get('valanx', 'aec', 'latest');
     $client->repos->releases->assets->upload('valanx', 'aec', $release->getId(), basename($file), 'application/zip', $file);
 }