Skip to content

Commit 45cfefa

Browse files
committed
Merge pull request #483 from niol/github-user-agent-fix
Github user agent fix
2 parents 832c871 + c2f29a4 commit 45cfefa

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

common.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$f3 = require(__DIR__.'/libs/f3/base.php');
4+
5+
$f3->set('DEBUG',0);
6+
$f3->set('version','2.10-SNAPSHOT');
7+
$f3->set('AUTOLOAD',__dir__.'/;libs/f3/;libs/;libs/WideImage/;daos/;libs/twitteroauth/;libs/FeedWriter/');
8+
$f3->set('cache',__dir__.'/data/cache');
9+
$f3->set('BASEDIR',__dir__);
10+
$f3->set('LOCALES',__dir__.'/public/lang/');
11+
12+
// read defaults
13+
$f3->config('defaults.ini');
14+
15+
// read config, if it exists
16+
if(file_exists('config.ini'))
17+
$f3->config('config.ini');
18+
19+
// init logger
20+
$f3->set(
21+
'logger',
22+
new \helpers\Logger( __dir__.'/data/logs/default.log', $f3->get('logger_level') )
23+
);
24+
25+
?>

index.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
<?php
22

3-
$f3 = require(__DIR__.'/libs/f3/base.php');
4-
5-
$f3->set('DEBUG',0);
6-
$f3->set('version','2.10-SNAPSHOT');
7-
$f3->set('AUTOLOAD',__dir__.'/;libs/f3/;libs/;libs/WideImage/;daos/;libs/twitteroauth/;libs/FeedWriter/');
8-
$f3->set('cache',__dir__.'/data/cache');
9-
$f3->set('BASEDIR',__dir__);
10-
$f3->set('LOCALES',__dir__.'/public/lang/');
11-
12-
// read defaults
13-
$f3->config('defaults.ini');
14-
15-
// read config, if it exists
16-
if(file_exists('config.ini'))
17-
$f3->config('config.ini');
3+
require(__DIR__.'/common.php');
184

195
// Load custom language
206
$lang = $f3->get('language');
217
if($lang!='0' && $lang!='')
228
$f3->set('LANGUAGE', $lang);
239

24-
// init logger
25-
$f3->set(
26-
'logger',
27-
new \helpers\Logger( __dir__.'/data/logs/default.log', $f3->get('logger_level') )
28-
);
29-
3010
// init authentication
3111
$f3->set('auth', new \helpers\Authentication());
3212

spouts/github/commits.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,17 @@ public function destroy() {
285285
* @return object JSON object
286286
*/
287287
public static function getJsonContent($url) {
288-
$content = @file_get_contents($url);
288+
$v = \F3::get('version');
289+
$options = array('http' => array(
290+
'user_agent' => "Selfoss/$v GitHub spout (+http://selfoss.aditu.de)",
291+
'ignore_errors' => true
292+
));
293+
$context = stream_context_create($options);
294+
295+
$content = file_get_contents($url, false, $context);
289296

290-
if ($content === false) {
297+
if( $http_response_header[0] != 'HTTP/1.1 200 OK' ) {
298+
\F3::get('logger')->log('github spout error ' . $http_response_header[0] . ': ' . substr($content, 0, 512), \ERROR);
291299
return false;
292300
}
293301

update.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
<?php
22

33
chdir(__DIR__);
4-
$f3 = require(__DIR__.'/libs/f3/base.php');
5-
6-
$f3->set('DEBUG',0);
7-
$f3->set('AUTOLOAD',__dir__.'/;libs/f3/;libs/;libs/WideImage/;daos/;libs/twitteroauth/;libs/FeedWriter/');
8-
$f3->set('cache',__dir__.'/data/cache');
9-
$f3->set('BASEDIR',__dir__);
10-
11-
// read config
12-
$f3->config('defaults.ini');
13-
if(file_exists('config.ini')){
14-
$f3->config('config.ini');
15-
}
16-
17-
// init logger
18-
$f3->set(
19-
'logger',
20-
new \helpers\Logger( __dir__.'/data/logs/default.log', $f3->get('logger_level') )
21-
);
4+
require(__DIR__.'/common.php');
225

236
$loader = new \helpers\ContentLoader();
247
$loader->update();
8+
9+
?>

0 commit comments

Comments
 (0)