Wordpress post via email

August 18th, 2008 by Sajith M.R

If you know this feature already , skip this article. But i have to ask a single question at the end of this section .

For wordpress version less than 2.3 , Go to Options  >  writing, and  for greater than 2.3, Go to settings > writing

What you have to do is create an email account with pop3 support

You can see the heading “Post via e-mail” there.

Enter your email server (by replacing mail.example.com)

Enter your pop3 port. (110 by default)

Enter your email login and password.

Choose a category to for the email entry posts

Finally Press update option Button

What you have done above is only the settings. For grabbing or pulling the content from email, you need to call/trigger an url.

That url is: http://yourblogdomain/wordpressinstalldir/wp-mail.php

Either you can call it manually. Or you can set up a cron job for that url by call the url using wget or like functions

Another simple mechanism to call this email trigger is use a hidden iframe in your blog template. (anywhere)

<iframe width=”0″ height=”0″  style=”display:none”  src=”http://yourblogdomain/wordpressinstalldir/wp-mail.php“></iframe>

The problem with this email posting is , it strips all the html tags before entering into wordpress database.

The is no way to find the attachments from an email.

So I decided to start a wordpress plugin which does the above missing properties. If there is any ‘working’ plugin available, please let me know, so that  I can avoid the re-inventing of wheel .

Thanks

Sajith M.R

Intelligent Watermark (php + gd)

August 9th, 2008 by Sajith M.R
This entry is part 5 of 5 in the series Online Photoshop

Online Photoshop in PHP Part (5) >>

(image after watermarked with gmail logo)

Those who haven’t seen  the online photoshop tool created by me, just click here: http://www.sajithmr.com/photoshop

Today we will implement the watermarking on images using php gd library. Intelligent watermarking means, apply a logo or a watermark image on another image by measuring the color depth of the applied image. For this water marking, use png images as logo or watermark  for better results.

Live example for watermark implementation: http://sajithmr.com/photoshop-tuts/watermark/addwatermark.php

You can see different watermark location by changing the x1,y1 and x2,y2 parameters of the following url:

http://sajithmr.com/photoshop-tuts/watermark/showresult.php?x1=405&y1=285&x2=520&y2=392&width=115&height=107

See the watermark php source code here: http://sajithmr.com/photoshop-tuts/watermark/watermark.class.txt

Download the full-source code of watermarking implementation using php+gd from here: http://sajithmr.com/photoshop-tuts/watermark.rar

Show Wordpress Currently Reading Posts

July 12th, 2008 by Sajith M.R

After the success of my previous wordpress plugins , Announcement, Show My Page Rank, Sexy Rating, Add to this , Stumble Reviews, I created one more interesting plugin, called Currently Reading Posts Plugin.

Whenever a visitor visits your website, he can see what are the posts currently reading by other visitors. It is like youtube’s currently watching videos.

Wordpress Currently Watching Plugin

You can see its current working at the top right corner of this website.

Download the plugin for here: http://www.sajithmr.com/downloads/CurrentlyWatching.zip

Go to Admin > Plugins > and activate the plugin.

Paste this code: <?php wp_show_currently_watching() ?> by editing your template / theme . (I placed the code in header.php file)

It is implemented with ajax support.

The biggest blunder I ever made with PHP

July 12th, 2008 by Sajith M.R

Blunder I ever made

I was writing a php code to parse images from a particular url . At the begining I used http://www.google.com as a testing url.

When I tested the php code from my local machine (http://localhost) it took time to get data from a remote url (google.com) . So I decided to check this code with my locally testing web page. So i write the code as bellow :

file: index.php

<?php

$content = file_get_contents(”http://localhost/”);

// parse($content);

?>

This is the biggest mistake I made that day. Did you find the mistake ?? Else try this code with your local machine. You can see your big blunder . Not only you, your system also will get hang .. :)

Because this is the longest recursive call you can call with your web server !!!

Regards

Sajith

Sexy Rating - Wordpress Plugin

June 19th, 2008 by Sajith M.R

If you wanna know , what is others review or opinion about your website, You can use this wordpress plugin. It will provide the blog readers and your regular visitor to rate your blog. You can put this plugin anywhere in your blog. The plugin name is sexyrate plugin.

Here is the screen shot:

Sexy Rate Plugin Screen Shot

There are 4 types for rating , Perfect, Good , Bad and Too-Bad. One user can rate one time only. The whole thing is made out of Ajax. For providing more attraction , the plugin is created with images of sexy ladies :) .

