WHMCS - Menambahkan Login Button Di Product/Service WHMCS


Hosterbyte

Apprentice 2.0
Verified Provider
Halo semua,
kali ini mau berbagi hooks hasil jalan-jalan. Hook untuk menambahkan login Button di Product/Service WHMCS. Penampakannya seperti berkut

Image 23.jpg


Berikut cara dan kode nya

1. Buat file hook dengan nama AutoLoginToAnyPanelFromMyServices.php dengan lokasi
folder-whmcs/include/hooks

PHP:
<?php

/**
* Auto-Login to cPanel/Plesk from My Services
*
* @package WHMCS
* @copyright Katamaze
* @link https://katamaze.com
* @author Davide Mantenuto <info@katamaze.com>
*/

// IMPORTANT! The hook requires changes to two template files. Read the following for instructions
// https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/README.md#cpanel–plesk-login-button-in-my-services

use WHMCS\Database\Capsule;

add_hook(‘ClientAreaPage’, 1, function($vars)
{
if ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘services’ AND $_SESSION[‘uid’])
{
$productIDs = Capsule::select(Capsule::raw(‘SELECT t1.id, t2.type FROM tblhosting AS t1 LEFT JOIN tblservers AS t2 ON t1.server = t2.id WHERE t1.userid = ‘ . $_SESSION[‘uid’] . ‘ AND t1.server != “0” AND t1.domainstatus IN (“Active”, “Suspended”) AND t1.username != “” AND t1.password != “” AND t2.type != “”‘));

foreach ($productIDs as $v)
{
$output[‘kt_autologin’][$v->id] = $v;
}

return $output;
}
elseif ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘productdetails’ AND $_GET[‘id’] AND $_GET[‘autologin’])
{
$product = Capsule::select(Capsule::raw(‘SELECT t2.type FROM tblhosting AS t1 LEFT JOIN tblservers AS t2 ON t1.server = t2.id WHERE t1.id = ‘ . $_GET[‘id’] . ‘ AND t1.server != “0” AND t1.domainstatus IN (“Active”, “Suspended”) AND t1.username IS NOT NULL AND t1.password IS NOT NULL AND t2.type IS NOT NULL LIMIT 1’))[0];

switch ($product->type)
{
case ‘cpanel’: header(‘Location: clientarea.php?action=productdetails&id=’ . $_GET[‘id’] . ‘&dosinglesignon=1’); die(); break;
}
}
});

