Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.13 KB | None | 0 0
  1. <?php
  2. $todata = "/home/all/data";
  3.  
  4. if (!isset($_GET['name'])) {
  5.     $main_content .= '
  6.            <table style="font:14px/15px Tahoma, Helvetica, sans-serif;">
  7.                <ul>
  8.        ';
  9.    
  10.     $path   = $todata . "/monster/";
  11.     $folder = opendir($path);
  12.     $i      = 3;
  13.     $monsters = array();
  14.     while ($filename = readdir($folder)) {
  15.         if ($filename == "." || $filename == "..")
  16.             continue;
  17.         $temp = explode(".", $filename);
  18.         if ($temp[1] == "xml") {
  19.             $nazwa = $temp[0];
  20.             if ($nazwa != "monsters") {
  21.                 $monster = simplexml_load_file($path . $nazwa . '.xml');
  22.                 $monsters[$nazwa] = $monster['name'];
  23.             }
  24.         }
  25.     }
  26.  
  27.     asort($monsters);
  28.     foreach ($monsters as $nazwa => $name) {
  29.         $begin   = ($i % 2) ? '<tr><td>' : '<td>';
  30.         $end     = ($i % 2) ? '</td>' : '</td></tr>';
  31.         $main_content .= $begin . '<li><a href="?subtopic=monsters&name=' . $nazwa . '">' . $name . '</a></li>' . $end;
  32.         $i++;
  33.     }
  34.     $main_content .= '
  35.                </ul>
  36.            </table>
  37.        ';
  38. } else {
  39.     $file_items   = $todata . "/items/items.xml";
  40.     $monster_path = $todata . "/monster/";
  41.     $imagefolder  = "assets/monsters/";
  42.     $monster_name = $_REQUEST['name'];
  43.     include("assets/ids.inc");
  44.    
  45.     $name     = "";
  46.     $exp      = 0;
  47.     $hp       = 0;
  48.     $looktype = 0;
  49.    
  50.     $file = $monster_path . $monster_name . ".xml";
  51.     $f    = @fopen($file, "r");
  52.     if ($f) {
  53.         $contents = fread($f, filesize($file));
  54.         fclose($f);
  55.         $tags = explode("<", $contents);
  56.        
  57.         foreach ($tags as $tag) {
  58.             if (substr($tag, 0, 7) == "monster") {
  59.                 $temp  = stristr($tag, " name=\"");
  60.                 $temp2 = explode("\"", $temp);
  61.                 $name  = $temp2[1];
  62.             }
  63.             if (substr($tag, 0, 7) == "monster") {
  64.                 $temp  = stristr($tag, " experience=\"");
  65.                 $temp2 = explode("\"", $temp);
  66.                 $exp   = $temp2[1];
  67.             }
  68.             if (substr($tag, 0, 6) == "health") {
  69.                 $temp  = stristr($tag, " max=\"");
  70.                 $temp2 = explode("\"", $temp);
  71.                 $hp    = $temp2[1];
  72.             }
  73.             if (substr($tag, 0, 4) == "look") {
  74.                 $temp     = stristr($tag, " type=\"");
  75.                 $temp2    = explode("\"", $temp);
  76.                 $looktype = $temp2[1];
  77.             }
  78.             if (substr($tag, 0, 7) == "defense") {
  79.                 $temp        = stristr($tag, " immunity=\"");
  80.                 $temp2       = explode("\"", $temp);
  81.                 $immunitys[] = $temp2[1];
  82.             }
  83.             if (substr($tag, 0, 6) == "summon") {
  84.                 $temp      = stristr($tag, " name=\"");
  85.                 $temp2     = explode("\"", $temp);
  86.                 $summons[] = $temp2[1];
  87.             }
  88.         }
  89.        
  90.         $temp              = stristr($contents, "<attacks>");
  91.         $attacks           = explode("</attacks>", $temp);
  92.         $attack            = explode("<attack", $attacks[0]);
  93.         $melee             = false;
  94.         $distance          = false;
  95.         $fire_spell        = false;
  96.         $energy_spell      = false;
  97.         $poison_spell      = false;
  98.         $explosion_rune    = false;
  99.         $sudden_death_rune = false;
  100.         $bersek_spell      = false;
  101.         $self_healing      = false;
  102.         $summons[]         = "";
  103.         $immunitys[]       = "";
  104.         foreach ($attack as $temp) {
  105.             if (stristr($temp, "type=\"melee\"")) {
  106.                 $melee = true;
  107.                 continue;
  108.             }
  109.             if (stristr($temp, "type=\"distance\"")) {
  110.                 $distance = true;
  111.                 continue;
  112.             }
  113.             if ((stristr($temp, "type=\"instant\"") || stristr($temp, "type=\"rune\"")) && (stristr($temp, "name=\"great fireball\"") || stristr($temp, "name=\"exevo gran mas vis\""))) {
  114.                 $fire_spell = true;
  115.                 continue;
  116.             }
  117.             if ((stristr($temp, "type=\"instant\"") || stristr($temp, "type=\"rune\"")) && (stristr($temp, "name=\"exevo gran vis lux\""))) {
  118.                 $energy_spell = true;
  119.                 continue;
  120.             }
  121.             if ((stristr($temp, "type=\"instant\"") || stristr($temp, "type=\"rune\"")) && (stristr($temp, "name=\"exura"))) {
  122.                 $self_healing = true;
  123.                 continue;
  124.             }
  125.             if ($tmp = stristr($temp, "name=\"")) {
  126.                 $temp2           = explode("\"", $tmp);
  127.                 $special_attacks = $special_attacks . $temp2[1] . ", ";
  128.                 continue;
  129.             }
  130.             if ($tmp = stristr($temp, "type=\"")) {
  131.                 $temp2           = explode("\"", $tmp);
  132.                 $special_attacks = $special_attacks . $temp2[1] . ", ";
  133.                 continue;
  134.             }
  135.            
  136.         }
  137.        
  138.         $main_content .= ("<img src=\"$imagefolder$looktype.gif\">\n<br>\n<b>Name:</b> $name\n<br>\n<b>Exp:</b> $exp\n<br>\n<b>Health:</b> $hp\n<br>\n<b>Defense:</b> \n<ul style='padding-left:20px;'>\n");
  139.         foreach ($immunitys as $temp) {
  140.             if (!$temp)
  141.                 continue;
  142.             $main_content .= ("<li>$temp<br>\n");
  143.         }
  144.         $main_content .= ("</ul><br>\n<b>Summons:</b> \n<ul style='padding-left:20px;'>\n");
  145.         foreach ($summons as $temp) {
  146.             if (!$temp)
  147.                 continue;
  148.             $main_content .= ("<li>$temp<br>\n");
  149.         }
  150.         $main_content .= ("</ul>");
  151.        
  152.         $main_content .= ("\n\n<br><b>Attack with:</b> \n<br>\n");
  153.         if ($melee)
  154.             $main_content .= ("Close combat, ");
  155.         if ($distance)
  156.             $main_content .= ("Distance attacks, ");
  157.         if ($fire_spell)
  158.             $main_content .= ("Fire spells, ");
  159.         if ($energy_spell)
  160.             $main_content .= ("Energy spells, ");
  161.         if ($poison_spell)
  162.             $main_content .= ("Poison spells, ");
  163.         if ($explosion_rune)
  164.             $main_content .= ("Explosions, ");
  165.         if ($sudden_death_rune)
  166.             $main_content .= ("Sudden Deaths, ");
  167.         if ($bersek_spell)
  168.             $main_content .= ("Berserk, ");
  169.         if ($self_healing)
  170.             $main_content .= ("Self healing, ");
  171.         if ($special_attacks)
  172.             $main_content .= ("$special_attacks");
  173.        
  174.         $temp     = stristr($contents, "<loot>");
  175.         $lootnode = explode("</loot>", $temp);
  176.         $loot     = explode("<item", $lootnode[0]);
  177.         $ids[]    = "";
  178.        
  179.         foreach ($loot as $itemid) {
  180.             if ($idpos = stristr($itemid, "id=\"")) {
  181.                 $temp  = explode("\"", $idpos);
  182.                 $id    = $temp[1];
  183.                 $ids[] = $id;
  184.             }
  185.         }
  186.        
  187.         $f2 = @fopen($file_items, "r");
  188.         if ($f2) {
  189.             $itemnames[]    = "";
  190.             $items_contents = fread($f2, filesize($file_items));
  191.             fclose($f2);
  192.             $items = explode("<item ", $items_contents);
  193.             foreach ($ids as $itemid) {
  194.                 $found = false;
  195.                 foreach ($items as $item_node) {
  196.                     if (stristr($item_node, "id=\"$itemid\"")) {
  197.                         $temp        = stristr($item_node, "name=\"");
  198.                         $temp2       = explode("\"", $temp);
  199.                         $itemnames[] = $temp2[1];
  200.                         $found       = true;
  201.                         break;
  202.                     }
  203.                 }
  204.                 if (!$found) {
  205.                     $itemnames[] = $itemid;
  206.                 }
  207.             }
  208.             $main_content .= ("\n<br><br>\n<b>Loot:</b> \n<ul style='padding-left:20px;'>\n");
  209.             foreach ($itemnames as $itemid) {
  210.                 if (!$item)
  211.                     continue;
  212.                 if ($itemid != "" && $itemid != "0" && $itemid != "0000") {
  213.                     $main_content .= ("<li>$item[$itemid]<br>\n");
  214.                 }
  215.             }
  216.             $main_content .= ("</ul>\n");
  217.         }
  218.     }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement