Subversion Repositories ALCASAR

Rev

Rev 3037 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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