This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
268fc22
commit d53dfff
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pmimporter 1.5pre | ||
pmimporter 1.5rel |