productressources.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. require("../../init.php");
  11. /*
  12. *** USAGE SAMPLES ***
  13. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=name"></script>
  14. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=description"></script>
  15. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly&currency=1"></script>
  16. <script language="javascript" src="feeds/productsinfo.php?pid=1&get=orderurl&carttpl=web20cart"></script>
  17. */
  18. $whmcs = App::self();
  19. $pid = (int) $whmcs->get_req_var('pid');
  20. $id = (int) $whmcs->get_req_var('id');
  21. $get = $whmcs->get_req_var('get');
  22. $language = $whmcs->get_req_var('language') ?: null;
  23. $data = array();
  24. $name = $description = '';
  25. // Verify user input for pid exists, is greater than 0, and as is a valid id
  26. if ($pid > 0) {
  27. $data = Capsule::table('tblproducts')
  28. ->where('id', '=', $pid)
  29. ->first();
  30. $pid = (int) $data->id;
  31. // If there is a user logged in, we will use the client language
  32. if (((int) $userId = Session::get('userid'))) {
  33. $language = Client::find($userId, array('language'))->language ?: null;
  34. }
  35. $name = Product::getProductName($pid, $data->name, $language);
  36. $description = Product::getProductDescription($pid, $data->description, $language);
  37. }
  38. // Verify that the pid is not less than 1 to in order to continue.
  39. if ($pid < 1) {
  40. widgetOutput('Product ID Not Found');
  41. }
  42. $configOptionsGroupID = Capsule::table('tblproductconfiglinks')
  43. ->where('pid', '=', $pid)
  44. ->select('gid')
  45. ->first();
  46. $configOptions = Capsule::table('tblproductconfigoptions')
  47. ->where('gid', '=', $configOptionsGroupID->gid)
  48. ->select('optionname','qtyminimum')
  49. ->get();
  50. $ressource = new ResourceManager();
  51. widgetOutput($id);
  52. function widgetOutput($value) {
  53. echo "document.write('".addslashes($value)."');";
  54. throw new ProgramExit();
  55. }