Skip to content

Commit 77fefe8

Browse files
SajakiSajaki
authored andcommitted
fixes
- [FIX] make curl https compatible - [FIX] #108 poll layout issue
1 parent 9607a50 commit 77fefe8

File tree

11 files changed

+3353
-20
lines changed

11 files changed

+3353
-20
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ env:
4141
branches:
4242
only:
4343
- develop32
44-
- develop32_cdb
4544
- /^\d+(\.\d+)?\.x$/
4645

4746
install:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
- 2.2.8 (10/06/2018)
55
- [FIX] #82 RT FIX
6+
- [FIX] make curl https compatible
7+
- [FIX] #108 poll layout issue
68

79
- 2.2.7 (25/02/2018)
810
- [NEW] #82 recent topics is now available on a special page http://url/app.php/rt

acp/recenttopics_module.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public function main($id, $mode)
4545
$ext_meta_manager = $ext_manager->create_extension_metadata_manager('paybas/recenttopics', $phpbb_container->get('template'));
4646
$meta_data = $ext_meta_manager->get_metadata();
4747
$ext_version = $meta_data['version'];
48-
$versionurl = $meta_data['extra']['version-check']['protocol']. $meta_data['extra']['version-check']['host'].$meta_data['extra']['version-check']['directory'].'/'.$meta_data['extra']['version-check']['filename'];
49-
$latest_version = $this->version_check($versionurl, $request->variable('versioncheck_force', false));
48+
$latest_version = $this->version_check($meta_data, $request->variable('versioncheck_force', false));
5049

5150
if ($request->is_set_post('submit'))
5251
{
@@ -190,17 +189,30 @@ public function main($id, $mode)
190189
* @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
191190
* @return bool
192191
*/
193-
public final function version_check($versionurl, $force_update = false, $ttl = 86400)
192+
public final function version_check($meta_data, $force_update = false, $ttl = 86400)
194193
{
195-
global $user, $cache;
194+
global $user, $cache, $phpbb_extension_manager, $path_helper;
195+
196+
$pemfile = '';
197+
$versionurl = ($meta_data['extra']['version-check']['ssl'] == '1' ? 'https://': 'http://') .
198+
$meta_data['extra']['version-check']['host'].$meta_data['extra']['version-check']['directory'].'/'.$meta_data['extra']['version-check']['filename'];
199+
$ssl = $meta_data['extra']['version-check']['ssl'] == '1' ? true: false;
200+
if ($ssl) {
201+
//https://davidwalsh.name/php-ssl-curl-error
202+
$pemfile = $phpbb_extension_manager->get_extension_path('paybas/recenttopics', true) . 'core/mozilla.pem';
203+
if (!(file_exists($pemfile) && is_readable($pemfile)))
204+
{
205+
$ssl = false;
206+
}
207+
}
196208

197209
//get latest productversion from cache
198210
$latest_version = $cache->get('recenttopics_versioncheck');
199211

200212
//if update is forced or cache expired then make the call to refresh latest productversion
201213
if ($latest_version === false || $force_update)
202214
{
203-
$data = parent::curl($versionurl, false, false, false);
215+
$data = parent::curl($versionurl, $ssl, $pemfile, false, false, false);
204216
if (0 === count($data) )
205217
{
206218
$cache->destroy('recenttopics_versioncheck');

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=5.4.0",
26-
"composer/installers": "~1.0.0",
27-
"phpbb/phpbb": ">=3.2.0"
25+
"php": ">=5.4",
26+
"composer/installers": "~1.0"
2827
},
2928
"require-dev": {
3029
"phpbb/epv": "dev-master"
@@ -35,10 +34,10 @@
3534
"phpbb/phpbb": ">=3.2.0"
3635
},
3736
"version-check": {
38-
"protocol": "https://",
3937
"host": "www.avathar.be",
4038
"directory": "/versioncheck",
41-
"filename": "recenttopics22.json"
39+
"filename": "recenttopics22.json",
40+
"ssl": true
4241
}
4342
}
4443
}

core/admin.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ class admin
1616
* connects to remote site and gets xml or html using Curl
1717
*
1818
* @param $url
19+
* @param $ssl
1920
* @param bool $return_Server_Response_Header
2021
* @param bool $loud
2122
* @param bool $json
2223
* @return array
2324
*/
24-
public final function curl($url, $return_Server_Response_Header = false, $loud = true, $json = true)
25+
public final function curl($url, $ssl = false, $pemfile, $return_Server_Response_Header = false, $loud = true, $json = true)
2526
{
2627
global $phpbb_container, $user;
2728

@@ -47,18 +48,24 @@ public final function curl($url, $return_Server_Response_Header = false, $loud =
4748
// set options
4849
curl_setopt_array(
4950
$curl, array(
50-
CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0', //override
51+
CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0', //override
5152
CURLOPT_TIMEOUT => 60,
5253
CURLOPT_VERBOSE => true,
5354
CURLOPT_URL => $url,
5455
CURLOPT_HEADER => $return_Server_Response_Header,
55-
CURLOPT_SSL_VERIFYHOST => 2,
56-
CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks
5756
CURLOPT_FOLLOWLOCATION, true,
5857
CURLOPT_RETURNTRANSFER => true, //return web page
5958
)
6059
);
6160

61+
// set ssl options
62+
if($ssl)
63+
{
64+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,true);
65+
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
66+
curl_setopt($curl, CURLOPT_CAINFO, $pemfile);
67+
}
68+
6269
$response = curl_exec($curl);
6370
$headers = curl_getinfo($curl);
6471

0 commit comments

Comments
 (0)