Web Hosting Talk







View Full Version : CPanel login Script


Synwave
08-15-2002, 02:06 PM
Hello,

Does anyone know of a good script so users can log into their Control Panel by entering their username and password from my site?


Thanks!

appletreats
08-15-2002, 02:47 PM
<?
header("Location: http://$un:$pw@domainoriporsomething:2082");
exit();
?>

save that as something.php and have a form submit to it.
username = un
password = pw

works only if your customers are all on the same server. might not be the least complex solution even if they are.

Synwave
08-15-2002, 03:06 PM
Thanks for that!

Im not too good with PHP. Is there and easier way?

appletreats
08-15-2002, 03:15 PM
Originally posted by Eurofficial
Thanks for that!

Im not too good with PHP. Is there and easier way?

Probably something with javascript of equal complexity. But I don't know javascript.

eddie
08-15-2002, 03:30 PM
how would you use that if you have more than 1 server?

wmac
08-15-2002, 04:07 PM
Just add a combo box which sets the server name.

You can write both a php and jscript for that.

Mac

Haze
08-16-2002, 03:34 AM
Im not programmer myself, but I managed to put this together. Hope it helps :)

for the login page, here is what I did:


cPanel Login page

Select your server:<form action="cplogin.php" method="post">
<select name="server">
<option value="server1.domain.com"> server1
<option value="server2.domain.com"> server2
</select>
<br>
Username: <input type="text" Name="un" Size="8"><br>
Password: <input type="password" Name="pw" Size="8"><br>

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


Now you need to create a page that is called in the <form action=cplogin.php ... I called it cplogin for my example.

In this paste the following:


<?
if ($server=="server1.domain.com"){
$link = "http://$un:$pw@$server:2082";
echo "<script>window.setTimeout('changeurl();',100); function changeurl(){window.location='$link'}</script>";
} elseif ($server=="server2.domain.com"){
$link = "http://$un:$pw@$server:2082";
echo "<script>window.setTimeout('changeurl();',100); function changeurl(){window.location='$link'}</script>";
}
?>


Again, I just threw this together, it worked for me, if anyone finds any problem, let me know :)

/me pats himself on the back.

Steve-PWH
08-17-2002, 07:44 AM
Here is a complete JS based login script

No point in using PHP or PERL when JS can do it :)

You can change how it looks in the Cascade Style Sheet.

-----------------------------------------------------------------------


<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> CP Login </title>

<style type="text/css">

.left_table { width: 150; }
.right_table { width: 150; }
.input_field { width: 150; border: 1px solid black; }
.login_but { width: 300; border: 1px solid black; }
.main_table { width: 300; border: 0; }

</style>

<script type="text/javascript">

/*
+----------------------------------------------------------------------------+
| Cpanel Login |
| By Steve Miles aka Steve-PWH / SmileyMan |
| Copyright Proxima Web-Hosting 2002 All Rights Resevred |
| Free for use as long as header stays in place |
+----------------------------------------------------------------------------+
*/

function cp_go( the_form ) {

if ( !the_form.username.value || !the_form.password.value ) { return; }

location = 'http://'+the_form.username.value+':'+the_form.password.value+'@'+the_form.server[the_form.server.selectedIndex].value+':2082/';

}

</script>

</head>

<body>

<form name="cplogin">

<table class="main_table" cellspacing="0" cellpadding="0">
<tr>
<td class="left_table">
Select your server:
</td>
<td class="right_table">
<select name="server" class="input_field">
<option value="server1.doamin.com"> Server1 </option>
<option value="server2.domain.com"> server2 </option>
</select>
</td>
</tr>
<tr>
<td class="left_table">
Username:
</td>
<td>
<input type="text" class="input_field" name="username">
</td>
</tr>
<tr>
<td class="left_table">
Password:
</td>
<td>
<input type="password" class="input_field" name="password">
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" class="login_but" Value="Login" onclick="cp_go(this.form)">
</td>
</tr>
</table>
</form>

</body>
</html>

Steve-PWH
08-17-2002, 08:08 AM
"<script>window.setTimeout('changeurl();',100); function changeurl(){window.location='$link'}</script>";

U use PHP manager dont u :)

