url.diff

git diff master (URL handling) - LupusMichaelis, 07/25/2009 10:14 am

Download (39.5 kB)

/dev/null
1
<?php
2

3
require_once('ryzom_api/ryzom_api.php');
4

5
if(isset($_POST['key']) && $_POST['key'] != '') header('Location: ?ckey='.ryzom_encrypt($_POST['key']));
6

7
ryzom_ckey_handle();
8

9
header('Content-Type:text/html; charset=UTF-8');
10

11
echo '
12
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
13
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
14
	<head>
15
	<title>Character Profile</title>
16
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
17
	'.ryzom_render_header().'
18
	'.ryzom_render_header_www().'
19
	</head>
20
	<body>
21
';
22

23
if (isset($_GET['ckey']) && $_GET['ckey'] != '') {
24

25
	ryzom_log_start('example_profile');
26

27
	// Display the profile
28
	$ckey = $_GET['ckey'];
29
	$key = ryzom_decrypt($ckey);
30

31
	$uid=0;$gid=0;$slot=0;$full=false;
32
	if(ryzom_character_valid_key($key, $uid, $slot, $full)) {
33
		$xml = ryzom_character_simplexml($key, 'full');
34
	} else if(ryzom_guild_valid_key($key, $gid)) {
35
		$xml = ryzom_guild_simplexml($key);
36
	} else {
37
		$xml = ryzom_error('Not valid character or guild key', 'simplexml');
38
	}
39
	if($xml->getName() == 'error') {
40
		$content = '<div class="error">'.$xml.'</div>';
41
		$content.= '<hr/><a class="ryzom-ui-button" href="?">back</a>';
42
		die(ryzom_render_www(ryzom_render_window('API error', $content)));
43
	}
44

45
    // Display the profile
46
	if((string)$xml->getName()=='character') {
47
		$title='Character profile';
48
		$content=render_character($xml,$key);
49
	} else {
50
		$title='Guild profile';
51
		$content=render_guild($xml);
52
	}
53

54
	ryzom_log_end();
55
} else {
56
	// Display the form to enter the API Key
57
	$title = 'Profile';
58
	$content = '<form action="" method="post">';
59
	$content .= 'Please enter the API Key (guild or character) that you can find on <a href="https://secure.ryzom.com/payment_profile">your profile page</a>:</br>';
60
	$content .= '<input type="text" name="key"><br/>';
61
	$content .= '<input type="submit" value="Submit" />';
62
	$content .= '</form>';
63
}
64

65
echo ryzom_render_www(ryzom_render_window($title, $content));
66
echo '</body></html>';
67

68
function render_guild($xml){
69
	$content = '<h1>'.$xml->name.'</h1>';
70

71
	$content .= '<ul>';
72
	$content .= '<li>Created: <b>'.ryzom_time_txt(ryzom_time_array($xml->creation_date, '')).'</b></li>';
73
	$content .= '<li>Cult: <b>'.$xml->cult.'</b></li>';
74
	$content .= '<li>Civilization: <b>'.$xml->civ.'</b></li>';
75

76
	$guild_icon = ryzom_guild_icon_image($xml->icon, 'b');
77
	$guild_icon_small = ryzom_guild_icon_image($xml->icon, 's');
78
	$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>";
79

80
	$content .= '</ul>';
81

82
	// read the members, then sort them by grade and name
83
	$result = $xml->xpath('/guild/members/*');
84
	$members=array();
85
	$s_gk=array();// multi array sort keys
86
	$s_nk=array();
87
	$key=0;
88
	while(list(,$item)=each($result)) {
89
		$members[$key]=array(
90
			'joined' => intval($item->joined_date), // joined_date is in server tick (ingame date)
91
			'grade'  => (string)$item->grade,
92
			'name'   => (string)$item->name,
93
			);
94
		$s_gk[$key]=memberGrade($members[$key]['grade']);
95
		$s_nk[$key]=$members[$key]['name'];
96
		$key++;
97
	}
98
	// sort members by grade, then by name
99
	array_multisort($s_gk, SORT_ASC, $s_nk, SORT_ASC, $members);
100
	$content .= '<h2>Members:'.count($members).'</h2>';
101
	$content .= '<table width="500px" border="1" cellpadding="1" cellspacing="0">';
102
	$content .= '<thead><tr><td>Name</td><td>Rank</td><td>Joined</td></thead>';
103
	foreach($members as $member) {
104
		$content .=
105
			'<tr>'.
106
			'<td>'.$member['name'].'</td>'.
107
			'<td>'.$member['grade'].'</td>'.
108
			'<td>'.ryzom_time_txt(ryzom_time_array($member['joined'], '')).'</td>'.
109
			'</tr>';
110
	}
111
	$content .= '</table>';
112

113
	$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>';
114
	return $content;
115
}
116

