external login and check for login status

jechilt

Verified User
Joined
Jun 21, 2004
Messages
212
not sure where to start but want to be able to provide a link inside our billing software to allow user to LOG IN to the DA panel. have not been able to find any examples of that. also, from the same billing software, we want to have a link to allow the user to change an email account password.
how hard is it to have a check to see if they are already logged into DA. if so, just pass to the change password link. if not, prompt for password before proceeding to password change page (api script i have seen in the forum).

any help would be super!

thanks!
 
is there a better way to do an external login to the control panel than this?
The variables are being pulled from the billing system...
Code:
<? if (!isset($_SERVER["USER"]) {
echo
"<form action=http://www.$domain:2222/CMD_LOGIN method=post name=login>
<input type=hidden name=LOGOUT_URL value=$base>
<input name=username type=hidden value=$username>
<input name=password type=hidden value=$pass>
<a href=\"javascript:void(document.login.submit())\">[url]http://www.[/url]$domain/config</a>" }
 
unfortunately, I am a bit over my head on this...

What I am hoping for is to provide a link to the DA Control Panel. when the user clicks on the link, it will check to see if they are already authenticated. If so, it will pass them directly to the DA control panel. If not, then it will load the form page to login.
Also, when the user clicks to login, it forces a new window. How to get this to open in the same window?

My guess is I need something like this-

<<blah>> psuedo code cause not sure what to put

menu link:
Code:
<? if (!isset($_SERVER["USER"]) {
echo
"<form action=http://www.$domain:2222/CMD_LOGIN method=post name=login>
<input type=hidden name=LOGOUT_URL value=$base>
<input name=username type=hidden value=$username>
<input name=password type=hidden value=$pass>
<a href=\"java script:void(document.login.submit())\">[url]http://www.[/url]$domain/config</a>" }
else
{ <<echo - open the control panel>>; }
?>
 
jechilt said:
Code:
<? if (!isset($_SERVER["USER"]) {
echo
"<form action=http://www.$domain:2222/CMD_LOGIN method=post name=login>
<input type=hidden name=LOGOUT_URL value=$base>
<input name=username type=hidden value=$username>
<input name=password type=hidden value=$pass>
<a href=\"java script:void(document.login.submit())\">[url]http://www.[/url]$domain/config</a>" 
[B]die()[/B]
}

[B] Header ("Location: [url]http://domain:2222/[/url]") ; [/B]
?>

When you use the above file as checking page, and put a DIE in it. Put a Header (Location: ...) to fully redirect him to the CP.

It should work in the following way:

User get's to this page and if he isn't logged in get the login form else he is redirected to the CP.

This is what you want ? you could even just use only:

Code:
<?

Header ("Location: [url]http://domain:2222/[/url]") ;

?>

As DA will check if he's logged in and present him with the default login page, but if you want to use you're own, you can use the first code of yours ;)
 
whew..... :)

I think the Locate is going to work great! Thanks...

got another question, probably just as simple...
I have multiple domains and IP addresses. I want to be able to have a generic change email password box on the main email page.

do you think this would work (i know the text is missing, I am looking for the form input being correct):

Code:
"<form action=http://www.mydomain:2222/CMD_CHANGE_EMAIL_PASSWORD method=post>
<input type=hidden name=redirect value=$base>
<input type=text name=email size=32>
<input type=password name=oldpassword size=32>
<input type=password name=password1 size=32>
<input type=password name=password2 size=32>
<input type=submit value="Change Password">

my thinking is the <<mydomain>> needs to be the user actual domain? if so, can we parse the email address and pass the domain url to a value for mydomain?
 
For this you can better use the DA API class and the DA API documentation.

I don't really know how this works. You can offcourse just look in the DA API documentation (http://www.directadmin.com/api.html)wich variables need to be posted to the CMD_PASSWORD_CHANGE :) without using the class :P

From the API docs:

http://www.directadmin.com/api.html#email

http://domain:2222/CMD_CHANGE_EMAIL_PASSWORD?email=..&oldpassword=..&password1=..&password2=..&redirect=http://...sucessfull.html

:)

Good luck ;)
 
Back
Top