Tuesday, September 11, 2012

session start headers already sent error

please add the top of the page below these code
-----------------------------------------------
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

ob_start();
session_cache_expire(30);
session_start();

Sunday, September 9, 2012

Create a simple Web Service Using PHP, MySQL,JSON, and , XML

Web services are taking over the world. I credit Twitter's epic rise to the availability of a simple but
rich API. Why not use the same model for your own sites? Here's how to create a basic web
 service that provides an XML or JSON response using some PHP and MySQL.

The PHP / MySQL

copy/* require the user as the parameter */
if(isset($_GET['user']) && intval($_GET['user'])) {

  /* soak in the passed variable or set our own */
  $number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; 
//10 is the default
  $format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; 
 //xml is the default
  $user_id = intval($_GET['user']); //no default

  /* connect to the db */
  $link = mysql_connect('localhost','username','password') or die('Cannot 
   connect to the DB');
  mysql_select_db('db_name',$link) or die('Cannot select the DB');

  /* grab the posts from the db */
  $query = "SELECT post_title, guid FROM wp_posts WHERE post_author = 
  $user_id AND post_status = 'publish' ORDER BY ID DESC LIMIT $number_of_posts";
  $result = mysql_query($query,$link) or die('Errant query:  '.$query);

  /* create one master array of the records */
  $posts = array();
  if(mysql_num_rows($result)) {
    while($post = mysql_fetch_assoc($result)) {
      $posts[] = array('post'=>$post);
    }
  }

  /* output in necessary format */
  if($format == 'json') {
    header('Content-type: application/json');
    echo json_encode(array('posts'=>$posts));
  }
  else {
    header('Content-type: text/xml');
    echo '<posts>';
    foreach($posts as $index => $post) {
      if(is_array($post)) {
        foreach($post as $key => $value) {
          echo '<',$key,'>';
          if(is_array($value)) {
            foreach($value as $tag => $val) {
              echo '<',$tag,'>',htmlentities($val),'</',$tag,'>';
            }
          }
          echo '</',$key,'>';
        }
      }
    }
    echo '</posts>';
  }

  /* disconnect from the db */
  @mysql_close($link);
}
With the number of persons hitting your web service (hopefully), you'll need to do adequate validation before attempting to connect to the database to avoid injection attacks. Once we get the desired results from the database, we cycle through the results to populate our return results array. Depending upon the response type desired, we output the proper header and content in the desired format.
Take the following sample URL for example:
copyhttp://mydomain.com/web-service.php?user=2&num=10
Now, we can take a look at the possible results of the URL.

The XML Output

copy<posts>
  <post>
    <post_title>SSLmatic SSL Certificate Giveaway Winners</post_title>
    <guid>http://davidwalsh.name/?p=2304</guid>
  </post>
  <post>
    <post_title>MooTools FileManager</post_title>
    <guid>http://davidwalsh.name/?p=2288</guid>
  </post>
  <post>
    <post_title>PHPTVDB: Using PHP to Retrieve TV Show Information</post_title>
    <guid>http://davidwalsh.name/?p=2266</guid>
  </post>
  <post>
    <post_title>David Walsh: The Lost MooTools Plugins</post_title>
    <guid>http://davidwalsh.name/?p=2258</guid>
  </post>
  <post>
    <post_title>Create Short URLs Using U.Nu</post_title>
    <guid>http://davidwalsh.name/?p=2218</guid>
  </post>
  <post>
    <post_title>Create Bit.ly Short URLs Using PHP</post_title>
    <guid>http://davidwalsh.name/?p=2194</guid>
  </post>
  <post>
    <post_title>Represent Your Repositories Using the GitHub Badge!</post_title>
    <guid>http://davidwalsh.name/?p=2178</guid>
  </post>
  <post>
    <post_title>ZebraTable</post_title>
    <guid>http://davidwalsh.name/?page_id=2172</guid>
  </post>
  <post>
    <post_title>MooTools Zebra Table Plugin</post_title>
    <guid>http://davidwalsh.name/?p=2168</guid>
  </post>
  <post>
    <post_title>SSLmatic: Quality, Cheap SSL Certificates and Giveaway!</post_title>
    <guid>http://davidwalsh.name/?p=2158</guid>
  </post>
</posts>
Take this next sample URL for example:
copyhttp://mydomain.com/web-service.php?user=2&num=10&format=json
Now, we can take a look at the possible results of the URL.

The JSON Output

copy{"posts":[{"post":{"post_title":"SSLmatic SSL Certificate Giveaway Winners",
 "guid":"http:\/\/davidwalsh.name\/?p=2304"}},
 {"post":{"post_title":"MooTools FileManager",
 "guid":"http:\/\/davidwalsh.name\/?p=2288"}},
 {"post":{"post_title":"PHPTVDB: Using PHP to Retrieve TV Show Information", 
"guid":"http:\/\/davidwalsh.name\/?p=2266"}}, 
{"post":{"post_title":"David Walsh: The Lost MooTools Plugins", 
"guid":"http:\/\/davidwalsh.name\/?p=2258"}},
 {"post":{"post_title":"Create Short URLs Using U.Nu",
 "guid":"http:\/\/davidwalsh.name\/?p=2218"}}, 
{"post":{"post_title":"Create Bit.ly Short URLs Using PHP","guid":
 "http:\/\/davidwalsh.name\/?p=2194"}},{"post":{"post_title":
 "Represent Your Repositories Using the GitHub Badge!","guid":
 "http:\/\/davidwalsh.name\/?p=2178"}},{"post": 
{"post_title":"ZebraTable","guid":"http:\/\/davidwalsh.name\/?page_id=2172"}}, 
{"post":{"post_title":"MooTools Zebra Table Plugin","guid": 
"http:\/\/davidwalsh.name\/?p=2168"}},
 {"post":{"post_title":"SSLmatic: Quality, 
Cheap SSL Certificates and Giveaway!", 
"guid":"http:\/\/davidwalsh.name\/?p=2158"}}]}

what is soap service in php example with php




The Soap Web services platform is XML and HTTP request. XML provides a language which can be used between different platforms and programming languages. The HTTP protocol is the most used Internet protocol. Web services platform elements are SOAP (Simple Object Access Protocol), UDDI (Universal Description, Discovery and Integration), WSDL (Web Services Description Language).
Here I have talking about SOAP, NuSOAP and how it will use in PHP with example. So now let's start. Simple Object Access Protocol (SOAP) is a simple XML-based protocol to let applications exchange information over HTTP.  Today's Web Service (SOAP) is most popular and it provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.
Actually, the SOAP API itself has not been deprecated-- just some of the functions. NuSOAP is a PHP library that allows you to send and receive SOAP messages. NuSOAP is a group of PHP classes that allow developers to create and consume SOAP services. It does not require any special PHP extensions. To use NuSOAP You must download NuSOAP library. Click Here to download library first.
Once you have downloaded a library file, you simply need to place it in your code tree so that you can include it from your PHP code. For my examples, I placed it in the same directory as the sample code itself.
I will start with the ubiquitous "Hello, World" example. This will demonstrate the basic coding of NuSOAP clients and servers.
I am going to start with the server code. The server exposes a single SOAP method named "Hello", which takes a single string parameter for input and returns a string. Hopefully, the comments within the code provide sufficient explanation. For example server.php is a file name.
<?php

 // include NuSOAP class for service call
 require_once('nusoap.php');
 // Create the server instance
 $server = new soap_server;

 // Register the method to expose
 $server->register('hello');

  // Define the method as a PHP function
  function hello($name) 
  {
   return 'Hello, ' . $name; 
  }

  // Use the request to (try to) invoke the service
  $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? 
               $HTTP_RAW_POST_DATA : '';

  $server->service($HTTP_RAW_POST_DATA);

?>
Now create a client side Script which will save it to the file clients.php. There are a few important things to note. First, when the instance of soap client is created, the parameter specified is the URL to the service. Second, when calling the service, the first parameter is the service name. This must match with the method registered within server.php. Finally, the second parameter in the call is an array of parameters that will be passed to the SOAP service method. Since the hello method of server.php requires a single parameter, this array has one element.
<?php
 
 // Pull in the NuSOAP code
 require_once('nusoap.php');
 // Create the client instance
 $client = new nusoap_client('http://localhost/xml-webservice/server.php');
 // Check for an error
 $err = $client->getError();

 if ($err) 
 {
     // Display the error
     echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
     // At this point, you know the call that follows will fail
 }

 // Call the SOAP method
 $result = $client->call('hello', array('name' => 'Scott'));

 // Check for a fault 
 if ($client->fault) 
 {
      echo '<h2>Fault</h2><pre>';
      print_r($result);
      echo '</pre>';
 }
  else
  {
    
  // Check for errors
      $err = $client->getError();
      if ($err) 
  {
          // Display the error
          echo '<h2>Error</h2><pre>' . $err . '</pre>';
      }
   else 
   {
          // Display the result
          echo '<h2>Result</h2><pre>';
          print_r($result);
       echo '</pre>';
      }
 }
?>
NuSOAP also provides a debug information. Adding the following to the client code will display this  debugging information.
/// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
I showed above code how  to display the SOAP request and response. Here is what the request from the client..php looks like.
Result

Hello, Scott

Request

POST /xml-webservice/server.php HTTP/1.0 
 Host: localhost  
User-Agent: NuSOAP/0.7.3 (1.114)  
Content-Type: text/xml; charset=ISO-8859-1  
SOAPAction: ""  
Content-Length: 500    
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1564:hello xmlns:ns1564="http://tempuri.org">
<name xsi:type="xsd:string">Scott</name>
</ns1564:hello></SOAP-ENV:Body></SOAP-ENV:Envelope>

Response

HTTP/1.1 200 OK  
Date: Tue, 29 Sep 2009 08:47:02 GMT  
Server: Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.0
X-Powered-By: PHP/5.2.0  
X-SOAP-Server: NuSOAP/0.7.3 (1.114)  
Content-Length: 518  
Connection: close  
Content-Type: text/xml; charset=ISO-8859-1    
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:helloResponse xmlns:ns1="http://tempuri.org">
<return xsi:type="xsd:string">Hello, Scott</return>
</ns1:helloResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
You can CLICK HERE full source code 

Saturday, September 8, 2012

simple create capcha code using php

<?php
session_start();

/*
* File: CaptchaSecurityImages.php
* Author: bikash ranjan nayak
* Copyright: 2012 bikash

* Updated: 07/09/12
* Requirements: PHP 4/5 with GD and

class CaptchaSecurityImagesbybikash {

    var $font = &#039;monofont.ttf&#039;;

    function generateCode($characters) {
        /* list all possible characters, similar looking characters and vowels have been removed */
        $possible = &#039;23456789bcdfghjkmnpqrstvwxyz&#039;;
        $code = &#039;&#039;;
        $i = 0;
        while ($i generateCode($characters);
        /* font size will be 75% of the image height */
        $font_size = $height * 0.75;
        $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
        /* set the colours */
        $background_color = imagecolorallocate($image, 255, 255, 255);
        $text_color = imagecolorallocate($image, 20, 40, 100);
        $noise_color = imagecolorallocate($image, 100, 120, 180);
        /* generate random dots in background */
        for( $i=0; $i&lt;($width*$height)/3; $i++ ) {
            imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
        }
        /* generate random lines in background */
        for( $i=0; $ifont, $code) or die('Error in imagettfbbox function');
        $x = ($width - $textbox[4])/2;
        $y = ($height - $textbox[5])/2;
        imagettftext($image, $font_size, 0, $x, $y, $text_color, $this-&gt;font , $code) or die('Error in imagettftext function');
        /* output captcha image to browser */
        header('Content-Type: image/jpeg');
        imagejpeg($image);
        imagedestroy($image);
        $_SESSION['security_code'] = $code;
    }

}

