Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.

Commit 759eb6a

Browse files
committed
Merge branch 'release/1.2.18'
2 parents 15ea9e0 + 9bd21be commit 759eb6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+325
-197
lines changed

CHANGELOG.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# OpenVBX Change Log
22

3+
## OpenVBX 1.2.18
4+
5+
- Fix implementation of several methods by making them static.
6+
- Update config of `base_url` to accommodate servers living behind a proxy.
7+
- Fix validation of the Twilio Request for servers not running mod-rewrite support.
8+
- Fix notification settings save when altering settings as a tenant. (Thanks @AsaadQ)
9+
- Removing obsolete update check.
10+
- Numerous small fixes, code style updates, and docblock fixes of issues found during static analysis.
11+
- Implement cache control on `messages/scripts` endpoint and script tag to prevent caching.
12+
- Fix user edit button href after new users are added to contain the proper user edit url.
13+
- Explicitly hide `E_DEPRECATED` and `E_STRICT` errors in the default error reporting to handle the differences in how different versions of PHP report errors.
14+
- Convert html entities in license section that were causing an email address to be hidden.
15+
16+
317
## OpenVBX 1.2.17
418

519
- Fix implementation of `OpenVBX::connectAuthTenant()` by making it static.

OpenVBX/config/config.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@
1919
| http://example.com/
2020
|
2121
*/
22-
$config['base_url']= "http".((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')? 's' : '')
23-
."://".$config['server_name']. rtrim(WEB_ROOT, '/').'/';
22+
$is_ssl_proto = false;
23+
switch(true) {
24+
case !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off':
25+
$is_ssl_proto = true;
26+
break;
27+
case !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https':
28+
$is_ssl_proto = true;
29+
break;
30+
}
31+
32+
$config['base_url'] = "http".($is_ssl_proto ? 's' : '') .
33+
"://".$config['server_name'] . rtrim(WEB_ROOT, '/') . '/';
2434

2535
/*
2636
|--------------------------------------------------------------------------
@@ -30,7 +40,7 @@
3040
| Used for asset url versioning.
3141
|
3242
*/
33-
$config['site_rev'] = 1024;
43+
$config['site_rev'] = 1026;
3444

3545
/*
3646
|--------------------------------------------------------------------------

OpenVBX/config/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
22

3-
$config['version'] = '1.2.17';
3+
$config['version'] = '1.2.18';

OpenVBX/controllers/audiofiles.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ function add_file()
119119

120120
// Return the URL for our newly created file
121121
$json['url'] = "vbx-audio-upload://" . basename($targetFile);
122-
123-
$ci =& get_instance();
124-
122+
125123
// And, make a record in the database
126124
$audioFile = new VBX_Audio_File();
127125
$audioFile->label = "Upload of " . $file['name'];
@@ -322,6 +320,7 @@ function accept_or_reject_recording_twiml()
322320
break;
323321
case 2:
324322
$response->redirect(site_url('audiofiles/prompt_for_recording_twiml'));
323+
break;
325324
default:
326325
$response->redirect(site_url('audiofiles/replay_recording_twiml'));
327326
break;

OpenVBX/controllers/auth/connect.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public function index()
5151
if ($account_sid = $this->input->get('AccountSid')) // regular account sid
5252
{
5353
$this->setup_connect_tenant($account_sid, $user->tenant_id);
54-
return redirect($tenant[0]->url_prefix.'/welcome#step-2');
54+
redirect($tenant[0]->url_prefix.'/welcome#step-2');
5555
}
5656
elseif ($error = $this->input->get('error')) // unauthorized_client
5757
{
5858
$this->setup_connect_tenant($error, $user->tenant_id);
59-
return redirect($tenant[0]->url_prefix.'/welcome');
59+
redirect($tenant[0]->url_prefix.'/welcome');
6060
}
6161
}
6262
}
@@ -150,7 +150,7 @@ protected function validate_returning_user($user_id)
150150
protected function returning_user_fail()
151151
{
152152
$this->session->sess_destroy();
153-
return redirect('auth/login');
153+
redirect('auth/login');
154154
}
155155

156156
/**

OpenVBX/controllers/auth/login.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ private function login($redirect)
125125
return $this->after_login_completed($user, $redirect);
126126
}
127127

128-
return $this->redirect($redirect);
128+
$this->redirect($redirect);
129129
}
130130

131131
$this->session->set_flashdata('error',
132132
'Email address and/or password is incorrect');
133-
return redirect('auth/login?redirect='.urlencode($redirect));
133+
redirect('auth/login?redirect='.urlencode($redirect));
134134
}
135135
catch(GoogleCaptchaChallengeException $e)
136136
{
@@ -175,7 +175,7 @@ protected function after_login_completed($user, $redirect)
175175
$path = '/'.(($this->tenant->id > 1)? $this->tenant->name : '');
176176
setrawcookie('banner', rawurlencode(json_encode($banner)), 0, $path);
177177
set_last_known_url(site_url('/numbers'));
178-
return redirect('');
178+
redirect('');
179179
}
180180
}
181181
catch(VBX_IncomingNumberException $e)
@@ -189,11 +189,11 @@ protected function after_login_completed($user, $redirect)
189189
if(empty($devices))
190190
{
191191
set_last_known_url(site_url('/devices'));
192-
return redirect('');
192+
redirect('');
193193
}
194194
}
195195

196196
set_last_known_url($redirect);
197-
return $this->redirect('');
197+
$this->redirect('');
198198
}
199199
}

OpenVBX/controllers/auth/reset.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function set_password($invite_code = '')
4747
{
4848
if(empty($invite_code))
4949
{
50-
return redirect('auth/login');
50+
redirect('auth/login');
5151
}
5252

5353
$user = VBX_User::get(array(
@@ -57,7 +57,7 @@ public function set_password($invite_code = '')
5757

5858
if(!$user)
5959
{
60-
return redirect('auth/login');
60+
redirect('auth/login');
6161
}
6262

6363
$data = array('invite_code' => $invite_code);
@@ -67,7 +67,7 @@ public function set_password($invite_code = '')
6767
try
6868
{
6969
$user->set_password($_POST['password'], $_POST['confirm']);
70-
return redirect('auth/login');
70+
redirect('auth/login');
7171
}
7272
catch(VBX_UserException $e) {
7373
$data['error'] = $e->getMessage();
@@ -98,7 +98,7 @@ public function reset()
9898
if(empty($user))
9999
{
100100
$this->session->set_flashdata('error', 'No active account found.');
101-
return redirect('auth/reset');
101+
redirect('auth/reset');
102102
}
103103

104104
if($user->auth_type == 'google')
@@ -116,10 +116,10 @@ public function reset()
116116
$this->session->set_flashdata('error',
117117
'The email was not sent. Contact your admin.');
118118
}
119-
return redirect('auth/login');
119+
redirect('auth/login');
120120
}
121121

122-
return redirect('auth/reset');
122+
redirect('auth/reset');
123123
}
124124

125125
}

OpenVBX/controllers/client.php

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -44,57 +44,6 @@ public function index()
4444
}
4545
}
4646

47-
public function updates()
48-
{
49-
switch($this->request_method)
50-
{
51-
case 'GET':
52-
return $this->get_updates();
53-
default:
54-
break;
55-
}
56-
}
57-
58-
private function get_updates()
59-
{
60-
if($this->session->userdata('loggedin') != 1
61-
|| $this->session->userdata('is_admin') != 1)
62-
{
63-
$data['json'] = array('message' => 'Unable to fetch updates', 'error' => true);
64-
return $this->respond('', '', $data);
65-
}
66-
67-
$ch = curl_init();
68-
curl_setopt($ch, CURLOPT_URL, 'http://openvbx.org/updates/latest.json');
69-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
70-
$resp = curl_exec($ch);
71-
72-
if(!$resp)
73-
{
74-
// Its okay we can't connect to the update system but log it
75-
error_log('Unable to connect to OpenVBX Update notification server');
76-
}
77-
78-
$data['json'] = array('message' => 'Unable to fetch updates', 'error' => true);
79-
80-
if($obj = json_decode($resp))
81-
{
82-
$data['json']['upgradeAvailable'] = false;
83-
list($current['major'], $current['minor']) = explode('.', OpenVBX::version());
84-
list($latest['major'], $latest['minor']) = explode('.', $obj->version);
85-
if($latest['major'] > $current['major']
86-
|| $latest['major'] == $current['major'] && $latest['minor'] > $current['minor'])
87-
{
88-
$data['json'] = array(
89-
'error' => false,
90-
'upgradeAvailable' => true
91-
);
92-
}
93-
}
94-
95-
$this->respond('', '', $data);
96-
}
97-
9847
private function get_client()
9948
{
10049
$theme_type = $this->input->get('type');
@@ -122,7 +71,7 @@ private function get_client()
12271

12372
if($this->response_type != 'json')
12473
{
125-
return redirect('');
74+
redirect('');
12675
}
12776

12877
$data['json'] = $client;

OpenVBX/controllers/devices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private function update_order()
201201

202202
if($this->response_type == 'html')
203203
{
204-
return redirect('account/number');
204+
redirect('account/number');
205205
}
206206

207207
$this->respond('', 'account/number', $data);

OpenVBX/controllers/dialog.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
* Contributor(s):
2020
**/
2121

22+
/**
23+
* @param VBX_User|stdClass $a
24+
* @param VBX_User|stdClass $b
25+
* @return int
26+
*/
2227
function sortUsersAndGroupsByNameComparator($a, $b)
2328
{
2429
$aName = null;

OpenVBX/controllers/external.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22

33
class External extends MY_Controller {
44

5+
/**
6+
* @param $id
7+
*/
58
public function message_details($id) {
6-
return $this->request(site_url('messages/details/'.$id), array(
9+
$this->request(site_url('messages/details/'.$id), array(
710
'iphone' => site_url('iphone/messages/details/'.$id)
811
));
912
}
1013

1114
/**
1215
* Handle all external requests detecting if they're a mobile
1316
* device otherwise pass-thru to target url
17+
*
18+
* @param $url
19+
* @param array $alternativeURLs
1420
*/
1521
protected function request($url, $alternativeURLs = array()) {
1622
set_last_known_url($url);

OpenVBX/controllers/install.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ private function setup_openvbx_settings($settings)
498498
* Check for the existence of a Twilio Client specific application
499499
* Create one if necessary
500500
*
501+
* @throws InstallException
501502
* @param array $settings
502503
* @return string Application Sid
503504
*/
@@ -517,6 +518,8 @@ private function get_application($settings)
517518
));
518519

519520
$application = false;
521+
522+
/** @var Services_Twilio_Rest_Application $_application */
520523
foreach ($applications as $_application)
521524
{
522525
if ($_application->friendly_name == $app_name)

OpenVBX/controllers/messages/inbox.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ public function scripts($group = false)
164164
$messageIdsJson = '{}';
165165
}
166166

167-
/* TODO: implement JS responding */
168167
header('content-type: text/javascript');
168+
header('Expires: Fri, 22 Mar 1974 06:30:00 GMT');
169+
header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s') . ' GMT');
170+
header('Cache-Control: no-store, no-cache, must-revalidate');
171+
header('Cache-Control: post-check=0, pre-check=0', false);
172+
header('Pragma: no-cache');
169173
echo "$(document).ready(function(){ Message.Player.messageIdsToRecordingURLs = ".
170174
$messageIdsJson."; });";
171175
}
@@ -196,8 +200,10 @@ private function inbox($group = false)
196200
return;
197201
}
198202

203+
$ts = time();
204+
199205
$this->template->add_js('messages/scripts'.($group? '/'.$group : '').'?'.
200-
http_build_query(compact('max', 'offset')), 'dynamic');
206+
http_build_query(compact('max', 'offset', 'ts')), 'dynamic');
201207

202208
$data['group'] = $group;
203209
$total_items = 0;
@@ -372,7 +378,7 @@ function edit($message_id) {
372378
// set message read flag
373379
$this->vbx_message->mark_read($message->id, $this->user_id);
374380
$message->caller = format_phone($message->caller);
375-
$accepts = split(',', $_SERVER['HTTP_ACCEPT']);
381+
$accepts = explode(',', $_SERVER['HTTP_ACCEPT']);
376382
if(in_array('application/json', $accepts))
377383
{
378384
echo json_encode($message);

OpenVBX/controllers/numbers.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ protected function get_flows_list()
204204
/**
205205
* Build a list of flow options for attaching numbers to flows
206206
*
207+
* @param VBX_Flow[]
207208
* @return array
208209
*/
209210
protected function get_flow_options($flows)
@@ -251,6 +252,9 @@ function add()
251252
$this->respond('', 'numbers', $data);
252253
}
253254

255+
/**
256+
* @param int $phone_id
257+
*/
254258
function delete($phone_id)
255259
{
256260
$this->admin_only($this->section);
@@ -288,6 +292,10 @@ function delete($phone_id)
288292
echo json_encode($data);
289293
}
290294

295+
/**
296+
* @param int $phone_id
297+
* @param int $id id of flow to assign number to
298+
*/
291299
function change($phone_id, $id)
292300
{
293301
$this->admin_only($this->section);

0 commit comments

Comments
 (0)