Showing posts with label Codes. Show all posts
Showing posts with label Codes. Show all posts
Posted by Anonymous Sunday, February 14, 2010 1 comments

1 Send E-mails from localhost

I was so worried that i was not able to send the E-mail from the localhost while using WAMP and i asked to my teacher that how can i send the E-mail from the localhost ? and he instructed me to follow the given instruction. This instruction is for both WAMP and XAMPP users.

1. Now open php.ini  file.
2. search for the STMP attribute. Generally you can find the line “SMTP=localhost“. change the localhost to the smtp server name of your ISP. And, there is another attribute called “smtp_port” which should be set to 25.

3. change the attribute as :


STMP = stmp.wlink.com.np
stmp_port = 25

I made stmp.wlink.com.np as my internet service provider (ISP) is Wlink.com.np

4.Now restart your apache server. so that your php.ini file will be reloaded.


5. now try sending the mail using main() function :)
thats it !!


You might get teh error message like this :


Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing in D:\wamp\www\Website\mail.php on line 28


if you get the error like this the specify the following headers and try again.



    $headers = ‘MIME-Version: 1.0′ . “\r\n”;
    $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;
    $headers .= ‘From: sender@sender.com’ . “\r\n”;
    mail(“you@yourdomain.com”,”subject”,”body”,$headers);

Now it will work :)

You must be using $_SERVER['REMOTE_ADDR'] in PHP to find the visitor's IP address. and you may also know that this will not return the true IP all the time, Because if your client is using the Proxy server then this will return back your client's proxy IP, so this is not correct all the time. to get the real IP of your visitor follow the steps.

First of all you need to make the function :


/*
* ComsGuru.blogspot.com
* Prakash Timilsina
*/
function TraceRealiP()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

Thanks, and i hope this works :)

Posted by Prakash timilsina Monday, January 25, 2010 2 comments

2 JavaScript Hack II

I gave you the cool and effective javascript tick last time. Now i have some other tircks also

They are

#How to use these hack ?
→ just paste the given codes in the address bar of your browser thats it !!
1. To dispaly the Dancing Images



code for this hack are :


javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24;  x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length;  function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style;  DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px";  DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5);  void(0);
Now another hack ..




javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page.");})();



Thats it :)
i hope it works..

Posted by Prakash timilsina Sunday, January 24, 2010 2 comments

2 JavaScript Hack







Do you want to fool your friends or family. then i have a simple trick of javascript. by this trick you can just make any website just like a notepad or word editor.


javascript: document.body.contentEditable = 'true';document.designMode = 'on'; void 0


Paste this code in the address bar of the internet browser.

Thats it

Posted by Prakash timilsina Sunday, January 10, 2010 1 comments

1 Smooth and cool JQuery Popups

Tested in: Firefox, Internet Explorer 6 & 7, Opera (old and 9.52) , Safari & Chrome.






x

Demo!


Your content goes here....







Hey i have an cool popup trick. this is so smooth.
Now lets try.

Make the .html file and include the following..

<!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" dir="ltr">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>yensdesign.com - How to create a stuning and smooth popup in jQuery</title>
  <link rel="stylesheet" href="general.css" type="text/css" media="screen" />
  <script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
  <script src="popup.js" type="text/javascript"></script>
  </head>
<body>
  <center>
  <div id="button"><input type="submit" value="Press me please!" /></div>
  </center>
  <div id="popupContact">
  <a id="popupContactClose">x</a>
  <h1>This is Try</h1>
 <p id="contactArea">
  Your content goes here
 
  </p>
  </div>
 <div id="backgroundPopup"></div>
  </body>
  </html>



After this Make the general.css file and include this :



table {
border-collapse:separate;
border-spacing:0pt;
}
caption, th, td {
font-weight:normal;
text-align:left;
}
blockquote:before, blockquote:after, q:before, q:after {
content:"";
}
blockquote, q {
quotes:"" "";
}
a{
cursor: pointer;
text-decoration:none;
}
br.both{
clear:both;
}
#backgroundPopup{
display:none;
position:fixed;
_position:absolute; /* hack for internet explorer 6*/
height:100%;
width:100%;
top:0;
left:0;
background:#000000;
border:1px solid #cecece;
z-index:1;
}
#popupContact{
display:none;
position:fixed;
_position:absolute; /* hack for internet explorer 6*/
height:384px;
width:408px;
background:#FFFFFF;
border:2px solid #cecece;
z-index:2;
padding:12px;
font-size:13px;
}
#popupContact h1{
text-align:left;
color:#6FA5FD;
font-size:22px;
font-weight:700;
border-bottom:1px dotted #D3D3D3;
padding-bottom:2px;
margin-bottom:20px;
}
#popupContactClose{
font-size:14px;
line-height:14px;
right:6px;
top:4px;
position:absolute;
color:#6fa5fd;
font-weight:700;
display:block;
}
#button{
text-align:center;
margin:100px;
}


Now its trun for the javascript
Make popup.js and include the following


var popupStatus = 0;
function loadPopup(){
    if(popupStatus==0){
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");
        popupStatus = 1;
    }
}