117
/**
118
  * memberGrade will convert memebr grade string value to int for sorting
119
  *
120
  * @param string $grade one of 'Leader', 'HighOfficer', 'Officer', 'Member'
121
  * @return int
122
  */
123
function memberGrade($grade) {
124
	switch(strtolower($grade)) {
125
	case 'leader': return 0;
126
	case 'highofficer': return 1;
127
	case 'officer': return 2;
128
	case 'member':
129
	default: return 3;
130
	}
131
}
132

133
function render_character($xml, $key) {
134
	$content = '<h1>'.$xml->name.'</h1>';
135
	$content .= '<ul>';
136
	$content .= '<li>Shard: <b>'.$xml->shard.'</b></li>';
137
	$content .= '<li>Race: <b>'.$xml->race.'</b></li>';
138
	$gender = $xml->gender;
139
	$content .= '<li>Gender: <b>'.($gender=='f'?'Female':'Male').'</b></li>';
140
	$title = ryzom_title_txt($xml->titleid, 'en', $gender);
141
	$content .= '<li>Title: <b>'.$title.'</b></li>';
142
	$content .= '</ul>';
143

144
	$content .= '<h2>Hands</h2>';
145
	$result = $xml->xpath('/character/hands/*');
146
	while(list( , $item) = each($result))
147
	{
148
		$content .= ryzom_item_icon_image_from_simplexml($item).' ';
149
	}
150

151
	$content .= '<h2>Equipments</h2>';
152
	$result = $xml->xpath('/character/equipments/*');
153
	while(list( , $item) = each($result))
154
	{
155
		$content .= ryzom_item_icon_image_from_simplexml($item).' ';
156
	}
157

158
	if($xml->guild->name != '') {
159
		$content .= '<h2>Guild</h2>';
160
		$content .= '<ul>';
161
		$content .= '<li>Name: <b>'.$xml->guild->name.'</b></li>';
162
		$guild_icon = ryzom_guild_icon_image($xml->guild->icon, 'b');
163
		$guild_icon_small = ryzom_guild_icon_image($xml->guild->icon, 's');
164
		$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>";
165
		$content .= '</ul>';
166
	} else {
167
		$content .= '<h2>No Guild</h2>';
168
	}
169

170
	// inventories
171

172
	$inv_xml = ryzom_character_simplexml($key, 'items');
173

174
	if(isset($inv_xml->inventories->bag)) {
175
		$content .= '<h2>Bag</h2>';
176
		$content .= '<p>(leave the mouse on an item to display its custom text, if any)</p>';
177
		$result = $inv_xml->xpath('/items/inventories/bag/*');
178
		while(list( , $item) = each($result))
179
		{
180
			$content .= ryzom_item_icon_image_from_simplexml($item);
181
		}
182
	}
183

184
	if(isset($inv_xml->item_in_store)) {
185
		$content .= '<h2>Item in store</h2>';
186
		$content .= '<p>(leave the mouse on an item to display its price)</p>';
187
		$result = $inv_xml->xpath('/items/item_in_store/*');
188
		while(list( , $item) = each($result))
189
		{
190
			$content .= ryzom_item_icon_image_from_simplexml($item, "Price: ".$item['price']);
191
		}
192
	}
193

194
	$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>';
195
	return $content;
196
}
b/examples/example_profile.php
1
<?php
2

3
require_once('ryzom_api/ryzom_api.php');
4

5
if(!empty($_POST['key'])) header('Location: ?ckey='.ryzom_encrypt($_POST['key']));
6

7
ryzom_ckey_handle();
8

9
header('Content-Type:text/html; charset=UTF-8');
10

11
echo '
12
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
13
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
14
	<head>
15
	<title>Character Profile</title>
16
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
17
	'.ryzom_render_header().'
18
	'.ryzom_render_header_www().'
19
	</head>
20
	<body>
21
';
22

23
if (isset($_GET['ckey']) && $_GET['ckey'] != '') {
24

25
	ryzom_log_start('example_profile');
26

27
	// Display the profile
28
	$ckey = $_GET['ckey'];
29
	$key = ryzom_decrypt($ckey);
30

31
	$uid=0;$gid=0;$slot=0;$full=false;
32
	if(ryzom_character_valid_key($key, $uid, $slot, $full)) {
33
		$xml = ryzom_character_simplexml($key, 'full');
34
	} else if(ryzom_guild_valid_key($key, $gid)) {
35
		$xml = ryzom_guild_simplexml($key);
36
	} else {
37
		$xml = ryzom_error('Not valid character or guild key', 'simplexml');
38
	}
39
	if($xml->getName() == 'error') {
40
		$content = '<div class="error">'.$xml.'</div>';
41
		$content.= '<hr/><a class="ryzom-ui-button" href="?">back</a>';
42
		die(ryzom_render_www(ryzom_render_window('API error', $content)));
43
	}
44

45
    // Display the profile
46
	if((string)$xml->getName()=='character') {
47
		$title='Character profile';
48
		$content=render_character($xml,$key);
49
	} else {
50
		$title='Guild profile';
51
		$content=render_guild($xml);
52
	}
53

54
	ryzom_log_end();
55
} else {
56
	// Display the form to enter the API Key
57
	$title = 'Profile';
58
	$content = '<form action="" method="post">';
59
	$content .= 'Please enter the API Key (guild or character) that you can find on <a href="https://secure.ryzom.com/payment_profile">your profile page</a>:</br>';
60
	$content .= '<input type="text" name="key"><br/>';
61
	$content .= '<input type="submit" value="Submit" />';
62
	$content .= '</form>';
63
}
64

