Disable Functions: Path : /opt/eig_wp/wp_install/ |
Current File : //opt/eig_wp/wp_install/common_core_add_redis.php |
<?php /* * This code will add an ACL for a user to a redis server * Note: Loops over each host, because they are not slaved */ function create_redis ($redis_hosts, $username, $pass, $master_user, $master_pass) { foreach (explode(',', $redis_hosts) as &$server) { $obj_r = new Redis(); $obj_r->connect($server, 6379); //TODO: from options passed in $obj_r->auth([$master_user, $master_pass]); //TODO: does this script know the admin connection, or is it passed in? //TODO: generate a pass, or get it passed in? // IF we generate, we still only want to do it on a first hit, then return so it can get passed in for other servers //$pass = $obj_r->acl('GENPASS'); //If we want one generated $ret = $obj_r->acl('SETUSER', $username, 'on', '~' . $username . '__*', '>' . $pass, '+@string', '+@connection'); // Set the acl //ACL SETUSER <username> on ~<username>__* +@string +@connection +EXISTS +DEL >password //acl('SETUSER', 'noperm', 'on', '>noperm', '-@all')) //TODO:will we actually use the on syntax? need to test that $save = $obj_r->acl('SAVE'); //test the connection? would create a new object with an auth with new credentials $test_obj = new Redis(); $test_obj->connect($server, 6379); $test_obj->auth([$username, $pass]); //validate connection? } unset($server); // how do we return this } ?>