RSS

Monthly Archives: September 2011

How You Use the Google Maps API

So your client emails you and asks, “Can you put one of those flashy maps on my contact page so that users can actually see our building from a satellite’s view?”. You’ve used Google maps many times, but there is only one problem: you have no idea how to use the API. Well get out your spoon and dig in!

For example and Code click on following link :
http://net.tutsplus.com/articles/news/this-is-how-you-use-the-google-maps-api

That’s it.

 
Leave a comment

Posted by on Sep 21, 2011 in API

 

Tags: , ,

5 Ways To Reduce Comment Spam On WordPress Blogs

If you have a self-hosted WordPress blog which is quite popular, the most annoying thing is fighting WordPress comment spam on a regular basis. Every time you login to WordPress dashboard, you see a whole lot of spam comments waiting to be deleted. Either you have to delete them manually or let them die in the spam queue.

The latter option is not recommended as it will increase database size and the resource loading time. Hence, you have to find and fight your way to prevent spam comments in WordPress. This article describes some of the proven techniques which can be used to reduce WordPress comment spam.

Before we go any further, let’s understand what exactly is a spam comment.

A spam comment is a comment which is posted automatically in blogs, websites, forums etc by automated bots, scripts or software. Some people use scripts and automated bots to target high traffic websites for posting comments. Typically, a spam comment is full of irrelevant keywords and hyperlinks and does not care about the discussion or article where the comment is posted.

In short, a spam comment is an evil form of shameless self-promotion and trying to get quick links for traffic or SEO.

If you are getting lots of spam comments in your WordPress blog, here are some techniques which can help:

  1. Install Akismet WordPress Plugin

Akismet is considered as the best WordPress plugin to reduce comment spam. The plugin checks each and every comment, pingbacks and trackbacks submitted in your blog and runs critical checks on the Akismet web service to determine whether the comment is a spam or not.

In addition to blocking spam comments and bad links, Akismet shows a stats page where you can see more details on the amount of comments blocked, accuracy, dates etc.

2. Close comments on Older Posts

Using Akismet is good but overtime you will find that Akismet is blocking hundreds of spam comments every week. You have to delete those spam comments manually, which is really a boring job. If you want even more control over the spam comments, consider blocking comments on older posts.

Spammers target posts which receive good traffic and you can automatically close comments on posts which are certain days old. Login to your blog’s administration area and go to Settings > Discussion. Next, select the checkbox “Automatically close comments on article older than” and enter the number of days in the text box (for example 90).

This ensures that the comments are closed on any article which is older than the number of days specified by you.

3. Ban Spam IP Addresses

Wp-Ban is a useful WordPress plugin which can be used to blacklist IP addresses who try to post spam comments in your blog. The plugin checks the IP address of the commentator and if you have already specified the same IP address in plugin settings, the commentator is shown a custom banned message.

Once you activate the plugin, keep an eye on the IP addresses of the spam comments. Next, add the IP addresses in the plugin blacklist and bingo! You will find that the number of spam comments are reducing as IP blacklist increases.

This plugin should be used with caution. If you blacklist an IP address, any visitor coming from the same host name would not be able to view your blog. Use this plugin to blacklist certain IP’s if they appear too frequently and post vulgar comments in your blog.

4. Use a Custom WordPress Function to Ban Empty Referrers

On most of the occasions, spam commentators never visit your blog and you can use this principle to drastically reduce comment spam.

Log in to WordPress administration area of your blog and go to “Theme Editor”. Select your blog’s theme and open the functions.php file for editing. Paste the following code:

 
<?php
 function verify_comment_referer() {
 if (!wp_get_referer()){
 wp_die( __('You cannot post comment at this time, may be you need to enable referrers in your browser.') ); 
 }
 }
 add_action('check_comment_flood', 'verify_comment_referer');
 ?>

The above function checks the “referring source” of the page on which the comment in posted.
 In case of spam comments, if the referring source is found to be empty the comments are never allowed to be posted and thus you do not receive any spam.
 Thanks to Internet Techies for the tip.

5. Use Recaptcha WordPress Plugin

