2017年2月26日 星期日

[PHP] 保護configuration file







Don't place the config file in web root
Protect with htaccess
chmod your config file

sudo find /var/www/ -type d -exec chmod 755 {} \;
sudo find /var/www/ -type f -exec chmod 644 {} \;




2017年2月4日 星期六

[Javascript] 取得過去時間與現在時間差距

function timeSince(date) {
    var seconds = Math.floor((new Date().getTime() - date) / 1000);
    var interval = Math.floor(seconds / 31536000);
    if (interval >= 1) {
        return interval + " years ago";
    }
    interval = Math.floor(seconds / 2592000);
    if (interval >= 1) {
        return interval + " months ago";
    }
    interval = Math.floor(seconds / 86400);
    if (interval >= 1) {
        return interval + " days ago";
    }
    interval = Math.floor(seconds / 3600);
    if (interval >= 1) {
        return interval + " hours ago";
    }
    interval = Math.floor(seconds / 60);
    if (interval >= 1) {
        return interval + " minutes ago";
    }
    return Math.floor(seconds) + " seconds ago";
}

[CentOS] httpd port 9000 to 80

<VirtualHost *:80>     ServerName domain.name     ProxyRequests Off     ProxyVia Block     ProxyPreserveHost On     <Proxy *...