Tuesday, August 31, 2010

Javascript function to check Password Strength

There is few line of code for check strength at client side with the help of Javascript and CSS.

In this code JS function will check the combination of password by found simple character and numeric character and special character.  and Check length of password it should be more or equal of 6.

Password with simple only character or number will week and with combination of character and number will medium and with character and number and special character is strong.

Css Code 
.strength0
{
width:250px;
background:#cccccc;
}

.strength1
{
width:50px;
background:#ff0000;
}

.strength2
{
width:100px;
background:#ff5f5f;
}

.strength3
{
width:150px;
background:#56e500;
}

.strength4
{
background:#4dcd00;
width:200px;
}

.strength5
{
background:#399800;
width:250px;
}

Javascript Function Code

function passwordStrength(password,passwordStrength,errorField)
{
var desc = new Array();
desc[0] = "Very Weak";
desc[1] = "Weak";
desc[2] = "Better";
desc[3] = "Medium";
desc[4] = "Strong";
desc[5] = "Strongest";

var score   = 0;

//if password bigger than 6 give 1 point
if (password.length > 6) score++;

//if password has both lower and uppercase characters give 1 point
if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

//if password has at least one number give 1 point
if (password.match(/\d+/)) score++;

//if password has at least one special caracther give 1 point
if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;

//if password bigger than 12 give another 1 point
if (password.length > 12) score++;

passwordStrength.innerHTML = desc[score];
passwordStrength.className = "strength" + score;
}



Html Code of Use it



<input id="password" name="password" onblur="passwordStrength(this.value,document.getElementById('strendth'),document.getElementById('passError'))" size="40" type="password" value="&lt;?=$getRs[0]['contact_person_name']?&gt;" />
<span id="passError"></span><span id="strendth"></span>

Working Output 


For Very weak and weak


pass:- abcdef or abcdef123


for better pass:-abcdef12345


for strong 



Wednesday, August 4, 2010

Dynamic Pagination by Selecting Page No

Pagination by selecting page no for navigation,


This code will help u send page no as parameter in url for navigate in paging.

we send page no 1,2,3 not sending record start position for record show or navigate.




//paging style css code start