function disablePopup(){
    if(popupStatus==1){
        $("#backgroundPopup").fadeOut("slow");
        $("#popupContact").fadeOut("slow");
        popupStatus = 0;
    }
}

function centerPopup(){
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();
    $("#popupContact").css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2,
        "left": windowWidth/2-popupWidth/2
    });
   
    $("#backgroundPopup").css({
        "height": windowHeight
    });
   
}


$(document).ready(function(){

    $("#button").click(function(){
        centerPopup();
        loadPopup();
    });
               
    $("#popupContactClose").click(function(){
        disablePopup();
    });
    $("#backgroundPopup").click(function(){
        disablePopup();
    });
    $(document).keypress(function(e){
        if(e.keyCode==27 && popupStatus==1){
            disablePopup();
        }
    });

});

Posted by Prakash timilsina Friday, January 8, 2010 0 comments

0 For the codes

I have got a nice trick to write the codes in the blog..
if you want to write < then write &lt;  and if you want to write > then write &gt;
Code decoration



If u want to put like this type of background in the codes then you have to perform the simple trick
Goto Blogger.com > Layout > Edit HTML
Now find

]]>

Now paste the below code just above that


/*code*/
div.code {
border : 2px solid #99cc66;
padding-top:-10px;
padding-left:25px;
margin:0 0 0 0;
line-height:15px;
border:dotted thin #008800;
font-size:13px;
color:#FF0000;
background : #fff url(http://i39.tinypic.com/a47lat.jpg) no-repeat left top;
}
coder {
border: 1px solid #ccc;
display:block;
padding: 4px 4px 5px 4px;
margin: 5px 0px 5px 4px;
font-family:"Courier New", Courier, mono;
overflow: auto;
text-align:left;
width: 480px;
}
thats it,
now if u want to publish any post with the codes then just add this tag just before the code
<div class="code">
Your Codes Here
</div>

Posted by Prakash timilsina Tuesday, January 5, 2010 0 comments

0 Smooth scrolling using JQuery

Last time i gave you the trick to scroll to top! But this trick was not moving so smoothly, So this time i got the great trick to scroll to top!


First of all find :

</body>
Then paste the below code

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'></script>
  <script type='text/javascript'>
$(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()!="0"){$(this).fadeIn("slow")}var scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()=="0"){$(scrollDiv).fadeOut("slow")}else{$(scrollDiv).fadeIn("slow")}});$(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}});
$(function() {
  $("#toTop").scrollToTop();
  });
  </script>
<a href="#" id="toTop">&uarr; Goto Top </a>

Now find :

]]></b:skin>
Then paste the below code just above the above code:

#toTop { width:80px;background:#F4FFBF;border:1px solid #ccc;text-align:center;padding:5px;position:fixed;bottom:10px;right:10px;cursor:pointer;color:#666;text-decoration:none; }

Thats it ;)
if u have any problem the drop the comment


As you know, the user login box of the website contains the following fields username and password. Furthermore, most of them put the “Username” inside user name field and “********” inside password field to save the space within designing. Do u want to make like this ?
Tradition Concept :


New Concept : Put the cursor in the field below and start typing password


<script language="javascript">
function changeBox()
{
document.getElementById('div1').style.display='none';
document.getElementById('div2').style.display='';
document.getElementById('password').focus();
}
function restoreBox()
{
if(document.getElementById('password').value=='')
{
document.getElementById('div1').style.display='';
document.getElementById('div2').style.display='none';
}
}
</script>
<div id="div1"><input name="pass_temp" type="text" value="Password" size="20" maxlength="20" onfocus="changeBox()" />
</div>
<div id="div2" style="display:none"><input name="password" id="password" type="password" value="" size="20" maxlength="20" onBlur="restoreBox()" />
</div>

Posted by Prakash timilsina Friday, January 1, 2010 1 comments

1 Cool JQuery example



This is the simple shuffle effect of the JQuery, you can see the live demo just in the buttom of this page.

You must be thinking to put the same effect in your blog also right ? Now i am going to tech you that how to put this effect in the blog.

1. First of all login to your blogger account and then click on Layout then Edit HTML.

2. Now search for ]]></b:skin> and paste this code :


body {
font: 12px Verdana,Arial, Helvetica, sans-serif;
margin: 10px auto;
width:350px;
}
.container {
width:312px;
margin-top:20px;
}
.msg_body {
border:1px solid #CCCCCC;
padding: 5px;
width: 300px;
background-color:#F4F4F8;
text-align:justify;
position:absolute;
}
.linkclass
{
font-weight:bold;
color:#006699;
}

Now, its time to paste the javascript code.
Paste the following code just after the ]]></b:skin>


