Just wanted to quickly post two PHP snippets that I find helpful at times. The first of the two snippets is arrayInsert, arrayInsert will return an array after placing a value at a specified index in an array and move all the elements after the insertion down one. There are three parameters; $array, $value, and $index.
$array should be pretty self explanatory, this is the array that you would like to insert an element into. $value, is the vale that you would like to insert, this can be any data type. Last is $index, $index is where you want to place the new value within the array. Remember that the first element in an array starts with an index of 0.
function arrayInsert($array, $value, $index){
//Loops through array pushing everything back one
for($i = count($array)-1; $i >= $index; $i--)
$array[$i+1] = $array[$i];
//Inserts the new value
$array[$index] = $value;
return $array;
}
Read More…
Have you ever looked on forums and wonder how people get images that display your IP address in their signature? In this post I will show you how to not only get and display the users IP address but also their browser information and host name. I’m going to try and explain how this can be achieved without going into to much detail.
Getting Started
Before we do anything lets set the header content-type to image/jpeg, to do this add the follow one line of code to the top of your PHP file.
header ("Content-type: image/jpeg");
Now that we have told PHP what it is exactly that we will be displaying, we can start to gather the user’s information.
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
/*wordwrap() will add a new line symbol after a specified amount
of characters, in our case 50*/
$browser = wordwrap($browser,50, "\n");
/*After we create the new lines we will need to explode the
$browser string into an array. (see more later)*/
$browser = explode("\n", $browser);
Read More…
This tutorial will show you how to access your computer’s localhost for a remote machine. We will need to forward incoming requests to the computer with localhost setup on it.
Step One: Gathering Information
Windows: Click Start>Run and type cmd and press <Enter>. A DOS windows will come up, when it does type “ipconfig/all” and press <Enter>. What we came her for are the lines “Default Gateway” and “ip address”, after you locate these lines write them down to be used later.
Mac: Open Applications>Utilities>Terminal. In the terminal window type “ipconfig getpacket en0″ if you have an Ethernet connection, or “ipconfig getpacket en1″ for wireless. What we came her for are the lines “yiaddr” and “siaddr”, after you locate these line write them down to be used later.
Now, we need to get our IP address for this go to whatismyip.com and write down that number as well.
Read More…
A dynamic theme in WordPress is key if you want to have a clean and organize site. WordPress offers ways to completely change a theme based on whatever the current page is.
One of the first sites I made in WordPress consisted of a bunch of different pages within my theme. Later on I found out that all my pages could be compiled into one, using the tricks below.
The Problem: You want to display the subpages of the current page
The Solution:
wp_list_pages("child_of=".$post->ID."&title_li=");
The Problem: You want to display the subpages of a different page other than the current one
The Solution:
$page = get_page_by_title('Residences');
wp_list_pages("child_of=".$page->ID."&title_li=");
The Problem: You want to test to see if the current post is in a curtain category
The Solution:
if (in_category('home')) {//is category}
Read More…
Not all browsers are created equal, CSS is interpret different ways, what looks perfect in one browser may not look to hot in another. While I do not recommend relying on hacks, but instead developing your code in such a way to not need them. Sometimes there are situations where applying styles to certain browsers is needed.
/*IE 7 and Modern Browsers*/
html>body #header {height: 25px;}
/*Modern Browsers (not IE 7)*/
html>/**/body #header {height: 25px;}
/*Firefox*/
#selector[id= header] {height: 25px;}
/*Hide from IE-Mac*/
/* Hide from IE-Mac \*/
#header {height: 25px;}
/* End hide */
/*IE 5*/
#header {height: 25px; height /**/:/**/ 50px;}
/*Second value will be ignored my IE 5 but not others*/
/*IE 6 and Below*/
* html #header {height: 25px;}
#header {_height: 25px;}
/*IE 7*/
*:first-child+html #header {height: 25px;}
/*Opera 9 and Below*/
html:first-child #header {height: 25px;}
/*Safari*/
html[xmlns*=""] body:last-child #header {height: 25px;}
Know any CSS hacks for browser detection that weren’t mentioned? Please share them!
XML is a huge part of AJAX, considering that AJAX is an acronym for Asynchronous JavaScript and XML. jQuery is no doubt one of the most powerful and popular JavaScript libraries out there. jQuery has made parsing XML a lot easier, faster, and cleaner.
The XML
The XML that I’m going to parse is a small phonebook with three people in it. Each person has a name, email, phone number, and an address. We are going to read in the information of each person and display them. To find out more about XML syntax see W3School’s XML Syntax.
<?xml version="1.0"?>
<phonebook>
<person>
<name>Joe A. Doyle</name>
<email>joe@example.com</email>
<phone_number>901-795-3338</phone_number>
<address>3102 Burton Avenue Memphis, TN 38118</address>
</person>
<person>
<name>Michael D. Montgomery</name>
<email>MichaelDMontgomery@example.com</email>
<phone_number>907-793-5822</phone_number>
<address>3295 Kidd Avenue Anchorage, AK 99501</address>
</person>
<person>
<name>Linda D. Serrano</name>
<email>LindaDSerrano@example.com</email>
<phone_number>978-793-2440</phone_number>
<address> 3725 Christie Way Westborough, MA 01581</address>
</person>
</phonebook>
Getting Start with jQuery
Let’s start off by including jQuery into our page.
Before we have jQuery parse the XML we need to make sure the DOM (Document Object Model) is loaded. We do this by simply adding the following code.
$(document).ready(function(){
//Everything will go inside here…
});
Read More…
All the themes below came from freethemelayouts.com , freethemelayouts is one of the best places I have found for WordPress themes.
Read More…
With CSS3 being rolled out to major browsers it’s time to learn about some of its many features. While IE doesn’t support much (if any) CSS3, Microsoft has announced that it will be supported in IE9. One of my favorite features of CSS3 is the ability to create rounded corners using pure CSS.
In this article I’m going to use images as my examples, so that my friends using Internet Explore will be able to see what they’re missing.
Syntax for border-radius
/*Mozilla*/
-moz-border-radius: /*horizontal and vertical radii*/;
-moz-border-radius-topleft: /*horizontal and vertical radii*/;
-moz-border-radius-topright: /*horizontal and vertical radii*/;
-moz-border-radius-bottomright: /*horizontal and vertical radii*/;
-moz-border-radius-bottomleft: /*horizontal and vertical radii*/;
/*WebKit*/
-webkit-border-radius: /*horizontal and vertical radii*/;
-webkit-border-top-left-radius: /*horizontal and vertical radii*/;
-webkit-border-top-right-radius: /*horizontal and vertical radii*/;
-webkit-border-bottom-right-radius: /*horizontal and vertical radii*/;
-webkit-border-bottom-left-radius: /*horizontal and vertical radii*/;
Read More…