Thursday, May 24, 2012

IPCop :: block facebook hhpd - altenative

from http://gateway.hacker.my/2011/02/blocking-https-facebook-using-ipcop/
As we know, Squid’s transparent proxy cannot filter https traffic, but we can block it using iptables. Here are some tricks how to block https traffic from Facebook using IPcop version 1.9.x.

The easiest way to block Facebook’s https traffic is by blocking its IP range. You don’t have to find the specific IP for Facebook to block it. As we know, Facebook has a lot of public IP addresses.

– SNIP

1. From the IPcop gui-menu, go to Firewall –> Addresses

2. Put Name, Address format (make sure you choose IP here), Address and Netmask.

3. Here is the tricky part. For the Address and Netmask, put these IP addresses.
 
69.63.176.0/255.255.240.0
66.220.144.0/255.255.240.0
204.15.20.0/255.255.240.0

4. From the whois information, you can see at least this range belongs to Facebook.com
 
bsd@genetics:~$ whois 204.15.20.0
#
# Query terms are ambiguous.  The query is assumed to be:
#     "n 204.15.20.0"
#
# Use "?" to get help.
#
 
#
# The following results may also be obtained via:
# http://whois.arin.net/rest/nets;q=204.15.20.0?showDetails=true&showARIN=false
#
 
NetRange:       204.15.20.0 - 204.15.23.255
CIDR:           204.15.20.0/22
OriginAS:       AS32934
NetName:        TFBNET1
NetHandle:      NET-204-15-20-0-1
Parent:         NET-204-0-0-0-0
NetType:        Direct Assignment
NameServer:     NS5.FACEBOOK.COM
NameServer:     NS4.FACEBOOK.COM
NameServer:     NS3.FACEBOOK.COM
Comment:        Contact abuse@facebook.com with issues.
RegDate:        2005-08-08
Updated:        2010-07-08
Ref:            http://whois.arin.net/rest/net/NET-204-15-20-0-1
 
OrgName:        Facebook, Inc.
OrgId:          THEFA-3
Address:        1601 S. California Ave
City:           Palo Alto
StateProv:      CA
PostalCode:     94304
Country:        US
RegDate:        2004-08-11
Updated:        2010-04-09
Ref:            http://whois.arin.net/rest/org/THEFA-3
 
OrgTechHandle: OPERA82-ARIN
OrgTechName:   Operations
OrgTechPhone:  +1-650-543-4800
OrgTechEmail:  domain@facebook.com
OrgTechRef:    http://whois.arin.net/rest/poc/OPERA82-ARIN
 
RTechHandle: OPERA82-ARIN
RTechName:   Operations
RTechPhone:  +1-650-543-4800
RTechEmail:  domain@facebook.com
RTechRef:    http://whois.arin.net/rest/poc/OPERA82-ARIN
 
RAbuseHandle: OPERA82-ARIN
RAbuseName:   Operations
RAbusePhone:  +1-650-543-4800
RAbuseEmail:  domain@facebook.com
RAbuseRef:    http://whois.arin.net/rest/poc/OPERA82-ARIN
 
RNOCHandle: OPERA82-ARIN
RNOCName:   Operations
RNOCPhone:  +1-650-543-4800
RNOCEmail:  domain@facebook.com
RNOCRef:    http://whois.arin.net/rest/poc/OPERA82-ARIN
 
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#
 
bsd@genetics:~$

5. Then proceed to Firewall –> Address Groups, create new Address Group Name (e.g Facebook), then select Custom Addresses inside that group.

6. Next, proceed to Firewall Rules –> Outgoing Traffic, then configure your firewall as below :
 
Default networks = Green Networks
Destination --> Address Groups -->Facebook
Tick Use Service --> Default Services --> https (443)
Additional --> Tick Rule enabled, Rule Action -->Drop, Remark -->Facebook https blocked
Click Save

7. Make sure these rules stay above any other rules.

8.  After this, point your browser at https://www.facebook.com. If you have understood and done things right, you should be unable to open https Facebook and get a timeout message.

MS Visual Studio

MS Visual Studio
Version history

Prior to Visual Studio Version 4.0 there were Visual Basic 3, Visual C++, Visual FoxPro and Visual SourceSafe as separate products.
Product name  Codename  Internal
version  Supported .NET
Framework versions  Release date
Visual Studio  N/A  4.0  N/A  1995-04
Visual Studio 97  Boston  5.0  N/A  1997-02
Visual Studio 6.0  Aspen  6.0  N/A  1998-06
Visual Studio .NET (2002)  Rainier  7.0  1.0  2002-02-13
Visual Studio .NET 2003  Everett  7.1  1.1  2003-04-24
Visual Studio 2005  Whidbey  8.0  2.0  2005-11-07
Visual Studio 2008  Orcas  9.0  2.0, 3.0, 3.5  2007-11-19
Visual Studio 2010  Dev10/Rosario  10.0  2.0, 3.0, 3.5, 4.0  2010-04-12

from : http://en.wikipedia.org/wiki/Microsoft_Visual_Studio

Monday, May 21, 2012

Tuesday, May 15, 2012

Ubuntu


Choose to be a pirate or choose to liberate!




upgrade ubuntu
do-release-upgrade --proposed
do-release-upgrade -d
update-manager -d
lsb_release -a