65
echo ryzom_render_www(ryzom_render_window($title, $content));
66
echo '</body></html>';
67

68
function render_guild($xml){
69
	$content = '<h1>'.$xml->name.'</h1>';
70

71
	$content .= '<ul>';
72
	$content .= '<li>Created: <b>'.ryzom_time_txt(ryzom_time_array($xml->creation_date, '')).'</b></li>';
73
	$content .= '<li>Cult: <b>'.$xml->cult.'</b></li>';
74
	$content .= '<li>Civilization: <b>'.$xml->civ.'</b></li>';
75

76
	$guild_icon = ryzom_guild_icon_image($xml->icon, 'b');
77
	$guild_icon_small = ryzom_guild_icon_image($xml->icon, 's');
78
	$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>";
79

80
	$content .= '</ul>';
81

82
	// read the members, then sort them by grade and name
83
	$result = $xml->xpath('/guild/members/*');
84
	$members=array();
85
	$s_gk=array();// multi array sort keys
86
	$s_nk=array();
87
	$key=0;
88
	while(list(,$item)=each($result)) {
89
		$members[$key]=array(
90
			'joined' => intval($item->joined_date), // joined_date is in server tick (ingame date)
91
			'grade'  => (string)$item->grade,
92
			'name'   => (string)$item->name,
93
			);
94
		$s_gk[$key]=memberGrade($members[$key]['grade']);
95
		$s_nk[$key]=$members[$key]['name'];
96
		$key++;
97
	}
98
	// sort members by grade, then by name
99
	array_multisort($s_gk, SORT_ASC, $s_nk, SORT_ASC, $members);
100
	$content .= '<h2>Members:'.count($members).'</h2>';
101
	$content .= '<table width="500px" border="1" cellpadding="1" cellspacing="0">';
102
	$content .= '<thead><tr><td>Name</td><td>Rank</td><td>Joined</td></thead>';
103
	foreach($members as $member) {
104
		$content .=
105
			'<tr>'.
106
			'<td>'.$member['name'].'</td>'.
107
			'<td>'.$member['grade'].'</td>'.
108
			'<td>'.ryzom_time_txt(ryzom_time_array($member['joined'], '')).'</td>'.
109
			'</tr>';
110
	}
111
	$content .= '</table>';
112

113
	$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>';
114
	return $content;
115
}
116

117
/**
118
  * memberGrade will convert memebr grade string value to int for sorting
119
  *
120
  * @param string $grade one of 'Leader', 'HighOfficer', 'Officer', 'Member'
121
  * @return int
122
  */
123
function memberGrade($grade) {
124
	switch(strtolower($grade)) {
125
	case 'leader': return 0;
126
	case 'highofficer': return 1;
127
	case 'officer': return 2;
128
	case 'member':
129
	default: return 3;
130
	}
131
}
132

