├── README.md └── modules └── addons └── tawkto ├── hooks.php └── tawkto.php /README.md: -------------------------------------------------------------------------------- 1 | tawk/tawk-whmcs 2 | ================ 3 | 4 | # About tawk.to 5 | tawk.to is a free live chat app that lets you monitor and chat with visitors on your website 6 | or from a free customizable page. No catch. No spam. No wares. It's truly free and always will be. 7 | 8 | # Installation 9 | Copy files modules folder to your whmcs installation folder. After that you will have to activate 10 | it by going to Setup -> Addon modules (admin/configaddonmods.php) and finding and activating 11 | Tawk.to widget module. Then make sure that you configure access to this module so that you have access to it. 12 | 13 | 14 | If you don't have [tawk.to](https://tawk.to/?utm_source=whmcs&utm_medium=link&utm_campaign=signup) account, you can always [create one for free](https://tawk.to/?utm_source=whmcs&utm_medium=link&utm_campaign=signup) -------------------------------------------------------------------------------- /modules/addons/tawkto/hooks.php: -------------------------------------------------------------------------------- 1 | select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-script')->pluck('value'); 11 | 12 | if ($widgetScript instanceof Collection) { 13 | $widgetScript = $widgetScript->all(); 14 | } 15 | 16 | if (is_array($widgetScript)) { 17 | $widgetScript = current($widgetScript); 18 | } 19 | 20 | if ($widgetScript) { 21 | // $widgetScript = addslashes($widgetScript); // this breaks the widget script when displayed on client side 22 | // $widgetScript = htmlentities($widgetScript); // this displays the script as html text and prevents proper rendering of the script 23 | $widgetScript = trim($widgetScript); 24 | } else { 25 | return; 26 | } 27 | 28 | // get the API key, if set 29 | $apikey = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-key')->pluck('value'); 30 | if ($apikey instanceof Collection) { 31 | $apikey = $apikey->all(); 32 | } 33 | if (is_array($apikey)) { 34 | $apikey = current($apikey); 35 | } 36 | if ($apikey) { 37 | $apikey = trim($apikey); 38 | } 39 | 40 | //no tawk-y (for now) 41 | $isenabled = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-enable')->WHERE('value' , 'on')->count(); 42 | if (empty($isenabled)) { 43 | return; 44 | } 45 | 46 | //clients only 47 | $clientsonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-clientsonly')->WHERE('value' , 'on')->count(); 48 | if (!empty($clientsonly)) { 49 | if (empty($uid)) { 50 | return; 51 | } 52 | } 53 | //maybe we just wanna chat with guests? 54 | $guestonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-unregonly')->WHERE('value' , 'on')->count(); 55 | if (!empty($guestonly)) { 56 | if (!empty($uid)) { 57 | return; 58 | } 59 | } 60 | 61 | // no name is show by default 62 | $tawkname = ""; 63 | if (isset($uid)) { 64 | //to name, or not to name, that is the question 65 | $showname = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-name')->WHERE('value' , 'on')->count(); 66 | 67 | if ($showname) { 68 | //now we get what we get! 69 | foreach (Capsule::table('tblclients') ->WHERE('id', $uid)->get() as $tawkclients) { 70 | $fname = html_entity_decode($tawkclients->firstname, ENT_QUOTES); 71 | $tlname = html_entity_decode($tawkclients->lastname, ENT_QUOTES); 72 | $fname = addslashes($fname); 73 | $lname = addslashes($tlname); 74 | $company = $tawkclients->companyname; 75 | $emailaddress = $tawkclients->email; 76 | } 77 | 78 | // show in secure mode if api key is set. else, show basic name/email info 79 | if (($fname || $lname) && $emailaddress) { 80 | if ($apikey && strlen($apikey) > 10) { 81 | $hash = hash_hmac("sha256", $emailaddress, $apikey); 82 | $tawkname = "Tawk_API.visitor = { 83 | name : '{$fname} {$lname}', 84 | email : '{$emailaddress}', 85 | hash : '{$hash}' 86 | };"; 87 | } else { 88 | $tawkname = "Tawk_API.visitor = { 89 | name : '{$fname} {$lname}', 90 | email : '{$emailaddress}' 91 | };"; 92 | } 93 | } 94 | } 95 | } 96 | 97 | //get the key 98 | $tawkreturn = "$widgetScript"; 99 | $tawkreturn = str_ireplace('', $tawkname.'', $tawkreturn); 100 | return($tawkreturn); 101 | } 102 | add_hook("ClientAreaFooterOutput",1,"tawkto_check"); 103 | -------------------------------------------------------------------------------- /modules/addons/tawkto/tawkto.php: -------------------------------------------------------------------------------- 1 | "tawk.to WHMCS Module", 13 | "description" => "A module designed to make it easier for clients to integrate tawk.to into their websites, with no template edits", 14 | "version" => "1.3.0", 15 | "author" => "tawk.to Team", 16 | "language" => "english", 17 | "fields" => array( 18 | "tawkto-script" => array ( 19 | "FriendlyName" => "tawk.to Script", 20 | "Type" => "textarea", 21 | "Rows" => "10", 22 | "Cols" => "100", 23 | "Description" => "Enter the tawk.to widget script here", 24 | "Default" => "", 25 | ), 26 | "tawkto-key" => array ( 27 | "FriendlyName" => "API Key", 28 | "Type" => "text", 29 | "Size" => "55", 30 | "Description" => "Obtained by going to the tawk.to dashboard, clicking on the 'Admin' menu, then viewing 'Property Settings' ", 31 | "Default" => "", 32 | ), 33 | "tawkto-enable" => array ( 34 | "FriendlyName" => "Enable mod?", 35 | "Type" => "yesno", 36 | "Size" => "55", 37 | "Description" => "A quick way to enable or disable this mod on your website ", 38 | "Default" => "", 39 | ), 40 | "tawkto-name" => array ("FriendlyName" => "Show name if logged in?", 41 | "Type" => "yesno", 42 | "Size" => "55", 43 | "Description" => "Do you want your user's name displayed in their chat (requires WHMCS login)? ", 44 | "Default" => "", 45 | ), 46 | "tawkto-clientsonly" => array ("FriendlyName" => "Only show to clients?", 47 | "Type" => "yesno", 48 | "Size" => "55", 49 | "Description" => "Hide from unregistered users?", 50 | "Default" => "", 51 | ), 52 | "tawkto-unregonly" => array ("FriendlyName" => "Only show to unregistered?", 53 | "Type" => "yesno", 54 | "Size" => "55", 55 | "Description" => "Hide from registered users?", 56 | "Default" => "", 57 | ), 58 | ) 59 | ); 60 | return $configarray; 61 | } 62 | --------------------------------------------------------------------------------