Just another person with internet access
Archive for November, 2007
Gas Station BSOD – Windows: 0, Other OS: 1
Nov 24th
When at the gas station earlier today, this is what I saw on the gas station TV-screen at a near-by pump (sorry for the blurry picture, I wasn’t very close to the pump and my camera on my phone is a little dirty):

PHP Sessions – Quick and dirty
Nov 13th
A session variable is a great way to store information about visitors on your site. For example if a user logs in you could store their username, and the date of login as session variables, then add a file include that checks to make sure the user is logged in before viewing a page.
Below is example code using session variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php echo "Creating session variables... <br />"; $_SESSION['uname'] = "Steve"; $_SESSION['pass'] = "MyPassword"; echo "Displaying session data... <br />"; echo $_SESSION['uname'] . "<br />" . $_SESSION['pass'] . "<br />"; echo "Destroying session data... <br />"; unset($_SESSION['uname']); unset($_SESSION['pass']); echo "Displaying session data again (should be empty)... <br />"; echo $_SESSION['uname'] . "<br />" . $_SESSION['pass'] . "<br />"; echo "Done! <br />"; ?> |
That code, when run will output:
Creating session variables...
Displaying session data...
Steve
MyPassword
Destroying session data...
Displaying session data again (should be empty)...
Done!
The code is very simple to follow, $_SESSION[] variables are created named uname and pass, values are assigned to them and displayed via echo. Then unset() is used to delete the values, thus when echoing the output again the lines are blank. Cake.
If my computer was like the ones in the movies, I wouldn’t use it
Nov 11th
After watching the movie “Live Free or Die Hard”, the latest Die hard movie, a realization I made years ago was refreshed. The movie contains heavy computer-usage scenes as the entire movie revolves around the hacking of the entire U.S. infrastructure. In all of the computer scenes, a distinct sound can be heard every time the computer does something. That sound is a soft beep. A new window pops up, and it beeps, the user clicks, and it beeps, a window resizes, and it beeps. Everything done on the computer is followed by a beeping sound. How annoying.
Would you use a computer that beeps over and over every single time you do something? What about a computer that, instead of displaying text instantly required it to scroll all across the screen, while beeping of course. Would you use that computer? Probably not. The fact is that ‘Hollywood’ computer scenes consist of nothing more than constant scrolling and beeping, for absolutely no reason. That is enough to drive anyone crazy. The question is why do they do this?
PHP Generated iPhone User Images
Nov 10th
I have been screwing around with some PHP using functions like imagecreatefrompng() and ImagePNG() to create a few images that create a ‘signature’ image that can be used on websites, etc.
Image 1:

Useage:
Forums: [img]http://www.rapidhash.com/rapidhash/autosig.php.png[/img]
Image 2:

Useage:
Forums: [img]http://www.rapidhash.com/rapidhash/iphone.php.png[/img]
Image 1 will just display the IP of the user. Image 2 will display the users IP, Browser, and Operating System.
Feel free to use them if you desire where ever you want. Just link to them (do not try to save the image, it will not work if you do).
Enjoy.
Track your site activity in PHP
Nov 6th
Want to know who is visiting your website, when the peak times are, and how people are finding you? It is a lot easier than it sounds. While the code below may be over-simplified, it does get the job done. The code assumes that you have a include in your main source file that opens a database connection, and a code at the end of your source file that closes it.
The code will get the referring page, the date and time of access, and the IP of the users and store it in a table called tracker. You can then easily code a interface to view that database information. Later I will post code for an interface to this data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php // very simple PHP function, call when database connection is open using tracker(); // By Steve Morrissey function tracker() { $referer = $_SERVER["HTTP_REFERER"]; $time = date("F j, Y, g:i a"); $ip = $_SERVER['REMOTE_ADDR']; if($referer == "") { $referer = "Direct hit"; } mysql_query("INSERT INTO tracker (id, referer, ip, accessed) VALUES('', '$referer', '$ip', '$time')") or die(mysql_error()); } // end tracker ?> |



