Skip to content

Хаброметр (Habrometr) — сбор и графическое отображение показателей хабраюзеров

License

Notifications You must be signed in to change notification settings

feedbee/habrometr

Repository files navigation

Habrometr Source Code.

Version 2.0.

This program collects habrahabr.ru karma, habraforce and habra rate values and
visualizes it on graphical informers.

The software published under GPL3 License.

 *  Copyright (C) 2009 Leontyev Valera
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.

SOFTWARE DEPENDENCIES

1) HTTP-Webserver (possible Apache);
2) MySQL Database (5.x and heigher);
3) PHP 5.1 or heigher with Curl, IMagick and memcache extensions;
4) Image Magick libs;
5) [Optional] nginx, eaccelerator, memcached.

INSTALLATION

1) Create new database and user. "Add" user to new database. Exequte SQL from
./habrometr.sql file.

2) Create config.local.php file with the next contents:
Listing 1. config.local.php
---------------------------------------------------------------------------------
<?php
define('DB_USER', 'xxx');
define('DB_PASS', 'yyy');
define('DB_NAME', 'zzz');
define('SERVICE_URL', 'http://localhost/habrometr');
define('RE_CAPTCHA_KEY_PRIVATE', '=== your private key ==='); // http://www.google.com/recaptcha/
define('RE_CAPTCHA_KEY_PUBLIC', '=== your public key ===');
define('DEBUG_MODE', true); // true to dump uncatched exception message, false to
                            // send wordless 404 or 500 responce codes
define('LOG_LEVEL', 7);     // 0...7 according BSD Syslog message severities
---------------------------------------------------------------------------------
Replace the xxx, yyy, zzz, keys and www-root path with real values.

3) Upload all source code to server. Chmod `image_cache` directory to 0777.

4) If you don't want to use Memcache (in relation with nginx), comment out
last if-block in index.php.
Other way use the next nginx configuration (replace hostnames and ports
with your values):
Listing 2. nginx.conf
---------------------------------------------------------------------------------
user www-data;
worker_processes 2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  2048;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;

    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    add_header Habrometr "hacker_mode_enabled;)";

    server {
        listen       80;
        server_name  habrometr.server.valera.ws habrometr.ru www.habrometr.ru;

        access_log  /var/log/nginx/habrometr.access.log;

        location / {
            root   /home/habrometr/public_html;
            index  index.html index.htm;

            if (-f $document_root/image_cache${uri}) {
                rewrite ^.*$ /image_cache/$uri last;
                break;
            }

            set $memcached_key "habrometr$uri";
            memcached_pass localhost:11211;
            error_page 404 405 502 504 = @backend;
            add_header Content-Type "text/html; charset=UTF-8";
            gzip on;
            gzip_proxied any;
            gzip_types application/octet-stream;
        }

        location @backend {
            set $proxy_uri http://habrometr.ru:9999$request_uri;
            proxy_pass $proxy_uri;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout 20;
        }

        location /image_cache/ {
            root   /home/habrometr/public_html;
            expires modified +2h;
        }

        location /stuff/ {
            root   /home/habrometr/public_html;
            expires 30d;
        }

        location ~* \.(gif|jpg|jpeg|ico) {
            root  /home/habrometr/public_html;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /var/www/nginx-default;
        }

        location ~ \.php$ {
            proxy_pass   http://habrometr.ru:9999;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout 20;
        }

        location ~ /\.ht {
            deny  all;
        }
    }
}

About

Хаброметр (Habrometr) — сбор и графическое отображение показателей хабраюзеров

Resources

License

Stars

Watchers

Forks

Packages

No packages published