Rochen
08-17-2002, 03:50 PM
Originally posted by Steve-PWH
No point in using PHP or PERL when JS can do it
Actually, PHP, Perl etc. are probably the better solution, due to the fact if someone has JS disabled, it wont work.

smidwap
08-17-2002, 04:12 PM
I always use PHP and Perl over JavaScript simply because they are server-side while JS is client-side.

Steve-PWH
08-17-2002, 05:01 PM
Originally posted by rochen

Actually, PHP, Perl etc. are probably the better solution, due to the fact if someone has JS disabled, it wont work.

Good point but why somone would now adays is questionable

Steve-PWH
08-17-2002, 05:04 PM
Originally posted by smidwap
I always use PHP and Perl over JavaScript simply because they are server-side while JS is client-side.

And? -> Dont get ur point

JS and PHP/PERL etc. have there own abilitys -> A lot of things JS can do PHP can not and the other way round your statment makes no sense.

P.S. U can get Server-Side JS :)

smidwap
08-17-2002, 05:14 PM
My point is I wouldn't rely on your viewer having JavaScript 2.8.34.55.333 installed. ;) Of course, must of OUR viewers (people interested in web hosting) have decent computers/browsers.

chrisb
08-18-2002, 12:40 AM
Yes, I agree that server side is better. Another reason not to use Javascript unless there is no other way is that besides JScript, there are many other flavors of Javascript that don't work well on all browsers.

Steve-PWH
08-18-2002, 05:09 PM
Do any of u know what u are on about?

All current browsers support JS 1.2 (1.3 soon)

There is not LOADS of different JS

What u getting mixed up about is DOM (Document Object Model)

DOM is part of the browser it is not JS (JS just munipulates it)

IE based and Gecko Based browsers have slightly different DOM hance the problems but if your JS is not munipulating the DOM then no problems JS is a STANDARD language

I for one test my JS in NS, MOS, OPERA and IE thank u

/gets of high seat

chrisb
08-18-2002, 05:37 PM
Originally posted by Steve-PWH
Do any of u know what u are on about?

All current browsers support JS 1.2 (1.3 soon)

There is not LOADS of different JS

What u getting mixed up about is DOM (Document Object Model)

DOM is part of the browser it is not JS (JS just munipulates it)

IE based and Gecko Based browsers have slightly different DOM hance the problems but if your JS is not munipulating the DOM then no problems JS is a STANDARD language

I for one test my JS in NS, MOS, OPERA and IE thank u

/gets of high seat

LOL. Well, I hate to knock you off of that high chair, but... <slap><crash> :)

Seriously, I was not talking about the different DOMs between IE and Mozilla. Checking your javascript in all of those browsers is to be commended and 99% more than most people do.

However, browsers are not strictly Mozilla, IE or Opera. For example, AOL uses a modfied IE, and there are others that use modified browsers or combinations thereof. Additionally, many do not follow the ECMA standard.

See http://developer.netscape.com/docs/manuals/javascript.html

IOW, because you cannot count on browser compatibility, server-side is usually best.

Steve-PWH
08-18-2002, 06:17 PM
Wrong end of stick m8t


Example using server-side PERL

A script that works on a *nix server more offen then not will fall over on a win server

Not PERL's fault but the platform

Same with JS -> JS as standard constructs and syntax but fails when used on different platforms somtimes not cos of JS but cos of the platform :(

I use both client and server side and decide on the requirment what does it best.

I like js (Consid myself quite advanced)
I love PERL (Consid very advanced OOP PERL coder)
I learning PHP (FAST) and quite like it but yern for the shortcuts and all the different ways you can do everything in PERL :)

Thankfully all three have simular constructs and syntax (After learning PERL to a advanced level PHP and JS seam easy :) )

Still get mixed up with the elsif, elseif, else if - when using all three around the same times as well as putting [] in
PERL for a hash LOL

My pet hate with both PHP and JS is how sloppy they let poeple code :( -> Some MESSY code i have seen -> PERL would slap u down hard if you tried that on with it :)

TimPD
08-18-2002, 06:18 PM
The script is pretty easy to get and I believe is a nice way of letting clients login to there control panel from your website. Which is a good way...

chrisb
08-18-2002, 11:15 PM
Originally posted by Steve-PWH
A script that works on a *nix server more offen then not will fall over on a win server


