hpdl
|
477
|
1
|
<?php
|
|
2
|
/*
|
hpdl
|
1739
|
3
|
$Id: html_output.php 1839 2008-12-12 11:15:33Z hpdl $
|
hpdl
|
477
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
1839
|
8
|
Copyright (c) 2008 osCommerce
|
hpdl
|
477
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
|
13
|
////
|
|
14
|
// The HTML href link wrapper function
|
|
15
|
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
|
hpdl
|
1839
|
16
|
$page = tep_output_string($page);
|
|
17
|
|
hpdl
|
477
|
18
|
if ($page == '') {
|
|
19
|
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
|
|
20
|
}
|
|
21
|
if ($connection == 'NONSSL') {
|
|
22
|
$link = HTTP_SERVER . DIR_WS_ADMIN;
|
|
23
|
} elseif ($connection == 'SSL') {
|
|
24
|
if (ENABLE_SSL == 'true') {
|
|
25
|
$link = HTTPS_SERVER . DIR_WS_ADMIN;
|
|
26
|
} else {
|
|
27
|
$link = HTTP_SERVER . DIR_WS_ADMIN;
|
|
28
|
}
|
|
29
|
} else {
|
|
30
|
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
|
|
31
|
}
|
|
32
|
if ($parameters == '') {
|
|
33
|
$link = $link . $page . '?' . SID;
|
|
34
|
} else {
|
hpdl
|
1839
|
35
|
$link = $link . $page . '?' . tep_output_string($parameters) . '&' . SID;
|
hpdl
|
477
|
36
|
}
|
|
37
|
|
|
38
|
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
|
|
39
|
|
|
40
|
return $link;
|
|
41
|
}
|
|
42
|
|
|
43
|
function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
|
|
44
|
if ($connection == 'NONSSL') {
|
|
45
|
$link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
|
|
46
|
} elseif ($connection == 'SSL') {
|
|
47
|
if (ENABLE_SSL_CATALOG == 'true') {
|
|
48
|
$link = HTTPS_CATALOG_SERVER . DIR_WS_CATALOG;
|
|
49
|
} else {
|
|
50
|
$link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
|
|
51
|
}
|
|
52
|
} else {
|
|
53
|
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
|
|
54
|
}
|
|
55
|
if ($parameters == '') {
|
|
56
|
$link .= $page;
|
|
57
|
} else {
|
|
58
|
$link .= $page . '?' . $parameters;
|
|
59
|
}
|
|
60
|
|
|
61
|
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
|
|
62
|
|
|
63
|
return $link;
|
|
64
|
}
|
|
65
|
|
|
66
|
////
|
|
67
|
// The HTML image wrapper function
|
|
68
|
function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
|
|
69
|
$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
|
|
70
|
|
|
71
|
if (tep_not_null($alt)) {
|
|
72
|
$image .= ' title=" ' . tep_output_string($alt) . ' "';
|
|
73
|
}
|
|
74
|
|
|
75
|
if (tep_not_null($width) && tep_not_null($height)) {
|
|
76
|
$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
|
|
77
|
}
|
|
78
|
|
|
79
|
if (tep_not_null($parameters)) $image .= ' ' . $parameters;
|
|
80
|
|
|
81
|
$image .= '>';
|
|
82
|
|
|
83
|
return $image;
|
|
84
|
}
|
|
85
|
|
|
86
|
////
|
|
87
|
// The HTML form submit button wrapper function
|
|
88
|
// Outputs a button in the selected language
|
|
89
|
function tep_image_submit($image, $alt = '', $parameters = '') {
|
|
90
|
global $language;
|
|
91
|
|
|
92
|
$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';
|
|
93
|
|
|
94
|
if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';
|
|
95
|
|
|
96
|
if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
|
|
97
|
|
|
98
|
$image_submit .= '>';
|
|
99
|
|
|
100
|
return $image_submit;
|
|
101
|
}
|
|
102
|
|
|
103
|
////
|
|
104
|
// Draw a 1 pixel black line
|
|
105
|
function tep_black_line() {
|
|
106
|
return tep_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1');
|
|
107
|
}
|
|
108
|
|
|
109
|
////
|
|
110
|
// Output a separator either through whitespace, or with an image
|
|
111
|
function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
|
|
112
|
return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
|
|
113
|
}
|
|
114
|
|
|
115
|
////
|
|
116
|
// Output a function button in the selected language
|
|
117
|
function tep_image_button($image, $alt = '', $params = '') {
|
|
118
|
global $language;
|
|
119
|
|
|
120
|
return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params);
|
|
121
|
}
|
|
122
|
|
|
123
|
////
|
|
124
|
// javascript to dynamically update the states/provinces list when the country is changed
|
|
125
|
// TABLES: zones
|
|
126
|
function tep_js_zone_list($country, $form, $field) {
|
|
127
|
$countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id");
|
|
128
|
$num_country = 1;
|
|
129
|
$output_string = '';
|
|
130
|
while ($countries = tep_db_fetch_array($countries_query)) {
|
|
131
|
if ($num_country == 1) {
|
|
132
|
$output_string .= ' if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n";
|
|
133
|
} else {
|
|
134
|
$output_string .= ' } else if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n";
|
|
135
|
}
|
|
136
|
|
|
137
|
$states_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $countries['zone_country_id'] . "' order by zone_name");
|
|
138
|
|
|
139
|
$num_state = 1;
|
|
140
|
while ($states = tep_db_fetch_array($states_query)) {
|
|
141
|
if ($num_state == '1') $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n";
|
|
142
|
$output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n";
|
|
143
|
$num_state++;
|
|
144
|
}
|
|
145
|
$num_country++;
|
|
146
|
}
|
|
147
|
$output_string .= ' } else {' . "\n" .
|
|
148
|
' ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" .
|
|
149
|
' }' . "\n";
|
|
150
|
|
|
151
|
return $output_string;
|
|
152
|
}
|
|
153
|
|
|
154
|
////
|
|
155
|
// Output a form
|
|
156
|
function tep_draw_form($name, $action, $parameters = '', $method = 'post', $params = '') {
|
|
157
|
$form = '<form name="' . tep_output_string($name) . '" action="';
|
|
158
|
if (tep_not_null($parameters)) {
|
|
159
|
$form .= tep_href_link($action, $parameters);
|
|
160
|
} else {
|
|
161
|
$form .= tep_href_link($action);
|
|
162
|
}
|
|
163
|
$form .= '" method="' . tep_output_string($method) . '"';
|
|
164
|
if (tep_not_null($params)) {
|
|
165
|
$form .= ' ' . $params;
|
|
166
|
}
|
|
167
|
$form .= '>';
|
|
168
|
|
|
169
|
return $form;
|
|
170
|
}
|
|
171
|
|
|
172
|
////
|
|
173
|
// Output a form input field
|
|
174
|
function tep_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
|
hpdl
|
1599
|
175
|
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
|
176
|
|
hpdl
|
477
|
177
|
$field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
|
|
178
|
|
hpdl
|
1599
|
179
|
if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
|
|
180
|
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
|
|
181
|
$value = stripslashes($HTTP_GET_VARS[$name]);
|
|
182
|
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
|
|
183
|
$value = stripslashes($HTTP_POST_VARS[$name]);
|
|
184
|
}
|
|
185
|
}
|
|
186
|
|
|
187
|
if (tep_not_null($value)) {
|
hpdl
|
477
|
188
|
$field .= ' value="' . tep_output_string($value) . '"';
|
|
189
|
}
|
|
190
|
|
|
191
|
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
|
|
192
|
|
|
193
|
$field .= '>';
|
|
194
|
|
|
195
|
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
|
|
196
|
|
|
197
|
return $field;
|
|
198
|
}
|
|
199
|
|
|
200
|
////
|
|
201
|
// Output a form password field
|
|
202
|
function tep_draw_password_field($name, $value = '', $required = false) {
|
|
203
|
$field = tep_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false);
|
|
204
|
|
|
205
|
return $field;
|
|
206
|
}
|
|
207
|
|
|
208
|
////
|
|
209
|
// Output a form filefield
|
|
210
|
function tep_draw_file_field($name, $required = false) {
|
|
211
|
$field = tep_draw_input_field($name, '', '', $required, 'file');
|
|
212
|
|
|
213
|
return $field;
|
|
214
|
}
|
|
215
|
|
|
216
|
////
|
|
217
|
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
|
|
218
|
function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '') {
|
hpdl
|
1599
|
219
|
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
|
220
|
|
hpdl
|
477
|
221
|
$selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
|
|
222
|
|
|
223
|
if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
|
|
224
|
|
hpdl
|
1599
|
225
|
if ( ($checked == true) || (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name]) && (($HTTP_GET_VARS[$name] == 'on') || (stripslashes($HTTP_GET_VARS[$name]) == $value))) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name]) && (($HTTP_POST_VARS[$name] == 'on') || (stripslashes($HTTP_POST_VARS[$name]) == $value))) || (tep_not_null($compare) && ($value == $compare)) ) {
|
hpdl
|
477
|
226
|
$selection .= ' CHECKED';
|
|
227
|
}
|
|
228
|
|
|
229
|
$selection .= '>';
|
|
230
|
|
|
231
|
return $selection;
|
|
232
|
}
|
|
233
|
|
|
234
|
////
|
|
235
|
// Output a form checkbox field
|
|
236
|
function tep_draw_checkbox_field($name, $value = '', $checked = false, $compare = '') {
|
|
237
|
return tep_draw_selection_field($name, 'checkbox', $value, $checked, $compare);
|
|
238
|
}
|
|
239
|
|
|
240
|
////
|
|
241
|
// Output a form radio field
|
|
242
|
function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '') {
|
|
243
|
return tep_draw_selection_field($name, 'radio', $value, $checked, $compare);
|
|
244
|
}
|
|
245
|
|
|
246
|
////
|
|
247
|
// Output a form textarea field
|
|
248
|
function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
|
hpdl
|
1599
|
249
|
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
|
250
|
|
hpdl
|
477
|
251
|
$field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
|
|
252
|
|
|
253
|
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
|
|
254
|
|
|
255
|
$field .= '>';
|
|
256
|
|
hpdl
|
1599
|
257
|
if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
|
|
258
|
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
|
|
259
|
$field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name]));
|
|
260
|
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
|
|
261
|
$field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name]));
|
|
262
|
}
|
hpdl
|
477
|
263
|
} elseif (tep_not_null($text)) {
|
|
264
|
$field .= tep_output_string_protected($text);
|
|
265
|
}
|
|
266
|
|
|
267
|
$field .= '</textarea>';
|
|
268
|
|
|
269
|
return $field;
|
|
270
|
}
|
|
271
|
|
|
272
|
////
|
|
273
|
// Output a form hidden field
|
|
274
|
function tep_draw_hidden_field($name, $value = '', $parameters = '') {
|
hpdl
|
1599
|
275
|
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
|
276
|
|
hpdl
|
477
|
277
|
$field = '<input type="hidden" name="' . tep_output_string($name) . '"';
|
|
278
|
|
|
279
|
if (tep_not_null($value)) {
|
|
280
|
$field .= ' value="' . tep_output_string($value) . '"';
|
hpdl
|
1599
|
281
|
} elseif ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
|
|
282
|
if ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) ) {
|
|
283
|
$field .= ' value="' . tep_output_string(stripslashes($HTTP_GET_VARS[$name])) . '"';
|
|
284
|
} elseif ( (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
|
|
285
|
$field .= ' value="' . tep_output_string(stripslashes($HTTP_POST_VARS[$name])) . '"';
|
|
286
|
}
|
hpdl
|
477
|
287
|
}
|
|
288
|
|
|
289
|
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
|
|
290
|
|
|
291
|
$field .= '>';
|
|
292
|
|
|
293
|
return $field;
|
|
294
|
}
|
|
295
|
|
|
296
|
////
|
hpdl
|
1607
|
297
|
// Hide form elements
|
|
298
|
function tep_hide_session_id() {
|
|
299
|
$string = '';
|
|
300
|
|
|
301
|
if (defined('SID') && tep_not_null(SID)) {
|
|
302
|
$string = tep_draw_hidden_field(tep_session_name(), tep_session_id());
|
|
303
|
}
|
|
304
|
|
|
305
|
return $string;
|
|
306
|
}
|
|
307
|
|
|
308
|
////
|
hpdl
|
477
|
309
|
// Output a form pull down menu
|
|
310
|
function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
|
hpdl
|
1599
|
311
|
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
|
312
|
|
hpdl
|
477
|
313
|
$field = '<select name="' . tep_output_string($name) . '"';
|
|
314
|
|
|
315
|
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
|
|
316
|
|
|
317
|
$field .= '>';
|
|
318
|
|
hpdl
|
1599
|
319
|
if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
|
|
320
|
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
|
|
321
|
$default = stripslashes($HTTP_GET_VARS[$name]);
|
|
322
|
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
|
|
323
|
$default = stripslashes($HTTP_POST_VARS[$name]);
|
|
324
|
}
|
|
325
|
}
|
hpdl
|
477
|
326
|
|
|
327
|
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
|
|
328
|
$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
|
|
329
|
if ($default == $values[$i]['id']) {
|
|
330
|
$field .= ' SELECTED';
|
|
331
|
}
|
|
332
|
|
|
333
|
$field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';
|
|
334
|
}
|
|
335
|
$field .= '</select>';
|
|
336
|
|
|
337
|
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
|
|
338
|
|
|
339
|
return $field;
|
|
340
|
}
|
|
341
|
?>
|