$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) &amp;&amp; $_GET['characters'] &gt; 1 ? $_GET['characters'] : '6';

$captcha = new CaptchaSecurityImagesbybikash($width,$height,$characters);

?>

<img src="/wp-content/themes/avd/CaptchaSecurityImages.php?width=162&amp;height=45&amp;characters=5" />

Friday, September 7, 2012

how to send email with attachment file php

<?php
$fileatt = "ptkt.docx"; // Path to the file
$fileatt_type = "application/docx"; // File Type
$fileatt_name = "ptkt.docx"; // Filename that will be used for the file as the attachment

$email_from = "bikash@nayak.com"; // Who the email is from
$email_subject = "Your attached file"; // The Subject of the email
$email_message = "Thanks for bikash my blog http://phptechnicalgroups.blogspot.in.
";
$email_message .= "Thanks for bikash.
"; // Message that the email has in it

$email_to = 'bikash@techwave.com'; // Who the email is to

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message .= "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data .= "\n\n" .
"--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
echo "you mail has sent with attchment";

} else {
die("smtp not connecting");
}
?>

paypal pro recurring payment method implement in php



1 step-> create a paypalconfig.php
----------------------------------------------------------------------------
<?php
class paypal_pro
{
    public $API_USERNAME;
    public $API_PASSWORD;
    public $API_SIGNATURE;
    public $API_ENDPOINT;
    public $USE_PROXY;
    public $PROXY_HOST;
    public $PROXY_PORT;
    public $PAYPAL_URL;
    public $VERSION;
    public $NVP_HEADER;
    public $CURLEMPTYCHECK=FALSE;
   
