Jump to content

Cpanel Login on ClientArea Home


robbo

Recommended Posts

updated version, added DotNetPanel, also edited the query to pull back the panel's url.

 

The panels URL is stored in configoption8 in the table tblproducts for DotNetPanel. I'm not sure if it's the same for all, so I only changed it for DotNetPanel. Maybe others can contribute to it and find out what it is for the other panels and update.

 

Also, I had to use {include_php file="cp.php"} and save the cp.php in the root of the web app. {include file="cp.php"} doesn't recognize the <?php, it only supports smarty code.

 

I added {include_php file="cp.php"} to the templates\portal\clientareahome.tpl file, above the line

<p><strong>{$LANG.invoicesdue}</strong></p>

 

<?php
       $query_string = "select s.name, s.type, h.packageid, h.domain, h.username, h.password, p.configoption8 from tblhosting h, tblservers s, tblproducts p where h.packageid = p.id AND h.server = s.id and h.userid = ".$_SESSION['uid']." and h.domainstatus = 'Active' order by h.domain";
       $query = mysql_query($query_string);
       if (mysql_num_rows($query)) {
?>


<p><strong>Control Panel Links</strong></p>

<table align="center" style="width:90%" class="clientareatable" cellspacing="1">
<tr class="clientareatableheading">
       <td>Domain</td>
       <td>Link</td>
</tr>

<?php
while ($row = mysql_fetch_assoc($query)) 
{	
       switch ($row["type"]) 
{
               case "dotnetpanel": 
                       echo '<tr class="clientareatableactive">';
                       echo '<td>'.$row["domain"].'</td>';
                       echo '<td><a target="_blank" href="'.$row['configoption8'].'/Default.aspx?pid=Login&user='.$row['username'].'&password='.decrypt($row['password']).'">Manage</a>';
                       echo '</td>';
                       echo '</tr>';
                       break;
               case "cpanel": 
                       echo '<tr class="clientareatableactive">';
                       echo '<td>'.$row["domain"].'</td>';
                       echo '<td><a target="_blank" href="https://'.$row['name'].'/login?user='.$row['username'].'&pass='.decrypt($row['password']).'">Manage</a>';
                       echo '</td>';
                       echo '</tr>';
                       break;
               case "helm":
                       echo '<tr class="clientareatableactive">';
                       echo '<td>'.$row["domain"].'</td>';
                       echo '<td>><a target="_blank" href="https://'.$row['name'].'/default.asp?txtUsername='.$row['username'].'&txtPassword='.decrypt($row['password']).'&&selLanguageCode=EN&selInterface=standard_XP">Manage</a></td>';
                       echo '</tr>';
       }
}
?>

</table>

<?php } ?>

Link to comment
Share on other sites

  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

I'm just reading around and found this mod but I'm confused about its purpose/need as there is already a login to control panel feature as well as a login to webmail feature built into the whmcs script in the client area under the product details of the individual products that appears to work great. Or am I missing something here?

Link to comment
Share on other sites

  • 2 months later...

After installing 3.7.1 my login scripts based on the code in this thread is broken. It appears that

decrypt($row['password'])
is no longer correctly generating the password. Is there a fix for this? This is a pretty urgent issue for me.

 

Thanks for any help.

Link to comment
Share on other sites

Ok, I see that the algorithm has changed and I need to use the API. However, I'm not getting any results out. I'm still a PHP newbie so maybe someone can see a flaw with my code... I modified the example in the documentation to make my call.

 

$url = "http://www.mydomain.com/whmcs/includes/api.php"; # URL to WHMCS API file
$username = "my_top_admin_user"; # Admin username goes here
$password = "the_password"; # Admin password goes here


//sql query and start of for loop omittted

	 //decrypt cpanel password
	$postfields["action"] = "decryptpassword";
	$postfields["password2"] = $row["cpass"];  //verified that data is there


	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 100);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
	$data2 = curl_exec($ch);
	curl_close($ch);

	$data2 = explode(";",$data2);
	foreach ($data2 AS $temp) {
	  $temp = explode("=",$temp);
	  $results2[$temp[0]] = $temp[1];
	}


//creating an array here
//none of these variables have data
//$data2["password"];
//$results2["password"];
//$data2[0];
//$results2[0];
//$data2[1];
//$results2[1];

 

What am I missing here? No errors. But not sure how to extract results from the call properly and not sure how to tell the call is working at all. My assumption is that I'm failing on the syntax somewhere.

 

Thanks

Link to comment
Share on other sites

Just a note that even after discovering I need to add:

 

$postfields["username"] = $username;
$postfields["password"] = md5($password);

 

I'm still getting nada back for $results2.['password']

 

fyi, I also have an api call using $results.['password'] in my loop thus the #results2... but that one is coming back blank as well.

Link to comment
Share on other sites

Syntax to access the variables stored into "$results2" would be "$results2['password']" or whatever you're trying to access.

