function VPOSSend($arrayIn, &$arrayOut, $llavePublicaCifrado, $llavePrivadaFirma, $VI) { $veractual = phpversion(); if (version_compare($veractual, "5.0") < 0) { die('PHP version is ' . $veractual . 'and should be >=5.0'); } $xmlSalida = createXMLPHP5($arrayIn); //Genera la firma Digital $firmaDigital = BASE64URL_digital_generate($xmlSalida, $llavePrivadaFirma); //Ya se genero el XML y se genera la llave de sesion $llavesesion = generateSessionKey(); //Se cifra el XML con la llave generada $xmlCifrado = BASE64URL_symmetric_cipher($xmlSalida, $llavesesion, $VI); if (!$xmlCifrado) { return null; } //Se cifra la llave de sesion con la llave publica dada $llaveSesionCifrada = BASE64URLRSA_encrypt($llavesesion, $llavePublicaCifrado); if (!$llaveSesionCifrada) { return null; } if (!$firmaDigital) { return null; } $arrayOut['SESSIONKEY'] = $llaveSesionCifrada; $arrayOut['XMLREQ'] = $xmlCifrado; $arrayOut['DIGITALSIGN'] = $firmaDigital; return true; }
<?php function generateSessionKey() { srand(mktime()); $lenght = 0; $sessionKey = ""; while ($lenght < 30) { $char = substr("0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRESTUVWXYZ", rand(0, strlen("0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRESTUVWXYZ") - 1), 1); if (!strstr($sessionKey, $char)) { $sessionKey .= $char; $lenght++; } } return $sessionKey; } return generateSessionKey();
return $sessionKey; } function isSelected($firstArg, $secondArg) { if (strtolower($firstArg) == strtolower($secondArg)) { return "true"; } return "false"; } if (!$logged) { header("Location: index.php?subtopic=accountmanagement"); } $player = new Player(); $player->loadByName($_REQUEST['name']); if ($player->isLoaded()) { $account = array('sessionKey' => generateSessionKey()); $server = array('WorldID' => 1, 'ip' => $_SERVER['SERVER_ADDR'], 'port' => 7171); $accountCharacters = ""; foreach ($account_logged->getPlayersList() as $character) { $accountCharacters .= "<character name='" . htmlspecialchars($character->getName()) . "' worldid='" . $server['WorldID'] . "' selected='" . isSelected($player->getName(), $character->getName()) . "' />"; } } else { header("Location: index.php?subtopic=accountmanagement"); } ?> <html> <head> <title>Tibia Flash Client</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="content-language" content="en" />