#my_print("Read failed on main socket, bailing"); # We failed on the main socket. There's no way to continue, so # break all the way out. break 2; } $xor = strrev(substr($header, 0, 4)); $request = substr($header, 4); $len_array = unpack("Nlen", xor_bytes($xor, substr($request, 0, 4))); $len = $len_array['len']; # length of the whole packet, including header # packet type should always be 0, i.e. PACKET_TYPE_REQUEST while (strlen($request) < $len) { $request .= read($msgsock, $len - strlen($request)); } #my_print("creating response"); $response = create_response($xor, $request); write_tlv_to_socket($msgsock, $response); } else { #my_print("not Msgsock: $ready"); $data = read($ready); if (false === $data) { handle_dead_resource_channel($ready); } elseif (strlen($data) > 0) { my_print(sprintf("Read returned %s bytes", strlen($data))); $request = handle_resource_read_channel($ready, $data); if ($request) { write_tlv_to_socket($msgsock, $request); } } } }
if (false == $request) { #my_print("Read failed on main socket, bailing"); # We failed on the main socket. There's no way to continue, so # break all the way out. break 2; } $a = unpack("Nlen/Ntype", $request); # length of the whole packet, including header $len = $a['len']; # packet type should always be 0, i.e. PACKET_TYPE_REQUEST $ptype = $a['type']; while (strlen($request) < $a['len']) { $request .= read($msgsock, $len - strlen($request)); } #my_print("creating response"); $response = create_response($request); write($msgsock, $response); } else { #my_print("not Msgsock: $ready"); $data = read($ready); if (false === $data) { handle_dead_resource_channel($ready); } elseif (strlen($data) > 0) { my_print(sprintf("Read returned %s bytes", strlen($data))); $request = handle_resource_read_channel($ready, $data); if ($request) { write($msgsock, $request); } } } }
$item_name = mysql_result(myquery("SELECT name FROM dungeon_quests WHERE id=" . $item_id . ""), 0, 0); $res_name = mysql_result(myquery("SELECT name FROM craft_resource WHERE id=" . $res_id . ""), 0, 0); myquery("INSERT INTO dungeon_quests_res (quest_id,res_id,col) VALUES ({$item_id},{$res_id},{$col}) ON DUPLICATE KEY UPDATE col={$col}"); $da = getdate(); $log = myquery("INSERT INTO game_log_adm (adm,dei,cur_time,day,month,year) \n\t\t VALUES (\n\t\t '" . $char['name'] . "',\n\t\t 'Для квеста Подземелий Мории: <b>" . $item_name . "</b> добавил(изменил) состав ресурсов: ресурс <b>" . $res_name . "</b>, количество - " . $col . "',\n\t\t '" . time() . "',\n\t\t '" . $da['mday'] . "',\n\t\t '" . $da['mon'] . "',\n\t\t '" . $da['year'] . "')") or die(mysql_error()); } $response = 'ok'; } if (isset($_GET['delete'])) { $id = (int) $_GET['delete']; list($res_id, $col, $item_id) = mysql_fetch_array(myquery("SELECT res_id,col,quest_id FROM dungeon_quests_res WHERE id={$id}")); $item_name = mysql_result(myquery("SELECT name FROM dungeon_quests WHERE id=" . $item_id . ""), 0, 0); $res_name = mysql_result(myquery("SELECT name FROM craft_resource WHERE id=" . $res_id . ""), 0, 0); myquery("DELETE FROM dungeon_quests_res WHERE id={$id}"); $da = getdate(); $log = myquery("INSERT INTO game_log_adm (adm,dei,cur_time,day,month,year) \n\t VALUES (\n\t '" . $char['name'] . "',\n\t 'Для квеста Подземелий Мории: <b>" . $item_name . "</b> удалил из состав ресурсов: ресурс <b>" . $res_name . "</b>, количество - " . $col . "',\n\t '" . time() . "',\n\t '" . $da['mday'] . "',\n\t '" . $da['mon'] . "',\n\t '" . $da['year'] . "')") or die(mysql_error()); $response = 'ok'; } if (isset($_GET['read'])) { $item_id = (int) $_GET['read']; $response = create_response($item_id); } if (ob_get_length()) { ob_clean(); } header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: text/html;charset=windows-1251'); echo $response;