If you want to place this plugin, what to do is , download it from http://downloads.wordpress.org/plugin/sexyrate.zip

Go to your wordpress Admin > Plugin and activate this plugin. After that , go to Admin > Presentation > Theme Editor and edit any place you want (header, single.php , index.php, home.php or sidebar.php) as suit to your blog and add this line:

<?php wp_show_my_rate() ?>

*Remember, this plugin is referred to those who has white backgroud wordpress theme.

Comment me your opinion about this plugin

Later
Sajith

Crop Image Like Orkut

June 5th, 2008 by Sajith M.R
This entry is part 4 of 5 in the series Online Photoshop

Online Photoshop in PHP (Series Part 4) >>

Crop Image Like Orkut

Today we will discuss about cropping of images using php and gd library.

Look at the simple example here:

http://www.sajithmr.com/photoshop-tuts/crop/simplecrop.php


Here the Crop function is doing the real work. x1 and y1 are Top-Left Coordinates of new image and x2, y2 are the Bottom-Right .

Here is the function for Crop

loadImageFromObject($image);
		$cc->cropToDimensions($xpos1, $ypos1, $xpos2,$ypos2 );
		return $cc->getImageObject();

	}

?>

You can see the class.cropcanvas.php file from the attachment.

In the above example, we have to enter each coordinates manually. See the example below:

http://www.sajithmr.com/photoshop-tuts/crop/realcrop.php

Here you can select the area by click and drag (like orkut)

This is implemented with the help or jslib javascript. The given attachment in the end of this post contains the all.

http://www.sajithmr.com/photoshop-tuts/crop.zip

Keep reading for the further posts in this series. Next post is on Intellegent watermarking on images.

Subscribe to my Feeds: http://www.sajithmr.com/feed/

Download Youtube Videos using PHP Code

May 29th, 2008 by Sajith M.R

If you want to get the FLV file of any youtube video url using php code, here is the solution.

If you are a PHP Programmer and if you are working with any video website, and if you need to grab videos (FLV files) from youtube and to put it yourown site (not object embedding) , Download the Full Source Code given at the end of this article (ZIP)

I used this php code for the Youtube video download tool http://www.googleneedle.com


Here function getPatternFromUrl is nothing but, get the exact pattern of a particular video from any youtube video url format.

In the above case , it returns pzmP4UvZRa4

The function is below

function getPatternFromUrl($url)

 {

$url = $url.'&';

$pattern = '/v=(.+?)&+/';

preg_match($pattern, $url, $matches);

return ($matches[1]);

}

GetFlvFromYoutube is the main function here, which download the flv file from youtube pattern and saves to your local machine.
The function is below:

function GrabFlvFromYoutube( $pattern )
{

 require_once ("phptube.php");

 $tube = new PHPTube ();

 $flv_http_path = $tube->download($pattern) ;

 echo $flv_http_path;

 set_time_limit(0);

 $data = file_get_contents($flv_http_path);

 $new_flv_path = dirname(_FILE_).'/flvs/'.$pattern.'.flv' ;

 file_put_contents($new_flv_path, $data);

 return $new_flv_path ;

}

Download the fullsource code from this link given:

http://www.sajithmr.com/downloads/youtube-download-php.zip

Online Photoshop in PHP (Series Part 3)

May 26th, 2008 by Sajith M.R
This entry is part 3 of 5 in the series Online Photoshop

Resize a Photo >>

Today we will implement hows to resize photo into a particular width and height (or keeping aspect ratio)

See the live example from: http://www.sajithmr.com/photoshop-tuts/resize/resize.php

