Friday, September 26, 2008
JavaScript Floating Layer
1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag
3. Put the last coding into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
window.onerror = null;
var topMargin = 100;
var slideTime = 1200;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
function layerObject(id,left) {
if (ns6) {
this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ie4) {
this.obj = document.all[id].style;
this.obj.left = left;
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
return this.obj;
}
}
function layerSetup() {
floatLyr = new layerObject('floatLayer', pageWidth * .5);
window.setInterval("main()", 10)
}
function floatObject() {
if (ns4 || ns6) {
findHt = window.innerHeight;
} else if(ie4) {
findHt = document.body.clientHeight;
}
}
function main() {
if (ns4) {
this.currentY = document.layers["floatLayer"].top;
this.scrollTop = window.pageYOffset;
mainTrigger();
}
else if(ns6) {
this.currentY = parseInt(document.getElementById('floatLayer').style.top);
this.scrollTop = scrollY;
mainTrigger();
} else if(ie4) {
this.currentY = floatLayer.style.pixelTop;
this.scrollTop = document.body.scrollTop;
mainTrigger();
}
}
function mainTrigger() {
var newTargetY = this.scrollTop + this.topMargin;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
}
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 2 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
}
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
if ( ns4 )document.layers["floatLayer"].top = newY;
if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px";
}
}
function start() {
if(ns6||ns4) {
pageWidth = innerWidth;
pageHeight = innerHeight;
layerSetup();
floatObject();
}
else if(ie4) {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
layerSetup();
floatObject();
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY onLoad="start()">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<DIV id="floatLayer" style="position: absolute; height:200px; width:200px; left:30px; top:1px;z-index: 100">This is a Floating Layer. Replace this content with your own.</DIV>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 3.52 KB -->
Monday, September 15, 2008
JavaScript DateValidation
}
var dateStr = ctrl.value;
var datePat = /^(\d}1,2})(\/|-)(\d}1,2})\2(\d}2}|\d}4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null)
}
alert("Invalid date format. Please enter the date in the MM/DD/YY format (example: 1/15/08) or select a date by clicking the calendar icon.")
ctrl.focus();
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month <> 12)
}
// check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day <> 31)
}
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31)
}
alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2)
}
// check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap))
}
alert("February " + year + " doesn't have " + day + " days!");
return false;
}
}
return true; // date is valid
}
Sunday, September 14, 2008
PHP Classes
Classes are object-oriented programming for PHP.
What is object-oriented programming?
Object-oriented programming consists of three main vocabulary words: classes, methods, and objects. An object is basically a data structure (also known as an abstract data type), which are encapsulated in a set of routines known as methods. A class is a collection of methods and objects.
What's the purpose of classes in PHP?
It's the same reason as any other programming language: for large projects, classes provide superior organization and less repetitive code.
A Simple Example:
class dummy {
var $variable;
var $variable2 = 1;
var $variable3 = 2;
function sum($one, $two) {
$val = $one + $two;
return $val;
}
?>
As you might have guessed, the line "class dummy {" initializes the class. "dummy" is now inherited as the name of the class. The purpose of this will be shown later. Declaring global variables in classes however are a tad different then regular PHP. They must be preceded by "var". (For all you C coders, this is identical to "int variable;") Next, we see a function in it's most purest form. "function sum($one, $two) {" intializes the function by the name of "sum" with the required arguments $one and $two. The function now adds the value of $one and $two, and returns the value quite obviously through "return $val;". Got it? Time to add more :-)
An Advance Example of Class
<?
class dummy {
var $variable;
var $variable2 = 1;
var $variable3 = 2;
function sum($one, $two) {
$val = $one + $two;
return $val;
}
function sum2() {
$val = $this->sum($this->variable2, $this->variable3);
return $val;
}
}
?>
What we just did right there is one of the most important aspects of object-oriented programming called "inheritance." Let's look at this line for line. All our variables are declared through the "var" procedure, that's nothing new. Nor is the first function sum(). However, sum2() is. First off, you might notice there are no arguments for this variable. That's because this variable is a void, much like numerous internal PHP functions like time() or others I can't think of. This line displays the inheritance. The "$this" variable is a reserved variable in object-oriented PHP programming (translation - don't use it in your classes!) that actually does the inheritance. "$this->sum()" is basically interpreted as, "in this class, perform the sum() function." Like "$this->sum()", "$this->variable2" is interpreted as "in this class, use the value of 'variable2'." Likewise with $this->variable3. Note: all calls to native class functions or variables are done in this manner. Starting with "$this->" and followed by the name of the function or variable you wish to use. I can't stress the importance of that enough. Now I want to show you something imperative to object-oriented programming, using all this outside of your classes. This is how it's done if your class is contained in an external file:
<?
include("/path/to/the/file/with/your/class/in/it");
$yourclass = new yourclassname;
echo $yourclass->somevariable;
?>
If the class is internal, simple exclude the include() line. Now this is more inheritance. "$yourclass" inherits all of the class because of the usage of the "new yourclassname". Obviously, you would replace "yourclassname" with the name of your class in your script. "$yourclass" is now used the same way as "$this" was inside of your class, as shown from the "$yourclass->somevariable" reference. Got all that? Good.
As if you haven't been bogged down with inheritance enough yet, I've got some more for you.
<?
class dummy {
var $variable;
var $variable2 = 1;
var $variable3 = 2;
function sum($one, $two) {
$val = $one + $two;
return $val;
}
function sum2() {
$val = $this->sum($this->variable2, $this->variable3);
return $val;
}
}
class dummy2 extends dummy {
function sum2_clone() {
$val = $this->sum($this->variable2, $this->variable3);
return $val;
}
}
?>
Ok now this is just fun. The "sum2_clone()" function will return the exact same result (3) as will the original "sum2()" function! If you didn't guess yet, the "extends" does this. "extends" inherits all the values of one class for use in a completely different class. IMPORTANT - the name that follows "extends" is *always* the inherited class. In our example, the "dummy" class is inherited. Therefore, we can access "$this->sum()" and everything else from the "dummy" class. How cool is that?
I've got more about "extends" for you (and a new vocabulary word); constructors.
<?
class dummy {
var $variable;
var $variable2 = 1;
var $variable3 = 2;
function sum($one, $two) {
$val = $one + $two;
return $val;
}
function sum2() {
$val = $this->sum($this->variable2, $this->variable3);
return $val;
}
}
class dummy3 extends dummy {
function dummy3($variable1, $variable2) {
$val = $this->sum($variable1, $variable2);
return $val;
}
?>
So what's so special about that? What makes "dummy3" special is how you call it. You'd do it like this:
<?
include("/path/to/file");
$1 = 1;
$2 = 2;
$sum = new dummy3($1, $2);
?>
See how you can pass arguments right inside of your "new dummy3()" call? That's what's special about this. Though it might seem rather pointless, this is great to use for functions you use repetitively and want to make calls to with fewer lines of code. "$sum" will now return 3 if you did "echo $sum" by the way.
The next part of this tutorial is the "::" operator. To be honest, the example shown in the PHP manual is much better then anything I could write. However, I'll give it a whirl.
<?
class dummy4 {
function test() {
echo "I am from class dummy4.";
}
}
class dummy5 extends dummy4 {
function test() {
echo "I am from class dummy5.";
dummy4::test();
}
}
?>
Now, if you were to call the "test()" function from "dummy5" you would see this:
I am from class dummy5.I am from class dummy5.
I think this is pretty self explanatory. The :: operate is simply another way to make a call to something from another class just as "$this" did.
Now if I haven't held your hand through this tutorial, it's time for some parenting. Watch the example and learn.
class dummy6 {
function test() {
echo "I am from class dummy 6.";
}
}
class dummy7 extends dummy6 {
function test() {
echo "I am from class dummy 7.";
parent::test();
}
}
?>
This will return:
I am from class dummy 6.I am from class dummy 7.
"Parent" basically replaces "dummy6". The value of "parent" will always be the name of the class that follows "extends". Got all that? Good.
Finally, the last part of this tutorial deals with "references inside the constructor." Don't worry, it's easier then it sounds. Think of it as adding more to our constructor then just one function. Let's go.
class dummy8 {
function dummy8($text) {
echo $text;
}
}
function clone() {
echo $this->dummy8($this->text);
}
}
?>
Then you would do this:
include("/path/to/file");
$text = "Hey there.";
$class = new dummy8($text);
echo $class->clone();
?>
Can you see what's going to happen? "$class->clone()" will print:
Hey there.
See how it works? "$text" is now recognized as a variable inside the class, so "$this->text" is a proper reference to it. Get it? Good. And that's everything, I hope your mind isn't too fried :P Any questions/comments/complaints/suggestions/hate mail can be sent to Ben Wirth. Happy PHP-ing!
Tuesday, September 9, 2008
PHP Associated MySQL Functions
$result = mysql_query($sql,$con);
while ($row = mysql_fetch_object($result)) {
echo $row->FirstName . "
";
}
mysql_fetch_row: Returns a numerical array that corresponds to the fetched row and moves the internal data pointer ahead. Returns an numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows.mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
$row = mysql_fetch_row($result);
echo $row[0]; // 42
echo $row[1]; // the email value
mysql_fetch_array: Fetch a result row as an associative array, a numeric array, or both. This function gets a row from the mysql_query() function and returns an array on success, or FALSE on failure or when there are no more rows. Optional. Specifies what kind of array to return.
Possible values:
* MYSQL_ASSOC - Associative array
* MYSQL_NUM - Numeric array
* MYSQL_BOTH - Default. Both associative and numeric array
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf("ID: %s Name: %s", $row[0], $row[1]);
------------------------------ or ----------------------------------------
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("ID: %s Name: %s", $row["id"], $row["name"]);
}
mysql_free_result($result);
Tuesday, September 2, 2008
Authorize.net AIM Integration | Mail for Valid Transaction
// calling php config file
require("includes/configs.php");
?>
<!--
###########################################################
# #
# D O C U M E N T A T I O N #
# #
# This code sample has been successfully tested on #
# third-party web servers and performed according to #
# documented Advanced Integration Method (AIM) #
# standards. #
# #
# Last updated September 2004. #
# #
# For complete and freely available documentation, #
# please visit the Authorize.Net web site at: #
# #
# http://www.authorizenet.com/support/guides.php #
# #
###########################################################
###########################################################
# #
# D I S C L A I M E R #
# #
# WARNING: ANY USE BY YOU OF THE SAMPLE CODE PROVIDED #
# IS AT YOUR OWN RISK. #
# #
# Authorize.Net provides this code "as is" without #
# warranty of any kind, either express or implied, #
# including but not limited to the implied warranties #
# of merchantability and/or fitness for a particular #
# purpose. #
# #
# #
###########################################################
###########################################################
# #
# P R E R E Q U I S I T E S #
# #
# Basically, all the required code to generate 1) a #
# unique fingerprint, using the HMAC-MD5 algorithm, #
# and 2) a compatible timestamp is included in the #
# sample code provided in this file and the additional #
# files that should have accompanied this file: #
# - simdata.php #
# - simlib.php #
# #
# However, you need to verify that the required PHP #
# MHASH extension is available; otherwise, you will #
# not be able to generate the required fingerprint. #
# #
# The required MHASH extension comes with PHP and #
# requires no additional cost. #
# #
# Most web hosting providers install this extension #
# along with PHP; however, in some circumstances, you #
# may have to enable it yourself or ask your web host #
# to enable it for you. #
# #
# PLEASE UNDERSTAND that it is impossible for us to #
# anticipate any and all possible web server #
# configurations. #
# #
# If you cannot get the sample code to work due to an #
# unknown server configuration or missing PHP extension, #
# and if you cannot figure out how to test for the #
# availability of the required extension, consider #
# hiring a professional web developer or server #
# administrator. #
# #
# Authorize.Net is unable to assist you with web #
# server troubleshooting. #
# #
# #
###########################################################
###########################################################
# #
# C O N T A C T I N F O R M A T I O N #
# #
# For specific questions, #
# please contact Authorize.Net's Integration Services: #
# #
# integration at authorize dot net #
# #
# Please remember that we cannot support individual #
# e-commerce developers with programming problems and #
# other issues that could be easily solved by referring #
# to the available reference materials. #
# #
###########################################################
###########################################################
# #
# S I M I N A N U T S H E L L #
# #
###########################################################
# #
# 1. You gather some basic transaction data on your web #
# site. #
# #
# 2. Using a standard HTML form, you submit the required #
# information to Authorize.Net, by posting the form data #
# to a specific URL on Authorize.Net’s secure server. #
# #
# 3. On Authorize.Net’s secure server, you collect all #
# the financial information on the SIM Payment Form. #
# #
# 4. When the transaction has been completed, you may #
# either re-direct the user to another web page on your #
# web site or complete the transaction on #
# Authorize.Net’s secure server. #
# #
# #
###########################################################
###########################################################
# #
# H A R D C O D E D V A L U E S #
# #
# The purpose of this sample code is to demonstrate how #
# a basic SIM transaction works. #
# #
# For this purpose, we have hard-coded a number of #
# values, to expedite your testing and integration #
# efforts. #
# #
# Please, pay special attention to values, such as #
# your log-in ID, transaction key, amount, description, #
# etc. that may need to be changed throughout this #
# code sample and/or its associated include files. #
# #
# #
###########################################################
-->
<?
if($_REQUEST['x_Amount']==""){
echo "<script>window.location='index.htm'</script>";
}
$x_Description = $HTTP_GET_VARS['x_Description'];
$x_Amount = $HTTP_GET_VARS['x_Amount'];
$x_Description = $_REQUEST['x_Description'];
$x_Amount = $_REQUEST['x_Amount'];
// *** IF YOU WANT TO PASS CURRENCY CODE do the following: ***
// Assign the transaction currency (from your shopping cart) to $currencycode variable
$currencycode="USD";
if ($x_Description == "")
$x_Description = $HTTP_POST_VARS['x_Description'];
if ($x_Amount == "")
$x_Amount = $HTTP_POST_VARS['x_Amount'];
?>
<!-- Description: <?=$x_Description?> <BR />
Total Amount : <?=$x_Amount?> -->
<!-- <FORM action="https://test.authorize.net/gateway/transact.dll" method="POST">
--><!-- Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts -->
<!--<FORM action="https://developer.authorize.net/param_dump.asp" method="POST">-->
<?
// authdata.php contains the loginid and x_tran_key.
// You may use a more secure alternate method to store these (like a DB / registry).
//include ("authorizedotnet/simdata.php");
//include ("authorizedotnet/simlib.php");
$DEBUGGING = 1; # Display additional information to track down problems
$TESTING = 1; # Set the testing flag so that transactions are not live
$ERROR_RETRIES = 2; # Number of transactions to post if soft errors occur
$auth_net_login_id = "2q";
$auth_net_tran_key = "biraj";
$auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
# Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
# $auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
$firstname = $_POST["txt_firstnatfme"];
$lastname = $_POST["txt_lastname"];
$streetaddress1 = $_POST["txt_address"];
$city = $_POST["txt_city"];
$state = $_POST["txt_state"];
$zip = $_POST["txt_zip"];
$country = $_POST["cmb_country"];
$email = $_POST["txt_email"];
$homephone = $_POST["txt_phone"];
$creditcard_no = $_POST["txt_creditcardno"];
$expiredate = $_POST["cmb_month"].$_POST["cmb_year"];
$invoice_no = date("siHdmY");
$authnet_values = array
(
"x_login" => $auth_net_login_id,
"x_version" => "3.1",
"x_delim_char" => "|",
"x_delim_data" => "TRUE",
"x_url" => "FALSE",
"x_type" => "AUTH_CAPTURE",
"x_method" => "CC",
"x_tran_key" => $auth_net_tran_key,
"x_relay_response" => "FALSE",
"x_card_num" => $creditcard_no,
"x_exp_date" => $expiredate,
"x_description" => $x_Description,
"x_amount" => $x_Amount,
"x_first_name" => $firstname,
"x_last_name" => $lastname,
"x_address" => $streetaddress1,
"x_city" => $city,
"x_state" => $state,
"x_zip" => $zip,
"x_phone" => $homephone,
);
$fields = "";
foreach( $authnet_values as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&";
$amount = $x_Amount;
// Trim $ sign if it exists
if (substr($amount, 0,1) == "$") {
$amount = substr($amount,1);
}
// I would validate the Order here before generating a fingerprint
// Seed random number for security and better randomness.
srand(time());
$sequence = rand(1, 1000);
// Insert the form elements required for SIM by calling InsertFP
//$ret = InsertFP ($loginid, $x_tran_key, $amount, $sequence);
//*** IF YOU ARE PASSING CURRENCY CODE uncomment and use the following instead of the InsertFP invocation above ***
//$ret = InsertFP ($loginid, $x_tran_key, $amount, $sequence, $currencycode);
// Insert rest of the form elements similiar to the legacy weblink integration
echo ("<input type=\"hidden\" name=\"x_description\" value=\"" . $x_Description . "\">\n" );
echo ("<input type=\"hidden\" name=\"x_login\" value=\"" . $loginid . "\">\n");
echo ("<input type=\"hidden\" name=\"x_amount\" value=\"" . $amount . "\">\n");
// *** IF YOU ARE PASSING CURRENCY CODE uncomment the line below *****
echo ("<input type=\"hidden\" name=\"x_currency_code\" value=\"" . $currencycode . "\">\n");
$_SESSION["description"]=$x_Description;
$_SESSION["length"]=$length;
$_SESSION["unit"]=$unit;
$_SESSION["startdate"]=$startDate;
$_SESSION["amount"]=$amount;
$_SESSION["cardnumber"]=$cardNumber;
$_SESSION["expirationDate"]=$expirationDate;
$_SESSION["name"]=$firstName;
$_SESSION["address"]=$address;
$_SESSION["city"]=$city;
$_SESSION["state"]=$state;
$_SESSION["zip"]=$zip;
$_SESSION["country"]=$country;
?>
<INPUT type="hidden" name="x_customer_ip" value="<?=$_SERVER[REMOTE_ADDR]?>">
<INPUT type="hidden" name="x_first_name" value="<?=$_POST['txt_firstname'];?>">
<INPUT type="hidden" name="x_last_name" value="<?=$_POST['txt_lasttname'];?>">
<INPUT type="hidden" name="x_address" value="<?=$streetaddress1;?>">
<INPUT type="hidden" name="x_city" value="<?=$city;?>">
<INPUT type="hidden" name="x_state" value="<?=$state;?>">
<INPUT type="hidden" name="x_zip" value="<?=$zip;?>">
<INPUT type="hidden" name="x_country" value="<?=$country;?>">
<INPUT type="hidden" name="x_phone" value="<?=$homephone;?>">
<INPUT type="hidden" name="x_fax" value="<?=$fax;?>">
<INPUT type="hidden" name="x_email" value="<?=$email;?>">
<INPUT type="hidden" name="x_delim_data" value="TRUE">
<INPUT type="hidden" name="x_method" value=""> <!--default will be Credit Card(CC)-->
<INPUT type="hidden" name="x_type" value="">
<INPUT type="hidden" name="x_card_num" value="<?=$creditcard_no;?>">
<INPUT type="hidden" name="x_exp_date" value="<?=$expiredate;?>">
<input type='hidden' name='x_invoice_num' value='<?=$invoice_no?>'>
<!-- <INPUT type="hidden" name="x_show_form" value="PAYMENT_FORM"> -->
<INPUT type="hidden" name="x_test_request" value="FALSE">
<INPUT type="hidden" name="x_relay_url" value="http://www.humpanch.com/authorizedotnet_thankyou.html">
<?php
$ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
### Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
### $ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
$resp = curl_exec($ch); //execute post and get results
curl_close ($ch);
?>
<?
//echo "<b>02: Get post results:</b><br>";
//echo $resp;
//echo "<br>";
?>
<!-- <INPUT type="submit" value="Accept Order"> -->
<?php
//$resp_trim=rtrim($resp,"|");
//$resp_trim=str_split($resp, 1);
$resp_trim=explode("|",$resp);
//echo $resp_trim[0];
if($resp_trim[0]!="1"){
$smarty->assign("HIDVAL", "1");
$smarty->assign("MESSAGE","Thank you for signing up. Your Transaction was successful. An email has been sent to <strong>".$_POST['txt_email']."</strong>.");
$_SESSION["firstname"]=$firstname;
$_SESSION["lastname"]=$lastname;
$_SESSION["DESCRIP"]=$x_Description;
echo $_SESSION["DESCRIP"];
$_SESSION["EMAIL"]=$email;
$_SESSION["PHONE"]=$_POST['txt_phone'];
//echo $_SESSION["PHONE"];
$smarty->assign("EMAIL", $_POST['email']);
/*........... SEND MAIL TO CUSTOMERS .......................*/
/* MAIL SENT PHP */
echo $_SESSION["phone"];
if($_SESSION["blk"]!=""){
$blackberry=" ".$_SESSION["blk"]." Blackberry, ";
}
if($_SESSION["sharept"]!=""){
if($_SESSION["sharept"]=="59.95"){
$sharepoint="Additional Package Amount for Sharepoint Platinum 10GB";
}else if($_SESSION["sharept"]=="24.95"){
$sharepoint="Additional Package Amount for Sharepoint Gold 3GB";
}else{
$sharepoint="Additional Package Amount for Sharepoint Silver 500MB";
}
}
if($_SESSION["blackberrySyn"]!=""){
$blackBerrySyn="Blackberry Syncronisation Price";
}
if($_SESSION["blackberrysetupfee"]!=""){
$blkbrysetupfee="Blackberry Setup Fee";
}
if($_SESSION["totalamount"]!=""){
$totalamount="Total Amount";
}
if($_SESSION["mailbox"]==1){
$dmailbox="Mailbox";
}else{
$dmailbox="Mailboxes";
}
if($_SESSION["blk"]>1){
$noblk= "(".$_SESSION["blk"]." Numbers)";
}
$message1 ="<html><head><style type='text/css'>
<!--
.tableOdd {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: bold;
background-color: #DFE9F7;
padding-left:20px;
}
.tableOddC {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: normal;
text-align:right;
background-color: #DFE9F7;
padding-right:20px;
}
.tableEven {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: bold;
background-color: #FFFFFF;
padding-left:20px;
}
.tableEvenC {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: normal;
text-align:right;
background-color: #FFFFFF;
padding-right:20px;
}
.tableTotal {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: bolder;
background-color: #EEEEEE;
padding-left:20px;
}
.tableTotalC {
font-family: 'Lucida Sans';
font-size: 12px;
font-style: normal;
font-weight: bolder;
text-align:right;
background-color: #EEEEEE;
padding-right:20px;
}
-->
</style>";
$message1 .="</head><body bgcolor='#EEEEEE'><br/><br/><center><table border='0' width='60%' bgcolor='#FFFFFF' cellspacing='0'><tr><td style='padding-left:20px; padding-right:20px; padding-top:40px;'><p><table border='0'><tr><td width='70%'><center><img src='http://www.humpanch.com/images/email-logo-mf.gif' width='257' height='77'/></td><td width='15%'> </td><td style='float:left;' width='15%'><span><a href='http://humpanch.com/chats/request.php?l=admin&x=1&deptid=29&pagex=http%3A//www.humpanch.com/' target='_blank'><img src='http://www.humpanch.com/images/livechat-m.gif' border='0' width='120' height='44'></a></span></td></tr></table></p></center><span style='font-weight:normal; font-size:12px; font-family: Lucida Sans';>Hello ".$_SESSION["firstname"]." ".$_SESSION["lastname"]."</span>,<p style='font-weight:normal; font-size:12px; font-family: Lucida Sans';>Thank you for signing up with humpanch. Please do not ignore this e-mail as it contains vital details that will help you in using our <span>services</span>.</p><p style='font-weight:normal; font-size:12px; font-family: Lucida Sans';>If you have not configured your Account Administration Panel yet, then please configure it now by clicking <a href='http://www.humpanch.com/payment-cpanel.html'>here</a>.</p><p style='font-weight:normal; font-size:12px; font-family: Lucida Sans';>Account Administration Panel needs to be configured initially so that you can start using the services you have purchased. Once you have completed the set-up, you can login into your Account Administration Panel at any time to configure the services you have purchased. You also have the option in your Account Administration Panel of purchasing additional services at any time.</p><p style='font-weight:normal; font-size:12px; font-family: Lucida Sans';>You have purchased following services from us.</p>
<table border='0' width='100%'><tr><td>
<table width='100%' border='0' cellspacing='0' cellpadding='2'>";
if($_SESSION["DESCRIP"]=="SharePointSilver"){
$message1 .= "<tr>
<td class='tableOdd' width='60%'>Sharepoint Silver Plan</td>
<td class='tableOddC'>$ 8.95</td>
</tr>";
}else if($_SESSION["DESCRIP"]=="SharePointGold"){
$message1 .= "<tr>
<td class='tableOdd' width='60%'>Sharepoint Gold Plan</td>
<td class='tableOddC'>$ 24.95</td>
</tr>";
}else if($_SESSION["DESCRIP"]=="SharePointPlatinum"){
$message1 .= "<tr>
<td class='tableOdd' width='60%'>Sharepoint Platinum Plan</td>
<td class='tableOddC'>$ 59.95</td>
</tr>";
}else{
$message1 .= "<tr>
<td class='tableOdd' width='60%'>".$_SESSION["description"]." ".$_SESSION["mailbox"]." ".$dmailbox."</td>
<td class='tableOddC'>".$_SESSION["mailboxprice"]."</td>
</tr>";
if($_SESSION["blk"]!=""){
$message1 .="<tr>
<td class='tableEven' width='60%'>".$blackBerrySyn." ".$noblk."</td>
<td class='tableEvenC' width='40%'>".$_SESSION["blackberrySyn"]."</td>
</tr><tr>
<td class='tableOdd' width='60%'>".$blkbrysetupfee." ".$noblk."</td>
<td class='tableOddC' width='40%'>".$_SESSION["blackberrysetupfee"]."</td>
</tr>";
}
if($_SESSION["sharept"]!=""){
$message1 .="<tr>
<td class='tableEven' width='60%'>".$sharepoint."</td>
<td class='tableEvenC' width='40%'>".$_SESSION["sharept"]."</td>
</tr>";
}
$message1 .="<tr>
<td class='tableTotal' width='60%'>".$totalamount."</td>
<td class='tableTotalC' width='40%'>$".$_SESSION["amount"]."</td>
</tr>";
}
$message1 .="</table></td></tr></table></center>";
$message1 .="<p style='font-weight:normal; font-size:12px;font-family: Lucida Sans;'>If you have any questions or need help, please do not hesitate to contact us at <a href='mailto:support@humpanch.com'>support@humpanch.com</a>. You can also visit http://www.humpanch.com or click on the Live Chat icon above to reach us.</p>";
$message1 .="<p style='font-weight:normal; font-size:12px; font-family: Lucida Sans; padding-bottom:40px;'>Regards,<br/>humpanch Team</p></td></tr></table>";
$message1 .="</body></html>";
$message2 ="<strong>Email :</strong>".$_POST['txt_email']."<br/><strong>Phone :</strong>".$_SESSION["PHONE"];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: For humpanch Sales Team<billing@humpanch.com>' . "\r\n" .
'Reply-To: billing@humpanch.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$smarty->assign("EMAIL", $_POST['email']);
$smarty->assign("MESSAGE2","You will be automatically redirected to setup your Administration Panel after ");
if($_SESSION["firstname"]!=""){
mail('sales@humpanch.com', 'FOR SALES TEAM:humpanch Account Administration Set-up Details
', $message2.$message1, $headers);
mail($_POST['txt_email'], 'humpanch Account Administration Set-up Details
', $message1, $headers);
}
/*--------------Track IP -------------------------*/
$logparameter_date = date("F jS, Y H:i:s");
$logparameter_d = "AIM";
$remote_address = $_SERVER['REMOTE_ADDR'];
$logparameter = $logparameter_date . "Invoice No.".$invoice_no." Method: " . $logparameter_d . " IP: ". $remote_address . " Card Number: ".$creditcard_no." Expire Date: ".$expiredate." Description: ".$x_Description." Amount: ".$x_Amount." First Name ".$firstname." Last Name: ".$lastname." Street Address".$streetaddress1." City:".$city." State: ".$state." Zip :".$zip." Home Phone".$homephone."\n";
error_log($logparameter, 3, "crcard-iptrack.log");
}else{
$smarty->assign("HIDVAL", "0");
$smarty->assign("MESSAGE","<strong><span style='color:#FF0000;'>The Credit Card information entered is invalid. You will be redirected to the home page.</span></strong>");
$smarty->assign("MESSAGE2","You will be redirected to home page after ");
}
/* end */
$smarty->assign("some","");
$smarty->assign("htmltitle","humpanch - Reseller");
// determind which inner body to be displayed
$smarty->assign("innerbody","sim.tpl");
$smarty->display("main.tpl");
session_destroy();
?>
Monday, September 1, 2008
LDAP Authentication, PHP
$ds=ldap_connect("***.***.**.**",389); // must be a valid LDAP server!
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
$r=ldap_bind($ds,$username,$password_ldap);
if($r){
$sr=ldap_search($ds, "DC=humaaaaa,DC=com", "(CN=*)") or die('LDAP SEARCH ERROR
');
//$sr=ldap_search($ds, "DC=".$domainname2[0].",DC=".$domainname2[1]."", "(CN=*)") or die('LDAP SEARCH ERROR
');
if(!$sr){
echo "<script>window.location='login.php?status=false'</SCRIPT>";
}else{
$noof_user=ldap_count_entries($ds, $sr); // calculate no. of records found
if($noof_user>=1){
$info=ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++) {
$givennname=$info[$i]["name"][0];
}
echo "<script>window.location='index.php?session_user=".$username."&access=valid'</SCRIPT>";
}else{
echo "<script>window.location='login.php?status=false'</SCRIPT>";
}
?>