Results 1 to 9 of 9
Thread: cplogin.php
-
08-04-2005, 12:08 PM #1Web Hosting Guru
- Join Date
- Jul 2005
- Location
- Tennessee
- Posts
- 325
cplogin.php
Can anyone help me modify this so it will take a customer to their own cpanel? I REALLY appreciate it!
<?php
# domain or ip (no http://)
$domain = $_POST['domain'];
if(!$_POST['login']) exit;
$user = $_POST['user'];
$pass = $_POST['pass'];
$port = $_POST['port'];
$port == '2083' || $port == '2096' ? $pre = 'https://' : $pre = 'http://';
$port == '2095' || $port == '2096' && !eregi('@', $user) ? $user = $user.'@'.$domain : $user = $user;
?>
I really suck at php.
-
08-05-2005, 05:07 AM #2Web Hosting Master
- Join Date
- Feb 2002
- Location
- Vestal, NY
- Posts
- 1,381
Any customer can get to their own cPanel via any cPanel login when they enter their username and password. It doesn't matter if it is theirdomain.com/cpanel or someoneelse'sdomain/cpanel or yourserverhostname:2083, it will all go to the same place. Are you trying to make the script auto-login a user once they are logged in via something else (like your billing system for example)?
H4Y Technologies LLC .. Since 2001!!
"Smarter, Cheaper, Faster" - SMB, Reseller, VPS, Dedicated, Colo hosting done right.
ZERO PACKETLOSS, ZERO DOWNTIME Dedicated and Colo - USA: IA, CA, NC, OR, NV
**http://h4y.us** **http://iwfhosting.net**Voice: (866)435-5642. *** askus at host4yourself d0t com
-
08-05-2005, 05:35 AM #3Junior Guru Wannabe
- Join Date
- Feb 2003
- Posts
- 34
here it is
Refer http://forum.mamboserver.com
it works perfectly
Two PHP Script
1)docpanellogin.php
2)include_anywhere.php
Code for docpanellogin.php
<?php
error_reporting(E_ALL ^ E_NOTICE);
//Here we check if any field was missed / left empty and act accordingly
if ($_POST['domain'] && $_POST['username'] && $_POST['pass'] && !($_GET['failed'] == "1"))
{
switch ($_POST['login_option'])
{
case "2082": $port = "2082";
$protocol = "http://";
break;
case "2083": $port = "2083";
$protocol = "https://";
break;
case "2086": $port = "2086";
$protocol = "http://";
break;
case "2087": $port = "2087";
$protocol = "https://";
break;
case "2095": $port = "2095";
$protocol = "http://";
break;
case "2096": $port = "2096";
$protocol = "https://";
break;
}
$redirectlocation = $protocol.$_POST['domain'].":".$port."/login/?user=".$_POST['username']."&pass=".$_POST['pass']."&failurl=".$_POST['failurl'];
header ("Location: ".$redirectlocation);
}
else
{
$error = 1;
header ("Location: ".$_POST['failurl']);
}
?>
code for include_anywhere.php
<?php
$postlocation = "docpanellogin.php";
print "<form action=\"" . $postlocation . "\" method=\"POST\">";
if (($_GET['failed'] == "1") or ($error == 1))
{
?>
<font color=#FF0000 face=verdana size=1>Your login attempt failed!</font><br>
<?php
}
?>
<font face="Verdana" size="1">Domain:</font>
<input name="domain" class="input2" type="text" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" /><br>
<font face="Verdana" size="1">Username:</font>
<input name="username" class="input2" type="text" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" /><br>
<font face="Verdana" size="1">Password:</font>
<input name="pass" class="input2" type="password" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" />
<?php
print "<input type=hidden name=failurl value=\"http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";
?>
<br>
<font face="Verdana" size="1">Options:</font>
<select name="login_option" style="font-family: Verdana; font-size: 8pt;width:110;height:18">
<option value="2082">cPanel </option>
<option value="2083">Secure cPanel </option>
<option value="2086">WHM</option>
<option value="2087">Secure WHM</option>
<option value="2095">Webmail</option>
<option value="2096">Secure Webmail</option>
</select>
<br>
<input class="input2" type="submit" value=" Click to Login " style="width:100;height:20;font-family:Verdana; font-size:8pt" onmouseout="blur(this);" />
</form>
-
08-05-2005, 07:13 AM #4Web Hosting Guru
- Join Date
- Jul 2005
- Location
- Tennessee
- Posts
- 325
Yes, this is the one I FINALLY wound using and it works like a charm. My question is is how can I incorporate this in an html page? I had to save it as a separate php page in order for it to work.
-
08-05-2005, 07:52 AM #5Junior Guru Wannabe
- Join Date
- Feb 2003
- Posts
- 34
you have two files
1)include_anywhere.php
2)docpanellogin.php
you shud be having a html or php page through which your clients are currently logging right
so remove all the existing cpanel login code. Replace that page with this code in include_anywhere.php
and the docpanellogin.php.. upload it in the same directory or different one. modify your form action if it is in a different directory
thats it it is ready to go.
you can take look at this site
http://www.ec-webhosting.jp/login.php
if you prefer java script i can give you the code for that too.
only problem.. error messages !!!Last edited by ranjith; 08-05-2005 at 07:55 AM.
-
08-05-2005, 08:02 AM #6Web Hosting Guru
- Join Date
- Jul 2005
- Location
- Tennessee
- Posts
- 325
I want something I can put on my homepage, which is html. I haven't been able to get the include_anywhere code to work in a regular html page, but can get it to work like a charm on a page like login.php. I am wanting to incorporate it into my index.html page. I would really rather stay away from javascript. Any ideas?
-
08-05-2005, 08:14 AM #7Junior Guru Wannabe
- Join Date
- Feb 2003
- Posts
- 34
change it from index.html to index.php and add the code there
you can get this done with out disturbing your html code
-
08-05-2005, 08:31 AM #8Web Hosting Guru
- Join Date
- Jul 2005
- Location
- Tennessee
- Posts
- 325
Ok, thanks tons. I haven't dealt with php much, so I am venturing into unchartered territory. Thanks
-
09-07-2005, 01:35 AM #9Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 1,042
Is it possible to log into a specific page of cpanel? Like if i wanted a user to login directly to his awstats. I know if you just type in the url for awstats, the login comes up, and you sign in, then thats what you will see. But i dont see a way to modify this script to do that.