- #if 0
- //
- strcpy(input, Username);
- strcpy(input, Salt);
- // TODO: Get user's SHA-1 hash
- sprintf(tmp, "uid=%s", Username);
- ldap_search_s(ld, "", LDAP_SCOPE_BASE, tmp, "userPassword", 0, res);
-
- sprintf(input+ofs, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- h[ 0], h[ 1], h[ 2], h[ 3], h[ 4], h[ 5], h[ 6], h[ 7], h[ 8], h[ 9],
- h[10], h[11], h[12], h[13], h[14], h[15], h[16], h[17], h[18], h[19]
+ // Create iterator
+ if( maxBal != INT_MAX )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MAXBALANCE, maxBal, 0);
+ else if( minBal != INT_MIN )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MINBALANCE, minBal, 0);
+ else
+ it = Bank_Iterator(0, 0, sort, 0, 0);
+
+ // Get return number
+ while( (i = Bank_IteratorNext(it)) != -1 )
+ {
+ int bal = Bank_GetBalance(i);
+
+ if( bal == INT_MIN ) continue;
+
+ if( bal < minBal ) continue;
+ if( bal > maxBal ) continue;
+
+ numRet ++;
+ }
+
+ Bank_DelIterator(it);
+
+ // Send count
+ sendf(Client->Socket, "201 Users %i\n", numRet);
+
+
+ // Create iterator
+ if( maxBal != INT_MAX )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MAXBALANCE, maxBal, 0);
+ else if( minBal != INT_MIN )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MINBALANCE, minBal, 0);
+ else
+ it = Bank_Iterator(0, 0, sort, 0, 0);
+
+ while( (i = Bank_IteratorNext(it)) != -1 )
+ {
+ int bal = Bank_GetBalance(i);
+
+ if( bal == INT_MIN ) continue;
+
+ if( bal < minBal ) continue;
+ if( bal > maxBal ) continue;
+
+ _SendUserInfo(Client, i);
+ }
+
+ Bank_DelIterator(it);
+
+ sendf(Client->Socket, "200 List End\n");
+}
+
+void Server_Cmd_USERINFO(tClient *Client, char *Args)
+{
+ int uid;
+ char *user = Args;
+ char *space;
+
+ space = strchr(user, ' ');
+ if(space) *space = '\0';
+
+ // Get recipient
+ uid = Bank_GetAcctByName(user);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 Invalid user");
+ return ;
+ }
+
+ _SendUserInfo(Client, uid);
+}
+
+void _SendUserInfo(tClient *Client, int UserID)
+{
+ char *type, *disabled="", *door="";
+ int flags = Bank_GetFlags(UserID);
+
+ if( flags & USER_FLAG_INTERNAL ) {
+ type = "internal";
+ }
+ else if( flags & USER_FLAG_COKE ) {
+ if( flags & USER_FLAG_ADMIN )
+ type = "coke,admin";
+ else
+ type = "coke";
+ }
+ else if( flags & USER_FLAG_ADMIN ) {
+ type = "admin";
+ }
+ else {
+ type = "user";
+ }
+
+ if( flags & USER_FLAG_DISABLED )
+ disabled = ",disabled";
+ if( flags & USER_FLAG_DOORGROUP )
+ door = ",door";
+
+ // TODO: User flags/type
+ sendf(
+ Client->Socket, "202 User %s %i %s%s\n",
+ Bank_GetAcctName(UserID), Bank_GetBalance(UserID),
+ type, disabled