Posted on November 16, 2009. Filed under
Coding,
Scripts,
Security.
1 Comment »
1) Tracking – In addition with cookies, IP addresses can be useful for tracking individual computers or networks. Take example one of the worlds greatest tracking analysis websites—Google Analytics (aka Urchin). Using IP Based information, Google can track, look up past visits, know what pages you visited, and what pages you came from (using http refer). IPs can give the anonymous visitor a name and collect data on that name.
2) User Interactivity – Display a user online script or even develop an online chatting program based on IP availability. With Session Handling, you could have people interact with each other by classifying IPs and logged in users that match those IP Addresses. Majority of online games are based using IPs. Though Session Handling could also provide user interactivity alone..
3) Ban Hammer – The three most effective way of banning someone off your website is Email, Username, and IP Address. Email and username are only available if users have the option to register their name. IP Addresses can be recorded without the user knowing. The only backdraw to this is if you ban an IP thats networking 10 computers, all 10 computers will be banned. That is the only downside when using IP as a ban hammer (though used commonly across the web).
4) Exceptions – Want to make a private viewing site specific towards a network? IP Exception (along with Cookies) are excellent. Give people cookies, record their IP Address, show them a sneak peak of what you’re working on. Great for showing a specific client how much work has been completed (if your a web developer) or if your just showing a small crowd of people a video and not want to program a login script.
Posted on May 28, 2009. Filed under
Coding,
Random,
Scripts.
1 Comment »
If your looking to gather data from Geometry Wars 2 from your Microsoft Xbox Live Gamertag but can’t seem to find the source or can’t figure out how to decipher the source look no further as I’ve provided a class that does all the work for you.
http://mattloinfo.com/source.php?file=class.leaderboard.php is the source file (I named it leaderboard because its based on the data of their leader boards).
Simpler than SimpleXML extension
1
2
3
4
5
6
7
8
9
10
11
12
13
| <?php
include("class.leaderboard.php");
$r = new leaderboard('php developer');
$define = $r->data('evolved', 'king', 'sequence');
if($define !== false) {
// testing
echo '<pre>';
print_r($define);
echo '</ pre>'; // had to add a space due to glitch in the WP plugin :\
} else {
echo 'Invalid Gamertag';
}
?> |
$r->data() is versatile! You can provide 1 or all 6 game types in the game and it’ll spit out an array filled with them.
5
| $define = $r->data('pacifism'); |
or…
5
| $define = $r->data('deadline', 'king', 'evolved', 'pacifism', 'waves', 'sequence'); |
Any improvements you see please comment back. Also remember to cache your data. I’m releasing a small application that utilizes this feature and is cached every hour to prevent over usage of the API. Unlike twitter’s API I don’t think there is a call limit (or its not addressed anywhere), so please be courteous and cache your data whether it’s every 2 minutes or every 2 hours, it always helps to reduce over usage of an API (and improves loading time in between).
Posted on May 10, 2009. Filed under
Coding,
Concepts,
Scripts,
Security.
2 Comments »
Had a few people ask me on windows live about the steps in preserving data in my PHP and I’d just respond “MySQL”, but I forgot to tell them that sensitive information needs to be handled differently. Storing information like passwords and “private numbers” should be encrypted and/or should have keys for the information.The simplest way to encrypt data is by the crypt functions in PHP.
// this is a general example of post data handling
$password = md5($_POST['pass']);
// another example
$password = sha1($_POST['pass']);
These are prime examples because they are not as easily reversible but they aren’t the world’s number one dependable algorithm. How to break md5 and other hash functions is a prime example in ways to break these encryption processes. I’m simply showing you these methods because general public won’t break them and they are secure enough where someone computer programming illiterate will fail and give up (presumably). So these functionality are dependable enough to store simple private data but not strongly recommended to store info like credit card or social security numbers. Also “rainbow tables” have been increasingly dependable for cracking an md5 encryption next to user submitted info like http://md5decryption.com/.
Do not use reversible encryption methods like base64
// encrypt
$var = base64_encode('hello world');
// decrypt
echo base64_decode($var); // exposed!
MD5 and Sha1 do not have decrypt functions (in php.net’s function database).
Posted on May 4, 2009. Filed under
Coding,
Concepts,
Scripts,
Websites.
1 Comment »
Image rollover is a very common design method on websites but many people use different methods in how they code their image rollover. The following method will show the best way to utilize the image rollover effect.
This will be a CSS class designated for a specified <a> tag.
.image1 {
background-image: url("path/to/image/normal.gif");
height: 100px;
width: 100px;
display: block;
}
.image1:hover {
background-image: url("path/to/image/hover.gif");
height: 100px;
width: 100px;
display: block;
}
After writing up the CSS, create the code in the HTML side
<a class="image1" href="#">Test</a>
The following will result in a 100 x 100 pixel rollover image link that can be used over and over, cross-browser.
Now the main issue with this is the loading aspect of the rollover image. When you declare it in the css, it not executed until the proper conditions are met (mouse hover). Meaning the hover.gif will not load until the user positions the mouse over the designated link. This will result in a quick blink in the image because its still loading when you put your mouse over it. To fix this you need to preload in javascript.
var test = new Image();
test.src = 'path/to/image/roll.gif';
Every rollover image is loaded along with the page and the “blink load” is no longer there. A clean transition from image to image on hover is established.
If your site is all custom coding, try making a PHP class that does all this for you. Create a public function that has the parameters of normal and rollover (and any other feature you want to add). Have it output the individual CSS class per image, a preload variable in the javascript, and the actual <a> tags within the html. A total of 3 output functions, 1 input functions, and unlimited processing functions in the class. This will save you a lot of time in coding and it will produce valid w3c coding. This will also eliminate the use of built-in methods that are in programs such as Adobe Dreamweaver and Microsoft FrontPage.
Posted on April 10, 2009. Filed under
Coding,
Scripts,
Websites.
No Comments »
This script will randomize images. Useful for ads or simply a change of scenery. Link capabilities are in this script. Please comment back, I would like to hear everyone’s response.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| <?php
// Created by Matt Lo, very simple :)
class random_images {
// store images
protected $_images = array();
// no constructor needed
// properties per image, protected, all parameters are strings
// $location = path/to/image.jpg, REQUIRED
public function define_image($location, $title=NULL, $link=NULL, $target='_blank') {
// html code for image with variables
// removing border, you can edit it out or leave it in
$image = '<img src="'.$location.'" alt="'.$title.'" style="border: none;" />';
// if link param has value to it...
if($link != '') {
$image = '<a href="'.$link.'" target="'.$target.'">'.$image.'</a>';
}
// array, key index starts at 0
$this->_images[] = $image;
}
public function display() {
// randomize the array by finding max
$rand_int = mt_rand(0, count($this->_images)-1);
return $this->_images[$rand_int];
}
}
// Usage
// NOTE: You can put the class into a separate page, then include it
// start
$image = new random_images();
// example 1
$image->define_image("http://cdn.joomla.org/images/logo.png", 'testing j');
// lets add a mix of linked images
$image->define_image("http://drupal.org/sites/all/themes/bluebeach/logos/drupal.org.png", 'drupal', 'http://drupal.org');
// output
echo $image->display();
?> |
Example: http://mattloinfo.com/scripts/random_image.php