summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2016-02-12 22:22:00 -0500
committerYury German <blueknight@gentoo.org>2016-02-12 22:22:00 -0500
commit657cafe0e955cf88033597f131aa50835140c617 (patch)
treecf21a30d319cb2a238a6cfb8b4eb3b20b1b5dcff /plugins/wordpress-mobile-pack/export/content.php
parentAdding New Mantra version 2.4.1.1 - Bug 574468 (diff)
downloadblogs-gentoo-657cafe0e955cf88033597f131aa50835140c617.tar.gz
blogs-gentoo-657cafe0e955cf88033597f131aa50835140c617.tar.bz2
blogs-gentoo-657cafe0e955cf88033597f131aa50835140c617.zip
Updating plugins easy-table, jetpack, openid, public-post preview, talbe-of-contents-plus, wordress-mobile-pack - Bug 574468
Diffstat (limited to 'plugins/wordpress-mobile-pack/export/content.php')
-rw-r--r--plugins/wordpress-mobile-pack/export/content.php159
1 files changed, 92 insertions, 67 deletions
diff --git a/plugins/wordpress-mobile-pack/export/content.php b/plugins/wordpress-mobile-pack/export/content.php
index 99c5428a..741c28ce 100644
--- a/plugins/wordpress-mobile-pack/export/content.php
+++ b/plugins/wordpress-mobile-pack/export/content.php
@@ -1,72 +1,97 @@
-<?php
+<?php
header("Content-Type: application/json; charset=UTF-8");
-require_once("export-class.php");
+
+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"]) && isset($_GET['callback'])) {
-
- // export categories
- if($_GET["content"] == 'exportcategories') { // export categories, optional param: limit
-
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportCategories().')';
-
- } elseif($_GET["content"] == 'exportarticles') { //export articles, optional params: categoryId, lastTimestamp, limit
-
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportArticles().')';
-
- } elseif($_GET["content"] == 'exportarticle' && isset($_GET["articleId"]) && is_numeric($_GET["articleId"])) {
-
- // export article details, mandatory param articleId
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportArticle().')';
-
- } elseif($_GET["content"] == 'exportcomments' && isset($_GET["articleId"]) && is_numeric($_GET["articleId"])) {
-
- // export article details, mandatory param articleId
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportComments().')';
-
- } elseif($_GET["content"] == 'savecomment' && isset($_GET["articleId"]) && is_numeric($_GET["articleId"])) {
-
- // save comment, mandatory get param is articleId
- $export = new Export();
- echo $_GET['callback'] . '('.$export->saveComment().')';
-
- } elseif($_GET["content"] == 'exportpages') {
-
- // export pages
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportPages().')';
-
- } elseif($_GET["content"] == 'exportpage' && isset($_GET["pageId"]) && is_numeric($_GET["pageId"])) {
-
- // save export page, manadatory param is pageId
- $export = new Export();
- echo $_GET['callback'] . '('.$export->exportPage().')';
-
- } else
- echo $_GET['callback'] . '({"error":"No export requested"})';
-
-} elseif (isset($_GET['content']) && $_GET["content"] == 'exportsettings') { // the endpoint for api settings
-
- if (isset($_POST['apiKey']) && $_POST['apiKey'] != '') { // export settings, optional param: limit
-
- $export = new Export();
- echo $export->exportSettings();
-
- } else
- echo '{"error":"No export requested","status" : 0}';
-
-} elseif (isset($_GET['content']) && ($_GET["content"] == 'androidmanifest' || $_GET["content"] == 'mozillamanifest')) {
-
- $export = new Export();
- echo $export->exportManifest();
-
-} else
- echo '({"error":"No export requested"})';
-
-?> \ No newline at end of file
+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}';
+ }
+ }
+
+} \ No newline at end of file