Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / web / public_php / api / server / guilds.php
blob5937de7e3d0b724e102f62bc5225b86cbb4ddae1
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/>.
19 // Get the guild from backup and return the filename of the final xml
20 function ryzom_guild($gid, $gz=false) {
21 $out_filename = RYAPI_PATH."data/cache/guilds/guild_$gid.xml";
22 if($gz) $out_filename .= '.gz';
24 if(!file_exists($out_filename)) return ''; //ryzom_die('File not found', $gz?'xmlgz':'txt');
26 return $out_filename;
29 // Get the guilds from backup and return the filename of the final xml
30 function ryzom_guilds($gz=false) {
31 $out_filename = RYAPI_PATH.'data/cache/guilds/guilds_atys.xml';
32 if($gz) $out_filename .= '.gz';
34 if(!file_exists($out_filename)) return ''; //ryzom_die('File not found', $gz?'xmlgz':'txt');
36 return $out_filename;
39 function ryzom_guild_icon($icon, $size) {
40 $filename = RYAPI_PATH."data/cache/guild_icons/${icon}_$size.png";
42 if($size != 'b' && $size != 's') die('Bad size parameter');
43 if($icon == '') die('icon parameter cannot be empty');
45 if(!file_exists($filename)) {
46 $command = RYAPI_PATH."server/scripts/generate_guild_icon.sh $icon $size 2>&1";
47 exec($command, $output, $result);
48 if ($result != 0)
50 echo $command;
51 print_r($output);
52 die('Cannot generate guild icon');
55 return file_get_contents($filename);
58 function ryzom_guild_icon_url($icon, $size) {
59 ryzom_guild_icon($icon, $size);
60 return RYAPI_URL."data/cache/guild_icons/${icon}_$size.png";