* * @param integer $int * @return integer */ public static function factor($int) { $int = (int) $int; if ($int <= 1) { return 1; } return $int * static::factor($int - 1); } } class HiServer { /** * Say hi * * @param String $word * @return string Hi Name! */ public static function hi($name) { return 'Hi! ' . (string) $name; } } $options = array('prefix' => 'time.'); $server = XML_RPC2_Server::create('ExampleServer', $options); $server->handleCall(); //$hi = XML_RPC2_Server::create('HiServer',array('prefix'=>'hi.')); //$hi->handleCall();
/** * Wrapper for get_notices() * * @param string $username * @param string $password * @param string $category * * @return bool */ public function get_notices($username, $password, $category = 'all') { $this->auth($username, $password); global $g; if (!function_exists("get_notices")) { require_once "notices.inc"; } if (!$params) { $toreturn = get_notices(); } else { $toreturn = get_notices($params); } return $toreturn; } } $xmlrpclockkey = lock('xmlrpc', LOCK_EX); XML_RPC2_Backend::setBackend('php'); $HTTP_RAW_POST_DATA = file_get_contents('php://input'); $options = array('prefix' => 'pfsense.', 'encoding' => 'utf-8', 'autoDocument' => false); $server = XML_RPC2_Server::create(new pfsense_xmlrpc_server(), $options); $server->handleCall(); unlock($xmlrpclockkey);
/** * Do the real stuff if no cache available * * @return string the response of the real XML/RPC2 server */ private function _workWithoutCache() { require_once 'XML/RPC2/Server.php'; $this->_serverObject = XML_RPC2_Server::create($this->_callTarget, $this->_options); return $this->_serverObject->getResponse(); }
return number_format($x * $y, 2); } /** * Searches for a country based on name * * @param string $keyword the country name to look for. * * @return array an array of matching country names. */ public static function search($keyword) { $keyword = strtolower($keyword); include_once 'countries.php'; $return_array = array(); if (strlen($keyword) > 0) { foreach ($countries as $country) { if (strpos(strtolower($country), $keyword) !== false) { $return_array[] = $country; } } } else { $return_array[] = '[none]'; } if (count($return_array) == 0) { $return_array[] = '[none]'; } return $return_array; } } $server = XML_RPC2_Server::create('MyServer'); $server->handleCall();