- Enforce minimum elapsed time on registration form
[scuttle] / api / posts_dates.php
1 <?php
2 // Implements the del.icio.us API request for a user's post counts by date (and optionally
3 // by tag).
4
5 // Force HTTP authentication first!
6 require_once 'httpauth.inc.php';
7 require_once '../header.inc.php';
8
9 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
10 $userservice     =& ServiceFactory::getServiceInstance('UserService');
11
12 // Check to see if a tag was specified.
13 if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
14     $tag = trim($_REQUEST['tag']);
15 else
16     $tag = NULL;
17
18 // Get the posts relevant to the passed-in variables.
19 $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag);
20
21 $currentuser = $userservice->getCurrentUser();
22 $currentusername = $currentuser[$userservice->getFieldName('username')];
23
24 //      Set up the XML file and output all the tags.
25 header('Content-Type: text/xml');
26 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
27 echo '<dates tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentusername, 'xml') ."\">\r\n";
28
29 $count    = 0;
30 $lastdate = NULL;
31 foreach ($bookmarks['bookmarks'] as $row) {
32     $thisdate = gmdate('Y-m-d', strtotime($row['bDatetime']));
33     if ($thisdate != $lastdate && $lastdate != NULL) {
34         echo "\t<date count=\"". $count .'" date="'. $lastdate ."\" />\r\n";
35         $count = 1;
36     }
37     else {
38         $count++;
39     }
40     $lastdate = $thisdate;
41 }
42
43 echo "</dates>";

Benjamin Mako Hill || Want to submit a patch?