Jump to content

Shaw Password Option in Product Details Page


Hardik Joshi

Recommended Posts

Hello Community,

I starts Hosting company a year ago and it's really awesome experience but there are few needs in WHMCS, 

can we add an option in WHMCS products and services details page, Shaw cPanel Password

I already added few things like Nameservers, IP and Hostname just need to add one option and it's Shaw you cPanel Password

 

1411381121_Screenshot2021-01-05at11_56_07PM.thumb.png.ec436960c9b925edce2738aec1f9d2ad.png

Link to comment
Share on other sites

20 hours ago, Hardik Joshi said:

I already added few things like Nameservers, IP and Hostname just need to add one option and it's Shaw you cPanel Password

if you wanted the decrypted cPanel service password value available to the template, you could use the hook below...

<?php

# cPanel Service Password Hook
# Written by brian!

function product_details_cpanel_password_hook($vars) {
	
	$service = Menu::context('service');    
	$servertype = $service->product->servertype;
	if ($servertype == 'cpanel') {
		$password = $service->password;
		$command = 'DecryptPassword';
		$postData = array('password2' => $password,);
		$results = localAPI($command, $postData);
		$realpassword = $results['password'];
		return array ("realpassword" => $realpassword);
	}
}
add_hook("ClientAreaPageProductDetails", 1, "product_details_cpanel_password_hook");

that would then allow you to use {$realpassword} in the template to show the password value.

Link to comment
Share on other sites

24 minutes ago, brian! said:

if you wanted the decrypted cPanel service password value available to the template, you could use the hook below...


<?php

# cPanel Service Password Hook
# Written by brian!

function product_details_cpanel_password_hook($vars) {
	
	$service = Menu::context('service');    
	$servertype = $service->product->servertype;
	if ($servertype == 'cpanel') {
		$password = $service->password;
		$command = 'DecryptPassword';
		$postData = array('password2' => $password,);
		$results = localAPI($command, $postData);
		$realpassword = $results['password'];
		return array ("realpassword" => $realpassword);
	}
}
add_hook("ClientAreaPageProductDetails", 1, "product_details_cpanel_password_hook");

that would then allow you to use {$realpassword} in the template to show the password value.

Thanks @brian!,

i tried with this but it's not working, may be am doing something wrong can you please check once, below code. it's not sawing any error, there are no output i mean not sawing password .

<div class="cpanel-package-details">
                    <em>{$groupname}</em>
                    <h4 style="margin:0;">{$product}</h4>
                    <a href="http://{$domain}" target="_blank">www.{$domain}</a>
                    <h3>cPanel Password: <input type="password" value="{$realpassword}" id="myInput"></h3>
                    <br>
                    <input type="checkbox" onclick="myFunction()"> Show Password
                </div>
                <script>
                function myFunction() {
                  var x = document.getElementById("myInput");
                  if (x.type === "password") {
                    x.type = "text";
                  } else {
                    x.type = "password";
                  }
                }
                </script>

662047677_Screenshot2021-01-06at11_03_56PM.thumb.png.5b2d520a5af0632058de9b58380710c4.png

Link to comment
Share on other sites

4 hours ago, brian! said:

if you wanted the decrypted cPanel service password value available to the template, you could use the hook below...



 

Just out of curiosity, when was the last time you were able to get DecryptPassword to work for passwords (not encrypted strings).
I do believe something's changed in the last few releases, as it does not accurately decrypt passwords any more.  At least where WHMCS is concerned. Don't have access to cPanel at the moment to test this

It used to do this, but they've changed something, somewhere

 

Link to comment
Share on other sites

20 hours ago, Hardik Joshi said:

i tried with this but it's not working, may be am doing something wrong can you please check once, below code. it's not sawing any error, there are no output i mean not sawing password .

if I paste your code into Six productdetails page, then it works fine....

Kx6FrHP.png

... and ticking the checkbox reveals the password.

if you were testing this on a service that wasn't defined as a cPanel account in the database, then I would expect to see what you're seeing - e.g $realpassword wouldn't be returned... adding a {debug} to the template should tell you if the variable is being generated by the hook.

17 hours ago, twhiting9275 said:

Just out of curiosity, when was the last time you were able to get DecryptPassword to work for passwords (not encrypted strings).

I think yesterday when I quickly wrote and tested, on a v8.1 dev, the above hook. 🙂

17 hours ago, twhiting9275 said:

I do believe something's changed in the last few releases, as it does not accurately decrypt passwords any more.  At least where WHMCS is concerned. Don't have access to cPanel at the moment to test this

It used to do this, but they've changed something, somewhere

generally, i'm not a big fan of using the API (or anything written internally by WHMCS if I can help it!), but the above hook is returning the correct password for me (though i've only tested it on one cpanel account) - there would be scenarios where the database might not contain the real current password (occurred to me this morning that when I tested the hook yesterday, it returned the decrypted password that was stored in the database table for the hosting account, but that wasn't the real-life password for that account)...

i've updated the password in WHMCS, so it's now returning the correct real-life password for that account... in either case, it's just returning the decrypted password from the database.

with regards to the API itself, if I rewrite the hook to just use the PHP decrypt function (which I think is all the DP API does itself), then I still get the same decrypted password result.

	$service = Menu::context('service');    
	$servertype = $service->product->servertype;
	if ($servertype == 'cpanel') {
		$password = $service->password;
		$realpassword = decrypt($password);
		return array ("realpassword" => $realpassword);
	}
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.

×
×
  • 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