.paging { padding:10px 0px 0px 0px; text-align:center; font-size:13px;}
  .paging.display{text-align:right;}
  .paging a, .paging span {padding:2px 8px 2px 8px;}
  .paging span {font-weight:bold; color:#000; font-size:13px; }
  .paging a {color:#000; text-decoration:none; border:1px solid #dddddd;}
  .paging a:hover { text-decoration:none; background-color:#6C6C6C; color:#fff; border-color:#000;}
  .paging span.prn { font-size:13px; font-weight:normal; color:#aaa; }
  .paging a.prn { border:2px solid #dddddd;}
  .paging a.prn:hover { border-color:#000;}
  .paging p#total_count{color:#aaa; font-size:12px; padding-top:8px; padding-left:18px;}
  .paging p#total_display{color:#aaa; font-size:12px; padding-top:10px;}



//paging style css code end


 


 


// paging php code start


$num; //total no of record from sql query


$display;//no of record display on page


$noDisplayPageNo=10; // no of page no range want to show on page


$query=""; // addition parameter or sending data need to send with page no in url


$display=10;
if(!isset($_REQUEST['init']) || $_REQUEST['init']==""){
$init=$start=0;

}else{
$init=$_REQUEST['init'];
$start=($init)*$display;
}


$pages=ceil($num/$display);

$current = ($start/$display)+1;

$startpageNo=max($current-intval($noDisplayPageNo/2), 1); // start page no range
$endpageNo=$start+$noDisplayPageNo-1; // end page no range



if(strlen($query)>0){
$query = "&amp;".$query_string;
}


echo '<div class="paging">';

if($current==1) {
echo '<span class="prn">&lt; Previous</span> ';
} else {
$i = $current-1;
//echo '--'.$i;
echo '<a class="prn" title="go to page '.$i.'" rel="nofollow" href="'.$_SERVER['PHP_SELF'].'?init='.($i-1).$query.'">&lt; Previous</a>';
echo '<span class="prn">...</span> ';
}



for ($i = $startpageNo; $i <= $endpageNo && $i <= $pages; $i++){
if($i==$current) {
echo '<span>'.$i.'</span> ';
} else {
echo '<a title="go to page '.$i.'" href="'.$_SERVER['PHP_SELF'].'?init='.($i-1).$query.'">'.$i.'</a> ';
}
}


if($current < $pages) {
$i = $current;
echo '<span class="prn">...</span> ';
echo '<a class="prn" title="go to page '.$i.'" rel="nofollow" href="'.$_SERVER['PHP_SELF'].'?init='.$i.$query.'">Next &gt;</a> ';
} else {
echo '<span class="prn">Next &gt;</span> ';
}


if ($total != 0){
//prints the total result count just below the paging
echo '(total '.$pages.' results)</div>';
}

Friday, May 28, 2010

Integrate Firebug Lite with all browser

Integrate Firebug lite with all available browser like Crome,Safari,IE

firebug is most advance tool for correct or check web page design like css,html tags.

It hard to install firebug to all browser. only mozilla firefox support the installation of firebug.

For using firebug in browser just copy below code and past it to before &lt/body &gt tag. So firebug lite link will appear on click firebug will work for that page on which that code present.

<a href="javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E=F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','1.3.0.3','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');">Firebug Lite</a>

Wednesday, May 5, 2010

Php Script for Check Email open

How to check that send email is open by receiver or not

If we send email use Php mail() function and want that you get information when receiver open that mail or want to keep record of open mail send in mass sending of mail using Php mail() function. To do that we use following code.




$to=""; //email receiver id
$subj=""; // subject of mail
$msg=""; // message that send to receiver
$senderheaders  = "From: news@example.com\r\n";
$senderheaders .= "Content-type: text/html\r\n";
$senderheaders.="<img src=\"http://www.example.com/trackemail.php?receiverId=$id\" width=\"1\" height=\"1\" />";

mail($to,$subj,$msg,$senderheaders);
?>

In above code we send image of 1*1px with the header of the mail. when receiver open that mail that will send back to tracking file of sender site and tell them that email is check by receiver.




Monday, May 3, 2010

Integration of CCAVENUE Payment gateway

Integration of CCAVENUE Payment Cart in Your Shopping Section 


CCavenue is most popular Payment gateway for online Shopping. It provide payment through using International credit card as well using your Bank (who have bond with CCavenue) online Account or using it's debit card(ATM card). It is one of the most secure place for given your money to online shop.

For Integrate it with your website you should have ccavenue account and they give you a merchant id and a unique key for your site that is most important for money transaction.


Php Function's Require TO Validate Require Value for CCAvenue Payment.


<?php


function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
  {
  $str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
  $adler = 1;
  $adler = adler32($adler,$str);
  return $adler;
  }


function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
  {
  $str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
  $adler = 1;
  $adler = adler32($adler,$str);

  if($adler == $CheckSum)
  return "true" ;
  else
  return "false" ;
  }


function adler32($adler , $str)
  {
  $BASE =  65521 ;


$s1 = $adler & 0xffff ;
  $s2 = ($adler >> 16) & 0xffff;
  for($i = 0 ; $i < strlen($str) ; $i++)
  {
  $s1 = ($s1 + Ord($str[$i])) % $BASE ;
  $s2 = ($s2 + $s1) % $BASE ;
  //echo "s1 : $s1 <BR> s2 : $s2 <BR>";


}
  return leftshift($s2 , 16) + $s1;
  }


function leftshift($str , $num)
  {


$str = DecBin($str);


for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
  $str = "0".$str ;


for($i = 0 ; $i < $num ; $i++)
  {
  $str = $str."0";
  $str = substr($str , 1 ) ;
  //echo "str : $str <BR>";
  }
  return cdec($str) ;
  }


function cdec($num)
  {


for ($n = 0 ; $n < strlen($num) ; $n++)
  {
  $temp = $num[$n] ;
  $dec =  $dec + $temp*pow(2 , strlen($num) - $n - 1);
  }


return $dec;
  }
  ?>







CCAvenue Passing Parameter That Require for Complete the Shopping


<?php
    $Merchant_Id = "";//This id(also User Id)  available at "Generate Working Key" of "Settings & Options"
    $Amount = $orderdata[5];//your script should substitute the amount in the quotes provided here
    $Order_Id = $orderdata[0];;//your script should substitute the order description in the quotes provided here
    $WorkingKey = "";//Given to merchant by ccavenue
    $Redirect_Url ="http://www.example.com/shopping.php";
    $Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value
    ?>
<p align="center" style="font-family:Calibri; font-size:18px;"><img src="http://www.example.com/images/loader.gif" alt="loader"></p>
<p align="center" style="font-family:Calibri; font-size:24px;color:#3670A7;">Processing to CCAvenue..............</p>
<form id="form2" method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">
<input type=hidden name=Merchant_Id value="<?php echo $Merchant_Id; ?>">
<input type="hidden" name="Amount" value="<?php echo $Amount; ?>">
<input type="hidden" name="Order_Id" value="<?php echo $Order_Id; ?>">
<input type="hidden" name="Redirect_Url" value="<?php echo $Redirect_Url; ?>">
<input type="hidden" name="Checksum" value="<?php echo $Checksum; ?>">
<input type="hidden" name="billing_cust_name" value="<?= $orderdata[7].' '.$orderdata[8];?>"> <!--Pass Customer Full Name -->
<input type="hidden" name="billing_cust_address" value="<?= $orderdata[9].' '.$orderdata[10];?>"><!--Pass Customer Full Address-->
<input type="hidden" name="billing_cust_country" value="<?= $orderdata[15];?>"> <!--Pass Customer Country -->
<input type="hidden" name="billing_cust_state" value="<?= $orderdata[14];?>"><!--Pass Customer State -->
<input type="hidden" name="billing_cust_city" value="<?= $orderdata[13];?>"> <!--Pass Customer City -->
<input type="hidden" name="billing_zip" value="<?= $orderdata[16];?>"> <!--Pass Customer Zip Code-->
<input type="hidden" name="billing_cust_tel" value="<?= $orderdata[11];?>"> <!--Pass Customer Phone No-->
<input type="hidden" name="billing_cust_email" value="<?= $orderdata[12];?>"> <!--Pass Customer Email address-->
<input type="hidden" name="delivery_cust_name" value="<?= $orderdata[7].' '.$orderdata[8];?>"> <!--Pass Same or other other detail fill by customer-->
<input type="hidden" name="delivery_cust_address" value="<?= $orderdata[9].' '.$orderdata[10];?>">
<input type="hidden" name="delivery_cust_country" value="<?= $orderdata[15];?>">
<input type="hidden" name="delivery_cust_state" value="<?= $orderdata[14];?>">
<input type="hidden" name="delivery_cust_tel" value="<?= $orderdata[11];?>">
<input type="hidden" name="delivery_cust_notes" value="">
<input type="hidden" name="Merchant_Param" value="">
<input type="hidden" name="billing_zip_code" value="<?= $orderdata[16];?>">
<input type="hidden" name="delivery_cust_city" value="<?= $orderdata[13];?>">
<input type="hidden" name="delivery_zip_code" value="<?= $orderdata[16];?>">


</form>



Friday, April 30, 2010

Paypal Webstie Standard Payment Method

Paypal Webstie Standard Payment Method for website

    
When we use Paypal website standard payment method for shopping cart with multiple buy item. On this method customer complete it's shopping on website and the time of payment he completely move to paypal website with complete detail of his buy item name, item qty , item amount and with Total Amount. On paypal site all detail will display as display on his shopping cart. here all necessary field that is will on site like first name, address,etc. will automatically filled and here customer need to just fill their credit card and it’s related field’s to complete the process.    

    
When customer complete the payment process then one url of success payment is also send form the site to paypal (in return input type) site will appear in form button on click on that button customer will reach to success page of website.      

    
There is on link of fail on cancel for not to complete the process.

    






Paypal Require Code:-





<form id="form1" action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="business" value="{$merchantId}" />


<!--merchant paypal id in which payment will go-->
  <input type="hidden" name="cmd" value="_cart" />
  <input type="hidden" name="paymentaction" value="sale" />
  <?php

 // $itemresult result set of customer buy item fetch form order_item table and table where final order item is store
 $i=1;
 while($row = mysql_fetch_array($itemresult))
 {
 $amountinrupee = $row[1];
 $amount = round(intval($amountinrupee)/46.180,2);

 ?>
  <input type="hidden" name="item_name_<?= $i;?>" value="<?= $row[0];?>" />
  <input type="hidden" name="amount_<?= $i;?>" value="<?= $amount;?>" />
  <input type="hidden" name="quantity_<?= $i;?>" value="<?= $row[2];?>" />
  <?php
 $i++;
 }
 ?>
  <input type="hidden" name="first_name" value="<?= $orderdata[7];?>" /><!--customer first name -->
  <input type="hidden" name="last_name" value="<?= $orderdata[8];?>" /><!--customer last name -->
  <input type="hidden" name="address1" value="<?= $orderdata[9];?>" /><!--customer address 1 name -->
  <input type="hidden" name="address2" value="<?= $orderdata[10];?>" /><!--customer add2 name -->
  <input type="hidden" name="email" value="<?= $orderdata[12];?>" /><!--customer email name -->
  <input type="hidden" name="city" value="<?= $orderdata[13];?>" /><!--customer city name -->
  <input type="hidden" name="state" value="<?= $orderdata[14];?>" /><!--customer state name -->
  <input type="hidden" name="country" value="<?= $orderdata[15];?>" /><!--customer country name -->
  <input type="hidden" name="zip" value="<?= $orderdata[16];?>" /><!--customer zip name -->
  <input type="hidden" name="currency_code" value="USD" /><!--currrecy in which payment u need-->
  <input type="hidden" name="upload" value="1" /><!--paypal parameter-->
  <input type="hidden" name="return" value="http://www.example.com/shopcomplete.php" />
  <input type="hidden" name="cancel_return" value="http://www.example.com/shopfail.php" />
  </form>



Thursday, April 29, 2010

Integrate Phpbb3 forum login(session) with website

Integrate Phpbb3 forum login(session) with website
When we use third part tool phpbb3 with your website as site forum there is necessary  to set phpbb3 login session when any user login to website so user can also use forum without re-login to phpbb3 forum because there is many session variable that is require for login to forum and work on it.
Example:-
Website name:-www.example.com
Website forum:- www.example.com/forum/
Website login page:-www.example.com/login.php
There is 3 way to reach to site forum first open/land to index.php page and reach to it’s viewforum.php page and reach to it’s viewtopic.php page
Website forum page use by user:-
www.example.com/forum/index.php,
First we need that user that is register with site also have entry in phpbb3 forum users table and user_group with same user id that is given on site registration time.
When we move site to forum any above forum page than we need to pass that user id as parameter and get that parameter then fetch record from site user table and set all necessary session parameter for keep login on form.



 Forum login session set code:-


//get site user Id
$var_id=$_GET['id'];
//start forum user session
$user->session_begin();
//check user id exist or login 
if($var_id!='')
{
$str="select * from site_members where member_id=$var_id"; 
$qstr=mysql_query($str,$dbc) or die('error in members'.mysql_error());
$fstr=mysql_fetch_array($qstr);
    
   $user->data[user_ip] = $_SERVER['REMOTE_ADDR'];
    $user->data[user_regdate] = 0;
    $user->data[username] = $fstr['first_name'];
    $user->data[username_clean] = $fstr['first_name'];
    $user->data[user_password] = md5($fstr['password']);
    $user->data[user_passchg] = 0;
    $user->data[user_pass_convert] = 0;
    $user->data[user_email] = '';
    $user->data[user_email_hash] = 0;
    $user->data[user_birthday] =  0- 0-   0;
    $user->data[user_lastvisit] = 1238142551;
    $user->data[user_lastmark] = 0;
    $user->data[user_lastpost_time] = 0;
    $user->data[user_lastpage] = index.php;
    $user->data[user_last_confirm_key] = '';
    $user->data[user_last_search] = 0;
    $user->data[user_warnings] = 0;
    $user->data[user_last_warning] = 0;
    $user->data[user_login_attempts] = 0;
    $user->data[user_inactive_reason] = 0;
    $user->data[user_inactive_time] = 0;
    $user->data[user_posts] = 1;
    $user->data[user_lang] = en;
    $user->data[user_timezone] = 0.00;
    $user->data[user_dst] = 0;
    $user->data[user_dateformat] = 'd M Y H:i';
    $user->data[user_style] = 1;
    $user->data[user_rank] = 0;
    $user->data[user_colour] = '';
    $user->data[user_new_privmsg] = 0;
    $user->data[user_unread_privmsg] = 0;
    $user->data[user_last_privmsg] = 0;
    $user->data[user_message_rules] = 0;
    $user->data[user_full_folder] = -3;
    $user->data[user_emailtime] = 0;
    $user->data[user_topic_show_days] = 0;
    $user->data[user_topic_sortby_type] = t;
    $user->data[user_topic_sortby_dir] = d;
    $user->data[user_post_show_days] = 0;
    $user->data[user_post_sortby_type] = t;
    $user->data[user_post_sortby_dir] = a;
    $user->data[user_notify] = 1;
    $user->data[user_notify_pm] = 0;
    $user->data[user_notify_type] = 0;
    $user->data[user_allow_pm] = 1;
    $user->data[user_allow_viewonline] = 1;
    $user->data[user_allow_viewemail] = 0;
    $user->data[user_allow_massemail] = 1;
    $user->data[user_options] = 831;
    $user->data[user_avatar] = '';
    $user->data[user_avatar_type] = 0;
    $user->data[user_avatar_width] = 0;
    $user->data[user_avatar_height] = 0;
    $user->data[user_sig] = '';
    $user->data[user_sig_bbcode_uid] = '3m872xlu';
    $user->data[user_sig_bbcode_bitfield] = 0;
    $user->data[user_from] = '';
    $user->data[user_icq] = '';
    $user->data[user_aim] = '';
    $user->data[user_yim] = '';
    $user->data[user_msnm] = '';
    $user->data[user_jabber] = '';
    $user->data[user_website] = '';
    $user->data[user_occ] = '';
    $user->data[user_interests] = '';
    $user->data[user_actkey] = '';
    $user->data[user_newpasswd] = '';
    $user->data[user_form_salt] = '168ff8093150140f';
    $user->data[session_id] = session_id();
    $user->data[session_user_id] = $fstr["member_id"];;
    $user->data[session_forum_id] = 0;
    $user->data[session_last_visit] = '1238142551';
    $user->data[session_start] = time();
    $user->data[session_time] = time();
    $user->data[session_ip] = $_SERVER['REMOTE_ADDR'];
    $user->data[session_browser] = $_SERVER['HTTP_USER_AGENT'];
    $user->data[session_forwarded_for] = '';
    $user->data[session_page] = 'index.php';  
    $user->data[session_viewonline] = 1;
    $user->data[session_autologin] = 0;
    $user->data[session_admin] = 0;
    $user->data[is_registered] = 1;
    $user->data[is_bot] = '';
    $autologin='true';
    $result = $auth->login($fstr['username'], $fstr['password'], $autologin);
    $result['error_msg']=LOGIN_SUCCESS;
}




Note-

1.    $user->data[session_page] = 'index.php';  

index.php is the value according to page on which it is use like for viewforum.php it will be viewforum.php and for viewtopic.php it will be viewtopic.php

2.
$auth->login($username, $password, $remember, 1, 0)


$username would be the exact username that would be found in the phpBB user table.

$password would be the string to match by (pre-hash, this should be just the original text, the $auth->login() function takes care of converting it into a comparable hash)

$remember is a boolean value, false if no remember me choice, true if user is going to have a 'remembered' session

Monday, March 29, 2010

Control Flow Functions in Mysql

In this post i describe about how to use conditional operation in sql command for retrieving a record form table.
using these function record display according to it's condition.
  these operator are following:-

  1. Case
  2. If
  3. IfNull
  4. Nullif  
Case function:-
   syntax:-
                case condition when value_to_compare1 then result1 when value_to_compare2 then result2 else result3 end;

In above syntax  when condition value is equal to value_to_compare1 then result1 will output other check value_to_compare2 then result2 will output if both comparison fail then result3 execute.

example:-
CASE var WHEN NULL THEN SELECT 'Hi'; ELSE SELECT 'friend.'; END CASE;


If:-
Syntax:-
           select if(condition,true,false) from table ;
In above syntax if condition is true then true comes in result other wise false.


example:-
      select if(id=vlaue,emp_name,emp_dept) from emp where id=value;


IFNULL
    syntax:
           ifnull(value1,value2)
    
ivalue1 is not NULLIFNULL() returns value1; otherwise it returns value2.
 IFNULL() returns a numeric or string 
example:-SELECT IFNULL(1,0);
Nullif:-

   syntax:- nullif(value1,value2);
if value1=value2 then return null other vise value1






Saturday, March 13, 2010

Server environment information in php

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.



$_SERVER[] Element:-


  1. $_SERVER['PHP_SELF'] :- The filename of the currently executing script, relative to the document root.
  2. $_SERVER['argv']:-Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters
  3. $_SERVER['argc']:-Contains the number of command line parameters passed to the script (if run on the command line).
  4.  $_SERVER['GATEWAY_INTERFACE']:-What revision of the CGI specification the server is using.
  5. $_SERVER['SERVER_ADDR']:-The IP address of the server under which the current script is executing.
  6. $_SERVER['SERVER_NAME']:-The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
  7. $_SERVER['SERVER_SOFTWARE']:- Server identification string, given in the headers when responding to requests.
  8. $_SERVER['SERVER_PROTOCOL']:-Name and revision of the information protocol via which the page was requested
  9. $_SERVER['REQUEST_METHOD']:-Which request method was used to access the page
  10. $_SERVER['REQUEST_TIME']:-The timestamp of the start of the request
  11. $_SERVER['QUERY_STRING']:-The query string, if any, via which the page was accessed
  12. $_SERVER['DOCUMENT_ROOT']:-The document root directory under which the current script is executing, as defined in the server's configuration file
  13. $_SERVER['HTTP_ACCEPT']:-Contents of the Accept: header from the current request, if there is one.
  14. $_SERVER['HTTP_ACCEPT_CHARSET']:-Contents of the Accept-Charset: header from the current request, if there is one.
  15. $_SERVER['HTTP_ACCEPT_ENCODING']:-Contents of the Accept-Encoding: header from the current request, if there is one.
  16. $_SERVER['HTTP_ACCEPT_LANGUAGE']:-Contents of the Accept-Language: header from the current request, if there is one.
  17. $_SERVER['HTTP_CONNECTION']:-Contents of the Connection: header from the current request, if there is one.
  18. $_SERVER['HTTP_HOST']:-Contents of the Host: header from the current request, if there is one.
  19. $_SERVER['HTTP_REFERER']:-The address of the page (if any) which referred the user agent to the current page. This is set by the user agent.
  20. $_SERVER['HTTP_USER_AGENT']:-Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page.
  21. $_SERVER['HTTPS']:-Set to a non-empty value if the script was queried through the HTTPS protocol.
  22. $_SERVER['REMOTE_ADDR']:-The IP address from which the user is viewing the current page.
  23. $_SERVER['REMOTE_HOST']:-The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user.
  24. $_SERVER['REMOTE_PORT']:-The port being used on the user's machine to communicate with the web server.
  25. $_SERVER['SCRIPT_FILENAME']:-The absolute pathname of the currently executing script.
  26. $_SERVER['SERVER_ADMIN']:-The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file.
  27. $_SERVER['SERVER_PORT']:-The port on the server machine being used by the web server for communication.
  28. $_SERVER['SERVER_SIGNATURE']:-String containing the server version and virtual host name which are added to servergenerated pages, if enabled.
  29. $_SERVER['PATH_TRANSLATED']:- Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.
  30. $_SERVER['SCRIPT_NAME']:-Contains the current script's path. This is useful for pages which need to point to themselves.
  31. $_SERVER['REQUEST_URI']:-The URI which was given in order to access this page;
  32. $_SERVER['PHP_AUTH_DIGEST']:- When running under Apache as module doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation).
  33. $_SERVER['PHP_AUTH_USER']:-When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the username provided by the user.
  34. $_SERVER['PHP_AUTH_PW']:-When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the password provided by the user.
  35. $_SERVER['AUTH_TYPE']:-When running under Apache as module doing HTTP authenticated this variable is set to the authentication type.
  36. $_SERVER['PATH_INFO']:- Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available.
  37. $_SERVER['ORIG_PATH_INFO']:-Original version of 'PATH_INFO' before processed by PHP.
Url:-http://localhost/testing/serverfunction.php?arg=value&arg1=value2


Output :-

/testing/serverfunction.phpPhp Self
Arrayargv
1argc
CGI/1.1GATEWAY_INTERFACE
127.0.0.1SERVER_ADDR
localhostSERVER_NAME
Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9SERVER_SOFTWARE
HTTP/1.1SERVER_PROTOCOL
GETREQUEST_METHOD
1268480923REQUEST_TIME
arg=value&arg1=value2QUERY_STRING
C:/xampp/htdocsDOCUMENT_ROOT
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5HTTP_ACCEPT
UTF-8,*;q=0.5HTTP_ACCEPT_CHARSET
gzip,deflate,sdchHTTP_ACCEPT_ENCODING
en-US,en;q=0.8HTTP_ACCEPT_LANGUAGE
keep-aliveHTTP_CONNECTION
localhostHTTP_HOST
HTTP_REFERER
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5HTTP_USER_AGENT
HTTPS
127.0.0.1REMOTE_ADDR
REMOTE_HOST
3145REMOTE_PORT
C:/xampp/htdocs/testing/serverfunction.phpSCRIPT_FILENAME
admin@localhostSERVER_ADMIN
80SERVER_PORT
Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 Server at localhost Port 80
SERVER_SIGNATURE
PATH_TRANSLATED
/testing/serverfunction.phpSCRIPT_NAME
/testing/serverfunction.php?arg=value&arg1=value2REQUEST_URI
PHP_AUTH_DIGEST
PHP_AUTH_USER
PHP_AUTH_PW
AUTH_TYPE

Thursday, March 11, 2010

Check Various Credit Card Validation In JS

This is code for check that enter card number with respect to card is valid or u enter wrong card number. Because every card or bank have different digit in his card and it's number.







function checkCreditCard (cardnumber, cardname) {
    
  // Array to hold the permitted card characteristics
  var cards = new Array();


// Define the cards we support. You may add addtional card types.
    
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa",
  length: "13,16",
  prefixes: "4",
  checkdigit: true};
  cards [1] = {name: "MasterCard",
  length: "16",
  prefixes: "51,52,53,54,55",
  checkdigit: true};
  cards [2] = {name: "DinersClub",
  length: "14,16",
  prefixes: "305, 36, 38, 54,55",
  checkdigit: true};
  cards [3] = {name: "CarteBlanche",
  length: "14",
  prefixes: "300,301,302,303,304,305",
  checkdigit: true};
  cards [4] = {name: "AmEx",
  length: "15",
  prefixes: "34,37",
  checkdigit: true};
  cards [5] = {name: "Discover",
  length: "16",
  prefixes: "6011,622,64,65",
  checkdigit: true};
  cards [6] = {name: "JCB",
  length: "16",
  prefixes: "35",
  checkdigit: true};
  cards [7] = {name: "enRoute",
  length: "15",
  prefixes: "2014,2149",
  checkdigit: true};
  cards [8] = {name: "Solo",
  length: "16,18,19",
  prefixes: "6334, 6767",
  checkdigit: true};
  cards [9] = {name: "Switch",
  length: "16,18,19",
  prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
  checkdigit: true};
  cards [10] = {name: "Maestro",
  length: "12,13,14,15,16,18,19",
  prefixes: "5018,5020,5038,6304,6759,6761",
  checkdigit: true};
  cards [11] = {name: "VisaElectron",
  length: "16",
  prefixes: "417500,4917,4913,4508,4844",
  checkdigit: true};
  cards [12] = {name: "LaserCard",
  length: "16,17,18,19",
  prefixes: "6304,6706,6771,6709",
  checkdigit: true};
  
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {


// See if it is this card (ignoring the case of the string)
  if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
  cardType = i;
  break;
  }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
  ccErrorNo = 0;
  return false;
  }
  
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
  ccErrorNo = 1;
  return false;
  }
  
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
  ccErrorNo = 2;
  return false;
  }
  
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
  var checksum = 0;                                  // running checksum total
  var mychar = "";                                   // next char to process
  var j = 1;                                         // takes value of 1 or 2
  
  // Process each digit one by one starting at the right
  var calc;
  for (i = cardNo.length - 1; i >= 0; i--) {






  // Extract the next digit and multiply by 1 or 2 on alternative digits.
  calc = Number(cardNo.charAt(i)) * j;
  
  // If the result is in two digits add 1 to the checksum total
  if (calc > 9) {
  checksum = checksum + 1;
  calc = calc - 10;
  }
  
  // Add the units element to the checksum total
  checksum = checksum + calc;
  
  // Switch the value of j
  if (j ==1) {j = 2} else {j = 1};
  }
  
  // All done - if checksum is divisible by 10, it is a valid modulus 10.
  // If not, report an error.
  if (checksum % 10 != 0)  {
  ccErrorNo = 3;
  return false;
  }
  }


// The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false;
  var undefined;


// We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
  
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
  
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
  var exp = new RegExp ("^" + prefix[i]);
  if (exp.test (cardNo)) PrefixValid = true;
  }
  
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
  ccErrorNo = 3;
  return false;
  }
  
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
  if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the
  // length if all else was hunky dory.
  if (!LengthValid) {
  ccErrorNo = 4;
  return false;
  };
  
  // The credit card is in the required format.
  return true;
  }
  function validateCard (errorField) {
  cardText = document.getElementById('txtCardNumber');
  myCardNo = document.getElementById('txtCardNumber').value;
  myCardType = document.getElementById('cardType').value;
  if (checkCreditCard (myCardNo,myCardType))
  {
  errorField.style.visibility='hidden';
  errorField.innerHTML="";
  cardText.style.border='#339900 solid 1px';
  return "";
  }
  else
  {//alert (ccErrors[ccErrorNo])
  errorField.innerHTML="Credit card number is invalid";
  errorField.style.visibility='visible';
  errorField.style.border='#FF3333 solid 1px';
  errorField.style.background='#FBE3E4';
  errorField.style.color='#8a1f11';
  errorField.style.fontSize='10px';
  cardText.style.border='#FF3333 solid 1px';
  return false;
  }
  }

