HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/survey.wb-webdesign.com/public_html/application/libraries/jsonRPCServer.php
<?php

/*
                    COPYRIGHT

Copyright 2007 Sergio Vaccaro <[email protected]>

This file is part of JSON-RPC PHP.

JSON-RPC PHP is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

JSON-RPC PHP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JSON-RPC PHP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
 * This class build a json-RPC Server 1.0
 * http://json-rpc.org/wiki/specification
 *
 * @author sergio <[email protected]>
 */
class jsonRPCServer
{
    /**
     * This function handle a request binding it to a given object
     *
     * @param object $object
     * @return boolean
     */
    public static function handle($object)
    {

        // checks if a JSON-RCP request has been received
        if (
            $_SERVER['REQUEST_METHOD'] != 'POST' ||
            empty($_SERVER['CONTENT_TYPE']) ||
            $_SERVER['CONTENT_TYPE'] != 'application/json'
        ) {
            // This is not a JSON-RPC request
            return false;
        }

        // reads the input data
        $request = json_decode(file_get_contents('php://input'), true);

        // executes the task on local object
        try {
            if ($result = @call_user_func_array(array($object, sanitize_alphanumeric($request['method'])), $request['params'])) {
                $response = array(
                                    'id' => $request['id'],
                                    'result' => $result,
                                    'error' => null
                                    );
            } else {
                $response = array(
                                    'id' => $request['id'],
                                    'result' => null,
                                    'error' => 'unknown method or incorrect parameters'
                                    );
            }
        } catch (Exception $e) {
            $response = array(
                                'id' => $request['id'],
                                'result' => null,
                                'error' => $e->getMessage()
                                );
        }

        // output the response
        if (!empty($request['id'])) {
// notifications don't want response
            header('content-type: text/javascript');
            echo json_encode($response);
        }

        // finish
        return true;
    }
}