You need to install php-gd library to do this. To functions, imagecreatetruecolor and imagecopyresampled will do the resizing.

Those who have not seen the Online Photo Editing tool yet, have a look at: http://www.sajithmr.com/photoshop/index.php 

Here is the function:


function Resize($image,$new_width,$new_height=0)
{

 $old_width = imagesx($image);
 $old_height= imagesy($image);

 if($new_height==0) // if the height is not specified
                           //....calculate the relative height
 $new_height= $new_width * $old_height / $old_width ;

 $new_image= imagecreatetruecolor($new_width, $new_height);
 imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width,
 $new_height, $old_width, $old_height);
 return $new_image;

}

Here the $image is the object of the image which is created from the function imagecreatefromgif($path_to_photo), if the image is in GIF format.

Other functions are imagecreatefromjpeg and imagecreatefrompng for JPEG and PNG respectively .

Download Full source code for this example from: http://www.sajithmr.com/photoshop-tuts/resize.zip

In the previous part we implemented browse photos area. http://www.sajithmr.com/online-photoshop-in-php-series-part-2/

In that for browsing picture files, we used full size image, instead of thumbnails. Here new example , in which browse photos is implemented with image thumbnails using resizing (150 px)

The difference is , instead of calling img tag’s src to the orginal image path, called through resize.php?img=path_to_image , passed the image path as parameter to resize function.

See live example: http://www.sajithmr.com/photoshop-tuts/browse-resize/browse.php

Take the html and see the difference from old browse implementation: http://www.sajithmr.com/photoshop-tuts/browse.php

Which is fast ??

Download the full source code for browsing with image thumbnail from: http://www.sajithmr.com/photoshop-tuts/browse-resize.zip

Keep reading for the coming series,  part 4 , Orkut Like Photo Cropping >>

Subscribe to this website feed now:

Regards

Sajith M.R

Online Photoshop in PHP (Series Part 2)

May 21st, 2008 by Sajith M.R
This entry is part 2 of 5 in the series Online Photoshop

Implementation of the Browse Photos Area >>

Today we will implement the browse photos area of online photoshop

Those who haven’t seen the online photo editing tool, click on the above icon (baloon)

You can see the browse area implementation here: http://www.sajithmr.com/photoshop-tuts/browse.php

What you need for this is 4 php functions: is_dir , opendir, readdir, filetype

Normal file browsing can be implemented using while loop with above four functions.

See its usage:

if (is_dir($dir)){if ($dh = opendir($dir)){

while ( ($file = readdir($dh)) !== false   )

{

if($file != '.' &&  $file != '..')

{

//if it is a directory show folder icon

if(  filetype($dir .$dir_sep. $file) == "dir"   )

{

//display a folder icon here with folder name using img tag

}

else

{

// display image here in img tag

}

}

}

}

}

The whole source code is here: http://www.sajithmr.com/photoshop-tuts/browse.zip

Online Photoshop in PHP (Series Part 1)

May 20th, 2008 by Sajith M.R
This entry is part 1 of 5 in the series Online Photoshop

Introduction >>

Online Photoshop in PHP (Series Part 1)

As i announced in my birthday post: celebrating-1st-year-of-sajithmr.com , i am starting my post series How to make Photoshop Express in PHP

Before we starting the step by step procedure, have a look at : http://www.sajithmr.com/photoshop/index.php

This is a basic version of online photo editing tool.

You can either upload a photo to this tool or you can browse some images already supplied.

The basic features are:

  1. Crop
  2. Resize
  3. Water marking (Both logo and text)
  4. Round corner
  5. Rotate
  6. Download and save

Try yourself

Upload some picture (or browse any picture), Press crop button (top left), you can see orkut photo upload like crop there. You can select the area, or drag anywhere in the image. Press crop button in the workdesk. (Press F11 or fullscreen view for better performance )

Try all other features provided.

The whole site is divided into four parts.

  1. Tools
  2. Work Desk
  3. Browse Photos
  4. Settings

