summaryrefslogtreecommitdiff
blob: 741c28cea330f593d5d11da8d0efc9fa11709074 (plain)
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
<?php

header("Content-Type: application/json; charset=UTF-8");

require_once("../../../../wp-config.php");

if ( ! class_exists( 'WMobilePack_Export' ) ) {
    require_once(WMP_PLUGIN_PATH.'export/class-export.php');
}

// Disable error reporting because these methods are used as callbacks by the mobile web app
error_reporting(0);

if (isset($_GET['content'])) {

    $export = new WMobilePack_Export();

    if (isset($_GET['callback'])){

        // filter callback param
        $callback = $export->purifier->purify($_GET['callback']);

        header('Content-Type: application/javascript');

        switch ($_GET['content']) {

            case 'exportcategories':

                echo $callback . '(' . $export->export_categories() . ')';
                break;

            case 'exportarticles':

                echo $callback . '(' . $export->export_articles() . ')';
                break;

            case 'exportarticle':

                echo $callback . '(' . $export->export_article() . ')';
                break;

            case 'exportcomments':

                echo $callback . '(' . $export->export_comments() . ')';
                break;

            case 'savecomment':

                echo $callback . '(' . $export->save_comment() . ')';
                break;

            case 'exportpages':

                echo $callback . '(' . $export->export_pages() . ')';
                break;

            case 'exportpage':

                echo $callback . '(' . $export->export_page() . ')';
                break;

            default:
                echo $callback . '({"error":"No export requested"})';
        }

    } else {

        switch ($_GET['content']) {

            case 'androidmanifest':
            case 'mozillamanifest':

                echo $export->export_manifest();
                break;

            case 'apptexts':

                $app_texts = $export->load_language($_GET['locale']);

                if ($app_texts !== false){
                    header('Content-Type: application/javascript');
                    echo $app_texts;
                }

                break;

            case 'exportsettings':

                echo $export->export_settings();
                break;

            default:
                echo '{"error":"No export requested","status":0}';
        }
    }

}