phpBB Forum

It is currently Mon 21. May 2012, 09:42

All times are UTC + 1 hour

Forum rules


Hello dearest user and welcome to our EQDKP-Plus support forum.

Please read the following rules and terms before posting anything! Failure in doing so will result in being ignored or being banned. Posting in our boards means you have read, understood and accepted those rules.

English Board Rules – Click here



Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next
Author Message
Offline
 Post subject: Adding RIFT support
PostPosted: Sun 24. Apr 2011, 18:30 

Joined: Fri 22. Apr 2011, 16:47
Posts: 5
Hi all, I need some help adding RIFT support as I am impatient :)

I have included 'rift_allakhazam.php' (never mind, boards don't allow it); but as it turns out now Yellow Gremlin has an API visible:
http://rift.yg.com/help-lookup-api

I have followed the logic and am at the part where I am parsing out the xml data. I have verified I have xml data but I cannot access any individual nodes using the current logic. Example:
Code:
// Get the XML
$xml_data = itemstats_read_url('http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml');


It is this next line that fails, the variable is never populated with the data from the 'name' node:

Code:
$xml_name = $this->xml_helper->parse($xml_data, 'name');


Nor can I pull out any info from any other nodes.

Thoughts?

Thanks!



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Thu 12. May 2011, 15:17 

Joined: Fri 22. Apr 2011, 16:47
Posts: 5
OK well I've finished off the code. If any needs RIFT support here are the new getItem and getItemId functions in your new includes\rift_SITENAME.php file

Code:
// Attempts to retrieve data for the specified item from Allakhazam. -- http://rift.zam.com/en/item.html?riftitem=C9DFDFA30201010101
   function getItem($name)
    {
      // Ignore blank names.
      $name = trim($name);
      if (empty($name))
      {
         return null;
      }

       $item = array('name' => $name);

      for ($ct = 0; isset($GLOBALS["allakhazam_lang"][$ct]); $ct++)
      {
         $current_lang = $GLOBALS["allakhazam_lang"][$ct];

         // Perform the search.
         //$data = itemstats_read_url('http://rift.zam.com/en/search.html?q=' . urlencode($name)); //urlencode(utf8_encode($name)));
         $data = itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)); //urlencode(utf8_encode($name)));
           $item_found = false;
          
         // Look for a name match in the search result.
         //regex fixed by hoofy
         //if (preg_match_all('#item\/(\w+)\/#', $data, $matches))
         if (preg_match_all('#item\/(\S+)\?id=(\w+)#', $data, $matches))         
         {
                   //header( 'Location: http://www.yahoo.com' ) ;
                  
            foreach ($matches[0] as $key => $match)
            {
               // Extract the item's ID from the match.
               //$item_id = $matches[1][$key];
               $item_id = $matches[2][$key];

               // Retrieve the XML for this item from Allakhazam.
               //$xml_data = itemstats_read_url('http://rift.zam.com/en/item-xml.pl?riftitem=' . $item_id);
               //$xml_data = itemstats_read_url('http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml');
               $request_url = 'http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml';
               $xml_data = simplexml_load_file($request_url) or die("Feed could not load");
            
               foreach ($xml_data as $object)
               {
                  $xml_name = $object->name;
                  $xml_url = $object->url;
                  
                  foreach ($object as $icon)
                  {
                     $xml_icon = $icon->medium;
                  }
                  
                  if ($xml_icon == "")
                  {
                     $xml_icon = "quest_1.jpg";
                  }                     
                  
                  if (strcasecmp($item['name'], $xml_name) == 0)
                  {                  
                     // If we have a match, grab additional information about this item and break out of this loop.
                     $item['name'] = $xml_name;
                     $item['id'] = $item_id;
                     $item['lang'] = "en";
                     $item['icon'] = $xml_icon;
                     $item['link'] = $xml_url;
                     $item_found = true;
                     break;
                  }
               }
                              
            }
         }

         // If a match was found, retrieve additional info about it.
           if ($item_found)
         {
            $html_data = utf8_decode(itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)));
            
              $intPositionBody = strpos($html_data, '<div class="yg_itemdetailscontent">', 0);
                $intPositionEndHTML = strpos($html_data, '<tr><td colspan="4" class="currency_container">', 0);
                if ($intPositionEndHTML === false)
                {
                    $intPositionEndHTML = strpos($html_data, '</html>', 0);
                }
            
              $item['html'] = substr($html_data, $intPositionBody, $intPositionEndHTML - $intPositionBody);
            //echo $item['html'];
            //die;
            
            // Parse out the display html of this item from the XML
               $item['html'] = str_replace("</div>", "{ITEMSTATS_LINK}</div>", $item['html']);
            
            // Append Image
            $item['html']  .=  "</tbody></table></div>";         
         
               // Fix up the html a bit.
            //$item['html'] = str_replace("</span></span><br /><span class='wowrttxt'>", "</span></span>\n<br /><span class='wowrttxt'>", $item['html']);
            $item['html'] = str_replace('"', '\'', $item['html']);
            $item['html'] = preg_replace('#(<[ /]*br[ /]*>)<[ /]*br[ /]*>#', '$1', $item['html']);
            //$item['html'] = str_replace("<a href='http://rift.zam.com/en/item/", "<br><a class='set' href='http://rift.zam.com/en/item/", $item['html']);
            $item['html'] = str_replace("<a", "<a target='_new'", $item['html']);
            $item['html'] = preg_replace("#<a ([^>]*) class='itemcreatelink'>#", "<br><span class='itemeffectlink'>Creates: </span>\\0", $item['html']);
            $item['html'] = str_replace('(', "", $item['html']);
            $item['html'] = str_replace(')', "", $item['html']);
            $item['html'] = str_replace("yg_itemdetailscontent", "wowitemt", $item['html']);
            $item['html'] = str_replace("rift_item5", "purplename", $item['html']);
            $item['html'] = str_replace("rift_item4", "bluename", $item['html']);
            $item['html'] = str_replace("rift_item8", "itemGold", $item['html']);
            $item['html'] = str_replace("rift_item3", "greenname", $item['html']);
            $item['html'] = str_replace("rift_item1", "greyname", $item['html']);
            $item['html'] = str_replace("rift_item6", "orangename", $item['html']);
            $item['html'] = str_replace("&quot;", "", $item['html']);                  

            // Extract the item color from the HTML.
            preg_match_all("#<strong class='(.*?)'>#s", $item['html'], $matches);
            foreach ($matches[1] as $match)
               {               
               if ($match == "purplename") // Purple
                   {
                  $item['color'] = "purplename";
                  break;
               }
               if ($match == "bluename") // Blue
                   {
                  $item['color'] = "bluename";
                  break;
               }
               if ($match == "itemGold") // Yellow
                   {
                  $item['color'] = "itemGold";
                  break;
               }
               if ($match == "greenname") // Green
                   {
                  $item['color'] = "greenname";
                  break;
               }
               if ($match == "greyname") // Gray
                   {
                  $item['color'] = "greyname";
                  break;
               }
               if ($match == "orangename") // Orange
                   {
                  $item['color'] = "orangename";
                  break;
               }
            }
            
            // If this is a set, grab the set bonuses and add it to the html.
            //$item_set_id = $this->xml_helper->parse($xml_data, 'setid');
            //if (!empty($item_set_id) && ($item_set_id != '0'))
            //{
               // Read the item set page.
               //$data = utf8_decode(itemstats_read_url('http://lotro.allakhazam.com/db/itemset.html?lotritemset=' . $item_set_id));

               // Extract the set bonus html from this page.
               //preg_match('#Set Bonuses:</div>(.*?)<br/><div class#s', $data, $match);
               //$item_set_bonuses = $match[1];

               // Fix up the html a bit /* COMMENT - MAY NEED TO CHANGE spell.html to skill.html ~Sokol */
               //$item_set_bonuses = str_replace('/db/skill.html', 'http://lotro.allakhazam.com/db/skill.html', $item_set_bonuses);
               //$item_set_bonuses = str_replace("<a", "<a class='setbonus' target='_new'", $item_set_bonuses);
               //$item_set_bonuses = str_replace('"', '\'', $item_set_bonuses);
               //$item_set_bonuses = preg_replace('#<[ /]*br[ /]*>$#','',$item_set_bonuses);
               //$item_set_bonuses = "<span class='setbonus'>" . $item_set_bonuses . "</span>";

               // Insert the set bonus text into the display html;
               //$item['html'] = preg_replace('#setid=(.*?)</span></a>#s', '\\0' . $item_set_bonuses, $item['html']);
            //}

               /*
                     $temp_size_object_data = strlen($object_data);
                     if (substr($item['html'], $temp_size_object_data - 5, 5) == '<br/>')
                         $item['html'] = substr($item['html'], 0, $temp_size_object_data - 5);
                     */

            // Build the final HTML by merging the template and the data we just prepared.
            $template_html = trim(file_get_contents(dirname(__FILE__) . '/../templates/popup.tpl'));
            $item['html'] = str_replace('{ITEM_HTML}', $item['html'], $template_html);
            
               return $item;
         }
      }

            
        unset($item['link']);
        //echo "Aucun objet trouvé !<br/>";      
        return ($item);
   }

   // Attempts to retrieve data for the specified item with ID from Allakhazam.
   function getItemId($item_id, $locale_lang)
    {
      $request_url = 'http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml';
      $xml_data = simplexml_load_file($request_url) or die("Feed could not load");
   
      foreach ($xml_data as $object)
      {
         $xml_name = $object->name;
         $xml_url = $object->url;
         
         foreach ($object as $icon)
         {
            $xml_icon = $icon->medium;
         }
         
         if ($xml_icon == "")
         {
            $xml_icon = "quest_1.jpg";
         }                     
         
         if (strcasecmp($item['name'], $xml_name) == 0)
         {                  
            // If we have a match, grab additional information about this item and break out of this loop.
            $item['name'] = $xml_name;
            $item['id'] = $item_id;
            $item['lang'] = "en";
            $item['icon'] = $xml_icon;
            $item['link'] = $xml_url;
            $item_found = true;
            break;
         }
      }
      
      
      if ($item_found)
         {
            $html_data = utf8_decode(itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)));
            
              $intPositionBody = strpos($html_data, '<div class="yg_itemdetailscontent">', 0);
                $intPositionEndHTML = strpos($html_data, '<tr><td colspan="4" class="currency_container">', 0);
                if ($intPositionEndHTML === false)
                {
                    $intPositionEndHTML = strpos($html_data, '</html>', 0);
                }
            
              $item['html'] = substr($html_data, $intPositionBody, $intPositionEndHTML - $intPositionBody);
            //echo $item['html'];
            //die;
            
            // Parse out the display html of this item from the XML
               $item['html'] = str_replace("</div>", "{ITEMSTATS_LINK}</div>", $item['html']);
            
            // Append Image
            $item['html']  .=  "</tbody></table></div>";                        
            
               // Fix up the html a bit.
            //$item['html'] = str_replace("</span></span><br /><span class='wowrttxt'>", "</span></span>\n<br /><span class='wowrttxt'>", $item['html']);
            $item['html'] = str_replace('"', '\'', $item['html']);
            $item['html'] = preg_replace('#(<[ /]*br[ /]*>)<[ /]*br[ /]*>#', '$1', $item['html']);
            //$item['html'] = str_replace("<a href='http://rift.zam.com/en/item/", "<br><a class='set' href='http://rift.zam.com/en/item/", $item['html']);
            $item['html'] = str_replace("<a", "<a target='_new'", $item['html']);
            $item['html'] = preg_replace("#<a ([^>]*) class='itemcreatelink'>#", "<br><span class='itemeffectlink'>Creates: </span>\\0", $item['html']);
            $item['html'] = str_replace('(', "", $item['html']);
            $item['html'] = str_replace(')', "", $item['html']);
            $item['html'] = str_replace("yg_itemdetailscontent", "wowitemt", $item['html']);
            $item['html'] = str_replace("rift_item5", "purplename", $item['html']);
            $item['html'] = str_replace("rift_item4", "bluename", $item['html']);
            $item['html'] = str_replace("rift_item8", "itemGold", $item['html']);
            $item['html'] = str_replace("rift_item3", "greenname", $item['html']);
            $item['html'] = str_replace("rift_item1", "greyname", $item['html']);
            $item['html'] = str_replace("rift_item6", "orangename", $item['html']);
            $item['html'] = str_replace("&quot;", "", $item['html']);
            
            // Extract the item color from the HTML.
            preg_match_all("#<strong class='(.*?)'>#s", $item['html'], $matches);
            foreach ($matches[1] as $match)
               {               
               if ($match == "purplename") // Purple
                   {
                  $item['color'] = "purplename";
                  break;
               }
               if ($match == "bluename") // Blue
                   {
                  $item['color'] = "bluename";
                  break;
               }
               if ($match == "itemGold") // Yellow
                   {
                  $item['color'] = "itemGold";
                  break;
               }
               if ($match == "greenname") // Green
                   {
                  $item['color'] = "greenname";
                  break;
               }
               if ($match == "greyname") // Gray
                   {
                  $item['color'] = "greyname";
                  break;
               }
               if ($match == "orangename") // Orange
                   {
                  $item['color'] = "orangename";
                  break;
               }
            }

      // If this is a set, grab the set bonuses and add it to the html.
      //$item_set_id = $this->xml_helper->parse($xml_data, 'setid');
      //if (!empty($item_set_id) && ($item_set_id != '0'))
      //{
         // Read the item set page.
         //$data = utf8_decode(itemstats_read_url('http://lotro.allakhazam.com/db/itemset.html?lotritemset=' . $item_set_id));

         // Extract the set bonus html from this page.
         //preg_match('#Set Bonuses:</div>(.*?)<br/><div class#s', $data, $match);
         //$item_set_bonuses = $match[1];

         // Fix up the html a bit
         //$item_set_bonuses = str_replace('/db/spell.html', 'http://lotro.allakhazam.com/db/skill.html', $item_set_bonuses);
         //$item_set_bonuses = str_replace("<a", "<a class='setbonus' target='_new'", $item_set_bonuses);
         //$item_set_bonuses = str_replace('"', '\'', $item_set_bonuses);
         //$item_set_bonuses = preg_replace('#<[ /]*br[ /]*>$#','',$item_set_bonuses);
         //$item_set_bonuses = "<span class='setbonus'>" . $item_set_bonuses . "</span>";

         // Insert the set bonus text into the display html;
         //$item['html'] = preg_replace('#setid=(.*?)</span></a>#s', '\\0' . $item_set_bonuses, $item['html']);
      //}

         // Build the final HTML by merging the template and the data we just prepared.
         $template_html = trim(file_get_contents(dirname(__FILE__) . '/../templates/popup.tpl'));
         $item['html'] = str_replace('{ITEM_HTML}', $item['html'], $template_html);
         return $item;
      }
   }



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Mon 16. May 2011, 12:51 