altenative
sed -i 's/oneiric/precise/g' /etc/apt/sources.list
apt-get update
apt-get dist-upgrade
apt-get upgrade


Monday, May 14, 2012

PHP

Display file size (Byte, MB,...)
 0.9){
        $filesize = $filesize / $decr;
        $step++;
    }
    return round($filesize,2).' '.$prefix[$step];
    } else {

    return 'NaN';
    }
  
}
?>
ftp

Upload image to database
////
/*

$result[name]
"; } ?> //// //// "; ?> */
Download image
            $filename = 'dummy.zip';
            $filename = realpath($filename);

            $file_extension = strtolower(substr(strrchr($filename,"."),1));

            switch ($file_extension) {
                case "pdf": $ctype="application/pdf"; break;
                case "exe": $ctype="application/octet-stream"; break;
                case "zip": $ctype="application/zip"; break;
                case "doc": $ctype="application/msword"; break;
                case "xls": $ctype="application/vnd.ms-excel"; break;
                case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
                case "gif": $ctype="image/gif"; break;
                case "png": $ctype="image/png"; break;
                case "jpe": case "jpeg":
                case "jpg": $ctype="image/jpg"; break;
                default: $ctype="application/force-download";
            }

            if (!file_exists($filename)) {
                die("NO FILE HERE");
            }

            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: private",false);
            header("Content-Type: $ctype");
            header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: ".@filesize($filename));
            set_time_limit(0);
            @readfile("$filename") or die("File not found.");
Upload image w/ YUI pgrogress bar
















 

Linux - environment

set date format to specific format :
vi /etc/environment
add the below setting
TIME_STYLE='+%Y-%m-%d %H:%M'
save & test :
drwxr-xr-x  2 fadabi fadabi  4096 2012-05-09 15:21 Music

Sunday, May 13, 2012

Linux common command

tar :
tar xvzf file-1.0.tar.gz - for uncompress a gzip tar file (.tgz or .tar.gz)
tar xvjf file-1.0.tar.bz2 - for uncompress a bzip2 tar file (.tbz or .tar.bz2)
tar xvf file-1.0.tar - for uncompressed tar file (.tar)

linux user:
groupadd developers
useradd -G developers vivek
passwd vivek
id vivek
useradd -G admins,ftp,www,developers jerry
useradd -g developers tony
usermod -a -G ftp tony
usermod -g www tony
usermod -s /sbin/nologin vivek
userdel vivek


'du' - Finding the size of a directory

$ du
Typing the above at the prompt gives you a list of directories that exist in the current directory along with their sizes. The last line of the output gives you the total size of the current directory including its subdirectories. The size given includes the sizes of the files and the directories that exist in the current directory as well as all of its subdirectories. Note that by default the sizes given are in kilobytes.


$ du /home/david
The above command would give you the directory size of the directory /home/david


$ du -h
This command gives you a better output than the default one. The option '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.


$ du -ah
This command would display in its output, not only the directories but also all the files that are present in the current directory. Note that 'du' always counts all files and directories while giving the final size in the last line. But the '-a' displays the filenames along with the directory names in the output. '-h' is once again human readable format.


$ du -c
This gives you a grand total as the last line of the output. So if your directory occupies 30MB the last 2 lines of the output would be

30M .
30M total

The first line would be the default last line of the 'du' output indicating the total size of the directory and another line displaying the same size, followed by the string 'total'. This is helpful in case you this command along with the grep command to only display the final total size of a directory as shown below.


$ du -ch | grep total
This would have only one line in its output that displays the total size of the current directory including all the subdirectories.

Note : In case you are not familiar with pipes (which makes the above command possible) refer to Article No. 24 . Also grep is one of the most important commands in Unix. Refer to Article No. 25 to know more about grep.


$ du -s
This displays a summary of the directory size. It is the simplest way to know the total size of the current directory.


$ du -S
This would display the size of the current directory excluding the size of the subdirectories that exist within that directory. So it basically shows you the total size of all the files that exist in the current directory.


$ du --exculde=mp3
The above command would display the size of the current directory along with all its subdirectories, but it would exclude all the files having the given pattern present in their filenames. Thus in the above case if there happens to be any mp3 files within the current directory or any of its subdirectories, their size would not be included while calculating the total directory size.

-

'df' - finding the disk free space / disk usage

$ df
Typing the above, outputs a table consisting of 6 columns. All the columns are very easy to understand. Remember that the 'Size', 'Used' and 'Avail' columns use kilobytes as the unit. The 'Use%' column shows the usage as a percentage which is also very useful.


$ df -h
Displays the same output as the previous command but the '-h' indicates human readable format. Hence instead of kilobytes as the unit the output would have 'M' for Megabytes and 'G' for Gigabytes.

Most of the users don't use the other parameters that can be passed to 'df'. So I shall not be discussing them.

I shall in turn show you an example that I use on my machine. I have actually stored this as a script named 'usage' since I use it often.

Example :

I have my Linux installed on /dev/hda1 and I have mounted my Windows partitions as well (by default every time Linux boots). So 'df' by default shows me the disk usage of my Linux as well as Windows partitions. And I am only interested in the disk usage of the Linux partitions. This is what I use :

$ df -h | grep /dev/hda1 | cut -c 41-43

This command displays the following on my machine

45%