calendar-icon

Here is a php function which returns from and to date as an array for a range:

<?php

function get_rangeof_dates($time_frame = ‘all_time’)

{

$from_date = ;

$to_date = ;

switch($time_frame)

{

case ‘all_time’:        $from_date = ’1170-01-01 00:00:00′;

$to_date = ’2250-12-31 23:59:59′;

break;

case ‘today’:

$from_date = date(‘Y-m-d 00:00:00′);

$to_date = date(‘Y-m-d 23:59:59′);

break;

case ‘yesterday’:

$from_date = date(‘Y-m-d 00:00:00′, time()- 24* 60 * 60 );

$to_date = date(‘Y-m-d 23:59:59′, time()- 24* 60 * 60 );

break;

case ‘this_week’:

$from_date = date(‘Y-m-d 00:00:00′, time() – (date(‘w’, time()) * 60 * 60 * 24));

$to_date = date(‘Y-m-d 23:59:59′, time() + ((6 – date(‘w’, time())) * 60* 60 * 24 ));

break;

case ‘last_week’:

$from_date = date(‘Y-m-d 00:00:00′, time() – (date(‘w’, time()) * 60 * 60 * 24) – 7 * 24 * 60 * 60);

$to_date = date(‘Y-m-d 23:59:59′, time() + (( 6 – date(‘w’, time()) ) * 60* 60 * 24 ) – 7 * 24* 60* 60);

break;

case ‘last_7_days’:     $additonal_query = “created_at > ‘”.date(‘Y-m-d’, time()- 7 * 24* 60 * 60 ).“‘”;

$from_date = date(‘Y-m-d 00:00:00′, time()- 7 * 24* 60 * 60 );

$to_date = date(‘Y-m-d 23:59:59′);

break;

case ‘this_month’:

$from_date = date(‘Y-m-d 00:00:00′, mktime( 0, 0, 0, date(“m”)  , 1 , date(“Y”) ) );

$to_date = date(‘Y-m-d 23:59:59′);

break;

case ‘last_month’:

$from_date = date(“Y-m-01 00:00:00″, strtotime(“-1 month”, strtotime(date(“Y-m-d”))));

$to_date = date(“Y-m-d 23:59:59″, strtotime(“-1 day”, strtotime(date(“Y-m-01″))));

break;

case ‘last_30_days’:

$from_date = date(‘Y-m-d 00:00:00′, time()- 30 * 24* 60 * 60 );

$to_date = date(‘Y-m-d 23:59:59′);

break;

case ‘this_quarter’:

$month = date(‘m’);

$year = date(‘Y’);

if($month == 1 || $month == 2 || $month == 3 )

{

$from_date = $year.‘-01-01′;

$to_date = $year.‘-03-31′;

}

elseif($month == 4 || $month == 5|| $month == 6 )

{

$from_date = $year.‘-04-01′;

$to_date = $year.‘-06-30′;

}

elseif($month == 7 || $month == 8|| $month == 9 )

{

$from_date = $year.‘-07-01′;

$to_date = $year.‘-09-30′;

}

else

{

$from_date = $year.‘-10-01′;

$to_date = $year.‘-12-31′;

}

break;

case ‘last_quarter’:

$month = date(‘m’);

$year = date(‘Y’);

if($month == 1 || $month == 2 || $month == 3 )

{

$from_date = ($year -1).‘-10-01′;

$to_date = ($year-1).‘-12-31′;

}

elseif($month == 4 || $month == 5|| $month == 6 )

{

$from_date = $year.‘-01-01′;

$to_date = $year.‘-03-31′;

}

elseif($month == 7 || $month == 8|| $month == 9 )

{

$from_date = $year.‘-04-01′;

$to_date = $year.‘-06-30′;

}

else

{

$from_date = $year.‘-07-01′;

$to_date = $year.‘-09-30′;

}

break;

case ‘this_year’:

$from_date = date(‘Y-01-01 00:00:00′);

$to_date = date(‘Y-12-31 23:59:59′);

break;

case ‘last_year’:

$from_date = date(‘Y-01-01 00:00:00′, mktime( 0, 0, 0, 01 , 01 , date(“Y”) – 1 ));

$to_date = date(‘Y-12-31 23:59:59′, mktime( 0, 0, 0, 12 , 31 , date(“Y”) – 1 ) );

break;

}

return array($from_date, $to_date);

}

?>


Tags: , , , , , , , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Contact Grabber

06 Nov 2008

If you are a social media website developer , sometimes you might search for grabbing contacts from a particular email account if the password is given. I also did the same.  In most of the cases it did not work properly. But recently i got a contact grabber from phpclasses.org which works perfectly on Gmail, Hotmail, Rediff, Yahoo, Orkut, MySpace, Indiatimes, Linkedin , AOL and lycos

screen shot

screen shot

But the zip file i got is not well arranged, so it shows some errors . I arranged it in proper way and uploaded here:

Download:

http://sajithmr.com/downloads/grabber.zip

(Under GNU Public License)

Using this php code , you can export the email contacts as csv file.

Here is the actual source website : http://www.phpclasses.org/browse/package/3895.html

Tags: , , , , , , , , , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

When ever we click on a downloadable file , our browser pop up a download window popup and ask us where to save. That download option does not have any other options like , limit the speed, scheduled download, download by split parts etc like what download accelerator like flashget does. In some cases we drag the link  (or click on download by flashget from context menu) to flashget for download using accelerator . But this is not possible in all the cases. Most of the downloads are not via direct link to the file, instead it points a dynamic web page (php or something), and it pops up the download option. Or sometimes there will be captcha to fill for download. In this case dragging to a accelerator is not possible.

The plugin which helped to do this is Mozilla’s FlashGot .What this plugin does is , it adds one more option for bypass the download from mozilla browser to some other accelerator say flashget.

FlashGot mozilla plugin

Might be some of you waiting  for such a solution for a long time , rite ?

Regards

Sajith

Tags: , , , , , , ,

· · · ◊ ◊ ◊ · · ·

After a long searching, i got this IDE , Aptana which satisfies all my requirement. It is just like .net IDE with auto compiling and error displaying system, and come with built in server. You can download it from: http://aptana.com/studio/download

Error display while coding time is its another feature.

Auto filling is another feature.

For oops concepts, it will show the details of method and its parameter while you start  a pointer (a dot . or -> )

See example of javascript “document.getEle”  function.

A lot of javascirpt buit-in libraries are included.

Features like, console, break point, watch etc are there . There is a special  Apatana Ajax Monitor to debug ajax calls.

Download it , and use it. I liked this one than dreamweaver or quanta or PHP Editor

More over the software Aptana is Free !!!

Tags: , , , , , ,

· · · ◊ ◊ ◊ · · ·

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

Tags: , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

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.me/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

Tags: , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431