Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Apr 16, 2015
1 parent 268fc22 commit d53dfff
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions stats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
//
// Get github download stats
//
function req($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch,CURLOPT_USERAGENT,"alejandroliu");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}

//$data = file_get_contents();
//echo $data;

///$url = "https://api.github.com/users/alejandroliu/repos";
//print_r( req("https://api.github.com/users/alejandroliu/repos"));

//echo req("https://api.github.com/repos/alejandroliu/bad-plugins/releases");
//print_r( req("https://api.github.com/repos/alejandroliu/bad-plugins/releases"));
//print_r( req("https://api.github.com/repos/alejandroliu/pocketmine-plugins/releases"));
foreach (req("https://api.github.com/repos/alejandroliu/pmimporter/releases")
as $rel) {
if (isset($rel->name) && $rel->name)
echo "# ".$rel->name."\n";
elseif (isset($rel->tag_name) && $rel->tag_name)
echo "# ".$rel->tag_name."\n";
else
echo "# release\n";
$tab = [];
$cols = [1,1];
if (isset($rel->assets)) {
foreach ($rel->assets as $a) {
if (isset($a->name) && isset($a->download_count)) {
$tab[] = [ $a->name, $a->download_count ];
}
}
}
foreach ($tab as $row) {
for ($i=0;$i<count($cols);$i++) {
if (strlen($row[$i]) > $cols[$i]) $cols[$i] = strlen($row[$i]);
}
}
foreach ($tab as $row) {
printf(" - %-".$cols[0]."s %".$cols[1]."d\n",$row[0],$row[1]);
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pmimporter 1.5pre
pmimporter 1.5rel

0 comments on commit d53dfff

Please sign in to comment.