source: subversion/sites/other/tilesAtHome/lib/users.inc @ 3655

Last change on this file since 3655 was 2344, checked in by ojw, 13 years ago

Function to lookup username from user ID

File size: 1012 bytes
Line 
1<?php
2
3function checkUser($SuppliedUsername, $SuppliedPassword){
4  $fp = fopen(userListFilename(), "r");
5  if(!$fp){
6    return(-1);
7  }
8  $SuppliedPasswordHash = md5($SuppliedPassword);
9 
10  while(($Line = fgets($fp, 100)) !== false){
11    if(preg_match("/(\d+)\|(\w+)\|(\w{32})/", $Line, $Matches)){
12      if(strlen($Matches[3]) == 32){
13        if($Matches[2] == $SuppliedUsername){
14          if($Matches[3] == $SuppliedPasswordHash){
15            fclose($fp);
16            return($Matches[1]);
17          }
18        }
19      }
20    }
21  }
22
23  fclose($fp);
24  return(-1);
25}
26
27function lookupUser($UserID){
28  $fp = fopen(userListFilename(), "r");
29  if(!$fp){
30    return(-1);
31  }
32 
33  while(($Line = fgets($fp, 100)) !== false){
34    if(preg_match("/(\d+)\|(\w+)\|(\w{32})/", $Line, $Matches)){
35      if($Matches[1] == $UserID){
36        fclose($fp);
37        return($Matches[2]);
38      }
39    }
40  }
41 
42  fclose($fp);
43  return("");
44
45}
46
47function userListFilename(){
48  return("/home/ojw/public_html/Data/Users/user_pw.txt");
49}
50?>
Note: See TracBrowser for help on using the repository browser.