Monthly Archives: March 2010

Session lost when switching from HTTP to HTTPS in PHP

Sometime we face the problem when we navigate from HTTP URL to HTTPS URL our session lost.

You can manage session between HTTP to HTTPS or HTTPS to HTTP:

1. Transmit session ID between page using GET

2. POST session ID by POST

3. Use files to save sessions

4. Use Cookies for sessions

5. Use database to save session

Below example can be used to transmit using GET….

File : http.php



$sessionID = session_id();

$_SESSION[‘svnlabs’] = ‘Demo session between HTTP HTTPS’;

echo ‘<a href=”;.$sessionID.'”>Demo session from HTTP to HTTPS</a>’;


File: https.php


$sessionID = $_GET[‘session’];



if (!empty($_SESSION[‘svnlabs’])) {
echo $_SESSION[‘svnlabs’];
} else {
echo ‘Demo session failed’;

IE7 : This page contains both secure and nonsecure items

You have to use relative path for all static resource on page like css, js, images, flash etc. to avoid IE message secure and nonsecure items…

IE message

IE message

Well! stay with us….. 🙂


Tags: , , , ,




Leave a comment

Posted by on March 24, 2010 in javascript, php, Tips, Tricks, Web Services


Tags: , , , ,

Facebook Application

Seven Version on Facebook

Seven Version on Facebook

FaceBook Application
FaceBook Profile

1 Comment

Posted by on March 20, 2010 in php, Tips, Tricks


Tags: , , , ,




# ffmpeg is a command line tool to convert one video file format to another. It can also grab and encode in real time from a TV card.
# ffserver is an HTTP and RTSP multimedia streaming server for live broadcasts. It can also time shift live broadcast.
# ffplay is a simple media player based on SDL and on the FFmpeg libraries.
# ffprobe is a command line tool to show media information.

# Convert video files into another format.
# flv -> avi
# flv -> mp4
# flv -> wmv
# flv -> swf
# avi -> mp4
# avi -> wmv
# avi -> flv
# avi -> swf
# mp4 -> avi
# mp4 -> wmv
# mp4 -> flv
# mp4 -> swf
# wmv -> mp4
# wmv -> avi
# wmv -> flv
# wmv -> swf
# divx -> mp4
# divx -> avi
# divx -> flv
# divx -> wmv
# divx -> swf
# Audio extraction
# flv -> mp3
# avi -> mp3
# mp4 -> mp3
# wmv -> mp3
# divx -> mp3
# swf -> mp3

if ($target == ‘mp3’)
$ffmpeg_cmd = exec($ffmpeg.” -y -i “.$source.” -acodec “.$acodec.” -vn “.$target);
} else {
$ffmpeg_cmd = exec($ffmpeg.” -y -i “.$source.” -acodec “.$acodec.” “. $ar .” -ab 128kb “.$vcodec.” “.$r.” -b 1200kb -mbd 2 -cmp 2 -subcmp 2 “.$size.” “.$aspect.” “.$target);


Tags: , , , , , ,

PHP – File Upload Stream

File Upload Stream

File Upload Stream

PHP supports upload file stream… we can stream data to server using PHP stream_open() & stream_write() functions.

There is alternate method in PEAR to transfer files to server1 to server2. PEAR have HTTP package for uploading files.

HTTP_Request supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc.

require_once "HTTP/Request.php";
$req =& new HTTP_Request("");
$req->setBasicAuth("login", "pass");

$result = $req->addFile("data", "/home/svnlabs.mp4");
if (PEAR::isError($result)) {
echo "Error occurred during file upload!";
} else {
$response = $req->sendRequest();
if (PEAR::isError($response)) {echo "Error occurred during file upload!";
} else {
echo "File successfully uploaded!";
1 Comment

Posted by on March 17, 2010 in CakePHP, Fedora, Linux, PEAR, php, Tips, Tricks, Web Application


Tags: , , , , , ,

Linux Network Configuration

# system-config-network
# redhat-config-network
# vi /etc/resolve.conf
# vi /etc/hosts
# /sbin/ifconfig eth0 netmask broadcast

# /etc/init.d/network restart

ifup – bring a network interface up

ifdown – take a network interface down





Leave a comment

Posted by on March 15, 2010 in CentOS, Fedora, Linux, Tips, Tricks


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

7 Simple Steps to create Twitter Application

First you have to download oAuth from github

“An open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.”

7 Simple Steps to create Twitter Application using Twitter’s OAuth….

1. Build TwitterOAuth object

Login to twitter and register a new application here … after registering application save consumer key and consumer secret.

$to = new TwitterOAuth($consumer_key, $consumer_secret);

Twitter OAuth

2. Request tokens from twitter

$tok = $to->getRequestToken();

3. Build authorize URL

$request_link = $to->getAuthorizeURL($token);

4. Send user to Twitter’s authorize URL


5. Get access tokens from twitter

$tok = $to->getAccessToken();

6. Rebuild TwitterOAuth object

$to = new TwitterOAuth($consumer_key, $consumer_secret, $user_access_key, $user_access_secret);

7. Query Twitter API with new access tokens

$content = $to->OAuthRequest(‘;, array(), ‘GET’);

$content = $to->OAuthRequest(‘;, array(‘status’ => ‘Test OAuth update. #testoauth’), ‘POST’);Twitter - Redirecting you back to the application_1268502564768



Tags: , , ,

How to Create OpenSearch Plugins?

browser search plugin

browser search plugin

OpenSearch is a collection of simple formats for the sharing of search results.

OpenSearch description file

We have to create  a simple xml file for websites and search engines to publish search results in a standard and accessible format.

See below the code in action…….

<?xml version=”1.0″ encoding=”UTF-8″?>

<OpenSearchDescription xmlns=””&gt; <ShortName>svnlabs</ShortName>

<LongName>svnlabs – Concentrate > Observe > Imagine > Launch</LongName>

<Description>Search through articles posted on</Description>







<Description>svnlabs – Concentrate – Observe – Imagine – Launch svnlabs, Linux, Apache, Mysql, PHP, Video Encoding, Youtube API, Facebook API, Twitter API, Amazon Web Service, OSCommerce, Joomla, WordPress</Description>

<Tags>svnlabs Linux Apache Mysql PHP Video Encoding Youtube API Facebook API Twitter API Amazon Web Service OSCommerce Joomla WordPress</Tags>

<Attribution>Search Articles on svnlabs,</Attribution&gt; <SyndicationRight>open</SyndicationRight>

<Query role=”example” searchTerms=”India”/>

<Image height=”16″ width=”16″ type=”image/”></Image&gt;

<Image height=”130″ width=”130″ type=”image/jpeg”></Image&gt;

<Url type=”text/html” template=”{searchTerms}”/>


Paste below block of code to HTML Heading section to add browser search plugin….

<link rel=“search” type=“application/opensearchdescription+xml” href=”“svnlabs blog search” />


Leave a comment

Posted by on March 7, 2010 in Java, javascript, Linux, php, Tips, Tricks


Tags: , , , , ,

Magic of PEAR – Date TimeZone

PEAR is a framework and distribution system for reusable PHP components.

How we get PEAR packages with php files?

Add block of code to the php file….

// include PEAR class
include (“Date.php”);

// initialize Date object
$d = new Date(“1981-08-07 01:30:11”);

// retrieve date to display
echo $d->getDate();

// retrieve date as formatted string
echo $d->format(“%A, %d %B %Y %T”);


1981-08-07 01:30:11
Friday, 07 August 1981 01:30:11

Converting between time zones

// include class
include (“Date.php”);

// initialize object
$d = new Date(“1981-08-07 10:36:27”);

// set local time zone

// convert to foreign time zone

// retrieve converted date/time
echo $d->format(“%A, %d %B %Y %T”);

Thursday, 07 August 1981 16:06:27

Calculating GMT offsets

// include class
include (“Date.php”);

// initialize object
$d = new Date(“2006-08-08 10:26:27”);

// set local time zone

// get raw offset from GMT, in msec
echo $d->tz->getRawOffset();

Adding and subtracting timespans

// include class
include (“Date.php”);

// initialize object
$d = new Date(“1951-09-13 16:55:11”);

// add 01:20 to it
$d->addSpan(new Date_Span(“0,1,20,0”));

// subtract 00:05 from it
$d->subtractSpan(new Date_Span(“0,0,5,0”));

// retrieve date as formatted string
echo $d->format(“%A, %d %B %Y %T”);

PHP have rich library to manage “Daylight saving time”… we can use PEAR for DST

United States begins Daylight Saving Time at 2:00 a.m. on the second Sunday in March and reverts to standard time on the first Sunday in November.

Daylight Saving Time

Daylight Saving Time

Enjoy programming with PEAR…. 😉


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