Epoch/Tools/PHP/FindPlayerUIDByName.php

30 lines
877 B
PHP
Raw Normal View History

2015-04-03 18:46:48 +00:00
<?php
/*
Example PHP code - Case-insensitive search for player Name returns UID's.
Requires: PHP5 and https://github.com/phpredis/phpredis installed
2015-04-05 14:05:40 +00:00
by [VB]AWOL - EpochMod.com
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
http://creativecommons.org/licenses/by-sa/4.0/
2015-04-03 18:46:48 +00:00
*/
2015-04-03 19:31:30 +00:00
$search = 'Mr. Jones';
2015-04-03 18:46:48 +00:00
$redis = new Redis();
2015-04-03 19:31:30 +00:00
$redis->pconnect(127.0.0.1, 6379, 2.5, "Server1");
2015-04-03 18:46:48 +00:00
$redis->auth("yourlongasspasswordhere");
$playerNames = $redis->keys('PlayerData:*');
// print all UID's matching player name
foreach ($playerNames as $key => $value) {
$data = $redis->get($value);
if (stripos($data, $search) !== false) {
$key = explode(":", $value);
echo "<p>" . $key[1] . "</p>" ;
2015-04-05 14:05:40 +00:00
break; // comment out this line if you want all matches and not just the first.
2015-04-03 18:46:48 +00:00
}
}
?>