PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Generating GUID tags with php
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Generating GUID tags with php

Réponse
 
LinkBack Outils de la discussion
Vieux 26/02/2008, 17h58   #1
Gary Hasler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Generating GUID tags with php

Does anyone have any suggestions on generating GUID (Globally Unique
Identifier) tags with php?
They would need to be in the format
4402bd8a-cd51-40ea-99d7-b510e89e344b

Specifically this is for adding accessibility for the PicLens browser
add-on (which uses an .rss file) to some of our photo gallery pages. It
seems to require each thumbnail have an identical GUID tag in both the
html and the rss file.
  Réponse avec citation
Vieux 26/02/2008, 19h57   #2
Jeremy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Generating GUID tags with php

Gary Hasler wrote:
> Does anyone have any suggestions on generating GUID (Globally Unique
> Identifier) tags with php?
> They would need to be in the format
> 4402bd8a-cd51-40ea-99d7-b510e89e344b
>
> Specifically this is for adding accessibility for the PicLens browser
> add-on (which uses an .rss file) to some of our photo gallery pages. It
> seems to require each thumbnail have an identical GUID tag in both the
> html and the rss file.


If a UUID is acceptable for you (GUID usually means Microsoft's
implementation of UUID; pretty much the same thing, just a 128-bit
unique identifier) then check out this PECL module:

http://pecl.php.net/package/uuid

Jeremy
  Réponse avec citation
Vieux 26/02/2008, 20h09   #3
Gary Hasler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Generating GUID tags with php

Jeremy wrote:
>
> Gary Hasler wrote:
> > Does anyone have any suggestions on generating GUID (Globally Unique
> > Identifier) tags with php?
> > They would need to be in the format
> > 4402bd8a-cd51-40ea-99d7-b510e89e344b
> >
> > Specifically this is for adding accessibility for the PicLens browser
> > add-on (which uses an .rss file) to some of our photo gallery pages. It
> > seems to require each thumbnail have an identical GUID tag in both the
> > html and the rss file.

>
> If a UUID is acceptable for you (GUID usually means Microsoft's
> implementation of UUID; pretty much the same thing, just a 128-bit
> unique identifier) then check out this PECL module:
>
> http://pecl.php.net/package/uuid
>
> Jeremy


Thanks jeremy;
of course as always happens, shortly after posting I stumbled upon the
'perfect' solution: md5().
I can simply use the URL of each picture as string input to the md5
function, which produces a md5 hash (32 character hex). So it is
completely predictable, which I want; yet will NEVER be the same unless
the path to the picture is identical--in which case it will be the same
file!

So I made this function (there may be a more elegant way to do it):
function MakeGUID ($str) {
$h = "-"; //-- HYPHEN
$gMd5 = md5($str);
$guidTag = substr($gMd5,0,8) . $h . substr($gMd5,7,4) . $h .
substr($gMd5,11,4) . $h . substr($gMd5,15,4) . $h . substr($gMd5,19,12);
return $guidTag;
}

....and use it in both the PHP file for the gallery page and the RSS
file, giving it the path to each image.
(Jeez PHP is brilliant...the only hard part is getting the right term to
search for. I've never heard of md5!)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h09.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09811 seconds with 11 queries