133
function render_character($xml, $key) {
134
	$content = '<h1>'.$xml->name.'</h1>';
135
	$content .= '<ul>';
136
	$content .= '<li>Shard: <b>'.$xml->shard.'</b></li>';
137
	$content .= '<li>Race: <b>'.$xml->race.'</b></li>';
138
	$gender = $xml->gender;
139
	$content .= '<li>Gender: <b>'.($gender=='f'?'Female':'Male').'</b></li>';
140
	$title = ryzom_title_txt($xml->titleid, 'en', $gender);
141
	$content .= '<li>Title: <b>'.$title.'</b></li>';
142
	$content .= '</ul>';
143

144
	$content .= '<h2>Hands</h2>';
145
	$result = $xml->xpath('/character/hands/*');
146
	while(list( , $item) = each($result))
147
	{
148
		$content .= ryzom_item_icon_image_from_simplexml($item).' ';
149
	}
150

151
	$content .= '<h2>Equipments</h2>';
152
	$result = $xml->xpath('/character/equipments/*');
153
	while(list( , $item) = each($result))
154
	{
155
		$content .= ryzom_item_icon_image_from_simplexml($item).' ';
156
	}
157

158
	if($xml->guild->name != '') {
159
		$content .= '<h2>Guild</h2>';
160
		$content .= '<ul>';
161
		$content .= '<li>Name: <b>'.$xml->guild->name.'</b></li>';
162
		$guild_icon = ryzom_guild_icon_image($xml->guild->icon, 'b');
163
		$guild_icon_small = ryzom_guild_icon_image($xml->guild->icon, 's');
164
		$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>";
165
		$content .= '</ul>';
166
	} else {
167
		$content .= '<h2>No Guild</h2>';
168
	}
169

170
	// inventories
171

172
	$inv_xml = ryzom_character_simplexml($key, 'items');
173

174
	if(isset($inv_xml->inventories->bag)) {
175
		$content .= '<h2>Bag</h2>';
176
		$content .= '<p>(leave the mouse on an item to display its custom text, if any)</p>';
177
		$result = $inv_xml->xpath('/items/inventories/bag/*');
178
		while(list( , $item) = each($result))
179
		{
180
			$content .= ryzom_item_icon_image_from_simplexml($item);
181
		}
182
	}
183

184
	if(isset($inv_xml->item_in_store)) {
185
		$content .= '<h2>Item in store</h2>';
186
		$content .= '<p>(leave the mouse on an item to display its price)</p>';
187
		$result = $inv_xml->xpath('/items/item_in_store/*');
188
		while(list( , $item) = each($result))
189
		{
190
			$content .= ryzom_item_icon_image_from_simplexml($item, "Price: ".$item['price']);
191
		}
192
	}
193

194
	$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>';
195
	return $content;
196
}
b/render/ryzom_ui.css
1
/* Copyright (C) 2009 Winch Gate Property Limited
2
 *
3
 * This file is part of ryzom_api.
4
 * ryzom_api is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * ryzom_api is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
/*
19
 * Check ryzom_api/functions_render.php for easy php function to render ryzom layout or use this following html:
20
 *
21
	<div class="ryzom-ui">
22
		<div class="ryzom-ui-tl"><div class="ryzom-ui-tr">
23
			<div class="ryzom-ui-t"><!-- title --></div>
24
		</div></div>
25
		<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m">
26
			<div class="ryzom-ui-body"><!-- content --></div>
27
		</div></div></div>
28
		<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div>
29
	</div><!-- .ryzom-ui -->
30
 */
31

