@@ -9,8 +9,8 @@ |
||
| 9 | 9 | |
| 10 | 10 | class SystemDiagnosticController extends BaseController { |
| 11 | 11 | |
| 12 | - public function indexAction() { |
|
| 12 | + public function indexAction() { |
|
| 13 | 13 | |
| 14 | - } |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -7,9 +7,11 @@ |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -class SystemDiagnosticController extends BaseController { |
|
| 10 | +class SystemDiagnosticController extends BaseController |
|
| 11 | +{ |
|
| 11 | 12 | |
| 12 | - public function indexAction() { |
|
| 13 | + public function indexAction() |
|
| 14 | + { |
|
| 13 | 15 | |
| 14 | 16 | } |
| 15 | 17 | |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class CustomFilesController extends BaseController { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Построение списка файлов |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * Построение списка файлов |
|
| 17 | + */ |
|
| 18 | 18 | public function indexAction() { |
| 19 | 19 | |
| 20 | 20 | $files = CustomFiles::find(); |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Открытие карточки редактирования Файла записи |
|
| 28 | - * |
|
| 29 | - * @param string $id редактируемой записи |
|
| 30 | - */ |
|
| 31 | - public function modifyAction(string $id) { |
|
| 27 | + * Открытие карточки редактирования Файла записи |
|
| 28 | + * |
|
| 29 | + * @param string $id редактируемой записи |
|
| 30 | + */ |
|
| 31 | + public function modifyAction(string $id) { |
|
| 32 | 32 | $file = CustomFiles::findFirstById($id); |
| 33 | 33 | if (!$file) { |
| 34 | 34 | return $this->forward('custom-files/index'); |
@@ -37,17 +37,17 @@ discard block |
||
| 37 | 37 | $form = new CustomFilesEditForm($file); |
| 38 | 38 | $this->view->content = $file->getContent(); |
| 39 | 39 | $this->view->form = $form; |
| 40 | - $this->view->represent = $file->getRepresent(); |
|
| 41 | - $this->view->submitMode = NULL; |
|
| 40 | + $this->view->represent = $file->getRepresent(); |
|
| 41 | + $this->view->submitMode = NULL; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Сохранение параметров переопределения системного файла |
|
| 47 | - * |
|
| 48 | - * @return void |
|
| 49 | - */ |
|
| 50 | - public function saveAction(){ |
|
| 45 | + /** |
|
| 46 | + * Сохранение параметров переопределения системного файла |
|
| 47 | + * |
|
| 48 | + * @return void |
|
| 49 | + */ |
|
| 50 | + public function saveAction(){ |
|
| 51 | 51 | if (!$this->request->isPost()) return; |
| 52 | 52 | |
| 53 | 53 | $data = $this->request->getPost(); |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return void |
| 49 | 49 | */ |
| 50 | - public function saveAction(){ |
|
| 50 | + public function saveAction() { |
|
| 51 | 51 | if (!$this->request->isPost()) return; |
| 52 | 52 | |
| 53 | 53 | $data = $this->request->getPost(); |
| 54 | 54 | $customFile = CustomFiles::findFirstById($data['id']); |
| 55 | - if ($customFile==false) return; |
|
| 55 | + if ($customFile == false) return; |
|
| 56 | 56 | |
| 57 | 57 | // Заполним параметры записи |
| 58 | 58 | foreach ($customFile as $name => $value) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $customFile->$name = $data[$name]; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - if ($customFile->save()=== false){ |
|
| 71 | + if ($customFile->save() === false) { |
|
| 72 | 72 | $errors = $customFile->getMessages(); |
| 73 | 73 | $this->flash->error(implode('<br>', $errors)); |
| 74 | 74 | $this->view->success = false; |
@@ -10,12 +10,14 @@ discard block |
||
| 10 | 10 | use Models\CustomFiles; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -class CustomFilesController extends BaseController { |
|
| 13 | +class CustomFilesController extends BaseController |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Построение списка файлов |
| 17 | 18 | */ |
| 18 | - public function indexAction() { |
|
| 19 | + public function indexAction() |
|
| 20 | + { |
|
| 19 | 21 | |
| 20 | 22 | $files = CustomFiles::find(); |
| 21 | 23 | |
@@ -28,7 +30,8 @@ discard block |
||
| 28 | 30 | * |
| 29 | 31 | * @param string $id редактируемой записи |
| 30 | 32 | */ |
| 31 | - public function modifyAction(string $id) { |
|
| 33 | + public function modifyAction(string $id) |
|
| 34 | + { |
|
| 32 | 35 | $file = CustomFiles::findFirstById($id); |
| 33 | 36 | if (!$file) { |
| 34 | 37 | return $this->forward('custom-files/index'); |
@@ -47,12 +50,17 @@ discard block |
||
| 47 | 50 | * |
| 48 | 51 | * @return void |
| 49 | 52 | */ |
| 50 | - public function saveAction(){ |
|
| 51 | - if (!$this->request->isPost()) return; |
|
| 53 | + public function saveAction() |
|
| 54 | + { |
|
| 55 | + if (!$this->request->isPost()) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 52 | 58 | |
| 53 | 59 | $data = $this->request->getPost(); |
| 54 | 60 | $customFile = CustomFiles::findFirstById($data['id']); |
| 55 | - if ($customFile==false) return; |
|
| 61 | + if ($customFile==false) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 56 | 64 | |
| 57 | 65 | // Заполним параметры записи |
| 58 | 66 | foreach ($customFile as $name => $value) { |
@@ -64,7 +72,9 @@ discard block |
||
| 64 | 72 | $customFile->setContent($data[$name]); |
| 65 | 73 | break; |
| 66 | 74 | default: |
| 67 | - if (!array_key_exists($name, $data)) continue; |
|
| 75 | + if (!array_key_exists($name, $data)) { |
|
| 76 | + continue; |
|
| 77 | + } |
|
| 68 | 78 | $customFile->$name = $data[$name]; |
| 69 | 79 | } |
| 70 | 80 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | $this->view->content = $file->getContent(); |
| 39 | 39 | $this->view->form = $form; |
| 40 | 40 | $this->view->represent = $file->getRepresent(); |
| 41 | - $this->view->submitMode = NULL; |
|
| 41 | + $this->view->submitMode = null; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
@@ -12,74 +12,74 @@ |
||
| 12 | 12 | |
| 13 | 13 | class Fail2BanController extends BaseController { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Построение списка внутренних номеров и сотрудников |
|
| 17 | - */ |
|
| 18 | - public function indexAction() { |
|
| 19 | - $rules = Fail2BanRules::findFirst(); |
|
| 20 | - if ( ! $rules ) { |
|
| 21 | - $rules = new Fail2BanRules(); |
|
| 22 | - } |
|
| 23 | - $fail2BanEnabled = PbxSettings::getValueByKey( 'PBXFail2BanEnabled' ); |
|
| 15 | + /** |
|
| 16 | + * Построение списка внутренних номеров и сотрудников |
|
| 17 | + */ |
|
| 18 | + public function indexAction() { |
|
| 19 | + $rules = Fail2BanRules::findFirst(); |
|
| 20 | + if ( ! $rules ) { |
|
| 21 | + $rules = new Fail2BanRules(); |
|
| 22 | + } |
|
| 23 | + $fail2BanEnabled = PbxSettings::getValueByKey( 'PBXFail2BanEnabled' ); |
|
| 24 | 24 | |
| 25 | - $this->view->form = new Fail2BanEditForm( $rules, |
|
| 26 | - [ 'PBXFail2BanEnabled' => $fail2BanEnabled ] ); |
|
| 27 | - $this->view->submitMode = NULL; |
|
| 28 | - } |
|
| 25 | + $this->view->form = new Fail2BanEditForm( $rules, |
|
| 26 | + [ 'PBXFail2BanEnabled' => $fail2BanEnabled ] ); |
|
| 27 | + $this->view->submitMode = NULL; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Сохранение настроек системы |
|
| 32 | - */ |
|
| 33 | - public function saveAction() { |
|
| 34 | - if ( ! $this->request->isPost() ) { |
|
| 35 | - return; |
|
| 36 | - } |
|
| 37 | - $data = $this->request->getPost(); |
|
| 38 | - $record = Fail2BanRules::findFirst(); |
|
| 30 | + /** |
|
| 31 | + * Сохранение настроек системы |
|
| 32 | + */ |
|
| 33 | + public function saveAction() { |
|
| 34 | + if ( ! $this->request->isPost() ) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 37 | + $data = $this->request->getPost(); |
|
| 38 | + $record = Fail2BanRules::findFirst(); |
|
| 39 | 39 | |
| 40 | - if ( ! $record ) { |
|
| 41 | - $record = new Fail2BanRules(); |
|
| 42 | - } |
|
| 43 | - $this->db->begin(); |
|
| 44 | - foreach ( $record as $key => $value ) { |
|
| 45 | - switch ( $key ) { |
|
| 46 | - case "id": |
|
| 47 | - break; |
|
| 48 | - default: |
|
| 49 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 50 | - $record->$key = ''; |
|
| 51 | - continue; |
|
| 52 | - } |
|
| 53 | - $record->$key = $data[ $key ]; |
|
| 54 | - } |
|
| 55 | - if ( $record->save() === FALSE ) { |
|
| 56 | - $errors = $record->getMessages(); |
|
| 57 | - $this->flash->warning( implode( '<br>', $errors ) ); |
|
| 58 | - $this->view->success = FALSE; |
|
| 59 | - $this->db->rollback(); |
|
| 40 | + if ( ! $record ) { |
|
| 41 | + $record = new Fail2BanRules(); |
|
| 42 | + } |
|
| 43 | + $this->db->begin(); |
|
| 44 | + foreach ( $record as $key => $value ) { |
|
| 45 | + switch ( $key ) { |
|
| 46 | + case "id": |
|
| 47 | + break; |
|
| 48 | + default: |
|
| 49 | + if ( ! array_key_exists( $key, $data ) ) { |
|
| 50 | + $record->$key = ''; |
|
| 51 | + continue; |
|
| 52 | + } |
|
| 53 | + $record->$key = $data[ $key ]; |
|
| 54 | + } |
|
| 55 | + if ( $record->save() === FALSE ) { |
|
| 56 | + $errors = $record->getMessages(); |
|
| 57 | + $this->flash->warning( implode( '<br>', $errors ) ); |
|
| 58 | + $this->view->success = FALSE; |
|
| 59 | + $this->db->rollback(); |
|
| 60 | 60 | |
| 61 | - return; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - // $fail2BanEnabled = PbxSettings::findFirstByKey( 'PBXFail2BanEnabled' ); |
|
| 65 | - // if ( ! $fail2BanEnabled ) { |
|
| 66 | - // $fail2BanEnabled = new PbxSettings(); |
|
| 67 | - // $fail2BanEnabled->key = 'PBXFail2BanEnabled'; |
|
| 68 | - // } |
|
| 69 | - // $fail2BanEnabled->value = ( $data['PBXFail2BanEnabled'] == 'on' ) ? "1" |
|
| 70 | - // : "0"; |
|
| 71 | - // if ( $fail2BanEnabled->save() === FALSE ) { |
|
| 72 | - // $errors = $fail2BanEnabled->getMessages(); |
|
| 73 | - // $this->flash->warning( implode( '<br>', $errors ) ); |
|
| 74 | - // $this->view->success = FALSE; |
|
| 75 | - // $this->db->rollback(); |
|
| 76 | - // |
|
| 77 | - // return; |
|
| 78 | - // } |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + // $fail2BanEnabled = PbxSettings::findFirstByKey( 'PBXFail2BanEnabled' ); |
|
| 65 | + // if ( ! $fail2BanEnabled ) { |
|
| 66 | + // $fail2BanEnabled = new PbxSettings(); |
|
| 67 | + // $fail2BanEnabled->key = 'PBXFail2BanEnabled'; |
|
| 68 | + // } |
|
| 69 | + // $fail2BanEnabled->value = ( $data['PBXFail2BanEnabled'] == 'on' ) ? "1" |
|
| 70 | + // : "0"; |
|
| 71 | + // if ( $fail2BanEnabled->save() === FALSE ) { |
|
| 72 | + // $errors = $fail2BanEnabled->getMessages(); |
|
| 73 | + // $this->flash->warning( implode( '<br>', $errors ) ); |
|
| 74 | + // $this->view->success = FALSE; |
|
| 75 | + // $this->db->rollback(); |
|
| 76 | + // |
|
| 77 | + // return; |
|
| 78 | + // } |
|
| 79 | 79 | |
| 80 | - $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) ); |
|
| 81 | - $this->view->success = FALSE; |
|
| 82 | - $this->db->commit(); |
|
| 83 | - } |
|
| 80 | + $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) ); |
|
| 81 | + $this->view->success = FALSE; |
|
| 82 | + $this->db->commit(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | \ No newline at end of file |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function indexAction() { |
| 19 | 19 | $rules = Fail2BanRules::findFirst(); |
| 20 | - if ( ! $rules ) { |
|
| 20 | + if (!$rules) { |
|
| 21 | 21 | $rules = new Fail2BanRules(); |
| 22 | 22 | } |
| 23 | - $fail2BanEnabled = PbxSettings::getValueByKey( 'PBXFail2BanEnabled' ); |
|
| 23 | + $fail2BanEnabled = PbxSettings::getValueByKey('PBXFail2BanEnabled'); |
|
| 24 | 24 | |
| 25 | - $this->view->form = new Fail2BanEditForm( $rules, |
|
| 26 | - [ 'PBXFail2BanEnabled' => $fail2BanEnabled ] ); |
|
| 25 | + $this->view->form = new Fail2BanEditForm($rules, |
|
| 26 | + ['PBXFail2BanEnabled' => $fail2BanEnabled]); |
|
| 27 | 27 | $this->view->submitMode = NULL; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -31,30 +31,30 @@ discard block |
||
| 31 | 31 | * Сохранение настроек системы |
| 32 | 32 | */ |
| 33 | 33 | public function saveAction() { |
| 34 | - if ( ! $this->request->isPost() ) { |
|
| 34 | + if (!$this->request->isPost()) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | $data = $this->request->getPost(); |
| 38 | 38 | $record = Fail2BanRules::findFirst(); |
| 39 | 39 | |
| 40 | - if ( ! $record ) { |
|
| 40 | + if (!$record) { |
|
| 41 | 41 | $record = new Fail2BanRules(); |
| 42 | 42 | } |
| 43 | 43 | $this->db->begin(); |
| 44 | - foreach ( $record as $key => $value ) { |
|
| 45 | - switch ( $key ) { |
|
| 44 | + foreach ($record as $key => $value) { |
|
| 45 | + switch ($key) { |
|
| 46 | 46 | case "id": |
| 47 | 47 | break; |
| 48 | 48 | default: |
| 49 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 49 | + if (!array_key_exists($key, $data)) { |
|
| 50 | 50 | $record->$key = ''; |
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | - $record->$key = $data[ $key ]; |
|
| 53 | + $record->$key = $data[$key]; |
|
| 54 | 54 | } |
| 55 | - if ( $record->save() === FALSE ) { |
|
| 55 | + if ($record->save() === FALSE) { |
|
| 56 | 56 | $errors = $record->getMessages(); |
| 57 | - $this->flash->warning( implode( '<br>', $errors ) ); |
|
| 57 | + $this->flash->warning(implode('<br>', $errors)); |
|
| 58 | 58 | $this->view->success = FALSE; |
| 59 | 59 | $this->db->rollback(); |
| 60 | 60 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | // return; |
| 78 | 78 | // } |
| 79 | 79 | |
| 80 | - $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) ); |
|
| 80 | + $this->flash->success($this->translation->_('ms_SuccessfulSaved')); |
|
| 81 | 81 | $this->view->success = FALSE; |
| 82 | 82 | $this->db->commit(); |
| 83 | 83 | } |
@@ -10,12 +10,14 @@ discard block |
||
| 10 | 10 | use \Models\Fail2BanRules; |
| 11 | 11 | use \Models\PbxSettings; |
| 12 | 12 | |
| 13 | -class Fail2BanController extends BaseController { |
|
| 13 | +class Fail2BanController extends BaseController |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Построение списка внутренних номеров и сотрудников |
| 17 | 18 | */ |
| 18 | - public function indexAction() { |
|
| 19 | + public function indexAction() |
|
| 20 | + { |
|
| 19 | 21 | $rules = Fail2BanRules::findFirst(); |
| 20 | 22 | if ( ! $rules ) { |
| 21 | 23 | $rules = new Fail2BanRules(); |
@@ -30,7 +32,8 @@ discard block |
||
| 30 | 32 | /** |
| 31 | 33 | * Сохранение настроек системы |
| 32 | 34 | */ |
| 33 | - public function saveAction() { |
|
| 35 | + public function saveAction() |
|
| 36 | + { |
|
| 34 | 37 | if ( ! $this->request->isPost() ) { |
| 35 | 38 | return; |
| 36 | 39 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $this->view->form = new Fail2BanEditForm( $rules, |
| 26 | 26 | [ 'PBXFail2BanEnabled' => $fail2BanEnabled ] ); |
| 27 | - $this->view->submitMode = NULL; |
|
| 27 | + $this->view->submitMode = null; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | $record->$key = $data[ $key ]; |
| 54 | 54 | } |
| 55 | - if ( $record->save() === FALSE ) { |
|
| 55 | + if ( $record->save() === false ) { |
|
| 56 | 56 | $errors = $record->getMessages(); |
| 57 | 57 | $this->flash->warning( implode( '<br>', $errors ) ); |
| 58 | - $this->view->success = FALSE; |
|
| 58 | + $this->view->success = false; |
|
| 59 | 59 | $this->db->rollback(); |
| 60 | 60 | |
| 61 | 61 | return; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // } |
| 79 | 79 | |
| 80 | 80 | $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) ); |
| 81 | - $this->view->success = FALSE; |
|
| 81 | + $this->view->success = false; |
|
| 82 | 82 | $this->db->commit(); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | if (strpos($interface->subnet, '.') === false) { |
| 34 | 34 | $localAddresses[] = $calculator->cidr2network($interface->ipaddr, |
| 35 | - $interface->subnet) . '/' . $interface->subnet; |
|
| 35 | + $interface->subnet).'/'.$interface->subnet; |
|
| 36 | 36 | } else { |
| 37 | 37 | $cidr = $calculator->netmask2cidr($interface->subnet); |
| 38 | - $localAddresses[] = $calculator->cidr2network($interface->ipaddr, $cidr) . '/' . $cidr; |
|
| 38 | + $localAddresses[] = $calculator->cidr2network($interface->ipaddr, $cidr).'/'.$cidr; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | if (strpos($permitParts[1], '.') === false) { |
| 53 | 53 | $networksTable[$filter->id]['network'] = $calculator->cidr2network($permitParts[0], |
| 54 | - $permitParts[1]) . '/' . $permitParts[1]; |
|
| 54 | + $permitParts[1]).'/'.$permitParts[1]; |
|
| 55 | 55 | } else { |
| 56 | 56 | $cidr = $calculator->netmask2cidr($permitParts[1]); |
| 57 | 57 | $networksTable[$filter->id]['network'] = $calculator->cidr2network($permitParts[0], |
| 58 | - $cidr) . '/' . $cidr; |
|
| 58 | + $cidr).'/'.$cidr; |
|
| 59 | 59 | } |
| 60 | 60 | $networksTable[$filter->id]['permanent'] = false; |
| 61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | // Заполним значениями по умолчанию |
| 64 | 64 | foreach ($defaultRules as $key => $value) { |
| 65 | 65 | $networksTable[$filter->id]['category'][$key] = [ |
| 66 | - 'name' => empty($value['shortName'])?$key:$value['shortName'], |
|
| 66 | + 'name' => empty($value['shortName']) ? $key : $value['shortName'], |
|
| 67 | 67 | 'action' => $value['action'] |
| 68 | 68 | ]; |
| 69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $firewallRules = $filter->FirewallRules; |
| 73 | 73 | foreach ($firewallRules as $rule) { |
| 74 | 74 | $networksTable[$filter->id]['category'][$rule->category]['action'] = $rule->action; |
| 75 | - if (!array_key_exists('name',$networksTable[$filter->id]['category'][$rule->category])){ |
|
| 75 | + if (!array_key_exists('name', $networksTable[$filter->id]['category'][$rule->category])) { |
|
| 76 | 76 | $networksTable[$filter->id]['category'][$rule->category]['name'] = $rule->category; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | break; |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | - if ( ! $existsPersistentRecord) { |
|
| 91 | + if (!$existsPersistentRecord) { |
|
| 92 | 92 | foreach ($defaultRules as $key => $value) { |
| 93 | 93 | $networksTableNewRecord['category'][$key] = [ |
| 94 | 94 | 'name' => $key, |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $networksTableNewRecord['id'] = ''; |
| 99 | 99 | $networksTableNewRecord['permanent'] = true; |
| 100 | 100 | $networksTableNewRecord['network'] = $localAddress; |
| 101 | - if ($localAddress==='0.0.0.0/0'){ |
|
| 101 | + if ($localAddress === '0.0.0.0/0') { |
|
| 102 | 102 | $networksTableNewRecord['description'] = $this->translation->_('fw_AllNetworksRule'); |
| 103 | 103 | } else { |
| 104 | 104 | $networksTableNewRecord['description'] = $this->translation->_('fw_LocalNetworksRule'); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $networkFilter = NetworkFilters::findFirstById($networkId); |
| 126 | 126 | $firewallRules = FirewallRules::getDefaultRules(); |
| 127 | 127 | $data = $this->request->getPost(); |
| 128 | - if ( ! $networkFilter) { |
|
| 128 | + if (!$networkFilter) { |
|
| 129 | 129 | $networkFilter = new NetworkFilters(); |
| 130 | 130 | $networkFilter->permit = empty($data['permit']) ? '0.0.0.0/0' : $data['permit']; |
| 131 | 131 | } else { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function saveAction(): void |
| 150 | 150 | { |
| 151 | - if ( ! $this->request->isPost()) { |
|
| 151 | + if (!$this->request->isPost()) { |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Заполним параметры записи Network Filter |
| 165 | - if ( ! $this->updateNetworkFilters($filterRecord, $data)) { |
|
| 165 | + if (!$this->updateNetworkFilters($filterRecord, $data)) { |
|
| 166 | 166 | $this->view->success = false; |
| 167 | 167 | $this->db->rollback(); |
| 168 | 168 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // Заполним параметры Firewall |
| 173 | 173 | $data['id'] = $filterRecord->id; |
| 174 | - if ( ! $this->updateFirewallRules($data)) { |
|
| 174 | + if (!$this->updateFirewallRules($data)) { |
|
| 175 | 175 | $this->view->success = false; |
| 176 | 176 | $this->db->rollback(); |
| 177 | 177 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $filterRecord = NetworkFilters::findFirstById($networkId); |
| 196 | 196 | |
| 197 | 197 | $errors = false; |
| 198 | - if ($filterRecord && ! $filterRecord->delete()) { |
|
| 198 | + if ($filterRecord && !$filterRecord->delete()) { |
|
| 199 | 199 | $errors = $filterRecord->getMessages(); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | switch ($name) { |
| 247 | 247 | case 'permit': |
| 248 | 248 | $filterRecord->$name = $calculator->cidr2network($data['network'], |
| 249 | - $data['subnet']) . '/' . $data['subnet']; |
|
| 249 | + $data['subnet']).'/'.$data['subnet']; |
|
| 250 | 250 | break; |
| 251 | 251 | case 'deny': |
| 252 | 252 | $filterRecord->$name = '0.0.0.0/0'; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | break; |
| 262 | 262 | default: |
| 263 | - if ( array_key_exists($name, $data)) { |
|
| 263 | + if (array_key_exists($name, $data)) { |
|
| 264 | 264 | $filterRecord->$name = $data[$name]; |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | // Удалим все предыдущие правила |
| 299 | - $parameters = [ |
|
| 299 | + $parameters = [ |
|
| 300 | 300 | 'conditions' => 'networkfilterid=:networkfilterid:', |
| 301 | 301 | 'bind' => [ |
| 302 | 302 | 'networkfilterid' => $data['id'], |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | $newRule->portto = $rule['portto']; |
| 332 | 332 | $newRule->category = $key; |
| 333 | 333 | |
| 334 | - if (array_key_exists('rule_' . $key, $data) && $data['rule_' . $key]) { |
|
| 335 | - $newRule->action = $data['rule_' . $key] === 'on' ? 'allow' : 'block'; |
|
| 334 | + if (array_key_exists('rule_'.$key, $data) && $data['rule_'.$key]) { |
|
| 335 | + $newRule->action = $data['rule_'.$key] === 'on' ? 'allow' : 'block'; |
|
| 336 | 336 | } else { |
| 337 | 337 | $newRule->action = 'block'; |
| 338 | 338 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | public function enableAction(): void |
| 361 | 361 | { |
| 362 | 362 | $fail2BanEnabled = PbxSettings::findFirstByKey('PBXFail2BanEnabled'); |
| 363 | - if ( ! $fail2BanEnabled) { |
|
| 363 | + if (!$fail2BanEnabled) { |
|
| 364 | 364 | $fail2BanEnabled = new PbxSettings(); |
| 365 | 365 | $fail2BanEnabled->key = 'PBXFail2BanEnabled'; |
| 366 | 366 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | $firewallEnabled = PbxSettings::findFirstByKey('PBXFirewallEnabled'); |
| 377 | - if ( ! $firewallEnabled) { |
|
| 377 | + if (!$firewallEnabled) { |
|
| 378 | 378 | $firewallEnabled = new PbxSettings(); |
| 379 | 379 | $firewallEnabled->key = 'PBXFail2BanEnabled'; |
| 380 | 380 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | public function disableAction(): void |
| 396 | 396 | { |
| 397 | 397 | $fail2BanEnabled = PbxSettings::findFirstByKey('PBXFail2BanEnabled'); |
| 398 | - if ( ! $fail2BanEnabled) { |
|
| 398 | + if (!$fail2BanEnabled) { |
|
| 399 | 399 | $fail2BanEnabled = new PbxSettings(); |
| 400 | 400 | $fail2BanEnabled->key = 'PBXFail2BanEnabled'; |
| 401 | 401 | } |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $firewallEnabled = PbxSettings::findFirstByKey('PBXFirewallEnabled'); |
| 412 | - if ( ! $firewallEnabled) { |
|
| 412 | + if (!$firewallEnabled) { |
|
| 413 | 413 | $firewallEnabled = new PbxSettings(); |
| 414 | 414 | $firewallEnabled->key = 'PBXFail2BanEnabled'; |
| 415 | 415 | } |
@@ -11,10 +11,10 @@ |
||
| 11 | 11 | |
| 12 | 12 | class RestartController extends BaseController { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Форма с основными кнопками для перезагрузки и выключения станции |
|
| 16 | - */ |
|
| 17 | - public function indexAction() { |
|
| 14 | + /** |
|
| 15 | + * Форма с основными кнопками для перезагрузки и выключения станции |
|
| 16 | + */ |
|
| 17 | + public function indexAction() { |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -9,12 +9,14 @@ |
||
| 9 | 9 | |
| 10 | 10 | use Models\Extensions; |
| 11 | 11 | |
| 12 | -class RestartController extends BaseController { |
|
| 12 | +class RestartController extends BaseController |
|
| 13 | +{ |
|
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Форма с основными кнопками для перезагрузки и выключения станции |
| 16 | 17 | */ |
| 17 | - public function indexAction() { |
|
| 18 | + public function indexAction() |
|
| 19 | + { |
|
| 18 | 20 | |
| 19 | 21 | } |
| 20 | 22 | } |
@@ -339,24 +339,24 @@ discard block |
||
| 339 | 339 | if (array_key_exists('submenu', $groupparams)) { |
| 340 | 340 | $resultHtml .= '<div class="item">'; |
| 341 | 341 | $resultHtml .= '<div class="header">'; |
| 342 | - if (array_key_exists('iconclass', $groupparams) && ! empty($groupparams['iconclass'])) { |
|
| 342 | + if (array_key_exists('iconclass', $groupparams) && !empty($groupparams['iconclass'])) { |
|
| 343 | 343 | $resultHtml .= "<i class='{$groupparams['iconclass']} icon'></i>"; |
| 344 | 344 | } |
| 345 | - $resultHtml .= $this->translation->_($groupparams['caption']) . '</div>'; |
|
| 346 | - $resultHtml .= "<div class='menu' data-group='{$group}'>"; |
|
| 345 | + $resultHtml .= $this->translation->_($groupparams['caption']).'</div>'; |
|
| 346 | + $resultHtml .= "<div class='menu' data-group='{$group}'>"; |
|
| 347 | 347 | foreach ($groupparams['submenu'] as $controller => $option) { |
| 348 | - $link = $this->url->get($controller . '/' . $option['action'] . '/' . $option['param']); |
|
| 348 | + $link = $this->url->get($controller.'/'.$option['action'].'/'.$option['param']); |
|
| 349 | 349 | $caption = $this->translation->_($option['caption']); |
| 350 | - $resultHtml .= "<a class='item {$option['style']}' href='{$link}'> |
|
| 350 | + $resultHtml .= "<a class='item {$option['style']}' href='{$link}'> |
|
| 351 | 351 | <i class='{$option['iconclass']} icon'></i>{$caption} |
| 352 | 352 | </a>"; |
| 353 | 353 | } |
| 354 | - $resultHtml .= '</div>'; |
|
| 355 | - $resultHtml .= '</div>'; |
|
| 354 | + $resultHtml .= '</div>'; |
|
| 355 | + $resultHtml .= '</div>'; |
|
| 356 | 356 | } else { |
| 357 | - $link = $this->url->get($group . '/' . $groupparams['action'] . '/' . $groupparams['param']); |
|
| 357 | + $link = $this->url->get($group.'/'.$groupparams['action'].'/'.$groupparams['param']); |
|
| 358 | 358 | $caption = $this->translation->_($groupparams['caption']); |
| 359 | - $resultHtml .= "<a class='item {$groupparams['style']}' href='{$link}'> |
|
| 359 | + $resultHtml .= "<a class='item {$groupparams['style']}' href='{$link}'> |
|
| 360 | 360 | <i class='{$groupparams['iconclass']} icon'></i>{$caption} |
| 361 | 361 | </a>"; |
| 362 | 362 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | foreach ($this->_headerMenu as $index => $group) { |
| 379 | 379 | if ($index === $uncamelizeControllerName |
| 380 | 380 | && array_key_exists('iconclass', $group[$uncamelizeControllerName]) |
| 381 | - && ! empty($group[$uncamelizeControllerName]['iconclass']) |
|
| 381 | + && !empty($group[$uncamelizeControllerName]['iconclass']) |
|
| 382 | 382 | ) { |
| 383 | 383 | $result = "<i class='{$group[$uncamelizeControllerName]['iconclass']} icon'></i>"; |
| 384 | 384 | break; |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | if (array_key_exists('submenu', $group)) { |
| 387 | 387 | foreach ($group['submenu'] as $index2 => $submenu) { |
| 388 | 388 | if ($index2 === $uncamelizeControllerName |
| 389 | - && ! empty($submenu['iconclass'])) { |
|
| 389 | + && !empty($submenu['iconclass'])) { |
|
| 390 | 390 | $result = "<i class='{$submenu['iconclass']} icon'></i>"; |
| 391 | 391 | break; |
| 392 | 392 | } |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | { |
| 405 | 405 | $result = []; |
| 406 | 406 | foreach ($this->_headerMenu as $group => $groupparams) { |
| 407 | - if (array_key_exists('submenu', $groupparams)){ |
|
| 408 | - $result[(string)($group)] =$this->translation->_($groupparams['caption']); |
|
| 407 | + if (array_key_exists('submenu', $groupparams)) { |
|
| 408 | + $result[(string) ($group)] = $this->translation->_($groupparams['caption']); |
|
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | return $result; |
@@ -12,172 +12,172 @@ |
||
| 12 | 12 | |
| 13 | 13 | class LicenseWorker extends Component { |
| 14 | 14 | |
| 15 | - private $serverUrl; |
|
| 16 | - |
|
| 17 | - function __construct( $serverUrl = 'http://127.0.0.1:8222' ) { |
|
| 18 | - $this->serverUrl = $serverUrl; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Выполнение запроса к серверу NATS. |
|
| 23 | - * |
|
| 24 | - * @param $metod |
|
| 25 | - * @param $data |
|
| 26 | - * |
|
| 27 | - * @return mixed |
|
| 28 | - */ |
|
| 29 | - private function curlPostRequest( $metod, $data = NULL ) { |
|
| 30 | - $url = $this->serverUrl . "/license.api/$metod"; |
|
| 31 | - $ch = curl_init(); |
|
| 32 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 33 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 34 | - curl_setopt( $ch, CURLOPT_TIMEOUT, 25 ); |
|
| 35 | - if ( $data != NULL ) { |
|
| 36 | - $params = http_build_query( $data ); |
|
| 37 | - curl_setopt( $ch, CURLOPT_POST, 1 ); |
|
| 38 | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); |
|
| 39 | - curl_setopt( $ch, CURLOPT_HTTPHEADER, |
|
| 40 | - [ "Content-type: application/x-www-form-urlencoded" ] ); |
|
| 41 | - } |
|
| 42 | - $output = curl_exec( $ch ); |
|
| 43 | - curl_close( $ch ); |
|
| 44 | - |
|
| 45 | - return $output; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Получение инфорамции по лицензиям. Установка значения ключа в NATS. |
|
| 50 | - * |
|
| 51 | - * @param $key |
|
| 52 | - * |
|
| 53 | - * @return array |
|
| 54 | - */ |
|
| 55 | - public function getLicenseInfo( $key ) { |
|
| 56 | - $response = $this->curlPostRequest( 'getlicenseinfo', |
|
| 57 | - [ 'key' => $key ] ); |
|
| 58 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 59 | - if ( $arResult['success'] ) { |
|
| 60 | - $result = $arResult['result']; |
|
| 61 | - } else { |
|
| 62 | - $result = $arResult['error']; |
|
| 63 | - if ( openlog( "License", LOG_ODELAY, LOG_LOCAL7 ) ) { |
|
| 64 | - syslog( LOG_EMERG, $arResult['error'] ); |
|
| 65 | - closelog(); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return $result; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Получение нового регистрационного номера. |
|
| 74 | - * |
|
| 75 | - * @param $params |
|
| 76 | - * |
|
| 77 | - * @return mixed |
|
| 78 | - */ |
|
| 79 | - public function getTrialLicense( $params ) { |
|
| 80 | - $data = [ |
|
| 81 | - 'companyname' => $params['companyname'], |
|
| 82 | - 'email' => $params['email'], |
|
| 83 | - 'contact' => $params['contact'], |
|
| 84 | - 'tel' => $params['telefone'], |
|
| 85 | - 'inn' => $params['inn'], |
|
| 86 | - 'description' => 'get trial from askozia pbx', |
|
| 87 | - 'product' => 11, |
|
| 88 | - ]; |
|
| 89 | - $response = $this->curlPostRequest( 'gettrial', $data ); |
|
| 90 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 91 | - if ( $arResult['success'] ) { |
|
| 92 | - $result = $arResult['result']; |
|
| 93 | - } else { |
|
| 94 | - $result = $arResult['error']; |
|
| 95 | - } |
|
| 96 | - return $result; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Добавление нового триала к ключу. |
|
| 101 | - * |
|
| 102 | - * @param $productid |
|
| 103 | - * |
|
| 104 | - * @return bool - результат активации триала |
|
| 105 | - */ |
|
| 106 | - public function addTrial( $productid = "11" ) { |
|
| 107 | - $data = [ 'product' => $productid ]; |
|
| 108 | - $response = $this->curlPostRequest( 'addtrial', $data ); |
|
| 109 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 110 | - if ( $arResult['success'] ) { |
|
| 111 | - $result = TRUE; |
|
| 112 | - } else { |
|
| 113 | - $result = $arResult['error']; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - return $result; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Активация купона |
|
| 121 | - * |
|
| 122 | - * @param $coupon |
|
| 123 | - * |
|
| 124 | - * @return bool результат активации купона |
|
| 125 | - */ |
|
| 126 | - public function activateCoupon( $coupon ) { |
|
| 127 | - $data = [ 'coupon' => trim( $coupon ) ]; |
|
| 128 | - $response = $this->curlPostRequest( 'activatecoupon', $data ); |
|
| 129 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 130 | - if ( $arResult['success'] ) { |
|
| 131 | - $result = TRUE; |
|
| 132 | - } else { |
|
| 133 | - $result = $arResult['error']; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $result; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Смена лицензионного ключа |
|
| 141 | - * |
|
| 142 | - * @param $newKey - новый ключ |
|
| 143 | - */ |
|
| 144 | - public function changeLicenseKey( $newKey ) { |
|
| 145 | - $this->curlPostRequest( 'changekey', [ 'key' => $newKey ] ); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Преобразование ответа в массив значений. |
|
| 150 | - * |
|
| 151 | - * @param $text |
|
| 152 | - * |
|
| 153 | - * @return array |
|
| 154 | - */ |
|
| 155 | - private function convertXMLToArray( $text ) { |
|
| 156 | - |
|
| 157 | - $json_data = json_decode( $text, TRUE ); |
|
| 158 | - if (is_null($json_data)){ |
|
| 159 | - $text = str_replace( '\n', "\n", $text ); |
|
| 160 | - $text = str_replace( '\"', '"', $text ); |
|
| 161 | - |
|
| 162 | - $json_data = json_decode( $text, TRUE ); |
|
| 163 | - } |
|
| 164 | - if ( ! isset( $json_data['error'] ) ) { |
|
| 165 | - $text_xml = urldecode($json_data['result']); |
|
| 166 | - libxml_use_internal_errors(true); |
|
| 167 | - $doc = simplexml_load_string($text_xml); |
|
| 168 | - if (!$doc) { |
|
| 169 | - libxml_clear_errors(); |
|
| 170 | - $doc = $text_xml; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - $result = ['success' => TRUE, 'result' => $doc]; |
|
| 174 | - }elseif ( isset( $json_data['error'] ) ) { |
|
| 175 | - $result = [ 'success' => FALSE, 'error' => $json_data['error'] ]; |
|
| 176 | - } else { |
|
| 177 | - $result = [ 'success' => FALSE, 'error' => $json_data ]; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return $result; |
|
| 181 | - } |
|
| 15 | + private $serverUrl; |
|
| 16 | + |
|
| 17 | + function __construct( $serverUrl = 'http://127.0.0.1:8222' ) { |
|
| 18 | + $this->serverUrl = $serverUrl; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Выполнение запроса к серверу NATS. |
|
| 23 | + * |
|
| 24 | + * @param $metod |
|
| 25 | + * @param $data |
|
| 26 | + * |
|
| 27 | + * @return mixed |
|
| 28 | + */ |
|
| 29 | + private function curlPostRequest( $metod, $data = NULL ) { |
|
| 30 | + $url = $this->serverUrl . "/license.api/$metod"; |
|
| 31 | + $ch = curl_init(); |
|
| 32 | + curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 33 | + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 34 | + curl_setopt( $ch, CURLOPT_TIMEOUT, 25 ); |
|
| 35 | + if ( $data != NULL ) { |
|
| 36 | + $params = http_build_query( $data ); |
|
| 37 | + curl_setopt( $ch, CURLOPT_POST, 1 ); |
|
| 38 | + curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); |
|
| 39 | + curl_setopt( $ch, CURLOPT_HTTPHEADER, |
|
| 40 | + [ "Content-type: application/x-www-form-urlencoded" ] ); |
|
| 41 | + } |
|
| 42 | + $output = curl_exec( $ch ); |
|
| 43 | + curl_close( $ch ); |
|
| 44 | + |
|
| 45 | + return $output; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Получение инфорамции по лицензиям. Установка значения ключа в NATS. |
|
| 50 | + * |
|
| 51 | + * @param $key |
|
| 52 | + * |
|
| 53 | + * @return array |
|
| 54 | + */ |
|
| 55 | + public function getLicenseInfo( $key ) { |
|
| 56 | + $response = $this->curlPostRequest( 'getlicenseinfo', |
|
| 57 | + [ 'key' => $key ] ); |
|
| 58 | + $arResult = $this->convertXMLToArray( $response ); |
|
| 59 | + if ( $arResult['success'] ) { |
|
| 60 | + $result = $arResult['result']; |
|
| 61 | + } else { |
|
| 62 | + $result = $arResult['error']; |
|
| 63 | + if ( openlog( "License", LOG_ODELAY, LOG_LOCAL7 ) ) { |
|
| 64 | + syslog( LOG_EMERG, $arResult['error'] ); |
|
| 65 | + closelog(); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return $result; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Получение нового регистрационного номера. |
|
| 74 | + * |
|
| 75 | + * @param $params |
|
| 76 | + * |
|
| 77 | + * @return mixed |
|
| 78 | + */ |
|
| 79 | + public function getTrialLicense( $params ) { |
|
| 80 | + $data = [ |
|
| 81 | + 'companyname' => $params['companyname'], |
|
| 82 | + 'email' => $params['email'], |
|
| 83 | + 'contact' => $params['contact'], |
|
| 84 | + 'tel' => $params['telefone'], |
|
| 85 | + 'inn' => $params['inn'], |
|
| 86 | + 'description' => 'get trial from askozia pbx', |
|
| 87 | + 'product' => 11, |
|
| 88 | + ]; |
|
| 89 | + $response = $this->curlPostRequest( 'gettrial', $data ); |
|
| 90 | + $arResult = $this->convertXMLToArray( $response ); |
|
| 91 | + if ( $arResult['success'] ) { |
|
| 92 | + $result = $arResult['result']; |
|
| 93 | + } else { |
|
| 94 | + $result = $arResult['error']; |
|
| 95 | + } |
|
| 96 | + return $result; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Добавление нового триала к ключу. |
|
| 101 | + * |
|
| 102 | + * @param $productid |
|
| 103 | + * |
|
| 104 | + * @return bool - результат активации триала |
|
| 105 | + */ |
|
| 106 | + public function addTrial( $productid = "11" ) { |
|
| 107 | + $data = [ 'product' => $productid ]; |
|
| 108 | + $response = $this->curlPostRequest( 'addtrial', $data ); |
|
| 109 | + $arResult = $this->convertXMLToArray( $response ); |
|
| 110 | + if ( $arResult['success'] ) { |
|
| 111 | + $result = TRUE; |
|
| 112 | + } else { |
|
| 113 | + $result = $arResult['error']; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + return $result; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Активация купона |
|
| 121 | + * |
|
| 122 | + * @param $coupon |
|
| 123 | + * |
|
| 124 | + * @return bool результат активации купона |
|
| 125 | + */ |
|
| 126 | + public function activateCoupon( $coupon ) { |
|
| 127 | + $data = [ 'coupon' => trim( $coupon ) ]; |
|
| 128 | + $response = $this->curlPostRequest( 'activatecoupon', $data ); |
|
| 129 | + $arResult = $this->convertXMLToArray( $response ); |
|
| 130 | + if ( $arResult['success'] ) { |
|
| 131 | + $result = TRUE; |
|
| 132 | + } else { |
|
| 133 | + $result = $arResult['error']; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $result; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Смена лицензионного ключа |
|
| 141 | + * |
|
| 142 | + * @param $newKey - новый ключ |
|
| 143 | + */ |
|
| 144 | + public function changeLicenseKey( $newKey ) { |
|
| 145 | + $this->curlPostRequest( 'changekey', [ 'key' => $newKey ] ); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Преобразование ответа в массив значений. |
|
| 150 | + * |
|
| 151 | + * @param $text |
|
| 152 | + * |
|
| 153 | + * @return array |
|
| 154 | + */ |
|
| 155 | + private function convertXMLToArray( $text ) { |
|
| 156 | + |
|
| 157 | + $json_data = json_decode( $text, TRUE ); |
|
| 158 | + if (is_null($json_data)){ |
|
| 159 | + $text = str_replace( '\n', "\n", $text ); |
|
| 160 | + $text = str_replace( '\"', '"', $text ); |
|
| 161 | + |
|
| 162 | + $json_data = json_decode( $text, TRUE ); |
|
| 163 | + } |
|
| 164 | + if ( ! isset( $json_data['error'] ) ) { |
|
| 165 | + $text_xml = urldecode($json_data['result']); |
|
| 166 | + libxml_use_internal_errors(true); |
|
| 167 | + $doc = simplexml_load_string($text_xml); |
|
| 168 | + if (!$doc) { |
|
| 169 | + libxml_clear_errors(); |
|
| 170 | + $doc = $text_xml; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + $result = ['success' => TRUE, 'result' => $doc]; |
|
| 174 | + }elseif ( isset( $json_data['error'] ) ) { |
|
| 175 | + $result = [ 'success' => FALSE, 'error' => $json_data['error'] ]; |
|
| 176 | + } else { |
|
| 177 | + $result = [ 'success' => FALSE, 'error' => $json_data ]; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return $result; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | } |
| 184 | 184 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | private $serverUrl; |
| 16 | 16 | |
| 17 | - function __construct( $serverUrl = 'http://127.0.0.1:8222' ) { |
|
| 17 | + function __construct($serverUrl = 'http://127.0.0.1:8222') { |
|
| 18 | 18 | $this->serverUrl = $serverUrl; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return mixed |
| 28 | 28 | */ |
| 29 | - private function curlPostRequest( $metod, $data = NULL ) { |
|
| 30 | - $url = $this->serverUrl . "/license.api/$metod"; |
|
| 29 | + private function curlPostRequest($metod, $data = NULL) { |
|
| 30 | + $url = $this->serverUrl."/license.api/$metod"; |
|
| 31 | 31 | $ch = curl_init(); |
| 32 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 33 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 34 | - curl_setopt( $ch, CURLOPT_TIMEOUT, 25 ); |
|
| 35 | - if ( $data != NULL ) { |
|
| 36 | - $params = http_build_query( $data ); |
|
| 37 | - curl_setopt( $ch, CURLOPT_POST, 1 ); |
|
| 38 | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); |
|
| 39 | - curl_setopt( $ch, CURLOPT_HTTPHEADER, |
|
| 40 | - [ "Content-type: application/x-www-form-urlencoded" ] ); |
|
| 32 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 33 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 34 | + curl_setopt($ch, CURLOPT_TIMEOUT, 25); |
|
| 35 | + if ($data != NULL) { |
|
| 36 | + $params = http_build_query($data); |
|
| 37 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
| 38 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 39 | + curl_setopt($ch, CURLOPT_HTTPHEADER, |
|
| 40 | + ["Content-type: application/x-www-form-urlencoded"]); |
|
| 41 | 41 | } |
| 42 | - $output = curl_exec( $ch ); |
|
| 43 | - curl_close( $ch ); |
|
| 42 | + $output = curl_exec($ch); |
|
| 43 | + curl_close($ch); |
|
| 44 | 44 | |
| 45 | 45 | return $output; |
| 46 | 46 | } |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | - public function getLicenseInfo( $key ) { |
|
| 56 | - $response = $this->curlPostRequest( 'getlicenseinfo', |
|
| 57 | - [ 'key' => $key ] ); |
|
| 58 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 59 | - if ( $arResult['success'] ) { |
|
| 55 | + public function getLicenseInfo($key) { |
|
| 56 | + $response = $this->curlPostRequest('getlicenseinfo', |
|
| 57 | + ['key' => $key]); |
|
| 58 | + $arResult = $this->convertXMLToArray($response); |
|
| 59 | + if ($arResult['success']) { |
|
| 60 | 60 | $result = $arResult['result']; |
| 61 | 61 | } else { |
| 62 | 62 | $result = $arResult['error']; |
| 63 | - if ( openlog( "License", LOG_ODELAY, LOG_LOCAL7 ) ) { |
|
| 64 | - syslog( LOG_EMERG, $arResult['error'] ); |
|
| 63 | + if (openlog("License", LOG_ODELAY, LOG_LOCAL7)) { |
|
| 64 | + syslog(LOG_EMERG, $arResult['error']); |
|
| 65 | 65 | closelog(); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return mixed |
| 78 | 78 | */ |
| 79 | - public function getTrialLicense( $params ) { |
|
| 80 | - $data = [ |
|
| 79 | + public function getTrialLicense($params) { |
|
| 80 | + $data = [ |
|
| 81 | 81 | 'companyname' => $params['companyname'], |
| 82 | 82 | 'email' => $params['email'], |
| 83 | 83 | 'contact' => $params['contact'], |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | 'description' => 'get trial from askozia pbx', |
| 87 | 87 | 'product' => 11, |
| 88 | 88 | ]; |
| 89 | - $response = $this->curlPostRequest( 'gettrial', $data ); |
|
| 90 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 91 | - if ( $arResult['success'] ) { |
|
| 89 | + $response = $this->curlPostRequest('gettrial', $data); |
|
| 90 | + $arResult = $this->convertXMLToArray($response); |
|
| 91 | + if ($arResult['success']) { |
|
| 92 | 92 | $result = $arResult['result']; |
| 93 | 93 | } else { |
| 94 | 94 | $result = $arResult['error']; |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return bool - результат активации триала |
| 105 | 105 | */ |
| 106 | - public function addTrial( $productid = "11" ) { |
|
| 107 | - $data = [ 'product' => $productid ]; |
|
| 108 | - $response = $this->curlPostRequest( 'addtrial', $data ); |
|
| 109 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 110 | - if ( $arResult['success'] ) { |
|
| 106 | + public function addTrial($productid = "11") { |
|
| 107 | + $data = ['product' => $productid]; |
|
| 108 | + $response = $this->curlPostRequest('addtrial', $data); |
|
| 109 | + $arResult = $this->convertXMLToArray($response); |
|
| 110 | + if ($arResult['success']) { |
|
| 111 | 111 | $result = TRUE; |
| 112 | 112 | } else { |
| 113 | 113 | $result = $arResult['error']; |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return bool результат активации купона |
| 125 | 125 | */ |
| 126 | - public function activateCoupon( $coupon ) { |
|
| 127 | - $data = [ 'coupon' => trim( $coupon ) ]; |
|
| 128 | - $response = $this->curlPostRequest( 'activatecoupon', $data ); |
|
| 129 | - $arResult = $this->convertXMLToArray( $response ); |
|
| 130 | - if ( $arResult['success'] ) { |
|
| 126 | + public function activateCoupon($coupon) { |
|
| 127 | + $data = ['coupon' => trim($coupon)]; |
|
| 128 | + $response = $this->curlPostRequest('activatecoupon', $data); |
|
| 129 | + $arResult = $this->convertXMLToArray($response); |
|
| 130 | + if ($arResult['success']) { |
|
| 131 | 131 | $result = TRUE; |
| 132 | 132 | } else { |
| 133 | 133 | $result = $arResult['error']; |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param $newKey - новый ключ |
| 143 | 143 | */ |
| 144 | - public function changeLicenseKey( $newKey ) { |
|
| 145 | - $this->curlPostRequest( 'changekey', [ 'key' => $newKey ] ); |
|
| 144 | + public function changeLicenseKey($newKey) { |
|
| 145 | + $this->curlPostRequest('changekey', ['key' => $newKey]); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -152,16 +152,16 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | - private function convertXMLToArray( $text ) { |
|
| 155 | + private function convertXMLToArray($text) { |
|
| 156 | 156 | |
| 157 | - $json_data = json_decode( $text, TRUE ); |
|
| 158 | - if (is_null($json_data)){ |
|
| 159 | - $text = str_replace( '\n', "\n", $text ); |
|
| 160 | - $text = str_replace( '\"', '"', $text ); |
|
| 157 | + $json_data = json_decode($text, TRUE); |
|
| 158 | + if (is_null($json_data)) { |
|
| 159 | + $text = str_replace('\n', "\n", $text); |
|
| 160 | + $text = str_replace('\"', '"', $text); |
|
| 161 | 161 | |
| 162 | - $json_data = json_decode( $text, TRUE ); |
|
| 162 | + $json_data = json_decode($text, TRUE); |
|
| 163 | 163 | } |
| 164 | - if ( ! isset( $json_data['error'] ) ) { |
|
| 164 | + if (!isset($json_data['error'])) { |
|
| 165 | 165 | $text_xml = urldecode($json_data['result']); |
| 166 | 166 | libxml_use_internal_errors(true); |
| 167 | 167 | $doc = simplexml_load_string($text_xml); |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | $doc = $text_xml; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $result = ['success' => TRUE, 'result' => $doc]; |
|
| 174 | - }elseif ( isset( $json_data['error'] ) ) { |
|
| 175 | - $result = [ 'success' => FALSE, 'error' => $json_data['error'] ]; |
|
| 173 | + $result = ['success' => TRUE, 'result' => $doc]; |
|
| 174 | + }elseif (isset($json_data['error'])) { |
|
| 175 | + $result = ['success' => FALSE, 'error' => $json_data['error']]; |
|
| 176 | 176 | } else { |
| 177 | - $result = [ 'success' => FALSE, 'error' => $json_data ]; |
|
| 177 | + $result = ['success' => FALSE, 'error' => $json_data]; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $result; |
@@ -10,11 +10,13 @@ discard block |
||
| 10 | 10 | use Phalcon\Mvc\User\Component; |
| 11 | 11 | use Mikopbx\License; |
| 12 | 12 | |
| 13 | -class LicenseWorker extends Component { |
|
| 13 | +class LicenseWorker extends Component |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | private $serverUrl; |
| 16 | 17 | |
| 17 | - function __construct( $serverUrl = 'http://127.0.0.1:8222' ) { |
|
| 18 | + function __construct( $serverUrl = 'http://127.0.0.1:8222' ) |
|
| 19 | + { |
|
| 18 | 20 | $this->serverUrl = $serverUrl; |
| 19 | 21 | } |
| 20 | 22 | |
@@ -26,7 +28,8 @@ discard block |
||
| 26 | 28 | * |
| 27 | 29 | * @return mixed |
| 28 | 30 | */ |
| 29 | - private function curlPostRequest( $metod, $data = NULL ) { |
|
| 31 | + private function curlPostRequest( $metod, $data = NULL ) |
|
| 32 | + { |
|
| 30 | 33 | $url = $this->serverUrl . "/license.api/$metod"; |
| 31 | 34 | $ch = curl_init(); |
| 32 | 35 | curl_setopt( $ch, CURLOPT_URL, $url ); |
@@ -52,7 +55,8 @@ discard block |
||
| 52 | 55 | * |
| 53 | 56 | * @return array |
| 54 | 57 | */ |
| 55 | - public function getLicenseInfo( $key ) { |
|
| 58 | + public function getLicenseInfo( $key ) |
|
| 59 | + { |
|
| 56 | 60 | $response = $this->curlPostRequest( 'getlicenseinfo', |
| 57 | 61 | [ 'key' => $key ] ); |
| 58 | 62 | $arResult = $this->convertXMLToArray( $response ); |
@@ -76,7 +80,8 @@ discard block |
||
| 76 | 80 | * |
| 77 | 81 | * @return mixed |
| 78 | 82 | */ |
| 79 | - public function getTrialLicense( $params ) { |
|
| 83 | + public function getTrialLicense( $params ) |
|
| 84 | + { |
|
| 80 | 85 | $data = [ |
| 81 | 86 | 'companyname' => $params['companyname'], |
| 82 | 87 | 'email' => $params['email'], |
@@ -103,7 +108,8 @@ discard block |
||
| 103 | 108 | * |
| 104 | 109 | * @return bool - результат активации триала |
| 105 | 110 | */ |
| 106 | - public function addTrial( $productid = "11" ) { |
|
| 111 | + public function addTrial( $productid = "11" ) |
|
| 112 | + { |
|
| 107 | 113 | $data = [ 'product' => $productid ]; |
| 108 | 114 | $response = $this->curlPostRequest( 'addtrial', $data ); |
| 109 | 115 | $arResult = $this->convertXMLToArray( $response ); |
@@ -123,7 +129,8 @@ discard block |
||
| 123 | 129 | * |
| 124 | 130 | * @return bool результат активации купона |
| 125 | 131 | */ |
| 126 | - public function activateCoupon( $coupon ) { |
|
| 132 | + public function activateCoupon( $coupon ) |
|
| 133 | + { |
|
| 127 | 134 | $data = [ 'coupon' => trim( $coupon ) ]; |
| 128 | 135 | $response = $this->curlPostRequest( 'activatecoupon', $data ); |
| 129 | 136 | $arResult = $this->convertXMLToArray( $response ); |
@@ -141,7 +148,8 @@ discard block |
||
| 141 | 148 | * |
| 142 | 149 | * @param $newKey - новый ключ |
| 143 | 150 | */ |
| 144 | - public function changeLicenseKey( $newKey ) { |
|
| 151 | + public function changeLicenseKey( $newKey ) |
|
| 152 | + { |
|
| 145 | 153 | $this->curlPostRequest( 'changekey', [ 'key' => $newKey ] ); |
| 146 | 154 | } |
| 147 | 155 | |
@@ -152,7 +160,8 @@ discard block |
||
| 152 | 160 | * |
| 153 | 161 | * @return array |
| 154 | 162 | */ |
| 155 | - private function convertXMLToArray( $text ) { |
|
| 163 | + private function convertXMLToArray( $text ) |
|
| 164 | + { |
|
| 156 | 165 | |
| 157 | 166 | $json_data = json_decode( $text, TRUE ); |
| 158 | 167 | if (is_null($json_data)){ |
@@ -171,7 +180,7 @@ discard block |
||
| 171 | 180 | } |
| 172 | 181 | |
| 173 | 182 | $result = ['success' => TRUE, 'result' => $doc]; |
| 174 | - }elseif ( isset( $json_data['error'] ) ) { |
|
| 183 | + } elseif ( isset( $json_data['error'] ) ) { |
|
| 175 | 184 | $result = [ 'success' => FALSE, 'error' => $json_data['error'] ]; |
| 176 | 185 | } else { |
| 177 | 186 | $result = [ 'success' => FALSE, 'error' => $json_data ]; |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return mixed |
| 28 | 28 | */ |
| 29 | - private function curlPostRequest( $metod, $data = NULL ) { |
|
| 29 | + private function curlPostRequest( $metod, $data = null ) { |
|
| 30 | 30 | $url = $this->serverUrl . "/license.api/$metod"; |
| 31 | 31 | $ch = curl_init(); |
| 32 | 32 | curl_setopt( $ch, CURLOPT_URL, $url ); |
| 33 | 33 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
| 34 | 34 | curl_setopt( $ch, CURLOPT_TIMEOUT, 25 ); |
| 35 | - if ( $data != NULL ) { |
|
| 35 | + if ( $data != null ) { |
|
| 36 | 36 | $params = http_build_query( $data ); |
| 37 | 37 | curl_setopt( $ch, CURLOPT_POST, 1 ); |
| 38 | 38 | curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $response = $this->curlPostRequest( 'addtrial', $data ); |
| 109 | 109 | $arResult = $this->convertXMLToArray( $response ); |
| 110 | 110 | if ( $arResult['success'] ) { |
| 111 | - $result = TRUE; |
|
| 111 | + $result = true; |
|
| 112 | 112 | } else { |
| 113 | 113 | $result = $arResult['error']; |
| 114 | 114 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $response = $this->curlPostRequest( 'activatecoupon', $data ); |
| 129 | 129 | $arResult = $this->convertXMLToArray( $response ); |
| 130 | 130 | if ( $arResult['success'] ) { |
| 131 | - $result = TRUE; |
|
| 131 | + $result = true; |
|
| 132 | 132 | } else { |
| 133 | 133 | $result = $arResult['error']; |
| 134 | 134 | } |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | private function convertXMLToArray( $text ) { |
| 156 | 156 | |
| 157 | - $json_data = json_decode( $text, TRUE ); |
|
| 157 | + $json_data = json_decode( $text, true ); |
|
| 158 | 158 | if (is_null($json_data)){ |
| 159 | 159 | $text = str_replace( '\n', "\n", $text ); |
| 160 | 160 | $text = str_replace( '\"', '"', $text ); |
| 161 | 161 | |
| 162 | - $json_data = json_decode( $text, TRUE ); |
|
| 162 | + $json_data = json_decode( $text, true ); |
|
| 163 | 163 | } |
| 164 | 164 | if ( ! isset( $json_data['error'] ) ) { |
| 165 | 165 | $text_xml = urldecode($json_data['result']); |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | $doc = $text_xml; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $result = ['success' => TRUE, 'result' => $doc]; |
|
| 173 | + $result = ['success' => true, 'result' => $doc]; |
|
| 174 | 174 | }elseif ( isset( $json_data['error'] ) ) { |
| 175 | - $result = [ 'success' => FALSE, 'error' => $json_data['error'] ]; |
|
| 175 | + $result = [ 'success' => false, 'error' => $json_data['error'] ]; |
|
| 176 | 176 | } else { |
| 177 | - $result = [ 'success' => FALSE, 'error' => $json_data ]; |
|
| 177 | + $result = [ 'success' => false, 'error' => $json_data ]; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $result; |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | public function cidr2netmask($cidr) |
| 16 | 16 | { |
| 17 | 17 | $bin = ''; |
| 18 | - for( $i = 1; $i <= 32; $i++ ) |
|
| 18 | + for ($i = 1; $i <= 32; $i++) |
|
| 19 | 19 | $bin .= $cidr >= $i ? '1' : '0'; |
| 20 | 20 | |
| 21 | 21 | $netmask = long2ip(bindec($bin)); |
| 22 | 22 | |
| 23 | - if ( $netmask == "0.0.0.0") |
|
| 23 | + if ($netmask == "0.0.0.0") |
|
| 24 | 24 | return false; |
| 25 | 25 | |
| 26 | 26 | return $netmask; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | // e.g. 10.0.2.56/21 = 10.0.0.0 |
| 31 | 31 | public function cidr2network($ip, $cidr) |
| 32 | 32 | { |
| 33 | - $network = long2ip((ip2long($ip)) & ((-1 << (32 - (int)$cidr)))); |
|
| 33 | + $network = long2ip((ip2long($ip)) & ((-1 << (32 - (int) $cidr)))); |
|
| 34 | 34 | |
| 35 | 35 | return $network; |
| 36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $bits = 0; |
| 43 | 43 | $netmask = explode(".", $netmask); |
| 44 | 44 | |
| 45 | - foreach($netmask as $octect) |
|
| 45 | + foreach ($netmask as $octect) |
|
| 46 | 46 | $bits += strlen(str_replace("0", "", decbin($octect))); |
| 47 | 47 | |
| 48 | 48 | return $bits; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | // is 192.168.50.2 in 192.168.30.0/23 == false |
| 54 | 54 | public function cidr_match($ip, $network, $cidr) |
| 55 | 55 | { |
| 56 | - if ((ip2long($ip) & ~((1 << (32 - $cidr)) - 1) ) == ip2long($network)) |
|
| 56 | + if ((ip2long($ip) & ~((1 << (32 - $cidr)) - 1)) == ip2long($network)) |
|
| 57 | 57 | { |
| 58 | 58 | return true; |
| 59 | 59 | } |
@@ -15,13 +15,15 @@ discard block |
||
| 15 | 15 | public function cidr2netmask($cidr) |
| 16 | 16 | { |
| 17 | 17 | $bin = ''; |
| 18 | - for( $i = 1; $i <= 32; $i++ ) |
|
| 19 | - $bin .= $cidr >= $i ? '1' : '0'; |
|
| 18 | + for( $i = 1; $i <= 32; $i++ ) { |
|
| 19 | + $bin .= $cidr >= $i ? '1' : '0'; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $netmask = long2ip(bindec($bin)); |
| 22 | 23 | |
| 23 | - if ( $netmask == "0.0.0.0") |
|
| 24 | - return false; |
|
| 24 | + if ( $netmask == "0.0.0.0") { |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | return $netmask; |
| 27 | 29 | } |
@@ -42,8 +44,9 @@ discard block |
||
| 42 | 44 | $bits = 0; |
| 43 | 45 | $netmask = explode(".", $netmask); |
| 44 | 46 | |
| 45 | - foreach($netmask as $octect) |
|
| 46 | - $bits += strlen(str_replace("0", "", decbin($octect))); |
|
| 47 | + foreach($netmask as $octect) { |
|
| 48 | + $bits += strlen(str_replace("0", "", decbin($octect))); |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | return $bits; |
| 49 | 52 | } |
@@ -10,15 +10,15 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | $arNameSpaces = [ |
| 13 | - 'Models' => $config->application->modelsDir, |
|
| 13 | + 'Models' => $config->application->modelsDir, |
|
| 14 | 14 | ]; |
| 15 | 15 | |
| 16 | 16 | $arDirs = [ |
| 17 | - $config->application->controllersDir, |
|
| 18 | - $config->application->pluginsDir, |
|
| 19 | - $config->application->libraryDir, |
|
| 20 | - $config->application->modelsDir, |
|
| 21 | - $config->application->formsDir, |
|
| 17 | + $config->application->controllersDir, |
|
| 18 | + $config->application->pluginsDir, |
|
| 19 | + $config->application->libraryDir, |
|
| 20 | + $config->application->modelsDir, |
|
| 21 | + $config->application->formsDir, |
|
| 22 | 22 | ]; |
| 23 | 23 | |
| 24 | 24 | $arrFiles[] = $config->application->backendDir.'modules/ClassLoader.php'; |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $arrFiles[] = $config->application->backendDir.'library/vendor/autoload.php'; |
| 26 | 26 | $loader->registerFiles($arrFiles); |
| 27 | 27 | $loader->registerNamespaces($arNameSpaces); |
| 28 | -$loader->registerDirs( $arDirs ); |
|
| 28 | +$loader->registerDirs($arDirs); |
|
| 29 | 29 | $loader->register(); |
| 30 | 30 | |
| 31 | 31 | // Зарегаем классы модулей |