ControlC
· Pastebin
Login
Register
ControlC
/
Create paste
Paste content
Up to 100 KB of text. BBCode formatting is supported.
Title
- optional
Content
B
I
U
S
</>
Colors ↓
Sizes ↓
Size 1
Size 2
Size 3
Size 4
Size 5
Size 6
Size 7
<?php\r\n\r\nif (!defined(\"WHMCS\"))\r\n die(\"This file cannot be accessed directly\");\r\n\r\nuse WHMCS\Database\Capsule;\r\nuse WHMCS\View\Menu\Item as MenuItem;\r\n\r\nfunction restrict_access_to_add_funds($vars) {\r\n\r\n if (filter_var($_GET['action'], FILTER_SANITIZE_STRING) == 'addfunds') {\r\n\r\n // Get PDO for the database queries\r\n $pdo = Capsule::connection()->getPdo();\r\n\r\n if ($vars['clientsdetails']['customfields']) {\r\n $customfields = $vars['clientsdetails']['customfields'];\r\n foreach ($customfields as $key => $customfield) {\r\n ##### Start Database Query #####\r\n try {\r\n $customfieldsquery = $pdo->query(\"SELECT fieldname FROM tblcustomfields WHERE id = \" . $pdo->quote($customfield['id']));\r\n\r\n while($row = $customfieldsquery->fetch(PDO::FETCH_ASSOC)) {\r\n if ($row['fieldname'] == 'Enable Add Funds') {\r\n $addfunds = $customfield['value'];\r\n }\r\n }\r\n } catch(PDOException $e) {\r\n echo 'ERROR: ' . $e->getMessage();\r\n }\r\n }\r\n\r\n if ($addfunds !== 'on') {\r\n header(\"Location: clientarea.php\");\r\n exit();\r\n }\r\n }\r\n\r\n }\r\n\r\n}\r\n\r\nfunction restrict_add_funds_link(MenuItem $primaryNavbar) {\r\n\r\n $client = Menu::context('client');\r\n\r\n // Get PDO for the database queries\r\n $pdo = Capsule::connection()->getPdo();\r\n\r\n try {\r\n $clientquery = $pdo->query(\"SELECT tblcustomfields.fieldname AS customfieldname, tblcustomfieldsvalues.value AS customfieldvalue FROM tblcustomfields INNER JOIN tblcustomfieldsvalues ON tblcustomfields.id = tblcustomfieldsvalues.fieldid WHERE tblcustomfieldsvalues.relid = \" . $pdo->quote($client->id));\r\n\r\n while($row = $clientquery->fetch(PDO::FETCH_ASSOC)) {\r\n if (trim($row['customfieldname']) == \"Enable Add Funds\") {\r\n $addfunds = $row['customfieldvalue'];\r\n }\r\n }\r\n } catch(PDOException $e) {\r\n echo 'ERROR: ' . $e->getMessage();\r\n }\r\n\r\n \r\n if ($addfunds !== 'on') {\r\n if (!is_null($primaryNavbar->getChild('Billing'))) {\r\n $primaryNavbar->getChild('Billing')->removeChild('Add Funds');\r\n }\r\n }\r\n\r\n}\r\n\r\nfunction add_funds_sidebar(MenuItem $primarySidebar) {\r\n\r\n $filename = APP::getCurrentFileName();\r\n $client = Menu::context(\"client\");\r\n $clientid = intval( $client->id );\r\n $action = $_GET['action'];\r\n $allowed = array('invoices', 'quotes', 'masspay', 'addfunds');\r\n\r\n /* prevents balance display to unauth'd users */\r\n if ($filename!=='clientarea' || $clientid===0 || strpos($_SERVER['REQUEST_URI'], 'verificationId') !== false || is_null($client)) {\r\n return;\r\n }\r\n\r\n // Get PDO for the database queries\r\n $pdo = Capsule::connection()->getPdo();\r\n\r\n try {\r\n $clientquery = $pdo->query(\"SELECT tblcustomfields.fieldname AS customfieldname, tblcustomfieldsvalues.value AS customfieldvalue FROM tblcustomfields INNER JOIN tblcustomfieldsvalues ON tblcustomfields.id = tblcustomfieldsvalues.fieldid WHERE tblcustomfieldsvalues.relid = \" . $pdo->quote($client->id));\r\n\r\n while($row = $clientquery->fetch(PDO::FETCH_ASSOC)) {\r\n if (trim($row['customfieldname']) == \"Enable Add Funds\") {\r\n $addfunds = $row['customfieldvalue'];\r\n }\r\n }\r\n } catch(PDOException $e) {\r\n echo 'ERROR: ' . $e->getMessage();\r\n }\r\n\r\n /* uncomment this to hide the sidebar if the client has no balance */\r\n if ($client->credit <= 0.00 && $addfunds !== 'on' && filter_var($_GET['action'], FILTER_SANITIZE_STRING) !== 'addfunds') { return; }\r\n\r\n $primarySidebar->addChild('Client-Balance', array(\r\n 'label' => Lang::trans('availcreditbal'),\r\n 'uri' => '#',\r\n 'order' => '1',\r\n 'icon' => 'fa fa-credit-card'\r\n ));\r\n\r\n # Get Currency\r\n $getCurrency = getCurrency($clientid);\r\n $balanceDisplay = formatCurrency($client->credit, $getCurrency);\r\n\r\n # Retrieve the panel we just created.\r\n $balancePanel = $primarySidebar->getChild('Client-Balance');\r\n\r\n // Move the panel to the end of the sorting order so it's always displayed\r\n // as the last panel in the sidebar.\r\n $balancePanel->moveToBack();\r\n $balancePanel->setOrder(0);\r\n\r\n # Add Balance.\r\n if ($addfunds == 'on' && filter_var($_GET['action'], FILTER_SANITIZE_STRING) !== 'addfunds') {\r\n $balancePanel->addChild('balance-amount', array(\r\n 'uri' => 'clientarea.php?action=addfunds',\r\n 'label' => '<h4 style=\"text-align:center;\">'.$balanceDisplay.'</h4>',\r\n 'order' => 1\r\n ));\r\n \r\n $balancePanel->setFooterHtml(\r\n '<a href=\"clientarea.php?action=addfunds\" class=\"btn btn-success btn-sm btn-block\">\r\n <i class=\"fa fa-plus\"></i> Add Funds </a>'\r\n );\r\n }else{\r\n $balancePanel->addChild('balance-amount', array(\r\n 'label' => '<h4 style=\"text-align:center;\">'.$balanceDisplay.'</h4>',\r\n 'order' => 1\r\n ));\r\n }\r\n\r\n}\r\n\r\nadd_hook(\"ClientAreaPageAddFunds\", 0, \"restrict_access_to_add_funds\");\r\nadd_hook(\"ClientAreaPrimaryNavbar\", 0, \"restrict_add_funds_link\");\r\nadd_hook(\"ClientAreaSecondarySidebar\", 0, \"add_funds_sidebar\");\r\n\r\n?>
Password
Anyone with the link will still need this password to view.
Expires
1 hour
3 hours
6 hours
12 hours
24 hours
48 hours
72 hours
Sign in to enable "Never expires".
Create paste
Please verify you are human
Cancel