Joined: Tue 1. Apr 2008, 14:33
Posts: 9
I can't seem to find the option to select this newly created file to use to parse Item ID's.. am i blind? :P



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Wed 18. May 2011, 18:24 

Joined: Tue 1. Apr 2008, 14:33
Posts: 9
Ok, it is deffo not in the options..

If someone could point me in the direction of which file i need to adjust i should be able to work it out from there :)

I have created that Rift php file and put it in the directory.



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Sun 5. Jun 2011, 11:54 

Joined: Sun 5. Jun 2011, 11:46
Posts: 1
Thx for the code to get Itemstats working for Rift.

I found two issue with it thou.
1) If the item does not have a currency such as Glyphed Helm it does not cut the item off and keeps reporting the site itself. The fix for this is chaning
Code:
<tr><td colspan="4" class="currency_container"> to <div class="tooltip_foot">


2) Duplicate items in YG's database do not get sorted out. You end up with the entire search page being displayed instead of the item tool tip. I haven't quite figured this one out yet, maybe someone a little more familiar with this code can fix it up.

Otherwise its good.



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Wed 15. Jun 2011, 05:37 

Joined: Wed 15. Jun 2011, 05:33
Posts: 1
I'm having problems with this, what other files need to be modified for eqdkp to use the new include file and what changes need to be made to those files?



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Thu 1. Sep 2011, 09:31 

