Created
July 23, 2010 21:40
-
-
Save inazt/488078 to your computer and use it in GitHub Desktop.
url-shorten-hash-generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getHash() { | |
$base=1000000; | |
$result = db_query_range('SELECT max(nid)+1 as nextId from {personal}', 0, 1); | |
$offset= db_fetch_object($result)->nextId; | |
$number=$base+$offset; | |
$out = ""; | |
$codes = "abcdefghjkmnpqrstuvwxyz23456789ABCDEFGHJKMNPQRSTUVWXYZ"; | |
while ($number > 53) { | |
$key = $number % 54; | |
$number = floor($number / 54) - 1; | |
$out = $codes{$key}.$out; | |
} | |
return $codes{$number}.$out; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment