Esempio n. 1
0
/**
 * @file
 * Display all users in XML or JSON format.
 * @package com.tecnick.tcexam.admin
 * @author Nicola Asuni
 * @since 2006-03-17
 */
/**
 */
// check user's authorization
require_once '../config/tce_config.php';
$pagelevel = K_AUTH_EXPORT_USERS;
require_once '../../shared/code/tce_authorization.php';
$output_format = isset($_REQUEST['format']) ? strtoupper($_REQUEST['format']) : 'XML';
$out_filename = 'tcexam_users_' . date('YmdHis');
$xml = F_xml_export_users();
switch ($output_format) {
    case 'JSON':
        header('Content-Description: JSON File Transfer');
        header('Cache-Control: public, must-revalidate, max-age=0');
        // HTTP/1.1
        header('Pragma: public');
        header('Expires: Thu, 04 Jan 1973 00:00:00 GMT');
        // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        // force download dialog
        header('Content-Type: application/force-download');
        header('Content-Type: application/octet-stream', false);
        header('Content-Type: application/download', false);
        header('Content-Type: application/json', false);
        // use the Content-Disposition header to supply a recommended filename
Esempio n. 2
0
header('Content-Description: XML File Transfer');
header('Cache-Control: public, must-revalidate, max-age=0');
// HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// force download dialog
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream', false);
header('Content-Type: application/download', false);
header('Content-Type: application/xml', false);
// use the Content-Disposition header to supply a recommended filename
header('Content-Disposition: attachment; filename=tcexam_users_' . date('YmdHis') . '.xml;');
header('Content-Transfer-Encoding: binary');
echo F_xml_export_users();
/**
 * Export all users to XML grouped by users' groups.
 * @author Nicola Asuni
 * @since 2006-03-17
 * @return XML data
 */
function F_xml_export_users()
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $boolean = array('false', 'true');
    $xml = '';
    // XML data to be returned
    $xml .= '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . K_NEWLINE;
    $xml .= '<tcexamusers version="' . K_TCEXAM_VERSION . '">' . K_NEWLINE;