Huh? If the script works on a server using perl why would you want it to work on a windows server, or vice versa? You only run it from one server whether it be windows or *nix. IOW, if the script is interpreted at the server level, whether it's 5.005 Perl on a Linux box or Indigo Perl on a Windows2000 box, it still works on that server.

Let me try to make this clearer to you. You write ONE script to fit your platform, and many more browsers will be able to view it correctly rather than writing one script to fit several browsers.

I like Perl because it is server-side, and am fairly adept at it. I'm a bit less adept at JS; but I have written alot of it. I'm not too familiar with server-side JS, but the reason I loathe client-side JS is because of it's incompatibility.

Steve-PWH
08-19-2002, 08:54 AM
HUH

Think u will find I know THAT ffs

I am no NOOBIE -> Been involed in many LARGE projects FFS

I was tying to say that both client-side and server-side languages have cross platform incompatiablitys - JESUS

U pick your language based on the PROJECT.

Need a bit of form validation then JS is the tool (Form DOM is standard)

Need a script to read/write a SQL db then JS is not ur tool (Well u could try and get it to work if u what to spend hours on somthing that can not be done as JS can not read files / DB's lol)

chrisb
08-19-2002, 11:54 PM
Server-side languages are ALWAYS more browser-compatible than client-side languages. Yes, you pick your language depending on the application, but most applications can be done in more than one language. When given a choice, it's usually better to use a server-side language such as perl.

Website Rob
08-20-2002, 03:46 AM
Server-side languages are ALWAYS more browser-compatible than client-side languages.That is so true. I love how some people create a JS script in IE, get it working and figure that's all there is. JS can always be turned off, there are 4 versions of JS that I know of, there is also the Accessabiltiy issue (most people don't even know there is a <noscript> tag). :D

JS should be used for the simplest of means and if any validation is required, it should always be backed up with a server-side script. In fact there is another thread (similar title to this one) where someone wanted and was given, a JS script for WHM/Cpanel access from a Web page.

Such a big security hole that shouldn't even be there IMHO. After pointing out the security flaw and how .htaccess is still the best route, some people still dont' get it. They probably will though, but they won't like how.

oze
08-20-2002, 04:00 AM
Originally posted by Steve-PWH
HUH

Think u will find I know THAT ffs

I am no NOOBIE -> Been involed in many LARGE projects FFS

I was tying to say that both client-side and server-side languages have cross platform incompatiablitys - JESUS

U pick your language based on the PROJECT.

Need a bit of form validation then JS is the tool (Form DOM is standard)

Need a script to read/write a SQL db then JS is not ur tool (Well u could try and get it to work if u what to spend hours on somthing that can not be done as JS can not read files / DB's lol)

Do you talk to your customers like that?

Good attitude!

Calm down some, take some deep breaths and think about being rational and non-confrontational when posting. Short tempers can worry people when looking for a host. I know I wouldn't want a host who would potentially bite my head off if I need tech support.

chrisb
08-20-2002, 04:15 AM
Originally posted by Website Rob
That is so true. I love how some people create a JS script in IE, get it working and figure that's all there is. JS can always be turned off, there are 4 versions of JS that I know of, there is also the Accessabiltiy issue (most people don't even know there is a <noscript> tag). :D

JS should be used for the simplest of means and if any validation is required, it should always be backed up with a server-side script. In fact there is another thread (similar title to this one) where someone wanted and was given, a JS script for WHM/Cpanel access from a Web page.

Such a big security hole that shouldn't even be there IMHO. After pointing out the security flaw and how .htaccess is still the best route, some people still dont' get it. They probably will though, but they won't like how.

Yep, it really baffles me when people use Javascript for something like a login that needs to be secure.

Steve-PWH
08-20-2002, 08:22 AM
Security -> Right here we go..

The most secure login is when you are the only person that ever uses the computer thats used for logins (Like myself -> Famiily use the other commy not mine ever)

If anyone else as access to the commy u login with u have a security problem :(

Yes if multiple people use the commy or its a public commy you have a security issue so dont use it in that situation

Also even is server-side is use for this system the security problem is the same ( Its not JS making it insecure )

One of the biggist security issues without a doupt is the little yellow bit of sticky paper called a postit :)