Tools area contains options for crop, resize, watermark, round, undo , save, clear all, download.

Here ‘clear all’ reset all the operations and navigate the website into initial settings.

From the Settings Area, You can fix the angle of the image. You can rotate either clock-wise or anti-clock-wise depending on the angle provided (+ve or -ve)

In Text Water Mark Setting Area, you can enter a text, set font size and font color. It generates a pictures corresponding to your text. Click water mark button in tool area and fix the position , press Apply Watermark

You can also upload your water mark logo.

Finally you can download the edited picture by clicking download button in the Tool area (top right) .

The interesting thing is the whole website / tool is created in a single day.

wanna learn how to implement this ??

Keep reading rest of the series.

In Online Photoshop in PHP (Series Part 2) >> Implementation of the Browse Photos Area

Thanks and Regards
Sajith M.R

Gmail Chat Implementation

May 7th, 2008 by Sajith M.R
This entry is part 3 of 3 in the series Gmail Architecture

Today i implemented gmail chat window , not an ajax chat with a chat server, but its client side implementation.

Here you can see the demo: http://www.sajithmr.com/gtalk/

Take this link in a new tab or window, and take any other website without closing it.

After 3 seconds , (Consider it as a new chat message arrived situation) you can see the google chat notification sound , and title changing. (I didn’t get the actual gtalk notification sound, so i used windows notify.wav file )

You know google (gmail) implemented its sound notification is via swf object. Here me too done the same.

I wrote two function to check whether the browser is in focus or not.


Here is the functions:

function lostFocus()
{
document.title = 'Sajith M.R Says...';
state = 'nonfocus';

played =  0 ;

changeColorRed();

alterTitle();

}

function gotFocus()
{
document.title = 'Gmail Inbox(1)';

state = 'focus';

played = 0 ;
}

The alterTitle() function calls in 3 seconds setTimeOut manner.

function alterTitle()
{

if(state =='nonfocus')

{
if ( document.title == 'Gmail Inbox(1)')
{

if(played == 0)
{
soundManager.play('notify');
played = 1;
}

document.title = 'Sajith M.R Says...';

}
else
document.title = 'Gmail Inbox(1)';

setTimeout("alterTitle()",3000);

}
}

The soundmanager.js file handles the swf flash object and sound triggering.

<script type=”text/javascript” src=”script/soundmanager.js”></script>

These three simple scripts together created this demo: http://www.sajithmr.com/gtalk/

If you want the whole source code , mail me: admin@sajithmr.com

Comment Please …

Regards

Sajith.M.R
http://www.sajith.name

Celebrating 1st year of Sajithmr.com

April 30th, 2008 by Sajith M.R

Happy Birthday Sajithmr.com

Sajithmr.com is Celebrating one year of technology blogging, I would like to thank my readers , as I begin another year of knowledge sharing.

So what have I achieved so far?

  • 16,000 unique visits per month

  • Alexa Rank: 308452

  • Page Rank: 3 (got 4 , three months back)

  • Morethan 500 backlinks

    300 keywords seach per day (Google)

This is my 80th post

Thank you all for visiting and keep coming.

Sajithmr.com just passed over 16,000 unique visitors per month, it has been mentioned on lots of blogs, linked to from many cool sites.
It was started as a tutorial site , and later changed into technology blog / my technology backup after a month. Old course website is shifted to http://course.sajithmr.com

I got more than 45 php students from course.sajithmr.com

I am getting  lots of emails daily to admin@sajithmr.com , and thus i got hundreds of tech savvy friends all over the world. (Especially from USA, Canada, Philippines, Pakistan and from my own India)

In this last one year , i blogged about, PHP, Symfony, Propel, Gmail, Mozilla plugin, Wordpress Extensions, Linux and Web 2.0

A Birthday gift from sajithmr.com for you:

Coming soon..

A very intersing post series is coming in sajithmr.com:
How to make Photoshop Express  in PHP

The post series will explain  how to create an online photo editing tool in php .

So subscribe to my Rss Feed now