- Enforce minimum elapsed time on registration form
[scuttle] / api / httpauth.inc.php
1 <?php
2 //  Provides HTTP Basic authentication of a user, and sets two variables, sId and username,
3 //  with the user's info.
4
5 function authenticate() {
6     header('WWW-Authenticate: Basic realm="del.icio.us API"');
7     header('HTTP/1.0 401 Unauthorized');
8     die(T_('Use of the API calls requires authentication.'));
9 }
10
11 if (!isset($_SERVER['PHP_AUTH_USER'])) {
12     authenticate();
13 } else {
14     require_once('../header.inc.php');
15     $userservice =& ServiceFactory::getServiceInstance('UserService');
16
17     $login = $userservice->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); 
18     if (!$login) {
19         authenticate();
20     }
21 }
22 ?>

Benjamin Mako Hill || Want to submit a patch?