Jump to content

Buttons to control panel on my services page


ouwejan

Recommended Posts

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!

Link to comment
Share on other sites

{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 :(

Link to comment
Share on other sites

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}

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