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

Commit d53dfff

Browse files
committed
Update
1 parent 268fc22 commit d53dfff

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

stats.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
//
3+
// Get github download stats
4+
//
5+
function req($url) {
6+
$ch = curl_init();
7+
curl_setopt($ch, CURLOPT_URL, $url);
8+
// Set so curl_exec returns the result instead of outputting it.
9+
curl_setopt($ch,CURLOPT_USERAGENT,"alejandroliu");
10+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
11+
// Get the response and close the channel.
12+
$response = curl_exec($ch);
13+
curl_close($ch);
14+
return json_decode($response);
15+
}
16+
17+
//$data = file_get_contents();
18+
//echo $data;
19+
20+
///$url = "https://api.github.com/users/alejandroliu/repos";
21+
//print_r( req("https://api.github.com/users/alejandroliu/repos"));
22+
23+
//echo req("https://api.github.com/repos/alejandroliu/bad-plugins/releases");
24+
//print_r( req("https://api.github.com/repos/alejandroliu/bad-plugins/releases"));
25+
//print_r( req("https://api.github.com/repos/alejandroliu/pocketmine-plugins/releases"));
26+
foreach (req("https://api.github.com/repos/alejandroliu/pmimporter/releases")
27+
as $rel) {
28+
if (isset($rel->name) && $rel->name)
29+
echo "# ".$rel->name."\n";
30+
elseif (isset($rel->tag_name) && $rel->tag_name)
31+
echo "# ".$rel->tag_name."\n";
32+
else
33+
echo "# release\n";
34+
$tab = [];
35+
$cols = [1,1];
36+
if (isset($rel->assets)) {
37+
foreach ($rel->assets as $a) {
38+
if (isset($a->name) && isset($a->download_count)) {
39+
$tab[] = [ $a->name, $a->download_count ];
40+
}
41+
}
42+
}
43+
foreach ($tab as $row) {
44+
for ($i=0;$i<count($cols);$i++) {
45+
if (strlen($row[$i]) > $cols[$i]) $cols[$i] = strlen($row[$i]);
46+
}
47+
}
48+
foreach ($tab as $row) {
49+
printf(" - %-".$cols[0]."s %".$cols[1]."d\n",$row[0],$row[1]);
50+
}
51+
}

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pmimporter 1.5pre
1+
pmimporter 1.5rel

0 commit comments

Comments
 (0)