As mentioned by Google in their Webmaster central blog, the Recaptcha WordPress plugin is one of the best ways to prevent WordPress spam comments in your blog. The concept is really simple – anyone trying to post a comment have to see a graphic and type the words matching the graphic. The spam bots do not have eyes and mind and thus can’t see and read those graphics. Hence they can’t post those intrusive comments.

Use recatcha WordPress plugin for protecting spam comments

The recatcha plugin serves the purpose well, but it has a major disadvantage. The regular commentators of your blog would have to fill up the catcha when they try to post a comment. This may appear discouraging or confusing to the visitor and he may refrain from posting comments altogether. Many popular blogs use Recaptcha, but I am not a fan of this plugin as this may offend the regular commentators.

 
Leave a comment

Posted by on Sep 19, 2011 in wordpress

 

Tags: , , , , , , ,

How to upload an image to a PHP server In chunks from Window7 Mobile

<?php
foreach ($_GET as $key => $value) { eval("\$" . $key . " = \"" . $value . "\";");}
$filename = isset($_REQUEST["filename"]) ? $_REQUEST["filename"] : "jjj";
$append = $_REQUEST["append"];
if($code == "54m3xuzm97z30rdfsloegjizvzgga12bshptv59o")
{
    try
    {
        if(!$append)
            $file = fopen("fishups/" . $filename,"w");
        else
            $file = fopen("fishups/" . $filename,"a");  

        $input = file_get_contents ("php://input");
        fwrite($file,$input);
        fclose($file);
        echo "OK";
    }
    catch (Exception $e)
    {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}
?>

For more click http://www.invulgo.dk/blog_PhotoUpload.php
 

Tags: , ,

Push Notification for Windows Phone 7 in php

It’s very easy to find samples and tutorial to send Push Notifications to Windows Phone 7 using ASP.Net Web Services, but there is nothing for php.

This class will help you. Only Curl is necessary.

available functions :

  • Send Toast Push Notification
  • Update Tile
  • Send Raw Push Notification

example :

$uri=”http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798&#8243;; //uri sended by Microsoft plateform
$notif=new WindowsPhonePushNotification($uri);
$notif->push_toast(“this is a title”,”this is the sub title”);

Full class file is as below:

Make a blank php file and add the following code in this

<?php
/**
*Windows Phone 7 Push Notification in php by Rudy HUYN
**/
final class WindowsPhonePushDelay
{

const Immediate=0;
const In450Sec=10;
const In900Sec=20;

private function __construct(){}
}

class WindowsPhonePushNotification
{
private $notif_url = ”;

function WindowsPhonePushNotification($notif_url)
{
$this->notif_url = $notif_url;
}

/**
* Toast notifications are system-wide notifications that do not disrupt the user workflow or require intervention to resolve. They are displayed at the top of the screen for ten seconds before disappearing. If the toast notification is tapped, the application that sent the toast notification will launch. A toast notification can be dismissed with a flick.
* Two text elements of a toast notification can be updated:
* Title. A bolded string that displays immediately after the application icon.
* Sub-title. A non-bolded string that displays immediately after the Title.
*/
public function push_toast($title, $subtitle,$delay = WindowsPhonePushDelay::Immediate, $message_id=NULL)
{
$msg =    “<?xml version=\”1.0\” encoding=\”utf-8\”?>” .
“<wp:Notification xmlns:wp=\”WPNotification\”>” .
“<wp:Toast>” .
“<wp:Text1>”.htmlspecialchars($title).”</wp:Text1>” .
“<wp:Text2>”.htmlspecialchars($subtitle).”</wp:Text2>” .
“</wp:Toast>” .
“</wp:Notification>”;

return $this->push(‘toast’,$delay+2,$message_id, $msg);
}

/**
*A Tile displays in the Start screen if the end user has pinned it. Three elements of the Tile can be updated:
*@background_url : You can use a local resource or remote resource for the background image of a Tile.
*@title : The Title must fit a single line of text and should not be wider than the actual Tile. If this value is not set, the already-existing Title will display in the Tile.
*@count. an integer value from 1 to 99. If not set in the push notification or set to any other integer value, the current Count value will continue to display.
*/
public function push_tile($background_url, $title, $count, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL)
{
$msg =     “<?xml version=\”1.0\” encoding=\”utf-8\”?>” .
“<wp:Notification xmlns:wp=\”WPNotification\”>” .
“<wp:Tile>” .
“<wp:BackgroundImage>”.htmlspecialchars($background_url).”</wp:BackgroundImage>” .
“<wp:Count>$count</wp:Count>” .
“<wp:Title>”.htmlspecialchars($title).”</wp:Title>” .
“</wp:Tile>” .
“</wp:Notification>”;

return $this->push(‘token’,$delay+1, $message_id,$msg);
}

/**
* If you do not wish to update the Tile or send a toast notification, you can instead send raw information to your application using a raw notification. If your application is not currently running, the raw notification is discarded on the Microsoft Push Notification Service and is not delivered to the device. The payload of a raw notification has a maximum size of 1 KB.
*/
public function push_raw($data, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL)
{
return $this->push(NULL,$delay+3,$message_id, $data);
}

/**
*@target : type of notification
*@delay : immediate, in 450sec or in 900sec
*@message_id : The optional custom header X-MessageID uniquely identifies a notification message. If it is present, the same value is returned in the notification response. It must be a string that contains a UUID
*/
private function push($target,$delay,$message_id,$msg)
{

$sendedheaders=  array(
‘Content-Type: text/xml’,
‘Accept: application/*’,
“X-NotificationClass: $delay”
);
if($message_id!=NULL)
$sendedheaders[]=”X-MessageID: $message_id”;
if($target!=NULL)
$sendedheaders[]=”X-WindowsPhone-Target:$target”;

$req = curl_init();
curl_setopt($req, CURLOPT_HEADER, true);
curl_setopt($req, CURLOPT_HTTPHEADER,$sendedheaders);
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $msg);
curl_setopt($req, CURLOPT_URL, $this->notif_url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($req);
curl_close($req);

$result=array();
foreach(explode(“\n”,$response) as $line)
{
$tab=explode(“:”,$line,2);
if(count($tab)==2)
$result[$tab[0]]=trim($tab[1]);
}
return $result;
}
}

?>

 
 

Tags: , , ,

Hindi English Dictionary and English to Hindi Dictionary

http://dict.hinkhoj.com/

 
Leave a comment

Posted by on Sep 14, 2011 in Uncategorized

 

How to store UTF8 (indian language) data in mysql?

We assume we have a DataBase with table news, and a column named posts, which will save the news written in your website.We know that all major DataBase’s support UTF8. And we shall explore that feature.
Now we write a article in hindi, हेल्लो वर्ल्ड
If the UTF8 is not specified, you should see something like ?????? in ur DataBase otherwise you should see the hindi data. Clear? Now lets see the code given below:

First check for UTF8 compatibility with this query. If it supports you should see the output as “Character_set_system”| “UTF8″
SHOW VARIABLES LIKE ‘character_set_system’;
this will show the below result if support:

Full Texts
Variable_name    Value
character_set_system    utf8

Now that being checked, alter the table and just modify the column, which is ‘text’ in our above example and specify it as UTF8
ALTER TABLE news MODIFY text VARCHAR(200) CHARACTER SET UTF8;

Then execute following query before inserting into the table:

mysql_query(‘SET character_set_results=utf8’);
mysql_query(‘SET names=utf8’);
mysql_query(‘SET character_set_client=utf8’);
mysql_query(‘SET character_set_connection=utf8’);
mysql_query(‘SET collation_connection=utf8_general_ci’);

 
Now, try to insert the hindi value and save it. Query it and u should see the hindi text :)

 
2 Comments

Posted by on Sep 14, 2011 in Mysql, PHP

 

Tags: , , ,

Run mysql connect in php on cron tab

run the following commands in terminal of ubantu:

1. crontab -e

2. Once it opens press i (for insert) and type the cron command.

3.  * * * * * /opt/lampp/bin/php -q /opt/lampp/htdocs/test1.php >> /home/a3logics/Desktop/log.txt

4. Press esc (escsape, you will taken out of insertion mode)

5. Press: :wq this will write (w) the file and quit (q), don’t forget the leading :

OR

5. Press:  😡 to quit

6. Show the listing of crontab by command crontab -l

for more details:

http://codeigniter.com/forums/viewthread/199279/#934603

 
Leave a comment

Posted by on Sep 13, 2011 in cron job

 

Tags: ,

 
%d bloggers like this: