Version 2.2 - retro layout + bug fixes

This commit is contained in:
OTCv8
2020-03-31 21:34:09 +02:00
parent 1df9b82846
commit 6b39f061ae
189 changed files with 3384 additions and 4603 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

View File

@@ -1,181 +0,0 @@
<?php
// author otclient@otclient.ovh
// config
$dbserver = "127.0.0.1";
$username = "otclient";
$password = "otclient";
$dbname = "otclient";
$serverName = "OTClientV8";
$serverIp = "otclient.ovh";
//$serverIp = "proxy"; // if serverIp set to 0.0.0.0 or proxy it will connect to server using proxies, set proxies bellow
$serverPort = 7172; // GAME PORT (7172 usually)
$version = 1099;
$otc_version = 1337; // APP_VERSION, from init.lua
$maxLogins = 10; // 0 or null to disable
$blockTime = 60; // after too many logins, in seconds
// CREATE TABLE `login_attmpts` ( `acc` varchar(50) NOT NULL, `ip` varchar(30) NOT NULL, `date` datetime NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
$encryption = "sha1"; // sha1 or md5, everything else == none
// required files in things, type => (filename, md5 checksum in hex)
// $things = null; things can be null if you want to use default values, but then enable auto download of sprites and dat in updater
/* //for 860
$things = array(
"sprites" => array("$version/Tibia.spr", "3db8c0098d34ca3d9a8ec29d40ef1b7b"),
"data" => array("$version/Tibia.dat", "85785b5d67b4c111f780a74895c85c75")
);
*/
// for 1099
$things = array(
"sprites" => array("$version/Tibia.spr", "63d38646597649a55a8be463d6c0fb49"),
"data" => array("$version/Tibia.dat", "ae7157cfff42f14583d6363e77044df7")
);
$customProtocol = nil; // if not nil it will replace client version in protocolgame, may be used to detect outdated client
// executes modules.client_options.setOption(option, value, true)
$settings = array(
);
// it's from src/client/const.h, executes g_game.enableFeature/g_game.disableFeature
$features = array(
22 => true, // GameFormatCreatureName
25 => true, // GameExtendedClientPing
30 => true, // GameChangeMapAwareRange
// 56 => true, // GameSpritesAlphaChannel
80 => true,
90 => true, // GameNewWalking
// 91 => true, // GameSmootherWalking
95 => true, // GameBot
97 => true, // light
);
$rsa = "1091201329673994292788609605089955415282375029027981291234687579" .
"3726629149257644633073969600111060390723088861007265581882535850" .
"3429057592827629436413108566029093628212635953836686562675849720" .
"6207862794310902180176810615217550567108238764764442605581471797" .
"07119674283982419152118103759076030616683978566631413";
// proxies (it's custom feature, not available for free)
$proxies = array(
array(
"localPort" => 7172,
"host" => "51.158.184.57",
"port" => 7162,
"priority" => 0
),
array(
"localPort" => 7172,
"host" => "54.39.190.20",
"port" => 7162,
"priority" => 0
),
array(
"localPort" => 7172,
"host" => "51.83.226.109",
"port" => 7162,
"priority" => 0,
),
array(
"localPort" => 7172,
"host" => "35.247.201.100",
"port" => 443,
"priority" => 0
)
);
// config end
$data = file_get_contents("php://input");
$data = json_decode($data);
if(empty($data)) {
http_response_code(400);
}
if($data->version != $otc_version) {
die(json_encode(array("error" => "Outdated client, please update!")));
}
$conn = new mysqli($dbserver, $username, $password, $dbname);
if ($conn->connect_error) {
die("SQL connection failed: " . $conn->connect_error);
}
$account = $data->account;
if($encryption == "sha1")
$password = sha1($data->password);
else if($encryption == "md5")
$password = md5($data->password);
else
$password = $data->password;
$token = $data->token;
$account = preg_replace("/[^A-Za-z0-9 ._-]/", '', $account);
$password = preg_replace("/[^A-Za-z0-9 ._-]/", '', $password);
$token = preg_replace("/[^A-Za-z0-9 ._-]/", '', $token);
$ip = preg_replace("/[^A-Za-z0-9 ._-]/", '', $_SERVER['REMOTE_ADDR']);
if($maxLogins != null && $maxLogins > 0) {
$result = $conn->query("select count(*) as `attempts` from `login_attmpts` where `ip` = '".$ip."' and `date` > NOW() - INTERVAL ".$blockTime." SECOND");
$result = $result->fetch_assoc();
if($result['attempts'] > $maxLogins) {
die(json_encode(array("error" => "Too many login attempts, please wait ".$blockTime." seconds.")));
}
$conn->query("INSERT INTO `login_attmpts` (`acc`, `ip`, `date`) VALUES ('".$conn->real_escape_string($account)."', '".$ip."', NOW())");
}
$result = $conn->query("select * from accounts where `name` = '".$conn->real_escape_string($account)."' and `password` = '".$conn->real_escape_string($password)."'");
if ($result->num_rows != 1) {
die(json_encode(array("error" => "Invalid account/password")));
}
$acc = $result->fetch_assoc();
$session = "".$data->account."\n".$data->password."\n$token\n".time();
if($serverIp != "proxy" && $serverIp != "0.0.0.0") {
$proxies = null;
}
$response = array(
"error" => "",
"rsa" => $rsa,
"version" => $version,
"things" => $things,
"customProtocol" => $customProtocol,
"session" => $session,
"characters" => array(),
"account" => array(),
"settings" => $settings,
"features" => $features,
"proxies" => $proxies
);
$response["account"]["status"] = 0; // 0=ok, 1=frozen, 2=supsended
$response["account"]["subStatus"] = 1; // 0=free, 1=premium
$response["account"]["premDays"] = 65535;
$characters = $conn->query("select * from `players` where `account_id` = '".$acc['id']."'");
if ($characters->num_rows == 0) {
die(json_encode(array("error" => "Account doesn't have any characters")));
}
while($character = $characters->fetch_assoc()) {
$response["characters"][] = array(
"name" => $character['name'],
"worldName" => $serverName,
"worldIp" => $serverIp,
"worldPort" => $serverPort
// if you are good enough and can code it in lua, you can add outfit, level, vocation, whatever you want here
);
}
echo json_encode($response);
?>