    function __construct($API_USERNAME, $API_PASSWORD, $API_SIGNATURE, $PROXY_HOST, $PROXY_PORT, $IS_ONLINE = FALSE, $USE_PROXY = FALSE, $VERSION = '57.0')
    {
   
        $this->API_USERNAME = $API_USERNAME;
        $this->API_PASSWORD = $API_PASSWORD;
        $this->API_SIGNATURE = $API_SIGNATURE;
        $this->API_ENDPOINT = 'https://api-3t.paypal.com/nvp';
        $this->USE_PROXY = $USE_PROXY;
        if($this->USE_PROXY == true)
        {
            $this->PROXY_HOST = $PROXY_HOST;
            $this->PROXY_PORT = $PROXY_PORT;
        }
        else
        {
            $this->PROXY_HOST = '127.0.0.1';
            $this->PROXY_PORT = '808';
        }
        if($IS_ONLINE == FALSE)
        {
            $this->PAYPAL_URL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
        }
        else
        {
            $this->PAYPAL_URL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
        }
        $this->VERSION = $VERSION;
    }

    function hash_call($methodName,$nvpStr)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$this->API_ENDPOINT);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POST, 1);
        if($this->USE_PROXY)
        {
            curl_setopt ($ch, CURLOPT_PROXY, $this->PROXY_HOST.":".$this->PROXY_PORT);
        }
        $nvpreq="METHOD=".urlencode($methodName)."&VERSION=".urlencode($this->VERSION)."&PWD=".urlencode($this->API_PASSWORD)."&USER=".urlencode($this->API_USERNAME)."&SIGNATURE=".urlencode($this->API_SIGNATURE).$nvpStr;
        curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);
        $response = curl_exec($ch);
        $nvpResArray=$this->deformatNVP($response);
        $nvpReqArray=$this->deformatNVP($nvpreq);
        $_SESSION['nvpReqArray']=$nvpReqArray;
        if (curl_errno($ch))
        {
            $this->CURLEMPTYCHECK=TRUE;
   
        }
        else
        {
            curl_close($ch);
        }

    return $nvpResArray;
    }

    function deformatNVP($nvpstr)
    {

        $intial=0;
        $nvpArray = array();
        while(strlen($nvpstr))
        {
            $keypos= strpos($nvpstr,'=');
            $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);
            $keyval=substr($nvpstr,$intial,$keypos);
            $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
            $nvpArray[urldecode($keyval)] =urldecode( $valval);
            $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
         }
        return $nvpArray;
    }

    function __destruct()
    {

    }
}
?>
----------------------end cofig class--------------------------------------

