Пример #1
0
    public function listAll($shop)
    {
        connect::selectDB('webdb');
        $shop = mysql_real_escape_string($shop);
        $result = mysql_query("SELECT entry,displayid,name,quality,price,faction,class\n\t\tFROM shopitems WHERE in_shop = '" . $shop . "'");
        if (mysql_num_rows($result) == 0) {
            echo 'No items was found in the shop.';
        } else {
            while ($row = mysql_fetch_assoc($result)) {
                $entry = $row['entry'];
                $getIcon = mysql_query("SELECT icon FROM item_icons WHERE displayid='" . $row['displayid'] . "'");
                if (mysql_num_rows($getIcon) == 0) {
                    //No icon found. Probably cataclysm item. Get the icon from wowhead instead.
                    $sxml = new SimpleXmlElement(file_get_contents('http://www.wowhead.com/item=' . $entry . '&xml'));
                    $icon = strtolower(mysql_real_escape_string($sxml->item->icon));
                    //Now that we have it loaded. Add it into database for future use.
                    //Note that WoWHead XML is extremely slow. This is the main reason why we're adding it into the db.
                    mysql_query("INSERT INTO item_icons VALUES('" . $row['displayid'] . "','" . $icon . "')");
                } else {
                    $iconrow = mysql_fetch_assoc($getIcon);
                    $icon = strtolower($iconrow['icon']);
                }
                ?>
                <div class="shopBox" id="item-<?php 
                echo $entry;
                ?>
"> 
                   <table>
                          <tr> 
                           <td>
                            <div class="iconmedium icon" rel="50818">
                                 <ins style="background-image: url('http://static.wowhead.com/images/wow/icons/medium/<?php 
                echo $icon;
                ?>
.jpg');">
                                 </ins>
                                 <del></del>
                                 </div>
                           </td>
                               <td width="380">
                               		<a href="http://<?php 
                echo $GLOBALS['tooltip_href'];
                ?>
item=<?php 
                echo $entry;
                ?>
" 
									class="<?php 
                echo $class;
                ?>
_tooltip" target="_blank">
                               			<?php 
                echo $row['name'];
                ?>
                                    </a>
                               </td>
                               <td align="right" width="350">
                               <?php 
                if ($row['faction'] == 2) {
                    echo "<span class='blue_text'>Alliance only </span>";
                    if ($row['class'] != "-1") {
                        echo "<br/>";
                    }
                } elseif ($row['faction'] == 1) {
                    echo "<span class='red_text'>Horde only </span>";
                    if ($row['class'] != "-1") {
                        echo "<br/>";
                    }
                }
                if ($row['class'] != "-1") {
                    echo shop::getClassMask($row['class']);
                }
                if (isset($_SESSION['cw_gmlevel']) && $_SESSION['cw_gmlevel'] >= 5) {
                    ?>
                             <font size="-2">
                                 ( <a onclick="editShopItem('<?php 
                    echo $entry;
                    ?>
','<?php 
                    echo $shop;
                    ?>
','<?php 
                    echo $row['price'];
                    ?>
')">Edit</a> | 
                                 <a onclick="removeShopItem('<?php 
                    echo $entry;
                    ?>
','<?php 
                    echo $shop;
                    ?>
')">Remove</a> )
                             </font>
                             &nbsp; &nbsp; &nbsp; &nbsp;   
                             <?php 
                }
                ?>
                               <font class="shopItemPrice"><?php 
                echo $row["price"];
                ?>
 
                               <?php 
                if ($shop == "donate") {
                    echo $GLOBALS['donation']['coins_name'];
                } else {
                    echo 'Vote Points';
                }
                ?>
                               </font>
                         
                       <div style="display:none;" id="status-<?php 
                echo $entry;
                ?>
" class="green_text">
                       		The item was added to your cart
                       </div>
                       </td>
                       <td>
                       		<input type="button" value="Add to cart" 
                       	    onclick="addCartItem(<?php 
                echo $entry;
                ?>
,'<?php 
                echo $shop;
                ?>
Cart',
                       		'<?php 
                echo $shop;
                ?>
',this)"> 
                       </td> 
                   </tr> 
                </table> 
            </div>
            <?php 
            }
        }
    }