Архив метки: php

Список IP адресов серверов, с которых производились рассылки СПАМа

DNSBL — это динамически обновляющийся список IP адресов серверов, с помощью которых производились рассылки СПАМа.

Continue reading “Список IP адресов серверов, с которых производились рассылки СПАМа” »

Getting real IP address in PHP

Are you using $_SERVER[‘REMOTE_ADDR’] to find the the client’s IP address in PHP? Well dude, you might be amazed to know that it may not return the true IP address of the client at all time. If your client is connected to the Internet through Proxy Server then $_SERVER[‘REMOTE_ADDR’] in PHP just returns the the IP address of the proxy server not of the client’s machine.  So here is a simple function in PHP to find the real IP address of the client’s machine. Continue reading “Getting real IP address in PHP” »

foreach in JavaScript

Actually that’s not true at all.
As all javascript objects are really just associative arrays, there is a foreach like syntax for the ‘for’ construct.
Without it it would be very hard to work with many common javascript objects.
It’s actually very simple to use and incredibly useful if you like associative arrays.

You just have to make sure to use it on an associative array and not an object.
Example below

Continue reading “foreach in JavaScript” »

Convert a Webpage to Plain Text

This function takes a URL and returns a plain-text version of the page. It uses cURL to retrieve the page and a combination of regular expressions to strip all unwanted whitespace. This function will even strip the text from STYLE and SCRIPT tags, which are ignored by PHP functions such as strip_tags (they strip only the tags, leaving the text in the middle intact).

Regular expressions were split in 2 stages, to avoid deleting single carriage returns (also matched by s) but still delete all blank lines and multiple linefeeds or spaces, trimming operations took place in 2 stages. Continue reading “Convert a Webpage to Plain Text” »