new cprop

Discussion about the development of POL's official distribution scripts.

Moderators: POL Developer, Distro Developer

Locked
itallosfo
New User
Posts: 4
Joined: Thu May 26, 2016 3:09 am

new cprop

Post by itallosfo »

I have to configure all the cprop?

Im trying to add new informations to the account when is created.

i make a c# request to this link:
var request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:5002/webacct.ecl?user=" + user + "&pass="+pass+"&pass2=" + pass2 + "&email=" + email + "&uobase=" + cmd.usuario);

the request work and the account as created, but the CPROP dont be set, take a look on code below.

webacct.src

Code: Select all

/////////////////
// Web POL Account adder for use with the POL web server
//
// * place webacct.ecl and acctadd.html in the pol/scripts/www directory
// * enable the POL webserver in pol.cfg and set the port for http connections
// * set WebServerLocalOnly=1 to only allow connections from the server 
//   set it =0 to allow everyone to access the server and the account adder page
// * accounts will be available immediately if successfully added
// 
// Notes: I don't know if someone's done something that serves this function
//        but I thought I'd do it just for kicks.
//
// Author: Racalac, 2/6/00
// Updated by: Edwards 8/12/07
/////////////////

use http;
use uo;

const MIN_CHARACTERS_FOR_ACCOUNT_NAME := 4;
const MAX_CHARACTERS_FOR_ACCOUNT_NAME := 10;
const MIN_CHARACTERS_FOR_PASSWORD     := 4;
const MAX_CHARACTERS_FOR_PASSWORD     := 10;

program account_add()

        var account_name := QueryParam("user");
	var password1    := QueryParam("pass");
	var password2    := QueryParam("pass2");
	var email_adress := QueryParam("email");
	var uobase 	 := QueryParam("uobase");

        // writehtml("<html><head><title>Account Adder</title></head><body>");
        // writehtml("<FONT SIZE=4><B>Account Adder</B></FONT><HR>");

        if( TypeOf(account_name) != "String" || account_name == "" )
		WriteHtml("<fail>Error: Login inválido.</fail>");
        elseif( TypeOf(password1) != "String" || password1 == "" )
		WriteHtml("<fail>Error: Senha inválida.</fail>");
	elseif( TypeOf(password2) != "String" || password2 == "" )
		WriteHtml("<fail>Error: Senha inválida.</fail>");
	elseif( TypeOf(email_adress) != "String" || email_adress == "" )
		WriteHtml("<fail>Error: Email inválido</fail>");
	elseif( len(account_name) < MIN_CHARACTERS_FOR_ACCOUNT_NAME )
		WriteHtml("<fail>Error: Login muito curto, mínimo 4 caracteres.</fail>");
	elseif( len(account_name) > MAX_CHARACTERS_FOR_ACCOUNT_NAME )
		WriteHtml("<fail>Error: Login muito longo, máximo 10 caracteres.</fail>");
	elseif( len(password1) < MIN_CHARACTERS_FOR_PASSWORD )
		WriteHtml("<fail>Error: Senha muito curta, mínimo 4 caracteres.</fail>");
        elseif( len(password1) > MAX_CHARACTERS_FOR_PASSWORD )
		WriteHtml("<fail>Error: Senha muito longa, máximo 10 caracteres.</fail>");
	elseif( password1 != password2 )
		WriteHtml("<fail>Error: As senhas não conferem.</fail>");
	elseif( password1 == account_name )
		WriteHtml("<fail>Error: Login e senha iguais, não utilize o login como a senha.</fail>");
        else
                 var account := CreateAccount(account_name, password1, 1 );
                 if( !account )
				case( account.errortext )
					"Account already exists":
						WriteHtml("<fail>Error: Este login já está em uso.</fail>");
					default:
						WriteHtml("<fail>Error: Este login já está em uso.</fail>");
				endcase
			else
				account.setProp("Email", email_adress);
				account.setProp("UOBASE", uobase);
				WriteHtml("<success>Cadastrado com sucesso!</success>");
		endif
       endif
endprogram
I have two lines:
account.setProp("Email", email_adress);
account.setProp("UOBASE", uobase);

both define data on user account but the cprop UOBASE dont be defined.

im newbie with a dream :)
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: new cprop

Post by Nando »

What do you mean that both define data in the user account but the cprop isn't defined?
itallosfo
New User
Posts: 4
Joined: Thu May 26, 2016 3:09 am

Re: new cprop

Post by itallosfo »

the account is created but CPROP property is not set in accounts.txt

look:

Code: Select all

Account
{
	Name	login
	Password	pw
	PasswordHash	!@#!@$!@#!@$!@$!@#!@#
	PasswordOnlyHash	!@#!@$!@#!@$!@$!@#!@#
	Enabled	1
	Banned	0
	CProp	Email skasdlasd
}
Only the email prop was defined, the cprop UoBase not defined on user account.
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: new cprop

Post by Nando »

Just to remove the obvious out of the way: did you add the email and uobase cprops at the same time? if not, did you recompile the script? did you reload POL?

The account.setprop() should have created the cprop for you...
itallosfo
New User
Posts: 4
Joined: Thu May 26, 2016 3:09 am

Re: new cprop

Post by itallosfo »

oh, i compile and now works.. thx :))
So... help me on one thing..

Code: Select all

foreach acctname in ListAccounts ()
		
		//acctname 
	
	endforeach
acctname will be the account name, right?
How can i get the characters prop from acctname.. like:

Code: Select all

if (account.getProp("UoBase") == account_id)
			WriteHTML ("")
		endif
I want return all characters that have same value of CPROP "UoBase".
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: new cprop

Post by CWO »

foreach acctname in ListAccounts() returns only the account names so you need to run the acctname through FindAccount(acctname); to get the actual account itself where you can get your props.

Code: Select all

foreach acctname in ListAccounts()
     var account := FindAccount(acctname);
     if (account.getProp("UoBase") == account_id)
         WriteHTML ("")
      endif
itallosfo
New User
Posts: 4
Joined: Thu May 26, 2016 3:09 am

Re: new cprop

Post by itallosfo »

thx it works! :)
Locked