uniqid generates it's ids from a timestamp plus some entropy so it's highly
unlikely (though not impossible) to get the same id twice.
I think the php-doc's example for uniqid is wrong. There's no sense in
creating an md5 hash from the id, since md5 doesn't get you any advantages
here (only extra cpu cycles and the -remote- possibility of two unidentical
ids to get the identical hashes). md5 has collisions, so using it to wrap an
uniqid is a bad idea imho.
If you're still paranoid, you can combine microtime() microseconds with some
other random source, but uniqid alone is more than in enough in most cases.
There are some examples floating on the 'net, you can also combine the data
from the particular request (phone number, ip, etc) to add some extra
entropy.
Storing the id's on a database to avoid reusing it would be a _very_ unwise
thing to do: You'd have to check each id against the database records!
(maybe millions of records?). I'd rather increment a counter or use
last_insert_id() as unique identifier...
Hope it helps,
Alejandro
On Sat, Mar 8, 2008 at 2:04 PM, Khary Sharpe <[EMAIL PROTECTED]> wrote:
> Clarence ,
>
> open up /var/www/mmsc.php and add
>
> function_that_generates_a_unique_id()
> {
>
> return md5(uniqid(rand(), true));
> }
>
>
> This will produce an id with length 32 characters, this may be too long
> but, you can always change the above to shorten it.
>
> The function name could be renamed to something better like getUniqueId,
> just remember to update line 20 to match the name you change it to.
>
> If you really want it to be unique, you should store all generated IDs to
> a database, and not resend what already has been inserted to the db.
>
> k#
>
>
>
> Clarence Carino wrote:
>
> thanks for the code
>
> i copied and paste the code into my htdocs folder.
>
> then changed the url,country code,phone(is this the sender's phone
> number?), push url(some image link from another website),text and smsc_id.
>
> then i ran the file into my browser but returned with an error:
> Fatal error: Call to undefined function
> function_that_generates_a_unique_id() in /var/www/mmsc.php on line 20
>
> maybe i'll debug tom since its 11pm here
> and yes. bearerbox, wapbox and smsbox are running
>
> thanks
>
>
>
>
>
--
Alejandro Guerrieri
Magicom
http://www.magicom-bcn.net/
LinkedIn: http://www.linkedin.com/in/aguerrieri