View File

@@ -1,28 +0,0 @@
<?php
function generateRandomString($length = 6) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$code = generateRandomString();
require_once("phpqrcode.php");
ob_start();
QRCode::png($code, null, QR_ECLEVEL_H, 7, 1);
$qrcode = base64_encode( ob_get_contents() );
ob_end_clean();
$data = array(
"qrcode" => $qrcode,
"code" => $code,
"status" => "waiting"
);
echo json_encode($data);
?>

View File

@@ -1,35 +0,0 @@
<?php
$news = array();
$lang = "en";
if(isset($_GET['lang']))
$lang = $_GET['lang'];
$jokes = array();
$jokes[] = "How do you make a tissue dance? You put a little boogie in it.";
$jokes[] = "Why did the policeman smell bad? He was on duty.";
$jokes[] = "Why does Snoop Dogg carry an umbrella? FO DRIZZLE!";
$jokes[] = "Why can't you hear a pterodactyl in the bathroom? Because it has a silent pee.";
$jokes[] = "What did the Zen Buddist say to the hotdog vendor? Make me one with everything.";
$jokes[] = "What kind of bees make milk instead of honey? Boobies.";
$jokes[] = "Horse walks into a bar. Bartender says, 'Why the long face?'";
$jokes[] = "A mushroom walks into a bar. The bartender says, 'Hey, get out of here! We don't serve mushrooms here'. Mushroom says, 'why not? I'm a fungai!'";
$jokes[] = "I never make mistakes…I thought I did once; but I was wrong.";
$jokes[] = "What's Beethoven's favorite fruit? Ba-na-na-naaa!";
$jokes[] = "What did the little fish say when he swam into a wall? DAM!";
$jokes[] = "Knock knock. Who's there? Smell mop. (finish this joke in your head)";
$jokes[] = "Where does a sheep go for a haircut? To the baaaaa baaaaa shop!";
$jokes[] = "What does a nosey pepper do? Gets jalapeno business!";
$jokes[] = "Your mom is so poor, she even can't pay attention";
$news[] = array("title" => "TEST SERVERS", "text" => "OTCLIENTV8 Accs:\nacc1/acc\nacc2/acc\nacc3/acc");
$news[] = array("title" => "First title",
"text" => "This is example of lua g_http api. Those news are from http://otclient.ovh/news.php
\nRequest was for language '".$lang."', however, there's only english version of this, don't have time to create more versions");
$news[] = array("title" => "Random joke", "text" => $jokes[array_rand($jokes)]);
$news[] = array("title" => "Image test", "image" => base64_encode(file_get_contents("image.png")));
echo json_encode($news);
?>

File diff suppressed because it is too large Load Diff

26
api/status.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
$online_otservlist = 0;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://otservlist.org/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return data inplace of echoing on screen
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Skip SSL Verification
curl_setopt($ch, CURLOPT_ENCODING , "");
$site = curl_exec($ch);
curl_close($ch);
preg_match('/There are <strong>([0-9]*)<\/strong>/', $site, $matches);
$online_otservlist = $matches[1];
} catch(Exception $e) {}
$online_discord = 0;
try {
$online_discord = json_decode(file_get_contents("https://discordapp.com/api/guilds/628769144925585428/widget.json"))->presence_count;
} catch(Exception $e) {}
$response = array(
"online" => "$online_otservlist Players online",
"discord_online" => $online_discord,
"discord_link" => "https://discord.gg/t4ntS5p"
);
echo json_encode($response);
?>

View File

@@ -22,7 +22,7 @@ $data_dir = "/var/www/otclient/files";
$things_dir = "/data/things"; // files from that dir won't be downloaded automaticly, you can set it to null to download everything automaticly (useful if you have only 1 version of data/sprites)
$files_url = "http://otclient.ovh/files";
$update_checksum_interval = 60; // caling updater 100x/s would lag disc, we need to cache it
$main_files_and_dirs = array("data", "modules", "init.lua"); // used to ignore other files/dirs in data_dir
$main_files_and_dirs = array("data", "modules", "layouts", "init.lua"); // used to ignore other files/dirs in data_dir
// CONFIG END