Joined: Thu 1. Sep 2011, 09:25
Posts: 1
Can anyone please give a little bit more informations how to do this?

What values must be in the __plus_config db itemstat properties?

How do i create items with the ids like "C9DFDFA30201010101" ?

Any help out there?

Thanks!



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Sat 1. Oct 2011, 22:42 

Joined: Mon 3. Nov 2008, 22:41
Posts: 20
Have no clue what to do here?
Can someone explane more exactly what to do?


//Kribba



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Wed 19. Oct 2011, 12:30 

Joined: Wed 19. Oct 2011, 12:21
Posts: 12
Interested in the progress of the support of the game.
I've seen on some external sites can import a list of guild members from a file which genenriruet game.

Will is, and what version is expected?
About 0.7 I read it, but the news that it would be dating March 2011 and already in October ...



Top
 Profile  
 
Offline
 Post subject: Re: Adding RIFT support
PostPosted: Wed 19. Oct 2011, 12:46 
Core-Developer
User avatar

Joined: Fri 15. May 2009, 19:32
Posts: 3458
With 0.7, we've implemented a guildimporter.


Greetings, GodMod
---
Schreibt mir nie unaufgefordert PNs! - Never write me unrequested PMs!

Support my work:Image



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

(C) The EQdkp-Plus Developer Team
EQdkp Plus Template by Ramon Kaes