2 step-> indclude paypalconfig.php where you input user information.
if(isset($_REQUEST['paynow'])){
require_once("paypal_pro.inc.php");
$firstName =urlencode( $_POST['firstName']);
$lastName =urlencode( $_POST['lastName']);
$creditCardType =urlencode( $_POST['creditCardType']);
$creditCardNumber = urlencode($_POST['creditCardNumber']);
$expDateMonth =urlencode( $_POST['expDateMonth']);
$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
$expDateYear =urlencode( $_POST['expDateYear']);
$cvv2Number = urlencode($_POST['cvv2Number']);
$address1 = urlencode($_POST['address1']);
$address2 = urlencode($_POST['address2']);
$city = urlencode($_POST['city']);
$state =urlencode( $_POST['state']);
$zip = urlencode($_POST['zip']);
$amount = urlencode($_POST['amount']);
$currencyCode="USD";
$paymentAction = urlencode("Sale");
 $carderrormsg="";


    $profileStartDate = urlencode(date('Y-m-d h:i:s'));
    $billingPeriod = urlencode($_POST['billingPeriod']);// or "Day", "Week", "SemiMonth", "Year"
    $billingFreq = urlencode($_POST['billingFreq']);// combination of this and billingPeriod must be at most a year
    $initAmt = $amount;
    $failedInitAmtAction = urlencode("ContinueOnFailure");
    $desc = urlencode("Recurring $".$amount);
    $autoBillAmt = urlencode("AddToNextBilling");
    $profileReference = urlencode("Anonymous");
    $methodToCall = 'CreateRecurringPaymentsProfile';
    $nvpRecurring ='&BILLINGPERIOD='.$billingPeriod.'&BILLINGFREQUENCY='.$billingFreq.'&PROFILESTARTDATE='.$profileStartDate.'&INITAMT='.$initAmt.'&FAILEDINITAMTACTION='.$failedInitAmtAction.'&DESC='.$desc.'&AUTOBILLAMT='.$autoBillAmt.'&PROFILEREFERENCE='.$profileReference;


$nvpstr='&PAYMENTACTION='.$paymentAction.'&AMT='.$amount.'&CREDITCARDTYPE='.$creditCardType.'&ACCT='.$creditCardNumber.'&EXPDATE='.         $padDateMonth.$expDateYear.'&CVV2='.$cvv2Number.'&FIRSTNAME='.$firstName.'&LASTNAME='.$lastName.'&STREET='.$address1.'&CITY='.$city.'&STATE='.$state.'&ZIP='.$zip.'&COUNTRYCODE=US&CURRENCYCODE='.$currencyCode.$nvpRecurring;


//$paypalPro = new paypal_pro('nayakr.bikash@gmail.com', 'QFZCW5555N5HZM8VBG7Q', 'A.d9eRKfd1yVkRrtmMfCFLTqa655555M9AyodL0SJkh55555YztxUi8W9pCXF6.4NI', '', '', FALSE, FALSE );

$resArray = $paypalPro->hash_call($methodToCall,$nvpstr);
echo "<pre>";print_r($resArray ) ;

Wednesday, September 5, 2012

ups, fedex and USPS shipping integration with joomla easily

download here source code
step-1-> create a fedex10.php under /administrator/components/com_virtuemart/classes/shipping
---------------------------------------------------------------------------------------------
<?php
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/* You must fill in the "Service Logins
/* values below for the example to work   
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

/*********** Shipping Services ************/
/* Here's an array of all the standard
/* shipping rates. You'll probably want to
/* comment out the ones you don't want
/******************************************/
// UPS
//$services['ups']['14'] = 'Next Day Air Early AM';
//$services['ups']['01'] = 'Next Day Air';
$services['ups']['65'] = 'Saver';
//$services['ups']['59'] = '2nd Day Air Early AM';
$services['ups']['02'] = '2nd Day Air';
$services['ups']['12'] = '3 Day Select';
$services['ups']['03'] = 'Ground';
/*$services['ups']['11'] = 'Standard';
$services['ups']['07'] = 'Worldwide Express';
$services['ups']['54'] = 'Worldwide Express Plus';
$services['ups']['08'] = 'Worldwide Expedited';*/


// FedEx
$services['fedex']['FEDEXGROUND'] = 'Ground';
$services['fedex']['PRIORITYOVERNIGHT'] = 'Priority Overnight';
$services['fedex']['STANDARDOVERNIGHT'] = 'Standard Overnight';
//$services['fedex']['FIRSTOVERNIGHT'] = 'First Overnight';
//$services['fedex']['FEDEX2DAY'] = '2 Day';
$services['fedex']['FEDEXEXPRESSSAVER'] = 'Express Saver';

/*$services['fedex']['FEDEX1DAYFREIGHT'] = 'Overnight Day Freight';
$services['fedex']['FEDEX2DAYFREIGHT'] = '2 Day Freight';
$services['fedex']['FEDEX3DAYFREIGHT'] = '3 Day Freight';
$services['fedex']['GROUNDHOMEDELIVERY'] = 'Home Delivery';
$services['fedex']['INTERNATIONALECONOMY'] = 'International Economy';
$services['fedex']['INTERNATIONALFIRST'] = 'International First';
$services['fedex']['INTERNATIONALPRIORITY'] = 'International Priority';*/

 $dbu = new ps_DB; // user data
        $dbv = new ps_DB; // vendor data
        $dbc = new ps_DB; // country data

        // get user info
        $q  = "SELECT * FROM #__{vm}_user_info, #__{vm}_country WHERE user_info_id='" . @$_REQUEST["ship_to_info_id"]."' AND ( country=country_2_code OR country=country_3_code)";
        $dbu->query($q);
        if ($dbu->num_rows()==0) {
            $vmLogger->debug("Fedex::__construct() no user information returned from database where \$_REQUEST[\"ship_to_info_id\"]==".@$vars["ship_to_info_id"]);

            // missing ship_to_info_id. probably a shop set up with no "choose a shipping address" step
            // let's choose the first ST address we can find
            $q="SELECT * FROM #__{vm}_user_info, #__{vm}_country WHERE user_id='". $_SESSION['auth']['user_id'] ."' AND address_type='ST' AND ( country=country_2_code OR country=country_3_code)";
            $dbu->query($q);
            if ($dbu->num_rows()==0) {
                // or default to BT address.
                $vmLogger->debug("Fedex::__construct() - Using first BT address found.");
                $q="SELECT * FROM #__{vm}_user_info, #__{vm}_country WHERE user_id='". $_SESSION['auth']['user_id'] ."' AND address_type='BT' AND ( country=country_2_code OR country=country_3_code)";
                $dbu->query($q);

                // ups module will fail if none of these queries return results.
            } else {
                $vmLogger->debug("Fedex::__construct() - Using first ST address found.");
            }
        }
        $dbu->next_record();
       
        // destination country
        $dbu->f("country_2_code");
        // destination state code
        // TODO: Make sure this works for Non-US countries
        $dbu->f('state');       
        //destination ZIP
        trim($dbu->f("zip"));       
        // Get a list of vendor data (including shipping address)
        $q  = "SELECT * FROM #__{vm}_vendor WHERE vendor_id='".$_SESSION['ps_vendor_id']."'";
        $dbv->query($q);
        $dbv->next_record();

        // source country
        $vendor_country_2_code;
       
       
        // source state code
        // TODO: Make sure this works for Non-US countries
        $dbv->f('vendor_state');
       
        // Source ZIP
       
         trim($dbv->f("vendor_zip"));

// Config
global $weight_total;
//echo $weight_total."<br>";
$formarweight=number_format($weight_total,2);
//echo $formarweight."<br>";
$arrayweight=explode('.',$formarweight);
//print_r($arrayweight)."<br>";
$extract_weight=$arrayweight[0].'.'.intval($arrayweight[1]);
//echo $extract_weight;
$config = array(
    // Services
    'services' => $services,
    // Weight
    'weight' =>$extract_weight, // Default = 1
    'weight_units' => 'lb', // lb (default), oz, gram, kg
    // Size
    //'size_length' => 0, // Default = 8
    //'size_width' => 6, // Default = 4
    //'size_height' => 3, // Default = 2
    //'size_units' => 'in', // in (default), feet, cm
    // From
    'from_zip' =>  trim($dbv->f("vendor_zip")),
    'from_state' =>$dbv->f('vendor_state'), // Only Required for FedEx
    'from_country' => $vendor_country_2_code,
    // To
    'to_zip' => trim($dbu->f("zip")),
    'to_state' =>$dbu->f('state'), // Only Required for FedEx
    'to_country' => $dbu->f("country_2_code"),
   
    // Service Logins
    'ups_access' => '0C2D05F55AF310D0', // UPS Access License Key
    'ups_user' => 'dwstudios', // UPS Username 
    'ups_pass' => 'dwstudios', // UPS Password 
    'ups_account' => '81476R', // UPS Account Number
    'usps_user' => '229DARKW7858', // USPS User Name
    'fedex_account' => '510087020', // FedEX Account Number
    'fedex_meter' => '100005263' // FedEx Meter Number
);

require_once(CLASSPATH ."shipping/fedex10/ShippingCalculator.php");
// Create Class (with config array)
$ship = new ShippingCalculator($config);
// Get Rates
$rates_array = $ship->calculate();



        foreach ($rates_array['fedex'] as $fedexservicename=>$fedexrate)
        {
            if($fedexrate!=""||$fedexrate!=NULL ||$fedexrate!=0)
            {
            $fedexservice_name[]=$services['fedex'][$fedexservicename];
            $fedexservice_name_key[]=$fedexservicename;
            $fedexservice_rate[] = $fedexrate;
            }
        }
       
    $cleancount=count($fedexservice_rate);
    if ($cleancount == 0)
        {
    echo '<img src="fedex.jpg" border="0"><br>';
            $vmLogger->notice("Fedex not provide the service your zip code.");
            return false;
        }
        else
        {
        $radioSelected = false;
        // iterate each service option and output information
        echo "<div style='margin-bottom:20px;'>";
          echo '<img src="fedex.jpg" border="0"><br>';
          for ($service_loop=0;$service_loop < $cleancount;$service_loop++)
            {       
            $html = "";           
            $current_service_display_name = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;','',$fedexservice_name[$service_loop]);           
            $servicerate = $GLOBALS['CURRENCY']->convert( $fedexservice_rate[$service_loop], 'USD',$this->currency);
            $servicerateFormatted = $CURRENCY_DISPLAY->getFullValue($servicerate);
           
            $shipping_rate_id = urlencode("fedexv2|FEDEX|".html_entity_decode($current_service_display_name)."|".$servicerate);
           
            if (((urlencode(@$d["shipping_rate_id"])==$shipping_rate_id) || ($radioSelected==false))) {
                $checked = "checked=\"checked\"";
                $radioSelected = true;
            }else{
                $checked = "";
            }
            $html .= "\n<input type=\"radio\" name=\"shipping_rate_id\" ".$checked." value=\"$shipping_rate_id\" />\n";
            $html .= html_entity_decode($current_service_display_name)." ";
            $html .= "<strong>(" . $servicerateFormatted . ")</strong>";           
            $html .= "<br />";
            // output the html
            echo $html;
            $_SESSION[$shipping_rate_id] = 1;
           
           }
           echo "</div>";
        }

//start ups shipping
  foreach ($rates_array['ups'] as $upsservicename=>$upsrate)
              {
                if($upsrate!=""||$upsrate!=NULL ||$upsrate!=0)
                {
                $upsservice_name[]=$services['ups'][$upsservicename];
                $upsservice_name_key[]=$upsservicename;
                $upsservice_rate[] = $upsrate;
                }
              }
             $cleancount=count($upsservice_rate);

             if ($cleancount == 0)
                {
                   echo    '<img src="ups_logo.jpg" border="0"><br>';
                   $vmLogger->notice("UPS not provide the service your zip code.");
                   return false;
                 }else
                 {
                     $radioSelected = false;
                   // iterate each service option and output information
                   echo "<div style='margin-bottom:20px;'>";
                   echo '<img src="ups_logo.jpg" border="0"><br>';
                   for ($service_loop=0;$service_loop < $cleancount;$service_loop++)
                   {
                        $html = "";           
                        $current_service_display_name = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;','',$upsservice_name[$service_loop]);           
                        $servicerate = $GLOBALS['CURRENCY']->convert( $upsservice_rate[$service_loop], 'USD',$this->currency);
                        $servicerateFormatted = $CURRENCY_DISPLAY->getFullValue($servicerate);               
                        $shipping_rate_id = urlencode("ups|UPS|".html_entity_decode($current_service_display_name)."|".$servicerate);           
                    if (((urlencode(@$d["shipping_rate_id"])==$shipping_rate_id) || ($radioSelected==false)))
                       {
                         $checked = "checked=\"checked\"";
                         $radioSelected = true;
                       }else
                       {
                        $checked = "";
                       }
                        $html .= "\n<input type=\"radio\" name=\"shipping_rate_id\" value=\"$shipping_rate_id\" />\n";
                        $html .= html_entity_decode($current_service_display_name)." ";
                        $html .= "<strong>(" . $servicerateFormatted . ")</strong>";               
                        $html .= "<br />";
                       // output the html
                        echo $html;
                        $_SESSION[$shipping_rate_id] = 1;
               
                     }
                                echo "</div>";
                   }


?>
---------------------------------------------End shipping class------------------------------------------
2 step-> create fedex10.ini under /administrator/components/com_virtuemart/classes/shipping

# $Id: fedex10.ini 617 2007-01-04 12:43:08 -0700 (Thu, 04 Jan 2012) soeren_nb $
[General]
name = FedEXdc
version = 10.02
creationDate = September 2005
author

= AJay
authorEmail = bikash@techwave.com
authorUrl = www.techwave.com.com/
copyright = (c) 2012 Vermonster LLC
license = GNU/GPL
description = The FedEX

Shipping module by bikash ranjan nayak.

[File]
filename = fedex10.php
-------------------------------------------End ini file-------------------------------------------------------

step 3-> create to ShippingCalculator.php under administrator/components/com_virtuemart/classes/shipping/fedex10
---------------------------------------------------------------------------------------------------
<?php
class ShippingCalculator  {
    // Defaults
    var $weight = 1;
    var $weight_unit = "lb";
    var $size_length = 4;
    var $size_width = 8;
    var $size_height = 2;
    var $size_unit = "in";
    var $debug = false; // Change to true to see XML sent and recieved
   
    // Batch (get all rates in one go, saves lots of time)
    var $batch_ups = false; // Currently Unavailable
    var $batch_usps = true;
    var $batch_fedex = false; // Currently Unavailable
   
    // Config (you can either set these here or send them in a config array when creating an instance of the class)
    var $services;
    var $from_zip;
    var $from_state;
    var $from_country;
    var $to_zip;
    var $to_stat;
    var $to_country;
    var $ups_access;
    var $ups_user;
    var $ups_pass;
    var $ups_account;
    var $usps_user;
    var $fedex_account;
    var $fedex_meter;
   
    // Results
    var $rates;
   
    // Setup Class with Config Options
    function ShippingCalculator($config) {
        if($config) {
            foreach($config as $k => $v) $this->$k = $v;
        }
    }
   
    // Calculate
    function calculate($company = NULL,$code = NULL) {
        $this->rates = NULL;
        $services = $this->services;
        if($company and $code) $services[$company][$code] = 1;
        foreach($services as $company => $codes) {
            foreach($codes as $code => $name) {
                switch($company) {
                    case "ups":
                        /*if($this->batch_ups == true) $batch[] = $code; // Batch calculation currently unavaiable
                        else*/ $this->rates[$company][$code] = $this->calculate_ups($code);
                        break;
                    case "usps":
                        if($this->batch_usps == true) $batch[] = $code;
                        else $this->rates[$company][$code] = $this->calculate_usps($code);
                        break;
                    case "fedex":
                        /*if($this->batch_fedex == true) $batch[] = $code; // Batch calculation currently unavaiable
                        else*/ $this->rates[$company][$code] = $this->calculate_fedex($code);
                        break;
                }
            }
            // Batch Rates
            //if($company == "ups" and $this->batch_ups == true and count($batch) > 0) $this->rates[$company] = $this->calculate_ups($batch);
            if($company == "usps" and $this->batch_usps == true and count($batch) > 0) $this->rates[$company] = $this->calculate_usps($batch);
            //if($company == "fedex" and $this->batch_fedex == true and count($batch) > 0) $this->rates[$company] = $this->calculate_fedex($batch);
        }
       
        return $this->rates;
    }
   
    // Calculate UPS
    function calculate_ups($code) {
        $url = "https://www.ups.com/ups.app/xml/Rate";
        $data = '<?xml version="1.0"?> 
<AccessRequest xml:lang="en-US"> 
    <AccessLicenseNumber>'.$this->ups_access.'</AccessLicenseNumber> 
    <UserId>'.$this->ups_user.'</UserId> 
    <Password>'.$this->ups_pass.'</Password> 
</AccessRequest> 
<?xml version="1.0"?> 
<RatingServiceSelectionRequest xml:lang="en-US"> 
    <Request> 
        <TransactionReference> 
            <CustomerContext>Bare Bones Rate Request</CustomerContext> 
            <XpciVersion>1.0001</XpciVersion> 
        </TransactionReference> 
        <RequestAction>Rate</RequestAction> 
        <RequestOption>Rate</RequestOption> 
    </Request> 
    <PickupType> 
        <Code>01</Code> 
    </PickupType> 
    <Shipment> 
        <Shipper> 
            <Address> 
                <PostalCode>'.$this->from_zip.'</PostalCode> 
                <CountryCode>'.$this->from_country.'</CountryCode> 
            </Address> 
        <ShipperNumber>'.$this->ups_account.'</ShipperNumber> 
        </Shipper> 
        <ShipTo> 
            <Address> 
                <PostalCode>'.$this->to_zip.'</PostalCode> 
                <CountryCode>'.$this->to_country.'</CountryCode> 
            <ResidentialAddressIndicator/> 
            </Address> 
        </ShipTo> 
        <ShipFrom> 
            <Address> 
                <PostalCode>'.$this->from_zip.'</PostalCode> 
                <CountryCode>'.$this->from_country.'</CountryCode> 
            </Address> 
        </ShipFrom> 
        <Service> 
            <Code>'.$code.'</Code> 
        </Service> 
        <Package> 
            <PackagingType> 
                <Code>02</Code> 
            </PackagingType> 
            <Dimensions> 
                <UnitOfMeasurement> 
                    <Code>IN</Code> 
                </UnitOfMeasurement> 
                <Length>'.($this->size_unit != "in" ? $this->convert_sze($this->size_length,$this->size_unit,"in") : $this->size_length).'</Length> 
                <Width>'.($this->size_unit != "in" ? $this->convert_sze($this->size_width,$this->size_unit,"in") : $this->size_width).'</Width> 
                <Height>'.($this->size_unit != "in" ? $this->convert_sze($this->size_height,$this->size_unit,"in") : $this->size_height).'</Height> 
            </Dimensions> 
            <PackageWeight> 
                <UnitOfMeasurement> 
                    <Code>LBS</Code> 
                </UnitOfMeasurement> 
                <Weight>'.($this->weight_unit != "lb" ? $this->convert_weight($this->weight,$this->weight_unit,"lb") : $this->weight).'</Weight> 
            </PackageWeight> 
        </Package> 
    </Shipment> 
</RatingServiceSelectionRequest>';
       
        // Curl
        $results = $this->curl($url,$data);
       
        // Debug
        if($this->debug == true) {
            print "<xmp>".$data."</xmp><br />";
            print "<xmp>".$results."</xmp><br />";
        }
       
        // Match Rate
        preg_match('/<MonetaryValue>(.*?)<\/MonetaryValue>/',$results,$rate);
       
        return $rate[1];
    }
   
    // Calculate USPS
    function calculate_usps($code) {
        // Weight (in lbs)
        if($this->weight_unit != 'lb') $weight = $this->convert_weight($weight,$this->weight_unit,'lb');
        else $weight = $this->weight;
        // Split into Lbs and Ozs
        $lbs = floor($weight);
        $ozs = ($weight - $lbs)  * 16;
        if($lbs == 0 and $ozs < 1) $ozs = 1;
        // Code(s)
        $array = true;
        if(!is_array($code)) {
            $array = false;
            $code = array($code);
        }
       
        $url = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
        $data = 'API=RateV2&XML=<RateV2Request USERID="'.$this->usps_user.'">';
        foreach($code as $x => $c) $data .= '<Package ID="'.$x.'"><Service>'.$c.'</Service><ZipOrigination>'.$this->from_zip.'</ZipOrigination><ZipDestination>'.$this->to_zip.'</ZipDestination><Pounds>'.$lbs.'</Pounds><Ounces>'.$ozs.'</Ounces><Size>REGULAR</Size><Machinable>TRUE</Machinable></Package>';
        $data .= '</RateV2Request>';
       
        // Curl
        $results = $this->curl($url,$data);
       
        // Debug
        if($this->debug == true) {
            print "<xmp>".$data."</xmp><br />";
            print "<xmp>".$results."</xmp><br />";
        }
       
        // Match Rate(s)
        preg_match_all('/<Package ID="([0-9]{1,3})">(.+?)<\/Package>/',$results,$packages);
        foreach($packages[1] as $x => $package) {
            preg_match('/<Rate>(.+?)<\/Rate>/',$packages[2][$x],$rate);
            $rates[$code[$package]] = $rate[1];
        }
        if($array == true) return $rates;
        else return $rate[1];
    }
   
    // Calculate FedEX
    function calculate_fedex($code) {
        $url = "https://gatewaybeta.fedex.com/GatewayDC";
        $data = '<?xml version="1.0" encoding="UTF-8" ?>
<FDXRateRequest xmlns:api="http://www.fedex.com/fsmapi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FDXRateRequest.xsd">
    <RequestHeader>
        <CustomerTransactionIdentifier>Express Rate</CustomerTransactionIdentifier>
        <AccountNumber>'.$this->fedex_account.'</AccountNumber>
        <MeterNumber>'.$this->fedex_meter.'</MeterNumber>
        <CarrierCode>'.(in_array($code,array('FEDEXGROUND','GROUNDHOMEDELIVERY')) ? 'FDXG' : 'FDXE').'</CarrierCode>
    </RequestHeader>
    <DropoffType>REGULARPICKUP</DropoffType>
    <Service>'.$code.'</Service>
    <Packaging>YOURPACKAGING</Packaging>
    <WeightUnits>LBS</WeightUnits>
    <Weight>'.number_format(($this->weight_unit != 'lb' ? convert_weight($this->weight,$this->weight_unit,'lb') : $this->weight), 1, '.', '').'</Weight>
    <OriginAddress>
        <StateOrProvinceCode>'.$this->from_state.'</StateOrProvinceCode>
        <PostalCode>'.$this->from_zip.'</PostalCode>
        <CountryCode>'.$this->from_country.'</CountryCode>
    </OriginAddress>
    <DestinationAddress>
        <StateOrProvinceCode>'.$this->to_state.'</StateOrProvinceCode>
        <PostalCode>'.$this->to_zip.'</PostalCode>
        <CountryCode>'.$this->to_country.'</CountryCode>
    </DestinationAddress>
    <Payment>
        <PayorType>SENDER</PayorType>
    </Payment>
    <PackageCount>1</PackageCount>
</FDXRateRequest>';
       
        // Curl
        $results = $this->curl($url,$data);
       
        // Debug
        if($this->debug == true) {
            print "<xmp>".$data."</xmp><br />";
            print "<xmp>".$results."</xmp><br />";
        }
   
        // Match Rate
        preg_match('/<NetCharge>(.*?)<\/NetCharge>/',$results,$rate);
       
        return $rate[1];
    }
   
    // Curl
    function curl($url,$data = NULL) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        if($data) {
            curl_setopt($ch, CURLOPT_POST,1); 
            curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
        } 
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
        $contents = curl_exec ($ch);
       
        return $contents;
       
        curl_close ($ch);
    }
   
    // Convert Weight
    function convert_weight($weight,$old_unit,$new_unit) {
        $units['oz'] = 1;
        $units['lb'] = 0.0625;
        $units['gram'] = 28.3495231;
        $units['kg'] = 0.0283495231;
       
        // Convert to Ounces (if not already)
        if($old_unit != "oz") $weight = $weight / $units[$old_unit];
       
        // Convert to New Unit
        $weight = $weight * $units[$new_unit];
       
        // Minimum Weight
        if($weight < .1) $weight = .1;
       
        // Return New Weight
        return round($weight,2);
    }
   
    // Convert Size
    function convert_size($size,$old_unit,$new_unit) {
        $units['in'] = 1;
        $units['cm'] = 2.54;
        $units['feet'] = 0.083333;
       
        // Convert to Inches (if not already)
        if($old_unit != "in") $size = $size / $units[$old_unit];
       
        // Convert to New Unit
        $size = $size * $units[$new_unit];
       
        // Minimum Size
        if($size < .1) $size = .1;
       
        // Return New Size
        return round($size,2);
    }
   
    // Set Value
    function set_value($k,$v) {
        $this->$k = $v;
    }

?>
--------------------------------end---------------------------------------------------
i hope enjoy and save the time
-------------------------------------------------------------
if you helpful my code please donate some few amount to
developing and free to post.
-------------------------------------------------------------

Tuesday, September 4, 2012

What is cloud computing?


Cloud computing changes the way we think about technology. Cloud is a
computing model providing web-based software, middleware and
computing resources on demand.
By deploying technology as a service, you give users access only to the
resources they need for a particular task. This prevents you from paying
for idle computing resources. Cloud computing can also go beyond cost
savings by allowing your users to access the latest software and
infrastructure offerings to foster business innovation.

Cloud computing consists of hardware and software resources made available on the Internet as managed third-party services. These services typically provide access to advanced software applications and high-end networks of server computers.

Types of Cloud Computing

Service providers create cloud computing systems to serve common business or research needs. Examples of cloud computing services include:
  • virtual IT - configure and utilize remote, third-party servers as extensions to a company's local IT network

  • software - utilize commercial software applications, or develop and remotely host custom built applications

  • network storage - back up or archive data across the Internet to a provider without needing to know the physical location of storage
Cloud computing systems all generally are designed for scalability to support large numbers of customers and surges in demand.

Examples of Cloud Computing Services

These examples illustrate the different types of cloud computing services available today: Some providers offer cloud computing services for free while others require a paid subscription.

Cloud Computing Pros and Cons

Service providers are responsible for installing and maintaining core technology within the cloud. Some customers prefer this model because it limits their own manageability burden. However, customers cannot directly control system stability in this model and are highly dependent on the provider instead. Cloud computing systems are normally designed to closely track all system resources, which enables providers to charge customers according to the resources each consumes. Some customers will prefer this so-called metered billing approach to save money, while others will prefer a flat-rate subscription to ensure predictable monthly or yearly costs.
Using a cloud computing environment generally requires you to send data over the Internet and store it on a third-party system. The privacy and security risks associated with this model must be weighed against alternatives.

Friday, August 31, 2012

how to clean link using php

function clickable_link($var)
{
$text = $var;
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
$ret = ' ' . $text;
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1\\2", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1\\2", $ret);
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1\\2@\\3", $ret);
$ret = substr($ret, 1);
return $ret;
}

-------------------------------------------------------------
if you helpful my code please donate some few amount to
developing and free to post.
-------------------------------------------------------------

how to check ban-word user in put using php

function banned_words_chk($phrase)
{
global $conn, $config;
$query = "SELECT word from bans_words";
$executequery = $conn->Execute($query);
$bwords = $executequery->getarray();
$found = 0;
$words = explode(" ", $phrase);
foreach($words as $word)
{
foreach($bwords as $bword)
{
if($word == $bword[0])
{
$found++;
}
else
{
$pos2 = strpos($word, $bword[0]);
if($pos2 !== false)
{
$found++;
}
}
}
}
if($found > 0)
{
return true;
}
else
{
return false;
}
}
-------------------------------------------------------------
if you helpful my code please donate some few amount to
developing and free to post.
-------------------------------------------------------------

how to send mail html using php with example

function mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc="")
{
global $SERVER_NAME;
$subject = nl2br($subject);
$sendmailbody = nl2br($sendmailbody);
$sendto = $sendto;
if($bcc!="")
{
$headers = "Bcc: ".$bcc."\n";
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "From: " . $from . "\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$sendmailbody","$headers");
}
-------------------------------------------------------------
if you helpful my code please donate some few amount to
developing and free to post.
-------------------------------------------------------------