/**
  * @desc Generates the binary code of a particular item.
  * @param hexItem Variable that will return the result in hex.
  * @param indexItem Item Id.
  * @param indexCategorie Id of the category to which the item belongs.
  * @param dbVersion Version database: 1 = (10 bytes, not personal store), 2 = (10 bytes, with personal store), 1 = (16 bytes, with personal store and harmony)
  * @param properties Properties of the item, level, excellent, etc.
  * @return BOOL.
  */
 public static function makeHexItem(&$hexItem, $indexItem, $indexCategorie, $dbVersion, $properties)
 {
     self::$dbVersion = $dbVersion;
     self::$properties = $properties;
     if (self::dbVersionRule() == false) {
         return false;
     }
     if (self::checkProperties() == false) {
         return false;
     }
     $dumpTemp['ItemId'] = NULL;
     $dumpTemp['ItemLOSL'] = NULL;
     $dumpTemp['ItemDurability'] = NULL;
     $dumpTemp['ItemSerial'] = NULL;
     $dumpTemp['ItemExcellents'] = NULL;
     $dumpTemp['ItemAncient'] = NULL;
     $dumpTemp['CategorieId'] = NULL;
     $dumpTemp['ItemRefine'] = NULL;
     $dumpTemp['HarmonyType'] = NULL;
     $dumpTemp['HarmonyLevel'] = NULL;
     $dumpTemp['Sockect'] = array(NULL, NULL, NULL, NULL, NULL);
     switch (self::$dbVersion) {
         case 1:
             $dumpTemp['ItemId'] = ($indexItem & 0x1f | $indexCategorie << 5 & 0xe0) & 0xff;
             $dumpTemp['ItemLOSL'] = (int) (self::$properties['Level'] * 8) + (self::$properties['Skill'] == true ? 128 : 0) + (self::$properties['Luck'] == true ? 4 : 0) + (self::$properties['Option'] < 4 ? self::$properties['Option'] : self::$properties['Option'] - 4);
             $dumpTemp['ItemDurability'] = self::ItemGetDurability($indexItem, $indexCategorie, self::$properties['Durability'], self::$properties['Level'], self::$properties['Excellent'][0] == true || self::$properties['Excellent'][1] == true || self::$properties['Excellent'][2] == true || self::$properties['Excellent'][3] == true || self::$properties['Excellent'][4] == true || self::$properties['Excellent'][5] == true ? 1 : 0, self::$properties['Ancient']);
             $dumpTemp['ItemSerial'] = self::$properties['Serial'];
             $dumpTemp['ItemExcellents'] = (int) ($indexCategorie * 32 > 255 ? 128 : 0) + (self::$properties['Option'] >= 4 ? 64 : 0) + (self::$properties['Excellent'][0] == true ? 1 : 0) + (self::$properties['Excellent'][1] == true ? 2 : 0) + (self::$properties['Excellent'][2] == true ? 4 : 0) + (self::$properties['Excellent'][3] == true ? 8 : 0) + (self::$properties['Excellent'][4] == true ? 16 : 0) + (self::$properties['Excellent'][5] == true ? 32 : 0);
             break;
         case 2:
             $dumpTemp['ItemId'] = ($indexItem & 0x1f | $indexCategorie << 5 & 0xe0) & 0xff;
             $dumpTemp['ItemLOSL'] = (int) (self::$properties['Level'] * 8) + (self::$properties['Skill'] == true ? 128 : 0) + (self::$properties['Luck'] == true ? 4 : 0) + (self::$properties['Option'] < 4 ? self::$properties['Option'] : self::$properties['Option'] - 4);
             $dumpTemp['ItemDurability'] = self::ItemGetDurability($indexItem, $indexCategorie, self::$properties['Durability'], self::$properties['Level'], self::$properties['Excellent'][0] == true || self::$properties['Excellent'][1] == true || self::$properties['Excellent'][2] == true || self::$properties['Excellent'][3] == true || self::$properties['Excellent'][4] == true || self::$properties['Excellent'][5] == true ? 1 : 0, self::$properties['Ancient']);
             $dumpTemp['ItemSerial'] = self::$properties['Serial'];
             $dumpTemp['ItemExcellents'] = (int) ($indexCategorie * 32 > 255 ? 128 : 0) + (self::$properties['Option'] >= 4 ? 64 : 0) + (self::$properties['Excellent'][0] == true ? 1 : 0) + (self::$properties['Excellent'][1] == true ? 2 : 0) + (self::$properties['Excellent'][2] == true ? 4 : 0) + (self::$properties['Excellent'][3] == true ? 8 : 0) + (self::$properties['Excellent'][4] == true ? 16 : 0) + (self::$properties['Excellent'][5] == true ? 32 : 0);
             $dumpTemp['ItemAncient'] = (int) (self::$properties['Ancient'] == 1 ? 5 : 0) + (self::$properties['Ancient'] == 2 ? 9 : 0);
             break;
         case 3:
             $dumpTemp['ItemId'] = $indexItem;
             $dumpTemp['ItemLOSL'] = (int) (self::$properties['Level'] * 8) + (self::$properties['Skill'] == true ? 128 : 0) + (self::$properties['Luck'] == true ? 4 : 0) + (self::$properties['Option'] < 4 ? self::$properties['Option'] : self::$properties['Option'] - 4);
             $dumpTemp['ItemDurability'] = self::ItemGetDurability($indexItem, $indexCategorie, self::$properties['Durability'], self::$properties['Level'], self::$properties['Excellent'][0] == true || self::$properties['Excellent'][1] == true || self::$properties['Excellent'][2] == true || self::$properties['Excellent'][3] == true || self::$properties['Excellent'][4] == true || self::$properties['Excellent'][5] == true ? 1 : 0, self::$properties['Ancient']);
             $dumpTemp['ItemSerial'] = hexdec(self::$properties['Serial']);
             $dumpTemp['ItemExcellents'] = (int) (self::$properties['Option'] >= 4 ? 64 : 0) + (self::$properties['Excellent'][0] == true ? 1 : 0) + (self::$properties['Excellent'][1] == true ? 2 : 0) + (self::$properties['Excellent'][2] == true ? 4 : 0) + (self::$properties['Excellent'][3] == true ? 8 : 0) + (self::$properties['Excellent'][4] == true ? 16 : 0) + (self::$properties['Excellent'][5] == true ? 32 : 0);
             $dumpTemp['ItemAncient'] = (int) (self::$properties['Ancient'] == 1 ? 5 : 0) + (self::$properties['Ancient'] == 2 ? 10 : 0);
             $dumpTemp['CategorieId'] = $indexCategorie;
             $dumpTemp['ItemRefine'] = (int) (self::$properties['Refine'] == true ? 8 : 0);
             $dumpTemp['HarmonyType'] = (int) self::$properties['HarmonyType'];
             $dumpTemp['HarmonyLevel'] = (int) self::$properties['HarmonyLevel'];
             $dumpTemp['Sockect'][0] = (int) self::$properties['SocketOption'][0];
             $dumpTemp['Sockect'][1] = (int) self::$properties['SocketOption'][1];
             $dumpTemp['Sockect'][2] = (int) self::$properties['SocketOption'][2];
             $dumpTemp['Sockect'][3] = (int) self::$properties['SocketOption'][3];
             $dumpTemp['Sockect'][4] = (int) self::$properties['SocketOption'][4];
             break;
     }
     switch (self::$dbVersion) {
         case 1:
             $hexItem = sprintf(self::$ruleHex, $dumpTemp['ItemId'], $dumpTemp['ItemLOSL'], $dumpTemp['ItemDurability'], $dumpTemp['ItemSerial'], $dumpTemp['ItemExcellents']);
             break;
         case 2:
             $hexItem = sprintf(self::$ruleHex, $dumpTemp['ItemId'], $dumpTemp['ItemLOSL'], $dumpTemp['ItemDurability'], $dumpTemp['ItemSerial'], $dumpTemp['ItemExcellents'], $dumpTemp['ItemAncient']);
             break;
         case 3:
             $hexItem = sprintf(self::$ruleHex, $dumpTemp['ItemId'], $dumpTemp['ItemLOSL'], $dumpTemp['ItemDurability'], $dumpTemp['ItemSerial'], $dumpTemp['ItemExcellents'], $dumpTemp['ItemAncient'], $dumpTemp['CategorieId'], $dumpTemp['ItemRefine'], $dumpTemp['HarmonyType'], $dumpTemp['HarmonyLevel'], $dumpTemp['Sockect'][0], $dumpTemp['Sockect'][1], $dumpTemp['Sockect'][2], $dumpTemp['Sockect'][3], $dumpTemp['Sockect'][4]);
             break;
     }
     return true;
 }
 public function insertItem()
 {
     global $sqlMu, $language;
     try {
         if (isset($_GET['account']) == false || empty($_GET['account']) == true) {
             throw new Exception("MNG_ACC_EV_EMPTY_FIELDS");
         }
         $checkAccount = $sqlMu->prepare("SELECT memb___id FROM [dbo].[MEMB_INFO] WHERE [memb___id] = :memb___id");
         $checkAccount->bindValue(":memb___id", $_GET['account'], sqlServerStatement::PARAM_STR);
         $checkAccount->execute();
         if ($checkAccount->rowsCount() == 0) {
             header("Location: ?call=managerAccounts&subCall=editVault");
         }
         require_once "ldItem/ldItemDatabase.class.php";
         require_once "ldItem/ldItemOptionsDatabase.class.php";
         require_once "ldItem/ldItemMake.class.php";
         require_once "ldItem/ldItemParse.class.php";
         require_once "ldItem/ldVault.class.php";
         require_once "ldItem/ldInventory.class.php";
         ldItemDatabase::setDatabases("application/", "item.txt", "class/ldItem/data/item.serialize.txt");
         if (ldItemDatabase::checkDatabaseExists() == false) {
             ldItemDatabase::createDatabase();
         }
         if (ldItemDatabase::checkDatabaseExists() == false) {
             throw new Exception("DATABASE_CANT_LOAD");
         }
         $settings = new Settings("managerAccounts");
         $this->ldVault = new ldVault($_GET['account'], $settings->dbversion);
         $this->ldVault->getVault();
         $this->ldVault->cutCode();
         $this->ldVault->structureVault();
         if ($this->ldVault->codeGroup[$_GET['slot']]['Details']['IsFree'] == false) {
             throw new Exception("Sexy.error('" . $language->sentence['MNG_ACC_EV_SEXY_HAVE_ITEM_SLOT'] . "');");
         }
         $HexItem = NULL;
         $harmony = explode(":", isset($_POST['itemHarmony']) ? $_POST['itemHarmony'] : '');
         $properties = array("Level" => $_POST['itemLevel'], "Option" => $_POST['itemOption'], "Skill" => isset($_POST['skillOp']) && $_POST['skillOp'] == 1 ? true : false, "Luck" => isset($_POST['luckOp']) && $_POST['luckOp'] == 1 ? true : false, "Serial" => isset($_POST['itemSerialText']) ? $_POST['itemSerialText'] : "FFFFFFFF", "Durability" => 255, "Excellent" => array(isset($_POST['excOp0']) && $_POST['excOp0'] == 1 ? true : false, isset($_POST['excOp1']) && $_POST['excOp1'] == 1 ? true : false, isset($_POST['excOp2']) && $_POST['excOp2'] == 1 ? true : false, isset($_POST['excOp3']) && $_POST['excOp3'] == 1 ? true : false, isset($_POST['excOp4']) && $_POST['excOp4'] == 1 ? true : false, isset($_POST['excOp5']) && $_POST['excOp5'] == 1 ? true : false), "Ancient" => isset($_POST['itemAncient']) && $_POST['itemAncient'] > -1 ? $_POST['itemAncient'] : 0, "Refine" => isset($_POST['refineOp']) && $_POST['refineOp'] == 1 ? true : false, "HarmonyType" => isset($_POST['itemHarmony']) && $_POST['itemHarmony'] > -1 ? $harmony[0] : 0, "HarmonyLevel" => isset($_POST['itemHarmony']) && $_POST['itemHarmony'] > -1 ? $harmony[1] : 0, "SocketOption" => array(isset($_POST['socketOp0']) ? $_POST['socketOp0'] : 255, isset($_POST['socketOp1']) ? $_POST['socketOp1'] : 255, isset($_POST['socketOp2']) ? $_POST['socketOp2'] : 255, isset($_POST['socketOp3']) ? $_POST['socketOp3'] : 255, isset($_POST['socketOp4']) ? $_POST['socketOp4'] : 255));
         if (ldItemMake::makeHexItem($HexItem, $_POST['itemIndex'], $_POST['itemSection'], $settings->dbversion, $properties) == false) {
             throw new Exception("Sexy.error('ItemMaker error.');");
         }
         $slot = $this->ldVault->searchSlotsInVault(ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['X'], ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['Y'], $_GET['slot']);
         if ($slot == -1) {
             $slot = $this->ldVault->searchSlotsInVault(ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['X'], ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['Y']);
             if ($slot > -1) {
                 throw new Exception("Sexy.error('" . sprintf($language->sentence['MNG_ACC_EV_SEXY_ITEM_SLOT_NO_SPACE_TRY'], $slot) . "'); \$('#slot_{$slot}').addClass('slotAttention');");
             } else {
                 throw new Exception("Sexy.error('" . $language->sentence['MNG_ACC_EV_SEXY_ITEM_SLOT_NO_SPACE'] . "');");
             }
         } else {
             $this->ldVault->insertItemInSlot($HexItem, $slot);
             $this->ldVault->writeVault(true);
             throw new Exception("\$('#slot_{$slot}').unbind('click').removeClass('slot').addClass('slotNoEmpty').width(32*" . ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['X'] . ").height( ((32*" . ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['Y'] . ")/2)+6 ).css({'padding-top': \$('#slot_{$slot}').height()-12, 'z-index': 50}).html('" . ldItemDatabase::$dbItem[$_POST['itemSection']][$_POST['itemIndex']]['Name'] . "');\n                                     \$('#slot_{$slot}').click(function(){ callModifyItem({$slot}); });\n                                     \$('.slot').removeClass('slotAttention');\n                                     var boxDetails{$slot} = \"<div class='boxDetails'>\\\n                                                <h2 " . (in_array(true, $this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'], true) ? "class='Gcolor'>" . $language->sentence['MNG_ACC_EV_TOOLTIP_EXCELLENT'] . " " : ">") . "" . utf8_encode($this->ldVault->codeGroup[$slot]['Details']['ItemName']) . "</h2>\\\n                                                <p class='info'>\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_LEVEL'] . ": +" . $this->ldVault->codeGroup[$slot]['Details']['ItemLevel'] . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_LUCK'] . ": " . ($this->ldVault->codeGroup[$slot]['Details']['ItemLuck'] == true ? "Sim" : "N&atilde;o") . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_SKILL'] . ": " . ($this->ldVault->codeGroup[$slot]['Details']['ItemSkill'] == true ? "Sim" : "N&atilde;o") . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_ADDITIONAL'] . ": +" . $this->ldVault->codeGroup[$slot]['Details']['ItemOption'] * 4 . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_DURABILITY'] . ": " . $this->ldVault->codeGroup[$slot]['Details']['ItemDurability'] . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_SERIAL'] . ": " . $this->ldVault->codeGroup[$slot]['Details']['ItemSerial'] . "<br />\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_ANCIENT'] . ": " . ldItemParse::getAncientName($this->ldVault->codeGroup[$slot]['Details']['ItemAncient'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) . "\\\n                                                </p>\\\n                                                <p class='blue'>\\\n                                                   " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][5] == true ? ldItemParse::getExcellentName(5, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                    " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][4] == true ? ldItemParse::getExcellentName(4, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                    " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][3] == true ? ldItemParse::getExcellentName(3, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                    " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][2] == true ? ldItemParse::getExcellentName(2, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                    " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][1] == true ? ldItemParse::getExcellentName(1, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                    " . ($this->ldVault->codeGroup[$slot]['Details']['ItemExcellents'][0] == true ? ldItemParse::getExcellentName(0, $this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) : "") . "\\\n                                                </p>\\\n                                                " . ($this->ldVault->codeGroup[$slot]['Details']['ItemRefine'] > 0 ? "<p class='purple'>\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_OPTION_REFINE'] . ": " . ldItemParse::getRefineName($this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex']) . "\\\n                                                </p>\\" : "\\") . "\n                                                " . ($this->ldVault->codeGroup[$slot]['Details']['HarmonyType'] > 0 ? "<p class='yellow'>\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_OPTION_HARMONY'] . ": " . ldItemParse::getHarmonyName($this->ldVault->codeGroup[$slot]['Details']['ItemIdSection'], $this->ldVault->codeGroup[$slot]['Details']['ItemIdIndex'], $this->ldVault->codeGroup[$slot]['Details']['HarmonyType'], $this->ldVault->codeGroup[$slot]['Details']['HarmonyLevel']) . "\\\n                                                </p>\\" : "\\") . "\n                                                <p class='blue'>\\\n                                                    " . $language->sentence['MNG_ACC_EV_TOOLTIP_OPTION_SOCKET'] . ":<br />\\\n                                                    1: " . ldItemParse::getSocketName(0, $this->ldVault->codeGroup[$slot]['Details']['Sockect'][0]) . "<br />\\\n                                                    2: " . ldItemParse::getSocketName(1, $this->ldVault->codeGroup[$slot]['Details']['Sockect'][1]) . "<br />\\\n                                                    3: " . ldItemParse::getSocketName(2, $this->ldVault->codeGroup[$slot]['Details']['Sockect'][2]) . "<br />\\\n                                                    4: " . ldItemParse::getSocketName(3, $this->ldVault->codeGroup[$slot]['Details']['Sockect'][3]) . "<br />\\\n                                                    5: " . ldItemParse::getSocketName(4, $this->ldVault->codeGroup[$slot]['Details']['Sockect'][4]) . "\\\n                                                </p>\\\n                                            </div>\";\n                                        \$('#slot_{$slot}').tooltip(boxDetails{$slot}, { hook: true, width: 200, mode: 'auto', tooltipClass: 'sexy-tooltipCM'});\n                                     ");
         }
     } catch (Exception $e) {
         echo "<script>" . $e->getMessage() . "</script>";
     }
 }
 private function loadOptionsGoldenArcher()
 {
     if ($_GET['action'] == "check") {
         try {
             if ($this->checkOnlineAccount($_SESSION['LOGIN']) == 1) {
                 throw new Exception(LDPU_YOU_MUST_BE_OFFLINE, 1);
             }
             if (empty($_GET['serial']) == true) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_FILL_SERIAL, 1);
             }
             $this->serial = $_GET['serial'];
             $this->serial = str_replace("-", "", $this->serial);
             if (strlen($this->serial) != 12) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_INVALID_SERIAL, 1);
             }
             $this->serial = array(substr($this->serial, 0, 4), substr($this->serial, 4, 4), substr($this->serial, 8, 4));
             $itemSerial = $this->query("SELECT [id],[username],[status],[itemCategorie],[itemIndex],[itemLevel],[itemOption],[itemSkill],[itemLuck],[excellent1],[excellent2],[excellent3],[excellent4],[excellent5],[excellent6],[ancient],[refine],[harmonyType],[harmonyLevel],[socketOp1],[socketOp2],[socketOp3],[socketOp4],[socketOp5] FROM [dbo].[webGoldenArcher] WHERE [pserial1] = '" . $this->serial[0] . "' AND [pserial2] = '" . $this->serial[1] . "' AND [pserial3] = '" . $this->serial[2] . "'");
             if (mssql_num_rows($itemSerial) == 0) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_INVALID_SERIAL, 1);
             }
             $itemSerial = mssql_fetch_object($itemSerial);
             if ($itemSerial->username != $_SESSION['LOGIN']) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_SERIAL_NOT_BELONG, 1);
             }
             if ($itemSerial->status == 1) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_SERIAL_IS_ACTIVE, 1);
             }
             require_once "ldItemClass/ldItemDatabase.class.php";
             require_once "ldItemClass/ldItemMake.class.php";
             require_once "ldItemClass/ldItemParse.class.php";
             require_once "ldItemClass/ldVault.class.php";
             // Gerar / Carregar banco de dados
             ldItemDatabase::setDatabases("modules/", "item.txt", "classes/ldItemClass/data/item.serialize.txt");
             if (ldItemDatabase::checkDatabaseExists() == false) {
                 ldItemDatabase::createDatabase();
             }
             if (ldItemDatabase::checkDatabaseExists() == false) {
                 exit(LDPU_VIRTUAL_VAULT_CANT_LOAD_DB);
             }
             if (isset(ldItemDatabase::$dbItem[$itemSerial->itemCategorie][$itemSerial->itemIndex]) == false) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_ITEM_NOT_EXISTS, 1);
             }
             $dbVersion = $this->query("SELECT [DbVersion] FROM [" . DATABASE_CHARACTERS . "].[dbo].[warehouse] WHERE [AccountId] = '" . $_SESSION['LOGIN'] . "'");
             if (mssql_num_rows($dbVersion) == 0) {
                 throw new Exception(LDPU_GOLDEN_ARCHER_ACCOUNT_NOT_VAULT, 1);
             }
             $dbVersion = mssql_fetch_object($dbVersion)->DbVersion;
             $HexItem = NULL;
             $optionsItem = array("Level" => $itemSerial->itemLevel, "Option" => $itemSerial->itemOption, "Skill" => $itemSerial->itemSkill, "Luck" => $itemSerial->itemLuck, "Serial" => true, "Excellent" => array($itemSerial->excellent1, $itemSerial->excellent2, $itemSerial->excellent3, $itemSerial->excellent4, $itemSerial->excellent5, $itemSerial->excellent6), "Ancient" => $itemSerial->ancient, "Refine" => $itemSerial->refine, "HarmonyType" => $itemSerial->harmonyType, "HarmonyLevel" => $itemSerial->harmonyLevel, "SocketOption" => array($itemSerial->socketOp1, $itemSerial->socketOp2, $itemSerial->socketOp3, $itemSerial->socketOp4, $itemSerial->socketOp5));
             if (ldItemMake::makeHexItem($HexItem, $itemSerial->itemIndex, $itemSerial->itemCategorie, $dbVersion, $optionsItem) == true) {
                 $ldVault = new ldVault($_SESSION['LOGIN'], $dbVersion);
                 $ldVault->getVault();
                 $ldVault->cutCode();
                 $ldVault->structureVault();
                 ldItemParse::parseHexItem($HexItem, $dbVersion);
                 $slot = $ldVault->searchSlotsInVault(ldItemParse::$dumpTemp['Item']['X'], ldItemParse::$dumpTemp['Item']['Y']);
                 if ($slot != -1) {
                     $ldVault->insertItemInSlot($HexItem, $slot);
                 } else {
                     throw new Exception(LDPU_GOLDEN_ARCHER_VAULT_NOT_SPACE, 1);
                 }
                 $ldVault->structureVault();
                 $ldVault->writeVault(true);
                 unset($ldVault);
             } else {
                 throw new Exception(LDPU_GOLDEN_ARCHER_ERROR_MAKE_ITEM, 1);
             }
             unset($HexItem);
             $updateStatus = $this->query("UPDATE [dbo].[webGoldenArcher] SET [status] = 1 WHERE [id] = '" . $itemSerial->id . "'");
             throw new Exception(ldItemDatabase::$dbItem[$itemSerial->itemCategorie][$itemSerial->itemIndex]["Name"], 0);
         } catch (Exception $e) {
             switch ($e->getCode()) {
                 case 1:
                     echo "<p class=\"white\">" . $e->getMessage() . "</p>";
                     break;
                 case 0:
                     echo "<p class=\"yellow\">" . LDPU_GOLDEN_ARCHER_REGISTER_SUCCESS . "</p><p class=\"yellow\">" . LDPU_GOLDEN_ARCHER_ITEM_RECEIVER . ": " . $e->getMessage() . "</p>";
                     break;
             }
         }
         exit;
     }
 }
 private function registerNow()
 {
     global $REGISTER_SETTINGS, $TABLES_CONFIGS, $PANELUSER_MODULE, $Config_SMTP;
     $login = $_POST['login'];
     $senha = $_POST['senha'];
     $resenha = $_POST['resenha'];
     $email = $_POST['email'];
     $reemail = $_POST['reemail'];
     $nome = $_POST['nome'];
     $telefone = $_POST['telefone'];
     $sexo = $_POST['sexo'];
     $nascimento_dia = $_POST['nascimento_dia'];
     $nascimento_mes = $_POST['nascimento_mes'];
     $nascimento_ano = $_POST['nascimento_ano'];
     $pergunta = $_POST['pergunta'];
     $resposta = $_POST['resposta'];
     $codigo = $_POST['codigo'];
     if (empty($login) || empty($senha) || empty($resenha) || empty($email) || empty($reemail) || empty($nome) || empty($telefone) || empty($sexo) || empty($nascimento_dia) || empty($nascimento_mes) || empty($nascimento_ano) || empty($pergunta) || empty($resposta)) {
         $errorTmp .= REGISTER_EMPTY_INPUTS . "<br />";
     }
     if ($codigo != $_SESSION["SecurityCode"]) {
         $error_tmp .= REGISTER_INCORRECT_SECURITY_CODE . "<br />";
     }
     if (eregi("[^a-zA-Z0-9_!=?&-]", $login) == true) {
         $error_tmp .= REGISTER_DO_NOT_USE_SYMBOLS_LOGIN . "<br />";
     }
     if (strlen($login) > 10) {
         $error_tmp .= REGISTER_LOGIN_INVALID_SIZE . "<br />";
     }
     if ($REGISTER_SETTINGS['USERNAME']['FORCELOWER'] == true) {
         $login = strtolower($login);
     }
     if (eregi("[^a-zA-Z0-9_!=?&-]", $senha) == true) {
         $error_tmp .= REGISTER_DO_NOT_USE_SYMBOLS_PASSWORD . "<br />";
     }
     if (eregi("[^a-zA-Z0-9_!=?&-]", $resenha) == true) {
         $error_tmp .= REGISTER_DO_NOT_USE_SYMBOLS_REPASSWORD . "<br />";
     }
     if ($REGISTER_SETTINGS['EMAIL_REPEAT'] == false) {
         if (mssql_num_rows($this->query("SELECT 1 FROM " . DATABASE_ACCOUNTS . ".dbo.MEMB_INFO WHERE mail_addr='" . $email . "'")) > 0) {
             $error_tmp .= REGISTER_EMAIL_IN_USE . "<br />";
         }
     }
     if (mssql_num_rows($this->query("SELECT memb___id FROM " . DATABASE_ACCOUNTS . ".dbo.MEMB_INFO WHERE memb___id='" . $login . "'")) > 0) {
         $error_tmp .= REGISTER_LOGIN_IN_USE . "<br />";
     }
     if ($senha != $resenha) {
         $error_tmp .= REGISTER_PASSWORD_NOT_MATCH . "<br />";
     }
     if ($email != $reemail) {
         $error_tmp .= REGISTER_EMAIL_NOT_MATCH . "<br />";
     }
     if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
         $error_tmp .= REGISTER_WRITE_VALID_EMAIL . "<br />";
     }
     if (isset($error_tmp) == true) {
         return $this->tpmResult = "<div class=\"quadros\">" . $error_tmp . "</div>";
     } else {
         $data = date('d/m/Y G:i');
         $nascimento = "{$nascimento_dia}/{$nascimento_mes}/{$nascimento_ano}";
         if (USE_MD5 == 1) {
             $senha_query = "CONVERT(varbinary(16),'0x00')";
         } else {
             $senha_query = "'{$senha}'";
         }
         $this->query("INSERT INTO " . DATABASE_ACCOUNTS . ".dbo.MEMB_INFO (memb___id,memb__pwd,memb_name,sno__numb,post_code,addr_info,addr_deta,tel__numb,mail_addr,phon_numb,fpas_ques,fpas_answ,job__code,data,aniversario,appl_days,modi_days,out__days,true_days,mail_chek,bloc_code,ctl1_code) VALUES ('{$login}',{$senha_query},'{$nome}','1','s-n','11111','','{$telefone}','{$email}','','{$pergunta}','{$resposta}','1','{$data}','{$nascimento}','2003-11-23','2003-11-23','2003-11-23','2003-11-23','1','0','1')");
         if (USE_MD5 == 1) {
             $this->query("exec dbo.webPwdHashWrite '" . $login . "','" . $senha . "'");
         }
         if (VI_CURR_INFO == true) {
             $this->query("INSERT INTO " . DATABASE_ACCOUNTS . ".dbo.VI_CURR_INFO (ends_days,chek_code,used_time,memb___id,memb_name,memb_guid,sno__numb,Bill_Section,Bill_value,Bill_Hour,Surplus_Point,Surplus_Minute,Increase_Days )  VALUES ('2005','1',1234,'{$login}','{$nome}',1,'7','6','3','6','6','2003-11-23 10:36:00','0' )");
         }
         if ($TABLES_CONFIGS['WEBCASH']['table'] != "MEMB_INFO") {
             $this->query("INSERT INTO " . $TABLES_CONFIGS['WEBCASH']['database'] . ".dbo." . $TABLES_CONFIGS['WEBCASH']['table'] . " \n                                    (" . $TABLES_CONFIGS['WEBCASH']['columnUsername'] . ",   \n                                    " . $TABLES_CONFIGS['WEBCASH']['columnAmount'] . ",   \n                                    " . $TABLES_CONFIGS['WEBCASH']['columnAmount2'] . ")\n                                  VALUES\n                                    ('" . $login . "', " . (int) $REGISTER_SETTINGS['BONUS_CASH']['AMOUNT'] . ", " . (int) $REGISTER_SETTINGS['BONUS_CASH']['AMOUNT2'] . ");\n                                  ");
         } else {
             $this->query("UPDATE " . $TABLES_CONFIGS['WEBCASH']['database'] . ".dbo." . $TABLES_CONFIGS['WEBCASH']['table'] . " \n                                    SET " . $TABLES_CONFIGS['WEBCASH']['columnUsername'] . " = '{$login}',   \n                                    " . $TABLES_CONFIGS['WEBCASH']['columnAmount'] . " = " . (int) $REGISTER_SETTINGS['BONUS_CASH']['AMOUNT'] . ",   \n                                    " . $TABLES_CONFIGS['WEBCASH']['columnAmount2'] . " = " . (int) $REGISTER_SETTINGS['BONUS_CASH']['AMOUNT2'] . "\n                                    WHERE " . $TABLES_CONFIGS['WEBCASH']['columnUsername'] . " = '{$login}'");
         }
         if ($TABLES_CONFIGS['WEBVIPS']['table'] != "MEMB_INFO") {
             $this->query("INSERT INTO " . $TABLES_CONFIGS['WEBVIPS']['database'] . ".dbo." . $TABLES_CONFIGS['WEBVIPS']['table'] . " \n                                    (" . $TABLES_CONFIGS['WEBVIPS']['columnUsername'] . ",\n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnType'] . ",\n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnDateBegin'] . ",\n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnDateEnd'] . ")\n                                  VALUES\n                                    ('" . $login . "', 0, '0', '0');\n                                  ");
         }
         if ($REGISTER_SETTINGS['BONUS_VIP']['ACTIVE'] == true) {
             $timeStampBegin = strtotime("now");
             $timeStampEnd = strtotime("+ " . $REGISTER_SETTINGS['BONUS_VIP']['DAYS'] . " days");
             $this->query("UPDATE " . $TABLES_CONFIGS['WEBVIPS']['database'] . ".dbo." . $TABLES_CONFIGS['WEBVIPS']['table'] . " SET \n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnType'] . " = " . $REGISTER_SETTINGS['BONUS_VIP']['TYPE'] . ",\n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnDateBegin'] . " = '" . $timeStampBegin . "',\n                                    " . $TABLES_CONFIGS['WEBVIPS']['columnDateEnd'] . " = '" . $timeStampEnd . "'\n                                    WHERE " . $TABLES_CONFIGS['WEBVIPS']['columnUsername'] . " = '" . $login . "'");
             $tempRespost .= sprintf("<div class='qdestaques2'>" . REGISTER_SUCCESS_REGISTER_BONUS_VIP . "</div>", $REGISTER_SETTINGS['BONUS_VIP']['DAYS'], $PANELUSER_MODULE['BUY_VIPS']['NAME_FLATS'][$REGISTER_SETTINGS['BONUS_VIP']['TYPE']], date("d-m-Y g:i a", $timeStampEnd));
         }
         if ($REGISTER_SETTINGS['BONUS_ITEM']['ACTIVE'] == true) {
             require_once "ldItemClass/ldItemDatabase.class.php";
             require_once "ldItemClass/ldItemMake.class.php";
             require_once "ldItemClass/ldItemParse.class.php";
             require_once "ldItemClass/ldVault.class.php";
             // Gerar / Carregar banco de dados
             ldItemDatabase::setDatabases("modules/", "item.txt", "classes/ldItemClass/data/item.serialize.txt");
             if (ldItemDatabase::checkDatabaseExists() == false) {
                 ldItemDatabase::createDatabase();
             }
             if (ldItemDatabase::checkDatabaseExists() == false) {
                 exit(LDPU_VIRTUAL_VAULT_CANT_LOAD_DB);
             }
             //var_dump(ldItemDatabase::$dbItem);
             switch ($REGISTER_SETTINGS['BONUS_ITEM']['VERSION']) {
                 case 1:
                     $length = 1200;
                     break;
                 case 2:
                     $length = 1200;
                     break;
                 case 3:
                     if (constant("VESION_MUSERVER") == 6) {
                         $length = 3840;
                     } else {
                         $length = 1920;
                     }
                     break;
             }
             $this->query("INSERT INTO [" . DATABASE_CHARACTERS . "].[dbo].[warehouse] ([AccountID], [Items], [Money], [EndUseDate], [DbVersion]) VALUES ('" . $login . "',cast(REPLICATE(char(0xff)," . $length . ") as varbinary(" . $length . ")),0, getdate()," . (int) $REGISTER_SETTINGS['BONUS_ITEM']['VERSION'] . ")");
             if (isset($REGISTER_SETTINGS['BONUS_ITEM']['ITEMS'][$_POST['registerBonus']]) && $_POST['registerBonus'] != -1) {
                 $tempRespost .= sprintf("<div class='qdestaques2'>" . REGISTER_SUCCESS_REGISTER_BONUS_ITEMS . "</div>", $REGISTER_SETTINGS['BONUS_ITEM']['ITEMS'][$_POST['registerBonus']]["Name"]);
                 foreach ($REGISTER_SETTINGS['BONUS_ITEM']['ITEMS'][$_POST['registerBonus']]["Items"] as $item) {
                     //var_dump( ldItemDatabase::$dbItem[ $item["idCategorie"] ][ $item["idItem"] ]["Name"] );
                     $HexItem = NULL;
                     if (ldItemMake::makeHexItem($HexItem, $item["idItem"], $item["idCategorie"], $REGISTER_SETTINGS['BONUS_ITEM']['VERSION'], $item["options"]) == true) {
                         $ldVault = new ldVault($login, $REGISTER_SETTINGS['BONUS_ITEM']['VERSION']);
                         $ldVault->getVault();
                         $ldVault->cutCode();
                         $ldVault->structureVault();
                         ldItemParse::parseHexItem($HexItem, $REGISTER_SETTINGS['BONUS_ITEM']['VERSION']);
                         $slot = $ldVault->searchSlotsInVault(ldItemParse::$dumpTemp['Item']['X'], ldItemParse::$dumpTemp['Item']['Y']);
                         if ($slot != -1) {
                             $ldVault->insertItemInSlot($HexItem, $slot);
                         }
                         $ldVault->structureVault();
                         $ldVault->writeVault(true);
                         unset($ldVault);
                     }
                     unset($HexItem);
                 }
             }
         }
         if ($REGISTER_SETTINGS['EMAIL_ACTIVE'] == true) {
             $hash = md5(microtime() . $login);
             $linkActive = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?page=register&activeAccount=" . $login . "&hash=" . $hash;
             $this->query("UPDATE [" . DATABASE_ACCOUNTS . "].[dbo].[MEMB_INFO] SET [bloc_code] = 1, [hashActivate] = '{$hash}' WHERE [memb___id] = '{$login}'");
             date_default_timezone_set("America/Sao_Paulo");
             $mail = new PHPMailer();
             $body .= sprintf(CREATE_ACCOUNT_ACTIVE_EMAIL_BODY, $login, $senha, $pergunta, $resposta, $linkActive, $linkActive);
             $body = eregi_replace("[\\]", '', $body);
             $mail->IsSMTP();
             $mail->SMTPDebug = $Config_SMTP['Debug'];
             $mail->Host = $Config_SMTP['Server'];
             $mail->Port = $Config_SMTP['Port'];
             $mail->From = $Config_SMTP['From'];
             $mail->Username = $Config_SMTP['User'];
             $mail->Password = $Config_SMTP['Password'];
             $mail->FromName = TITLE_SITE;
             $mail->Subject = CREATE_ACCOUNT_ACTIVE_EMAIL_SUBJECT;
             $mail->MsgHTML($body);
             $mail->AddAddress($email, $login);
             if ($mail->Send()) {
                 $emailSend = "<div class='qdestaques2'><strong>" . CREATE_ACCOUNT_EMAIL_SEND_INFO_ACTIVE_SUCCESS . "</strong></div>";
             } else {
                 $emailSend = "<div class='qdestaques'><strong>" . CREATE_ACCOUNT_EMAIL_SEND_INFO_ACTIVE_ERROR . "</strong></div>";
             }
         } else {
             date_default_timezone_set("America/Sao_Paulo");
             $mail = new PHPMailer();
             $body .= sprintf(CREATE_ACCOUNT_EMAIL_BODY, $login, $senha, $pergunta, $resposta);
             $body = eregi_replace("[\\]", '', $body);
             $mail->IsSMTP();
             $mail->SMTPDebug = $Config_SMTP['Debug'];
             $mail->Host = $Config_SMTP['Server'];
             $mail->Port = $Config_SMTP['Port'];
             $mail->From = $Config_SMTP['From'];
             $mail->Username = $Config_SMTP['User'];
             $mail->Password = $Config_SMTP['Password'];
             $mail->FromName = TITLE_SITE;
             $mail->Subject = CREATE_ACCOUNT_EMAIL_SUBJECT;
             $mail->MsgHTML($body);
             $mail->AddAddress($email, $login);
             if ($mail->Send()) {
                 $emailSend = "<div class='qdestaques2'><strong>" . CREATE_ACCOUNT_EMAIL_SEND_INFO_SUCCESS . "</strong></div>";
             } else {
                 $emailSend = "<div class='qdestaques'><strong>" . CREATE_ACCOUNT_EMAIL_SEND_INFO_ERROR . "</strong></div>";
             }
         }
         return $this->tpmResult = sprintf("<div class=\"quadros\">" . REGISTER_SUCCESS_REGISTER . "</div>" . $tempRespost . $emailSend, $login, $senha, $pergunta, $resposta);
     }
 }