Friday, February 12, 2010

Contact Me

If Any one want to contact me use following form. and me your suggestion and your view. 

Wednesday, February 10, 2010

Send Mail of Dynamic generate table in php

If we need to send some data comes from database in table format via email to other email automatically to using PHP script like newsletter.


Code:-

<?php
$senderheaders  = "From: dept@xyz.com\r\n";
  $senderheaders .= "Content-type: text/html\r\n";
  
  $subject="Dept Category Item Detail";
  $sendId='test@xyz.com';
  $textTosend='
  
  
  
  <table width="700px" align="center">
  <tr>
  <td colspan="3" align="center"  class="title" height="30px"><strong>Category Item Detail </strong></td>
  </tr>
  
  
  <tr>
  <td >
  <strong>Item Name</strong> </td>
  <td >
  <strong>Item Cost</strong> </td>
  <td >
  <strong>Item Qty.</strong> </td>
  
  
  </tr>';
$selItem="select * from item where cate_id=$Id";
  $itemRs=mysql_query($selItem,$dbc);
  while($itemRow=mysql_fetch_array($itemRs)){
  $itemDetail=itemDetail($itemRow["product_id"],$dbc);
  
  $textTosend.='<tr>
  <td >
  '.$itemDetail["item_name"].' </td>
  <td >
  '.$itemDetail["price_unit"].' </td>
  <td >
  '.$itemRow["quantity"].' </td>
  
  </tr>
  ';
  
  }
$textTosend.='</table><br>
    
    
  ';
if(mail($sendId,$subject,$textTosend,$senderheaders)){
    
    
  echo '<div class="success">Echo Mail Send  SuccessFully</div>';
  }
  ?>