function get_json($data, $status = 'ok') { // Include a status value with the response if (is_array($data)) { $data = array_merge(array('status' => $status), $data); } else { if (is_object($data)) { $data = get_object_vars($data); $data = array_merge(array('status' => $status), $data); } } $data = apply_filters('wpapp_encode', $data); if (function_exists('json_encode')) { // Use the built-in json_encode function if it's available return json_encode($data); } else { // Use PEAR's Services_JSON encoder otherwise if (!class_exists('Services_JSON')) { $dir = wpapp_dir(); require_once "{$dir}/library/JSON.php"; } $json = new Services_JSON(); return $json->encode($data); } }
public function info() { global $wpapp; $php = ''; if (!empty($wpapp->query->controller)) { return $wpapp->controller_info($wpapp->query->controller); } else { $dir = wpapp_dir(); if (file_exists("{$dir}/wpapp.php")) { $php = file_get_contents("{$dir}/wpapp.php"); } else { // Check one directory up, in case wpapp.php was moved $dir = dirname($dir); if (file_exists("{$dir}/wpapp.php")) { $php = file_get_contents("{$dir}/wpapp.php"); } } if (preg_match('/^\\s*Version:\\s*(.+)$/m', $php, $matches)) { $version = $matches[1]; } else { $version = '(Unknown)'; } $active_controllers = explode(',', get_option('wpapp_controllers', 'core')); $controllers = array_intersect($wpapp->get_controllers(), $active_controllers); return array('wpapp_version' => $version, 'controllers' => array_values($controllers)); } }
function controller_path($controller) { $dir = wpapp_dir(); $controller_class = $this->controller_class($controller); return apply_filters("{$controller_class}_path", "{$dir}/controllers/{$controller}.php"); }
<?php /* Plugin Name: WPAPP Plugin URI: http://github.com/dodyrw/wpapp Description: Secure data provider for WpApp WordPress mobile app. Version: 3.0.0 Author: Dody Rachmat W. Author URI: http://www.dodyrw.com/ */ $dir = wpapp_dir(); @(include_once "{$dir}/singletons/api.php"); @(include_once "{$dir}/singletons/query.php"); @(include_once "{$dir}/singletons/introspector.php"); @(include_once "{$dir}/singletons/response.php"); @(include_once "{$dir}/models/post.php"); @(include_once "{$dir}/models/comment.php"); @(include_once "{$dir}/models/category.php"); @(include_once "{$dir}/models/tag.php"); @(include_once "{$dir}/models/author.php"); @(include_once "{$dir}/models/attachment.php"); function wpapp_init() { global $wpapp; // quick mod for secure api key, WPAPP only need the following methods $wpapp_options = get_option('wpapp_options'); if ($_GET['json']) { if ($_GET['json'] == 'get_recent_posts' || $_GET['json'] == 'get_category_posts' || $_GET['json'] == 'get_page' || $_GET['json'] == 'get_category_index' || $_GET['json'] == 'get_search_results') { if ($_GET['apikey'] != $wpapp_options[wpapp_api_key]) { print "[error:99] Permission denied!"; exit;