32
.ryzom-ui {
33
	color: white;
34
	opacity: .95;
35
}
36
.ryzom-ui input, .ryzom-ui select {
37
	border-top: 1px solid #030403;
38
	border-right: 1px solid #6e7f57;
39
	border-bottom: 1px solid #889e6c;
40
	border-left: 1px solid #272d1f;
41
	background-color: #37402b;
42
	color: #ddd;
43
	font-size: 12px;
44
	margin: 2px 0 5px 0;
45
}
46
.ryzom-ui input[type=text] {
47
	width: 100%;
48
}
49
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */
50
input[type=submit] {
51
	border-bottom: 1px solid #030403;
52
	border-left: 1px solid #6e7f57;
53
	border-top: 1px solid #889e6c;
54
	border-right: 1px solid #272d1f;
55
	background-color: #435120;
56
}
57
input.ryzom-ui-button, .ryzom-ui-button {
58
	border-bottom: 1px solid #030403;
59
	border-left: 1px solid #6e7f57;
60
	border-top: 1px solid #889e6c;
61
	border-right: 1px solid #272d1f;
62
	background-color: #435120;
63
}
64
a.ryzom-ui-button, a.ryzom-ui-button:visited {
65
	color: white;
66
	padding: 0 .5em;
67
	text-decoration: none;
68
}
69
a.ryzom-ui-button:hover {
70
	background: #536130;
71
	color: #ddd;
72
}
73
/* window without title - just borders */
74
.ryzom-ui-tl {
75
	background-image: url(skin_tl.gif);
76
	background-repeat: no-repeat;
77
	background-position: left top;
78
	width: 100%; height: 8px;
79
}
80
.ryzom-ui-tr {
81
	background-image: url(skin_tr.gif);
82
	background-repeat: no-repeat;
83
	background-position: right top;
84
	height: 8px;
85
}
86
.ryzom-ui-t {
87
	background-image: url(skin_t.gif);
88
	background-repeat: repeat-x;
89
	background-position: left top;
90
	height: 8px;
91
	margin: 0 8px;
92
}
93
/* window with proper header */
94
.ryzom-ui-header .ryzom-ui-tl {
95
	margin: 0px 0px;
96
	line-height: 32px;
97
	background-image: url(skin_header_l.gif);
98
	background-repeat: no-repeat;
99
	background-position: left top;
100
	height: 32px;
101
}
102
.ryzom-ui-header .ryzom-ui-tr {
103
	background-image: url(skin_header_r.gif);
104
	background-repeat: no-repeat;
105
	background-position: right top;
106
	height: 32px;
107
}
108
.ryzom-ui-header .ryzom-ui-t {
109
	background-image: url(skin_header_m.gif);
110
	background-repeat: repeat-x;
111
	background-position: left top;
112
	margin-left: 12px;
113
	margin-right: 26px;
114
	height: 32px;
115
	text-transform: uppercase;
116
	color: white;
117
}
118
/* window body */
119
.ryzom-ui-l {
120
	background-image: url(skin_l.gif);
121
	background-position: left top;
122
	background-repeat: repeat-y;
123
	width: 100%;
124
}
125
.ryzom-ui-r {
126
	background-image: url(skin_r.gif);
127
	background-position: right top;
128
	background-repeat: repeat-y;
129
	width: 100%;
130
}
131
.ryzom-ui-m {
132
	margin: 0 8px;
133
	padding: 8px;
134
	background-image: url(skin_blank.png);
135
	background-repeat: repeat;
136
}
137
.ryzom-ui-body {
138
	background-image: url(skin_blank_inner.png);
139
	background-repeat: repeat;
140
	/* leave 5px room after bottom border */
141
	margin: 0px 0 5px 0;
142
	padding: 10px 10px 5px 10px;
143
	border-top: 1px solid #030403;
144
	border-right: 1px solid #6e7f57;
145
	border-bottom: 1px solid #889e6c;
146
	border-left: 1px solid #272d1f;
147
}
148
/* window bottom border */
149
.ryzom-ui-bl {
150
	background-image: url(skin_bl.gif);
151
	background-repeat: no-repeat;
152
	background-position: left top;
153
	height: 8px;
154
}
155
.ryzom-ui-br {
156
	background-image: url(skin_br.gif);
157
	background-repeat: no-repeat;
158
	background-position: right top;
159
	height: 8px;
160
}
161
.ryzom-ui-b {
162
	background-image: url(skin_b.gif);
163
	background-repeat: repeat-x;
164
	background-position: left top;
165
	height: 8px;
166
	margin: 0 8px;
167
}
168
.ryzom-ui-notice {
169
	margin: 0px;
170
	padding: 0px;
171
	color: #333;
172
	text-align: center;
173
}
174
a.ryzom-ui-notice, a.ryzom-ui-notice:visited {
175
	margin: 0px;
176
	padding: 0px;
177
	color: #555;
178
	padding: 0 .5em;
179
	text-decoration: underline;
180
}
181
a.ryzom-ui-notice:hover {
182
	color: grey;
183
}
b/ryzom_api/client_functions_character.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
function ryzom_character_url($key, $part='') {
20
	$params = array('key' => $key) ;
21
	if(!empty($part))
22
		$params['part'] = $part ;
23

24
	return ryzom_url('character.php', $params) ;
25
}
26

19 27
function ryzom_character_simplexml($key, $part='') {
20
	$url = ryzom_api_base_url()."character.php?key=$key".($part!=''?"&part=$part":'');
28

29
	$url = ryzom_character_url($key, $part) ;
30

21 31
	$ch = curl_init();
22 32
	curl_setopt($ch, CURLOPT_URL, $url);
23 33
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
......
28 38
}
29 39

30 40
function ryzom_character_xmlgz($key, $part='') {
31
	return file_get_contents(ryzom_api_base_url()."character.php?key=$key".($part!=''?"&part=$part":''));
41
	return file_get_contents(ryzom_character_url($key, $part));
32 42
}
33 43

34 44
function ryzom_character_valid_key($key, &$uid, &$slot, &$full) {
......
40 50
	return true;
41 51
}
42 52

43
?>
53
?>
b/ryzom_api/client_functions_guild.php
24 24
	return true;
25 25
}
26 26

27
function ryzom_guild_url($key) {
28
	return $ryzom_url('guild.php', array('key' => $key)) ;
29
}
30

27 31
function ryzom_guild_simplexml($key) {
28
	$url = ryzom_api_base_url()."guild.php?key=$key";
32
	$url = ryzom_guild_url($key) ;
29 33
	$ch = curl_init();
30 34
	curl_setopt($ch, CURLOPT_URL, $url);
31 35
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
......
36 40
}
37 41

38 42
function ryzom_guild_xmlgz($key) {
39
	return file_get_contents(ryzom_api_base_url()."guild.php?key=$key");
43
	return file_get_contents(ryzom_guild_url($key)) ;
40 44
}
41 45

42
?>
46
?>
b/ryzom_api/client_functions_guilds.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
function ryzom_guilds_url($shardid) {
20
	return ryzom_url('guilds.php', array('shardid', $shardid)) ;
21
}
22

