Epoch/Tools/PHP/FindPlayerUIDByName.php

31 lines
922 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");
2015-04-05 14:08:28 +00:00
// get all players names in database
2015-04-03 18:46:48 +00:00
$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) {
2015-04-05 14:08:28 +00:00
$UID_raw = explode(":", $value);
echo "<p>" . $UID_raw[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
}
}
?>