Added Global Variables

• Changed 'companyName' into a global variable.
• Changed 'whmcsAdminURL' into a global variable.
• Changed 'discordWebHookURL' into a global variable.
• Removed "Global Variables do not work" message since they do and has been successfully tested.
This commit is contained in:
Jack Kelly-Bayliss
2018-03-03 23:41:48 +00:00
committed by GitHub
parent 65c480ce9a
commit 88b7d39c5f

View File

@@ -1,35 +1,28 @@
<?php <?php
//////// Configuration Information //////// //////// Configuration Information ////////
// Unfortunately due to WHMCS hooks not allowing external inputs, values are required to defined within each hook. If this changes it will be updated! $GLOBALS['discordWebHookURL'] = "";
// I recommend using NotePad++ to mass replace all values at once.
// $discordWebHookURL = "";
// Found on line(s): 300
// Your Discord WebHook URL. Please be aware that the channel which you select to create the web hook is the channel which will be used for sending messages. // Your Discord WebHook URL. Please be aware that the channel which you select to create the web hook is the channel which will be used for sending messages.
// $whmcsAdminURL = ""; $GLOBALS['whmcsAdminURL'] = "";
// Found on line(s): 24, 45, 66, 87, 125, 146, 199, 220, 259
// Your WHMCS Admin URL. Please include the end / on your URL. An example of an accepted link would be: https://account.whmcs.com/admin/ // Your WHMCS Admin URL. Please include the end / on your URL. An example of an accepted link would be: https://account.whmcs.com/admin/
// $companyName = ""; $GLOBALS['companyName'] = "";
// Found on line(s): 25, 46, 67, 88, 126, 147, 200, 221, 260
// Your Company Name. This will be the name of the user which sends the messages. // Your Company Name. This will be the name of the user which sends the messages.
// $discordGroupID = ""; // $discordGroupID = "";
// Found on line(s): 26, 47, 68, 89, 127, 148, 201, 222, 261 // Found on line(s): 21, 38, 57, 76, 112, 131, 182, 201, 238
// Discord Group ID Config Option. If you wished for each message which is sent to ping a specific group, please place the ID here. An example of a group ID is: @&343029528563548162 // Discord Group ID Config Option. If you wished for each message which is sent to ping a specific group, please place the ID here. An example of a group ID is: @&343029528563548162
add_hook('InvoicePaid', 1, function($vars) { add_hook('InvoicePaid', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'invoices.php?action=edit&id=' . $vars['invoiceid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -42,15 +35,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('InvoiceRefunded', 1, function($vars) { add_hook('InvoiceRefunded', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'invoices.php?action=edit&id=' . $vars['invoiceid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -63,15 +54,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('AcceptOrder', 1, function($vars) { add_hook('AcceptOrder', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -84,15 +73,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('CancellationRequest', 1, function($vars) { add_hook('CancellationRequest', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'cancelrequests.php', 'url' => $GLOBALS['whmcsAdminURL'] . 'cancelrequests.php',
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => $vars['reason'], 'description' => $vars['reason'],
'color' => '5653183', 'color' => '5653183',
@@ -122,15 +109,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('FraudOrder', 1, function($vars) { add_hook('FraudOrder', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -143,15 +128,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('NetworkIssueAdd', 1, function($vars) { add_hook('NetworkIssueAdd', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'networkissues.php?action=manage&id=' . $vars['announcementid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'networkissues.php?action=manage&id=' . $vars['announcementid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => $vars['reason'], 'description' => $vars['reason'],
'color' => '5653183', 'color' => '5653183',
@@ -196,15 +179,13 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('PendingOrder', 1, function($vars) { add_hook('PendingOrder', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -217,16 +198,14 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('TicketOpen', 1, function($vars) { add_hook('TicketOpen', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'title' => $vars['subject'], 'title' => $vars['subject'],
'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -256,16 +235,14 @@
processNotification($dataPacket); processNotification($dataPacket);
}); });
add_hook('TicketUserReply', 1, function($vars) { add_hook('TicketUserReply', 1, function($vars) {
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
$companyName = ""; // Your Company Name.
$discordGroupID = ""; // Discord Group ID Config Option. $discordGroupID = ""; // Discord Group ID Config Option.
$dataPacket = array( $dataPacket = array(
'content' => $discordGroupID, 'content' => $discordGroupID,
'username' => $companyName, 'username' => $GLOBALS['companyName'],
'embeds' => array( 'embeds' => array(
array( array(
'title' => $vars['subject'], 'title' => $vars['subject'],
'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'], 'url' => $GLOBALS['whmcsAdminURL'] . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
'timestamp' => date(DateTime::ISO8601), 'timestamp' => date(DateTime::ISO8601),
'description' => '', 'description' => '',
'color' => '5653183', 'color' => '5653183',
@@ -297,8 +274,7 @@
function processNotification($dataPacket, $discordWebHookURL) { function processNotification($dataPacket, $discordWebHookURL) {
$dataString = json_encode($dataPacket); $dataString = json_encode($dataPacket);
$curl = curl_init(); $curl = curl_init();
$discordWebHookURL = ""; // Your Discord WebHook URL curl_setopt($curl, CURLOPT_URL, $GLOBALS['discordWebHookURL']);
curl_setopt($curl, CURLOPT_URL, $discordWebHookURL);
curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array( curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json' 'Content-Type: application/json'