Changeset 374 for minimanager/scripts/get_lib.php
- Timestamp:
- Sep 11, 2008, 9:10:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/scripts/get_lib.php
r307 r374 10 10 11 11 //########################################################################################## 12 13 require_once("item_display_info.php"); 14 require_once("char_aura.php"); 15 12 16 //get name from realmlist.name 13 17 function get_realm_name($realm_id){ … … 22 26 $sql_0->close(); 23 27 return $realm_name; 28 } 29 30 //get displayid of item 31 function get_displayid($itemid) 32 { 33 global $lang_global, $realm_id, $mangos_db; 34 $sql_0 = new SQL; 35 $sql_0->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 36 $result = $sql_0->query("SELECT `displayid` FROM `item_template` WHERE `entry` = $itemid"); 37 if ($result) 38 $displayid = $sql_0->result($result, 0); 39 else 40 $diaplayid = 0; 41 $sql_0->close(); 42 return $displayid; 24 43 } 25 44 … … 107 126 $tooltip = ""; 108 127 109 switch ($item[35]) { 128 $itemname = htmlspecialchars($item[32]); 129 switch ($item[35]) { 110 130 case 0: //Grey Poor 111 $tooltip .= "<font color='#b2c2b9' class='large'>$item [32]</font><br />";131 $tooltip .= "<font color='#b2c2b9' class='large'>$itemname</font><br />"; 112 132 break; 113 133 case 1: //White Common 114 $tooltip .= "<font color='white' class='large'>$item [32]</font><br />";134 $tooltip .= "<font color='white' class='large'>$itemname</font><br />"; 115 135 break; 116 136 case 2: //Green Uncommon 117 $tooltip .= "<font color='#1eff00' class='large'>$item [32]</font><br />";137 $tooltip .= "<font color='#1eff00' class='large'>$itemname</font><br />"; 118 138 break; 119 139 case 3: //Blue Rare 120 $tooltip .= "<font color='#0070dd' class='large'>$item [32]</font><br />";140 $tooltip .= "<font color='#0070dd' class='large'>$itemname</font><br />"; 121 141 break; 122 142 case 4: //Purple Epic 123 $tooltip .= "<font color='#a335ee' class='large'>$item [32]</font><br />";143 $tooltip .= "<font color='#a335ee' class='large'>$itemname</font><br />"; 124 144 break; 125 145 case 5: //Orange Legendary 126 $tooltip .= "<font color='orange' class='large'>$item [32]</font><br />";146 $tooltip .= "<font color='orange' class='large'>$itemname</font><br />"; 127 147 break; 128 148 case 6: //Red Artifact 129 $tooltip .= "<font color='red' class='large'>$item [32]</font><br />";149 $tooltip .= "<font color='red' class='large'>$itemname</font><br />"; 130 150 break; 131 151 default: … … 653 673 654 674 function get_icon($itemid) { 655 global $proxy_cfg, $get_icons_from_web; 656 if (file_exists("img/INV/$itemid.jpg")) return "img/INV/$itemid.jpg"; 657 658 if($get_icons_from_web){ 659 //only customitems have ids in this range. 660 if ($itemid > 35000) return "img/INV/INV_blank_32.gif"; 661 662 $xmlfilepath="http://www.wowhead.com/?item="; 663 $proxy = $proxy_cfg['addr']; 664 $port = $proxy_cfg['port']; 665 666 if (empty($proxy_cfg['addr'])) { 667 $proxy = "www.wowhead.com"; 668 $xmlfilepath = "?item="; 669 $port = 80; 670 } 671 672 //get the icon name 673 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 674 if (!$fp) return "img/INV/INV_blank_32.gif"; 675 $out = "GET $xmlfilepath$itemid HTTP/1.0\r\nHost: $proxy\r\n"; 676 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 677 $out .="Connection: Close\r\n\r\n"; 675 $displayid = get_displayid($itemid); 676 677 return get_icon_by($displayid, $itemid); 678 } 679 680 function get_icon_by($displayid, $itemid) 681 { 682 global $proxy_cfg, $get_icons_from_web, $item_display_info; 683 684 if ($displayid) 685 { 686 $item = $item_display_info[$displayid]; 687 if ($item && file_exists("img/item_icons/$item.jpg")) 688 return "img/item_icons/$item.jpg"; 689 else 690 $item = ''; 691 } 692 else $item = ''; 693 694 if($get_icons_from_web) 695 { 696 $xmlfilepath="http://www.wowhead.com/?item="; 697 $proxy = $proxy_cfg['addr']; 698 $port = $proxy_cfg['port']; 699 700 if (empty($proxy_cfg['addr'])) 701 { 702 $proxy = "www.wowhead.com"; 703 $xmlfilepath = "?item="; 704 $port = 80; 705 } 706 707 if ($item == '') 708 { 709 //get the icon name 710 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 711 if (!$fp) return "img/INV/INV_blank_32.gif"; 712 $out = "GET /$xmlfilepath$itemid HTTP/1.0\r\nHost: www.wowhead.com\r\n"; 713 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 714 $out .="Connection: Close\r\n\r\n"; 678 715 679 716 $temp = ""; 680 fwrite($fp, $out); 681 while ($fp && !feof($fp)) $temp .= fgets($fp, 4096); 682 fclose($fp); 683 684 preg_match("~(Icon.create\('(.*?)')~", $temp, $temp); 685 if (!isset($temp[2])) return "img/INV/INV_blank_32.gif"; 686 $temp[2] = strtolower($temp[2]); 687 688 //get the icon itself 689 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 690 if (!$fp) return "img/INV/INV_blank_32.gif"; 691 $file = (empty($proxy_cfg['addr'])) ? "/images/icons/medium/$temp[2].jpg" : "http://www.wowhead.com/images/icons/medium/$temp[2].jpg"; 692 $out = "GET $file HTTP/1.0\r\nHost: $proxy\r\n"; 693 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 694 $out .="Connection: Close\r\n\r\n"; 695 fwrite($fp, $out); 696 697 //remove header 698 while ($fp && !feof($fp)){ 699 $headerbuffer = fgets($fp, 4096); 700 if (urlencode($headerbuffer) == "%0D%0A") break; 701 } 702 703 $img_file = fopen("img/INV/$itemid.jpg", 'wb'); 704 while (!feof($fp)) fwrite($img_file,fgets($fp, 4096)); 705 fclose($fp); 706 fclose($img_file); 707 708 if (file_exists("img/INV/$itemid.jpg")) return "img/INV/$itemid.jpg"; 709 else return "img/INV/INV_blank_32.gif"; 710 711 } else return "img/INV/INV_blank_32.gif"; 717 fwrite($fp, $out); 718 while ($fp && !feof($fp)) $temp .= fgets($fp, 4096); 719 fclose($fp); 720 721 //ADDED: 722 $wowhead_string = $temp; 723 //ENDOF ADDED 724 725 //preg_match("~(Icon.create\('(.*?)')~", $temp, $temp); 726 //foxpl regexp: 727 //preg_match("Icon.create\('([^\']*?)", $temp, $temp); 728 729 // if (!isset($temp[2])) return "img/INV/INV_blank_32.gif"; 730 //$item = $temp[2]; 731 } 732 //$iconfilename = strtolower($item); 733 734 //ADDED: 735 //GETTING ICON NAME FROM WOWHEAD STRING: 736 $temp_string1 = strstr($wowhead_string, "Icon.create("); 737 $temp_string2 = substr($temp_string1, 12, 50); 738 $temp_string3 = strtok($temp_string2, ','); 739 $temp_string4 = substr($temp_string3, 1, strlen($temp_string3) - 2); 740 741 $icon_name = $temp_string4; 742 $item = $icon_name; 743 $iconfilename = strtolower($icon_name); 744 //ENDOF ADDED 745 746 //get the icon itself 747 if (empty($proxy_cfg['addr'])) 748 { 749 $proxy = "static.wowhead.com"; 750 $port = 80; 751 } 752 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 753 if (!$fp) return "img/INV/INV_blank_32.gif"; 754 $file = "http://static.wowhead.com/images/icons/medium/$iconfilename.jpg"; 755 $out = "GET $file HTTP/1.0\r\nHost: static.wowhead.com\r\n"; 756 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 757 $out .="Connection: Close\r\n\r\n"; 758 fwrite($fp, $out); 759 760 //remove header 761 while ($fp && !feof($fp)) 762 { 763 $headerbuffer = fgets($fp, 4096); 764 if (urlencode($headerbuffer) == "%0D%0A") break; 765 } 766 767 if (file_exists("img/item_icons/$item.jpg")) return "img/item_icons/$item.jpg"; 768 769 $img_file = fopen("img/item_icons/$item.jpg", 'wb'); 770 while (!feof($fp)) fwrite($img_file,fgets($fp, 4096)); 771 fclose($fp); 772 fclose($img_file); 773 774 if (file_exists("img/item_icons/$item.jpg")) return "img/item_icons/$item.jpg"; 775 else return "img/INV/INV_blank_32.gif"; 776 } 777 else return "img/INV/INV_blank_32.gif"; 778 } 779 780 //########################################################################################## 781 //get aura icon - if icon not exists in Char_AURA folder D/L it from web. 782 783 function get_aura_icon($auraid) 784 { 785 global $proxy_cfg, $get_icons_from_web, $char_aura; 786 if ($auraid) 787 { 788 $aura = $char_aura[$auraid[1]]; 789 if ($aura && file_exists("img/Char_AURA/$aura.jpg")) return "img/Char_AURA/$aura.jpg"; 790 else 791 $aura = ''; 792 } 793 else $aura = ''; 794 795 if($get_icons_from_web) 796 { 797 $xmlfilepath="http://www.wowhead.com/?spell="; 798 $proxy = $proxy_cfg['addr']; 799 $port = $proxy_cfg['port']; 800 801 if (empty($proxy_cfg['addr'])) 802 { 803 $proxy = "www.wowhead.com"; 804 $xmlfilepath = "?spell="; 805 $port = 80; 806 } 807 808 if ($aura == '') 809 { 810 //get the icon name 811 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 812 if (!$fp) return "img/INV/INV_blank_32.gif"; 813 $out = "GET /$xmlfilepath$auraid HTTP/1.0\r\nHost: www.wowhead.com\r\n"; 814 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 815 $out .="Connection: Close\r\n\r\n"; 816 817 $temp = ""; 818 fwrite($fp, $out); 819 while ($fp && !feof($fp)) $temp .= fgets($fp, 4096); 820 fclose($fp); 821 822 //ADDED 823 $wowhead_string = $temp; 824 //ENDOF ADDED 825 826 //preg_match("~(Icon.create\('(.*?)')~", $temp, $temp); 827 //foxpl regexp: 828 //preg_match("Icon.create\('([^\']*?)\'", $temp, $temp); 829 // $temp = "test"; 830 //if (!isset($temp[2])) return "img/INV/INV_blank_32.gif"; 831 //$aura = $temp[2]; 832 } 833 //$iconfilename = strtolower($aura); 834 835 //ADDED: 836 //GETTING ICON NAME FROM WOWHEAD STRING: 837 $temp_string1 = strstr($wowhead_string, "Icon.create("); 838 $temp_string2 = substr($temp_string1, 12, 50); 839 $temp_string3 = strtok($temp_string2, ','); 840 $temp_string4 = substr($temp_string3, 1, strlen($temp_string3) - 2); 841 842 $aura_icon_name = $temp_string4; 843 $aura = $aura_icon_name; 844 $iconfilename = strtolower($aura_icon_name); 845 //ENDOF ADDED 846 847 //get the icon itself 848 if (empty($proxy_cfg['addr'])) 849 { 850 $proxy = "static.wowhead.com"; 851 $port = 80; 852 } 853 $fp = @fsockopen($proxy, $port, $errno, $errstr, 0.4); 854 if (!$fp) return "img/INV/INV_blank_32.gif"; 855 $file = "http://static.wowhead.com/images/icons/medium/$iconfilename.jpg"; 856 $out = "GET $file HTTP/1.0\r\nHost: static.wowhead.com\r\n"; 857 if (!empty($proxy_cfg['user'])) $out .= "Proxy-Authorization: Basic ". base64_encode ("{$proxy_cfg['user']}:{$proxy_cfg['pass']}")."\r\n"; 858 $out .="Connection: Close\r\n\r\n"; 859 fwrite($fp, $out); 860 861 //remove header 862 while ($fp && !feof($fp)) 863 { 864 $headerbuffer = fgets($fp, 4096); 865 if (urlencode($headerbuffer) == "%0D%0A") break; 866 } 867 868 if (file_exists("img/Char_AURA/$aura.jpg")) return "img/Char_AURA/$aura.jpg"; 869 870 $img_file = fopen("img/Char_AURA/$aura.jpg", 'wb'); 871 while (!feof($fp)) fwrite($img_file,fgets($fp, 4096)); 872 fclose($fp); 873 fclose($img_file); 874 if (file_exists("img/Char_AURA/$aura.jpg")) return "img/Char_AURA/$aura.jpg"; 875 else 876 return "img/INV/INV_blank_32.gif"; 877 } 878 else return "img/INV/INV_blank_32.gif"; 712 879 } 713 880 … … 729 896 return "icon_border_0"; 730 897 } 898 899 // for calc next level xp 900 function xp_Diff($lvl) 901 { 902 if( $lvl < 29 ) 903 return 0; 904 if( $lvl == 29 ) 905 return 1; 906 if( $lvl == 30 ) 907 return 3; 908 if( $lvl == 31 ) 909 return 6; 910 else 911 return (5*($lvl-30)); 912 } 913 914 function mxp($lvl) 915 { 916 if ($lvl < 60) 917 { 918 return (45 + (5*$lvl)); 919 } 920 else 921 { 922 return (235 + (5*$lvl)); 923 } 924 } 925 926 function xp_to_level($lvl) 927 { 928 $RATE_XP_PAST_70 = 1; 929 $xp = 0; 930 if (lvl < 60) 931 { 932 $xp = (8*$lvl + xp_Diff($lvl)) * mxp($lvl); 933 } 934 else if ($lvl == 60) 935 { 936 $xp = (155 + mxp($lvl) * (1344 - 70 - ((69 - $lvl) * (7 + (69 - $lvl) * 8 - 1)/2))); 937 } 938 else if ($lvl < 70) 939 { 940 $xp = (155 + mxp($lvl) * (1344 - ((69-$lvl) * (7 + (69 - $lvl) * 8 - 1)/2))); 941 }else 942 { 943 // level higher than 70 is not supported 944 $xp = (779700 * (pow($RATE_XP_PAST_70, $lvl - 69))); 945 return (($xp < 0x7fffffff) ? $xp : 0x7fffffff); 946 } 947 948 // The $xp to Level is always rounded to the nearest 100 points (50 rounded to high). 949 $xp = (($xp + 50) / 100) * 100; // use additional () for prevent free association operations in C++ 950 951 if (($lvl > 10) && ($lvl < 60)) // compute discount added in 2.3.x 952 { 953 $discount = ($lvl < 28) ? ($lvl - 10) : 18; 954 $xp = ($xp * (100 - $discount)) / 100; // apply discount 955 $xp = ($xp / 100) * 100; // floor to hundreds 956 } 957 958 return $xp; 959 } 731 960 ?>
Note:
See TracChangeset
for help on using the changeset viewer.