Disqus problem with wordpress “unable to connect to the disqus api servers”

I recently installed Disqus plugin for WordPress; however, I have been receiving this message “unable to connect to the disqus api servers.” By looking into the source code, it looks like curl is the problem! more specifically the _dsq_curl_urlopen() function, but I did not investigate this error further. As fortunately, we can easily switch to the alternative function _dsq_fsockopen_urlopen().

Ban IP from logging in for 5 minutes after 10 failed logins

if( login_limit() )
   die( 'Your IP has been banned from logging in for the next 5 minutes' );

 * Counts login times by same IP 
 * returns true if limit reached or false if not 
function login_limit(){
    //get real IP if user behind proxy noted by Sebastian Enger
    //user still banned from login
    if( _cache( $ip . 'banned' ) )
        return true;

    //number of seconds 
    $sec = 30;
    //find ip info array in cache saved less than $sec ago
    if( ($ip_info=_cache( $ip ))  && $ip_info[0] > time()-$sec ){
        //user login 10 times during last $sec 
        if(  $ip_info[1] > 10 ){
            //ban user ip for the next 5 minutes
            _cache( $ip . 'banned', 1, 0, 60*5 );
            _cache( $ip, -1 );
            return true;
        //increase login retries +1 
        _cache( $ip, array(  $ip_info[0],   ++$ip_info[1] ), 0, $sec );
        return false;
    //add ip info to cache
    _cache( $ip, array( time(), 1 ), 0, $sec );
    return false;

function _cache( $name, $val=NULL, $ttl=false ){
	global $mcdb;
	if(empty($mcdb) ) 
		$mcdb = memcache_connect('unix:///etc/sockets/memcached.sock', 0);
	if($val === -1){
		return memcache_delete($mcdb,$name);
	}elseif( $val !== NULL ){
		return memcache_set($mcdb,$name,$val, false, $ttl);
		$retval = memcache_get($mcdb,$name);
		return  $retval ? $retval : NULL;


Convert html to vbcode and post to vbulletin

using vbulletin files :

define('THIS_SCRIPT', 'login');
require_once( './global.php');
require_once( DIR . '/includes/functions_wysiwyg.php' );

echo convert_wysiwyg_html_to_bbcode('<i>hello world</i>');

using external function :

get an array containing random integers between $min and $max integers

Trying to pick up random keys from an array but don’t want any duplicates?
try this

Using Google AJAX API to copy google results in array

This is some way you can get Google results as a JavaScript array that you can display on any page, you first need to get your Google API Key then try this code…