Skip to content

Commit

Permalink
add spider Disallow roles
Browse files Browse the repository at this point in the history
  • Loading branch information
xCss committed Apr 1, 2017
1 parent d4dfca7 commit d7c5c98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/www
Expand Up @@ -15,7 +15,7 @@ var http = require('http');
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '1001');
var port = normalizePort(process.env.PORT || '999');
app.set('port', port);

/**
Expand Down
5 changes: 3 additions & 2 deletions routes/photo.js
Expand Up @@ -35,7 +35,8 @@ router.get('/:photo', function(req, res, next) {
return;
break;
case 'download':
if (!isAjax) {
var ua = req.get('User-Agent');
if (!isAjax && !/(spider|bot)/ig.test(ua)) {
var sql = `update bing as a join (select downloads,id from bing WHERE qiniu_url='${photo}') as b on a.id=b.id set a.downloads=(b.downloads+1)`;
db.commonQuery(sql, function(rows) {
res.set({
Expand All @@ -44,7 +45,7 @@ router.get('/:photo', function(req, res, next) {
});
request.get(`http://images.ioliu.cn/bing/${photo}_1920x1080.jpg`)
.set({
'User-Agent': req.get('User-Agent')
'User-Agent': ua
}).pipe(res);
});
} else {
Expand Down

0 comments on commit d7c5c98

Please sign in to comment.