<script src='http://roshanbh.com.np/examples/block-shuffle/jquery.js' type='text/javascript'/>
<script type='text/javascript'>
$(document).ready(function()
{
//hide the all div except first one
$(&#39;.msg_body:not(:first)&#39;).hide();
//when the anchor is clicked
$(&quot;a.linkclass&quot;).click(function()
{
//check weather the visible block and clicked link&#39;s block is same or different
if($(this).attr(&quot;href&quot;)!=&quot;#&quot;+$(&quot;.msg_body:visible&quot;).attr(&quot;id&quot;))
{
//reduces the z-index and margin of left side increased and decreased by 400px and hide
$(&quot;.msg_body:visible&quot;).css(&quot;z-index&quot;,&quot;0&quot;).animate({marginLeft: &quot;-=400px&quot;},&quot;500&quot;).animate({marginLeft: &quot;+=400px&quot;},&quot;500&quot;).hide(&quot;1&quot;);
//increase the z-index of the new visible block
$($(this).attr(&quot;href&quot;)).css(&quot;z-index&quot;,&quot;10&quot;).fadeIn(400);
}
});

});
</script>


Now Save Template.
Goto Page Elements sub-tab


Click Add a gadget Then select HTML/JAVASCRIPT then Paste the below code



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xp" class="linkclass">Xp </a>&nbsp;&nbsp;
  <a href="#vista" class="linkclass">Vista</a>&nbsp;&nbsp;
  <a href="#messenger" class="linkclass">Messenger</a>&nbsp;&nbsp;
  <a href="#software" class="linkclass">Softwares</a>

<div class="container">
  <div id="xp" class="msg_body"> <b>XP</b><br/><br/>
  <b>System Shutdown</b><br/>
  The error message came "System Shutdown" Worried about this ? you can stop this unwanted message. you  can Go to Start → Run → type Shutdown -a there. This stops the message which comes there and it will stop the shutdown. If this message comes many times in your computer and if u feel lazy going to the run and typing then you can right-click on the desktop then select new → Shortcut → type Shutdown -a there and click on next lastly...<a href="http://comsguru.blogspot.com/2009/12/system-shutdown.html"><div class="more">
  MORE</div></a>
  </div>
  <div id="vista" class="msg_body"> <b>Vista</b><br/><br/>
  <b>Can I dual-boot Windowx XP and Vista ?</b><br/>
  Few Months ago the windows vista's public release hence compatibility issue with system drivers and software are to be expected, i.e. your favorite games or image editor may not work on vista yet. Fortunately, you can have both Windows XP and windows vista on the same computer, by setting up your PC to dual-boot. Assuming that Windows XP is installed first, creat new partation on hard drive Right-Click on My Computer and choose Manage...<a href="http://comsguru.blogspot.com/2009/10/can-i-dual-boot-windowx-xp-and-vista.html"><div class="more">
  MORE</div></a>
  </div>
  <div id="messenger" class="msg_body"> <b>Messenger</b><br/><br/>
  <b>Find who is invisible in Gtalk :</b><br/>
  Many people now a dayz become invisible in the messenger but they are online. Today in the morning also i was online on the Gtalk but i found my friend was offline. Actually he was online but he was invisible. I came to know that thing after the friend told me later. One of my friend told that there is way to find who is online in Gtalk :1. If you get hte message that " The user is offline and can’t receive messages right now " then your...<a href="http://comsguru.blogspot.com/2009/10/find-who-is-invisible-in-gtalk.html"><div class="more">
  MORE</div></a>
  </div>
  <div id="software" class="msg_body">  <b>Softwares</b><br/> <br/>
  <b>Realtek AC'97 Driver A4.06</b><br/>
  Realtek Drivers and codecs for Realteks series of audio chipsets for motherboards. The package includes: Driver/Application Setup Program RtlRack for Win98/Me/2000/XP and AvRack for Win95/NT4 Realtek Sound Effect Manager (DirectX 8 is required to enable advanced features.) Download...<a href="http://comsguru.blogspot.com/2009/11/realtek-drivers-and-codecs-for-realteks.html"><div class="more">
  MORE</div></a>
  </div>
  </div>

You can modify the content as your wish ;)
Thankx [Roshan Bhattarai]

Drop the comment of you have any problem.

Posted by Prakash timilsina Thursday, December 31, 2009 0 comments

0 How to make "Scrool to top" using JQuery


If your blog have long post then i suggest you to put "Scroll to top" in your blog or website. This enables your visitors to scroll to the top of your blog's page without scrolling the scrolling button on the mouse.
If you want to add this then Follow the instructions,
# Login to your Blogger > Layout > Edit HTML
# Now Find :
</body>
# Now add the below code just after the body tag,

<a href="#" id="backtotop">^ Scroll to Top</a>
  <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'></script>
  <script type='text/javascript'>
    /*-----------------------
  Scroll to top
  Creator : Prakash Timilsina,
ComsGuru.blogspot.com

 -----------------------*/
  $(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()!="0"){$(this).fadeIn("slow")}var  scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()=="0"){$(scrollDiv).fadeOut("slow")}else{$(scrollDiv).fadeIn("slow")}});$(this).click(function(){$("html,  body").animate({scrollTop:0},"slow")})}});
  $(function() {
  $("#toTop").scrollToTop();
  });
  </script>

# Now you have to add some CSS for that, Now find
]]></b:skin>
→Paste the below code just above the above code :

#backtotop {  width:100px;background:#F4FFBF;border:1px solid  #ccc;text-align:center;padding:5px;position:fixed;bottom:10px;right:10px;cursor:pointer;color:#666;text-decoration:none;  }

Goto Top