19 23
function ryzom_guilds_simplexml($shardid) {
20
	$url = ryzom_api_base_url()."guilds.php?shardid=$shardid";
24
	$url = ryzom_guild_url($shardid) ;
21 25
	$ch = curl_init();
22 26
	curl_setopt($ch, CURLOPT_URL, $url);
23 27
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
......
28 32
}
29 33

30 34
function ryzom_guilds_xmlgz($shardid) {
31
	return file_get_contents(ryzom_api_base_url()."guilds.php?shardid=$shardid");
35
	return file_get_contents(ryzom_guild_url('guilds.php', array('shardid' => $shardid)));
32 36
}
33 37

34
?>
38
?>
b/ryzom_api/client_functions_status.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
function ryzom_status_url($format) {
20
	return ryzom_url('status.php', array('format', $format)) ;
21
}
22

19 23
function ryzom_status_array() {
20 24
	$xml = ryzom_status_simplexml();
21 25
	$array = array();
......
26 30
}
27 31

28 32
function ryzom_status_simplexml() {
29
	$xml_txt = file_get_contents(ryzom_api_base_url().'status.php?format=xml');
33
	$xml_txt = file_get_contents(ryzom_status_url($status)) ;
30 34
	return new SimpleXMLElement($xml_txt);
31 35
}
32 36

33
?>
37
?>
b/ryzom_api/client_functions_time.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
function ryzom_time_url($shardid) {
20
	return ryzom_url('time.php', array('shardid', $shardid)) ;
21
}
22

19 23
// return the tick for a specific shard
20 24
function ryzom_time_tick($shardid) {
21
	return file_get_contents(ryzom_api_base_url()."time.php?shardid=$shardid");
25
	return file_get_contents(ryzom_url($shardid));
22 26
}
23 27

24 28
/**
......
28 32
	return ryzom_time_xml_without_cache($rytime);
29 33
}
30 34

31
?>
35
?>
b/ryzom_api/client_functions_title.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
function ryzom_title_url($titleid, $langid, $gender, $format) {
20
	$params = array
21
				( 'titleid' => $titleid
22
				, 'langid' => $langid
23
				) ;
24

25
	if(!empty($gender))
26
		$params['gender'] = $gender ;
27

28
	return ryzom_url('title.php', $params) ;
29
}
30

19 31
function ryzom_title_simplexml($titleid, $langid) {
20
	return simplexml_load_string(file_get_contents(ryzom_api_base_url()."title.php?titleid=$titleid&langid=$langid&format=xml"));
32
	return simplexml_load_string(file_get_contents(ryzom_title_url($titleid, $langid, null, 'xml'))) ;
21 33
}
22 34

23 35
function ryzom_title_txt($titleid, $langid, $gender) {
24
	return file_get_contents(ryzom_api_base_url()."title.php?titleid=$titleid&langid=$langid&gender=$gender&format=txt");
36
	return file_get_contents(ryzom_title_url($titleid, $langid, $gender, 'txt'));
25 37
}
26 38

27
?>
39
?>
b/ryzom_api/functions_banner.php
16 16
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
17 17
 */
18 18

19
require_once 'ryzom_url.php' ;
20

19 21
function ryzom_banner_image($ckey, $langid, $width=500) {
20 22
	return '<img src="'.ryzom_banner_url($ckey, $langid, $width).'"/>';
21 23
}
22 24

23 25
function ryzom_banner_url($ckey, $langid, $width=500) {
24
	return ryzom_api_base_url()."banner.php?ckey=$ckey&langid=$langid&w=$width";
26
	return ryzom_url
27
		( 'banner.php', array
28
			( 'ckey' => $ckey
29
			, 'langid '=> $langid
30
			, 'w' => $width
31
			)
32
		) ;
25 33
}
26 34

27
?>
35
?>
b/ryzom_api/functions_common.php
38 38
	}
39 39
}
40 40

41
function ryzom_api_base_url() {
42
	return 'http://atys.ryzom.com/api/';
43
}
44

45 41
function ryzom_display_xml_header() {
46 42
	header('Content-Type: application/xml; charset=UTF-8');
47 43
}
......
114 110
	if($ryzom_fn!==false) file_put_contents($ryzom_fn, date("Y-m-d H:i:s") .' '. $_SERVER['REMOTE_ADDR'] .' '. $_SERVER['REQUEST_URI'] ." $str\n", FILE_APPEND);
115 111
}
116 112

117
?>
113
?>
b/ryzom_api/functions_guild_icon.php
21 21
}
22 22

23 23
function ryzom_guild_icon_url($icon, $size) {
24
	return ryzom_api_base_url()."guild_icon.php?icon=$icon&size=$size";
24
	return ryzom_url('guild_icon.php?'
25
			, array('icon' => $icon, 'size' => $size)) ;
25 26
}
26 27

