Advertisement
Guest User

Untitled

a guest
Aug 10th, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.5.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. if (!defined('WHMCS')) {
  15. exit('This file cannot be accessed directly');
  16. }
  17.  
  18. if (!defined('DS')) {
  19. define('DS', DIRECTORY_SEPARATOR);
  20. }
  21.  
  22. if (!defined('INVOICEPATH')) {
  23. define('INVOICEPATH', ROOTDIR . '/modules/addons/invoiceme');
  24. }
  25.  
  26. if (isset($_REQUEST['m']) && $_REQUEST['m'] == 'invoiceme' && $_REQUEST['type'] == 'i' && 0 < (int) $_SESSION['uid'] && 0 < (int) $_REQUEST['id']) {
  27. $openAPI = ROOTDIR . DS . 'modules' . DS . 'addons' . DS . 'openAPI' . DS . 'init.php';
  28.  
  29. if (!file_exists($openAPI)) {
  30. exit('Please install the openAPI module');
  31. }
  32.  
  33. require $openAPI;
  34.  
  35. if (!class_exists('DB_INVOICES')) {
  36. require_once INVOICEPATH . '/classes/db.php';
  37. }
  38.  
  39. if (!class_exists('INVOICEAPI')) {
  40. require_once INVOICEPATH . '/classes/api.php';
  41. }
  42.  
  43. if (!class_exists('INVOICESME')) {
  44. require_once INVOICEPATH . '/classes/invoices.php';
  45. }
  46.  
  47. @header('Cache-Control: private');
  48. $db = DB_INVOICES::getInstance();
  49. $api = INVOICEAPI::getInstance();
  50. $inv = INVOICESME::getInstance();
  51. $userID = (int) $_SESSION['uid'];
  52. $invoiceID = (int) $_REQUEST['id'];
  53. $invoice = $inv->getInvoice($invoiceID);
  54. $isSkipped = (int) $db->getValue('SELECT COUNT(*) FROM `mod_invoiceme_skipped` WHERE `invoiceid`=' . $invoiceID . ';');
  55.  
  56. if ($isSkipped) {
  57. WOAAPI::redirect('index.php?m=invoiceme');
  58. }
  59.  
  60. if (!$isSkipped && in_array($invoice['status'], array('Paid', 'Unpaid', 'Cancelled', 'Refunded'))) {
  61. $genID = (int) $db->getValue('SELECT g.id FROM `mod_invoiceme_generated` as g LEFT JOIN `tblinvoices` as i ON g.invoiceid=i.id WHERE i.userid=' . $userID . ' AND g.invoiceid=' . $invoiceID . ' ORDER BY g.`generated` DESC LIMIT 1;');
  62.  
  63. if (0 < $genID) {
  64. WOAAPI::redirect('index.php?m=invoiceme&action=download&id=' . $genID);
  65. }
  66. }
  67.  
  68. if ($invoice['status'] == 'Paid') {
  69. WOAAPI::redirect('index.php?m=invoiceme');
  70. }
  71.  
  72. WOAAPI::redirect('dl.php?type=i&id=' . $invoiceID);
  73. }
  74.  
  75. if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'invoiceme' && 0 < $_SESSION['adminid'] && strpos($_SERVER['REQUEST_URI'], 'addonmodules.php?') !== false) {
  76. $openAPI = ROOTDIR . DS . 'modules' . DS . 'addons' . DS . 'openAPI' . DS . 'init.php';
  77.  
  78. if (!file_exists($openAPI)) {
  79. exit('Please install the openAPI module');
  80. }
  81.  
  82. require $openAPI;
  83.  
  84. if (!class_exists('DB_INVOICES')) {
  85. require_once INVOICEPATH . '/classes/db.php';
  86. }
  87.  
  88. if (!class_exists('INVOICEAPI')) {
  89. require_once INVOICEPATH . '/classes/api.php';
  90. }
  91.  
  92. if (!class_exists('INVOICESME')) {
  93. require_once INVOICEPATH . '/classes/invoices.php';
  94. }
  95.  
  96. @header('Cache-Control: private');
  97. $api = INVOICEAPI::getInstance();
  98. $db = DB_INVOICES::getInstance();
  99. $inv = INVOICESME::getInstance();
  100. $PDFreportsPath = INVOICEPATH . '/reports/';
  101. $lang = (isset($_REQUEST['lang']) ? trim($_REQUEST['lang']) : $sysConfig['language']);
  102. $_LANG = $api->getAddonLang($lang, 'invoiceme');
  103.  
  104. if ($_REQUEST['view'] == 'reports' && !empty($_REQUEST['pdf'])) {
  105. $_REQUEST['pdf'] = basename(urldecode(trim($_REQUEST['pdf'])));
  106.  
  107. if ($_REQUEST['a'] == 'download' && $api->checkACL($_REQUEST['view'], 'download')) {
  108. if (!class_exists('DownloaderPDF')) {
  109. require_once INVOICEPATH . '/classes/downloader.php';
  110. }
  111.  
  112. if (file_exists($PDFreportsPath . $_REQUEST['pdf'])) {
  113. error_reporting(0);
  114. $ddl = new DownloaderPDF();
  115. $result = $ddl->doDownload($PDFreportsPath, $_REQUEST['pdf'], true);
  116.  
  117. exit();
  118. }
  119.  
  120. exit('Not exists');
  121. }
  122.  
  123. if ($_REQUEST['a'] == 'delete' && $api->checkACL($_REQUEST['view'], 'delete')) {
  124. if (file_exists($PDFreportsPath . $_REQUEST['pdf'])) {
  125. unlink($PDFreportsPath . $_REQUEST['pdf']);
  126. @header('Location: addonmodules.php?module=invoiceme&view=reports&cid=' . @$api->getProfileID());
  127. }
  128. } else {
  129. if ($_REQUEST['a'] == 'send' && $api->checkACL($_REQUEST['view'], 'send') && !empty($_REQUEST['email'])) {
  130. $_REQUEST['pdf'] = basename(urldecode(trim($_REQUEST['pdf'])));
  131. $file = $PDFreportsPath . $_REQUEST['pdf'];
  132.  
  133. if (file_exists($PDFreportsPath . $_REQUEST['pdf'])) {
  134. $ccEmail = $api->getConfig('ccemail', 0);
  135. $sendTo = array('to' => array(trim(urldecode($_REQUEST['email']))));
  136.  
  137. if (!empty($ccEmail)) {
  138. $sendTo['bcc'] = @explode(',', $ccEmail);
  139. }
  140.  
  141. $whmcs = $api->getWhmcsConfig();
  142. ...................................................................
  143. ........................................
  144. ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement