Jump to content

Client Register from Outside WHMCS


Recommended Posts

Hello,

 

I know that for the client to login from outside WHMCS I just have to use

 

<form method="post" action="/dologin.php">

 

But when it comes to register, what should I do?

 

Maybe this would work?

 

<form method="post" action="/register.php">

Link to comment
Share on other sites

Okay so, I'm halfway through.

 

I have managed to duplicated the password field into the pw verification, and also created the whole form externally to be sent via POST to register.php, with same field values of clientregister.tpl, wich also points to register.php

 

The problem is it's not working, when I submit the form I get to the clientarea login page.

 

<form id="formulario-registro" method="post" action="register.php" class="form-stacked" autocomplete="off">
  <input type="hidden" name="register" value="true" />
  <input type="hidden" name="country" id="country" value="BR" />

<!-- Name -->
<div class="campo-registro">
	<label for="firstname" class="registro">Full Name</label>
	<span class="formwrapper-registro">
		<input type="text" name="firstname" id="firstname"/><br class="naofrita">
		<label class="registro-error" for="firstname" generated="true"></label>
	</span>
</div>


  [... All the other messy inputs ... ]

<input type="submit" value="Submit">
</form>

 

PS: I've hardcoded the country as a hidden input to shorten the number of inputs and make the form shorter and less boring. Already tried using the legit way to select a country and such, without passing a hardcoded value. Same results.

Edited by lukinhasb
Link to comment
Share on other sites

Okay, I've managed to advance a lot, the only thing missing now is to generate dynamic tokens for the requests. How can I do this PLEASE??

 

<input type="hidden" name="token" id="token" value="40 CHARACTERS TOKEN" />

 

PS: Both the "external" register file and WHMCS are on the same website! WHMCS is a sub-folder, I'm doing this because I want the client to register on a modal on my website

 

PS 2:

 

So, just debugged this token stuff. It's confirmed to be the only thing stopping my script from working

 

I have pointed the original register script at whmcs to test.php, wich outputs all the vars that has been posted

 

Using the token in my script makes it work, but it only works once, after the first use it expires.

 

I want to know the dynamic code to generate this token

Thanks!

 

Something like:

 

<form id="external-register" method="post" action="/register.php">
<?php
	$autoauthkey = "************************"; # autoauthkey from configuration.php, turned them to * for security purposes
	$timestamp = time(); # Get current timestamp
	$email = "[Here it should go the e-mail entered in the form, right? I don't know how to do that. Token didn't work with static e-mail neither]"; # Clients Email Address to Login										
	$hash = sha1($email.$timestamp.$autoauthkey); # Generate Hash
?>
	<input type="hidden" name="token" id="token" value="<?php echo $hash; ?>" />
	<input type="hidden" name="register" value="true" />
	<input type="text" name="firstname" id="firstname"/>
	<input type="text" name="lastname" id="lastname"/>
	<input type="text" name="email" id="email"/>
	<input type="password" name="password" id="password"/>
	<input type="password" name="password2" id="password2"/>
	<input type="text" name="phonenumber" id="phonenumber"/>
	<input type="text" name="companyname" id="companyname"/>
	<!-- Hid unnecessary fields because of conversion rate -->
	<input type="hidden" name="address1" value="" />
	<input type="hidden" name="address2" value="" />
	<input type="hidden" name="city" value="" />
	<input type="hidden" name="state" value="" />
	<input type="hidden" name="postcode" value="" />
	<input type="hidden" name="country" id="country" value="BR" />
</form>

 

Tried generating a random string of 40 numbers similar to the token, didn't work lol

 

function makeid()
{
var text = "";
var possible = "abcdefghijklmnopqrstuvwxyz0123456789";

for( var i=0; i < 40; i++ )
	text += possible.charAt(Math.floor(Math.random() * possible.length));

return text;
}
$("#token").val(makeid);

Edited by lukinhasb
Link to comment
Share on other sites

The current token is stored in $_SESSION["tkval"]

 

What you could try to do is include the init.php file for WHMCS which will give you a valid WHMCS session and then set the $_SESSION["tkval"] to the token that you pass on the registration form.

 

I haven't tested this so I can't guarantee it will work, but it is worth a try!

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated