Created
October 20, 2015 15:43
-
-
Save ahonymous/a77379f14930b2997230 to your computer and use it in GitHub Desktop.
test
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
<?php | |
require_once 'vendor/autoload.php'; | |
use Filipac\Ip; | |
PHP_Timer::start(); | |
$ip = Ip::get(); | |
echo "Hello, your ip is: {$ip} </br> "; | |
$client = new \Github\Client(); | |
$userList = []; | |
$userFile = fopen("libs/users.lib", "a+"); | |
if ($userFile) { | |
while (($buffer = fgets($userFile, 4096)) !== false) { | |
$user = explode(',', $buffer); | |
if ($user[0] && $user[1]) { | |
$userList[] = [ | |
'name' => $user[0], | |
'login' => $user[1] | |
]; | |
} | |
} | |
if (!feof($userFile)) { | |
echo "Error: unexpected fgets() fail\n"; | |
} | |
fclose($userFile); | |
} | |
?> | |
<table cellspacing="2" border="1" cellpadding="5" width="600"> | |
<tr> | |
<td>Name</td> | |
<td>Login</td> | |
<td>URL</td> | |
<td>Repositories</td> | |
</tr> | |
<?php | |
foreach ($userList as $user) { | |
$login = trim($user['login'], PHP_EOL); | |
try { | |
$repositories = $client->api('user')->repositories($login); | |
} catch (Exception $e) { | |
error_log($e->getMessage()); | |
$repositories = ''; | |
} | |
if (!empty($repositories)) { | |
$url = $repositories[0][owner][html_url]; | |
$repoCount = count($repositories); | |
}else{ | |
$url = 'none'; | |
$repoCount = '-'; | |
} | |
?> | |
<tr> | |
<td><?= $user['name'] ?></td> | |
<td><?= $login ?></td> | |
<td><a href="<?= $url ?>"><?= $url ?></a></td> | |
<td><?= $repoCount ?></td> | |
</tr> | |
<?php | |
} | |
?> | |
</table> | |
<?php | |
$time = PHP_Timer::stop(); | |
echo 'Loaded for: ' . PHP_Timer::secondsToTimeString($time); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment