Subversion Repositories ALCASAR

Rev

Rev 3037 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2808 rexy 1
<?php
2
header('Access-Control-Allow-Origin: *');
3
/**
4
 * generate the xml
5
 *
6
 * PHP version 5
7
 *
8
 * @category  PHP
9
 * @package   PSI_XML
10
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
11
 * @copyright 2009 phpSysInfo
12
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
13
 * @version   SVN: $Id: xml.php 614 2012-07-28 09:02:59Z jacky672 $
14
 * @link      http://phpsysinfo.sourceforge.net
15
 */
16
 
17
 /**
18
 * application root path
19
 *
20
 * @var string
21
 */
22
define('PSI_APP_ROOT', dirname(__FILE__));
23
 
24
require_once PSI_APP_ROOT.'/includes/autoloader.inc.php';
25
 
26
if ((isset($_GET['json']) || isset($_GET['jsonp'])) && !extension_loaded("json")) {
27
    echo '<Error Message="The json extension to php required!" Function="ERROR"/>';
28
} else {
29
    // check what xml part should be generated
30
    if (isset($_GET['plugin'])) {
31
        if (($_GET['plugin'] !== "") && !preg_match('/[^A-Za-z]/', $_GET['plugin'])) {
32
            $output = new WebpageXML($_GET['plugin']);
33
        } else {
34
            unset($output);
35
        }
36
    } else {
37
        $output = new WebpageXML();
38
    }
39
    // if $output is correct generate output in proper type
40
    if (isset($output) && is_object($output)) {
41
        if (isset($_GET['json']) || isset($_GET['jsonp'])) {
42
            header("Cache-Control: no-cache, must-revalidate\n");
43
            $json = $output->getJsonString();
44
            if (isset($_GET['jsonp'])) {
45
                header("Content-Type: application/javascript\n\n");
46
                echo (!preg_match('/[^\w\?]/', $_GET['callback'])?$_GET['callback']:'') . '('.$json.')';
47
            } else {
48
                header("Content-Type: application/json\n\n");
49
                echo $json;
50
            }
51
        } else {
52
            $output->run();
53
        }
54
    }
55
}