Notice the lack of "." inbetween.

 

There's nothing within the code that is different from my implementations other than i have a lower timeout value of 10 instead of 100. But that shouldn't make a difference.

Link to comment
Share on other sites

Oh... yeah I have $results2['password'] in my code... just made that mistake in my post. But still, no errors returning from call... yet no password coming back. If it looks like a valid call to others... I guess I'll put in a support ticket on it.

 

Dump question then, have you made an API call before at all? If you haven't then double check your permissions on api.php.. i think it's supposed to be 755.

Edited by nielsenj
fix for my horrible spelling
Link to comment
Share on other sites

Well... no I actually haven't come to think of it. I use WHM's api and one for my site builder but hadn't needed to use WHMCS's before. I put the api.php to 755 but still no dice. Is there anyway to be sure I'm getting communication here? Like intentionally invoking an error or something? Thanks for helping out.

Link to comment
Share on other sites

Well error handling is always returned by the api in $results['result'] in any case any communication coming back from the API should have that filled so try echo'ing it.

 

If you like, you can pm me your current code and i can give it a shot on mine as i know it's working.

 

Regards,

J

Link to comment
Share on other sites

We just did a very simple template change. No extra files required.

 

In clientareaproductdetails.tpl, find

<td width="50%" align="center">{$serverclientarea}</td>

and replace it with

<td width="50%" align="center">
   <input class="button" type="button" onclick="window.open('https://{$server.name}:2083/login?user={$username}&pass={$password}')" value="Login to cPanel"/>
   <input class="button" type="button" onclick="window.open('https://{$server.name}:2096/login?user={$username}&pass={$password}')" value="Login to Webmail"/>
</td>

 

The only drawback is that there is no WHM login button (but this was not an issue for us because we haven't yet gone down the reseller route)

 

Great post! I made a few adjustments that may help any resellers out there that don't have a full dedicated server with SSL cert covering all user logins.

 

If you are on a reseller account, your host should be able provide you with the overall domain login that is covered with an SSL already. This means your site is reachable by yourdomain.com/cpanel or youripaddress.com/cpanel or the one that's covered by an SSL which would be something.something.com/cpanel.

 

Replace this in the above quoted code:

<input class="button" type="button" onclick="window.open('https://{$server.name}:2083/login?user={$username}&pass={$password}')" value="Login to cPanel"/>

With this:

<input class="button" type="button" onclick="window.open('https://something.something.com:2083/login?user={$username}&pass={$password}')" value="Login to cPanel"/>

 

Next, if you're following the cool trend of using Google Apps to set up email for your clients, this won't send their username and password over, but it can bring up their secure email login page for their Google Apps email account.

 

Replace this in the above quoted code:

<input class="button" type="button" onclick="window.open('https://{$server.name}:2096/login?user={$username}&pass={$password}')" value="Login to Webmail"/>

With this:

<input class="button" type="button" onclick="window.open('https://mail.google.com/a/{$domain}')" value="Login to Email"/>

 

Please critique as I am not a pro.

Link to comment
Share on other sites

I wrote my own cPanel/WebMail login a while ago when I changed my clientareahome page.

When a user clicks the cPanel button it automatically logs them into cPanel. When they log out of cPanel they are redirected back to there clientarea home page.

Webmail is a little different as cPanel still has a few bugs with the redirection of the logout link. (has been fixed in the EDGE release but I will wait until it gets to RELEASE)

I might add the WHM buttons when I get a chance for when I start to have reseller packages available.

 

Here is a pic of my clientarea home page

clientareahome.jpg

Link to comment
Share on other sites

Can you share this clientareahome?

 

I wrote my own cPanel/WebMail login a while ago when I changed my clientareahome page.

When a user clicks the cPanel button it automatically logs them into cPanel. When they log out of cPanel they are redirected back to there clientarea home page.

Webmail is a little different as cPanel still has a few bugs with the redirection of the logout link. (has been fixed in the EDGE release but I will wait until it gets to RELEASE)

I might add the WHM buttons when I get a chance for when I start to have reseller packages available.

 

Here is a pic of my clientarea home page

clientareahome.jpg

Link to comment
Share on other sites

  • 2 weeks later...

People,

 

I have used this 'Cpanel Login on ClientArea Home' hack successfully for very long time with 3.6.0.

 

Now I want to upgrade to 3.7.x. So I'm wondering:

 

Will this 'Cpanel Login on ClientArea Home' work well with WHMCS version 3.7.x?

 

I will appriciate any answer.

 

Regards.

Link to comment
Share on other sites

People,

 

I have used this 'Cpanel Login on ClientArea Home' hack successfully for very long time with 3.6.0.

 

Now I want to upgrade to 3.7.x. So I'm wondering:

 

Will this 'Cpanel Login on ClientArea Home' work well with WHMCS version 3.7.x?

 

I will appriciate any answer.

 

Regards.

Link to comment
Share on other sites

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