27
?>
28
?>
b/ryzom_api/functions_item_icon.php
21 21
}
22 22

23 23
function ryzom_item_icon_url($sheetid, $c=-1, $q=-1, $s=-1, $sap=-1, $destroyed=false) {
24
	return ryzom_api_base_url()."item_icon.php?sheetid=$sheetid&c=$c&q=$q&s=$s&sap=$sap".($destroyed?'&destroyed=1':'');
24
	$params = array
25
		( 'sheetid' => $sheetid
26
		, 'c' => $c
27
		, 'q' => $q
28
		, 's' => $s
29
		, 'sap' => $sap 
30
		) ;
31

32
	if($destroyed)
33
		$params['destroyed'] = 1 ;
34

35
	return ryzom_url('item_icon.php', $params) ;
25 36
}
26 37

27 38
function ryzom_item_icon_image_from_simplexml($item, $add_text='') {
......
39 50
	return "<img title=\"$text\" src=\"$url\"/> ";
40 51
}
41 52

42
?>
53
?>
b/ryzom_api/functions_render.php
18 18

19 19
// Call this inside the <head> part if you wan to use ryzom_render_window()
20 20
function ryzom_render_header() {
21
	return '<link type="text/css" href="ryzom_api/render/ryzom_ui.css" rel="stylesheet" media="all" />';
21
	return '<link type="text/css" href="render/ryzom_ui.css" rel="stylesheet" media="all" />';
22 22
}
23 23

24 24
// Render a Ryzom style window
......
68 68
	';
69 69
}
70 70

71
?>
71
?>
/dev/null
1
/* Copyright (C) 2009 Winch Gate Property Limited
2
 *
3
 * This file is part of ryzom_api.
4
 * ryzom_api is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * ryzom_api is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with ryzom_api.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
/*
19
 * Check ryzom_api/functions_render.php for easy php function to render ryzom layout or use this following html:
20
 *
21
	<div class="ryzom-ui">
22
		<div class="ryzom-ui-tl"><div class="ryzom-ui-tr">
23
			<div class="ryzom-ui-t"><!-- title --></div>
24
		</div></div>
25
		<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m">
26
			<div class="ryzom-ui-body"><!-- content --></div>
27
		</div></div></div>
28
		<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div>
29
	</div><!-- .ryzom-ui -->
30
 */
31

