productressources.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. use WHMCS\Application;
  3. use WHMCS\Config\Setting;
  4. use WHMCS\Exception\ProgramExit;
  5. use WHMCS\Product\Product;
  6. use WHMCS\Session;
  7. use WHMCS\User\Client;
  8. use WHMCS\Database\Capsule;
  9. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ResourceManager;
  10. use ModulesGarden\Servers\ProxmoxCloudVps\Packages\WhmcsService\Service;
  11. require("../../init.php");
  12. /*
  13. *** USAGE SAMPLES ***
  14. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=name"></script>
  15. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=description"></script>
  16. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly&currency=1"></script>
  17. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=orderurl&carttpl=web20cart"></script>
  18. */
  19. $whmcs = App::self();
  20. $pid = (int) $whmcs->get_req_var('pid');
  21. $id = (int) $whmcs->get_req_var('id');
  22. $get = $whmcs->get_req_var('get');
  23. $language = $whmcs->get_req_var('language') ?: null;
  24. $data = array();
  25. $name = $description = '';
  26. // Verify user input for pid exists, is greater than 0, and as is a valid id
  27. if ($pid > 0) {
  28. $data = Capsule::table('tblproducts')
  29. ->where('id', '=', $pid)
  30. ->first();
  31. $pid = (int) $data->id;
  32. // If there is a user logged in, we will use the client language
  33. if (((int) $userId = Session::get('userid'))) {
  34. $language = Client::find($userId, array('language'))->language ?: null;
  35. }
  36. $name = Product::getProductName($pid, $data->name, $language);
  37. $description = Product::getProductDescription($pid, $data->description, $language);
  38. }
  39. // Verify that the pid is not less than 1 to in order to continue.
  40. if ($pid < 1) {
  41. widgetOutput('Product ID Not Found');
  42. }
  43. $configOptionsGroupID = Capsule::table('tblproductconfiglinks')
  44. ->where('pid', '=', $pid)
  45. ->select('gid')
  46. ->first();
  47. $configOptions = Capsule::table('tblproductconfigoptions')
  48. ->where('gid', '=', $configOptionsGroupID->gid)
  49. ->select('optionname','qtyminimum')
  50. ->get();
  51. $this->service = new Service($id);
  52. $this->service->loadWhmcsService();
  53. $this->ressource = new ResourceManager();
  54. print_r($this->ressource);
  55. widgetOutput($this->ressource->vcpus()->getUsed());
  56. function widgetOutput($value) {
  57. echo "document.write('".addslashes($value)."');";
  58. throw new ProgramExit();
  59. }