Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / web / public_php / api / server / utils.php
blob2d7146176461fdf10b7c7e585c9b97d34519f229
1 <?php
2 /* Copyright (C) 2009 Winch Gate Property Limited
4 * This file is part of ryzom_api.
5 * ryzom_api is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * ryzom_api is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
20 function ryzom_name_to_file($name)
22 $r = '';
23 for ($i=0; $i<strlen($name); ++$i)
25 if ($name[$i] == ' ')
26 $r .= '_';
27 else if ($name[$i] == '%' || $name[$i] <= chr(32) || $name[$i] >= chr(127))
28 $r .= sprintf("%%%02x", ord($name[$i]));
29 else
30 $r .= $name[$i];
32 return $r;
35 // -------------------------------------
36 // get user home directory
37 // -------------------------------------
38 function ryzom_get_user_dir($user)
40 global $_RYZOM_API_CONFIG;
42 if ($user == "")
43 die("INTERNAL ERROR CODE 1");
45 $user = ryzom_name_to_file($user);
46 return $_RYZOM_API_CONFIG['cookie_path'].'/'.$_RYZOM_API_CONFIG['shardid'].'/'.substr(strtolower($user), 0, 2).'/'.strtolower($user).'/';