Beispiel #1
0
Bool CreateAccount(char *name,char *password,int type,int *account_id)
{
   char buf[ENCRYPT_LEN+1];
   account_node *a;

	if (GetAccountByName(name) != NULL)
		return False;

   a = (account_node *)AllocateMemory(MALLOC_ID_ACCOUNT,sizeof(account_node));
   a->account_id = next_account_id++;

   a->name = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(name)+1);
   strcpy(a->name,name);
 
   MDString(password,(unsigned char *) buf);
   buf[ENCRYPT_LEN] = 0;
   a->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(buf)+1);
   strcpy(a->password,buf);

   a->type = type;
   a->last_login_time = 0;
   a->suspend_time = 0;
   a->credits = 100*ConfigInt(CREDIT_INIT);

   InsertAccount(a);

	*account_id = a->account_id;
	return True;
}
Beispiel #2
0
int CreateAccountSecurePassword(char *name,char *password,int type)
{
   char buf[100],*ptr;
   int index;
   account_node *a;
   unsigned int ch;

   index = 0;
   ptr = password;
   while (sscanf(ptr,"%02x",&ch) == 1)
   {
      buf[index++] = ch;
      ptr += 2;
   }
   buf[index] = 0;

   a = (account_node *)AllocateMemory(MALLOC_ID_ACCOUNT,sizeof(account_node));
   a->account_id = next_account_id++;

   a->name = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(name)+1);
   strcpy(a->name,name);

   a->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(buf)+1);
   strcpy(a->password,buf);

   a->type = type;
   a->last_login_time = 0;
   a->suspend_time = 0;
   a->credits = 100*ConfigInt(CREDIT_INIT);

   InsertAccount(a);

   return a->account_id;
}
Beispiel #3
0
	void Logger::LogEvent (Logger::Event event, const ICLEntry *entry, const QString& descr)
	{
		const QString accId { entry->GetParentAccount ()->GetAccountID () };
		const auto& entryId = entry->GetEntryID ();

		const auto& maybeAccPKey = AdaptedAccount_->DoSelectOneByFields_ (sph::_0, sph::_1 == accId);
		const auto accPKey = maybeAccPKey ?
				**maybeAccPKey :
				InsertAccount (entry->GetParentAccount ());

		const auto maybeEntryPKey = AdaptedEntry_->DoSelectOneByFields_ (sph::_0, sph::_2 == entryId);
		const auto entryPKey = maybeEntryPKey ?
				**maybeEntryPKey :
				InsertEntry (accPKey, entry);

		AdaptedEvent_->DoInsert_ ({ {}, entryPKey, event, descr });
	}
Beispiel #4
0
void LoadAccount(int account_id,char *name,char *password,int type,int last_login_time,
		 int suspend_time, int credits)
{
   account_node *a;

   a = (account_node *)AllocateMemory(MALLOC_ID_ACCOUNT,sizeof(account_node));

   a->account_id = account_id;
   if (account_id >= next_account_id)
      next_account_id = account_id + 1;

   a->name = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(name)+1);
   strcpy(a->name,name);
   a->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(password)+1);
   strcpy(a->password,password);

   a->type = type;
   a->last_login_time = last_login_time;
   a->suspend_time = suspend_time;
   a->credits = credits;

   InsertAccount(a);
}