Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
client.php
1<?php
2
4
8
9class Client
10{
11 const TYPE_BITRIX24 = "B24";
12 const TYPE_BOX = "BOX";
13
14 public static function getPortalType(): string
15 {
16 if(Loader::includeModule("bitrix24") && defined("BX24_HOST_NAME"))
17 {
18 return static::TYPE_BITRIX24;
19 }
20 else
21 {
22 return static::TYPE_BOX;
23 }
24 }
25
31 public static function getLicenseCode(): string
32 {
33 if(defined('BX24_HOST_NAME'))
34 {
35 return BX24_HOST_NAME;
36 }
37 else
38 {
39 return Application::getInstance()->getLicense()->getPublicHashKey();
40 }
41 }
42
43 public static function getServerName(): string
44 {
45 if(defined('BX24_HOST_NAME'))
46 {
47 return "https://" . BX24_HOST_NAME;
48 }
49 else
50 {
51 return (\CMain::isHTTPS() ? "https" : "http")."://".((defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) ? SITE_SERVER_NAME : Option::get("main", "server_name"));
52 }
53 }
54
63 public static function signRequest(array $parameters, string $suffix = ""): string
64 {
65 $paramStr = md5(implode("|", $parameters) . ($suffix ? "|" . $suffix : ""));
66
67 $portalType = static::getPortalType();
68 if ($portalType == self::TYPE_BITRIX24 && function_exists('bx_sign'))
69 {
70 return bx_sign($paramStr);
71 }
72 else
73 {
74 return md5($paramStr . Application::getInstance()->getLicense()->getHashLicenseKey());
75 }
76 }
77}
static includeModule($moduleName)
Definition loader.php:69
static signRequest(array $parameters, string $suffix="")
Definition client.php:63