// Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . $publicAccess = true; include('authenticate.php'); include('request_interface.php'); $error = ''; if ($allowDownload && $download) { // query file to BSs $query = "*.*.BS.getFileBase64Content $file"; $qstate = nel_query($query, $commandResult); //echo "$commandResult"; if ($commandResult) { $res_array = explode("\n", $commandResult); $parse_start = 0; while (true) { if ($parse_start >= count($res_array)) break; $offset = 4; list($res_shard) = sscanf($res_array[$parse_start], "----- Result from Shard %s"); list($dld_file, $num_res, $file_size, $originalMD5) = sscanf($res_array[$parse_start+$offset-1], "file %s lines %d size %d haskey %s"); $start = $parse_start+$offset; $stop = $start+$num_res; $parse_start += $num_res+$offset; if ($num_res == 0) continue; $buffer = ''; for ($line=$start; $line<$stop; ++$line) $buffer .= trim($res_array[$line]); $decoded = base64_decode($buffer); $decodedMD5 = md5($decoded); if ($originalMD5 != '' && $originalMD5 != $decodedMD5) { $error = "ERROR: failed to download file '$file', MD5 signature indicates file is corrupted."; } else { header("Content-type: application/bin"); header("Content-Disposition: attachment; filename=".basename($file)); echo $decoded; die(); } } } if (!$error) $error = "ERROR: failed to download file '$file', file may not exist on any server."; } if ($allowUpload && $upload) { $f = fopen($upld_file, "rb"); if ($f) { $content = base64_encode(fread($f, $upld_file_size)); $query = $shard_addr.".putFileBase64Content $file $content"; $qstate = nel_query($query, $commandResult); } } htmlProlog($_SERVER['PHP_SELF'], "Backup Interface (Character Up/Download)"); // input variables : // - $charid : character id to upload/download // - $file : filename to upload/download // $query = "*.*.BS.State"; $qstate = nel_query($query, $result); if ($qstate) { $arr = explode(' ', $result); $numRes = count($arr); $numRows = current($arr); $numLines = ($numRes-$numRows-2)/$numRows; next($arr); for ($i=0; $i<$numRows; ++$i) { $vars[] = current($arr); next($arr); } unset($shards); for ($i=0; $i<$numLines; ++$i) { unset($l); foreach($vars as $var) { $l[$var] = current($arr); next($arr); } $shards[] = $l; } } echo "

\n"; if ($error) { echo "$error

\n"; } if ($allowDownload) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Download file
"; echo ""; echo ""; echo "
"; echo "
"; } if ($allowUpload) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Upload file
"; echo "
"; echo "\n"; echo ""; echo ""; echo "
"; } /* echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; $result = sqlquery("SELECT DISTINCT shard FROM service ORDER BY shard"); echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Player/Character name
\n"; if (isset($char_name)) { $addr = (count($selected_shards) > 0 ? "[".join(",", $selected_shards)."]" : "*").".*.EGS.playerInfo $char_name"; $qstate = nel_query($addr, $commandResult); } if ($commandResult) { $res_array = explode("\n", $commandResult); $parse_start = 0; echo "

\n"; $num_player = 0; echo "\n"; while (true) { if ($res_array[$parse_start] == "") break; $offset = 4; list($res_shard) = sscanf($res_array[$parse_start], "----- Result from Shard %s"); list($num_res) = sscanf($res_array[$parse_start+$offset-1], "%d"); $start = $parse_start+$offset; $stop = $start+$num_res; $parse_start += $num_res+$offset; $last_uid = ""; $icolor = 0; echo "Result of search for '$char_name' on Shard '$res_shard' ($num_res entr".($num_res>1 ? "ies" : "y")." found)
\n"; echo "Click on EntityId to get directly to DefaultPlayer view,
or click anywhere else to select a player and then click Select Players button.


\n"; echo "\n"; for ($line=$start; $line<$stop; ++$line) { $l = explode(" ", $res_array[$line]); for ($i=1; $i\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; ++$num_player; } echo "
UIdUserNameEIdEntityNameEntitySlotStateExt commands
".($chUser ? $parse["UId"] : "")."".$parse["UserName"]."".$parse["EId"]."".$parse["EntityName"]."".$parse["EntitySlot"]."".$parse["State"].""; if (isset($parse["SaveFile"])) { echo "Load/Save sheet"; } echo "
\n"; } echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } echo "
\n"; echo "\n"; */ htmlEpilog(); ?>