Commit:    136cc0d7058fb75af35914b759511ce97c451f44
Author:    Hannes Magnusson <[email protected]>         Sun, 29 Dec 2013 
21:44:36 -0800
Parents:   6e51ad42ecc386b2dabd5bc86d2a25acc4230cc3
Branches:  master

Link:       
http://git.php.net/?p=web/people.git;a=commitdiff;h=136cc0d7058fb75af35914b759511ce97c451f44

Log:
List devs on the frontpage

Changed paths:
  M  include/misc.php
  M  index.php


Diff:
diff --git a/include/misc.php b/include/misc.php
index 78b1ffb..d1ecffd 100644
--- a/include/misc.php
+++ b/include/misc.php
@@ -16,6 +16,26 @@ function getDOMNodeFrom($url, $nodename)
     return $search->item(0);
 }
 
+function findAllUsers($batch) {
+    $opts = array("ignore_errors" => true);
+    $ctx = stream_context_create(array("http" => $opts));
+    $token = getenv("TOKEN");
+    if (!$token) {
+        $token = trim(file_get_contents("token"));
+    }
+    $url = "https://master.php.net/fetch/allusers.php?token="; . 
rawurlencode($token);
+    $retval = cached($url, false, $ctx);
+    $json = json_decode($retval, true);
+    if (!is_array($json)) {
+        error("Something happend to master");
+    }
+    if (isset($json["error"])) {
+        error($json["error"]);
+    }
+
+    $batch *= 100;
+    return array_slice($json, $batch, 100);
+}
 function findPHPUser($username)
 {
     $opts = array("ignore_errors" => true);
diff --git a/index.php b/index.php
index 5f2a181..913451f 100644
--- a/index.php
+++ b/index.php
@@ -2,6 +2,7 @@
 /* $Id$ */
 
 require "./include/layout.php";
+require "./include/misc.php";
 $USERNAME = filter_input(INPUT_GET, "username", FILTER_SANITIZE_ENCODED, 
FILTER_FLAG_STRIP_HIGH);
 
 if ($USERNAME) {
@@ -10,10 +11,44 @@ if ($USERNAME) {
 }
 
 site_header("PHP: Developers Profile Pages");
+$page = filter_input(INPUT_GET, "page", FILTER_VALIDATE_INT, array("options" 
=> array("min_range" => 1))) ?: 1;
 ?>
 
-  <p class="warning smaller"><strong>WARNING</strong>: This is obviously work 
in progress :)</p>
-  <p>Use the searchbox to search for usernames/names</p>
+<table>
+<thead>
+    <tr>
+        <th></th>
+        <th>Username</th>
+        <th>Full name</th>
+    </tr>
+</thead>
+<tbody>
+
+<?php $x = 0 ?>
+<?php foreach (findAllUsers($page) as $x => $user): ?>
+    <tr>
+        <td class="gravatar"><img src="http://www.gravatar.com/avatar/<?php 
echo md5($user["username"] . "@php.net")?>.jpg" alt="Picture of <?php 
$user["name"] ?>" height="80" width="80" /></td>
+        <td class="username"><a href="user.php?username=<?php echo 
$user["username"]?>"><?php echo $user["username"] ?></a></td>
+        <td class="name"><?php echo $user["name"] ?></td>
+    </tr>
+<?php endforeach ?>
+</tbody>
+<tfoot>
+<tr>
+<th>
+    <?php if ($page): ?>
+    <a href="?page=<?php echo $page-1?>">Previous page</a></th>
+    <?php endif ?>
+</th>
+<th></th>
+<th>
+    <?php if ($x == 99): ?>
+    <a href="?page=<?php echo ++$page?>">Next page</a></th>
+    <?php endif ?>
+</th>
+</tr>
+</tfoot>
+</table>
 
 <?php
 site_footer();


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to