Advertisement
Drakonas

Untitled

Mar 12th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. /*
  3. Description: FF XIV Item Link
  4. Shortcode: [14item itemname="name"]
  5. */
  6.  
  7. // Returns a well formed XIVDB Link
  8. function xivdb_link($Page, $Arguments = NULL)
  9. {
  10.     $Link = "http://xivdb.com/?". strtolower($Page);
  11.     if ($Arguments && is_array($Arguments))
  12.     {
  13.         $i = 0;
  14.         foreach($Arguments as $A)
  15.         {
  16.             $Arguments[$i] = str_ireplace(" ", "-", $A);
  17.             $i++;
  18.         }
  19.         if ($Arguments) { $Link .= '/'. implode("/", $Arguments); }
  20.     }
  21.     return $Link;
  22. }
  23.  
  24. // Obtain the array: [MD] => ID
  25. $itemids = json_decode(file_get_contents("items.json"), true);
  26.  
  27. // Format the item name from Lodestone into MD5
  28. $mdname = md5(strtolower($itemname));
  29.  
  30. // Get the real id that can be used for XIVDB
  31. $realid = $itemids[$mdname];
  32.  
  33. echo '<a href="'. xivdb_link('item', [$realid, $itemname]) . '">'. $itemname .'</a>';
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement