File: export.php

package info (click to toggle)
opendb 0.62p9-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,544 kB
  • ctags: 3,560
  • sloc: php: 26,575; sql: 1,982; sh: 250; makefile: 54
file content (569 lines) | stat: -rw-r--r-- 20,670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<?php
/* 	OpenDb - Open Lending Database Project
	Copyright (C) 2001,2002 by Jason Pell

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

// This must be first - includes config.php
require_once("./include/begin.inc.php");

include_once("./include/theme.php");
include_once("./include/language.php");

include_once("./functions/function.php");
include_once("./functions/item_type.php");
include_once("./functions/item.php");
include_once("./functions/item_attribute.php");
include_once("./functions/user.php");
include_once("./functions/widgets.php");
include_once("./functions/utils.php");
include_once("./functions/export.php");

$item_level = 0;

/*
* This function exports a single Item, and will
* be recursively called for child items.  Child
* items do not have children.
*/
function export_type_item($item_id, $instance_no, $s_item_type, $title, $category, $owner_id, $linked_items=NULL, $isChild=FALSE)
{
	global $item_level;
	
	$buffer = "";
	
	$buffer .= start_item($item_level++, $item_id, $s_item_type, $title, $category);
	if($isChild!==TRUE)
	{
		if(is_numeric($instance_no))
		{
			$item_instance_r = fetch_item_instance_r($item_id, $instance_no);
			if(is_not_empty_array($item_instance_r))
				$buffer .= item_instance($item_level, $item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment']);
		}
		else
		{
			$iiresults = fetch_item_instance_rs($item_id, $owner_id);
			if($iiresults)
			{
				while($item_instance_r = mysql_fetch_array($iiresults))
				{
					$buffer .= item_instance($item_level, $item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment']);
				}
				mysql_free_result($iiresults);
			}
		}
		
		if($linked_items != 'exclude')
		{
			$childresults = fetch_child_item_rs($item_id);
			if($childresults)
			{
				while($child_item_r = mysql_fetch_array($childresults))
				{
					// recursive call.
					$buffer .= export_type_item($child_item_r['item_id'], NULL, $child_item_r['s_item_type'], $child_item_r['title'], $child_item_r['category'], NULL, NULL, TRUE);
				}
			
				mysql_free_result($childresults);
			}
		}
	}
		
	//export attributes.
	$attresults = fetch_item_attribute_type_with_val_rs($s_item_type, $item_id, FALSE, TRUE);
	if($attresults)
	{
		while($item_attribute_r = mysql_fetch_array($attresults))
		{
			// Only attribute specific s_field_type's should be exported as XML.
			if(strlen($item_attribute_type_r['s_field_type'])==0 || $item_attribute_type_r['s_field_type'] == 'IMAGE')
				$buffer .= item_attribute($item_level, $item_id, $item_attribute_r['s_attribute_type'], $item_attribute_r['order_no'], $item_attribute_r['attribute_val']);
		}
		mysql_free_result($attresults);
	}
	
	$buffer .= end_item(--$item_level, $item_id);
	return $buffer;
}

function get_data_header($s_item_type)
{
	$headings[] = 'item_id';
	$headings[] = 'instance_no';
	$headings[] = 'owner_id';
	$headings[] = 'parent_id';
	$headings[] = 's_item_type';
		
	// Get the item_attribute headings.
	$results = fetch_item_attribute_type_rs($s_item_type, TRUE, TRUE);
	if($results)
	{
		while($item_attribute_type_r = mysql_fetch_array($results))
		{
			// Only legal s_field_type's - ignore ITEM_ID!!!
			if(strlen($item_attribute_type_r['s_field_type'])==0 || 
						$item_attribute_type_r['s_field_type'] == 'TITLE' || 
						$item_attribute_type_r['s_field_type'] == 'DURATION' ||
						$item_attribute_type_r['s_field_type'] == 'STATUSTYPE' ||
						$item_attribute_type_r['s_field_type'] == 'STATUSCMNT' ||
						$item_attribute_type_r['s_field_type'] == 'CATEGORY' || 
						$item_attribute_type_r['s_field_type'] == 'IMAGE')
			{						
				$headings[] = strtolower($item_attribute_type_r['s_attribute_type']."_".$item_attribute_type_r['order_no']);
			}
		}
		mysql_free_result($results);
	}
	
	return $headings;
}

function get_prompt_header($s_item_type)
{
	global $LANG_VARS;

	$headings[] = $LANG_VARS['item_id'];
	$headings[] = $LANG_VARS['instance_no'];
	$headings[] = $LANG_VARS['owner_id'];
	$headings[] = $LANG_VARS['parent_id'];
	$headings[] = $LANG_VARS[ 's_item_type'];
		
	// Get the item_attribute headings.
	$results = fetch_item_attribute_type_rs($s_item_type, TRUE, TRUE);
	if($results)
	{
		while($item_attribute_type_r = mysql_fetch_array($results))
		{
			// Only legal s_field_type's - ignore ITEM_ID!!!
			if(strlen($item_attribute_type_r['s_field_type'])==0 || 
						$item_attribute_type_r['s_field_type'] == 'TITLE' || 
						$item_attribute_type_r['s_field_type'] == 'DURATION' ||
						$item_attribute_type_r['s_field_type'] == 'STATUSTYPE' ||
						$item_attribute_type_r['s_field_type'] == 'STATUSCMNT' ||
						$item_attribute_type_r['s_field_type'] == 'CATEGORY' || 
						$item_attribute_type_r['s_field_type'] == 'IMAGE')
			{
				$headings[] = $item_attribute_type_r['prompt'];
			}
		}
		mysql_free_result($results);
	}
	
	return $headings;
}

function get_row_array($item_id, $instance_no, $owner_id, $parent_id, $s_item_type, $title, $category, $borrow_duration, $s_status_type, $status_comment)
{
	$row[] = $item_id;
	$row[] = $instance_no;
	$row[] = $owner_id;
	$row[] = $parent_id;
	$row[] = $s_item_type;
			
	$results = fetch_item_attribute_type_with_val_rs($s_item_type, $item_id, TRUE, TRUE);
	if($results)
	{
		while($item_attribute_type_r = mysql_fetch_array($results))
		{
			if($item_attribute_type_r['s_field_type'] == 'TITLE')
				$row[] = $title;
			else if($item_attribute_type_r['s_field_type'] == 'DURATION')
				$row[] = $borrow_duration;
			else if($item_attribute_type_r['s_field_type'] == 'STATUSTYPE')
				$row[] = $s_status_type;
			else if($item_attribute_type_r['s_field_type'] == 'STATUSCMNT')
				$row[] = $status_comment;
			else if($item_attribute_type_r['s_field_type'] == 'CATEGORY')
				$row[] = $category;
			else if($item_attribute_type_r['s_field_type'] != 'ITEM_ID')
				$row[] = $item_attribute_type_r['attribute_val'];
		}
		mysql_free_result($results);
	}
	return $row;
}

function export_linked_row_items($item_id)
{
	$buffer = "";
	
	$childresults = fetch_child_item_rs($item_id);
	if($childresults)
	{
		while($child_item_r = mysql_fetch_array($childresults))
		{
			echo item_row(
				get_row_array($child_item_r['item_id'], NULL, NULL, $item_id, $child_item_r['s_item_type'], $child_item_r['title'], $child_item_r['category'], NULL, NULL, NULL));
		}
		mysql_free_result($childresults);
	}
	
	return $buffer;
}

/*
* Output content, in correct 'send_as_format'.  if the
* Send_as_format is not 'file' we assume it should be
* streamed directly to the browser.
*/
function echo_output($send_as_format, $buffer)
{
	if($send_as_format == 'file')
		return $buffer;
	else
		return str_replace("\t", str_repeat("&nbsp;",8), htmlspecialchars($buffer));
}

function echo_output_header($title, $send_as_format)
{
	if($send_as_format == 'file')
	{
		// hard code for now
		$filename_prefix = 'export';
	
		if(function_exists('file_extension'))
			$filename = "$filename_prefix.".file_extension();
		else
			$filename = "$filename_prefix.txt";
									
		if(function_exists('file_content_type'))
			$content_type = file_content_type();
		else
			$content_type = 'application/octetstream';

		header("Cache-control: no-store");
		header("Pragma: no-store");
		header("Expires: 0");
		header("Content-disposition: attachment; filename=$filename");
		header("Content-type: $content_type");
		
		if(function_exists('file_header'))
			echo file_header($title);
	}
	else
	{
		echo _theme_header($title);
		echo("<h2>".$title."</h2>");
									
		echo("<pre>");
	}			
}

function echo_output_footer($send_as_format)
{
	if($send_as_format == 'file')
	{
		if(function_exists('file_footer'))
			echo file_footer();
	}
	else
	{
		echo("</pre>");
		echo _theme_footer();
	}
}

/*
* Export Type 
* 
* @param linked_items - 'include' or 'exclude'
*/
function export_type_items($title, $send_as_format, $s_item_type, $item_id, $instance_no, $owner_id, $linked_items)
{
	global $item_level;

	$itemresults = fetch_export_item_rs($s_item_type, $item_id, $owner_id);
	if($itemresults)
	{
		echo_output_header($title, $send_as_format);
		while($item_r = mysql_fetch_array($itemresults))
		{
			$item_level = 0;
			echo echo_output(
					$send_as_format, 
					export_type_item($item_r['item_id'],
								$instance_no,
								$item_r['s_item_type'],
								$item_r['title'],
								$item_r['category'],
								$owner_id,
								$linked_items));
		}
		mysql_free_result($itemresults);
		
		echo_output_footer($send_as_format);
		return TRUE;
	}
	else
		return FALSE;
}

function export_row_items($title, $send_as_format, $s_item_type, $owner_id, $linked_items)
{
	$iiresults = fetch_export_item_instance_rs($s_item_type, $owner_id);
	if($iiresults)
	{
		echo_output_header($title, $send_as_format);
		if(function_exists('prompt_header'))
			echo echo_output($send_as_format, prompt_header(get_prompt_header($s_item_type)));
		else if(function_exists('data_header'))
			echo echo_output($send_as_format, data_header(get_data_header($s_item_type)));
		
		$item_instance_r2 = NULL;
		while($item_instance_r = mysql_fetch_array($iiresults))
		{
			// If we have changed item_id's then we need to do the child items, before continuing.
			if($linked_items !== 'exclude' && $item_instance_r2!=NULL && $item_instance_r2['item_id'] != $item_instance_r['item_id'])
				echo echo_output($send_as_format, export_linked_row_items($item_instance_r2['item_id']));
					
			echo echo_output(
						$send_as_format, 
						item_row(get_row_array($item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], NULL, $item_instance_r['s_item_type'], $item_instance_r['title'], $item_instance_r['category'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment'])));
						
			$item_instance_r2 = $item_instance_r;
		}
		
		// If we have changed item_id's then we need to do the child items, before continuing.
		if($linked_items !== 'exclude' && $item_instance_r!=NULL)
			echo echo_output($send_as_format, export_linked_row_items($item_instance_r2['item_id']));
		
		mysql_free_result($iiresults);
		
		// If get_buffer exists, then the plugin is keeping an internal buffer, and the
		// data_header / prompt_header / item_row functions are all returning NULL.
		if(function_exists('get_export_buffer'))
			echo echo_output($send_as_format, get_export_buffer());
		
		if(function_exists('close_export'))
			echo echo_output($send_as_format, close_export());

		echo_output_footer($send_as_format);
		return TRUE;
	}
	else
		return FALSE;
}

session_start();
if(is_opendb_valid_session())
{
	if ( is_user_allowed_to_own($HTTP_SESSION_VARS['user_id'], $HTTP_SESSION_VARS['user_type']) )
	{
		if($HTTP_VARS['op'] == 'export')
		{
			if(is_legal_export_type($HTTP_VARS['type']))
			{
				// Either owner_id not specified, in which case we would export for current user, or owner_id is specified
				// and is the same as current user or user is admin, where no item_id specified.
				if(is_numeric($HTTP_VARS['item_id']) ||
						(!is_numeric($HTTP_VARS['item_id']) && (strlen($HTTP_VARS['owner_id'])==0 || $HTTP_VARS['owner_id']==$HTTP_SESSION_VARS['user_id'] || is_user_admin($HTTP_SESSION_VARS['user_id'], $HTTP_SESSION_VARS['user_type']))))
				{
					if((strlen($HTTP_VARS['s_item_type'])==0 && is_numeric($HTTP_VARS['item_id'])) || is_valid_item_type_structure($HTTP_VARS['s_item_type']))
					{
						@set_time_limit(600);
						
						// Now include the plugin code.
						include("./export/".$HTTP_VARS['type'].".php");
						
						// If the 'item_row' function is defined, then we assume that we are
						// working with a row orientated plugin.  Otherwise 
						if(function_exists('item_row'))
						{
							// Work out page title.
							if(strlen($HTTP_VARS['owner_id'])>0)
								$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'fullname'=>fetch_user_name($HTTP_VARS['owner_id']),'user_id'=>$HTTP_VARS['owner_id'], 's_item_type'=>$HTTP_VARS['s_item_type']), $LANG_VARS['type_export_for_name_item_type']);
							else
								$page_title = replace_lang_var("type", get_display_export_type($HTTP_VARS['type']), $LANG_VARS['type_export']);
							
							if(!export_row_items($page_title, $HTTP_VARS['send_as_format'], $HTTP_VARS['s_item_type'], $HTTP_VARS['owner_id'], $HTTP_VARS['linked_items']))
							{
								echo _theme_header($page_title);
								echo("<h2>".$page_title."</h2>");
								echo format_error_block(array('error'=>$LANG_VARS['no_records_found'],'detail'=>''));
								echo _theme_footer();
							}
						}
						else // XML 'type' export.
						{
							// Work out page title.
							if(strlen($HTTP_VARS['owner_id'])>0 || is_numeric($HTTP_VARS['item_id']))
							{
								if(strlen($HTTP_VARS['owner_id'])>0 && strlen($HTTP_VARS['s_item_type'])>0)
									$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'fullname'=>fetch_user_name($HTTP_VARS['owner_id']),'user_id'=>$HTTP_VARS['owner_id'], 's_item_type'=>$HTTP_VARS['s_item_type']), $LANG_VARS['type_export_for_name_item_type']);
								else if(strlen($HTTP_VARS['s_item_type'])>0)
									$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'s_item_type'=>$HTTP_VARS['s_item_type']), $LANG_VARS['type_export_for_item_type']);
								else if(is_numeric($HTTP_VARS['item_id']) && is_numeric($HTTP_VARS['instance_no']))
								{
									$item_r = fetch_item_instance_r($HTTP_VARS['item_id'], $HTTP_VARS['instance_no']);
									$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'item_id'=>$HTTP_VARS['item_id'],'instance_no'=>$HTTP_VARS['instance_no'],'title'=>expand_item_title_mask($item_r['title'], $item_r['s_item_type'], $item_r['item_id'], $item_r['instance_no'], $item_r['s_status_type'], $CONFIG_VARS['item_display.title_display_mask'])), $LANG_VARS['type_export_for_item_instance']);
								}
								else if(is_numeric($HTTP_VARS['item_id']))
								{
									// Not really a child item, but we are not interested in the instance, so use this.  It still
									// returns the right data anyway.
									$item_r = fetch_child_item_r($HTTP_VARS['item_id']);
									$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'item_id'=>$HTTP_VARS['item_id'],'title'=>expand_item_title_mask($item_r['title'], $item_r['s_item_type'], $item_r['item_id'], NULL, NULL, $CONFIG_VARS['item_display.title_display_mask'])), $LANG_VARS['type_export_for_item']);
								}
								else //if(strlen($HTTP_VARS['owner_id'])>0)
									$page_title = replace_lang_vars(array('type'=>get_display_export_type($HTTP_VARS['type']),'fullname'=>fetch_user_name($HTTP_VARS['owner_id']), 'user_id'=>$HTTP_VARS['owner_id']), $LANG_VARS['type_export_for_name']);
							}
							else
								$page_title = replace_lang_var("type", get_display_export_type($HTTP_VARS['type']), $LANG_VARS['type_export']);
								
							if(!export_type_items($page_title, $HTTP_VARS['send_as_format'], $HTTP_VARS['s_item_type'], $HTTP_VARS['item_id'], $HTTP_VARS['instance_no'], $HTTP_VARS['owner_id'], $HTTP_VARS['linked_items']))
							{
								echo _theme_header($page_title);
								echo("<h2>".$page_title."</h2>");
								echo format_error_block(array('error'=>$LANG_VARS['no_records_found'],'detail'=>''));
								echo _theme_footer();
							}
						}
					}
					else//if(is_valid_item_type_structure($HTTP_VARS['s_item_type']))
					{
						$page_title = replace_lang_var("type", get_display_export_type($HTTP_VARS['type']), $LANG_VARS['type_export']);
						echo _theme_header($page_title);
						echo("<h2>".$page_title."</h2>");
						echo format_error_block(array('error'=>replace_lang_var("s_item_type", $HTTP_VARS['s_item_type'], $LANG_VARS['invalid_item_type_structure']),'detail'=>''));
						echo _theme_footer();
					}
				}
				else //no access available for specified item, or illegal owner specified.
				{
					$page_title = replace_lang_var("type", get_display_export_type($HTTP_VARS['type']), $LANG_VARS['type_export']);
					echo _theme_header($page_title);
					echo("<h2>".$page_title."</h2>");
					echo format_error_block(array('error'=>$LANG_VARS['operation_not_available'],'detail'=>''));
					echo _theme_footer();
				}
			}
			else //if(is_legal_export_type($HTTP_VARS['type']))
			{
				$page_title = replace_lang_var("type", get_display_export_type($HTTP_VARS['type']), $LANG_VARS['type_export']);
				echo _theme_header($page_title);
				echo("<h2>".$page_title."</h2>");
				echo format_error_block(array('error'=>replace_lang_var("type", $HTTP_VARS['type'], $LANG_VARS['illegal_export_type']),'detail'=>''));
				echo _theme_footer();
			}
		}
		else
		{
			// A custom title.
			if(is_user_admin($HTTP_SESSION_VARS['user_id'], $HTTP_SESSION_VARS['user_type']) && strlen($HTTP_VARS['owner_id'])==0)
				$page_title = $LANG_VARS['export_items'];
			else if($HTTP_VARS['owner_id'] == $HTTP_SESSION_VARS['user_id'] || strlen($HTTP_VARS['owner_id'])==0)
				$page_title = $LANG_VARS['export_my_items'];
				
			echo _theme_header($page_title);
			echo("<h2>".$page_title."</h2>");
			
			echo("<form name=\"search\" method=\"get\" action=\"$PHP_SELF\">");
			echo("<table border=0 frameborder=0 cellspacing=1>");
			echo("\n<input type=hidden name=op value=\"export\">");
			
			// Item Type select block.
			echo format_field(
					$LANG_VARS['item_type'], 
					NULL,
					single_select("s_item_type", 
						fetch_item_type_rs(TRUE), 
						"%value% - %display%", 
						NULL, 
						$HTTP_VARS['s_item_type']
					)
				);
			
			if($CONFIG_VARS['item_input.linked_item_support']!==FALSE)
			{
				echo format_field(
					$LANG_VARS['linked_item(s)'],
					NULL,
						"\n<input type=radio name=\"linked_items\" value=\"include\" CHECKED>".$LANG_VARS['include']."&nbsp;&nbsp;".
 							"<input type=radio name=\"linked_items\" value=\"exclude\">".$LANG_VARS['exclude']);
			}
						
			// Do not show OwnerID field, if not an admin user.
			if($HTTP_VARS['owner_id'] != $HTTP_SESSION_VARS['user_id'] && is_user_admin($HTTP_SESSION_VARS['user_id'], $HTTP_SESSION_VARS['user_type']))
			{
				// Item Type field.
				echo format_field(
						$LANG_VARS['owner'], 
						NULL,
						"\n<select name=\"owner_id\">".
							"\n<option value=\"\">-------------- ".$LANG_VARS['all']." --------------".
							custom_select(
								'owner_id', 
								fetch_user_rs(get_owner_user_types_r()), 
								'%fullname% (%user_id%)',
								'NA',
								NULL,
								'user_id'
							).
							"\n</select>"
						);
			}
			else
			{
				echo("<input type=\"hidden\" name=\"owner_id\" value=\"".$HTTP_VARS['owner_id']."\">");
			}
			
			$field = "\n<select name=\"type\">\n";
			$export_type_rs = get_export_r();
			if(is_array($export_type_rs))
			{
				while(list(,$value) = @each($export_type_rs))
				{
					$field .= "<option value=\"$value\">".get_display_export_type($value)."\n";
				}
			}
			$field .= "</select>";
			
			echo format_field(
				$LANG_VARS['type'], 
				NULL, 
				$field
			);
			
			echo format_field(
				$LANG_VARS['send_as_file'],
				NULL,
				"<input type=\"checkbox\" name=\"send_as_format\" value=\"file\" CHECKED>");
			
			echo("<tr><td align=center colspan=2>");
			echo("<br><input type=submit value=\"".$page_title."\">");
			echo("</td></tr>");
	
			echo("</table>");
			echo("</form>");
			echo _theme_footer();
		}
	}
	else//no guests or borrowers allowed!
	{
		echo _theme_header($LANG_VARS['not_authorized_to_page']);
		echo _theme_error($LANG_VARS['not_authorized_to_page']);
		echo _theme_footer();
	}	
}
else
{
	include("./include/invalidsession.php");
}

// Cleanup after begin.inc.php
require_once("./include/end.inc.php");
?>