32
.ryzom-ui {
33
	color: white;
34
	opacity: .95;
35
}
36
.ryzom-ui input, .ryzom-ui select {
37
	border-top: 1px solid #030403;
38
	border-right: 1px solid #6e7f57;
39
	border-bottom: 1px solid #889e6c;
40
	border-left: 1px solid #272d1f;
41
	background-color: #37402b;
42
	color: #ddd;
43
	font-size: 12px;
44
	margin: 2px 0 5px 0;
45
}
46
.ryzom-ui input[type=text] {
47
	width: 100%;
48
}
49
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */
50
input[type=submit] {
51
	border-bottom: 1px solid #030403;
52
	border-left: 1px solid #6e7f57;
53
	border-top: 1px solid #889e6c;
54
	border-right: 1px solid #272d1f;
55
	background-color: #435120;
56
}
57
input.ryzom-ui-button, .ryzom-ui-button {
58
	border-bottom: 1px solid #030403;
59
	border-left: 1px solid #6e7f57;
60
	border-top: 1px solid #889e6c;
61
	border-right: 1px solid #272d1f;
62
	background-color: #435120;
63
}
64
a.ryzom-ui-button, a.ryzom-ui-button:visited {
65
	color: white;
66
	padding: 0 .5em;
67
	text-decoration: none;
68
}
69
a.ryzom-ui-button:hover {
70
	background: #536130;
71
	color: #ddd;
72
}
73
/* window without title - just borders */
74
.ryzom-ui-tl {
75
	background-image: url(skin_tl.gif);
76
	background-repeat: no-repeat;
77
	background-position: left top;
78
	width: 100%; height: 8px;
79
}
80
.ryzom-ui-tr {
81
	background-image: url(skin_tr.gif);
82
	background-repeat: no-repeat;
83
	background-position: right top;
84
	height: 8px;
85
}
86
.ryzom-ui-t {
87
	background-image: url(skin_t.gif);
88
	background-repeat: repeat-x;
89
	background-position: left top;
90
	height: 8px;
91
	margin: 0 8px;
92
}
93
/* window with proper header */
94
.ryzom-ui-header .ryzom-ui-tl {
95
	margin: 0px 0px;
96
	line-height: 32px;
97
	background-image: url(skin_header_l.gif);
98
	background-repeat: no-repeat;
99
	background-position: left top;
100
	height: 32px;
101
}
102
.ryzom-ui-header .ryzom-ui-tr {
103
	background-image: url(skin_header_r.gif);
104
	background-repeat: no-repeat;
105
	background-position: right top;
106
	height: 32px;
107
}
108
.ryzom-ui-header .ryzom-ui-t {
109
	background-image: url(skin_header_m.gif);
110
	background-repeat: repeat-x;
111
	background-position: left top;
112
	margin-left: 12px;
113
	margin-right: 26px;
114
	height: 32px;
115
	text-transform: uppercase;
116
	color: white;
117
}
118
/* window body */
119
.ryzom-ui-l {
120
	background-image: url(skin_l.gif);
121
	background-position: left top;
122
	background-repeat: repeat-y;
123
	width: 100%;
124
}
125
.ryzom-ui-r {
126
	background-image: url(skin_r.gif);
127
	background-position: right top;
128
	background-repeat: repeat-y;
129
	width: 100%;
130
}
131
.ryzom-ui-m {
132
	margin: 0 8px;
133
	padding: 8px;
134
	background-image: url(skin_blank.png);
135
	background-repeat: repeat;
136
}
137
.ryzom-ui-body {
138
	background-image: url(skin_blank_inner.png);
139
	background-repeat: repeat;
140
	/* leave 5px room after bottom border */
141
	margin: 0px 0 5px 0;
142
	padding: 10px 10px 5px 10px;
143
	border-top: 1px solid #030403;
144
	border-right: 1px solid #6e7f57;
145
	border-bottom: 1px solid #889e6c;
146
	border-left: 1px solid #272d1f;
147
}
148
/* window bottom border */
149
.ryzom-ui-bl {
150
	background-image: url(skin_bl.gif);
151
	background-repeat: no-repeat;
152
	background-position: left top;
153
	height: 8px;
154
}
155
.ryzom-ui-br {
156
	background-image: url(skin_br.gif);
157
	background-repeat: no-repeat;
158
	background-position: right top;
159
	height: 8px;
160
}
161
.ryzom-ui-b {
162
	background-image: url(skin_b.gif);
163
	background-repeat: repeat-x;
164
	background-position: left top;
165
	height: 8px;
166
	margin: 0 8px;
167
}
168
.ryzom-ui-notice {
169
	margin: 0px;
170
	padding: 0px;
171
	color: #333;
172
	text-align: center;
173
}
174
a.ryzom-ui-notice, a.ryzom-ui-notice:visited {
175
	margin: 0px;
176
	padding: 0px;
177
	color: #555;
178
	padding: 0 .5em;
179
	text-decoration: underline;
180
}
181
a.ryzom-ui-notice:hover {
182
	color: grey;
183
}
b/ryzom_api/ryzom_url.php
1
<?php
2
/* Copyright (C) 2009 Winch Gate Property Limited
3
 *
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.
9
 *
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.
14
 *
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/>.
17
 */
18

19
require_once 'url.php' ;
20

21
const RYZOM_HOST = 'atys.ryzom.com' ;
22
const RYZOM_PATH = 'api' ;
23

24
function ryzom_url($filename, $params)
25
{
26
	return (string) http_url(RYZOM_HOST, RYZOM_PATH, $filename, $params) ;
27
}
28

29

30

31

b/ryzom_api/url.php
1
<?php
2
/* Copyright (C) 2009 Winch Gate Property Limited
3
 *
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.
9
 *
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.
14
 *
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/>.
17
 */
18

19
/** \file
20
 *	Tools to secure URL forging.
21
 *	\todo	Secure attributes and check for malformed file or path names.
22
 */
23

24
function http_url($hostname, $pathname = '', $filename = '', $params = array())
25
{
26
	$url = new http_url ;
27
	$url->hostname = $hostname ;
28
	$url->pathname = $pathname ;
29
	$url->filename = $filename ;
30
	$url->params = $params ;
31

32
	return $url ;
33
}
34

35
class http_url
36
{
37
	public	$hostname = '' ;
38
	public	$pathname = '' ;
39
	public	$filename = '' ;
40
	public	$params = array() ;
41

42
	/*
43
	public	function __construct()
44
	{
45
	}
46
	*/
47

48
	public	function escape($string)
49
	{
50
		return urlencode($string) ;
51
	}
52

53
	public	function __tostring()
54
	{
55
		$searchpart = array() ;
56
		foreach($this->params as $name => $value)
57
			$searchpart[] = sprintf
58
				( '%s=%s'
59
				, $this->escape($name)
60
				, $this->escape($value)
61
				) ;
62
		$searchpart = implode('&', $searchpart) ;
63

64
		$string = sprintf
65
			( 'http://%s/%s/%s?%s'
66
			, $this->hostname
67
			, $this->pathname
68
			, $this->filename
69
			, $searchpart
70
			) ;
71

72
		return $string ;
73
	}
74
}
75