Jump to content

cPanel and WHM Login Script


HazMat Hosting

Recommended Posts

Heres the script i have right now:

<?php#Login Configuration#cPanel$protocol = 'http';$port = 2082;#Secure cPanel#$protocol = 'https';#$port = 2083;#WHM#$protocol = 'http';#$port = 2086;#Secure WHM#$protocol = 'https';#$port = 2087;#Webmail#$protocol = 'http';#$port = 2095;#Secure Webmail#$protocol = 'https';#$port = 2096;?><html><?phpif ($_GET['failed'] == "1") {?><font color='#FF0000'>Your login attempt failed!</font><?php}print "<form action=\"" . $protocol . "://" . $_SERVER['HTTP_HOST'] . ":" . $port . "/login/\" method=POST>";?><font color='#D0D0D0'>User:</font><br> <input type=text name=user><p><font color='#DODODO'>Pass:</font><br> <input type=password name=pass><p><?phpprint "<input type=hidden name=failurl value=\"http://" .  $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";?><input type="submit" value="cPanel Login" target="_blank"></html>

As you probably noticed this script can be used for more that cpanel.I would like to use it for webmail AND cPanel at the SAME time.I want it to have 2 login buttons so i can click cPanel or Webmail, but only 1 spot for username and password.Thanks in advance to anyone that helps me,HMH

Link to comment
Share on other sites

If you want to use PHP to do this, you'll have to use a library like cURL to send a post request to the appropriate login page. It would be easier to just have Javascript change the form action based on whatever you select. So you could have a group of radio buttons or a select menu where the user chooses which system to log in to, and some Javascript code could just update the form action to point to the correct place. It looks like cPanel or WHM always look for a field called "user" and one called "pass", so you need fields called "user" and "pass" also. The login script is always in the /login/ directory. You could have an id on the form and have a series of radio buttons or a select menu to update the action.<form id="login_form" method="post" action=""><input type="radio" onclick="document.getElementById('login_form').action = 'https://domain.com:2083/login/';"> cPanel

Link to comment
Share on other sites

well the problem comes wen people have javascript disabledisnt there a way to set $cPanel = then the login button for cpanel and then set $webmail = the login button for webmailthen:

if ($cpanel) {   #cPanel   $protocol = 'http';    $port = 2082; }elseif ($webmail) {  #Webmail  $protocol = 'http';  $port = 2095; }else ($_GET['failed'] == "1") {   <font color='#FF0000'>Your login attempt failed!</font> }

Sorry for my BAD php i am still learning. I hope its good enough to understand it.

Link to comment
Share on other sites

Well yeah, you can have PHP determine which button you clicked on and execute some code. The problem is the code you need to execute. This isn't going to do anything:

  $protocol = 'http';  $port = 2095;

You would need to use the cURL library to send a post request to the appropriate page with the same username and password that they just typed in. There is also a way to send a post request without cURL, you can read about that here:http://netevil.org/blog/2006/nov/http-post...hp-without-curlThe body of the request (the data) would need to be something like this:

$data = "user=" . urlencode($_POST['user']) . "&pass=" . urlencode($_POST['pass']);

Link to comment
Share on other sites

Don't worry :) 98% of web users have JavaScript, and for the rest you could always just provide a <noscript> option with a second form...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...