PageRenderTime 132ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/main/admin/buy_support.php

https://gitlab.com/alexprowars/bitrix
PHP | 188 lines | 171 code | 11 blank | 6 comment | 21 complexity | da6e18bc3ed8d3391498f2af49e59f78 MD5 | raw file
  1. <?php
  2. ##############################################
  3. # Bitrix Site Manager #
  4. # Copyright (c) 2002-2007 Bitrix #
  5. # http://www.bitrixsoft.com #
  6. # mailto:admin@bitrixsoft.com #
  7. ##############################################
  8. require_once(dirname(__FILE__)."/../include/prolog_admin_before.php");
  9. require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/classes/general/update_client.php");
  10. if(!$USER->CanDoOperation('view_other_settings'))
  11. $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  12. $isAdmin = $USER->CanDoOperation('edit_other_settings');
  13. IncludeModuleLangFile(__FILE__);
  14. $APPLICATION->SetTitle(GetMessage("BUY_SUP_TITLE"));
  15. $APPLICATION->SetAdditionalCSS("/bitrix/components/bitrix/desktop/templates/admin/style.css");
  16. require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");
  17. $lkeySign = md5(CUpdateClient::GetLicenseKey());
  18. if(!in_array(LANGUAGE_ID, array("ru", "ua")) || intval(COption::GetOptionString("main", "~PARAM_PARTNER_ID")) <= 0)
  19. {
  20. LocalRedirect("http://www.1c-bitrix.ru/buy_tmp/key_update.php?license_key=".$lkeySign."&tobasket=y&lang=".LANGUAGE_ID, true);
  21. }
  22. else
  23. {
  24. $partner_id = COption::GetOptionString("main", "~PARAM_PARTNER_ID");
  25. $lkid = 0;
  26. ?>
  27. <div class="bx-gadgetsadm-list-table-layout">
  28. <div class="bx-gadgets-top-wrap" style="cursor: auto !important;">
  29. <div class="bx-gadgets-top-center">
  30. <div class="bx-gadgets-top-title"><?=GetMessage("BUY_SUP_PARTNER_TITLE")?></div>
  31. </div>
  32. </div>
  33. <div class="bx-gadgets-content" style="padding: 25px;">
  34. <?=GetMessage("BUY_SUP_BUY_3")?>
  35. <?
  36. $ht = new Bitrix\Main\Web\HttpClient(array("socketTimeout" => 30));
  37. $arF = array(
  38. "license_key" => $lkeySign,
  39. "action" => "get_partner",
  40. "partner_id" => $partner_id,
  41. "lang" => LANGUAGE_ID,
  42. );
  43. if($res = $ht->post("https://www.1c-bitrix.ru/buy_tmp/key_update.php", $arF))
  44. {
  45. if ($ht->getStatus() == "200")
  46. {
  47. $res = Bitrix\Main\Web\Json::decode($res);
  48. if ($res["result"] == "ok")
  49. {
  50. ?><div style="background-color: #f2f6f7; padding: 10px 20px 15px 20px; font-size: 15px; border-radius: 4px;">
  51. <div style="font-weight: bold; line-height: 2em;"><span style="color: #798284;"><?=GetMessage("BUY_SUP_PARTNER")?></span>&nbsp;
  52. <?
  53. if($res["link"] <> '')
  54. {
  55. ?><a href="<?=$res["link"]?>" target="_blank" style="color: #000; text-decoration: none;"><?=$res["name"]?></a><?
  56. }
  57. else
  58. {
  59. echo $res["name"];
  60. }
  61. echo "</div>";
  62. if($res["phone"] <> '')
  63. {
  64. ?><div style="display: inline-block;"><span style="color: #798284;"><?=GetMessage("BUY_SUP_PHONE")?></span>&nbsp;<?=$res["phone"]?></div><?
  65. }
  66. if($res["email"] <> '')
  67. {
  68. ?><div style="display: inline-block; padding-left: 40px;"><span style="color: #798284;"><?=GetMessage("BUY_SUP_EMAIL")?></span>&nbsp;<a href="mailto:<?=$res["email"]?>" style="color: #000; text-decoration: none;"><?=$res["email"]?></a></div><?
  69. }
  70. ?>
  71. </div>
  72. <?
  73. }
  74. }
  75. }
  76. ?>
  77. <div style="position: relative; padding: 25px; border: 1px solid #859f4a; border-radius: 4px; margin-top: 40px;">
  78. <div style="font-size: 18px; line-height: 28px; position: absolute; top: -14px; left: 14px; display: block; height: 28px; margin: 0; padding: 0; padding: 0 10px; vertical-align: middle; color: #859f4a; background: #fff; font-weight: bold;"><?=GetMessage("BUY_SUP_TOBUY")?></div>
  79. <?
  80. $ht = new Bitrix\Main\Web\HttpClient(array("socketTimeout" => 30));
  81. $arF = array(
  82. "license_key" => $lkeySign,
  83. "lang" => LANGUAGE_ID,
  84. );
  85. $buyUrl = "";
  86. if($res = $ht->post("https://www.1c-bitrix.ru/buy_tmp/key_update.php", $arF))
  87. {
  88. if($ht->getStatus() == "200")
  89. {
  90. $res = Bitrix\Main\Web\Json::decode($res);
  91. if($res["result"] == "ok")
  92. {
  93. ?>
  94. <div style="font-size: 16px; padding-top: 10px;"><?
  95. $lkid = $res["lkid"];
  96. if(count($res["toBuy"]) == 1)
  97. {
  98. foreach($res["toBuy"] as $v)
  99. {
  100. echo $v["NAME"]." &mdash; <b>".$res["price"]."</b>";
  101. }
  102. }
  103. else
  104. {
  105. foreach($res["toBuy"] as $v)
  106. {
  107. echo $v["NAME"];
  108. if(intval($v["CNT"]) > 0)
  109. echo " - ".$v["CNT"]." ".GetMessage("BUY_SUP_SHT");
  110. echo "<br />";
  111. }
  112. echo GetMessage("BUY_SUP_AMOUNT", array("#AMOUNT#" => $res["price"]));
  113. }
  114. $buyUrl = $res["toBasket"];
  115. ?></div><?
  116. }
  117. }
  118. }
  119. ?>
  120. <script>
  121. function sendRequest()
  122. {
  123. var nm = BX('name').value;
  124. var em = BX('email').value;
  125. var pn = BX('phone').value;
  126. BX('error').innerHTML = '';
  127. if(em.length > 0 || pn.length > 0)
  128. {
  129. BX.ajax.post(
  130. 'https://www.1c-bitrix.ru/buy_tmp/key_update.php',
  131. {"action": "send_partner_info", "partner_id": "<?=intval($partner_id)?>", "phone": pn, "email": em, "name": nm, "license_key": "<?=CUtil::JSEscape($lkeySign)?>", "site" : "<?=CUtil::JSEscape($_SERVER["HTTP_HOST"])?>"}
  132. );
  133. BX.show(BX('ok'));
  134. BX.hide(BX('req'));
  135. }
  136. else
  137. {
  138. BX('error').innerHTML = '<?=GetMessageJS("BUY_SUP_CONTACT")?>';
  139. }
  140. }
  141. </script>
  142. <div id="error"></div>
  143. <div id="ok" style="display: none; color: #859f4a; font-weight: bold;"><br /><br /><?=GetMessage("BUY_SUP_CONTACT_OK2")?></div>
  144. <div id="req">
  145. <br /><br/>
  146. <table style="border-bottom: 1px solid #dbdbda;">
  147. <tr>
  148. <td nowrap valign="middle"><?=GetMessage("BUY_SUP_NAME")?></td>
  149. <td style="padding: 5px 0 5px 15px;"><input type="text" name="name" value="<?=htmlspecialcharsbx($USER->GetFullName())?>" id="name"></td>
  150. <td rowspan="3" style="color:#788186; padding-left: 25px;" valign="top"><?=GetMessage("BUY_SUP_PREQUEST1")?></td>
  151. </tr>
  152. <tr>
  153. <td nowrap valign="middle"><?=GetMessage("BUY_SUP_YPHONE")?></td>
  154. <td style="padding: 5px 0 5px 15px;"><input type="text" name="phone" value="" id="phone"></td>
  155. </tr>
  156. <tr>
  157. <td nowrap valign="middle"><?=GetMessage("BUY_SUP_YEMAIL")?></td>
  158. <td style="padding: 5px 0 5px 15px;"><input type="text" name="email" value="<?=htmlspecialcharsbx($USER->GetEmail())?>" id="email"></td>
  159. </tr>
  160. <tr>
  161. <td colspan="3">&nbsp;</td>
  162. </tr>
  163. </table>
  164. <br />
  165. <a href="javascript:void(0)" onclick="sendRequest();" class="adm-btn adm-btn-save"><?=GetMessage("BUY_SUP_BUTTON")?></a>
  166. </div>
  167. </div>
  168. <br /><br />
  169. <div style="color:#464f57;">
  170. <?=GetMessage("BUY_SUP_BUY_1_1", ["#LINK#" => GetMessage("BUY_SUP_BUY_EULA_LINK".(IsModuleInstalled("intranet") ? "_CP" : ""))]);?>
  171. <a href="<?=$res["toBasket"]?>" target="_blank"><?=GetMessage("BUY_SUP_BUY_SELF")?></a><br /><br />
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <?}?>
  177. <?require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");?>