Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (p && fs.existsSync(p)) {
// browser caching
var fd = fs.openSync(p, 'r');
var modified = new Date(fs.fstatSync(fd).mtime);
fs.closeSync(fd);
var ifmodifiedsince = new Date(context.req.headers['if-modified-since']);
if (modified.getTime() >= ifmodifiedsince.getTime() && !disableCache) {
context.res.writeHead(304);
context.res.end();
return;
}
// file caching
var hash = md5.digest_s(type + ':' + ':' + key + ':' + size);
var filename = writeable.imgCache + '/' + hash + '.png';
if (fs.existsSync(filename)) {
//logger.info('[asset] File cache hit, returning ' + filename);
return file(context, filename);
} else {
logger.info('[asset] No cache hit for ' + filename);
}
// cache, process.
var now = new Date().getTime();
processFct(gm(p), function(gm) {
// stream to client
gm.stream(function(err, stream) {
if (err) {
logger.error('[asset] ERROR streaming image: ' + err);
function hashData (url, datastr) {
url = url.toLowerCase().substr(7);
var indexS = url.indexOf("/");
if(indexS == -1 || url.substr(indexS + 1) == "" ) { // url is like http://127.0.0.1 or http://127.0.0.1/
url = "host";
}else {
url = url.substr(indexS + 1);
}
return url+ "/" + md5.digest_s(datastr);
}
User.findOne({ _id: mongoose.Types.ObjectId(userid) },function(err,user){
if (!err && user) {
// this is required.
if (inprofile.gravatar_email) {
user.profile.gravatar_email = inprofile.gravatar_email;
user.profile.gravatar_hash = md5.digest_s(inprofile.gravatar_email);
user.profile.twitter_user = inprofile.twitter_user;
user.profile.github_user = inprofile.github_user;
user.profile.website = inprofile.website;
user.save(function(err){
if (err) {
log.error('user_setprofile_sav',{userid: userid, err: err});
}
callback(err);
});
} else {
callback("gravatar email is required, if you don't have a gravatar account, that's OK. just enter anything.");
BuilderDatabase.prototype.saveHash = function(project, packages, callback){
if (!packages || !packages.length){
if (callback) callback(null);
return;
}
var packageString = typeof packages == 'string' ? packages : packages.join(';');
var hash = md5.digest_s(packageString);
function hashCount(db, cb){
db.get('SELECT COUNT(*) AS count FROM hashes WHERE md5 = ?', {1: hash}, function(err, row){
cb(err, row && {count: row.count, db: db, hash: hash});
});
}
function insertIfNotExisting(res, cb){
if (res.hash){
cb(null, {hash: hash, packages: packages});
} else {
var values = {1: hash, 2: packageString, 3: Math.round(Date.now() / 1000)};
res.db.run('INSERT INTO hashes (md5, packages, date) VALUES (?, ?, ?)', values, function(error){
if (error) cb(error);
else cb(null, {hash: hash, packages: packages});
});
}
getUrl() {
var hash = md5.digest_s(this.props.email.toLocaleLowerCase());
var size = Math.ceil(this.props.size * (window.devicePixelRatio || 1));
return "https://secure.gravatar.com/avatar/" + hash + "?d=mm&s=" + size;
}