Name:
Anonymous
2007-08-15 9:47
ID:rAGjFXj3
What's a good way to generate trip codes like 4chan uses? Taking the user IP as an argument.
Name:
Anonymous
2011-02-07 3:57
<?php
$ALPHABET = "0123456789!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
function tripcode($ip) {
$ip = "127.0.0.1";
$salt = date();
$crypt = crypt($ip, $salt);
$trip = "";
for(int i=0; i<strlen($crypt); i++) {
int idx = ((int) $crypt[i]) % strlen($ALPHABET);
$trip .= $ALPHABET[idx];
}
return $trip;
}
?>