add_hook(‘ClientAreaHeadOutput’, 1, function($vars)
{
if ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘productdetails’ AND $_GET[‘id’] AND $_GET[‘autologin’])
{
return <<<HTML
<style>
body {
visibility:hidden;
}
</style>
<script type=”text/javascript”>
$(document).ready(function() {
$(“#domain form”).removeAttr(‘target’);
$(“#domain form”).submit();
});
</script>
HTML;
}
});

2. Cari file clientareaproducts.tpl pada folderwhmcs/templetes/{namafolder-template}/
Note : jangan lupa backup file asli sebelum dilakukan editing

3. Ganti Isinya dengan kode berikut

Code:
{include file=”$template/includes/tablelist.tpl” tableName=”ServicesList” filterColumn=”4″ noSortColumns=”0″}

<script>
jQuery(document).ready(function() {
var table = jQuery(‘#tableServicesList’).show().DataTable();

{if $orderby == ‘product’}
table.order([1, ‘{$sort}’], [4, ‘asc’]);
{elseif $orderby == ‘amount’ || $orderby == ‘billingcycle’}
table.order(2, ‘{$sort}’);
{elseif $orderby == ‘nextduedate’}
table.order(3, ‘{$sort}’);
{elseif $orderby == ‘domainstatus’}
table.order(4, ‘{$sort}’);
{/if}
table.draw();
jQuery(‘#tableLoading’).hide();
});
</script>

<div class=”table-container clearfix”>
<table id=”tableServicesList” class=”table table-list w-hidden”>
<thead>
<tr>
<th></th>
<th>{lang key=’orderproduct’}</th>
<th>{lang key=’clientareaaddonpricing’}</th>
<th>{lang key=’clientareahostingnextduedate’}</th>
<th>{lang key=’clientareastatus’}</th>
<th> Login Panel </th>
</tr>
</thead>
<tbody>
{foreach $services as $service}
<tr onclick=”clickableSafeRedirect(event, ‘clientarea.php?action=productdetails&amp;id={$service.id}’, false)”>
<td class=”py-0 text-center{if $service.sslStatus} ssl-info{/if}” data-element-id=”{$service.id}” data-type=”service”{if $service.domain} data-domain=”{$service.domain}”{/if}>
{if $service.sslStatus}
<img src=”{$service.sslStatus->getImagePath()}” data-toggle=”tooltip” title=”{$service.sslStatus->getTooltipContent()}” class=”{$service.sslStatus->getClass()}” width=”25″>
{elseif !$service.isActive}
<img src=”{$BASE_PATH_IMG}/ssl/ssl-inactive-domain.png” data-toggle=”tooltip” title=”{lang key=’sslState.sslInactiveService’}” width=”25″>
{/if}
</td>
<td><strong>{$service.product}</strong>{if $service.domain}<br /><a href=”http://{$service.domain}” target=”_blank”>{$service.domain}</a>{else}<br />-{/if}</td>
<td class=”text-center” data-order=”{$service.amountnum}”>{$service.amount} <small class=”text-muted”>{$service.billingcycle}</small></td>
<td class=”text-center”><span class=”w-hidden”>{$service.normalisedNextDueDate}</span>{$service.nextduedate}</td>
<td class=”text-center”><span class=”label status status-{$service.status|strtolower}”>{$service.statustext}</span></td>
<td class=”text-center”>
{if $kt_autologin[$service.id]}
<div class=”btn-group btn-group-sm plesk-login” style=”width:60px;”>
<a href=”clientarea.php?action=productdetails&id={$service.id}&autologin=1″ target=”_blank” class=”btn btn-primary btn-xs” alt=”Click to Login Panel” title=”Click to Login Panel” style=”padding: 2px 5px;”><i class=”fa fa-sign-in fa-fw” aria-hidden=”true”></i></a>
</div>
{/if}
</td>
</tr>

{/foreach}
</tbody>
</table>
<div class=”text-center” id=”tableLoading”>
<p><i class=”fas fa-spinner fa-spin”></i> {lang key=’loading’}</p>
</div>
</div>
4. Save dan lihat hasilnya.

Catatan
- Kode diatas saya pakai di WHMCS 8.1.0

Semoga Bermanfaat.


Referensi :
 

natanetwork

Hosting Guru
Verified Provider
nice info..
di whmcs 7.10.3 bisa ga ya?

benernya saya jg lagi cari di my service kalo yg status terminated, 1 baris itu background color nya soft red gitu..
 

Hosterbyte

Apprentice 2.0
Verified Provider
Coba tes di versi 8.2.1 gak bisa ternyata
Mungkin bisa di update lagi.

mungkin bisa langsung ke link github tuan. saya nemu aja si kemaren dan berbagi disini hehe. itu di link git bisa request juga
 

Hosterbyte

Apprentice 2.0
Verified Provider
nice info..
di whmcs 7.10.3 bisa ga ya?

benernya saya jg lagi cari di my service kalo yg status terminated, 1 baris itu background color nya soft red gitu..
ini blm nyoba si di v7 nya. coba saya open request yang diwarna merah status terminate :4:
 

natanetwork

Hosting Guru
Verified Provider
itu di link github nya wkwkw ini tadi saya coba request uda dikasi code yna cuma g jalan wkwkw
barusan coba jg jalan tapi yg <tr class="even"> ga working.. yg <tr class="odd"> bisa working warna soft red..haha
 

Hosterbyte

Apprentice 2.0
Verified Provider
barusan coba jg jalan tapi yg <tr class="even"> ga working.. yg <tr class="odd"> bisa working warna soft red..haha
oh ya uda jalan ? kayak gimana om? saya blm bisa eh wkwkw
 

Top