using System;
using System.Text;
using System.Collections.Generic;
using Woodpecker.Data;
using Woodpecker.Strings;
namespace Woodpecker.Core
{
///
/// Provides alot of functions which do things. doh.
///
public static class Access
{
#region Username checks, passwords etc
///
/// Returns a boolean that indicates if a user with a certain username exists in the 'users' table of the database.
///
/// The username to check.
public static bool userExists(string Username)
{
return Database.checkExists("users", "username", Username);
}
///
/// Returns the ID of the error at a name check of a username/new pet. If no errors, then 0 is returned.
///
/// Specifies if this namecheck is for a pet purchase.
/// The name to check.
public static int getNameCheckError(bool Pet, string Name)
{
if (Name.Length > 15)
return 2;
else
{
if (Pet == false && userExists(Name))
return 4; // Username already taken
else
return 0; // OK
}
}
///
/// Returns a boolean that indicates if a string is valid as a password for a user. The string shouldn't be the same as the username, it should be 6-9 characters long and it should contain at least one number.
///
/// The username for this password.
/// The password to check.
public static bool passwordOK(string Username, string Password)
{
return (Username != Password && (Password.Length > 5 && Password.Length < 10) && stringManager.hasNumbers(Password));
}
///
/// Returns a boolean that indicates if an email address is valid.
///
/// The email address to check.
public static bool emailOK(string Email)
{
try
{
// mike.fails@script-o-matic.net :]
string[] Parts = Email.Split('@');
return (Parts.Length == 2 && Parts[1].Contains("."));
}
catch { return false; }
}
#endregion
#region FUSE rights
#region Declares
///
/// Contains the accessRank objects.
///
private static Dictionary