October
31
Posted on 31-10-2008
Filed Under (Articles, PHP, WebDev) by Dayson Pais

When you feel you may want to use the requested url with all the get variables passed (just the way it is in the browser’s address bar), you can use the following code snippet:

private function getCurPageURL()
{
	$pageURL = 'http';
	if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
	$pageURL .= "://";
	if ($_SERVER["SERVER_PORT"] != "80") {
	$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} else {
	$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	}
	return $pageURL;
}
(0) Comments    Read More   
October
13
Posted on 13-10-2008
Filed Under (Articles, PHP, WebDev) by Dayson Pais

php currency conversion

With global economic meltdowns & fluctuating prices, we often can’t rely on human entry to get up to date currency rates in our web applications. Especially if you are building a website which may require your products cost to be displayed in various currencies.

This is a very powerful and light weight PHP class that lets you convert between 65+ currencies using Google Finance (http://www.google.com/finance/converter)

Example:

CurrencyRates::Convert('USD', 'INR');

Output:

49 //Since $1 is Rs. 49

Read the rest of this entry »

(7) Comments    Read More   
September
26
Posted on 26-09-2008
Filed Under (PHP, WebDev) by Dayson Pais

Sometimes you may want to display some part of the page/code only to IE users. Especially when you may be using some png fix javascript files or the famous iepngfix.htc for IE6 clients. This php function lets you identify an IE browser loading your page:

Example:

<?php
    if(detect_ie())
    { //if internet explorer 6 being used, then apply IE png fix
    ?>
        <!--Begin IE PNG Fix-->
        <style type="text/css">
        #shadow_tp, #shadow_btm {
            behavior: url(iepngfix.htc)
        }
        </style>
        <!--End IE PNG Fix-->        
    <?php
    }
?>

Read the rest of this entry »

(3) Comments    Read More   
October
28
Posted on 28-10-2007
Filed Under (WebDev) by Dayson Pais

Intro: It was quite disappointing to realize that an amazing CMS like Drupal failed to have a rich download system. I was expecting a rich downloads section with categories, download counts, rating, etc. The script that answered it all was “pafiledb“. This article explains how to integrate pafiledb into Drupal as if it were a drupal module in a very easy manner. This is a must read for anyone using Drupal.

View a demo of pafiledb.

Installing pafiledb:

  • Unzip the file you downloaded from the paFileDB homepage.
  • Open the “upload” folder, then open “includes” and then open the file “config.php”. You will need to edit that file to reflect your MySQL server information. You will need to edit the server, username, password and the database name.
  • Make a folder in your drupal root directory called “downloads“.
  • Open up the “upload” folder from the file you just unzipped. Copy everything, except for the “upgrade” folder from this folder into the “downloads” folder you just created.
  • Navigate to the “downloads/install/index.php” folder using your web browser and setup pafiledb with any settings you want.
  • Once you’ve done so, you will be prompted to delete the install folder and then you can easily view your pafiledb by browsing to your /downloads/index.php folder.

Read the rest of this entry »

(9) Comments    Read More