ouwejan Posted November 9, 2013 Share Posted November 9, 2013 Hi, We're trying to mimic the 'Login to DirectAdmin' button on the My Services page. Hostname and username are easily loaded ({$service.server.hostname} and {$service.username}), however we're stuck with the password. Does someone have an idea of how to load and decrypt the password? <form action="http://{$service.server.hostname}:2222/CMD_LOGIN" method="post" target="_blank"> <input type="hidden" name="username" value="{$service.username}"> <input type="hidden" name="password" value="{$service.password}"> <input type="submit" value="Login to DirectAdmin" class="button"> </form> Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 10, 2013 Share Posted November 10, 2013 Are you talking of tblhosting.password? In this case you can use this function. $password = decrypt($password); echo $password; // Displays your decoded password 0 Quote Link to comment Share on other sites More sharing options...
ouwejan Posted November 11, 2013 Author Share Posted November 11, 2013 Yes, I think so. However, how could we link your code with the right account? Please note the password is needed in the 'My Products & Services' table, so in the{foreach from=$services item=service}. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 11, 2013 Share Posted November 11, 2013 Use {php} Smarty tag. {php} $password = decrypt($password); echo $password; // Displays your decoded password {/php} 0 Quote Link to comment Share on other sites More sharing options...
ouwejan Posted November 11, 2013 Author Share Posted November 11, 2013 {foreach from=$services item=service} ... <form action="http://{$service.server.hostname}:2222/CMD_LOGIN" method="post" target="_blank"> <input type="hidden" name="username" value="{$service.username}"> <input type="hidden" name="password" value=" {php} $password = decrypt($password); echo $password; // Displays your decoded password {/php} "> <input type="submit" value="Login to DirectAdmin" class="button"> </form> ... {/foreach} Unfortunately, it outputs nothing 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 11, 2013 Share Posted November 11, 2013 Oh no, not in that way $password variable does not exist. Mine was just an example. I will go directly to the point. I suppose that you are editing clientareaproducts.tpl. Just to make things clear let's say that we want to get the password of a client which has only one cPanel product. Said that, the password is stored inside {$services.0.server.password}. Now probably you are thinking that to get the job done you can use the code below. {foreach from=$services item=service} ... <form action="http://{$service.server.hostname}:2222/CMD_LOGIN" method="post" target="_blank"> <input type="hidden" name="username" value="{$service.username}"> <input type="hidden" name="password" value=" {php} $password = decrypt({$services.0.server.password}); echo $password; {/php} "> <input type="submit" value="Login to DirectAdmin" class="button"> </form> ... {/foreach} But you can't get a Smarty variable on PHP in this way. It doesn't work. You have to use get_template_vars() function to load the variable from template. In other words here's how you can get the password. {foreach from=$services item=service} ... <form action="http://{$service.server.hostname}:2222/CMD_LOGIN" method="post" target="_blank"> <input type="hidden" name="username" value="{$service.username}"> <input type="hidden" name="password" value=" {php} $result = $this->get_template_vars('services'); $result = $result["0"]["server"]["password"]; echo $result; // Your encrypted password echo decrypt($result); // Your decrypted password {/php} "> <input type="submit" value="Login to DirectAdmin" class="button"> </form> ... {/foreach} 0 Quote Link to comment Share on other sites More sharing options...
ouwejan Posted November 13, 2013 Author Share Posted November 13, 2013 Thanks for all the help! I've tried the code, but I believe it gets the server password instead of the password of the clients account. I believe the account password is not a smarty variable on that page, so that might be a problem. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.