Generating GUID tags with php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Hasler

    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.
  • Jeremy

    #2
    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:



    Jeremy

    Comment

    • Gary Hasler

      #3
      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:
      >

      >
      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!)

      Comment

      Working...