make-act-provided-services-invoice
43 строки · 1.4 Кб
1<?php
2
3// init config
4require(__DIR__ . "/../config/1-make-hours-amount/config.php");
5
6// composer libs
7require_once(__DIR__ . '/../vendor/autoload.php');
8
9// rpabot api
10$GLOBALS['xhe_host'] = getActualRpabotPort($robotConfig['rpabotInstallDir']);
11$GLOBALS['server_password'] = $robotConfig['server_password'];
12
13// rpabot php lib
14$GLOBALS['PHP_Use_Trought_Shell'] = false;
15require_once($robotConfig['rpabotPhpLibFp']);
16$GLOBALS['bUTF8Ver'] = true;
17
18// ---
19
20function getActualRpabotPort($rpabotInstallDir): string
21{
22// default
23$xheHostDefault = "127.0.0.1";
24$xhePortDefault = 7010;
25$xheHostPortDefault = "{$xheHostDefault}:{$xhePortDefault}";
26
27// Папка с настройками рпабот
28$rpabotSettingsDir = $rpabotInstallDir . "Settings/";
29// Файл Settings/port.txt, где указан актуальный порт работающего рпабот
30$rpabotSettingsPortFp = $rpabotSettingsDir . "port.txt";
31
32if (!file_exists($rpabotSettingsDir)) { return $xheHostPortDefault; }
33if (!file_exists($rpabotSettingsPortFp)) { return $xheHostPortDefault; }
34if (!is_file($rpabotSettingsPortFp)) { return $xheHostPortDefault; }
35
36$valueRaw = @trim(file_get_contents($rpabotSettingsPortFp));
37$portMaybe = (int) $valueRaw;
38
39if ($portMaybe <= 0) { return $xheHostPortDefault; }
40
41$result = "{$xheHostDefault}:{$portMaybe}";
42return $result;
43}
44