scriptygoddess RSS Feed
 
 
 
 

Archive for Script snippet

Get users IP with PHP

Not sure why I haven't posted this before. (or maybe I did and I'm just drawing a blank). Get the IP of the user:
if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
I've also seen it done this way too but for some reason I was under the impression the method above was more reliable:
$ip = [...]

Adjusting the date with php

Will asked about adjusting the date php displays to account for the fact that the server may not be in the same location as you. (I don't think this solved his problem with displaying the actual timezone differently - but thought it was worth putting up anyway…)
I'm sure there are other ways (if you got [...]

Move and resize browser window…

To move a browser window to a specific location on the users screen:
window.moveTo(x,y);
replacing "x,y" with pixel coordinates.
More info here, where they also have the below which will give you the users screen width, height:
screen.widthscreen.height
Also, to resize the browser window:
window.resize(width,height)
Now, before you go all crazy on me - I'm not suggesting people do this for sport [...]

Get first (part of) name

(non blog related post) Needed to use this php function: strchr (alias to strstr).
I had a field that had a person's full name (first and last). 99.999% of the time, the first name and last name were seperated by a space (no Mr. or Mrs. in there) and I needed a script that assumed as [...]

You are currently browsing the archives for the Script snippet category.

Categories

Archives

Bookmarks

WordPress Resources

Meta

Random Stuff