29 May 2017

How to change localhost to ip address in wamp server

Port Forwarding

In order to be reached by the world, you should tell your gateway where is your web server. All incoming request on port 80 should be redirected to your own private IP address. Even this process may vary; it really depends on your router. By the way, this is what you basically want to do: forward every request on port 80 to 192.168.1.27 (of course you must use your own IP address). But since the router’s web server already keeps the port 80 busy, here’s what you can do:


  • Move the gateway’s web interface to another port;
  • Move your web server to another port.


I’ll pick the last one, since it’s usually easier to do, and the first option is not always possible. So, let’s change the port: 

Just go to httpd.conf file, for ex. under WAMP environment its situated at:
File path: C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf


New Version of WAMP uses these 2 lines:
Listen 0.0.0.0:80
Listen [::0]:80

Change it to:

Listen 0.0.0.0:8033
Listen [::0]:8033


Next go to edit ServerName localhost:80 to your requirement for ex.
Find  ServerName localhost:80

Change it to:

ServerName localhost:8033

Also find this line:
#   onlineoffline tag - don't remove
    Require local

Change it to:

#   onlineoffline tag - don't remove
    Require all granted



OLD Version:
Find 
Listen 80

Change it to:

Listen <port number>
for example:
Listen 8080
And restart the server. Now go to http://localhost:8080 and check that everything went as expected.


Restart Apache and its done !!

Now, you can access with your URL:




http://localhost:8033 or http://192.168.1.1:8033

26 May 2017

How to Use Shortcode in your WordPress Sidebar Widgets (Text)

Just Add the following short code in your theme function.php
// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');
Now check it ...


Don’t auto-p wrap shortcodes that stand alone use this like same
add_filter( 'widget_text', 'shortcode_unautop'); 

13 Sept 2016

How Capture Left, Right and Middle Mouse Click with jQuery

$('body').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Left Mouse button clicked.');
            break;
        case 2:
            alert('Middle Mouse button clicked.');
            break;
        case 3:
            alert('Right Mouse button clicked.');
            break;
        default:
            alert('You have a strange Mouse!');
    }
});





Reference:
http://api.jquery.com/event.which/
http://www.w3schools.com/jsref/event_button.asp
http://stackoverflow.com/questions/1206203/how-to-distinguish-between-left-and-right-mouse-click-with-jquery

25 Feb 2016

One Gmail Account = Multiple Test Email Addresses


Don't know about you but a lot of what I do requires having access to multiple email addresses (testing websites that require signup etc). To aide my development I have a few email accounts I use - a Gmail, a Hotmail, a Yahoo and a Google Apps one (my main account). That's only four addresses though, which can be quite limiting at times.
In steps Gmail. If you have a Gmail account then you have access to "infinite" email addresses using that one account.
The Gmail account I use for general testing is:
myname@gmail.com (I left a t off on purpose)
But I could also use any of the following:
myname+1@gmail.com

myname+2@gmail.com

myname+3@gmail.com

myname+123456789@gmail.com, etc etc,.

You get the idea. You can tack a + sign and then any random string after it to invent a new email address. Obviously it still delivers to your Gmail account and it lets you signup to a website over and over as a "different" user.


17 Feb 2016

Simple PHP pagination example using MySql database

<?php
$num_rec_per_page=10;
mysql_connect('localhost','root','');
mysql_select_db('apex1');
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$sql = "SELECT * FROM student LIMIT $start_from, $num_rec_per_page";
$rs_result = mysql_query ($sql); //run the query
?>
<table>
<tr><td>Name</td><td>Phone</td></tr>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
?>
            <tr>
            <td><?php echo $row['Name']; ?></td>
            <td><?php echo $row['Phone']; ?></td>          
            </tr>
<?php
};
?>
</table>
<?php
$sql = "SELECT * FROM student";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result);  //count number of records
$total_pages = ceil($total_records / $num_rec_per_page);

echo "<a href='pagination.php?page=1'>".'|<'."</a> "; // Goto 1st page

for ($i=1; $i<=$total_pages; $i++) {
            echo "<a href='pagination.php?page=".$i."'>".$i."</a> ";
};
echo "<a href='pagination.php?page=$total_pages'>".'>|'."</a> "; // Goto last page
?>