Install libpurple with PHP


Hits: 3017  

libpurple is intended to be the core of an IM program.

This libpurple PHP binding, which defines a set of internal classes, gives a possibility to use aol and icq (oscar), yahoo, msn, jabber, irc and much more protocols directly from PHP. Write your own IM chat client in PHP, as simply as PHP enables it.

Download latest version of “phurple” from here

http://sourceforge.net/projects/phurple/
# yum install pidgin
# yum install libpurple-devel
# wget http://nchc.dl.sourceforge.net/project/phurple/phurple/phpurple-0.4.0-alpha/phurple-0.4.0-alpha.tar.bz2
# bunzip2 phurple-0.4.0-alpha.tar.bz2; tar xvf phurple-0.4.0-alpha.tar
# cd phurple-0.4.0-alpha
# phpize && ./configure –enable-phurple && make
# make install

Now we find phurple.so in /usr/lib/php/modules…
Make a phurple.ini in /etc/php.d add extention phurple.so in it 😉

phurple
phurple

Phurple Reference: http://phurple.php.belsky.info/

Session lost when switching from HTTP to HTTPS in PHP


Hits: 4005  

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
……………

<?php

session_start();

$sessionID = session_id();

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

echo ‘<a href=”https://www.svnlabs.com/https.php?session=’.$sessionID.'”>Demo session from HTTP to HTTPS</a>’;

?>

File: https.php
……………

<?php

$sessionID = $_GET[‘session’];

session_id($sessionID);

session_start();

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

Well! stay with us….. 🙂

Magic of PEAR – Date TimeZone


Hits: 4363  

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….

<?php
// 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”);

?>

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

Converting between time zones

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

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

// set local time zone
$d->setTZByID(“GMT”);

// convert to foreign time zone
$d->convertTZByID(“IST”);

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

Output:
Thursday, 07 August 1981 16:06:27

Calculating GMT offsets

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

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

// set local time zone
$d->setTZByID(“PST”);

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

Adding and subtracting timespans

<?php
// 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…. 😉

Oscommerce – Features


Hits: 1539  

Features of Oscommerce
Features of Oscommerce

* Multi language

* Content Management

~ WYSIWYG editor integrated into the shop admin to allow easy entering    of    HTML and uploading of images
~ Add text to your category pages – great for SEO and providing information
~ Content Management System – no more FTP and working with PHP files – amend text for information pages (homepage, delivery, about us etc) from the shop admin
~ Enable / Disable categories (and all contained products) at the click of one button
~ Take control of your product display and choose the sort order for each product
~ Select which products appear on your homepage with “showcase”
~ NEW! Reports for orders, sales, tax, products in HTML and CSV (Excel) format
~ NEW! Attribute Manager with Ajax & bulk management

* Marketing tools
~ Affiliate Scheme integrated into your shop, allowing you to offer commission on successful referrals
~ Discount Coupons & Gift Vouchers integrated into shop
~ Downloadable PDF Catalogue: create a PDF catalogue from your shop’s database
~ Professional Mail List Manager with HTML templates, subscribe/unsubscribe links and option to set up multiple mailing list. Customers can subscribe to the mail list with their name & email address (without the need to set up an account). Double opt in option (verify email).
~ NEW! Multiple product images (up to 4) with lightbox effect
~ NEW! Cross Sell module with Ajax & category bulk application

* Search-engine friendly
~ Ultimate SEO URLs: built in search-engine friendly URLs for best spider results
~ Dynamic Metatags: automatically create metatags from the product description
~ Site Map / All Products: two additional pages featuring your shop’s products

* Online payment facilities
~ Multi-currency support
~ VAT support
~ Pay Pal IPN, Nochex, Pay by cheque, Pay by bank transfer are included
~ Other payment modules are available on request (see add-on section)

* Delivery options
~ Charge shipping as flat rate, per item, per weight or per order total
~ Or base your Delivery charges on weight or price and the delivery country, inc. an “email for quote” message for defined countries
~ UK Royal Mail shipping module for 1st & 2nd Class Standard / Recorded, Special Delivery, Standard Parcels, Surface Mail, Parcel Force 48

😉

Create TCPDF PHP Fonts


Hits: 3964  

TCPDF supports TrueTypeUnicode (UTF-8 Unicode), OpenTypeUnicode, TrueType, OpenType, Type1, CID-0 and Core (standard) fonts.

You will find font creation utility at fonts/utils of TCPDF… copy desired font to fonts/utils/svnlabs.ttf

* For TrueTypeUnicode

# cd /var/www/html/tcpdf/fonts/utils

# ttf2ufm -a -F svnlabs.ttf

# php -q makefont.php svnlabs.ttf svnlabs.ufm

* For embedded fonts to tcpdf PDF file.. copy the resulting svnlabs.php, svnlabs.z and svnlabs.ctg.z to fonts folder

Uses:

<?php

……..

$pdf->SetFont(‘svnlabs’,’I’,8);

……….

?>

Trim and remove empty key & value in php array


Hits: 1378  

Here is the PHP function that will remove empty key => value in PHP array…

function array_trim($sv)
{
$s = 0;
$svn = null;
$c = count($sv);
for($i = 0; $i < $c; $i++)
{
if($sv[$i] != “”){
$svn[$s++] = trim($sv[$i]);
}
}
return $svn;
}

$svarray = array(‘   ‘, ‘svlinux’, ‘svnlabs’, ‘lamp’, ”);
$svarray = array_trim($svarray);
echo ‘<pre>’;
print_r($svarray);
echo ‘</pre>’;

Output:

Array(
[0] => svlinux
[1] => svnlabs
[2] => lamp
)

Oscommerce – made easy


Hits: 1389  

osCommerce is an online e-commerce solution that offers a wide range of features that allows online stores to be setup quickly with ease, and is available for free as an Open Source based solution released under the GNU General Public License.

http://svn.oscommerce.com/confluence/display/OSCDOC/Installation+and+Upgrades

http://www.oscommerce.info/contents