@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | // $ echo test | php examples/uppercase.php |
4 | 4 | |
5 | -require __DIR__ . '/../vendor/autoload.php'; |
|
5 | +require __DIR__.'/../vendor/autoload.php'; |
|
6 | 6 | |
7 | 7 | Clue\StreamFilter\append(STDIN, 'strtoupper'); |
8 | 8 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | // $ echo test | php examples/base64_encode.php | base64 --decode |
4 | 4 | |
5 | -require __DIR__ . '/../vendor/autoload.php'; |
|
5 | +require __DIR__.'/../vendor/autoload.php'; |
|
6 | 6 | |
7 | 7 | // encoding requires buffering in chunks of 3 bytes each |
8 | 8 | $buffer = ''; |
9 | -Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { |
|
9 | +Clue\StreamFilter\append(STDIN, function($chunk = null) use (&$buffer) { |
|
10 | 10 | if ($chunk === null) { |
11 | 11 | return base64_encode($buffer); |
12 | 12 | } |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | // encoding requires buffering in chunks of 3 bytes each |
8 | 8 | $buffer = ''; |
9 | -Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { |
|
9 | +Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) |
|
10 | +{ |
|
10 | 11 | if ($chunk === null) { |
11 | 12 | return base64_encode($buffer); |
12 | 13 | } |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function Register($di): void |
31 | 31 | { |
32 | - $registeredDBServices=[]; |
|
32 | + $registeredDBServices = []; |
|
33 | 33 | $config = $di->getConfig(); |
34 | 34 | // Зарегистрируем сервисы базы данных для модулей расширений |
35 | - $results = glob( $config->application->modulesDir . '*/db/*.db', GLOB_NOSORT ); |
|
36 | - foreach ( $results as $file ) { |
|
35 | + $results = glob($config->application->modulesDir.'*/db/*.db', GLOB_NOSORT); |
|
36 | + foreach ($results as $file) { |
|
37 | 37 | $service_name = self::makeServiceName($file, $config->application->modulesDir); |
38 | - $registeredDBServices[]=$service_name; |
|
38 | + $registeredDBServices[] = $service_name; |
|
39 | 39 | $di->set($service_name, function() use ($file) { |
40 | 40 | return new Sqlite(['dbname' => $file]); |
41 | 41 | }); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | $mainConnection = $di->get('db'); |
46 | 46 | |
47 | 47 | $eventsManager = $mainConnection->getEventsManager(); |
48 | - if ($eventsManager === null){ |
|
48 | + if ($eventsManager === null) { |
|
49 | 49 | $eventsManager = new Manager(); |
50 | 50 | } |
51 | 51 | // Слушаем все события базы данных |
52 | - $eventsManager->attach('db', function ($event) use ($registeredDBServices, $di){ |
|
53 | - switch ($event->getType()){ |
|
52 | + $eventsManager->attach('db', function($event) use ($registeredDBServices, $di){ |
|
53 | + switch ($event->getType()) { |
|
54 | 54 | case 'beginTransaction':{ |
55 | - foreach ($registeredDBServices as $service){ |
|
55 | + foreach ($registeredDBServices as $service) { |
|
56 | 56 | $di->get($service)->begin(); |
57 | 57 | } |
58 | 58 | break; |
59 | 59 | } |
60 | 60 | case 'commitTransaction':{ |
61 | - foreach ($registeredDBServices as $service){ |
|
61 | + foreach ($registeredDBServices as $service) { |
|
62 | 62 | $di->get($service)->commit(); |
63 | 63 | } |
64 | 64 | break; |
65 | 65 | } |
66 | 66 | case 'rollbackTransaction':{ |
67 | - foreach ($registeredDBServices as $service){ |
|
67 | + foreach ($registeredDBServices as $service) { |
|
68 | 68 | $di->get($service)->rollback(); |
69 | 69 | } |
70 | 70 | break; |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private static function makeServiceName($filePath, $modulesRoot):string |
88 | 88 | { |
89 | - $moduleName=self::findModuleIdByDbPath($filePath, $modulesRoot); |
|
89 | + $moduleName = self::findModuleIdByDbPath($filePath, $modulesRoot); |
|
90 | 90 | $dbName = pathinfo($filePath)['filename']; |
91 | - return $moduleName.'_'.Text::uncamelize($dbName,'_').'_db'; |
|
91 | + return $moduleName.'_'.Text::uncamelize($dbName, '_').'_db'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private static function findModuleIdByDbPath($filePath, $modulesRoot) :string |
101 | 101 | { |
102 | - $filePath = str_replace($modulesRoot,'',$filePath); |
|
103 | - return implode('/', array_slice(explode('/', $filePath), 0,1)); |
|
102 | + $filePath = str_replace($modulesRoot, '', $filePath); |
|
103 | + return implode('/', array_slice(explode('/', $filePath), 0, 1)); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | foreach ( $results as $file ) { |
37 | 37 | $service_name = self::makeServiceName($file, $config->application->modulesDir); |
38 | 38 | $registeredDBServices[]=$service_name; |
39 | - $di->set($service_name, function() use ($file) { |
|
39 | + $di->set($service_name, function() use ($file) |
|
40 | + { |
|
40 | 41 | return new Sqlite(['dbname' => $file]); |
41 | 42 | }); |
42 | 43 | } |
@@ -49,7 +50,8 @@ discard block |
||
49 | 50 | $eventsManager = new Manager(); |
50 | 51 | } |
51 | 52 | // Слушаем все события базы данных |
52 | - $eventsManager->attach('db', function ($event) use ($registeredDBServices, $di){ |
|
53 | + $eventsManager->attach('db', function ($event) use ($registeredDBServices, $di) |
|
54 | + { |
|
53 | 55 | switch ($event->getType()){ |
54 | 56 | case 'beginTransaction':{ |
55 | 57 | foreach ($registeredDBServices as $service){ |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | public function __construct($class, $moduleId) |
28 | 28 | { |
29 | 29 | $logPath = System::get_log_dir().'/'.$moduleId.'/'; |
30 | - $this->logFile = $logPath.$class.'log'; |
|
30 | + $this->logFile = $logPath.$class.'log'; |
|
31 | 31 | $logfilestokeep = 30; |
32 | 32 | |
33 | 33 | if (file_exists($this->logFile)) { |
34 | 34 | if (date('Y-m-d', filemtime($this->logFile)) !== date('Y-m-d')) { |
35 | - if (file_exists($this->logFile . '.' . $logfilestokeep)) { |
|
36 | - unlink($this->logFile . '.' . $logfilestokeep); |
|
35 | + if (file_exists($this->logFile.'.'.$logfilestokeep)) { |
|
36 | + unlink($this->logFile.'.'.$logfilestokeep); |
|
37 | 37 | } |
38 | 38 | for ($i = $logfilestokeep; $i > 0; $i--) { |
39 | - if (file_exists($this->logFile . '.' . $i)) { |
|
39 | + if (file_exists($this->logFile.'.'.$i)) { |
|
40 | 40 | $next = $i + 1; |
41 | - rename($this->logFile . '.' . $i, $this->logFile . '.' . $next); |
|
41 | + rename($this->logFile.'.'.$i, $this->logFile.'.'.$next); |
|
42 | 42 | } |
43 | 43 | } |
44 | - rename($this->logFile, $this->logFile . '.1'); |
|
44 | + rename($this->logFile, $this->logFile.'.1'); |
|
45 | 45 | } |
46 | - } elseif (!file_exists($logPath) && !mkdir($logPath, 0777, true) && !is_dir($logPath)){ |
|
46 | + } elseif (!file_exists($logPath) && !mkdir($logPath, 0777, true) && !is_dir($logPath)) { |
|
47 | 47 | $this->logFile = "/var/log/$moduleId.log"; |
48 | 48 | } |
49 | 49 | $this->logger = new FileAdapter($this->logFile); |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | |
52 | 52 | public function write($data, $level = \Phalcon\Logger::ERROR):void |
53 | 53 | { |
54 | - $this->logger->log(print_r($data,true)); |
|
54 | + $this->logger->log(print_r($data, true)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function writeError($data, $level = \Phalcon\Logger::ERROR):void |
58 | 58 | { |
59 | - $this->logger->log(print_r($data,true)); |
|
59 | + $this->logger->log(print_r($data, true)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function writeInfo($data, $level = \Phalcon\Logger::INFO):void |
63 | 63 | { |
64 | - $this->logger->log(print_r($data,true)); |
|
64 | + $this->logger->log(print_r($data, true)); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | private function curlPostRequest($metod, $data = null) |
37 | 37 | { |
38 | - $url = $this->serverUrl . "/license.api/$metod"; |
|
38 | + $url = $this->serverUrl."/license.api/$metod"; |
|
39 | 39 | $ch = curl_init(); |
40 | 40 | curl_setopt($ch, CURLOPT_URL, $url); |
41 | 41 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $version = str_replace(PHP_EOL, '', file_get_contents('/etc/version')); |
93 | 93 | |
94 | - $data = [ |
|
94 | + $data = [ |
|
95 | 95 | 'companyname' => $params['companyname'], |
96 | 96 | 'email' => $params['email'], |
97 | 97 | 'contact' => $params['contact'], |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $params = "feature={$featureId}"; |
186 | 186 | $response = $this->curlPostRequest('capturefeature?'.$params); |
187 | 187 | $data = json_decode($response['result'], true); |
188 | - if ($response['code']===200){ |
|
188 | + if ($response['code'] === 200) { |
|
189 | 189 | $this->sessionId = $data['session']; |
190 | 190 | return ['success'=>true]; |
191 | 191 | } else { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | $params = "feature={$featureId}"; |
206 | 206 | $response = $this->curlPostRequest('featureavailable?'.$params); |
207 | - if ($response['code'] === 200){ |
|
207 | + if ($response['code'] === 200) { |
|
208 | 208 | return ['success'=>true]; |
209 | 209 | } else { |
210 | 210 | $data = json_decode($response['result'], true); |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function releaseFeature($featureId) :array |
224 | 224 | { |
225 | - if ($this->sessionId){ |
|
225 | + if ($this->sessionId) { |
|
226 | 226 | $params = "session={$this->sessionId}&feature={$featureId}"; |
227 | 227 | $response = $this->curlPostRequest('releasefeature?'.$params); |
228 | - if ($response['code'] === 200){ |
|
228 | + if ($response['code'] === 200) { |
|
229 | 229 | return ['success'=>true]; |
230 | 230 | } else { |
231 | 231 | $data = json_decode($response['result'], true); |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | |
249 | 249 | $json_data = json_decode($text, true); |
250 | 250 | if (is_null($json_data)) { |
251 | - $text = str_replace(['\n','\"'], "\n", $text); |
|
251 | + $text = str_replace(['\n', '\"'], "\n", $text); |
|
252 | 252 | $json_data = json_decode($text, true); |
253 | 253 | } |
254 | - if ( ! isset($json_data['error'])) { |
|
254 | + if (!isset($json_data['error'])) { |
|
255 | 255 | $text_xml = urldecode($json_data['result']); |
256 | 256 | libxml_use_internal_errors(true); |
257 | 257 | $doc = simplexml_load_string($text_xml); |
258 | - if ( ! $doc) { |
|
258 | + if (!$doc) { |
|
259 | 259 | libxml_clear_errors(); |
260 | 260 | $doc = $text_xml; |
261 | 261 | } |
@@ -27,19 +27,19 @@ |
||
27 | 27 | ], |
28 | 28 | ]; |
29 | 29 | |
30 | - $results = glob( $config->application->modulesDir . '*/*/{controllers,forms}', GLOB_BRACE ); |
|
31 | - foreach ( $results as $path ) { |
|
30 | + $results = glob($config->application->modulesDir.'*/*/{controllers,forms}', GLOB_BRACE); |
|
31 | + foreach ($results as $path) { |
|
32 | 32 | $arDirs[] = $path; |
33 | 33 | } |
34 | 34 | |
35 | - $results = glob( $config->application->modulesDir . '*/{setup}', GLOB_BRACE ); |
|
36 | - foreach ( $results as $path ) { |
|
35 | + $results = glob($config->application->modulesDir.'*/{setup}', GLOB_BRACE); |
|
36 | + foreach ($results as $path) { |
|
37 | 37 | $arDirs[] = $path; |
38 | 38 | } |
39 | 39 | $arrFiles[] = $config->application->backendDir.'modules/DiServicesInstall.php'; |
40 | 40 | $loader->registerFiles($arrFiles, true); |
41 | - $loader->registerNamespaces($arNameSpaces,true); |
|
42 | - $loader->registerDirs( $arDirs,true ); |
|
41 | + $loader->registerNamespaces($arNameSpaces, true); |
|
42 | + $loader->registerDirs($arDirs, true); |
|
43 | 43 | $loader->register(); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -122,42 +122,42 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function __construct($module_uniqid = null) |
124 | 124 | { |
125 | - if($module_uniqid!==null){ |
|
126 | - $this->module_uniqid = $module_uniqid; |
|
125 | + if ($module_uniqid !== null) { |
|
126 | + $this->module_uniqid = $module_uniqid; |
|
127 | 127 | } |
128 | 128 | $this->di = DI::getDefault(); |
129 | 129 | $this->db = $this->di->get('db'); |
130 | 130 | $this->config = $this->di->get('config'); |
131 | - $settings_file = "{$this->config->application->modulesDir}{$this->module_uniqid}/module.json"; |
|
132 | - if (file_exists($settings_file)){ |
|
133 | - $module_settings = json_decode(file_get_contents($settings_file),true); |
|
134 | - if ($module_settings){ |
|
131 | + $settings_file = "{$this->config->application->modulesDir}{$this->module_uniqid}/module.json"; |
|
132 | + if (file_exists($settings_file)) { |
|
133 | + $module_settings = json_decode(file_get_contents($settings_file), true); |
|
134 | + if ($module_settings) { |
|
135 | 135 | $this->version = $module_settings['version']; |
136 | 136 | $this->min_pbx_version = $module_settings['min_pbx_version']; |
137 | 137 | $this->developer = $module_settings['developer']; |
138 | 138 | $this->support_email = $module_settings['support_email']; |
139 | - if (array_key_exists('lic_product_id', $module_settings)){ |
|
139 | + if (array_key_exists('lic_product_id', $module_settings)) { |
|
140 | 140 | $this->lic_product_id = $module_settings['lic_product_id']; |
141 | 141 | } else { |
142 | - $this->lic_product_id = 0 ; |
|
142 | + $this->lic_product_id = 0; |
|
143 | 143 | } |
144 | - if (array_key_exists('lic_feature_id', $module_settings)){ |
|
144 | + if (array_key_exists('lic_feature_id', $module_settings)) { |
|
145 | 145 | $this->lic_feature_id = $module_settings['lic_feature_id']; |
146 | 146 | } else { |
147 | - $this->lic_feature_id = 0 ; |
|
147 | + $this->lic_feature_id = 0; |
|
148 | 148 | } |
149 | 149 | } else { |
150 | - $this->messages[]= 'Error on decode module.json'; |
|
150 | + $this->messages[] = 'Error on decode module.json'; |
|
151 | 151 | } |
152 | 152 | } |
153 | - $this->moduleDir = $this->config->application->modulesDir . $this->module_uniqid; |
|
153 | + $this->moduleDir = $this->config->application->modulesDir.$this->module_uniqid; |
|
154 | 154 | $this->messages = []; |
155 | 155 | |
156 | 156 | // Create and connect database |
157 | 157 | $dbPath = "{$this->moduleDir}/db"; |
158 | 158 | |
159 | - if(!file_exists($dbPath) && !mkdir($dbPath, 0777, true) && !is_dir($dbPath)){ |
|
160 | - $this->messages[]=sprintf('Directory "%s" was not created', $dbPath); |
|
159 | + if (!file_exists($dbPath) && !mkdir($dbPath, 0777, true) && !is_dir($dbPath)) { |
|
160 | + $this->messages[] = sprintf('Directory "%s" was not created', $dbPath); |
|
161 | 161 | throw new RuntimeException(sprintf('Directory "%s" was not created', $dbPath)); |
162 | 162 | } |
163 | 163 | $this->moduleDB = new Sqlite(['dbname' => "$dbPath/module.db"]); |
@@ -173,21 +173,21 @@ discard block |
||
173 | 173 | { |
174 | 174 | $result = true; |
175 | 175 | try { |
176 | - if ( ! $this->activateLicense()) { |
|
177 | - $this->messages[] = 'License activate error'; |
|
176 | + if (!$this->activateLicense()) { |
|
177 | + $this->messages[] = 'License activate error'; |
|
178 | 178 | $result = false; |
179 | 179 | } |
180 | - if ( ! $this->installFiles()) { |
|
181 | - $this->messages[] = ' installFiles error'; |
|
180 | + if (!$this->installFiles()) { |
|
181 | + $this->messages[] = ' installFiles error'; |
|
182 | 182 | $result = false; |
183 | 183 | } |
184 | - if ( ! $this->installDB()) { |
|
185 | - $this->messages[] = ' installDB error'; |
|
184 | + if (!$this->installDB()) { |
|
185 | + $this->messages[] = ' installDB error'; |
|
186 | 186 | $result = false; |
187 | 187 | } |
188 | 188 | } catch (Throwable $exception) { |
189 | 189 | $result = false; |
190 | - $this->messages=$exception->getMessage(); |
|
190 | + $this->messages = $exception->getMessage(); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return $result; |
@@ -244,17 +244,17 @@ discard block |
||
244 | 244 | { |
245 | 245 | $result = true; |
246 | 246 | try { |
247 | - if ( ! $this->unInstallDB($keepSettings)) { |
|
248 | - $this->messages[]= ' unInstallDB error'; |
|
247 | + if (!$this->unInstallDB($keepSettings)) { |
|
248 | + $this->messages[] = ' unInstallDB error'; |
|
249 | 249 | $result = false; |
250 | 250 | } |
251 | - if ($result && ! $this->unInstallFiles($keepSettings)) { |
|
252 | - $this->messages[]= ' unInstallFiles error'; |
|
251 | + if ($result && !$this->unInstallFiles($keepSettings)) { |
|
252 | + $this->messages[] = ' unInstallFiles error'; |
|
253 | 253 | $result = false; |
254 | 254 | } |
255 | 255 | } catch (Throwable $exception) { |
256 | 256 | $result = false; |
257 | - $this->messages=$exception->getMessage(); |
|
257 | + $this->messages = $exception->getMessage(); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return $result; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $backupPath = "{$this->config->application->modulesDir}Backup/{$this->module_uniqid}"; |
287 | 287 | Util::mwexec("rm -rf {$backupPath}"); |
288 | 288 | if ($keepSettings) { |
289 | - if ( ! is_dir($backupPath) && ! mkdir($backupPath, 0777, true) && ! is_dir($backupPath)) { |
|
289 | + if (!is_dir($backupPath) && !mkdir($backupPath, 0777, true) && !is_dir($backupPath)) { |
|
290 | 290 | $this->messages[] = sprintf('Directory "%s" was not created', $backupPath); |
291 | 291 | |
292 | 292 | return false; |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | { |
308 | 308 | // Проверим версию АТС и Модуля на совместимость |
309 | 309 | $currentVersionPBX = PbxSettings::getValueByKey('PBXVersion'); |
310 | - $currentVersionPBX = str_replace('-dev','', $currentVersionPBX); |
|
310 | + $currentVersionPBX = str_replace('-dev', '', $currentVersionPBX); |
|
311 | 311 | if (version_compare($currentVersionPBX, $this->min_pbx_version) < 0) { |
312 | 312 | $this->messages[] = "Error: module depends minimum PBX ver $this->min_pbx_version"; |
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
316 | 316 | $module = PbxExtensionModules::findFirst("uniqid='{$this->module_uniqid}'"); |
317 | - if ( ! $module) { |
|
317 | + if (!$module) { |
|
318 | 318 | $module = new PbxExtensionModules(); |
319 | 319 | $module->name = $this->locString("SubHeader{$this->module_uniqid}"); |
320 | 320 | $module->disabled = '1'; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $language = substr(PbxSettings::getValueByKey('PBXLanguage'), 0, 2); |
341 | 341 | $translates = []; |
342 | 342 | $extensionsTranslates = [[]]; |
343 | - $results = glob($this->moduleDir . '/{messages}/en.php', GLOB_BRACE); |
|
343 | + $results = glob($this->moduleDir.'/{messages}/en.php', GLOB_BRACE); |
|
344 | 344 | foreach ($results as $path) { |
345 | 345 | $langArr = require $path; |
346 | 346 | if (is_array($langArr)) { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | if ($language !== 'en') { |
354 | 354 | $additionalTranslates = [[]]; |
355 | - $results = glob($this->moduleDir . "/{messages}/{$language}.php", GLOB_BRACE); |
|
355 | + $results = glob($this->moduleDir."/{messages}/{$language}.php", GLOB_BRACE); |
|
356 | 356 | foreach ($results as $path) { |
357 | 357 | $langArr = require $path; |
358 | 358 | if (is_array($langArr)) { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | protected function createSettingsTableByModelsAnnotations(): bool |
381 | 381 | { |
382 | 382 | $result = true; |
383 | - $results = glob($this->moduleDir . '/Models/*.php', GLOB_NOSORT); |
|
383 | + $results = glob($this->moduleDir.'/Models/*.php', GLOB_NOSORT); |
|
384 | 384 | foreach ($results as $file) { |
385 | 385 | $className = pathinfo($file)['filename']; |
386 | 386 | $moduleModelClass = "\\Modules\\{$this->module_uniqid}\\Models\\{$className}"; |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $tableName = $model->getSource(); |
463 | 463 | $this->moduleDB->begin(); |
464 | 464 | |
465 | - if ( ! $this->moduleDB->tableExists($tableName)) { |
|
465 | + if (!$this->moduleDB->tableExists($tableName)) { |
|
466 | 466 | $result = $this->moduleDB->createTable($tableName, null, $columnsNew); |
467 | 467 | } else { // Таблица существует, создадим новую и скопируем данные, чтобы не думать про новые, старые колонки |
468 | 468 | |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | } |
478 | 478 | |
479 | 479 | $aquery = ' |
480 | - CREATE TEMPORARY TABLE ' . $tableName . '_backup(' . implode(',', $currentStateColumnList) . '); |
|
481 | - INSERT INTO ' . $tableName . '_backup SELECT ' . implode(',', |
|
482 | - $currentStateColumnList) . ' FROM ' . $tableName . '; |
|
483 | - DROP TABLE ' . $tableName . ';'; |
|
480 | + CREATE TEMPORARY TABLE ' . $tableName.'_backup('.implode(',', $currentStateColumnList).'); |
|
481 | + INSERT INTO ' . $tableName.'_backup SELECT '.implode(',', |
|
482 | + $currentStateColumnList).' FROM '.$tableName.'; |
|
483 | + DROP TABLE ' . $tableName.';'; |
|
484 | 484 | $result = $result && $this->moduleDB->execute($aquery); |
485 | 485 | |
486 | 486 | $result = $result && $this->moduleDB->createTable($tableName, null, $columnsNew); |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $newColumnNames = array_intersect($newColNames, $oldColNames); |
489 | 489 | |
490 | 490 | $result = $result && $this->moduleDB->execute(' |
491 | - INSERT INTO ' . $tableName . '(' . implode(',', $newColumnNames) . ') |
|
492 | - SELECT ' . implode(',', $newColumnNames) . ' FROM ' . $tableName . '_backup; |
|
491 | + INSERT INTO ' . $tableName.'('.implode(',', $newColumnNames).') |
|
492 | + SELECT ' . implode(',', $newColumnNames).' FROM '.$tableName.'_backup; |
|
493 | 493 | '); |
494 | 494 | $result = $result && $this->moduleDB->execute(' |
495 | - DROP TABLE ' . $tableName . '_backup; |
|
495 | + DROP TABLE ' . $tableName.'_backup; |
|
496 | 496 | '); |
497 | 497 | } |
498 | 498 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | $columnsNew = ['columns' => $columns]; |
554 | 554 | $this->moduleDB->begin(); |
555 | 555 | |
556 | - if ( ! $this->moduleDB->tableExists($tableName)) { |
|
556 | + if (!$this->moduleDB->tableExists($tableName)) { |
|
557 | 557 | $result = $this->moduleDB->createTable($tableName, null, $columnsNew); |
558 | 558 | |
559 | 559 | } else { // Таблица существует, создадим новую и скопируем данные, чтобы не думать про новые, старые колонки |
@@ -569,10 +569,10 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | $aquery = ' |
572 | - CREATE TEMPORARY TABLE ' . $tableName . '_backup(' . implode(',', $currentStateColumnList) . '); |
|
573 | - INSERT INTO ' . $tableName . '_backup SELECT ' . implode(',', |
|
574 | - $currentStateColumnList) . ' FROM ' . $tableName . '; |
|
575 | - DROP TABLE ' . $tableName . ';'; |
|
572 | + CREATE TEMPORARY TABLE ' . $tableName.'_backup('.implode(',', $currentStateColumnList).'); |
|
573 | + INSERT INTO ' . $tableName.'_backup SELECT '.implode(',', |
|
574 | + $currentStateColumnList).' FROM '.$tableName.'; |
|
575 | + DROP TABLE ' . $tableName.';'; |
|
576 | 576 | $result = $result && $this->moduleDB->execute($aquery); |
577 | 577 | |
578 | 578 | $result = $result && $this->moduleDB->createTable($tableName, null, $columnsNew); |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | $newColumnNames = array_intersect($newColNames, $oldColNames); |
581 | 581 | |
582 | 582 | $result = $result && $this->moduleDB->execute(' |
583 | - INSERT INTO ' . $tableName . '(' . implode(',', $newColumnNames) . ') |
|
584 | - SELECT ' . implode(',', $newColumnNames) . ' FROM ' . $tableName . '_backup; |
|
583 | + INSERT INTO ' . $tableName.'('.implode(',', $newColumnNames).') |
|
584 | + SELECT ' . implode(',', $newColumnNames).' FROM '.$tableName.'_backup; |
|
585 | 585 | '); |
586 | 586 | $result = $result && $this->moduleDB->execute(' |
587 | - DROP TABLE ' . $tableName . '_backup; |
|
587 | + DROP TABLE ' . $tableName.'_backup; |
|
588 | 588 | '); |
589 | 589 | |
590 | 590 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $menuSettingsKey = "AdditionalMenuItem{$this->module_uniqid}"; |
661 | 661 | $unCamelizedControllerName = Text::uncamelize($this->module_uniqid, '-'); |
662 | 662 | $menuSettings = PbxSettings::findFirstByKey($menuSettingsKey); |
663 | - if (!$menuSettings){ |
|
663 | + if (!$menuSettings) { |
|
664 | 664 | $menuSettings = new PbxSettings(); |
665 | 665 | $menuSettings->key = $menuSettingsKey; |
666 | 666 | } |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | $module = PbxExtensionModules::findFirst("uniqid='{$this->module_uniqid}'"); |
317 | 317 | if ( ! $module) { |
318 | 318 | $module = new PbxExtensionModules(); |
319 | - $module->name = $this->locString("SubHeader{$this->module_uniqid}"); |
|
319 | + $module->name = $this->locString("subheader{$this->module_uniqid}"); |
|
320 | 320 | $module->disabled = '1'; |
321 | 321 | } |
322 | 322 | $module->uniqid = $this->module_uniqid; |
323 | 323 | $module->developer = $this->developer; |
324 | 324 | $module->version = $this->version; |
325 | - $module->description = $this->locString("Breadcrumb{$this->module_uniqid}"); |
|
325 | + $module->description = $this->locString("breadcrumb{$this->module_uniqid}"); |
|
326 | 326 | $module->support_email = $this->support_email; |
327 | 327 | |
328 | 328 | return $module->save(); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | protected function addToSidebar(): bool |
659 | 659 | { |
660 | - $menuSettingsKey = "AdditionalMenuItem{$this->module_uniqid}"; |
|
660 | + $menuSettingsKey = "additionalmenuitem{$this->module_uniqid}"; |
|
661 | 661 | $unCamelizedControllerName = Text::uncamelize($this->module_uniqid, '-'); |
662 | 662 | $menuSettings = PbxSettings::findFirstByKey($menuSettingsKey); |
663 | 663 | if (!$menuSettings){ |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | 'href'=>"/admin-cabinet/$unCamelizedControllerName", |
670 | 670 | 'group'=>'maintenance', |
671 | 671 | 'iconClass'=>'puzzle', |
672 | - 'caption'=>"Breadcrumb$this->module_uniqid", |
|
672 | + 'caption'=>"breadcrumb$this->module_uniqid", |
|
673 | 673 | 'showAtSidebar'=>true, |
674 | 674 | ]; |
675 | 675 | $menuSettings->value = json_encode($value); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | require_once 'globals.php'; |
12 | 12 | require_once 'Nats/autoloader.php'; |
13 | 13 | |
14 | -class CDR_Data{ |
|
14 | +class CDR_Data { |
|
15 | 15 | private $callback; |
16 | 16 | private $vars; |
17 | 17 | private $exten = NULL; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | $this->callback = function($message) { |
28 | 28 | $this->q_done($message); |
29 | 29 | }; |
30 | - if(count($argv)==1){ |
|
30 | + if (count($argv) == 1) { |
|
31 | 31 | require_once('phpagi.php'); |
32 | 32 | $AGI_class_name = 'AGI'; |
33 | - }else{ |
|
33 | + } else { |
|
34 | 34 | $this->exten = $argv[1]; |
35 | 35 | define('PT1C_SKRIPTNAME', $this->exten); |
36 | 36 | require_once('phpagi-debug.php'); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | $this->agi = new $AGI_class_name(); |
42 | - if($this->exten == NULL){ |
|
42 | + if ($this->exten == NULL) { |
|
43 | 43 | $this->exten = $this->agi->request['agi_extension']; |
44 | 44 | } |
45 | 45 | $this->get_vars(); |
@@ -52,34 +52,34 @@ discard block |
||
52 | 52 | * Отправка ивента. |
53 | 53 | * @param $options |
54 | 54 | */ |
55 | - private function UserEvent($options){ |
|
55 | + private function UserEvent($options) { |
|
56 | 56 | $this->agi->exec("UserEvent", $options); |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Получение переменных канала. Параметры запроса. |
61 | 61 | */ |
62 | - private function get_vars(){ |
|
63 | - if('10000555' == $this->exten){ |
|
62 | + private function get_vars() { |
|
63 | + if ('10000555' == $this->exten) { |
|
64 | 64 | $this->vars['chan'] = $this->agi->get_variable("v1", true); |
65 | 65 | $this->vars['date1'] = $this->agi->get_variable("v2", true); |
66 | 66 | $this->vars['date2'] = $this->agi->get_variable("v3", true); |
67 | 67 | |
68 | - $numbers = explode("-", $this->agi->get_variable("v4", true) ); |
|
69 | - $this->vars['numbers']= $numbers; |
|
70 | - }else if('10000666' == $this->exten){ |
|
68 | + $numbers = explode("-", $this->agi->get_variable("v4", true)); |
|
69 | + $this->vars['numbers'] = $numbers; |
|
70 | + } else if ('10000666' == $this->exten) { |
|
71 | 71 | $this->vars['chan'] = $this->agi->get_variable("v1", true); |
72 | 72 | $this->vars['id'] = $this->agi->get_variable("v2", true); |
73 | 73 | $this->vars['recfile'] = $this->agi->get_variable("v6", true); |
74 | - }else if('10000777' == $this->exten){ |
|
74 | + } else if ('10000777' == $this->exten) { |
|
75 | 75 | $this->vars['chan'] = $this->agi->get_variable("chan", true); |
76 | 76 | $this->vars['id'] = $this->agi->get_variable("uniqueid1c", true); |
77 | - }else if('10000111' == $this->exten){ |
|
78 | - $this->vars['chan'] = $this->agi->get_variable("v1", true); |
|
79 | - }else if('10000109' == $this->exten){ |
|
80 | - $this->vars['tehnology']= $this->agi->get_variable("tehnology", true); |
|
77 | + } else if ('10000111' == $this->exten) { |
|
78 | + $this->vars['chan'] = $this->agi->get_variable("v1", true); |
|
79 | + } else if ('10000109' == $this->exten) { |
|
80 | + $this->vars['tehnology'] = $this->agi->get_variable("tehnology", true); |
|
81 | 81 | $this->vars['number'] = $this->agi->get_variable("number", true); |
82 | - }else if('10000222' == $this->exten){ |
|
82 | + } else if ('10000222' == $this->exten) { |
|
83 | 83 | $this->vars['command'] = $this->agi->get_variable("command", true); |
84 | 84 | $this->vars['dbFamily'] = $this->agi->get_variable("dbFamily", true); |
85 | 85 | $this->vars['key'] = $this->agi->get_variable("key", true); |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | * @param $q_res_data |
95 | 95 | * @throws Exception |
96 | 96 | */ |
97 | - private function q_done($q_res_data){ |
|
98 | - if('10000555' == $this->exten) { |
|
97 | + private function q_done($q_res_data) { |
|
98 | + if ('10000555' == $this->exten) { |
|
99 | 99 | $res_data = json_decode($q_res_data, true); |
100 | 100 | $this->app_10000555($res_data); |
101 | - }else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
101 | + } else if ('10000666' == $this->exten || '10000777' == $this->exten) { |
|
102 | 102 | $res_data = json_decode($q_res_data, true); |
103 | 103 | $this->app_10000666_777($res_data); |
104 | - }else if('10000109' == $this->exten){ |
|
104 | + } else if ('10000109' == $this->exten) { |
|
105 | 105 | $res = Models\Extensions::findFirst("number='{$this->vars['number']}'"); |
106 | - $context = ($res != null)?'all_peers':''; |
|
106 | + $context = ($res != null) ? 'all_peers' : ''; |
|
107 | 107 | $this->UserEvent("GetContest,chan1c:{$this->vars['tehnology']}/{$this->vars['number']},peercontext:{$context}"); |
108 | - }else if('10000111' == $this->exten){ |
|
108 | + } else if ('10000111' == $this->exten) { |
|
109 | 109 | $stat = file_get_contents('/var/etc/http_auth'); |
110 | 110 | $this->UserEvent("AsteriskSettings,chan1c:{$this->vars['chan']},Statistic:{$stat},DefaultContext:all_peers,DialplanVer:1.0.0.6,usemp3player:1,autoanswernumber:*8"); |
111 | 111 | $this->GetHints(); |
112 | - }else if('10000222' == $this->exten){ |
|
112 | + } else if ('10000222' == $this->exten) { |
|
113 | 113 | $this->app_10000222(); |
114 | 114 | } |
115 | 115 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * Инициация запроса к NATS. |
119 | 119 | * @throws Exception |
120 | 120 | */ |
121 | - private function exec_query(){ |
|
121 | + private function exec_query() { |
|
122 | 122 | $miko_result_in_file = false; |
123 | - if('10000555' == $this->exten) { |
|
123 | + if ('10000555' == $this->exten) { |
|
124 | 124 | $miko_result_in_file = true; |
125 | 125 | $filter = [ |
126 | 126 | 'start BETWEEN :date1: AND :date2: AND (src_num IN ({numbers:array}) OR dst_num IN ({numbers:array}) )', |
@@ -142,35 +142,35 @@ discard block |
||
142 | 142 | ]; |
143 | 143 | $filter['add_pack_query'] = $add_query; |
144 | 144 | $filter['miko_result_in_file'] = $miko_result_in_file; |
145 | - }else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
145 | + } else if ('10000666' == $this->exten || '10000777' == $this->exten) { |
|
146 | 146 | $filter = [ |
147 | 147 | 'linkedid=:linkedid: AND recordingfile<>""', |
148 | - 'bind' => [ 'linkedid' => $this->vars['id'] ], |
|
148 | + 'bind' => ['linkedid' => $this->vars['id']], |
|
149 | 149 | 'limit' => 10, |
150 | 150 | 'columns' => 'recordingfile' |
151 | 151 | ]; |
152 | - }else if('10000111' == $this->exten || '10000109' == $this->exten || '10000222' == $this->exten){ |
|
152 | + } else if ('10000111' == $this->exten || '10000109' == $this->exten || '10000222' == $this->exten) { |
|
153 | 153 | $this->q_done(null); |
154 | 154 | return; |
155 | - }else{ |
|
155 | + } else { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | 159 | $client = new BeanstalkClient('select_cdr'); |
160 | 160 | $message = $client->request(json_encode($filter), 2); |
161 | - if($message == false){ |
|
161 | + if ($message == false) { |
|
162 | 162 | Util::sys_log_msg('miko_ajam', "Error get data from queue 'select_cdr'. "); |
163 | 163 | $this->q_done("[]"); |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | $result_data = "[]"; |
166 | 166 | $result = $client->getBody(); |
167 | - if($miko_result_in_file){ |
|
167 | + if ($miko_result_in_file) { |
|
168 | 168 | $filename = json_decode($result); |
169 | - if(file_exists($filename) ){ |
|
169 | + if (file_exists($filename)) { |
|
170 | 170 | $result_data = file_get_contents($filename); |
171 | 171 | unlink($filename); |
172 | 172 | } |
173 | - }elseif(!$miko_result_in_file){ |
|
173 | + }elseif (!$miko_result_in_file) { |
|
174 | 174 | $result_data = $result; |
175 | 175 | } |
176 | 176 | $this->q_done($result_data); |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | $arr_hints = []; |
186 | 186 | $context = 'internal-hints'; |
187 | 187 | exec("asterisk -rx\"core show hints\" | grep -v egistered | grep State | awk -F'([ ]*[:]?[ ]+)|@' ' {print $1\"@{$context}\" \"@.@\" $3 \"@.@\" $4 } '", $arr_hints); |
188 | - $result = ''; $count = 1; |
|
189 | - foreach ($arr_hints as $hint_row){ |
|
190 | - if($count >= 10){ |
|
188 | + $result = ''; $count = 1; |
|
189 | + foreach ($arr_hints as $hint_row) { |
|
190 | + if ($count >= 10) { |
|
191 | 191 | $this->UserEvent("RowsHint,chan1c:{$this->vars['chan']},Lines:{$result}"); |
192 | 192 | $result = ''; $count = 1; |
193 | 193 | } |
194 | 194 | $result .= trim($hint_row).'.....'; |
195 | 195 | $count++; |
196 | 196 | } |
197 | - if($result!==''){ |
|
197 | + if ($result !== '') { |
|
198 | 198 | $this->UserEvent("RowsHint,chan1c:{$this->vars['chan']},Lines:{$result}"); |
199 | 199 | } |
200 | 200 | $this->UserEvent("HintsEnd,chan1c:{$this->vars['chan']}"); |
@@ -203,51 +203,51 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * Работа со статусами в astdb. |
205 | 205 | */ |
206 | - private function app_10000222(){ |
|
206 | + private function app_10000222() { |
|
207 | 207 | $commands = ['CF', 'UserBuddyStatus', 'DND']; |
208 | - if(!in_array($this->vars['dbFamily'], $commands)){ |
|
208 | + if (!in_array($this->vars['dbFamily'], $commands)) { |
|
209 | 209 | $this->UserEvent("DB_ERR,user:{$this->vars['key']},status:{$this->vars['val']}"); |
210 | - }elseif( $this->vars['command'] =='get' ){ |
|
210 | + }elseif ($this->vars['command'] == 'get') { |
|
211 | 211 | // Получение статуса конкретного пользователя |
212 | 212 | $ret = $this->agi->evaluate("DATABASE GET {$this->vars['dbFamily']} {$this->vars['key']}"); |
213 | - if($ret['result']==1&&$ret['code']==200){ |
|
213 | + if ($ret['result'] == 1 && $ret['code'] == 200) { |
|
214 | 214 | // Успех выполнения операции |
215 | 215 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$ret['data']}"); |
216 | - }else{ |
|
216 | + } else { |
|
217 | 217 | // Не установлена! |
218 | 218 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:"); |
219 | 219 | } |
220 | - }elseif($this->vars['command']=='put'){ |
|
221 | - if($this->vars['val']==''){ |
|
220 | + }elseif ($this->vars['command'] == 'put') { |
|
221 | + if ($this->vars['val'] == '') { |
|
222 | 222 | $ret = $this->agi->evaluate("DATABASE DEL {$this->vars['dbFamily']} {$this->vars['key']}"); |
223 | - }else{ |
|
223 | + } else { |
|
224 | 224 | // Установка статуса |
225 | 225 | $ret = $this->agi->evaluate("DATABASE PUT {$this->vars['dbFamily']} {$this->vars['key']} {$this->vars['val']}"); |
226 | 226 | } |
227 | - if($ret['result']==1&&$ret['code']==200){ |
|
227 | + if ($ret['result'] == 1 && $ret['code'] == 200) { |
|
228 | 228 | // Успех выполнения операции |
229 | 229 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$this->vars['val']}"); |
230 | - }else{ |
|
230 | + } else { |
|
231 | 231 | // Были ошибки |
232 | 232 | $this->UserEvent("Error_data_put_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$this->vars['val']}"); |
233 | 233 | } |
234 | - }elseif($this->vars['command']=='show'){ |
|
234 | + }elseif ($this->vars['command'] == 'show') { |
|
235 | 235 | $output = array(); |
236 | - $result =''; |
|
236 | + $result = ''; |
|
237 | 237 | |
238 | 238 | // Получение статустов всех пользователей |
239 | 239 | $dbFamily = escapeshellcmd($this->vars['dbFamily']); |
240 | - Util::mwexec('asterisk -rx"database show '.$dbFamily.'" | grep /',$output); |
|
240 | + Util::mwexec('asterisk -rx"database show '.$dbFamily.'" | grep /', $output); |
|
241 | 241 | $ch = 0; |
242 | 242 | // Обходим файл построчно |
243 | - foreach($output as $_data){ |
|
243 | + foreach ($output as $_data) { |
|
244 | 244 | // Набор символов - разделитель строк |
245 | - if(! $result=="") $result = $result."....."; |
|
245 | + if (!$result == "") $result = $result."....."; |
|
246 | 246 | |
247 | 247 | $_data = str_replace('/UserBuddyStatus/', '', $_data); |
248 | 248 | |
249 | 249 | $arr_data = explode(':', $_data); |
250 | - if(count($arr_data) <> 2){ |
|
250 | + if (count($arr_data) <> 2) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | $key = trim($arr_data[0]); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $result = $result."$key@.@$val"; |
261 | 261 | |
262 | 262 | // Если необходимо отправляем данные порциями |
263 | - if($ch == 20){ |
|
263 | + if ($ch == 20) { |
|
264 | 264 | // Отправляем данные в 1С, обнуляем буфер |
265 | 265 | $this->UserEvent("From{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
266 | 266 | $result = ""; $ch = 1; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $ch = $ch + 1; |
269 | 269 | } |
270 | 270 | // Проверяем, есть ли остаток данных для отправки |
271 | - if(!$result == ""){ |
|
271 | + if (!$result == "") { |
|
272 | 272 | $this->UserEvent("From{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
273 | 273 | } |
274 | 274 | } |
@@ -279,34 +279,34 @@ discard block |
||
279 | 279 | * @param $res_data |
280 | 280 | * @throws Exception |
281 | 281 | */ |
282 | - private function app_10000555($res_data){ |
|
283 | - $fields = [ 'start','src_num','dst_num','src_chan', |
|
284 | - 'dst_chan','billsec','disposition','UNIQUEID','recordingfile', |
|
285 | - 'v1','appname','linkedid','did']; |
|
282 | + private function app_10000555($res_data) { |
|
283 | + $fields = ['start', 'src_num', 'dst_num', 'src_chan', |
|
284 | + 'dst_chan', 'billsec', 'disposition', 'UNIQUEID', 'recordingfile', |
|
285 | + 'v1', 'appname', 'linkedid', 'did']; |
|
286 | 286 | $result = ""; $ch = 0; |
287 | - foreach ($res_data as $_data){ |
|
288 | - $result .= ($result=="")?"":"....."; |
|
289 | - foreach ($fields as $key){ |
|
290 | - if('start' == $key){ |
|
287 | + foreach ($res_data as $_data) { |
|
288 | + $result .= ($result == "") ? "" : "....."; |
|
289 | + foreach ($fields as $key) { |
|
290 | + if ('start' == $key) { |
|
291 | 291 | $d = new DateTime($_data[$key]); |
292 | 292 | $_field = $d->format("Y-m-d H:i:s"); |
293 | 293 | $field = trim(str_replace(" ", '\ ', $_field)); |
294 | - }else if(isset($_data[$key])){ |
|
294 | + } else if (isset($_data[$key])) { |
|
295 | 295 | $field = trim(str_replace(" ", '\ ', $_data[$key])); |
296 | - }else if('appname' == $key){ |
|
296 | + } else if ('appname' == $key) { |
|
297 | 297 | $field = 'Dial'; |
298 | - }else{ |
|
298 | + } else { |
|
299 | 299 | $field = ''; |
300 | 300 | } |
301 | - $result.=$field.'@.@'; |
|
301 | + $result .= $field.'@.@'; |
|
302 | 302 | } |
303 | 303 | $ch = $ch + 1; |
304 | - if($ch >= 7){ |
|
304 | + if ($ch >= 7) { |
|
305 | 305 | $this->UserEvent("FromCDR,chan1c:{$this->vars['chan']},Date:{$this->vars['date1']},Lines:$result"); |
306 | 306 | $result = ""; $ch = 0; |
307 | 307 | } |
308 | 308 | } |
309 | - if(!$result == ""){ |
|
309 | + if (!$result == "") { |
|
310 | 310 | $this->UserEvent("FromCDR,chan1c:{$this->vars['chan']},Date:{$this->vars['date1']},Lines:$result"); |
311 | 311 | } |
312 | 312 | $this->UserEvent("Refresh1CHistory,chan1c:{$this->vars['chan']},Date:{$this->vars['date1']}"); |
@@ -316,27 +316,27 @@ discard block |
||
316 | 316 | * Обработка запроса скачивания / прослушивания. |
317 | 317 | * @param $res_data |
318 | 318 | */ |
319 | - private function app_10000666_777($res_data){ |
|
319 | + private function app_10000666_777($res_data) { |
|
320 | 320 | $search_file = ''; |
321 | - foreach ($res_data as $ar_str){ |
|
322 | - if(Util::rec_file_exists($ar_str['recordingfile'])){ |
|
323 | - $search_file.=($search_file=="")?'':"@.@"; |
|
324 | - $search_file.= $ar_str['recordingfile']; |
|
321 | + foreach ($res_data as $ar_str) { |
|
322 | + if (Util::rec_file_exists($ar_str['recordingfile'])) { |
|
323 | + $search_file .= ($search_file == "") ? '' : "@.@"; |
|
324 | + $search_file .= $ar_str['recordingfile']; |
|
325 | 325 | } |
326 | 326 | } |
327 | - if($search_file == ''){ |
|
327 | + if ($search_file == '') { |
|
328 | 328 | $search_file = $this->old_10000666_777($this->vars['id']); |
329 | 329 | } |
330 | - if($search_file != ''){ |
|
331 | - if('10000777' == $this->exten){ |
|
330 | + if ($search_file != '') { |
|
331 | + if ('10000777' == $this->exten) { |
|
332 | 332 | $event = 'CallRecord'; |
333 | - }else{ |
|
333 | + } else { |
|
334 | 334 | $event = 'StartDownloadRecord'; |
335 | 335 | } |
336 | 336 | $path = "80/pbxcore/api/cdr/records?view="; |
337 | 337 | $response = "{$event},chan1c:{$this->vars['chan']},fPath:{$path},FileName:{$search_file},uniqueid1c:{$this->vars['id']}"; |
338 | - }else{ |
|
339 | - $event = ('10000777' == $this->exten)?'CallRecordFail':'FailDownloadRecord'; |
|
338 | + } else { |
|
339 | + $event = ('10000777' == $this->exten) ? 'CallRecordFail' : 'FailDownloadRecord'; |
|
340 | 340 | |
341 | 341 | $response = "{$event},chan1c:{$this->vars['chan']},uniqueid1c:{$this->vars['id']}"; |
342 | 342 | } |
@@ -349,36 +349,36 @@ discard block |
||
349 | 349 | * @param $id |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - private function old_10000666_777($id){ |
|
353 | - if(!file_exists('/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php')) return ''; |
|
352 | + private function old_10000666_777($id) { |
|
353 | + if (!file_exists('/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php')) return ''; |
|
354 | 354 | $settings = include "/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php"; |
355 | 355 | $host = $settings['host']; |
356 | 356 | $res = $settings['res']; |
357 | - $auth = $settings['auth'];; |
|
357 | + $auth = $settings['auth']; ; |
|
358 | 358 | |
359 | - $zapros ="SELECT"." recordingfile FROM cdr WHERE linkedid = \"{$id}\" GROUP BY recordingfile"; |
|
360 | - $output = array(); |
|
359 | + $zapros = "SELECT"." recordingfile FROM cdr WHERE linkedid = \"{$id}\" GROUP BY recordingfile"; |
|
360 | + $output = array(); |
|
361 | 361 | $cdr_db = dirname(Cdr::getPathToDB()).'/master.db'; |
362 | - if(!file_exists($cdr_db)){ |
|
362 | + if (!file_exists($cdr_db)) { |
|
363 | 363 | return ''; |
364 | 364 | } |
365 | - exec("sqlite3 '$cdr_db' '{$zapros}'",$output); |
|
365 | + exec("sqlite3 '$cdr_db' '{$zapros}'", $output); |
|
366 | 366 | $arr_files = array(); |
367 | - foreach($output as $_data){ |
|
368 | - if(empty($_data)) continue; |
|
367 | + foreach ($output as $_data) { |
|
368 | + if (empty($_data)) continue; |
|
369 | 369 | $fname = "{$_data}.mp3"; |
370 | - if(in_array($fname, $arr_files)) { |
|
370 | + if (in_array($fname, $arr_files)) { |
|
371 | 371 | // Файл уже обработали ранее успешно. |
372 | 372 | continue; |
373 | 373 | } |
374 | - if(file_exists("{$fname}.empty")){ |
|
374 | + if (file_exists("{$fname}.empty")) { |
|
375 | 375 | // Уже пытались скачать файл. Файл не найден на другой АТС. |
376 | 376 | continue; |
377 | 377 | } |
378 | - if(!file_exists($fname)){ |
|
378 | + if (!file_exists($fname)) { |
|
379 | 379 | exec("mkdir -p ".dirname($_data)); |
380 | 380 | exec("curl -s -f 'http://{$host}:23600{$res}{$_data}' -u {$auth} -I", $curl_output); |
381 | - if(stripos(implode('',$curl_output), 'attachment;') === FALSE){ |
|
381 | + if (stripos(implode('', $curl_output), 'attachment;') === FALSE) { |
|
382 | 382 | file_put_contents("{$fname}.empty", ''); |
383 | 383 | continue; |
384 | 384 | } |
@@ -386,12 +386,12 @@ discard block |
||
386 | 386 | } |
387 | 387 | $arr_files[] = $fname; |
388 | 388 | } |
389 | - return implode("@.@",$arr_files); |
|
389 | + return implode("@.@", $arr_files); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | -try{ |
|
393 | +try { |
|
394 | 394 | $d = new CDR_Data($argv); |
395 | -}catch (Exception $e){ |
|
395 | +} catch (Exception $e) { |
|
396 | 396 | Util::sys_log_msg('miko_ajam', $e->getMessage()); |
397 | 397 | } |
398 | 398 | \ No newline at end of file |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | require_once 'globals.php'; |
12 | 12 | require_once 'Nats/autoloader.php'; |
13 | 13 | |
14 | -class CDR_Data{ |
|
14 | +class CDR_Data |
|
15 | +{ |
|
15 | 16 | private $callback; |
16 | 17 | private $vars; |
17 | 18 | private $exten = NULL; |
@@ -23,14 +24,16 @@ discard block |
||
23 | 24 | * @param $argv |
24 | 25 | * @throws Exception |
25 | 26 | */ |
26 | - function __construct($argv) { |
|
27 | - $this->callback = function($message) { |
|
27 | + function __construct($argv) |
|
28 | + { |
|
29 | + $this->callback = function($message) |
|
30 | + { |
|
28 | 31 | $this->q_done($message); |
29 | 32 | }; |
30 | 33 | if(count($argv)==1){ |
31 | 34 | require_once('phpagi.php'); |
32 | 35 | $AGI_class_name = 'AGI'; |
33 | - }else{ |
|
36 | + } else{ |
|
34 | 37 | $this->exten = $argv[1]; |
35 | 38 | define('PT1C_SKRIPTNAME', $this->exten); |
36 | 39 | require_once('phpagi-debug.php'); |
@@ -52,14 +55,16 @@ discard block |
||
52 | 55 | * Отправка ивента. |
53 | 56 | * @param $options |
54 | 57 | */ |
55 | - private function UserEvent($options){ |
|
58 | + private function UserEvent($options) |
|
59 | + { |
|
56 | 60 | $this->agi->exec("UserEvent", $options); |
57 | 61 | } |
58 | 62 | |
59 | 63 | /** |
60 | 64 | * Получение переменных канала. Параметры запроса. |
61 | 65 | */ |
62 | - private function get_vars(){ |
|
66 | + private function get_vars() |
|
67 | + { |
|
63 | 68 | if('10000555' == $this->exten){ |
64 | 69 | $this->vars['chan'] = $this->agi->get_variable("v1", true); |
65 | 70 | $this->vars['date1'] = $this->agi->get_variable("v2", true); |
@@ -67,19 +72,19 @@ discard block |
||
67 | 72 | |
68 | 73 | $numbers = explode("-", $this->agi->get_variable("v4", true) ); |
69 | 74 | $this->vars['numbers']= $numbers; |
70 | - }else if('10000666' == $this->exten){ |
|
75 | + } else if('10000666' == $this->exten){ |
|
71 | 76 | $this->vars['chan'] = $this->agi->get_variable("v1", true); |
72 | 77 | $this->vars['id'] = $this->agi->get_variable("v2", true); |
73 | 78 | $this->vars['recfile'] = $this->agi->get_variable("v6", true); |
74 | - }else if('10000777' == $this->exten){ |
|
79 | + } else if('10000777' == $this->exten){ |
|
75 | 80 | $this->vars['chan'] = $this->agi->get_variable("chan", true); |
76 | 81 | $this->vars['id'] = $this->agi->get_variable("uniqueid1c", true); |
77 | - }else if('10000111' == $this->exten){ |
|
82 | + } else if('10000111' == $this->exten){ |
|
78 | 83 | $this->vars['chan'] = $this->agi->get_variable("v1", true); |
79 | - }else if('10000109' == $this->exten){ |
|
84 | + } else if('10000109' == $this->exten){ |
|
80 | 85 | $this->vars['tehnology']= $this->agi->get_variable("tehnology", true); |
81 | 86 | $this->vars['number'] = $this->agi->get_variable("number", true); |
82 | - }else if('10000222' == $this->exten){ |
|
87 | + } else if('10000222' == $this->exten){ |
|
83 | 88 | $this->vars['command'] = $this->agi->get_variable("command", true); |
84 | 89 | $this->vars['dbFamily'] = $this->agi->get_variable("dbFamily", true); |
85 | 90 | $this->vars['key'] = $this->agi->get_variable("key", true); |
@@ -94,22 +99,23 @@ discard block |
||
94 | 99 | * @param $q_res_data |
95 | 100 | * @throws Exception |
96 | 101 | */ |
97 | - private function q_done($q_res_data){ |
|
102 | + private function q_done($q_res_data) |
|
103 | + { |
|
98 | 104 | if('10000555' == $this->exten) { |
99 | 105 | $res_data = json_decode($q_res_data, true); |
100 | 106 | $this->app_10000555($res_data); |
101 | - }else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
107 | + } else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
102 | 108 | $res_data = json_decode($q_res_data, true); |
103 | 109 | $this->app_10000666_777($res_data); |
104 | - }else if('10000109' == $this->exten){ |
|
110 | + } else if('10000109' == $this->exten){ |
|
105 | 111 | $res = Models\Extensions::findFirst("number='{$this->vars['number']}'"); |
106 | 112 | $context = ($res != null)?'all_peers':''; |
107 | 113 | $this->UserEvent("GetContest,chan1c:{$this->vars['tehnology']}/{$this->vars['number']},peercontext:{$context}"); |
108 | - }else if('10000111' == $this->exten){ |
|
114 | + } else if('10000111' == $this->exten){ |
|
109 | 115 | $stat = file_get_contents('/var/etc/http_auth'); |
110 | 116 | $this->UserEvent("AsteriskSettings,chan1c:{$this->vars['chan']},Statistic:{$stat},DefaultContext:all_peers,DialplanVer:1.0.0.6,usemp3player:1,autoanswernumber:*8"); |
111 | 117 | $this->GetHints(); |
112 | - }else if('10000222' == $this->exten){ |
|
118 | + } else if('10000222' == $this->exten){ |
|
113 | 119 | $this->app_10000222(); |
114 | 120 | } |
115 | 121 | } |
@@ -118,7 +124,8 @@ discard block |
||
118 | 124 | * Инициация запроса к NATS. |
119 | 125 | * @throws Exception |
120 | 126 | */ |
121 | - private function exec_query(){ |
|
127 | + private function exec_query() |
|
128 | + { |
|
122 | 129 | $miko_result_in_file = false; |
123 | 130 | if('10000555' == $this->exten) { |
124 | 131 | $miko_result_in_file = true; |
@@ -142,17 +149,17 @@ discard block |
||
142 | 149 | ]; |
143 | 150 | $filter['add_pack_query'] = $add_query; |
144 | 151 | $filter['miko_result_in_file'] = $miko_result_in_file; |
145 | - }else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
152 | + } else if('10000666' == $this->exten || '10000777' == $this->exten ){ |
|
146 | 153 | $filter = [ |
147 | 154 | 'linkedid=:linkedid: AND recordingfile<>""', |
148 | 155 | 'bind' => [ 'linkedid' => $this->vars['id'] ], |
149 | 156 | 'limit' => 10, |
150 | 157 | 'columns' => 'recordingfile' |
151 | 158 | ]; |
152 | - }else if('10000111' == $this->exten || '10000109' == $this->exten || '10000222' == $this->exten){ |
|
159 | + } else if('10000111' == $this->exten || '10000109' == $this->exten || '10000222' == $this->exten){ |
|
153 | 160 | $this->q_done(null); |
154 | 161 | return; |
155 | - }else{ |
|
162 | + } else{ |
|
156 | 163 | return; |
157 | 164 | } |
158 | 165 | |
@@ -161,7 +168,7 @@ discard block |
||
161 | 168 | if($message == false){ |
162 | 169 | Util::sys_log_msg('miko_ajam', "Error get data from queue 'select_cdr'. "); |
163 | 170 | $this->q_done("[]"); |
164 | - }else{ |
|
171 | + } else{ |
|
165 | 172 | $result_data = "[]"; |
166 | 173 | $result = $client->getBody(); |
167 | 174 | if($miko_result_in_file){ |
@@ -170,7 +177,7 @@ discard block |
||
170 | 177 | $result_data = file_get_contents($filename); |
171 | 178 | unlink($filename); |
172 | 179 | } |
173 | - }elseif(!$miko_result_in_file){ |
|
180 | + } elseif(!$miko_result_in_file){ |
|
174 | 181 | $result_data = $result; |
175 | 182 | } |
176 | 183 | $this->q_done($result_data); |
@@ -203,35 +210,36 @@ discard block |
||
203 | 210 | /** |
204 | 211 | * Работа со статусами в astdb. |
205 | 212 | */ |
206 | - private function app_10000222(){ |
|
213 | + private function app_10000222() |
|
214 | + { |
|
207 | 215 | $commands = ['CF', 'UserBuddyStatus', 'DND']; |
208 | 216 | if(!in_array($this->vars['dbFamily'], $commands)){ |
209 | 217 | $this->UserEvent("DB_ERR,user:{$this->vars['key']},status:{$this->vars['val']}"); |
210 | - }elseif( $this->vars['command'] =='get' ){ |
|
218 | + } elseif( $this->vars['command'] =='get' ){ |
|
211 | 219 | // Получение статуса конкретного пользователя |
212 | 220 | $ret = $this->agi->evaluate("DATABASE GET {$this->vars['dbFamily']} {$this->vars['key']}"); |
213 | 221 | if($ret['result']==1&&$ret['code']==200){ |
214 | 222 | // Успех выполнения операции |
215 | 223 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$ret['data']}"); |
216 | - }else{ |
|
224 | + } else{ |
|
217 | 225 | // Не установлена! |
218 | 226 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:"); |
219 | 227 | } |
220 | - }elseif($this->vars['command']=='put'){ |
|
228 | + } elseif($this->vars['command']=='put'){ |
|
221 | 229 | if($this->vars['val']==''){ |
222 | 230 | $ret = $this->agi->evaluate("DATABASE DEL {$this->vars['dbFamily']} {$this->vars['key']}"); |
223 | - }else{ |
|
231 | + } else{ |
|
224 | 232 | // Установка статуса |
225 | 233 | $ret = $this->agi->evaluate("DATABASE PUT {$this->vars['dbFamily']} {$this->vars['key']} {$this->vars['val']}"); |
226 | 234 | } |
227 | 235 | if($ret['result']==1&&$ret['code']==200){ |
228 | 236 | // Успех выполнения операции |
229 | 237 | $this->UserEvent("DB_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$this->vars['val']}"); |
230 | - }else{ |
|
238 | + } else{ |
|
231 | 239 | // Были ошибки |
232 | 240 | $this->UserEvent("Error_data_put_{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},key:{$this->vars['key']},val:{$this->vars['val']}"); |
233 | 241 | } |
234 | - }elseif($this->vars['command']=='show'){ |
|
242 | + } elseif($this->vars['command']=='show'){ |
|
235 | 243 | $output = array(); |
236 | 244 | $result =''; |
237 | 245 | |
@@ -242,7 +250,9 @@ discard block |
||
242 | 250 | // Обходим файл построчно |
243 | 251 | foreach($output as $_data){ |
244 | 252 | // Набор символов - разделитель строк |
245 | - if(! $result=="") $result = $result."....."; |
|
253 | + if(! $result=="") { |
|
254 | + $result = $result."....."; |
|
255 | + } |
|
246 | 256 | |
247 | 257 | $_data = str_replace('/UserBuddyStatus/', '', $_data); |
248 | 258 | |
@@ -279,7 +289,8 @@ discard block |
||
279 | 289 | * @param $res_data |
280 | 290 | * @throws Exception |
281 | 291 | */ |
282 | - private function app_10000555($res_data){ |
|
292 | + private function app_10000555($res_data) |
|
293 | + { |
|
283 | 294 | $fields = [ 'start','src_num','dst_num','src_chan', |
284 | 295 | 'dst_chan','billsec','disposition','UNIQUEID','recordingfile', |
285 | 296 | 'v1','appname','linkedid','did']; |
@@ -291,11 +302,11 @@ discard block |
||
291 | 302 | $d = new DateTime($_data[$key]); |
292 | 303 | $_field = $d->format("Y-m-d H:i:s"); |
293 | 304 | $field = trim(str_replace(" ", '\ ', $_field)); |
294 | - }else if(isset($_data[$key])){ |
|
305 | + } else if(isset($_data[$key])){ |
|
295 | 306 | $field = trim(str_replace(" ", '\ ', $_data[$key])); |
296 | - }else if('appname' == $key){ |
|
307 | + } else if('appname' == $key){ |
|
297 | 308 | $field = 'Dial'; |
298 | - }else{ |
|
309 | + } else{ |
|
299 | 310 | $field = ''; |
300 | 311 | } |
301 | 312 | $result.=$field.'@.@'; |
@@ -316,7 +327,8 @@ discard block |
||
316 | 327 | * Обработка запроса скачивания / прослушивания. |
317 | 328 | * @param $res_data |
318 | 329 | */ |
319 | - private function app_10000666_777($res_data){ |
|
330 | + private function app_10000666_777($res_data) |
|
331 | + { |
|
320 | 332 | $search_file = ''; |
321 | 333 | foreach ($res_data as $ar_str){ |
322 | 334 | if(Util::rec_file_exists($ar_str['recordingfile'])){ |
@@ -330,12 +342,12 @@ discard block |
||
330 | 342 | if($search_file != ''){ |
331 | 343 | if('10000777' == $this->exten){ |
332 | 344 | $event = 'CallRecord'; |
333 | - }else{ |
|
345 | + } else{ |
|
334 | 346 | $event = 'StartDownloadRecord'; |
335 | 347 | } |
336 | 348 | $path = "80/pbxcore/api/cdr/records?view="; |
337 | 349 | $response = "{$event},chan1c:{$this->vars['chan']},fPath:{$path},FileName:{$search_file},uniqueid1c:{$this->vars['id']}"; |
338 | - }else{ |
|
350 | + } else{ |
|
339 | 351 | $event = ('10000777' == $this->exten)?'CallRecordFail':'FailDownloadRecord'; |
340 | 352 | |
341 | 353 | $response = "{$event},chan1c:{$this->vars['chan']},uniqueid1c:{$this->vars['id']}"; |
@@ -349,8 +361,11 @@ discard block |
||
349 | 361 | * @param $id |
350 | 362 | * @return string |
351 | 363 | */ |
352 | - private function old_10000666_777($id){ |
|
353 | - if(!file_exists('/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php')) return ''; |
|
364 | + private function old_10000666_777($id) |
|
365 | + { |
|
366 | + if(!file_exists('/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php')) { |
|
367 | + return ''; |
|
368 | + } |
|
354 | 369 | $settings = include "/storage/usbdisk1/mikopbx/astlogs/asterisk/askozia_http_settings.php"; |
355 | 370 | $host = $settings['host']; |
356 | 371 | $res = $settings['res']; |
@@ -365,7 +380,9 @@ discard block |
||
365 | 380 | exec("sqlite3 '$cdr_db' '{$zapros}'",$output); |
366 | 381 | $arr_files = array(); |
367 | 382 | foreach($output as $_data){ |
368 | - if(empty($_data)) continue; |
|
383 | + if(empty($_data)) { |
|
384 | + continue; |
|
385 | + } |
|
369 | 386 | $fname = "{$_data}.mp3"; |
370 | 387 | if(in_array($fname, $arr_files)) { |
371 | 388 | // Файл уже обработали ранее успешно. |
@@ -392,6 +409,6 @@ discard block |
||
392 | 409 | |
393 | 410 | try{ |
394 | 411 | $d = new CDR_Data($argv); |
395 | -}catch (Exception $e){ |
|
412 | +} catch (Exception $e){ |
|
396 | 413 | Util::sys_log_msg('miko_ajam', $e->getMessage()); |
397 | 414 | } |
398 | 415 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | class CDR_Data{ |
22 | 22 | private $callback; |
23 | 23 | private $vars; |
24 | - private $exten = NULL; |
|
24 | + private $exten = null; |
|
25 | 25 | /** @var AGI $agi */ |
26 | 26 | private $agi; |
27 | 27 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | $this->agi = new $AGI_class_name(); |
49 | - if($this->exten == NULL){ |
|
49 | + if($this->exten == null){ |
|
50 | 50 | $this->exten = $this->agi->request['agi_extension']; |
51 | 51 | } |
52 | 52 | $this->get_vars(); |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | // Если необходимо отправляем данные порциями |
270 | 270 | if($ch == 20){ |
271 | 271 | // Отправляем данные в 1С, обнуляем буфер |
272 | - $this->UserEvent("From{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
|
272 | + $this->UserEvent("from{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
|
273 | 273 | $result = ""; $ch = 1; |
274 | 274 | } |
275 | 275 | $ch = $ch + 1; |
276 | 276 | } |
277 | 277 | // Проверяем, есть ли остаток данных для отправки |
278 | 278 | if(!$result == ""){ |
279 | - $this->UserEvent("From{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
|
279 | + $this->UserEvent("from{$this->vars['dbFamily']},chan1c:{$this->vars['chan']},Lines:$result"); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | if(!file_exists($fname)){ |
386 | 386 | exec("mkdir -p ".dirname($_data)); |
387 | 387 | exec("curl -s -f 'http://{$host}:23600{$res}{$_data}' -u {$auth} -I", $curl_output); |
388 | - if(stripos(implode('',$curl_output), 'attachment;') === FALSE){ |
|
388 | + if(stripos(implode('',$curl_output), 'attachment;') === false){ |
|
389 | 389 | file_put_contents("{$fname}.empty", ''); |
390 | 390 | continue; |
391 | 391 | } |
@@ -12,21 +12,21 @@ |
||
12 | 12 | // Функция позволяет получить активные каналы. |
13 | 13 | // Возвращает ассоциативный массив. Ключ - Linkedid, значение - массив каналов. |
14 | 14 | function get_active_id_channels($EXTEN){ |
15 | - $ParkeeChannel = ''; |
|
16 | - $am = Util::get_am('off'); |
|
15 | + $ParkeeChannel = ''; |
|
16 | + $am = Util::get_am('off'); |
|
17 | 17 | if(!$am->logged_in()){ |
18 | 18 | return $ParkeeChannel; |
19 | 19 | } |
20 | - $res = $am->ParkedCalls('default'); |
|
21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
20 | + $res = $am->ParkedCalls('default'); |
|
21 | + if(count($res['data'])==0) return $ParkeeChannel; |
|
22 | 22 | |
23 | 23 | foreach($res['data']['ParkedCall'] as $park_row){ |
24 | - if($park_row['ParkingSpace'] == $EXTEN){ |
|
25 | - $ParkeeChannel = $park_row['ParkeeChannel']; |
|
26 | - } |
|
24 | + if($park_row['ParkingSpace'] == $EXTEN){ |
|
25 | + $ParkeeChannel = $park_row['ParkeeChannel']; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | |
29 | - return $ParkeeChannel; |
|
29 | + return $ParkeeChannel; |
|
30 | 30 | } |
31 | 31 | $agi = new AGI(); |
32 | 32 | $exten = $agi->get_variable("EXTEN", true); |
@@ -11,17 +11,17 @@ discard block |
||
11 | 11 | |
12 | 12 | // Функция позволяет получить активные каналы. |
13 | 13 | // Возвращает ассоциативный массив. Ключ - Linkedid, значение - массив каналов. |
14 | -function get_active_id_channels($EXTEN){ |
|
14 | +function get_active_id_channels($EXTEN) { |
|
15 | 15 | $ParkeeChannel = ''; |
16 | - $am = Util::get_am('off'); |
|
17 | - if(!$am->logged_in()){ |
|
16 | + $am = Util::get_am('off'); |
|
17 | + if (!$am->logged_in()) { |
|
18 | 18 | return $ParkeeChannel; |
19 | 19 | } |
20 | - $res = $am->ParkedCalls('default'); |
|
21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
20 | + $res = $am->ParkedCalls('default'); |
|
21 | + if (count($res['data']) == 0) return $ParkeeChannel; |
|
22 | 22 | |
23 | - foreach($res['data']['ParkedCall'] as $park_row){ |
|
24 | - if($park_row['ParkingSpace'] == $EXTEN){ |
|
23 | + foreach ($res['data']['ParkedCall'] as $park_row) { |
|
24 | + if ($park_row['ParkingSpace'] == $EXTEN) { |
|
25 | 25 | $ParkeeChannel = $park_row['ParkeeChannel']; |
26 | 26 | } |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $ParkeeChannel; |
30 | 30 | } |
31 | 31 | $agi = new AGI(); |
32 | -$exten = $agi->get_variable("EXTEN", true); |
|
32 | +$exten = $agi->get_variable("EXTEN", true); |
|
33 | 33 | |
34 | 34 | $PARK_CHAN = get_active_id_channels($exten); |
35 | 35 | $agi->set_variable("__pt1c_IS_PARK", "1"); |
@@ -11,14 +11,17 @@ |
||
11 | 11 | |
12 | 12 | // Функция позволяет получить активные каналы. |
13 | 13 | // Возвращает ассоциативный массив. Ключ - Linkedid, значение - массив каналов. |
14 | -function get_active_id_channels($EXTEN){ |
|
14 | +function get_active_id_channels($EXTEN) |
|
15 | +{ |
|
15 | 16 | $ParkeeChannel = ''; |
16 | 17 | $am = Util::get_am('off'); |
17 | 18 | if(!$am->logged_in()){ |
18 | 19 | return $ParkeeChannel; |
19 | 20 | } |
20 | 21 | $res = $am->ParkedCalls('default'); |
21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
22 | + if(count($res['data'])==0) { |
|
23 | + return $ParkeeChannel; |
|
24 | + } |
|
22 | 25 | |
23 | 26 | foreach($res['data']['ParkedCall'] as $park_row){ |
24 | 27 | if($park_row['ParkingSpace'] == $EXTEN){ |