Example #1
0
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
include_once "../includes/sp-load.php";
include_once SP_CTRLPATH . "/api.ctrl.php";
include_once SP_CTRLPATH . "/settings.ctrl.php";
include SP_ABSPATH . "/api/api.functions.php";
$controller = new APIController();
$inputInfo = $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET;
// sp demo enabled
if (SP_DEMO) {
    $returnInfo['response'] = 'Error';
    $returnInfo['error_msg'] = "API will not work in demo mode!";
} else {
    if ($controller->verifyAPICredentials($inputInfo)) {
        $category = strtolower($inputInfo['category']);
        $action = $inputInfo['action'];
        // check for category and action values
        if (!empty($category) && !empty($action)) {
            // call api class with the action
            if (include SP_ABSPATH . "/api/" . $category . ".api.php") {
                $categortClassName = ucfirst($category) . "API";
                // check for class exists or not
                if (class_exists($categortClassName)) {
                    $apiObj = new $categortClassName();
                    // check action exists or not
                    if (method_exists($apiObj, $action)) {
                        $returnInfo = $apiObj->{$action}($inputInfo);
                    } else {
                        $returnInfo['response'] = 'Error';