@@ -26,8 +26,8 @@ |
||
26 | 26 | $this->add(new Hidden($key)); |
27 | 27 | break; |
28 | 28 | case "description": |
29 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
30 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
29 | + $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
30 | + $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
31 | 31 | break; |
32 | 32 | case "type": |
33 | 33 | $select= new Select($key, |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function initialize($entity = null, $options = null) |
19 | 19 | { |
20 | - foreach ($entity as $key=>$value){ |
|
21 | - switch ($key){ |
|
20 | + foreach ($entity as $key=>$value) { |
|
21 | + switch ($key) { |
|
22 | 22 | |
23 | 23 | case "id": |
24 | 24 | case "uniqid": |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | $this->add(new Hidden($key)); |
27 | 27 | break; |
28 | 28 | case "description": |
29 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
30 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
29 | + $rows = max(round(strlen($value) / 95), 2); |
|
30 | + $this->add(new TextArea($key, ["rows" => $rows])); |
|
31 | 31 | break; |
32 | 32 | case "type": |
33 | - $select= new Select($key, |
|
33 | + $select = new Select($key, |
|
34 | 34 | array( |
35 | 35 | 'php'=>$this->translation->_("da_TypePhp"), |
36 | 36 | 'plaintext'=>$this->translation->_("da_TypePlaintext") |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->add($select); |
47 | 47 | break; |
48 | 48 | case "applicationlogic": |
49 | - $this->add(new Hidden($key,['value'=>''])); |
|
49 | + $this->add(new Hidden($key, ['value'=>''])); |
|
50 | 50 | break; |
51 | 51 | default: |
52 | 52 | $this->add(new Text($key)); |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | { |
21 | 21 | public function initialize($entity = null, $options = null) |
22 | 22 | { |
23 | - $arrRealInterfaces = []; |
|
23 | + $arrRealInterfaces = []; |
|
24 | 24 | |
25 | 25 | $this->add(new Text('hostname')); |
26 | 26 | $this->add(new Text('gateway',array('class'=>'ipaddress'))); |
27 | 27 | $this->add(new Text('primarydns',array('class'=>'ipaddress'))); |
28 | 28 | $this->add(new Text('secondarydns',array('class'=>'ipaddress'))); |
29 | 29 | $this->add(new Text('extipaddr',array('class'=>'ipaddress'))); |
30 | - $this->add(new Text('exthostname')); |
|
30 | + $this->add(new Text('exthostname')); |
|
31 | 31 | |
32 | 32 | $cheskArr=array('value'=>null); |
33 | 33 | if ($entity->topology=='private') { |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | ))); |
110 | 110 | |
111 | 111 | $arrInterfaces[$eth->id]= $eth->name.' ('.$eth->interface.(($eth->vlanid>0)? '.'.$eth->vlanid:'').')'; |
112 | - if ( ! in_array( $eth->interface, $arrRealInterfaces ) ) { |
|
113 | - $arrRealInterfaces[ $eth->id ] = $eth->interface; |
|
114 | - } |
|
112 | + if ( ! in_array( $eth->interface, $arrRealInterfaces ) ) { |
|
113 | + $arrRealInterfaces[ $eth->id ] = $eth->interface; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | 118 | unset($arrInterfaces['new']); |
119 | - unset( $arrRealInterfaces['new'] ); |
|
119 | + unset( $arrRealInterfaces['new'] ); |
|
120 | 120 | // Выбор интернет интерфейса |
121 | 121 | $internetInterface = new Select('internet_interface', $arrInterfaces, array( |
122 | 122 | 'using' => array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | |
133 | 133 | // Поля для вновь добавляемого интерфейса |
134 | - $newInterface = new Select( 'interface_new', $arrRealInterfaces, array( |
|
134 | + $newInterface = new Select( 'interface_new', $arrRealInterfaces, array( |
|
135 | 135 | 'using' => array( |
136 | 136 | 'id', |
137 | 137 | 'name' |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | $arrRealInterfaces = []; |
24 | 24 | |
25 | 25 | $this->add(new Text('hostname')); |
26 | - $this->add(new Text('gateway',array('class'=>'ipaddress'))); |
|
27 | - $this->add(new Text('primarydns',array('class'=>'ipaddress'))); |
|
28 | - $this->add(new Text('secondarydns',array('class'=>'ipaddress'))); |
|
29 | - $this->add(new Text('extipaddr',array('class'=>'ipaddress'))); |
|
26 | + $this->add(new Text('gateway', array('class'=>'ipaddress'))); |
|
27 | + $this->add(new Text('primarydns', array('class'=>'ipaddress'))); |
|
28 | + $this->add(new Text('secondarydns', array('class'=>'ipaddress'))); |
|
29 | + $this->add(new Text('extipaddr', array('class'=>'ipaddress'))); |
|
30 | 30 | $this->add(new Text('exthostname')); |
31 | 31 | |
32 | - $cheskArr=array('value'=>null); |
|
33 | - if ($entity->topology=='private') { |
|
34 | - $cheskArr = array('checked' => 'checked','value'=>null); |
|
32 | + $cheskArr = array('value'=>null); |
|
33 | + if ($entity->topology == 'private') { |
|
34 | + $cheskArr = array('checked' => 'checked', 'value'=>null); |
|
35 | 35 | } |
36 | - $this->add(new Check('usenat',$cheskArr)); |
|
36 | + $this->add(new Check('usenat', $cheskArr)); |
|
37 | 37 | |
38 | 38 | foreach ($options['eths'] as $eth) { |
39 | 39 | $this->add(new Hidden('interface_'.$eth->id, array( |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | ))); |
46 | 46 | |
47 | 47 | // DHCP |
48 | - $cheskarr=array('value'=>null); |
|
48 | + $cheskarr = array('value'=>null); |
|
49 | 49 | if ($eth->dhcp) { |
50 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
50 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
51 | 51 | } |
52 | 52 | |
53 | - $this->add(new Check('dhcp_'.$eth->id,$cheskarr)); |
|
53 | + $this->add(new Check('dhcp_'.$eth->id, $cheskarr)); |
|
54 | 54 | |
55 | 55 | $this->add(new Text('ipaddr_'.$eth->id, array( |
56 | 56 | 'value' => $eth->ipaddr, |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | 'value' => $eth->vlanid |
109 | 109 | ))); |
110 | 110 | |
111 | - $arrInterfaces[$eth->id]= $eth->name.' ('.$eth->interface.(($eth->vlanid>0)? '.'.$eth->vlanid:'').')'; |
|
112 | - if ( ! in_array( $eth->interface, $arrRealInterfaces ) ) { |
|
113 | - $arrRealInterfaces[ $eth->id ] = $eth->interface; |
|
111 | + $arrInterfaces[$eth->id] = $eth->name.' ('.$eth->interface.(($eth->vlanid > 0) ? '.'.$eth->vlanid : '').')'; |
|
112 | + if (!in_array($eth->interface, $arrRealInterfaces)) { |
|
113 | + $arrRealInterfaces[$eth->id] = $eth->interface; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | 118 | unset($arrInterfaces['new']); |
119 | - unset( $arrRealInterfaces['new'] ); |
|
119 | + unset($arrRealInterfaces['new']); |
|
120 | 120 | // Выбор интернет интерфейса |
121 | 121 | $internetInterface = new Select('internet_interface', $arrInterfaces, array( |
122 | 122 | 'using' => array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | |
133 | 133 | // Поля для вновь добавляемого интерфейса |
134 | - $newInterface = new Select( 'interface_new', $arrRealInterfaces, array( |
|
134 | + $newInterface = new Select('interface_new', $arrRealInterfaces, array( |
|
135 | 135 | 'using' => array( |
136 | 136 | 'id', |
137 | 137 | 'name' |
@@ -22,13 +22,13 @@ |
||
22 | 22 | |
23 | 23 | case "id": |
24 | 24 | case "content": |
25 | - case "filepath": |
|
25 | + case "filepath": |
|
26 | 26 | case "***ALL HIDDEN ABOVE***": |
27 | 27 | $this->add(new Hidden($key)); |
28 | 28 | break; |
29 | 29 | case "description": |
30 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
31 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
30 | + $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
31 | + $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
32 | 32 | break; |
33 | 33 | case "mode": |
34 | 34 | $select= new Select($key, |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function initialize($entity = null, $options = null) |
19 | 19 | { |
20 | - foreach ($entity as $key=>$value){ |
|
21 | - switch ($key){ |
|
20 | + foreach ($entity as $key=>$value) { |
|
21 | + switch ($key) { |
|
22 | 22 | |
23 | 23 | case "id": |
24 | 24 | case "content": |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | $this->add(new Hidden($key)); |
28 | 28 | break; |
29 | 29 | case "description": |
30 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
31 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
30 | + $rows = max(round(strlen($value) / 95), 2); |
|
31 | + $this->add(new TextArea($key, ["rows" => $rows])); |
|
32 | 32 | break; |
33 | 33 | case "mode": |
34 | - $select= new Select($key, |
|
34 | + $select = new Select($key, |
|
35 | 35 | array( |
36 | 36 | 'none'=>$this->translation->_("cf_FileActionsNone"), |
37 | 37 | 'append'=>$this->translation->_("cf_FileActionsAppend"), |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | 'fewestcalls'=>$this->translation->_('cq_fewestcalls'), |
42 | 42 | 'random'=>$this->translation->_('cq_random'), |
43 | 43 | 'rrmemory'=>$this->translation->_('cq_rrmemory'), |
44 | - 'linear'=>$this->translation->_('cq_linear'), |
|
44 | + 'linear'=>$this->translation->_('cq_linear'), |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | $strategy= new Select('strategy', $arrActions, array( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->add($strategy); |
57 | 57 | |
58 | 58 | |
59 | - // Seconds_to_ring_each_member - Seconds between announcements |
|
59 | + // Seconds_to_ring_each_member - Seconds between announcements |
|
60 | 60 | $this->add(new Numeric('seconds_to_ring_each_member',array("maxlength"=>2,"style"=>"width: 80px;"))); |
61 | 61 | |
62 | 62 | // Secondsforwrapup - Seconds for Wrap Up |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | |
106 | 106 | // Periodicannouncesoundid |
107 | 107 | $periodicannouncesoundid= new Select('periodic_announce_sound_id', $options['soundfiles'], array( |
108 | - 'using' => array( |
|
108 | + 'using' => array( |
|
109 | 109 | 'id', |
110 | 110 | 'name' |
111 | 111 | ), |
112 | - 'useEmpty' => TRUE, |
|
113 | - 'class' => 'ui selection dropdown search periodic-announce-sound-id-select', |
|
112 | + 'useEmpty' => TRUE, |
|
113 | + 'class' => 'ui selection dropdown search periodic-announce-sound-id-select', |
|
114 | 114 | )); |
115 | 115 | $this->add($periodicannouncesoundid); |
116 | 116 | |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | |
192 | 192 | |
193 | 193 | // Description |
194 | - $rows = max( round( strlen( $entity->description ) / 95 ), 2 ); |
|
195 | - $this->add( new TextArea( 'description', [ "rows" => $rows ] ) ); |
|
194 | + $rows = max( round( strlen( $entity->description ) / 95 ), 2 ); |
|
195 | + $this->add( new TextArea( 'description', [ "rows" => $rows ] ) ); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | // Strategy |
38 | - $arrActions=array( |
|
38 | + $arrActions = array( |
|
39 | 39 | 'ringall'=>$this->translation->_('cq_ringall'), |
40 | 40 | 'leastrecent'=>$this->translation->_('cq_leastrecent'), |
41 | 41 | 'fewestcalls'=>$this->translation->_('cq_fewestcalls'), |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'linear'=>$this->translation->_('cq_linear'), |
45 | 45 | ); |
46 | 46 | |
47 | - $strategy= new Select('strategy', $arrActions, array( |
|
47 | + $strategy = new Select('strategy', $arrActions, array( |
|
48 | 48 | 'using' => array( |
49 | 49 | 'id', |
50 | 50 | 'name' |
@@ -57,26 +57,26 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | // Seconds_to_ring_each_member - Seconds between announcements |
60 | - $this->add(new Numeric('seconds_to_ring_each_member',array("maxlength"=>2,"style"=>"width: 80px;"))); |
|
60 | + $this->add(new Numeric('seconds_to_ring_each_member', array("maxlength"=>2, "style"=>"width: 80px;"))); |
|
61 | 61 | |
62 | 62 | // Secondsforwrapup - Seconds for Wrap Up |
63 | - $this->add(new Numeric('seconds_for_wrapup',array("maxlength"=>2,"style"=>"width: 80px;"))); |
|
63 | + $this->add(new Numeric('seconds_for_wrapup', array("maxlength"=>2, "style"=>"width: 80px;"))); |
|
64 | 64 | |
65 | 65 | // Recivecallswhileonacall |
66 | - $cheskarr=array('value'=>null); |
|
66 | + $cheskarr = array('value'=>null); |
|
67 | 67 | if ($entity->recive_calls_while_on_a_call) { |
68 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
68 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
69 | 69 | } |
70 | 70 | |
71 | - $this->add(new Check('recive_calls_while_on_a_call',$cheskarr)); |
|
71 | + $this->add(new Check('recive_calls_while_on_a_call', $cheskarr)); |
|
72 | 72 | |
73 | 73 | // Callerhear |
74 | - $arrActions=array( |
|
74 | + $arrActions = array( |
|
75 | 75 | 'ringing'=>$this->translation->_('cq_ringing'), |
76 | 76 | 'moh'=>$this->translation->_('cq_moh'), |
77 | 77 | ); |
78 | 78 | |
79 | - $callerhear= new Select('caller_hear', $arrActions, array( |
|
79 | + $callerhear = new Select('caller_hear', $arrActions, array( |
|
80 | 80 | 'using' => array( |
81 | 81 | 'id', |
82 | 82 | 'name' |
@@ -87,24 +87,24 @@ discard block |
||
87 | 87 | $this->add($callerhear); |
88 | 88 | |
89 | 89 | // Announceposition |
90 | - $cheskarr=array('value'=>null); |
|
90 | + $cheskarr = array('value'=>null); |
|
91 | 91 | if ($entity->announce_position) { |
92 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
92 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
93 | 93 | } |
94 | 94 | |
95 | - $this->add(new Check('announce_position',$cheskarr)); |
|
95 | + $this->add(new Check('announce_position', $cheskarr)); |
|
96 | 96 | |
97 | 97 | // Announceholdtime |
98 | - $cheskarr=array('value'=>null); |
|
98 | + $cheskarr = array('value'=>null); |
|
99 | 99 | if ($entity->announce_hold_time) { |
100 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
100 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
101 | 101 | } |
102 | 102 | |
103 | - $this->add(new Check('announce_hold_time',$cheskarr)); |
|
103 | + $this->add(new Check('announce_hold_time', $cheskarr)); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | // Periodicannouncesoundid |
107 | - $periodicannouncesoundid= new Select('periodic_announce_sound_id', $options['soundfiles'], array( |
|
107 | + $periodicannouncesoundid = new Select('periodic_announce_sound_id', $options['soundfiles'], array( |
|
108 | 108 | 'using' => array( |
109 | 109 | 'id', |
110 | 110 | 'name' |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->add($periodicannouncesoundid); |
116 | 116 | |
117 | 117 | // Periodicannouncefrequency - Seconds between announcements |
118 | - $this->add(new Numeric('periodic_announce_frequency',array("maxlength"=>2,"style"=>"width: 80px;"))); |
|
118 | + $this->add(new Numeric('periodic_announce_frequency', array("maxlength"=>2, "style"=>"width: 80px;"))); |
|
119 | 119 | |
120 | 120 | // Timeouttoredirecttoextension |
121 | 121 | $ringlength = $entity->timeout_to_redirect_to_extension; |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | array( |
124 | 124 | "maxlength"=>2, |
125 | 125 | "style"=>"width: 80px;", |
126 | - "value"=>($ringlength>0)?$ringlength:'' |
|
126 | + "value"=>($ringlength > 0) ? $ringlength : '' |
|
127 | 127 | ))); |
128 | 128 | |
129 | 129 | // Timeoutextension |
130 | - $extension= new Select('timeout_extension', $options['extensions'], array( |
|
130 | + $extension = new Select('timeout_extension', $options['extensions'], array( |
|
131 | 131 | 'using' => array( |
132 | 132 | 'id', |
133 | 133 | 'name' |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->add($extension); |
139 | 139 | |
140 | 140 | // Redirecttoextensionifempty |
141 | - $extension= new Select('redirect_to_extension_if_empty', $options['extensions'], array( |
|
141 | + $extension = new Select('redirect_to_extension_if_empty', $options['extensions'], array( |
|
142 | 142 | 'using' => array( |
143 | 143 | 'id', |
144 | 144 | 'name' |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | array( |
155 | 155 | "maxlength"=>2, |
156 | 156 | "style"=>"width: 80px;", |
157 | - "value"=>($ringlength>0)?$ringlength:'' |
|
157 | + "value"=>($ringlength > 0) ? $ringlength : '' |
|
158 | 158 | ))); |
159 | 159 | |
160 | 160 | // Redirecttoextensionifunanswered |
161 | - $extension= new Select('redirect_to_extension_if_unanswered', $options['extensions'], array( |
|
161 | + $extension = new Select('redirect_to_extension_if_unanswered', $options['extensions'], array( |
|
162 | 162 | 'using' => array( |
163 | 163 | 'id', |
164 | 164 | 'name' |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | array( |
175 | 175 | "maxlength"=>2, |
176 | 176 | "style"=>"width: 80px;", |
177 | - "value"=>($ringlength>0)?$ringlength:'' |
|
177 | + "value"=>($ringlength > 0) ? $ringlength : '' |
|
178 | 178 | ))); |
179 | 179 | |
180 | 180 | // Redirecttoextensionifrepeatexceeded |
181 | 181 | |
182 | - $extension= new Select('redirect_to_extension_if_repeat_exceeded', $options['extensions'], array( |
|
182 | + $extension = new Select('redirect_to_extension_if_repeat_exceeded', $options['extensions'], array( |
|
183 | 183 | 'using' => array( |
184 | 184 | 'id', |
185 | 185 | 'name' |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | |
192 | 192 | |
193 | 193 | // Description |
194 | - $rows = max( round( strlen( $entity->description ) / 95 ), 2 ); |
|
195 | - $this->add( new TextArea( 'description', [ "rows" => $rows ] ) ); |
|
194 | + $rows = max(round(strlen($entity->description) / 95), 2); |
|
195 | + $this->add(new TextArea('description', ["rows" => $rows])); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | } |
@@ -109,7 +109,7 @@ |
||
109 | 109 | 'id', |
110 | 110 | 'name' |
111 | 111 | ), |
112 | - 'useEmpty' => TRUE, |
|
112 | + 'useEmpty' => true, |
|
113 | 113 | 'class' => 'ui selection dropdown search periodic-announce-sound-id-select', |
114 | 114 | )); |
115 | 115 | $this->add($periodicannouncesoundid); |
@@ -60,22 +60,22 @@ |
||
60 | 60 | case 'weekday_from' : |
61 | 61 | case 'weekday_to' : |
62 | 62 | $action= new Select($key, $options['week-days'], array( |
63 | - 'using' => array( |
|
63 | + 'using' => array( |
|
64 | 64 | 'id', |
65 | 65 | 'name' |
66 | 66 | ), |
67 | - 'useEmpty' => true, |
|
68 | - 'value' => empty( $entity->$key ) ? - 1 : $value, |
|
69 | - 'class' => 'ui selection' |
|
67 | + 'useEmpty' => true, |
|
68 | + 'value' => empty( $entity->$key ) ? - 1 : $value, |
|
69 | + 'class' => 'ui selection' |
|
70 | 70 | )); |
71 | 71 | $this->add($action); |
72 | 72 | break; |
73 | 73 | case 'description' : |
74 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
75 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
76 | - break; |
|
74 | + $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
75 | + $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
76 | + break; |
|
77 | 77 | |
78 | - default : |
|
78 | + default : |
|
79 | 79 | $this->add(new Text($key)); |
80 | 80 | |
81 | 81 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | public function initialize($entity = null, $options = null) |
21 | 21 | { |
22 | 22 | foreach ($entity as $key=>$value) { |
23 | - switch ($key){ |
|
23 | + switch ($key) { |
|
24 | 24 | case 'id' : |
25 | 25 | $this->add(new Hidden($key)); |
26 | 26 | break; |
27 | 27 | case 'extension' : |
28 | - $extension= new Select($key, $options['extensions'], array( |
|
28 | + $extension = new Select($key, $options['extensions'], array( |
|
29 | 29 | 'using' => array( |
30 | 30 | 'id', |
31 | 31 | 'name' |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->add($extension); |
37 | 37 | break; |
38 | 38 | case 'audio_message_id' : |
39 | - $audiomessageid= new Select($key, $options['audio-message'], array( |
|
39 | + $audiomessageid = new Select($key, $options['audio-message'], array( |
|
40 | 40 | 'using' => array( |
41 | 41 | 'id', |
42 | 42 | 'name' |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->add($audiomessageid); |
48 | 48 | break; |
49 | 49 | case 'action' : |
50 | - $action= new Select($key, $options['available-actions'], array( |
|
50 | + $action = new Select($key, $options['available-actions'], array( |
|
51 | 51 | 'using' => array( |
52 | 52 | 'id', |
53 | 53 | 'name' |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | break; |
60 | 60 | case 'weekday_from' : |
61 | 61 | case 'weekday_to' : |
62 | - $action= new Select($key, $options['week-days'], array( |
|
62 | + $action = new Select($key, $options['week-days'], array( |
|
63 | 63 | 'using' => array( |
64 | 64 | 'id', |
65 | 65 | 'name' |
66 | 66 | ), |
67 | 67 | 'useEmpty' => true, |
68 | - 'value' => empty( $entity->$key ) ? - 1 : $value, |
|
68 | + 'value' => empty($entity->$key) ? -1 : $value, |
|
69 | 69 | 'class' => 'ui selection' |
70 | 70 | )); |
71 | 71 | $this->add($action); |
72 | 72 | break; |
73 | 73 | case 'description' : |
74 | - $rows = max( round( strlen( $value ) / 95 ), 2 ); |
|
75 | - $this->add( new TextArea( $key, [ "rows" => $rows ] ) ); |
|
74 | + $rows = max(round(strlen($value) / 95), 2); |
|
75 | + $this->add(new TextArea($key, ["rows" => $rows])); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | default : |
@@ -15,11 +15,11 @@ |
||
15 | 15 | |
16 | 16 | class LicensingGetTrialForm extends Form { |
17 | 17 | |
18 | - public function initialize( $entity = NULL, $options = NULL ) { |
|
19 | - $this->add( new Text( 'companyname' ) ); |
|
20 | - $this->add( new Email( 'email' ) ); |
|
21 | - $this->add( new Text( 'contact' ) ); |
|
22 | - $this->add( new Numeric( 'inn' ) ); |
|
23 | - $this->add( new Text( 'telefone' ) ); |
|
24 | - } |
|
18 | + public function initialize( $entity = NULL, $options = NULL ) { |
|
19 | + $this->add( new Text( 'companyname' ) ); |
|
20 | + $this->add( new Email( 'email' ) ); |
|
21 | + $this->add( new Text( 'contact' ) ); |
|
22 | + $this->add( new Numeric( 'inn' ) ); |
|
23 | + $this->add( new Text( 'telefone' ) ); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -15,11 +15,11 @@ |
||
15 | 15 | |
16 | 16 | class LicensingGetTrialForm extends Form { |
17 | 17 | |
18 | - public function initialize( $entity = NULL, $options = NULL ) { |
|
19 | - $this->add( new Text( 'companyname' ) ); |
|
20 | - $this->add( new Email( 'email' ) ); |
|
21 | - $this->add( new Text( 'contact' ) ); |
|
22 | - $this->add( new Numeric( 'inn' ) ); |
|
23 | - $this->add( new Text( 'telefone' ) ); |
|
18 | + public function initialize($entity = NULL, $options = NULL) { |
|
19 | + $this->add(new Text('companyname')); |
|
20 | + $this->add(new Email('email')); |
|
21 | + $this->add(new Text('contact')); |
|
22 | + $this->add(new Numeric('inn')); |
|
23 | + $this->add(new Text('telefone')); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -13,9 +13,11 @@ |
||
13 | 13 | use Phalcon\Forms\Element\Numeric; |
14 | 14 | |
15 | 15 | |
16 | -class LicensingGetTrialForm extends Form { |
|
16 | +class LicensingGetTrialForm extends Form |
|
17 | +{ |
|
17 | 18 | |
18 | - public function initialize( $entity = NULL, $options = NULL ) { |
|
19 | + public function initialize( $entity = NULL, $options = NULL ) |
|
20 | + { |
|
19 | 21 | $this->add( new Text( 'companyname' ) ); |
20 | 22 | $this->add( new Email( 'email' ) ); |
21 | 23 | $this->add( new Text( 'contact' ) ); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | class LicensingGetTrialForm extends Form { |
17 | 17 | |
18 | - public function initialize( $entity = NULL, $options = NULL ) { |
|
18 | + public function initialize( $entity = null, $options = null ) { |
|
19 | 19 | $this->add( new Text( 'companyname' ) ); |
20 | 20 | $this->add( new Email( 'email' ) ); |
21 | 21 | $this->add( new Text( 'contact' ) ); |
@@ -77,13 +77,13 @@ |
||
77 | 77 | $this->add(new Check('newer_block_ip',$cheskarr)); |
78 | 78 | |
79 | 79 | |
80 | - // Local_network |
|
81 | - $cheskarr=array('value'=>null); |
|
82 | - if ($entity->local_network) { |
|
83 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
84 | - } |
|
80 | + // Local_network |
|
81 | + $cheskarr=array('value'=>null); |
|
82 | + if ($entity->local_network) { |
|
83 | + $cheskarr = array('checked' => 'checked','value'=>null); |
|
84 | + } |
|
85 | 85 | |
86 | - $this->add(new Check('local_network',$cheskarr)); |
|
86 | + $this->add(new Check('local_network',$cheskarr)); |
|
87 | 87 | |
88 | 88 | |
89 | 89 | } |
@@ -69,21 +69,21 @@ |
||
69 | 69 | $this->add($mask); |
70 | 70 | |
71 | 71 | // Newer_block_ip |
72 | - $cheskarr=array('value'=>null); |
|
72 | + $cheskarr = array('value'=>null); |
|
73 | 73 | if ($entity->newer_block_ip) { |
74 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
74 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
75 | 75 | } |
76 | 76 | |
77 | - $this->add(new Check('newer_block_ip',$cheskarr)); |
|
77 | + $this->add(new Check('newer_block_ip', $cheskarr)); |
|
78 | 78 | |
79 | 79 | |
80 | 80 | // Local_network |
81 | - $cheskarr=array('value'=>null); |
|
81 | + $cheskarr = array('value'=>null); |
|
82 | 82 | if ($entity->local_network) { |
83 | - $cheskarr = array('checked' => 'checked','value'=>null); |
|
83 | + $cheskarr = array('checked' => 'checked', 'value'=>null); |
|
84 | 84 | } |
85 | 85 | |
86 | - $this->add(new Check('local_network',$cheskarr)); |
|
86 | + $this->add(new Check('local_network', $cheskarr)); |
|
87 | 87 | |
88 | 88 | |
89 | 89 | } |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | * Read the configuration |
16 | 16 | */ |
17 | 17 | if (file_exists('/cf/conf/mikopbx.db')) { |
18 | - $file = require 'phalcon_settings.php'; |
|
19 | - require_once 'SentryErrorLogger.php'; |
|
18 | + $file = require 'phalcon_settings.php'; |
|
19 | + require_once 'SentryErrorLogger.php'; |
|
20 | 20 | } else { |
21 | - // Fallback to some default |
|
22 | - $file = require '../../config/Config.php'; |
|
23 | - require_once '../../../pbxcore/inc/SentryErrorLogger.php'; |
|
21 | + // Fallback to some default |
|
22 | + $file = require '../../config/Config.php'; |
|
23 | + require_once '../../../pbxcore/inc/SentryErrorLogger.php'; |
|
24 | 24 | } |
25 | 25 | $config = new Config($file); |
26 | 26 | |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | require_once '../app/config/services.php'; |
44 | 44 | try { |
45 | - $application = new Application($di); |
|
46 | - echo $application->handle()->getContent(); |
|
45 | + $application = new Application($di); |
|
46 | + echo $application->handle()->getContent(); |
|
47 | 47 | } catch (Exception $e) { |
48 | - $errorLogger->captureException($e); |
|
49 | - PhpError::exceptionHandler($e); |
|
50 | - echo $e->getMessage(); |
|
48 | + $errorLogger->captureException($e); |
|
49 | + PhpError::exceptionHandler($e); |
|
50 | + echo $e->getMessage(); |
|
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * Read the configuration |
16 | 16 | */ |
17 | 17 | if (file_exists('/cf/conf/mikopbx.db')) { |
18 | - $file = require 'phalcon_settings.php'; |
|
18 | + $file = require 'phalcon_settings.php'; |
|
19 | 19 | require_once 'SentryErrorLogger.php'; |
20 | 20 | } else { |
21 | 21 | // Fallback to some default |
22 | - $file = require '../../config/Config.php'; |
|
22 | + $file = require '../../config/Config.php'; |
|
23 | 23 | require_once '../../../pbxcore/inc/SentryErrorLogger.php'; |
24 | 24 | } |
25 | 25 | $config = new Config($file); |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | $errorLogger->init(); |
35 | 35 | |
36 | 36 | require_once '../../back-end/library/utilities/debug/PhpError.php'; |
37 | -register_shutdown_function(['\Utilities\Debug\PhpError','runtimeShutdown']); |
|
38 | -set_error_handler(['\Utilities\Debug\PhpError','errorHandler']); |
|
37 | +register_shutdown_function(['\Utilities\Debug\PhpError', 'runtimeShutdown']); |
|
38 | +set_error_handler(['\Utilities\Debug\PhpError', 'errorHandler']); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Load application services |
@@ -560,7 +560,6 @@ |
||
560 | 560 | * "function": "upload_audio_file" |
561 | 561 | * } |
562 | 562 | * Удаление аудио файла: |
563 | - |
|
564 | 563 | * curl -X POST -d '{"filename": "/storage/usbdisk1/mikopbx/tmp/2233333.wav"}' http://172.16.156.212/pbxcore/api/system/remove_audio_file; |
565 | 564 | * Обновление системы (офлайн) |
566 | 565 | * curl -X POST -d '{"filename": "/storage/usbdisk1/mikopbx/tmp/2019.4.200-mikopbx-generic-x86-64-linux.img"}' http://127.0.0.1/pbxcore/api/system/upgrade -H 'Cookie: XDEBUG_SESSION=PHPSTORM'; |
@@ -17,36 +17,36 @@ discard block |
||
17 | 17 | |
18 | 18 | // Create a events manager |
19 | 19 | $eventsManager = new EventsManager(); |
20 | -$eventsManager->attach('micro:beforeExecuteRoute', function (Event $event, Micro $app) { |
|
20 | +$eventsManager->attach('micro:beforeExecuteRoute', function(Event $event, Micro $app) { |
|
21 | 21 | // return true; |
22 | - if($_SERVER['REMOTE_ADDR'] === '127.0.0.1'){ |
|
22 | + if ($_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
23 | 23 | return true; |
24 | 24 | } |
25 | 25 | $config = $GLOBALS['g']['phalcon_settings']; |
26 | - if($config['application']['debugMode'] === true){ |
|
26 | + if ($config['application']['debugMode'] === true) { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | System::session_readonly(); |
30 | - if( isset($_SESSION['auth']) ){ |
|
30 | + if (isset($_SESSION['auth'])) { |
|
31 | 31 | return true; |
32 | 32 | } |
33 | 33 | // Исключения дла авторизации.content-disposition |
34 | 34 | $panel_pattern = [ |
35 | 35 | '/api/miko_ajam/getvar', // Тут авторизация basic |
36 | - '/api/cdr/records', // Тут авторизация basic |
|
37 | - '/api/cdr/playback', // Защищен fail2ban |
|
36 | + '/api/cdr/records', // Тут авторизация basic |
|
37 | + '/api/cdr/playback', // Защищен fail2ban |
|
38 | 38 | '/api/cdr/get_data', |
39 | 39 | ]; |
40 | 40 | // Текущий паттерн. |
41 | 41 | $pattern = $app->getRouter()->getRewriteUri(); |
42 | 42 | $res_auth = true; |
43 | 43 | // Проверяем авторизацию. |
44 | - if(preg_match_all('/\/api\/modules\/Module\w*\/custom_action\S*/m', $pattern) > 0){ |
|
44 | + if (preg_match_all('/\/api\/modules\/Module\w*\/custom_action\S*/m', $pattern) > 0) { |
|
45 | 45 | // Это сервисы модулей. |
46 | - }elseif(!in_array($pattern, $panel_pattern, true)) { |
|
46 | + }elseif (!in_array($pattern, $panel_pattern, true)) { |
|
47 | 47 | $res_auth = false; |
48 | 48 | } |
49 | - if(FALSE === $res_auth){ |
|
49 | + if (FALSE === $res_auth) { |
|
50 | 50 | $app->response->setStatusCode(403, 'Forbidden')->sendHeaders(); |
51 | 51 | $app->response->setContent('The user isn\'t authenticated. '); |
52 | 52 | $app->response->send(); |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * /pbxcore/api/cdr/get_data MIKO AJAM |
65 | 65 | * curl 'http://127.0.0.1:80/pbxcore/api/cdr/get_data?offset=0&limit=1'; |
66 | 66 | */ |
67 | -$app->get('/api/cdr/get_data', function () use ($app) { |
|
67 | +$app->get('/api/cdr/get_data', function() use ($app) { |
|
68 | 68 | $offset = $app->request->get('offset'); |
69 | 69 | $limit = $app->request->get('limit'); |
70 | - $limit = ($limit>600)?600:$limit; |
|
70 | + $limit = ($limit > 600) ? 600 : $limit; |
|
71 | 71 | |
72 | 72 | $filter = [ |
73 | 73 | 'id>:id:', |
@@ -79,25 +79,25 @@ discard block |
||
79 | 79 | |
80 | 80 | $client = new BeanstalkClient('select_cdr'); |
81 | 81 | $message = $client->request(json_encode($filter), 2); |
82 | - if($message === false){ |
|
82 | + if ($message === false) { |
|
83 | 83 | $app->response->setContent(''); |
84 | 84 | $app->response->send(); |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | $result = json_decode($message, true); |
87 | 87 | $arr_data = []; |
88 | - if(file_exists($result)){ |
|
88 | + if (file_exists($result)) { |
|
89 | 89 | $arr_data = json_decode(file_get_contents($result), true); |
90 | 90 | @unlink($result); |
91 | 91 | } |
92 | 92 | $xml_output = "<?xml version=\"1.0\"?>\n"; |
93 | 93 | $xml_output .= "<cdr-table-askozia>\n"; |
94 | - if(is_array($arr_data)){ |
|
95 | - foreach ($arr_data as $data){ |
|
94 | + if (is_array($arr_data)) { |
|
95 | + foreach ($arr_data as $data) { |
|
96 | 96 | $attributes = ''; |
97 | 97 | foreach ($data as $tmp_key => $tmp_val) { |
98 | 98 | $attributes .= sprintf('%s="%s" ', $tmp_key, rawurlencode($tmp_val)); |
99 | 99 | } |
100 | - $xml_output.= "<cdr-row $attributes />\n"; |
|
100 | + $xml_output .= "<cdr-row $attributes />\n"; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | $xml_output .= '</cdr-table-askozia>'; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * /pbxcore/api/cdr/records MIKO AJAM |
112 | 112 | * curl http://172.16.156.223/pbxcore/api/cdr/records?view=/storage/usbdisk1/mikoziapbx/voicemailarchive/monitor/2018/05/05/16/mikozia-1525527966.4_oWgzQFMPRA.mp3 |
113 | 113 | */ |
114 | -$app->get('/api/cdr/records', function () use ($app) { |
|
115 | - if(!Util::check_auth_http($this->request)){ |
|
114 | +$app->get('/api/cdr/records', function() use ($app) { |
|
115 | + if (!Util::check_auth_http($this->request)) { |
|
116 | 116 | $app->response->setStatusCode(403, 'Forbidden'); |
117 | 117 | $app->response->setContent('The user isn\'t authenticated.'); |
118 | 118 | $app->response->send(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | $filename = $app->request->get('view'); |
123 | - $extension = strtolower(substr(strrchr($filename,'.'),1)); |
|
123 | + $extension = strtolower(substr(strrchr($filename, '.'), 1)); |
|
124 | 124 | $type = ''; |
125 | 125 | switch ($extension) { |
126 | 126 | case 'mp3': |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | break; |
135 | 135 | } |
136 | 136 | $size = @filesize($filename); |
137 | - if(!$size || $type === ''){ |
|
137 | + if (!$size || $type === '') { |
|
138 | 138 | openlog('miko_ajam', LOG_PID | LOG_PERROR, LOG_AUTH); |
139 | 139 | $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Undefined'; |
140 | 140 | syslog(LOG_WARNING, "From {$_SERVER['REMOTE_ADDR']}. UserAgent: ({$user_agent}). File not found."); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - $fp=fopen($filename, 'rb'); |
|
150 | + $fp = fopen($filename, 'rb'); |
|
151 | 151 | if ($fp) { |
152 | 152 | $app->response->setHeader('Content-Description', 'mp3 file'); |
153 | 153 | $app->response->setHeader('Content-Disposition', 'attachment; filename='.basename($filename)); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $app->response->setContentLength($size); |
157 | 157 | $app->response->sendHeaders(); |
158 | 158 | fpassthru($fp); |
159 | - }else{ |
|
159 | + } else { |
|
160 | 160 | $response = new Phalcon\Http\Response(); |
161 | 161 | $response->setStatusCode(404, 'Файл не найден'); |
162 | 162 | $response->setContent('Не удалось открыть файо на сервере'); |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | * download - опциональный параметр, скачивать записи или нет |
177 | 177 | * filename - опциональный параметр, красивое имя для файла, так файл будет назван при скачивании браузером |
178 | 178 | */ |
179 | -$app->get('/api/cdr/playback', function () use ($app) { |
|
180 | - $filename = $app->request->get('view'); |
|
181 | - $extension = strtolower(substr(strrchr($filename,'.'),1)); |
|
182 | - if(($extension === 'mp3' || $extension === 'wav' ) && Util::rec_file_exists($filename)){ |
|
183 | - $ctype =''; |
|
184 | - switch( $extension ) { |
|
185 | - case 'mp3': $ctype='audio/mpeg'; break; |
|
186 | - case 'wav': $ctype='audio/x-wav'; break; |
|
179 | +$app->get('/api/cdr/playback', function() use ($app) { |
|
180 | + $filename = $app->request->get('view'); |
|
181 | + $extension = strtolower(substr(strrchr($filename, '.'), 1)); |
|
182 | + if (($extension === 'mp3' || $extension === 'wav') && Util::rec_file_exists($filename)) { |
|
183 | + $ctype = ''; |
|
184 | + switch ($extension) { |
|
185 | + case 'mp3': $ctype = 'audio/mpeg'; break; |
|
186 | + case 'wav': $ctype = 'audio/x-wav'; break; |
|
187 | 187 | } |
188 | 188 | $filesize = filesize($filename); |
189 | - if (isset($_SERVER['HTTP_RANGE'])){ |
|
189 | + if (isset($_SERVER['HTTP_RANGE'])) { |
|
190 | 190 | $range = $_SERVER['HTTP_RANGE']; |
191 | 191 | list ($param, $range) = explode('=', $range); |
192 | 192 | if (strtolower(trim($param)) !== 'bytes') { |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | if ($range[0] === '') { |
199 | 199 | $end = $filesize - 1; |
200 | 200 | $start = $end - (int) $range[0]; |
201 | - }else |
|
202 | - if ($range[1] === ''){ |
|
201 | + } else |
|
202 | + if ($range[1] === '') { |
|
203 | 203 | $start = (int) $range[0]; |
204 | 204 | $end = $filesize - 1; |
205 | - }else{ |
|
205 | + } else { |
|
206 | 206 | $start = (int) $range[0]; |
207 | 207 | $end = (int) $range[1]; |
208 | 208 | // if ($end >= $filesize || (! $start && (! $end || $end == ($filesize - 1)))){ |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | $length = $end - $start + 1; |
213 | 213 | |
214 | 214 | $app->response->resetHeaders(); |
215 | - if (! $fp = fopen($filename, 'rb')) { |
|
215 | + if (!$fp = fopen($filename, 'rb')) { |
|
216 | 216 | $app->response->setRawHeader('HTTP/1.1 500 Internal Server Error'); |
217 | - }else{ |
|
217 | + } else { |
|
218 | 218 | $app->response->setRawHeader('HTTP/1.1 206 Partial Content'); |
219 | 219 | $app->response->setHeader('Content-type', $ctype); |
220 | 220 | $app->response->setHeader('Content-Range', "bytes $start-$end/$filesize"); |
221 | 221 | $app->response->setContentLength($length); |
222 | - if ($start){ |
|
222 | + if ($start) { |
|
223 | 223 | fseek($fp, $start); |
224 | 224 | } |
225 | 225 | $content = ''; |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | set_time_limit(0); |
228 | 228 | $read = ($length > 8192) ? 8192 : $length; |
229 | 229 | $length -= $read; |
230 | - $content.=fread($fp, $read); |
|
230 | + $content .= fread($fp, $read); |
|
231 | 231 | } |
232 | 232 | fclose($fp); |
233 | 233 | $app->response->setContent($content); |
234 | 234 | } |
235 | - }else{ |
|
235 | + } else { |
|
236 | 236 | $app->response->setHeader('Content-type', $ctype); |
237 | 237 | $app->response->setContentLength($filesize); |
238 | 238 | $app->response->setHeader('Accept-Ranges', 'bytes'); |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | $app->response->setHeader('Server', 'nginx'); |
245 | 245 | |
246 | 246 | $is_download = !empty($app->request->get('download')); |
247 | - if($is_download){ |
|
247 | + if ($is_download) { |
|
248 | 248 | $new_filename = $app->request->get('filename'); |
249 | - if(empty($new_filename)){ |
|
249 | + if (empty($new_filename)) { |
|
250 | 250 | $new_filename = basename($filename); |
251 | 251 | } |
252 | 252 | |
253 | 253 | $app->response->setHeader('Content-Disposition', "attachment; filename*=UTF-8''".basename($new_filename)); |
254 | 254 | } |
255 | 255 | $app->response->send(); |
256 | - }else{ |
|
256 | + } else { |
|
257 | 257 | openlog('miko_ajam', LOG_PID | LOG_PERROR, LOG_AUTH); |
258 | 258 | |
259 | 259 | $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Undefined'; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | "linkedid" => 'TEXT', |
282 | 282 | "did" => 'TEXT', |
283 | 283 | */ |
284 | -$app->get('/api/cdr/get_active_calls', function () use ($app) { |
|
284 | +$app->get('/api/cdr/get_active_calls', function() use ($app) { |
|
285 | 285 | $content = Cdr::get_active_calls(); |
286 | 286 | $app->response->setContent($content); |
287 | 287 | $app->response->send(); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | "linkedid" => 'TEXT', |
303 | 303 | "did" => 'TEXT', |
304 | 304 | */ |
305 | -$app->get('/api/cdr/get_active_channels', function () use ($app) { |
|
305 | +$app->get('/api/cdr/get_active_channels', function() use ($app) { |
|
306 | 306 | $content = Cdr::get_active_channels(); |
307 | 307 | $app->response->setContent($content); |
308 | 308 | $app->response->send(); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * Пример ответа: |
322 | 322 | * {"result":"Success","data":[{"id":"SIP-PROVIDER-426304427564469b6c7755","state":"Registered"}]} |
323 | 323 | */ |
324 | -$app->get('/api/sip/{name}', function ($params) use ($app) { |
|
324 | +$app->get('/api/sip/{name}', function($params) use ($app) { |
|
325 | 325 | $request = [ |
326 | 326 | 'data' => null, |
327 | 327 | 'action' =>$params |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $client = new Nats\Connection(); |
331 | 331 | $client->connect(2); |
332 | - $cb = function (Nats\Message $message) use ($app) { |
|
332 | + $cb = function(Nats\Message $message) use ($app) { |
|
333 | 333 | $app->response->setContent($message->getBody()); |
334 | 334 | $app->response->send(); |
335 | 335 | exit(0); |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * Статусы регистраций: |
349 | 349 | * curl http://172.16.156.212/pbxcore/api/iax/get_registry; |
350 | 350 | */ |
351 | -$app->get('/api/iax/{name}', function ($params) use ($app) { |
|
351 | +$app->get('/api/iax/{name}', function($params) use ($app) { |
|
352 | 352 | $request = [ |
353 | 353 | 'data' => null, |
354 | 354 | 'action' =>$params |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | $client = new Nats\Connection(); |
358 | 358 | $client->connect(2); |
359 | - $cb = function (Nats\Message $message) use ($app) { |
|
359 | + $cb = function(Nats\Message $message) use ($app) { |
|
360 | 360 | $app->response->setContent($message->getBody()); |
361 | 361 | $app->response->send(); |
362 | 362 | exit(0); |
@@ -375,24 +375,24 @@ discard block |
||
375 | 375 | * Получение информации по SIP пиру. |
376 | 376 | * curl -X POST -d '{"peer": "212"}' http://127.0.0.1/pbxcore/api/sip/get_sip_peer; |
377 | 377 | */ |
378 | -$app->post('/api/sip/{name}', function ($params) use ($app) { |
|
378 | +$app->post('/api/sip/{name}', function($params) use ($app) { |
|
379 | 379 | $row_data = $app->request->getRawBody(); |
380 | 380 | // Проверим, переданные данные. |
381 | - if(!Util::is_json($row_data)){ |
|
381 | + if (!Util::is_json($row_data)) { |
|
382 | 382 | $app->response->setStatusCode(200, "OK")->sendHeaders(); |
383 | 383 | $app->response->setContent('{"result":"ERROR"}'); |
384 | 384 | $app->response->send(); |
385 | 385 | return; |
386 | 386 | } |
387 | - $data = json_decode( $row_data, true); |
|
387 | + $data = json_decode($row_data, true); |
|
388 | 388 | $request = array( |
389 | - 'data' => $data, // Параметры запроса. |
|
389 | + 'data' => $data, // Параметры запроса. |
|
390 | 390 | 'action' => $params // Операция. |
391 | 391 | ); |
392 | 392 | |
393 | 393 | $client = new Nats\Connection(); |
394 | 394 | $client->connect(2); |
395 | - $cb = function (Nats\Message $message) use ($app) { |
|
395 | + $cb = function(Nats\Message $message) use ($app) { |
|
396 | 396 | $app->response->setContent($message->getBody()); |
397 | 397 | $app->response->send(); |
398 | 398 | exit(0); |
@@ -428,10 +428,10 @@ discard block |
||
428 | 428 | * Пример ответа: |
429 | 429 | * {"result":"Success"} |
430 | 430 | */ |
431 | -$app->get('/api/pbx/{name}', function ($params) use ($app) { |
|
431 | +$app->get('/api/pbx/{name}', function($params) use ($app) { |
|
432 | 432 | $client = new Nats\Connection(); |
433 | 433 | $client->connect(10); |
434 | - $cb = function (Nats\Message $message) use ($app) { |
|
434 | + $cb = function(Nats\Message $message) use ($app) { |
|
435 | 435 | $app->response->setContent($message->getBody()); |
436 | 436 | $app->response->send(); |
437 | 437 | }; |
@@ -478,22 +478,22 @@ discard block |
||
478 | 478 | * Пример ответа: |
479 | 479 | * {"result":"Success"} |
480 | 480 | */ |
481 | -$app->get('/api/system/{name}', function ($params)use ($app) { |
|
481 | +$app->get('/api/system/{name}', function($params)use ($app) { |
|
482 | 482 | |
483 | 483 | $request = array( |
484 | 484 | 'data' => null, |
485 | 485 | 'action' =>$params |
486 | 486 | ); |
487 | 487 | $client = new Nats\Connection(); |
488 | - if($params === 'stop_log') { |
|
488 | + if ($params === 'stop_log') { |
|
489 | 489 | $client->connect(60); |
490 | - }else{ |
|
490 | + } else { |
|
491 | 491 | $client->connect(5); |
492 | 492 | } |
493 | - $cb = function (Nats\Message $message) use ($params, $app) { |
|
494 | - if($params === 'stop_log'){ |
|
493 | + $cb = function(Nats\Message $message) use ($params, $app) { |
|
494 | + if ($params === 'stop_log') { |
|
495 | 495 | $data = json_decode($message->getBody(), true); |
496 | - if(!file_exists($data['filename'])){ |
|
496 | + if (!file_exists($data['filename'])) { |
|
497 | 497 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
498 | 498 | $app->response->setContent('Log file not found.'); |
499 | 499 | $app->response->send(); |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | Util::mwexec("ln -s {$data['filename']} {$result_dir}/{$link_name}"); |
514 | 514 | $app->response->redirect("{$scheme}://{$host}/download_link/{$uid}/{$link_name}"); |
515 | 515 | $app->response->send(); |
516 | - }else{ |
|
516 | + } else { |
|
517 | 517 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
518 | 518 | $app->response->setContent($message->getBody()); |
519 | 519 | $app->response->send(); |
@@ -568,21 +568,21 @@ discard block |
||
568 | 568 | * Онлайн обновление АТС. |
569 | 569 | * curl -X POST -d '{"md5":"df7622068d0d58700a2a624d991b6c1f", "url": "https://www.askozia.ru/upload/update/firmware/6.2.96-9.0-svn-mikopbx-x86-64-cross-linux.img"}' http://172.16.156.223/pbxcore/api/system/upgrade_online; |
570 | 570 | */ |
571 | -$app->post('/api/system/{name}', function ($params) use ($app) { |
|
571 | +$app->post('/api/system/{name}', function($params) use ($app) { |
|
572 | 572 | $data = [ |
573 | 573 | 'result"' => 'ERROR' |
574 | 574 | ]; |
575 | - if($params === 'upgrade') { |
|
575 | + if ($params === 'upgrade') { |
|
576 | 576 | $dirs = PBX::get_asterisk_dirs(); |
577 | 577 | $upd_file = "{$dirs['tmp']}/update.img"; |
578 | 578 | $res = false; |
579 | 579 | if ($app->request->hasFiles() === 0) { |
580 | 580 | // Используем существующий файл; |
581 | 581 | $post_data = json_decode($app->request->getRawBody(), true); |
582 | - if($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
582 | + if ($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
583 | 583 | $res = Util::mwexec("cp '{$post_data['filename']}' '{$upd_file}'") === 0; |
584 | 584 | } |
585 | - }else{ |
|
585 | + } else { |
|
586 | 586 | // Загружаем новый файл на сервер |
587 | 587 | foreach ($app->request->getUploadedFiles() as $file) { |
588 | 588 | $res = $file->moveTo($upd_file); |
@@ -597,21 +597,21 @@ discard block |
||
597 | 597 | return; |
598 | 598 | } |
599 | 599 | $data = null; |
600 | - }else if($params === 'upload_audio_file') { |
|
600 | + } else if ($params === 'upload_audio_file') { |
|
601 | 601 | $dirs = PBX::get_asterisk_dirs(); |
602 | 602 | $filename = ''; |
603 | 603 | $res = false; |
604 | 604 | if ($app->request->hasFiles() === 0) { |
605 | 605 | // Используем существующий файл; |
606 | 606 | $post_data = json_decode($app->request->getRawBody(), true); |
607 | - if($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
607 | + if ($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
608 | 608 | $filename = "{$dirs['media']}/".basename($post_data['filename']); |
609 | 609 | $res = Util::mwexec("cp {$post_data['filename']} {$filename}") === 0; |
610 | 610 | } |
611 | - }else{ |
|
611 | + } else { |
|
612 | 612 | foreach ($app->request->getUploadedFiles() as $file) { |
613 | 613 | $filename = $dirs['media'].'/'.basename($file->getName()); |
614 | - $res = $file->moveTo( $filename); |
|
614 | + $res = $file->moveTo($filename); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
@@ -625,26 +625,26 @@ discard block |
||
625 | 625 | |
626 | 626 | $data = ['filename' => $filename]; |
627 | 627 | $params = 'convert_audio_file'; |
628 | - }else{ |
|
628 | + } else { |
|
629 | 629 | $row_data = $app->request->getRawBody(); |
630 | 630 | // Проверим, переданные данные. |
631 | - if(!Util::is_json($row_data)){ |
|
631 | + if (!Util::is_json($row_data)) { |
|
632 | 632 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
633 | 633 | $app->response->setContent(json_encode($data)); |
634 | 634 | $app->response->send(); |
635 | 635 | return; |
636 | 636 | } |
637 | - $data = json_decode( $row_data, true); |
|
637 | + $data = json_decode($row_data, true); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | $request = array( |
641 | - 'data' => $data, // Параметры запроса. |
|
641 | + 'data' => $data, // Параметры запроса. |
|
642 | 642 | 'action' => $params // Операция. |
643 | 643 | ); |
644 | 644 | |
645 | 645 | $client = new Nats\Connection(); |
646 | 646 | $client->connect(10); |
647 | - $cb = function (Nats\Message $message) use ($app) { |
|
647 | + $cb = function(Nats\Message $message) use ($app) { |
|
648 | 648 | $app->response->setStatusCode(200, "OK")->sendHeaders(); |
649 | 649 | $app->response->setContent(''.$message->getBody()); |
650 | 650 | $app->response->send(); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | * Проверить соединение с FTP / SFTP хранилищем. |
673 | 673 | * curl http://172.16.156.212/pbxcore/api/backup/check_storage_ftp?id=1 |
674 | 674 | */ |
675 | -$app->get('/api/backup/{name}', function ($action)use ($app) { |
|
675 | +$app->get('/api/backup/{name}', function($action)use ($app) { |
|
676 | 676 | $request = array( |
677 | 677 | 'data' => $_REQUEST, |
678 | 678 | 'action' => $action |
@@ -680,15 +680,15 @@ discard block |
||
680 | 680 | |
681 | 681 | $client = new Nats\Connection(); |
682 | 682 | $client->connect(10); |
683 | - $cb = function (Nats\Message $message) use ($action, $app) { |
|
684 | - if($action === 'download'){ |
|
683 | + $cb = function(Nats\Message $message) use ($action, $app) { |
|
684 | + if ($action === 'download') { |
|
685 | 685 | $id = $app->request->get('id'); |
686 | 686 | $b = new Backup($id); |
687 | 687 | $filename = $b->get_result_file(); |
688 | 688 | |
689 | 689 | Util::sys_log_msg('test', $filename); |
690 | 690 | |
691 | - if(!file_exists($filename)){ |
|
691 | + if (!file_exists($filename)) { |
|
692 | 692 | $app->response->setStatusCode(404, 'File not found')->sendHeaders(); |
693 | 693 | $app->response->setContent('File not found '.$id); |
694 | 694 | $app->response->send(); |
@@ -696,9 +696,9 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | $extension = Util::get_extension_file($filename); |
699 | - if($extension === 'zip'){ |
|
699 | + if ($extension === 'zip') { |
|
700 | 700 | $size = filesize($filename); |
701 | - $app->response->setHeader('Content-type', 'application/zip'); |
|
701 | + $app->response->setHeader('Content-type', 'application/zip'); |
|
702 | 702 | $app->response->setHeader('Content-Description', 'File Transfer'); |
703 | 703 | $app->response->setHeader('Content-Disposition', "attachment; filename={$id}.{$extension}"); |
704 | 704 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | |
708 | 708 | proc_nice(15); |
709 | 709 | readfile($filename); |
710 | - }else{ |
|
710 | + } else { |
|
711 | 711 | $scheme = $app->request->getScheme(); |
712 | 712 | $host = $app->request->getHttpHost(); |
713 | 713 | $port = $app->request->getPort(); |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | $app->response->redirect("{$scheme}://{$host}:{$port}/download_link/{$uid}/{$id}.{$extension}"); |
721 | 721 | $app->response->send(); |
722 | 722 | } |
723 | - }else{ |
|
723 | + } else { |
|
724 | 724 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
725 | 725 | $app->response->setContent($message->getBody()); |
726 | 726 | $app->response->send(); |
@@ -745,46 +745,46 @@ discard block |
||
745 | 745 | * curl -X POST -d '{"id": "backup_1534838222", "options":{"backup-config":"1","backup-records":"1","backup-cdr":"1","backup-sound-files":"1"}}' http://172.16.156.212/pbxcore/api/backup/recover; |
746 | 746 | * curl -X POST -d '{"id": "backup_1534838222", "options":{"backup-sound-files":"1"}}' http://172.16.156.212/pbxcore/api/backup/recover; |
747 | 747 | */ |
748 | -$app->post('/api/backup/{name}', function ($params)use ($app){ |
|
749 | - if($params === 'upload' ){ |
|
748 | +$app->post('/api/backup/{name}', function($params)use ($app){ |
|
749 | + if ($params === 'upload') { |
|
750 | 750 | $data = []; |
751 | 751 | $data['result'] = 'ERROR'; |
752 | 752 | |
753 | 753 | foreach ($_FILES as $file) { |
754 | 754 | // check the error status |
755 | 755 | if ($file['error'] !== 0) { |
756 | - Util::sys_log_msg('UploadFile','error '.$file['error'].' in file '.$_POST['resumableFilename']); |
|
756 | + Util::sys_log_msg('UploadFile', 'error '.$file['error'].' in file '.$_POST['resumableFilename']); |
|
757 | 757 | continue; |
758 | 758 | } |
759 | 759 | $dirs = PBX::get_asterisk_dirs(); |
760 | 760 | // init the destination file (format <filename.ext>.part<#chunk> |
761 | 761 | // the file is stored in a temporary directory |
762 | - if(isset($_POST['resumableIdentifier']) && trim($_POST['resumableIdentifier'])!==''){ |
|
762 | + if (isset($_POST['resumableIdentifier']) && trim($_POST['resumableIdentifier']) !== '') { |
|
763 | 763 | $temp_dir = $dirs['tmp'].'/'.$_POST['resumableIdentifier']; |
764 | - }else{ |
|
764 | + } else { |
|
765 | 765 | $temp_dir = $dirs['tmp'].'/backup'; |
766 | 766 | } |
767 | 767 | $dest_file = $temp_dir.'/'.$_POST['resumableFilename'].'.part'.$_POST['resumableChunkNumber']; |
768 | 768 | // create the temporary directory |
769 | - if(!Util::mw_mkdir($temp_dir)){ |
|
769 | + if (!Util::mw_mkdir($temp_dir)) { |
|
770 | 770 | Util::sys_log_msg('UploadFile', "Error create dir '$temp_dir'"); |
771 | 771 | } |
772 | 772 | |
773 | 773 | $result = false; |
774 | 774 | // move the temporary file |
775 | 775 | if (!move_uploaded_file($file['tmp_name'], $dest_file)) { |
776 | - Util::sys_log_msg('UploadFile','Error saving (move_uploaded_file) chunk '.$_POST['resumableChunkNumber'].' for file '.$dest_file); |
|
776 | + Util::sys_log_msg('UploadFile', 'Error saving (move_uploaded_file) chunk '.$_POST['resumableChunkNumber'].' for file '.$dest_file); |
|
777 | 777 | } else { |
778 | 778 | // check if all the parts present, and create the final destination file |
779 | - $result = Util::createFileFromChunks($temp_dir, $_POST['resumableFilename'], $_POST['resumableTotalSize'],$_POST['resumableTotalChunks'], '', $_POST['resumableChunkSize']); |
|
779 | + $result = Util::createFileFromChunks($temp_dir, $_POST['resumableFilename'], $_POST['resumableTotalSize'], $_POST['resumableTotalChunks'], '', $_POST['resumableChunkSize']); |
|
780 | 780 | } |
781 | - if($result === true){ |
|
781 | + if ($result === true) { |
|
782 | 782 | $data['result'] = 'Success'; |
783 | 783 | $backupdir = Backup::get_backup_dir(); |
784 | 784 | $dir_name = Util::trim_extension_file(basename($_POST['resumableFilename'])); |
785 | 785 | $extension = Util::get_extension_file(basename($_POST['resumableFilename'])); |
786 | 786 | $mnt_point = "{$backupdir}/$dir_name/mnt_point"; |
787 | - if(!file_exists("{$backupdir}/$dir_name/")){ |
|
787 | + if (!file_exists("{$backupdir}/$dir_name/")) { |
|
788 | 788 | Util::mwexec("mkdir -p '{$backupdir}/{$dir_name}/' '{$mnt_point}'"); |
789 | 789 | } |
790 | 790 | file_put_contents("{$backupdir}/$dir_name/upload_status", 'MERGING'); |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | 'result' => 'MERGING' |
795 | 795 | ]; |
796 | 796 | |
797 | - $merge_post_action = ($extension === 'xml')?'convert_config':'upload_backup'; |
|
797 | + $merge_post_action = ($extension === 'xml') ? 'convert_config' : 'upload_backup'; |
|
798 | 798 | $merge_settings = [ |
799 | 799 | 'data' => [ |
800 | 800 | 'result_file' => "{$backupdir}/$dir_name/resultfile.{$extension}", |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | 'action' => $merge_post_action |
810 | 810 | ]; |
811 | 811 | $settings_file = "{$backupdir}/$dir_name/merge_settings"; |
812 | - file_put_contents($settings_file, json_encode($merge_settings, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); |
|
812 | + file_put_contents($settings_file, json_encode($merge_settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); |
|
813 | 813 | |
814 | 814 | // Отправляем задачу на склеивание файла. |
815 | 815 | $client = new Nats\Connection(); |
@@ -820,36 +820,36 @@ discard block |
||
820 | 820 | 'settings_file' => $settings_file |
821 | 821 | ] |
822 | 822 | ]; |
823 | - $client->request('backup', json_encode($req_data), function (Nats\Message $message){ |
|
823 | + $client->request('backup', json_encode($req_data), function(Nats\Message $message) { |
|
824 | 824 | }); |
825 | 825 | |
826 | - }else{ |
|
826 | + } else { |
|
827 | 827 | $data['result'] = 'INPROGRESS'; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
831 | - $app->response->setContent(json_encode($data, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); |
|
831 | + $app->response->setContent(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); |
|
832 | 832 | $app->response->send(); |
833 | 833 | return; |
834 | 834 | } |
835 | 835 | |
836 | 836 | $row_data = $app->request->getRawBody(); |
837 | 837 | // Проверим, переданные данные. |
838 | - if(!Util::is_json($row_data)){ |
|
838 | + if (!Util::is_json($row_data)) { |
|
839 | 839 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
840 | 840 | $app->response->setContent('{"result":"ERROR"}'); |
841 | 841 | $app->response->send(); |
842 | 842 | return; |
843 | 843 | } |
844 | - $data = json_decode( $row_data, true); |
|
844 | + $data = json_decode($row_data, true); |
|
845 | 845 | $request = array( |
846 | - 'data' => $data, // Параметры запроса. |
|
846 | + 'data' => $data, // Параметры запроса. |
|
847 | 847 | 'action' => $params // Операция. |
848 | 848 | ); |
849 | 849 | |
850 | 850 | $client = new Nats\Connection(); |
851 | 851 | $client->connect(10); |
852 | - $cb = static function (Nats\Message $message) use ($app) { |
|
852 | + $cb = static function(Nats\Message $message) use ($app) { |
|
853 | 853 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
854 | 854 | $app->response->setContent(''.$message->getBody()); |
855 | 855 | $app->response->send(); |
@@ -862,14 +862,14 @@ discard block |
||
862 | 862 | * curl -F "[email protected]" http://127.0.0.1/pbxcore/api/upload/module -H 'Cookie: XDEBUG_SESSION=PHPSTORM' |
863 | 863 | * curl -X POST -d '{"id": "1531474060"}' http://127.0.0.1/pbxcore/api/upload/status; -H 'Cookie: XDEBUG_SESSION=PHPSTORM' |
864 | 864 | */ |
865 | -$app->post('/api/upload/{name}', function ($params)use ($app){ |
|
865 | +$app->post('/api/upload/{name}', function($params)use ($app){ |
|
866 | 866 | |
867 | 867 | $data = []; |
868 | 868 | $data['result'] = 'ERROR'; |
869 | 869 | $data['data'] = ''; |
870 | 870 | |
871 | 871 | $dirs = PBX::get_asterisk_dirs(); |
872 | - if ($app->request->hasFiles() > 0){ |
|
872 | + if ($app->request->hasFiles() > 0) { |
|
873 | 873 | $upload_id = time(); |
874 | 874 | $resumableFilename = $app->request->getPost('resumableFilename'); |
875 | 875 | $resumableIdentifier = $app->request->getPost('resumableIdentifier'); |
@@ -878,37 +878,37 @@ discard block |
||
878 | 878 | $resumableChunkSize = $app->request->getPost('resumableChunkSize'); |
879 | 879 | |
880 | 880 | foreach ($app->request->getUploadedFiles() as $file) { |
881 | - if ( $file->getError() ) { |
|
881 | + if ($file->getError()) { |
|
882 | 882 | $data['data'] = 'error '.$file->getError().' in file '.$resumableFilename; |
883 | - Util::sys_log_msg('UploadFile','error '.$file->getError().' in file '.$resumableFilename); |
|
883 | + Util::sys_log_msg('UploadFile', 'error '.$file->getError().' in file '.$resumableFilename); |
|
884 | 884 | continue; |
885 | 885 | } |
886 | - if(isset($resumableIdentifier) && trim($resumableIdentifier)!==''){ |
|
886 | + if (isset($resumableIdentifier) && trim($resumableIdentifier) !== '') { |
|
887 | 887 | $temp_dir = $dirs['tmp'].'/'.Util::trim_extension_file(basename($resumableFilename)); |
888 | 888 | $temp_dst_file = $dirs['tmp'].'/'.$upload_id.'/'.basename($resumableFilename); |
889 | 889 | $chunks_dest_file = $temp_dir.'/'.$resumableFilename.'.part'.$resumableChunkNumber; |
890 | - }else{ |
|
890 | + } else { |
|
891 | 891 | $temp_dir = $dirs['tmp'].'/'.$upload_id; |
892 | 892 | $temp_dst_file = $temp_dir.'/'.basename($file->getName()); |
893 | 893 | $chunks_dest_file = $temp_dst_file; |
894 | 894 | } |
895 | - if(!Util::mw_mkdir($temp_dir) || ! Util::mw_mkdir(dirname($temp_dst_file))){ |
|
895 | + if (!Util::mw_mkdir($temp_dir) || !Util::mw_mkdir(dirname($temp_dst_file))) { |
|
896 | 896 | Util::sys_log_msg('UploadFile', "Error create dir '$temp_dir'"); |
897 | 897 | $data['data'] .= "Error create dir 'temp_dir'"; |
898 | 898 | continue; |
899 | 899 | } |
900 | - if ( !$file->moveTo($chunks_dest_file) ) { |
|
901 | - Util::sys_log_msg('UploadFile','Error saving (move_uploaded_file) for '.$chunks_dest_file); |
|
900 | + if (!$file->moveTo($chunks_dest_file)) { |
|
901 | + Util::sys_log_msg('UploadFile', 'Error saving (move_uploaded_file) for '.$chunks_dest_file); |
|
902 | 902 | $data['result'] = 'ERROR'; |
903 | 903 | $data['d_status_progress'] = '0'; |
904 | 904 | $data['d_status'] = 'ID_NOT_SET'; |
905 | - }elseif($resumableFilename) { |
|
905 | + }elseif ($resumableFilename) { |
|
906 | 906 | // Передача файлов частями. |
907 | 907 | $result = Util::createFileFromChunks($temp_dir, $resumableFilename, $resumableTotalSize, $resumableChunkNumber, '', $resumableChunkSize); |
908 | - if($result === true){ |
|
908 | + if ($result === true) { |
|
909 | 909 | $data['result'] = 'Success'; |
910 | 910 | |
911 | - $merge_settings = [ |
|
911 | + $merge_settings = [ |
|
912 | 912 | 'data' => [ |
913 | 913 | 'result_file' => $temp_dst_file, |
914 | 914 | 'temp_dir' => $temp_dir, |
@@ -929,13 +929,13 @@ discard block |
||
929 | 929 | 'settings_file' => $settings_file |
930 | 930 | ] |
931 | 931 | ]; |
932 | - $client->request('system', json_encode($req_data), function (Nats\Message $message){ |
|
932 | + $client->request('system', json_encode($req_data), function(Nats\Message $message) { |
|
933 | 933 | }); |
934 | 934 | $data['upload_id'] = $upload_id; |
935 | 935 | $data['filename'] = $temp_dst_file; |
936 | 936 | $data['d_status'] = 'INPROGRESS'; |
937 | 937 | } |
938 | - }else{ |
|
938 | + } else { |
|
939 | 939 | $data['result'] = 'Success'; |
940 | 940 | // Передача файла целиком. |
941 | 941 | $data['upload_id'] = $upload_id; |
@@ -945,37 +945,37 @@ discard block |
||
945 | 945 | Util::mwexec_bg('/etc/rc/shell_functions.sh killprocesses '.$temp_dir.' -TERM 0;rm -rf '.$temp_dir, '/dev/null', 30); |
946 | 946 | } |
947 | 947 | } |
948 | - }elseif($params === 'status'){ |
|
948 | + }elseif ($params === 'status') { |
|
949 | 949 | $data['result'] = 'Success'; |
950 | 950 | $post_data = json_decode($app->request->getRawBody(), true); |
951 | - if($post_data && isset($post_data['id'])){ |
|
951 | + if ($post_data && isset($post_data['id'])) { |
|
952 | 952 | $upload_id = $post_data['id']; |
953 | 953 | $progress_dir = $dirs['tmp'].'/'.$upload_id; |
954 | 954 | $progress_file = $progress_dir.'/progress'; |
955 | 955 | |
956 | - if(empty($upload_id)){ |
|
956 | + if (empty($upload_id)) { |
|
957 | 957 | $data['result'] = 'ERROR'; |
958 | 958 | $data['d_status_progress'] = '0'; |
959 | 959 | $data['d_status'] = 'ID_NOT_SET'; |
960 | 960 | } |
961 | - elseif(!file_exists($progress_file) && file_exists($progress_dir)){ |
|
961 | + elseif (!file_exists($progress_file) && file_exists($progress_dir)) { |
|
962 | 962 | $data['d_status_progress'] = '0'; |
963 | 963 | $data['d_status'] = 'INPROGRESS'; |
964 | - }elseif( !file_exists($progress_dir) ){ |
|
964 | + }elseif (!file_exists($progress_dir)) { |
|
965 | 965 | $data['result'] = 'ERROR'; |
966 | 966 | $data['d_status_progress'] = '0'; |
967 | 967 | $data['d_status'] = 'NOT_FOUND'; |
968 | - }elseif('100' === file_get_contents($progress_file) ){ |
|
968 | + }elseif ('100' === file_get_contents($progress_file)) { |
|
969 | 969 | $data['d_status_progress'] = '100'; |
970 | 970 | $data['d_status'] = 'DOWNLOAD_COMPLETE'; |
971 | - }else{ |
|
971 | + } else { |
|
972 | 972 | $data['d_status_progress'] = file_get_contents($progress_file); |
973 | 973 | } |
974 | 974 | } |
975 | 975 | } |
976 | 976 | |
977 | 977 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
978 | - $app->response->setContent(json_encode($data, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); |
|
978 | + $app->response->setContent(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); |
|
979 | 979 | $app->response->send(); |
980 | 980 | |
981 | 981 | |
@@ -1016,21 +1016,21 @@ discard block |
||
1016 | 1016 | * @param $name |
1017 | 1017 | * @param $command |
1018 | 1018 | */ |
1019 | -$f_modules_name_command = function ($name, $command) use ($app) { |
|
1019 | +$f_modules_name_command = function($name, $command) use ($app) { |
|
1020 | 1020 | |
1021 | 1021 | $_REQUEST['ip_srv'] = $_SERVER['SERVER_ADDR']; |
1022 | - $input = file_get_contents( 'php://input' ); |
|
1022 | + $input = file_get_contents('php://input'); |
|
1023 | 1023 | $request = [ |
1024 | 1024 | 'data' => $_REQUEST, |
1025 | 1025 | 'module' => $name, |
1026 | - 'input' => $input, // Параметры запроса. |
|
1026 | + 'input' => $input, // Параметры запроса. |
|
1027 | 1027 | 'action' => $command, |
1028 | 1028 | 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'] |
1029 | 1029 | ]; |
1030 | 1030 | |
1031 | - $cb = function (Nats\Message $message) use ($name, $command, $app) { |
|
1031 | + $cb = function(Nats\Message $message) use ($name, $command, $app) { |
|
1032 | 1032 | $response = json_decode($message->getBody(), true); |
1033 | - if( isset($response['fpassthru']) ) { |
|
1033 | + if (isset($response['fpassthru'])) { |
|
1034 | 1034 | $fp = fopen($response['filename'], "rb"); |
1035 | 1035 | if ($fp) { |
1036 | 1036 | $size = filesize($response['filename']); |
@@ -1047,22 +1047,22 @@ discard block |
||
1047 | 1047 | if (isset($response['need_delete']) && $response['need_delete'] == true) { |
1048 | 1048 | unlink($response['filename']); |
1049 | 1049 | } |
1050 | - }elseif (isset($response['redirect'])){ |
|
1050 | + }elseif (isset($response['redirect'])) { |
|
1051 | 1051 | $app->response->redirect($response['redirect'], true, 302); |
1052 | 1052 | $app->response->send(); |
1053 | - }elseif (isset($response['headers']) && isset($response['echo'])){ |
|
1054 | - foreach ($response['headers'] as $name => $value){ |
|
1053 | + }elseif (isset($response['headers']) && isset($response['echo'])) { |
|
1054 | + foreach ($response['headers'] as $name => $value) { |
|
1055 | 1055 | $app->response->setHeader($name, $value); |
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | $app->response->setContent($response['echo']); |
1059 | 1059 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1060 | 1060 | $app->response->send(); |
1061 | - }elseif (isset($response['echo_file'])){ |
|
1061 | + }elseif (isset($response['echo_file'])) { |
|
1062 | 1062 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1063 | 1063 | $app->response->setFileToSend($response['echo_file']); |
1064 | 1064 | $app->response->send(); |
1065 | - }else{ |
|
1065 | + } else { |
|
1066 | 1066 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1067 | 1067 | $app->response->setContent($message->getBody()); |
1068 | 1068 | $app->response->send(); |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | $client->connect(100); |
1074 | 1074 | $client->request('modules', json_encode($request), $cb); |
1075 | 1075 | }; |
1076 | -$app->get( '/api/modules/{name}/{command}', $f_modules_name_command); |
|
1076 | +$app->get('/api/modules/{name}/{command}', $f_modules_name_command); |
|
1077 | 1077 | $app->post('/api/modules/{name}/{command}', $f_modules_name_command); |
1078 | 1078 | |
1079 | 1079 | /** |
@@ -1084,20 +1084,20 @@ discard block |
||
1084 | 1084 | curl -F "[email protected]" http://127.0.0.1/pbxcore/api/modules/upload; |
1085 | 1085 | curl -X POST -d '{"filename":"/storage/usbdisk1/mikopbx/tmp/ModuleTemplate.zip"}' http://127.0.0.1/pbxcore/api/modules/unpack -H 'Cookie: XDEBUG_SESSION=PHPSTORM'; |
1086 | 1086 | */ |
1087 | -$app->post('/api/modules/{command}', function ($command) use ($app){ |
|
1087 | +$app->post('/api/modules/{command}', function($command) use ($app){ |
|
1088 | 1088 | $result = [ |
1089 | 1089 | 'result' => 'ERROR', |
1090 | 1090 | 'uniqid' => null |
1091 | 1091 | ]; |
1092 | 1092 | $data = NULL; |
1093 | - if ('upload' === $command && $app->request->hasFiles() === 0){ |
|
1094 | - if (Util::is_json($app->request->getRawBody() ) ){ |
|
1093 | + if ('upload' === $command && $app->request->hasFiles() === 0) { |
|
1094 | + if (Util::is_json($app->request->getRawBody())) { |
|
1095 | 1095 | $row_data = $app->request->getRawBody(); |
1096 | - $data = json_decode( $row_data, true); |
|
1097 | - }else{ |
|
1096 | + $data = json_decode($row_data, true); |
|
1097 | + } else { |
|
1098 | 1098 | $result['data'] = 'Body is not JSON'; |
1099 | 1099 | } |
1100 | - }elseif( in_array($command, ['upload', 'unpack']) ){ |
|
1100 | + }elseif (in_array($command, ['upload', 'unpack'])) { |
|
1101 | 1101 | $dirs = PBX::get_asterisk_dirs(); |
1102 | 1102 | $module_file = "{$dirs['tmp']}/".time().'.zip'; |
1103 | 1103 | if ($app->request->hasFiles() > 0) { |
@@ -1109,9 +1109,9 @@ discard block |
||
1109 | 1109 | $file->moveTo($module_file); |
1110 | 1110 | break; |
1111 | 1111 | } |
1112 | - }elseif ('unpack' === $command ){ |
|
1112 | + }elseif ('unpack' === $command) { |
|
1113 | 1113 | $post_data = json_decode($app->request->getRawBody(), true); |
1114 | - if($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
1114 | + if ($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
|
1115 | 1115 | Util::mwexec("cp '{$post_data['filename']}' '{$module_file}'"); |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | $settings = json_decode(implode("\n", $out), true); |
1122 | 1122 | |
1123 | 1123 | $module_uniqid = $settings['module_uniqid'] ?? NULL; |
1124 | - if(!$module_uniqid){ |
|
1124 | + if (!$module_uniqid) { |
|
1125 | 1125 | $result['data'] = 'The" module_uniqid " in the module file is not described.the json or file does not exist.'; |
1126 | 1126 | } |
1127 | 1127 | $data = [ |
@@ -1130,21 +1130,21 @@ discard block |
||
1130 | 1130 | 'l_file' => $module_file, |
1131 | 1131 | 'uniqid' => $module_uniqid |
1132 | 1132 | ]; |
1133 | - }else{ |
|
1133 | + } else { |
|
1134 | 1134 | $result['data'] = 'Failed to upload file to server'; |
1135 | 1135 | } |
1136 | 1136 | $command = 'upload'; |
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if($data){ |
|
1140 | - $request = array( |
|
1141 | - 'data' => $data, // Параметры запроса. |
|
1139 | + if ($data) { |
|
1140 | + $request = array( |
|
1141 | + 'data' => $data, // Параметры запроса. |
|
1142 | 1142 | 'module' => $data['uniqid'], // Параметры запроса. |
1143 | 1143 | 'action' => $command // Операция. |
1144 | 1144 | ); |
1145 | 1145 | $client = new Nats\Connection(); |
1146 | 1146 | $client->connect(5); |
1147 | - $cb = function (Nats\Message $message) use (&$result) { |
|
1147 | + $cb = function(Nats\Message $message) use (&$result) { |
|
1148 | 1148 | $result = json_decode($message->getBody(), true); |
1149 | 1149 | }; |
1150 | 1150 | $client->request('modules', json_encode($request), $cb); |
@@ -1160,14 +1160,14 @@ discard block |
||
1160 | 1160 | * Получить список подключенных дисков к ПК. |
1161 | 1161 | * curl http://172.16.156.212/pbxcore/api/storage/list |
1162 | 1162 | */ |
1163 | -$app->get('/api/storage/{name}', function ($name) use ($app) { |
|
1163 | +$app->get('/api/storage/{name}', function($name) use ($app) { |
|
1164 | 1164 | $request = array( |
1165 | 1165 | 'data' => $_REQUEST, |
1166 | 1166 | 'action' => $name |
1167 | 1167 | ); |
1168 | 1168 | $client = new Nats\Connection(); |
1169 | 1169 | $client->connect(10); |
1170 | - $cb = function (Nats\Message $message) use ($name, $app) { |
|
1170 | + $cb = function(Nats\Message $message) use ($name, $app) { |
|
1171 | 1171 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1172 | 1172 | $app->response->setContent($message->getBody()); |
1173 | 1173 | $app->response->send(); |
@@ -1186,16 +1186,16 @@ discard block |
||
1186 | 1186 | * curl -X POST -d '{"dev":"/dev/sdc"}' http://172.16.156.212/pbxcore/api/storage/status_mkfs; |
1187 | 1187 | * 'ended' / 'inprogress' |
1188 | 1188 | */ |
1189 | -$app->post('/api/storage/{name}', function ($name)use ($app){ |
|
1189 | +$app->post('/api/storage/{name}', function($name)use ($app){ |
|
1190 | 1190 | $row_data = $app->request->getRawBody(); |
1191 | 1191 | // Проверим, переданные данные. |
1192 | - if(!Util::is_json($row_data)){ |
|
1192 | + if (!Util::is_json($row_data)) { |
|
1193 | 1193 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1194 | 1194 | $app->response->setContent('{"result":"ERROR"}'); |
1195 | 1195 | $app->response->send(); |
1196 | 1196 | return; |
1197 | 1197 | } |
1198 | - $data = json_decode( $row_data, true); |
|
1198 | + $data = json_decode($row_data, true); |
|
1199 | 1199 | $request = array( |
1200 | 1200 | 'data' => $data, // Параметры запроса. |
1201 | 1201 | 'action' => $name // Операция. |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | |
1204 | 1204 | $client = new Nats\Connection(); |
1205 | 1205 | $client->connect(10); |
1206 | - $cb = function (Nats\Message $message) use ($app) { |
|
1206 | + $cb = function(Nats\Message $message) use ($app) { |
|
1207 | 1207 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1208 | 1208 | $app->response->setContent(''.$message->getBody()); |
1209 | 1209 | $app->response->send(); |
@@ -1215,17 +1215,17 @@ discard block |
||
1215 | 1215 | /** |
1216 | 1216 | * Обработка не корректного запроса. |
1217 | 1217 | */ |
1218 | -$app->notFound(function () use ($app) { |
|
1218 | +$app->notFound(function() use ($app) { |
|
1219 | 1219 | sleep(2); |
1220 | 1220 | $app->response->setStatusCode(404, 'Not Found')->sendHeaders(); |
1221 | 1221 | $app->response->setContent('This is crazy, but this page was not found!'); |
1222 | 1222 | $app->response->send(); |
1223 | 1223 | }); |
1224 | 1224 | |
1225 | -try{ |
|
1225 | +try { |
|
1226 | 1226 | $app->handle(); |
1227 | -}catch( Nats\Exception $e){ |
|
1228 | - Util::sys_log_msg('pbx_core_api', $e->getMessage() ); |
|
1227 | +} catch (Nats\Exception $e) { |
|
1228 | + Util::sys_log_msg('pbx_core_api', $e->getMessage()); |
|
1229 | 1229 | // Если произошло исключение, то NATS скорее всего не запущен. |
1230 | 1230 | $response = [ |
1231 | 1231 | 'result' => 'ERROR', |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | |
18 | 18 | // Create a events manager |
19 | 19 | $eventsManager = new EventsManager(); |
20 | -$eventsManager->attach('micro:beforeExecuteRoute', function (Event $event, Micro $app) { |
|
20 | +$eventsManager->attach('micro:beforeExecuteRoute', function (Event $event, Micro $app) |
|
21 | +{ |
|
21 | 22 | // return true; |
22 | 23 | if($_SERVER['REMOTE_ADDR'] === '127.0.0.1'){ |
23 | 24 | return true; |
@@ -43,7 +44,7 @@ discard block |
||
43 | 44 | // Проверяем авторизацию. |
44 | 45 | if(preg_match_all('/\/api\/modules\/Module\w*\/custom_action\S*/m', $pattern) > 0){ |
45 | 46 | // Это сервисы модулей. |
46 | - }elseif(!in_array($pattern, $panel_pattern, true)) { |
|
47 | + } elseif(!in_array($pattern, $panel_pattern, true)) { |
|
47 | 48 | $res_auth = false; |
48 | 49 | } |
49 | 50 | if(FALSE === $res_auth){ |
@@ -64,7 +65,8 @@ discard block |
||
64 | 65 | * /pbxcore/api/cdr/get_data MIKO AJAM |
65 | 66 | * curl 'http://127.0.0.1:80/pbxcore/api/cdr/get_data?offset=0&limit=1'; |
66 | 67 | */ |
67 | -$app->get('/api/cdr/get_data', function () use ($app) { |
|
68 | +$app->get('/api/cdr/get_data', function () use ($app) |
|
69 | +{ |
|
68 | 70 | $offset = $app->request->get('offset'); |
69 | 71 | $limit = $app->request->get('limit'); |
70 | 72 | $limit = ($limit>600)?600:$limit; |
@@ -82,7 +84,7 @@ discard block |
||
82 | 84 | if($message === false){ |
83 | 85 | $app->response->setContent(''); |
84 | 86 | $app->response->send(); |
85 | - }else{ |
|
87 | + } else{ |
|
86 | 88 | $result = json_decode($message, true); |
87 | 89 | $arr_data = []; |
88 | 90 | if(file_exists($result)){ |
@@ -111,7 +113,8 @@ discard block |
||
111 | 113 | * /pbxcore/api/cdr/records MIKO AJAM |
112 | 114 | * curl http://172.16.156.223/pbxcore/api/cdr/records?view=/storage/usbdisk1/mikoziapbx/voicemailarchive/monitor/2018/05/05/16/mikozia-1525527966.4_oWgzQFMPRA.mp3 |
113 | 115 | */ |
114 | -$app->get('/api/cdr/records', function () use ($app) { |
|
116 | +$app->get('/api/cdr/records', function () use ($app) |
|
117 | +{ |
|
115 | 118 | if(!Util::check_auth_http($this->request)){ |
116 | 119 | $app->response->setStatusCode(403, 'Forbidden'); |
117 | 120 | $app->response->setContent('The user isn\'t authenticated.'); |
@@ -156,7 +159,7 @@ discard block |
||
156 | 159 | $app->response->setContentLength($size); |
157 | 160 | $app->response->sendHeaders(); |
158 | 161 | fpassthru($fp); |
159 | - }else{ |
|
162 | + } else{ |
|
160 | 163 | $response = new Phalcon\Http\Response(); |
161 | 164 | $response->setStatusCode(404, 'Файл не найден'); |
162 | 165 | $response->setContent('Не удалось открыть файо на сервере'); |
@@ -176,7 +179,8 @@ discard block |
||
176 | 179 | * download - опциональный параметр, скачивать записи или нет |
177 | 180 | * filename - опциональный параметр, красивое имя для файла, так файл будет назван при скачивании браузером |
178 | 181 | */ |
179 | -$app->get('/api/cdr/playback', function () use ($app) { |
|
182 | +$app->get('/api/cdr/playback', function () use ($app) |
|
183 | +{ |
|
180 | 184 | $filename = $app->request->get('view'); |
181 | 185 | $extension = strtolower(substr(strrchr($filename,'.'),1)); |
182 | 186 | if(($extension === 'mp3' || $extension === 'wav' ) && Util::rec_file_exists($filename)){ |
@@ -198,11 +202,11 @@ discard block |
||
198 | 202 | if ($range[0] === '') { |
199 | 203 | $end = $filesize - 1; |
200 | 204 | $start = $end - (int) $range[0]; |
201 | - }else |
|
205 | + } else |
|
202 | 206 | if ($range[1] === ''){ |
203 | 207 | $start = (int) $range[0]; |
204 | 208 | $end = $filesize - 1; |
205 | - }else{ |
|
209 | + } else{ |
|
206 | 210 | $start = (int) $range[0]; |
207 | 211 | $end = (int) $range[1]; |
208 | 212 | // if ($end >= $filesize || (! $start && (! $end || $end == ($filesize - 1)))){ |
@@ -214,7 +218,7 @@ discard block |
||
214 | 218 | $app->response->resetHeaders(); |
215 | 219 | if (! $fp = fopen($filename, 'rb')) { |
216 | 220 | $app->response->setRawHeader('HTTP/1.1 500 Internal Server Error'); |
217 | - }else{ |
|
221 | + } else{ |
|
218 | 222 | $app->response->setRawHeader('HTTP/1.1 206 Partial Content'); |
219 | 223 | $app->response->setHeader('Content-type', $ctype); |
220 | 224 | $app->response->setHeader('Content-Range', "bytes $start-$end/$filesize"); |
@@ -232,7 +236,7 @@ discard block |
||
232 | 236 | fclose($fp); |
233 | 237 | $app->response->setContent($content); |
234 | 238 | } |
235 | - }else{ |
|
239 | + } else{ |
|
236 | 240 | $app->response->setHeader('Content-type', $ctype); |
237 | 241 | $app->response->setContentLength($filesize); |
238 | 242 | $app->response->setHeader('Accept-Ranges', 'bytes'); |
@@ -253,7 +257,7 @@ discard block |
||
253 | 257 | $app->response->setHeader('Content-Disposition', "attachment; filename*=UTF-8''".basename($new_filename)); |
254 | 258 | } |
255 | 259 | $app->response->send(); |
256 | - }else{ |
|
260 | + } else{ |
|
257 | 261 | openlog('miko_ajam', LOG_PID | LOG_PERROR, LOG_AUTH); |
258 | 262 | |
259 | 263 | $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Undefined'; |
@@ -281,7 +285,8 @@ discard block |
||
281 | 285 | "linkedid" => 'TEXT', |
282 | 286 | "did" => 'TEXT', |
283 | 287 | */ |
284 | -$app->get('/api/cdr/get_active_calls', function () use ($app) { |
|
288 | +$app->get('/api/cdr/get_active_calls', function () use ($app) |
|
289 | +{ |
|
285 | 290 | $content = Cdr::get_active_calls(); |
286 | 291 | $app->response->setContent($content); |
287 | 292 | $app->response->send(); |
@@ -302,7 +307,8 @@ discard block |
||
302 | 307 | "linkedid" => 'TEXT', |
303 | 308 | "did" => 'TEXT', |
304 | 309 | */ |
305 | -$app->get('/api/cdr/get_active_channels', function () use ($app) { |
|
310 | +$app->get('/api/cdr/get_active_channels', function () use ($app) |
|
311 | +{ |
|
306 | 312 | $content = Cdr::get_active_channels(); |
307 | 313 | $app->response->setContent($content); |
308 | 314 | $app->response->send(); |
@@ -321,7 +327,8 @@ discard block |
||
321 | 327 | * Пример ответа: |
322 | 328 | * {"result":"Success","data":[{"id":"SIP-PROVIDER-426304427564469b6c7755","state":"Registered"}]} |
323 | 329 | */ |
324 | -$app->get('/api/sip/{name}', function ($params) use ($app) { |
|
330 | +$app->get('/api/sip/{name}', function ($params) use ($app) |
|
331 | +{ |
|
325 | 332 | $request = [ |
326 | 333 | 'data' => null, |
327 | 334 | 'action' =>$params |
@@ -329,7 +336,8 @@ discard block |
||
329 | 336 | |
330 | 337 | $client = new Nats\Connection(); |
331 | 338 | $client->connect(2); |
332 | - $cb = function (Nats\Message $message) use ($app) { |
|
339 | + $cb = function (Nats\Message $message) use ($app) |
|
340 | + { |
|
333 | 341 | $app->response->setContent($message->getBody()); |
334 | 342 | $app->response->send(); |
335 | 343 | exit(0); |
@@ -348,7 +356,8 @@ discard block |
||
348 | 356 | * Статусы регистраций: |
349 | 357 | * curl http://172.16.156.212/pbxcore/api/iax/get_registry; |
350 | 358 | */ |
351 | -$app->get('/api/iax/{name}', function ($params) use ($app) { |
|
359 | +$app->get('/api/iax/{name}', function ($params) use ($app) |
|
360 | +{ |
|
352 | 361 | $request = [ |
353 | 362 | 'data' => null, |
354 | 363 | 'action' =>$params |
@@ -356,7 +365,8 @@ discard block |
||
356 | 365 | |
357 | 366 | $client = new Nats\Connection(); |
358 | 367 | $client->connect(2); |
359 | - $cb = function (Nats\Message $message) use ($app) { |
|
368 | + $cb = function (Nats\Message $message) use ($app) |
|
369 | + { |
|
360 | 370 | $app->response->setContent($message->getBody()); |
361 | 371 | $app->response->send(); |
362 | 372 | exit(0); |
@@ -375,7 +385,8 @@ discard block |
||
375 | 385 | * Получение информации по SIP пиру. |
376 | 386 | * curl -X POST -d '{"peer": "212"}' http://127.0.0.1/pbxcore/api/sip/get_sip_peer; |
377 | 387 | */ |
378 | -$app->post('/api/sip/{name}', function ($params) use ($app) { |
|
388 | +$app->post('/api/sip/{name}', function ($params) use ($app) |
|
389 | +{ |
|
379 | 390 | $row_data = $app->request->getRawBody(); |
380 | 391 | // Проверим, переданные данные. |
381 | 392 | if(!Util::is_json($row_data)){ |
@@ -392,7 +403,8 @@ discard block |
||
392 | 403 | |
393 | 404 | $client = new Nats\Connection(); |
394 | 405 | $client->connect(2); |
395 | - $cb = function (Nats\Message $message) use ($app) { |
|
406 | + $cb = function (Nats\Message $message) use ($app) |
|
407 | + { |
|
396 | 408 | $app->response->setContent($message->getBody()); |
397 | 409 | $app->response->send(); |
398 | 410 | exit(0); |
@@ -428,10 +440,12 @@ discard block |
||
428 | 440 | * Пример ответа: |
429 | 441 | * {"result":"Success"} |
430 | 442 | */ |
431 | -$app->get('/api/pbx/{name}', function ($params) use ($app) { |
|
443 | +$app->get('/api/pbx/{name}', function ($params) use ($app) |
|
444 | +{ |
|
432 | 445 | $client = new Nats\Connection(); |
433 | 446 | $client->connect(10); |
434 | - $cb = function (Nats\Message $message) use ($app) { |
|
447 | + $cb = function (Nats\Message $message) use ($app) |
|
448 | + { |
|
435 | 449 | $app->response->setContent($message->getBody()); |
436 | 450 | $app->response->send(); |
437 | 451 | }; |
@@ -478,7 +492,8 @@ discard block |
||
478 | 492 | * Пример ответа: |
479 | 493 | * {"result":"Success"} |
480 | 494 | */ |
481 | -$app->get('/api/system/{name}', function ($params)use ($app) { |
|
495 | +$app->get('/api/system/{name}', function ($params)use ($app) |
|
496 | +{ |
|
482 | 497 | |
483 | 498 | $request = array( |
484 | 499 | 'data' => null, |
@@ -487,10 +502,11 @@ discard block |
||
487 | 502 | $client = new Nats\Connection(); |
488 | 503 | if($params === 'stop_log') { |
489 | 504 | $client->connect(60); |
490 | - }else{ |
|
505 | + } else{ |
|
491 | 506 | $client->connect(5); |
492 | 507 | } |
493 | - $cb = function (Nats\Message $message) use ($params, $app) { |
|
508 | + $cb = function (Nats\Message $message) use ($params, $app) |
|
509 | + { |
|
494 | 510 | if($params === 'stop_log'){ |
495 | 511 | $data = json_decode($message->getBody(), true); |
496 | 512 | if(!file_exists($data['filename'])){ |
@@ -513,7 +529,7 @@ discard block |
||
513 | 529 | Util::mwexec("ln -s {$data['filename']} {$result_dir}/{$link_name}"); |
514 | 530 | $app->response->redirect("{$scheme}://{$host}/download_link/{$uid}/{$link_name}"); |
515 | 531 | $app->response->send(); |
516 | - }else{ |
|
532 | + } else{ |
|
517 | 533 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
518 | 534 | $app->response->setContent($message->getBody()); |
519 | 535 | $app->response->send(); |
@@ -568,7 +584,8 @@ discard block |
||
568 | 584 | * Онлайн обновление АТС. |
569 | 585 | * curl -X POST -d '{"md5":"df7622068d0d58700a2a624d991b6c1f", "url": "https://www.askozia.ru/upload/update/firmware/6.2.96-9.0-svn-mikopbx-x86-64-cross-linux.img"}' http://172.16.156.223/pbxcore/api/system/upgrade_online; |
570 | 586 | */ |
571 | -$app->post('/api/system/{name}', function ($params) use ($app) { |
|
587 | +$app->post('/api/system/{name}', function ($params) use ($app) |
|
588 | +{ |
|
572 | 589 | $data = [ |
573 | 590 | 'result"' => 'ERROR' |
574 | 591 | ]; |
@@ -582,7 +599,7 @@ discard block |
||
582 | 599 | if($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
583 | 600 | $res = Util::mwexec("cp '{$post_data['filename']}' '{$upd_file}'") === 0; |
584 | 601 | } |
585 | - }else{ |
|
602 | + } else{ |
|
586 | 603 | // Загружаем новый файл на сервер |
587 | 604 | foreach ($app->request->getUploadedFiles() as $file) { |
588 | 605 | $res = $file->moveTo($upd_file); |
@@ -597,7 +614,7 @@ discard block |
||
597 | 614 | return; |
598 | 615 | } |
599 | 616 | $data = null; |
600 | - }else if($params === 'upload_audio_file') { |
|
617 | + } else if($params === 'upload_audio_file') { |
|
601 | 618 | $dirs = PBX::get_asterisk_dirs(); |
602 | 619 | $filename = ''; |
603 | 620 | $res = false; |
@@ -608,7 +625,7 @@ discard block |
||
608 | 625 | $filename = "{$dirs['media']}/".basename($post_data['filename']); |
609 | 626 | $res = Util::mwexec("cp {$post_data['filename']} {$filename}") === 0; |
610 | 627 | } |
611 | - }else{ |
|
628 | + } else{ |
|
612 | 629 | foreach ($app->request->getUploadedFiles() as $file) { |
613 | 630 | $filename = $dirs['media'].'/'.basename($file->getName()); |
614 | 631 | $res = $file->moveTo( $filename); |
@@ -625,7 +642,7 @@ discard block |
||
625 | 642 | |
626 | 643 | $data = ['filename' => $filename]; |
627 | 644 | $params = 'convert_audio_file'; |
628 | - }else{ |
|
645 | + } else{ |
|
629 | 646 | $row_data = $app->request->getRawBody(); |
630 | 647 | // Проверим, переданные данные. |
631 | 648 | if(!Util::is_json($row_data)){ |
@@ -644,7 +661,8 @@ discard block |
||
644 | 661 | |
645 | 662 | $client = new Nats\Connection(); |
646 | 663 | $client->connect(10); |
647 | - $cb = function (Nats\Message $message) use ($app) { |
|
664 | + $cb = function (Nats\Message $message) use ($app) |
|
665 | + { |
|
648 | 666 | $app->response->setStatusCode(200, "OK")->sendHeaders(); |
649 | 667 | $app->response->setContent(''.$message->getBody()); |
650 | 668 | $app->response->send(); |
@@ -672,7 +690,8 @@ discard block |
||
672 | 690 | * Проверить соединение с FTP / SFTP хранилищем. |
673 | 691 | * curl http://172.16.156.212/pbxcore/api/backup/check_storage_ftp?id=1 |
674 | 692 | */ |
675 | -$app->get('/api/backup/{name}', function ($action)use ($app) { |
|
693 | +$app->get('/api/backup/{name}', function ($action)use ($app) |
|
694 | +{ |
|
676 | 695 | $request = array( |
677 | 696 | 'data' => $_REQUEST, |
678 | 697 | 'action' => $action |
@@ -680,7 +699,8 @@ discard block |
||
680 | 699 | |
681 | 700 | $client = new Nats\Connection(); |
682 | 701 | $client->connect(10); |
683 | - $cb = function (Nats\Message $message) use ($action, $app) { |
|
702 | + $cb = function (Nats\Message $message) use ($action, $app) |
|
703 | + { |
|
684 | 704 | if($action === 'download'){ |
685 | 705 | $id = $app->request->get('id'); |
686 | 706 | $b = new Backup($id); |
@@ -707,7 +727,7 @@ discard block |
||
707 | 727 | |
708 | 728 | proc_nice(15); |
709 | 729 | readfile($filename); |
710 | - }else{ |
|
730 | + } else{ |
|
711 | 731 | $scheme = $app->request->getScheme(); |
712 | 732 | $host = $app->request->getHttpHost(); |
713 | 733 | $port = $app->request->getPort(); |
@@ -720,7 +740,7 @@ discard block |
||
720 | 740 | $app->response->redirect("{$scheme}://{$host}:{$port}/download_link/{$uid}/{$id}.{$extension}"); |
721 | 741 | $app->response->send(); |
722 | 742 | } |
723 | - }else{ |
|
743 | + } else{ |
|
724 | 744 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
725 | 745 | $app->response->setContent($message->getBody()); |
726 | 746 | $app->response->send(); |
@@ -745,7 +765,8 @@ discard block |
||
745 | 765 | * curl -X POST -d '{"id": "backup_1534838222", "options":{"backup-config":"1","backup-records":"1","backup-cdr":"1","backup-sound-files":"1"}}' http://172.16.156.212/pbxcore/api/backup/recover; |
746 | 766 | * curl -X POST -d '{"id": "backup_1534838222", "options":{"backup-sound-files":"1"}}' http://172.16.156.212/pbxcore/api/backup/recover; |
747 | 767 | */ |
748 | -$app->post('/api/backup/{name}', function ($params)use ($app){ |
|
768 | +$app->post('/api/backup/{name}', function ($params)use ($app) |
|
769 | +{ |
|
749 | 770 | if($params === 'upload' ){ |
750 | 771 | $data = []; |
751 | 772 | $data['result'] = 'ERROR'; |
@@ -761,7 +782,7 @@ discard block |
||
761 | 782 | // the file is stored in a temporary directory |
762 | 783 | if(isset($_POST['resumableIdentifier']) && trim($_POST['resumableIdentifier'])!==''){ |
763 | 784 | $temp_dir = $dirs['tmp'].'/'.$_POST['resumableIdentifier']; |
764 | - }else{ |
|
785 | + } else{ |
|
765 | 786 | $temp_dir = $dirs['tmp'].'/backup'; |
766 | 787 | } |
767 | 788 | $dest_file = $temp_dir.'/'.$_POST['resumableFilename'].'.part'.$_POST['resumableChunkNumber']; |
@@ -820,10 +841,11 @@ discard block |
||
820 | 841 | 'settings_file' => $settings_file |
821 | 842 | ] |
822 | 843 | ]; |
823 | - $client->request('backup', json_encode($req_data), function (Nats\Message $message){ |
|
844 | + $client->request('backup', json_encode($req_data), function (Nats\Message $message) |
|
845 | + { |
|
824 | 846 | }); |
825 | 847 | |
826 | - }else{ |
|
848 | + } else{ |
|
827 | 849 | $data['result'] = 'INPROGRESS'; |
828 | 850 | } |
829 | 851 | } |
@@ -849,7 +871,8 @@ discard block |
||
849 | 871 | |
850 | 872 | $client = new Nats\Connection(); |
851 | 873 | $client->connect(10); |
852 | - $cb = static function (Nats\Message $message) use ($app) { |
|
874 | + $cb = static function (Nats\Message $message) use ($app) |
|
875 | + { |
|
853 | 876 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
854 | 877 | $app->response->setContent(''.$message->getBody()); |
855 | 878 | $app->response->send(); |
@@ -862,7 +885,8 @@ discard block |
||
862 | 885 | * curl -F "[email protected]" http://127.0.0.1/pbxcore/api/upload/module -H 'Cookie: XDEBUG_SESSION=PHPSTORM' |
863 | 886 | * curl -X POST -d '{"id": "1531474060"}' http://127.0.0.1/pbxcore/api/upload/status; -H 'Cookie: XDEBUG_SESSION=PHPSTORM' |
864 | 887 | */ |
865 | -$app->post('/api/upload/{name}', function ($params)use ($app){ |
|
888 | +$app->post('/api/upload/{name}', function ($params)use ($app) |
|
889 | +{ |
|
866 | 890 | |
867 | 891 | $data = []; |
868 | 892 | $data['result'] = 'ERROR'; |
@@ -887,7 +911,7 @@ discard block |
||
887 | 911 | $temp_dir = $dirs['tmp'].'/'.Util::trim_extension_file(basename($resumableFilename)); |
888 | 912 | $temp_dst_file = $dirs['tmp'].'/'.$upload_id.'/'.basename($resumableFilename); |
889 | 913 | $chunks_dest_file = $temp_dir.'/'.$resumableFilename.'.part'.$resumableChunkNumber; |
890 | - }else{ |
|
914 | + } else{ |
|
891 | 915 | $temp_dir = $dirs['tmp'].'/'.$upload_id; |
892 | 916 | $temp_dst_file = $temp_dir.'/'.basename($file->getName()); |
893 | 917 | $chunks_dest_file = $temp_dst_file; |
@@ -902,7 +926,7 @@ discard block |
||
902 | 926 | $data['result'] = 'ERROR'; |
903 | 927 | $data['d_status_progress'] = '0'; |
904 | 928 | $data['d_status'] = 'ID_NOT_SET'; |
905 | - }elseif($resumableFilename) { |
|
929 | + } elseif($resumableFilename) { |
|
906 | 930 | // Передача файлов частями. |
907 | 931 | $result = Util::createFileFromChunks($temp_dir, $resumableFilename, $resumableTotalSize, $resumableChunkNumber, '', $resumableChunkSize); |
908 | 932 | if($result === true){ |
@@ -929,13 +953,14 @@ discard block |
||
929 | 953 | 'settings_file' => $settings_file |
930 | 954 | ] |
931 | 955 | ]; |
932 | - $client->request('system', json_encode($req_data), function (Nats\Message $message){ |
|
956 | + $client->request('system', json_encode($req_data), function (Nats\Message $message) |
|
957 | + { |
|
933 | 958 | }); |
934 | 959 | $data['upload_id'] = $upload_id; |
935 | 960 | $data['filename'] = $temp_dst_file; |
936 | 961 | $data['d_status'] = 'INPROGRESS'; |
937 | 962 | } |
938 | - }else{ |
|
963 | + } else{ |
|
939 | 964 | $data['result'] = 'Success'; |
940 | 965 | // Передача файла целиком. |
941 | 966 | $data['upload_id'] = $upload_id; |
@@ -945,7 +970,7 @@ discard block |
||
945 | 970 | Util::mwexec_bg('/etc/rc/shell_functions.sh killprocesses '.$temp_dir.' -TERM 0;rm -rf '.$temp_dir, '/dev/null', 30); |
946 | 971 | } |
947 | 972 | } |
948 | - }elseif($params === 'status'){ |
|
973 | + } elseif($params === 'status'){ |
|
949 | 974 | $data['result'] = 'Success'; |
950 | 975 | $post_data = json_decode($app->request->getRawBody(), true); |
951 | 976 | if($post_data && isset($post_data['id'])){ |
@@ -957,18 +982,17 @@ discard block |
||
957 | 982 | $data['result'] = 'ERROR'; |
958 | 983 | $data['d_status_progress'] = '0'; |
959 | 984 | $data['d_status'] = 'ID_NOT_SET'; |
960 | - } |
|
961 | - elseif(!file_exists($progress_file) && file_exists($progress_dir)){ |
|
985 | + } elseif(!file_exists($progress_file) && file_exists($progress_dir)){ |
|
962 | 986 | $data['d_status_progress'] = '0'; |
963 | 987 | $data['d_status'] = 'INPROGRESS'; |
964 | - }elseif( !file_exists($progress_dir) ){ |
|
988 | + } elseif( !file_exists($progress_dir) ){ |
|
965 | 989 | $data['result'] = 'ERROR'; |
966 | 990 | $data['d_status_progress'] = '0'; |
967 | 991 | $data['d_status'] = 'NOT_FOUND'; |
968 | - }elseif('100' === file_get_contents($progress_file) ){ |
|
992 | + } elseif('100' === file_get_contents($progress_file) ){ |
|
969 | 993 | $data['d_status_progress'] = '100'; |
970 | 994 | $data['d_status'] = 'DOWNLOAD_COMPLETE'; |
971 | - }else{ |
|
995 | + } else{ |
|
972 | 996 | $data['d_status_progress'] = file_get_contents($progress_file); |
973 | 997 | } |
974 | 998 | } |
@@ -1016,7 +1040,8 @@ discard block |
||
1016 | 1040 | * @param $name |
1017 | 1041 | * @param $command |
1018 | 1042 | */ |
1019 | -$f_modules_name_command = function ($name, $command) use ($app) { |
|
1043 | +$f_modules_name_command = function ($name, $command) use ($app) |
|
1044 | +{ |
|
1020 | 1045 | |
1021 | 1046 | $_REQUEST['ip_srv'] = $_SERVER['SERVER_ADDR']; |
1022 | 1047 | $input = file_get_contents( 'php://input' ); |
@@ -1028,7 +1053,8 @@ discard block |
||
1028 | 1053 | 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'] |
1029 | 1054 | ]; |
1030 | 1055 | |
1031 | - $cb = function (Nats\Message $message) use ($name, $command, $app) { |
|
1056 | + $cb = function (Nats\Message $message) use ($name, $command, $app) |
|
1057 | + { |
|
1032 | 1058 | $response = json_decode($message->getBody(), true); |
1033 | 1059 | if( isset($response['fpassthru']) ) { |
1034 | 1060 | $fp = fopen($response['filename'], "rb"); |
@@ -1047,10 +1073,10 @@ discard block |
||
1047 | 1073 | if (isset($response['need_delete']) && $response['need_delete'] == true) { |
1048 | 1074 | unlink($response['filename']); |
1049 | 1075 | } |
1050 | - }elseif (isset($response['redirect'])){ |
|
1076 | + } elseif (isset($response['redirect'])){ |
|
1051 | 1077 | $app->response->redirect($response['redirect'], true, 302); |
1052 | 1078 | $app->response->send(); |
1053 | - }elseif (isset($response['headers']) && isset($response['echo'])){ |
|
1079 | + } elseif (isset($response['headers']) && isset($response['echo'])){ |
|
1054 | 1080 | foreach ($response['headers'] as $name => $value){ |
1055 | 1081 | $app->response->setHeader($name, $value); |
1056 | 1082 | } |
@@ -1058,11 +1084,11 @@ discard block |
||
1058 | 1084 | $app->response->setContent($response['echo']); |
1059 | 1085 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1060 | 1086 | $app->response->send(); |
1061 | - }elseif (isset($response['echo_file'])){ |
|
1087 | + } elseif (isset($response['echo_file'])){ |
|
1062 | 1088 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1063 | 1089 | $app->response->setFileToSend($response['echo_file']); |
1064 | 1090 | $app->response->send(); |
1065 | - }else{ |
|
1091 | + } else{ |
|
1066 | 1092 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1067 | 1093 | $app->response->setContent($message->getBody()); |
1068 | 1094 | $app->response->send(); |
@@ -1084,7 +1110,8 @@ discard block |
||
1084 | 1110 | curl -F "[email protected]" http://127.0.0.1/pbxcore/api/modules/upload; |
1085 | 1111 | curl -X POST -d '{"filename":"/storage/usbdisk1/mikopbx/tmp/ModuleTemplate.zip"}' http://127.0.0.1/pbxcore/api/modules/unpack -H 'Cookie: XDEBUG_SESSION=PHPSTORM'; |
1086 | 1112 | */ |
1087 | -$app->post('/api/modules/{command}', function ($command) use ($app){ |
|
1113 | +$app->post('/api/modules/{command}', function ($command) use ($app) |
|
1114 | +{ |
|
1088 | 1115 | $result = [ |
1089 | 1116 | 'result' => 'ERROR', |
1090 | 1117 | 'uniqid' => null |
@@ -1094,10 +1121,10 @@ discard block |
||
1094 | 1121 | if (Util::is_json($app->request->getRawBody() ) ){ |
1095 | 1122 | $row_data = $app->request->getRawBody(); |
1096 | 1123 | $data = json_decode( $row_data, true); |
1097 | - }else{ |
|
1124 | + } else{ |
|
1098 | 1125 | $result['data'] = 'Body is not JSON'; |
1099 | 1126 | } |
1100 | - }elseif( in_array($command, ['upload', 'unpack']) ){ |
|
1127 | + } elseif( in_array($command, ['upload', 'unpack']) ){ |
|
1101 | 1128 | $dirs = PBX::get_asterisk_dirs(); |
1102 | 1129 | $module_file = "{$dirs['tmp']}/".time().'.zip'; |
1103 | 1130 | if ($app->request->hasFiles() > 0) { |
@@ -1109,7 +1136,7 @@ discard block |
||
1109 | 1136 | $file->moveTo($module_file); |
1110 | 1137 | break; |
1111 | 1138 | } |
1112 | - }elseif ('unpack' === $command ){ |
|
1139 | + } elseif ('unpack' === $command ){ |
|
1113 | 1140 | $post_data = json_decode($app->request->getRawBody(), true); |
1114 | 1141 | if($post_data && isset($post_data['filename']) && file_exists($post_data['filename'])) { |
1115 | 1142 | Util::mwexec("cp '{$post_data['filename']}' '{$module_file}'"); |
@@ -1130,7 +1157,7 @@ discard block |
||
1130 | 1157 | 'l_file' => $module_file, |
1131 | 1158 | 'uniqid' => $module_uniqid |
1132 | 1159 | ]; |
1133 | - }else{ |
|
1160 | + } else{ |
|
1134 | 1161 | $result['data'] = 'Failed to upload file to server'; |
1135 | 1162 | } |
1136 | 1163 | $command = 'upload'; |
@@ -1144,7 +1171,8 @@ discard block |
||
1144 | 1171 | ); |
1145 | 1172 | $client = new Nats\Connection(); |
1146 | 1173 | $client->connect(5); |
1147 | - $cb = function (Nats\Message $message) use (&$result) { |
|
1174 | + $cb = function (Nats\Message $message) use (&$result) |
|
1175 | + { |
|
1148 | 1176 | $result = json_decode($message->getBody(), true); |
1149 | 1177 | }; |
1150 | 1178 | $client->request('modules', json_encode($request), $cb); |
@@ -1160,14 +1188,16 @@ discard block |
||
1160 | 1188 | * Получить список подключенных дисков к ПК. |
1161 | 1189 | * curl http://172.16.156.212/pbxcore/api/storage/list |
1162 | 1190 | */ |
1163 | -$app->get('/api/storage/{name}', function ($name) use ($app) { |
|
1191 | +$app->get('/api/storage/{name}', function ($name) use ($app) |
|
1192 | +{ |
|
1164 | 1193 | $request = array( |
1165 | 1194 | 'data' => $_REQUEST, |
1166 | 1195 | 'action' => $name |
1167 | 1196 | ); |
1168 | 1197 | $client = new Nats\Connection(); |
1169 | 1198 | $client->connect(10); |
1170 | - $cb = function (Nats\Message $message) use ($name, $app) { |
|
1199 | + $cb = function (Nats\Message $message) use ($name, $app) |
|
1200 | + { |
|
1171 | 1201 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1172 | 1202 | $app->response->setContent($message->getBody()); |
1173 | 1203 | $app->response->send(); |
@@ -1186,7 +1216,8 @@ discard block |
||
1186 | 1216 | * curl -X POST -d '{"dev":"/dev/sdc"}' http://172.16.156.212/pbxcore/api/storage/status_mkfs; |
1187 | 1217 | * 'ended' / 'inprogress' |
1188 | 1218 | */ |
1189 | -$app->post('/api/storage/{name}', function ($name)use ($app){ |
|
1219 | +$app->post('/api/storage/{name}', function ($name)use ($app) |
|
1220 | +{ |
|
1190 | 1221 | $row_data = $app->request->getRawBody(); |
1191 | 1222 | // Проверим, переданные данные. |
1192 | 1223 | if(!Util::is_json($row_data)){ |
@@ -1203,7 +1234,8 @@ discard block |
||
1203 | 1234 | |
1204 | 1235 | $client = new Nats\Connection(); |
1205 | 1236 | $client->connect(10); |
1206 | - $cb = function (Nats\Message $message) use ($app) { |
|
1237 | + $cb = function (Nats\Message $message) use ($app) |
|
1238 | + { |
|
1207 | 1239 | $app->response->setStatusCode(200, 'OK')->sendHeaders(); |
1208 | 1240 | $app->response->setContent(''.$message->getBody()); |
1209 | 1241 | $app->response->send(); |
@@ -1215,7 +1247,8 @@ discard block |
||
1215 | 1247 | /** |
1216 | 1248 | * Обработка не корректного запроса. |
1217 | 1249 | */ |
1218 | -$app->notFound(function () use ($app) { |
|
1250 | +$app->notFound(function () use ($app) |
|
1251 | +{ |
|
1219 | 1252 | sleep(2); |
1220 | 1253 | $app->response->setStatusCode(404, 'Not Found')->sendHeaders(); |
1221 | 1254 | $app->response->setContent('This is crazy, but this page was not found!'); |
@@ -1224,7 +1257,7 @@ discard block |
||
1224 | 1257 | |
1225 | 1258 | try{ |
1226 | 1259 | $app->handle(); |
1227 | -}catch( Nats\Exception $e){ |
|
1260 | +} catch( Nats\Exception $e){ |
|
1228 | 1261 | Util::sys_log_msg('pbx_core_api', $e->getMessage() ); |
1229 | 1262 | // Если произошло исключение, то NATS скорее всего не запущен. |
1230 | 1263 | $response = [ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | }elseif(!in_array($pattern, $panel_pattern, true)) { |
47 | 47 | $res_auth = false; |
48 | 48 | } |
49 | - if(FALSE === $res_auth){ |
|
49 | + if(false === $res_auth){ |
|
50 | 50 | $app->response->setStatusCode(403, 'Forbidden')->sendHeaders(); |
51 | 51 | $app->response->setContent('The user isn\'t authenticated. '); |
52 | 52 | $app->response->send(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if(!$size || $type === ''){ |
138 | 138 | openlog('miko_ajam', LOG_PID | LOG_PERROR, LOG_AUTH); |
139 | 139 | $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Undefined'; |
140 | - syslog(LOG_WARNING, "From {$_SERVER['REMOTE_ADDR']}. UserAgent: ({$user_agent}). File not found."); |
|
140 | + syslog(LOG_WARNING, "from {$_SERVER['REMOTE_ADDR']}. UserAgent: ({$user_agent}). File not found."); |
|
141 | 141 | closelog(); |
142 | 142 | |
143 | 143 | $response = new Phalcon\Http\Response(); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | openlog('miko_ajam', LOG_PID | LOG_PERROR, LOG_AUTH); |
258 | 258 | |
259 | 259 | $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Undefined'; |
260 | - syslog(LOG_WARNING, "From {$_SERVER['REMOTE_ADDR']}. UserAgent: ({$user_agent}). File not found."); |
|
260 | + syslog(LOG_WARNING, "from {$_SERVER['REMOTE_ADDR']}. UserAgent: ({$user_agent}). File not found."); |
|
261 | 261 | closelog(); |
262 | 262 | $app->response->resetHeaders(); |
263 | 263 | $app->response->setRawHeader('HTTP/1.0 404 Not Found'); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | 'result' => 'ERROR', |
1090 | 1090 | 'uniqid' => null |
1091 | 1091 | ]; |
1092 | - $data = NULL; |
|
1092 | + $data = null; |
|
1093 | 1093 | if ('upload' === $command && $app->request->hasFiles() === 0){ |
1094 | 1094 | if (Util::is_json($app->request->getRawBody() ) ){ |
1095 | 1095 | $row_data = $app->request->getRawBody(); |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | Util::mwexec($cmd, $out); |
1121 | 1121 | $settings = json_decode(implode("\n", $out), true); |
1122 | 1122 | |
1123 | - $module_uniqid = $settings['module_uniqid'] ?? NULL; |
|
1123 | + $module_uniqid = $settings['module_uniqid'] ?? null; |
|
1124 | 1124 | if(!$module_uniqid){ |
1125 | 1125 | $result['data'] = 'The" module_uniqid " in the module file is not described.the json or file does not exist.'; |
1126 | 1126 | } |