Changeset 19 for minimanager/scripts/del_lib.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/scripts/del_lib.php
r5 r19 16 16 global $mangos_db, $realm_db, $user_lvl, $user_id, $tab_del_user_mangos; 17 17 18 $ mysql_01 = new MySQL;19 $ mysql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']);20 $query = $ mysql_01->query("SELECT account,online FROM `character` WHERE guid ='$guid' LIMIT 1");21 $owner_acc_id = $ mysql_01->result($query, 0, 'account');22 $ mysql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);23 $query1 = $ mysql_01->query("SELECT gmlevel FROM account WHERE id ='$owner_acc_id'");24 $owner_gmlvl = $ mysql_01->result($query1, 0, 'gmlevel');18 $sql_01 = new SQL; 19 $sql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']); 20 $query = $sql_01->query("SELECT account,online FROM `character` WHERE guid ='$guid' LIMIT 1"); 21 $owner_acc_id = $sql_01->result($query, 0, 'account'); 22 $sql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 23 $query1 = $sql_01->query("SELECT gmlevel FROM account WHERE id ='$owner_acc_id'"); 24 $owner_gmlvl = $sql_01->result($query1, 0, 'gmlevel'); 25 25 unset($query1); 26 26 27 27 if (($user_lvl > $owner_gmlvl)||($owner_acc_id == $user_id)) { 28 $ mysql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']);28 $sql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']); 29 29 30 if (!$ mysql_01->result($query, 0, 'online')){30 if (!$sql_01->result($query, 0, 'online')){ 31 31 foreach ($tab_del_user_mangos as $value){ 32 $query = $ mysql_01->query("DELETE FROM {$value[0]} WHERE {$value[1]} = '$guid'");32 $query = $sql_01->query("DELETE FROM {$value[0]} WHERE {$value[1]} = '$guid'"); 33 33 } 34 34 35 $ mysql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);36 $query_2 = $ mysql_01->query("SELECT numchars FROM realmcharacters WHERE acctid ='$owner_acc_id' AND realmid = '$realm'");37 $chars_in_acc = $ mysql_01->result($query_2, 0, 'numchars');35 $sql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 36 $query_2 = $sql_01->query("SELECT numchars FROM realmcharacters WHERE acctid ='$owner_acc_id' AND realmid = '$realm'"); 37 $chars_in_acc = $sql_01->result($query_2, 0, 'numchars'); 38 38 if ($chars_in_acc) $chars_in_acc--; 39 39 else $chars_in_acc = 0; 40 $query_2 = $ mysql_01->query("UPDATE realmcharacters SET numchars='$chars_in_acc' WHERE acctid ='$owner_acc_id' AND realmid = '$realm'");40 $query_2 = $sql_01->query("UPDATE realmcharacters SET numchars='$chars_in_acc' WHERE acctid ='$owner_acc_id' AND realmid = '$realm'"); 41 41 42 $ mysql_01->close();42 $sql_01->close(); 43 43 return true; 44 44 } 45 45 } 46 $ mysql_01->close();46 $sql_01->close(); 47 47 return false; 48 48 } … … 55 55 $del_char = 0; 56 56 57 $ mysql_01 = new MySQL;58 $ mysql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);59 $query = $ mysql_01->query("SELECT gmlevel,online FROM account WHERE id ='$acc_id'");60 $gmlevel = $ mysql_01->result($query, 0, 'gmlevel');57 $sql_01 = new SQL; 58 $sql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 59 $query = $sql_01->query("SELECT gmlevel,online FROM account WHERE id ='$acc_id'"); 60 $gmlevel = $sql_01->result($query, 0, 'gmlevel'); 61 61 62 62 if (($user_lvl > $gmlevel)||($acc_id == $user_id)) { 63 if (!$ mysql_01->result($query, 0, 'online')){63 if (!$sql_01->result($query, 0, 'online')){ 64 64 foreach ($mangos_db as $db){ 65 $ mysql_01->connect($db['addr'], $db['user'], $db['pass'], $db['name']);66 $result = $ mysql_01->query("SELECT guid FROM `character` WHERE account='$acc_id'");67 while ($row = $ mysql_01->fetch_array($result)) {65 $sql_01->connect($db['addr'], $db['user'], $db['pass'], $db['name']); 66 $result = $sql_01->query("SELECT guid FROM `character` WHERE account='$acc_id'"); 67 while ($row = $sql_01->fetch_array($result)) { 68 68 foreach ($tab_del_user_mangos as $value) 69 $query = $ mysql_01->query("DELETE FROM $value[0] WHERE $value[1] = '$row[0]'");69 $query = $sql_01->query("DELETE FROM $value[0] WHERE $value[1] = '$row[0]'"); 70 70 $del_char++; 71 71 } 72 72 } 73 73 74 $ mysql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);74 $sql_01->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 75 75 76 76 foreach ($tab_del_user_realmd as $value){ 77 $query = $ mysql_01->query("DELETE FROM $value[0] WHERE $value[1] = '$acc_id'");77 $query = $sql_01->query("DELETE FROM $value[0] WHERE $value[1] = '$acc_id'"); 78 78 } 79 if ($ mysql_01->affected_rows()) {80 $ mysql_01->close();79 if ($sql_01->affected_rows()) { 80 $sql_01->close(); 81 81 return array(true,$del_char); 82 82 } 83 83 } 84 84 } 85 $ mysql_01->close();85 $sql_01->close(); 86 86 return array(false,$del_char); 87 87 } … … 95 95 require_once("scripts/defines.php"); 96 96 97 $ mysql_01 = new MySQL;98 $ mysql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']);99 $query = $ mysql_01->query("DELETE FROM guild WHERE guildid = '$guid'");100 $query = $ mysql_01->query("DELETE FROM guild_rank WHERE guildid = '$guid'");97 $sql_01 = new SQL; 98 $sql_01->connect($mangos_db[$realm]['addr'], $mangos_db[$realm]['user'], $mangos_db[$realm]['pass'], $mangos_db[$realm]['name']); 99 $query = $sql_01->query("DELETE FROM guild WHERE guildid = '$guid'"); 100 $query = $sql_01->query("DELETE FROM guild_rank WHERE guildid = '$guid'"); 101 101 102 102 //clean data inside character.data field 103 $temp = $ mysql_01->query("SELECT guid FROM guild_member WHERE guildid = '$guid'");104 while ($guild_member = $ mysql_01->fetch_row($temp)){105 $char_data = $ mysql_01->query("SELECT data FROM `character` WHERE guid = '$guild_member[0]'");106 $data = $ mysql_01->result($char_data, 0, 'data');103 $temp = $sql_01->query("SELECT guid FROM guild_member WHERE guildid = '$guid'"); 104 while ($guild_member = $sql_01->fetch_row($temp)){ 105 $char_data = $sql_01->query("SELECT data FROM `character` WHERE guid = '$guild_member[0]'"); 106 $data = $sql_01->result($char_data, 0, 'data'); 107 107 $data = explode(' ',$data); 108 108 $data[CHAR_DATA_OFFSET_GUILD_ID] = 0; 109 109 $data[CHAR_DATA_OFFSET_GUILD_RANK] = 0; 110 110 $data = implode(" ",$data); 111 $query = $ mysql_01->query("UPDATE `character` SET data = '$data' WHERE guid = '$guild_member[0]'");111 $query = $sql_01->query("UPDATE `character` SET data = '$data' WHERE guid = '$guild_member[0]'"); 112 112 } 113 113 114 $query = $ mysql_01->query("DELETE FROM guild_member WHERE guildid = '$guid'");114 $query = $sql_01->query("DELETE FROM guild_member WHERE guildid = '$guid'"); 115 115 116 if ($ mysql_01->affected_rows()){117 $ mysql_01->close();116 if ($sql_01->affected_rows()){ 117 $sql_01->close(); 118 118 return true; 119 119 } else { 120 $ mysql_01->close();120 $sql_01->close(); 121 121 return false; 122 122 }
Note:
See TracChangeset
for help on using the changeset viewer.