Monday, January 17, 2011

Disable copy paste and autocomplete for textbox in HTML

Disable copy paste and autocomplete for textbox in HTML

<input size="25" name="name" id="name' maxlength="20" onCopy="return false" onDrag="return false" onDrop="return false" onPaste="return false" autocomplete="off" />

Saturday, January 15, 2011

Login Screen Shaking

Shaking the Login Screen.  when u can refresh the page and submit the page....

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
          addLoadEvent = function(func){
            if (typeof jQuery!="undefined")
                jQuery(document).ready(func);
           
            else if ( typeof wpOnload!='function'){
                wpOnload=func;
            } else {
                var oldonload=wpOnload;
                wpOnload=function(){
                    oldonload();
                    func();
                }
            }
        };
       
        function s(id,pos){
            g(id).left = pos+'px';
        }
        function g(id){
            return document.getElementById(id).style;
        }
        function shake(id,a,d) {
            c=a.shift();
            s(id,c);
            if(a.length>0){
                setTimeout(function(){
                    shake(id,a,d);
                },d);
            } else {
                try {
                    g(id).position='static';
                    wp_attempt_focus();
                }
                catch(e){}
            }
        }
       
        addLoadEvent(function(){
            var p = new Array(10, 10, 10, 0, -10, -10, -10, 0);
            p = p.concat(p.concat(p));
            var i = document.forms[0].id;g(i).position='relative';
            shake(i, p, 20);
        });
  </script>


</head>
<body onload="document.getElementById('username').focus();">
<table width="90%" cellpadding="0" cellspacing="0" border="0" align="center">
   <tr>
      <td valign="top">
         <form method="post" action="" name="frmLogin" id="frmLogin">
                 <table width="50%" cellpadding="2" cellspacing="2" border="1" align="center">
                         <tr><td height="10px"></td></tr>
                          <tr>
                        <td width="40%"> USERNAME:</td>
                         <td width="60%">
                                 <input type="text" name="username" id="username" autocomplete="off" />
                      </td>
                      </tr>
                       <tr>
                       <td>PASSWORD: </td>
                      <td>
                       <input type="password" name="password" id="password" autocomplete="off" />
                   </td>
               </tr>             </table>
      </form>
  </td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
    function wp_attempt_focus(){
        setTimeout( function() {
            try {
                d = document.getElementById('username');
                d.value = '';
                d.focus();
            } catch(e){}
        }, 200);
    }
     wp_attempt_focus();
    if(typeof wpOnload == 'function')wpOnload();
  </script>

Saturday, January 8, 2011

Sort An Array of String Without Using PHP Function

To sort an array of string without using php function?

try this...

$str = array(“Z”,”c”,”A”,”C”,”E”,”B”,”M”,”N”);
$array_length = sizeof($str);

for($x = 0; $x < $array_length; $x++) {

for($y = 0; $y < $array_length; $y++) {

if(strcasecmp($str[$x],$str[$y])<0) {

$hold = $str[$x];
$str[$x] = $str[$y];
$str[$y] = $hold;
}
}
}

echo "<pre>”;
print_r($str);
echo “</pre>”;

get last day of the previous month in PHP

Get Last Day Of The Previous Month


$date = "2010-12-31";

list($yr,$mn,$dt)  = split('-', $date);         // separate year, month and date
$time_stamp        = mktime(000$mn0$yr);   // Create time stamp
$last_month_last_day = date("Y-m-t", $time_stamp);

echo "last_month : " . $last_month";
ouptut : 2010-11-30...

get last day of the current month in PHP

Get Last Day Of The Current Month


To get the last day of the month so got this piece of code.
try the following code all are different format....

date('Y-m-d', strtotime('-1 second', strtotime(date('m') . '/01/' . date('Y') . '00:00:00')))

date(“Y-m-d”,mktime(0,  0,  0, (date(‘m’) + 1), 0, date(‘Y’)))

strtotime(‘+1 month -1 second ‘ . date(‘Y’) . ’-’ . date(‘m’) . ’-01′ );

date(“Y-m-t”); //t = number of days in the month

date(“Y-m-d’,mktime(0, 0, 0,  2, 32, 2008));

date(‘t’,strtotime(“last month”));

date(‘D Y-m-t’, strtotime(“last month”))