예제 #1
0
function drawMachines()
{
    $cli = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]);
    $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct");
    $msg = new XML_RPC_Message('listMachines', array($req));
    $resp = $cli->send($msg);
    if (hasErrors($resp)) {
        return;
    }
    $machines = $resp->value();
    $i = $machines->arraysize();
    while ($i--) {
        $m = XML_RPC_decode($machines->arraymem($i));
        echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'>\n        <ul class='menu' >\n        <li >\n        <p  onclick='javascript:toggleSpan(\"span{$m}\");' >{$m}<br/><span id='span{$m}'>{$m}\n        <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n        <input type='submit' value='Save'><br style='clear:both'>\n        <a href='setup_machine.php?machine={$m}'><em class='butt'>Setup</em></a>\n        <a href='start_manager.php?machine={$m}'><input type='button' value='StartManager'></a><br>\n\n        <input id='sName{$m}'  type='text' value='SUT_NAME' style='clear:both; float:left; width:25%;'/>\n        <input id='sValue{$m}' type='text' value='Value'/><br>";
        $params = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string'), "sut_machine" => new XML_RPC_Value($m, 'string')), "struct");
        $msg = new XML_RPC_Message('getConfig', array($params));
        $resp = $cli->send($msg);
        if (hasErrors($resp)) {
            return;
        }
        $cfgTable = $resp->value();
        $j = $cfgTable->arraysize();
        while ($j--) {
            $cfgEntry = $cfgTable->arraymem($j);
            $cfgEntry->structreset();
            $symbol = XML_RPC_decode($cfgEntry->structmem("symbol"));
            $value = XML_RPC_decode($cfgEntry->structmem("val"));
            echo "<b>{$symbol}</b>";
            echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n";
        }
        echo " </span></p>\n            </li> </ul> </form>";
    }
}
예제 #2
0
function drawMachines()
{
    $cli = new XML_RPC_Client('/RPCSERVER', 'localhost', 5000);
    $msg = new XML_RPC_Message('listMachines');
    $resp = $cli->send($msg);
    if (hasErrors($resp)) {
        return;
    }
    $machines = $resp->value();
    $i = $machines->arraysize();
    #$i = 1;
    while ($i--) {
        $m = XML_RPC_decode($machines->arraymem($i));
        echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'> <ul id='menu'>\n        <li ><p>{$m}\n        <span id='span{$m}'>\n        <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n        <input type='submit' value='Save'>\n\n        <input id='sName{$m}'  type='text' value='SUT_NAME' style='text-align:right; clear:both; float:left; width:12em;'/>\n        <input id='sValue{$m}' type='text' value='Value'/>\n\n\n        ";
        $params = array(new XML_RPC_Value($m, 'string'));
        $msg = new XML_RPC_Message('getConfig', $params);
        $resp = $cli->send($msg);
        if (hasErrors($resp)) {
            return;
        }
        $cfgTable = $resp->value();
        $j = $cfgTable->arraysize();
        while ($j--) {
            $cfgEntry = $cfgTable->arraymem($j);
            $cfgEntry->structreset();
            $symbol = XML_RPC_decode($cfgEntry->structmem("symbol"));
            $value = XML_RPC_decode($cfgEntry->structmem("val"));
            echo "<b>{$symbol}</b>";
            echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n";
        }
        echo "\n\n        </span></p>\n            </li>\n            </ul>\n\n</form>";
    }
}
예제 #3
0
 /**
  * Method to get a specific wiki page in HTML
  *
  * @param string $pagename
  * @return string HTML
  */
 public function fullGraph()
 {
     $msg = new XML_RPC_Message('dlGraphFull');
     $pserv = $this->objSysConfig->getValue('package_server', 'packages');
     $purl = $this->objSysConfig->getValue('package_url', 'packages');
     $cli = new XML_RPC_Client($purl, $pserv);
     $cli->setDebug(0);
     // send the request message
     $resp = $cli->send($msg);
     if (!$resp) {
         throw new customException($this->objLanguage->languageText("mod_filters_commserr", "filters") . ": " . $cli->errstr);
         exit;
     }
     if (!$resp->faultCode()) {
         $val = $resp->value();
         $val = XML_RPC_decode($val);
         if (is_array($val)) {
             return $val['faultString'];
         } else {
             return $val;
         }
     } else {
         /*
          * Display problems that have been gracefully caught and
          * reported by the xmlrpc server class.
          */
         throw new customException($this->objLanguage->languageText("mod_filters_faultcode", "filters") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_filters_faultreason", "filters") . ": " . $resp->faultString());
     }
 }
예제 #4
0
function xmlrpc_smtp2pne($message)
{
    // パラメータを取得
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return $param;
    }
    $params = XML_RPC_decode($param);
    // 入力チェック とりあえず空かどうかのみ
    if (empty($params['prefix']) and empty($params['domain'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    if (empty($params['to'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    if (empty($params['from'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    // デコーダオブジェクトを作成
    $options['from_encoding'] = 'UTF-8';
    $options['to_encoding'] = 'UTF-8';
    $options['img_tmp_dir'] = OPENPNE_VAR_DIR . '/tmp';
    $options['img_max_filesize'] = IMAGE_MAX_FILESIZE * 1024;
    $options['trim_doublebyte_space'] = OPENPNE_TRIM_DOUBLEBYTE_SPACE;
    $decoder =& new OpenPNE_KtaiMail_RPC($options);
    $decoder->assign($params);
    // メール受信処理オブジェクトを起動
    $mail_sns =& new mail_sns($decoder);
    if (!$mail_sns->main()) {
        //エラーの場合はfaultCodeを返す
        return xmlrpc_get_fault_response(56, 'Can\'t Receive Mail');
    }
    return xmlrpc_get_response(0);
}
 /**
  * Method to get a specific wiki page in HTML
  *
  * @param string $pagename
  * @return string HTML
  */
 public function grabTracWikiPageHTML($pagename)
 {
     $msg = new XML_RPC_Message('wiki.getPageHTML', array(new XML_RPC_Value($pagename, "string")));
     $cli = new XML_RPC_Client($this->tracURL, $this->tracServ);
     $cli->setDebug(0);
     // send the request message
     $resp = $cli->send($msg);
     if (!$resp) {
         throw new customException($this->objLanguage->languageText("mod_filters_commserr", "filters") . ": " . $cli->errstr);
         exit;
     }
     if (!$resp->faultCode()) {
         $val = $resp->value();
         $val = XML_RPC_decode($val);
         if (is_array($val)) {
             return $val['faultString'];
         } else {
             return $val;
         }
     } else {
         /*
          * Display problems that have been gracefully caught and
          * reported by the xmlrpc server class.
          */
         throw new customException($this->objLanguage->languageText("mod_filters_faultcode", "filters") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_filters_faultreason", "filters") . ": " . $resp->faultString());
     }
 }
예제 #6
0
/**
 * 認証API
 */
function xmlrpc_000_auth($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['sid'])) {
        return false;
    }
    if (empty($params['mid'])) {
        return false;
    }
    if (empty($params['dt'])) {
        return false;
    }
    $c_member_id = $params['mid'];
    $datetime = $params['dt'];
    if (!db_member_c_member4c_member_id_LIGHT($c_member_id)) {
        return xmlrpc_get_fault_response(56);
    }
    if (!($member_token = db_api_get_member_token($c_member_id))) {
        return xmlrpc_get_fault_response(52);
    }
    $session_id = api_get_sid($c_member_id, $member_token, $datetime);
    if ($params['sid'] != $session_id) {
        return xmlrpc_get_fault_response(52);
    }
    return xmlrpc_get_response($c_member_id);
}
예제 #7
0
function returnXmlRpcResponseData($oResponse)
{
    if (!$oResponse->faultCode()) {
        $oVal = $oResponse->value();
        $data = XML_RPC_decode($oVal);
        return $data;
    } else {
        die('Fault Code: ' . $oResponse->faultCode() . "\n" . 'Fault Reason: ' . $oResponse->faultString() . "\n");
    }
}
예제 #8
0
function xmlrpc_di_000_get_diary($message)
{
    $dummy = array();
    $re_false = array('result' => 1, 'list' => $dummy);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    if (empty($params['mid_to'])) {
        //対象メンバID必須
        return xmlrpc_get_response($re_false);
    }
    if (empty($params['count'])) {
        //取得数必須
        return xmlrpc_get_response($re_false);
    }
    if (!is_numeric($params['mid_to'])) {
        //対象メンバIDは整数値
        return xmlrpc_get_response($re_false);
    }
    if (!empty($params['mid_from'])) {
        //アクセスメンバIDは(存在する場合は)整数値
        if (!is_numeric($params['mid_from'])) {
            return xmlrpc_get_response($re_false);
        }
    }
    if (!is_numeric($params['count'])) {
        //取得数は整数値
        return xmlrpc_get_response($re_false);
    }
    if ($params['count'] < 0) {
        //取得数は正
        return xmlrpc_get_response($re_false);
    }
    $member_id_to = $params['mid_to'];
    $member_id_from = $params['mid_from'];
    $count = $params['count'];
    if ($count > 100) {
        //取得最大数は100
        $count = 100;
    }
    if (!($arr = OP::op_diary_get_c_diary($member_id_to, $member_id_from, $count))) {
        return xmlrpc_get_response($re_false);
    } else {
        foreach ($arr as $key => $value) {
            $diary[$key]['id'] = $arr[$key]['c_diary_id'];
            $diary[$key]['subject'] = $arr[$key]['subject'];
            $diary[$key]['body'] = $arr[$key]['body'];
            $diary[$key]['datetime'] = date('Y/m/d H:i:s', strtotime($arr[$key]['r_datetime']));
        }
        $re_true = array('result' => 0, 'list' => $diary);
        return xmlrpc_get_response($re_true);
    }
}
예제 #9
0
function runTests($cli)
{
    /* Serialize the SUT Versions */
    print "\nVersions:\n";
    $versions = array();
    for ($i = 0; $i < count($_GET['sut_versions']); ++$i) {
        print "   " . $_GET['sut_versions'][$i] . "\n";
        $versions[] = new XML_RPC_Value($_GET['sut_versions'][$i], 'string');
    }
    $xversions = new XML_RPC_Value($versions, "array");
    print "\nBuild:\n   " . $_GET['sut_build'] . "\n";
    /*--------------------------------------------*/
    /* Serialize the OSes  */
    print "\nOS:\n";
    $oses = array();
    for ($i = 0; $i < count($_GET['sut_os']); ++$i) {
        print "   " . $_GET['sut_os'][$i] . "\n";
        $oses[] = new XML_RPC_Value($_GET['sut_os'][$i], 'string');
    }
    $xoses = new XML_RPC_Value($oses, 'array');
    /*--------------------------------------------*/
    /* Serialize the TEST categories */
    print "\nTests:\n";
    $tests = array();
    for ($i = 0; $i < count($_GET['sut_tests']); ++$i) {
        print "   " . $_GET['sut_tests'][$i] . "\n";
        $tests[] = new XML_RPC_Value($_GET['sut_tests'][$i], 'string');
    }
    $xtests = new XML_RPC_Value($tests, "array");
    /*--------------------------------------------*/
    /* Serialize Method parameter */
    $request = new XML_RPC_Value(array("sut_tests" => $xtests, "sut_versions" => $xversions, "sut_os" => $xoses, "sut_build" => new XML_RPC_Value($_GET['sut_build'], 'string')), "struct");
    $params = array($request);
    $msg = new XML_RPC_Message('runTests', $params);
    /*--------------------------------------------*/
    $resp = $cli->send($msg);
    if (!$resp) {
        echo 'Communication error: ' . $cli->errstr;
        exit;
    }
    if (!$resp->faultCode()) {
        $val = $resp->value();
        $data = XML_RPC_decode($val);
        echo $data;
    } else {
        /*
         * Display problems that have been gracefully cought and
         * reported by the xmlrpc.php script
         */
        echo 'Fault Code: ' . $resp->faultCode() . "\n";
        echo 'Fault Reason: ' . $resp->faultString() . "\n";
    }
}
예제 #10
0
 /**
  * Send message to remote rpc server and get response.
  *
  * @return object result object. Type is depend on the calles method
  *
  * @access protected
  */
 function &send()
 {
     include_once 'XML/RPC.php';
     if (!($response =& $this->rpc_client->send($this->rpc_message, $this->response_timeout))) {
         $this->log->write("ilRPCServerAdapter: Communication error");
         return null;
     }
     if ($response->faultCode()) {
         $this->log->write("ilRPCServerAdapter: Communication error: " . $response->faultString());
         return null;
     }
     return XML_RPC_decode($response->value());
 }
예제 #11
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_002_get_member_point($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['c_member_id'])) {
        return false;
    }
    $point = get_point($params['c_member_id']);
    return xmlrpc_get_response($point);
}
예제 #12
0
 /**
  * Call a method
  * @param string Method name, automatically gets "grav." prepended to it
  * @param Array List of named arguments
  */
 protected function call($method, $params = array())
 {
     #$params = array_map('XML_RPC_encode', $params);
     $params = array_merge($params, array('apikey' => $this->apikey));
     $msg = new XML_RPC_Message("grav.{$method}", array(XML_RPC_encode($params)));
     $response = $this->client()->send($msg);
     if (!$response->faultCode()) {
         $value = $response->value();
         $value = XML_RPC_decode($value);
         return $value;
     } else {
         throw new GravatarException($response->faultString(), $response->faultCode());
     }
 }
예제 #13
0
function xmlrpc_as_001_set_ashiato($message)
{
    $dummy = array();
    $re_false = array('result' => 1);
    $re_true = array('result' => 0);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    //「あしあと」を付けたメンバID必須
    if (empty($params['mid_from'])) {
        return xmlrpc_get_response($re_false);
    }
    //「あしあと」を付けられたメンバID必須
    if (empty($params['mid_to'])) {
        return xmlrpc_get_response($re_false);
    }
    $mid_from = $params['mid_from'];
    $mid_to = $params['mid_to'];
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($mid_from)) {
        return xmlrpc_get_response($re_false);
    }
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($mid_to)) {
        return xmlrpc_get_response($re_false);
    }
    //あしあとを付けたメンバIDと付けられたメンバIDは同一か
    if ($mid_from == $mid_to) {
        return xmlrpc_get_response($re_true);
    }
    //一定時間内の連続アクセスか?
    if (!OP::op_ashiato_check_access_minute($mid_to, $mid_from)) {
        return xmlrpc_get_response($re_true);
    }
    //忍び足状態か?
    if (USE_SHINOBIASHI) {
        if (OP::op_member_is_shinobiashi($mid_from)) {
            return xmlrpc_get_response($re_true);
        }
    }
    if (!OP::op_ashiato_insert_c_ashiato($mid_to, $mid_from)) {
        return xmlrpc_get_response($re_false);
    }
    //正常終了
    return xmlrpc_get_response($re_true);
}
예제 #14
0
 function listOSes()
 {
     echo "ON Machine:<br>";
     $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct");
     $msg = new XML_RPC_Message('listMachines', array($req));
     $resp = $this->xmlrpc->send($msg);
     if (hasErrors($resp)) {
         return false;
     }
     $i = $resp->value()->arraysize();
     echo "<select name='sut_os[]' multiple size='5'>";
     while ($i--) {
         echo "<option>" . XML_RPC_decode($resp->value()->arraymem($i)) . "</option>";
     }
     echo "</select>";
 }
예제 #15
0
function xmlrpc_as_000_get_ashiato($message)
{
    $dummy = array();
    $re_false = array('result' => 1, 'list' => $dummy);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    //対象メンバID必須
    if (empty($params['mid'])) {
        return xmlrpc_get_response($re_false);
    }
    //取得数必須
    if (empty($params['count'])) {
        return xmlrpc_get_response($re_false);
    }
    //取得数は数値
    if (!is_numeric($params['count'])) {
        return xmlrpc_get_response($re_false);
    }
    $member_id = $params['mid'];
    $count = intval($params['count']);
    $profile = $params['profile'];
    //取得数は正
    if ($count <= 0) {
        return xmlrpc_get_response($re_false);
    }
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($member_id)) {
        return xmlrpc_get_response($re_false);
    }
    //あしあとのあるメンバか
    if (!OP::op_is_ahiato_member($member_id)) {
        return xmlrpc_get_response($re_false);
    }
    //取得最大数は100
    if ($count > 100) {
        $count = 100;
    }
    $list = OP::op_ashiato_list_c_member_profile($member_id, $count, $profile);
    if (empty($list)) {
        return xmlrpc_get_respose($re_false);
    }
    return xmlrpc_get_response(array('result' => 0, 'list' => $list));
}
예제 #16
0
 /**
  * @param methodStr
  *		The string for the method to be invoked on ther server.
  *
  * @param params
  *		An array of XML-RPC encoded parameters to the method that will be invoked on the server.
  *
  * @param falseOnFail
  *		If set to true, sendMessage will return false on a failure, rather than exiting.
  *
  * @return The un-decoded data from the method invoked on the server.
  */
 private function sendMessage($methodStr, $params)
 {
     $message = new XML_RPC_Message($methodStr, $params);
     $response = $this->client->send($message);
     if (!$response) {
         throw new XmlRpcFilemgrException("No response was received from Xml-Rpc Client\nError msg: " . $this->client->errstr);
     }
     if (!$response->faultCode()) {
         $value = $response->value();
         $data = XML_RPC_decode($value);
         if (isset($data->faultString)) {
             throw new XmlRpcFilemgrException("Fault String in Xml-Rpc response: " . $data["faultString"]);
         }
         return $data;
     } else {
         throw new XmlRpcFilemgrException("Fault Code in Xml-Rpc response: " . $response->faultCode);
     }
 }
예제 #17
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_001_get_c_member($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['target_c_member_id'])) {
        return false;
    }
    if (empty($params['my_c_member_id'])) {
        return false;
    }
    $t_id = intval($params['target_c_member_id']);
    $m_id = intval($params['my_c_member_id']);
    // my_c_member_id が不正
    if (!db_member_c_member4c_member_id_LIGHT($m_id)) {
        return xmlrpc_get_fault_response(56);
    }
    if ($t_id == $m_id) {
        // 自分
        $public_flag = 'private';
    } elseif (db_friend_is_friend($t_id, $m_id)) {
        $public_flag = 'friend';
    } else {
        $public_flag = 'public';
    }
    // target_c_member_id が不正
    if (!($c_member = db_member_c_member4c_member_id($t_id, false, true, $public_flag))) {
        return xmlrpc_get_fault_response(56);
    }
    // アクセスブロック判定
    if (db_member_is_access_block($m_id, $t_id)) {
        $result = array('c_member_id' => $t_id, 'nickname' => $c_member['nickname'], 'image_url' => xmlrpc_get_image_url());
    } else {
        $result = array('c_member_id' => $t_id, 'nickname' => $c_member['nickname'], 'image_url' => xmlrpc_get_image_url($c_member['image_filename']), 'image_url_1' => xmlrpc_get_image_url($c_member['image_filename_1'], false), 'image_url_2' => xmlrpc_get_image_url($c_member['image_filename_2'], false), 'image_url_3' => xmlrpc_get_image_url($c_member['image_filename_3'], false), 'birth_year' => intval($c_member['birth_year']), 'birth_month' => intval($c_member['birth_month']), 'birth_day' => intval($c_member['birth_day']), 'access_date' => xmlrpc_get_date($c_member['access_date']), 'r_date' => xmlrpc_get_date($c_member['r_date']), 'profile' => array());
        foreach ($c_member['profile'] as $key => $profile) {
            $result['profile'][$key] = $profile['value'];
        }
    }
    return xmlrpc_get_response($result);
}
예제 #18
0
function UPMS_getNextVersion($aServer)
{
    // Create the XML-RPC message
    $message = new XML_RPC_Message('OXUPMS.getNextID');
    // Create an XML-RPC client to talk to the XML-RPC server
    $client = new XML_RPC_Client($aServer['path'], $aServer['host'], $aServer['port']);
    $client->debug = 0;
    // Send the XML-RPC message to the server
    $response = $client->send($message, 60, 'http');
    // Was the response OK?
    if ($response && $response->faultCode() == 0) {
        $result = XML_RPC_decode($response->value());
        return $result;
    } else {
        if ($response->faultCode() > 0) {
            $result = $response->faultString();
        }
    }
    return $result;
}
예제 #19
0
function setMachineConfig($cli)
{
    /* Serialize the SUT Versions */
    print "\nSet config of machine:\n";
    $versions = array();
    $m = $_GET['SUT_MACHINE'];
    print "   {$m}--\n";
    $xmachine = new XML_RPC_Value($m, 'string');
    /*--------------------------------------------*/
    /* Serialize the content of config */
    foreach ($_POST as $k => $v) {
        if (preg_match("/SUT_/", $k)) {
            echo "GOT: {$k} = {$v}\n";
            $cfgLines[] = new XML_RPC_Value("{$k} = '{$v}'\n", 'string');
        }
    }
    $xcfgLines = new XML_RPC_Value($cfgLines, 'array');
    /* Serialize Method parameter */
    $request = new XML_RPC_Value(array("sut_machine" => $xmachine, "cfg_lines" => $xcfgLines), "struct");
    $params = array($request);
    $msg = new XML_RPC_Message('setConfig', $params);
    /*--------------------------------------------*/
    $resp = $cli->send($msg);
    if (!$resp) {
        echo 'Communication error: ' . $cli->errstr;
        exit;
    }
    if (!$resp->faultCode()) {
        $val = $resp->value();
        $data = XML_RPC_decode($val);
        echo $data;
    } else {
        /*
         * Display problems that have been gracefully cought and
         * reported by the xmlrpc.php script
         */
        echo 'Fault Code: ' . $resp->faultCode() . "\n";
        echo 'Fault Reason: ' . $resp->faultString() . "\n";
    }
}
예제 #20
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_901_o_search($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (!array_key_exists('searchword', $params)) {
        return false;
    }
    if (empty($params['type'])) {
        return false;
    }
    $searchword = $params['searchword'];
    if (empty($searchword)) {
        $searchword = '';
    }
    $type = $params['type'];
    $number = 0;
    switch ($type) {
        case 'DIARY':
            $diary = p_h_diary_list_all_search_c_diary4c_diary($searchword, 0, 1);
            $number += (int) $diary[3];
            break;
        case 'COMMUNITY':
            $commu = db_commu_search_c_commu4c_commu_category($searchword, 0, 0, 1);
            $number += (int) $commu[3];
            break;
        case 'ALL':
        default:
            $diary = p_h_diary_list_all_search_c_diary4c_diary($searchword, 0, 1);
            $number += (int) $diary[3];
            $commu = db_commu_search_c_commu4c_commu_category($searchword, 0, 0, 1);
            $number += (int) $commu[3];
            break;
    }
    $result = array('number' => intval($number), 'sns_name' => SNS_NAME);
    return xmlrpc_get_response($result);
}
예제 #21
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_101_add_point($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['c_member_id'])) {
        return false;
    }
    if (!isset($params['point'])) {
        return false;
    }
    $c_member_id = intval($params['c_member_id']);
    $point = intval($params['point']);
    if (!db_member_c_member4c_member_id_LIGHT($c_member_id)) {
        return xmlrpc_get_fault_response(56);
    }
    $c_point_log_id = db_point_insert_log($c_member_id, $point, $params['memo']);
    db_point_insert_tags($c_point_log_id, $params['tags']);
    $point = db_point_add_point($c_member_id, $point);
    return xmlrpc_get_response($point);
}
예제 #22
0
function call($arg1, $arg2, $cli)
{
    echo $arg2;
    $params = array(new XML_RPC_Value($arg2, 'string'));
    $msg = new XML_RPC_Message($arg1, $params);
    $resp = $cli->send($msg);
    if (!$resp) {
        echo 'Communication error: ' . $cli->errstr;
        exit;
    }
    if (!$resp->faultCode()) {
        $val = $resp->value();
        $data = XML_RPC_decode($val);
        echo $data;
    } else {
        /*
         * Display problems that have been gracefully cought and
         * reported by the xmlrpc.php script
         */
        echo 'Fault Code: ' . $resp->faultCode() . "\n";
        echo 'Fault Reason: ' . $resp->faultString() . "\n";
    }
}
예제 #23
0
 function translate($lemma)
 {
     $lemma = strtolower($lemma);
     $targetLang = 'en';
     $sourceLang = 'id';
     $params = array(new XML_RPC_Value($lemma, 'string'), new XML_RPC_Value($sourceLang, 'string'), new XML_RPC_Value($targetLang, 'string'), new XML_RPC_Value(20, 'int'));
     $msg = new XML_RPC_Message('suggest3', $params);
     $cli = new XML_RPC_Client('/RPC2', 'open-tran.eu');
     $resp = $cli->send($msg);
     if ($resp) {
         if (!$resp->faultCode()) {
             $val = $resp->value();
             $data = XML_RPC_decode($val);
             foreach ($data as $value) {
                 $matched = false;
                 $text = strtolower(strip_tags($value['text']));
                 if (is_array($value['projects'])) {
                     foreach ($value['projects'] as $orig) {
                         if (strtolower(strip_tags($orig['orig_phrase'])) == $text) {
                             $matched = true;
                             break;
                         }
                     }
                 }
                 if ($matched) {
                     $translation .= ($translation ? '; ' : '') . $text;
                 }
             }
         }
     }
     if ($translation) {
         $ret = array('ref_source' => 'open-tran.eu', 'lemma' => $lemma, 'translation' => $translation);
     }
     //      var_dump($ret);
     //      die('<br /><br />a');
     return $ret;
 }
예제 #24
0
function sxr_call($host, $port, $path, $func, $params)
{
    debug(XMLRPC, "SXR calling {$func} via http://{$host}:{$port}/{$path}");
    global $sxr_clients;
    $key = "{$host}:{$port}/{$path}";
    if (!array_key_exists($key, $sxr_clients)) {
        $sxr_clients[$key] = new XML_RPC_Client($path, $host, $port);
    }
    $p = array();
    if (is_array($params)) {
        foreach ($params as $i) {
            array_push($p, XML_RPC_encode($i));
        }
    } else {
        $p[0] = $params;
    }
    $req = new XML_RPC_Message($func, $p);
    $resp = $sxr_clients[$key]->send($req);
    if ($resp->faultCode()) {
        return FALSE;
    } else {
        return XML_RPC_decode($resp->value());
    }
}
예제 #25
0
/**
 * Converts an XML_RPC_Value object into native PHP types
 *
 * @param object $XML_RPC_val  the XML_RPC_Value object to decode
 *
 * @return mixed  the PHP values
 */
function XML_RPC_decode($XML_RPC_val)
{
    $kind = $XML_RPC_val->kindOf();
    if ($kind == 'scalar') {
        return $XML_RPC_val->scalarval();
    } elseif ($kind == 'array') {
        $size = $XML_RPC_val->arraysize();
        $arr = array();
        for ($i = 0; $i < $size; $i++) {
            $arr[] = XML_RPC_decode($XML_RPC_val->arraymem($i));
        }
        return $arr;
    } elseif ($kind == 'struct') {
        $XML_RPC_val->structreset();
        $arr = array();
        while (list($key, $value) = $XML_RPC_val->structeach()) {
            $arr[$key] = XML_RPC_decode($value);
        }
        return $arr;
    }
}
예제 #26
0
 function call($method)
 {
     $_args = $args = func_get_args();
     $this->cache = $this->getCache($args);
     $cachettl = $this->config->get('cache_ttl');
     // If cache is newer than $cachettl seconds, we use the cache!
     if ($this->cache !== null && $this->cache['age'] < $cachettl) {
         return $this->cache['content'];
     }
     if (extension_loaded("xmlrpc")) {
         $result = call_user_func_array(array(&$this, 'call_epi'), $args);
         if (!PEAR::isError($result)) {
             $this->saveCache($_args, $result);
         }
         return $result;
     }
     if (!@(include_once "XML/RPC.php")) {
         return $this->raiseError("For this remote PEAR operation you need to install the XML_RPC package");
     }
     array_shift($args);
     $server_host = $this->config->get('master_server');
     $username = $this->config->get('username');
     $password = $this->config->get('password');
     $eargs = array();
     foreach ($args as $arg) {
         $eargs[] = $this->_encode($arg);
     }
     $f = new XML_RPC_Message($method, $eargs);
     if ($this->cache !== null) {
         $maxAge = '?maxAge=' . $this->cache['lastChange'];
     } else {
         $maxAge = '';
     }
     $proxy_host = $proxy_port = $proxy_user = $proxy_pass = '';
     if ($proxy = parse_url($this->config->get('http_proxy'))) {
         $proxy_host = @$proxy['host'];
         $proxy_port = @$proxy['port'];
         $proxy_user = @urldecode(@$proxy['user']);
         $proxy_pass = @urldecode(@$proxy['pass']);
     }
     $c = new XML_RPC_Client('/xmlrpc.php' . $maxAge, $server_host, 80, $proxy_host, $proxy_port, $proxy_user, $proxy_pass);
     if ($username && $password) {
         $c->setCredentials($username, $password);
     }
     if ($this->config->get('verbose') >= 3) {
         $c->setDebug(1);
     }
     $r = $c->send($f);
     if (!$r) {
         return $this->raiseError("XML_RPC send failed");
     }
     $v = $r->value();
     if ($e = $r->faultCode()) {
         if ($e == $GLOBALS['XML_RPC_err']['http_error'] && strstr($r->faultString(), '304 Not Modified') !== false) {
             return $this->cache['content'];
         }
         return $this->raiseError($r->faultString(), $e);
     }
     $result = XML_RPC_decode($v);
     $this->saveCache($_args, $result);
     return $result;
 }
예제 #27
0
 private function _params_to_args($message)
 {
     $args = array();
     foreach ($message->params as $param) {
         $args[] = XML_RPC_decode($param);
     }
     return $args;
 }
 /**
  * This function sends a method call to a specified service.
  *
  * @param string $method  The name of the remote method to call.
  * @param mixed  $data    The data to send to the web service.
  * @return mixed The response from the server or false in the event of failure.
  */
 function _send($method, $data)
 {
     $dataMessage = array();
     foreach ($data as $element) {
         if (is_object($element) && is_subclass_of($element, 'OA_Info')) {
             $dataMessage[] = XmlRpcUtils::getEntityWithNotNullFields($element);
         } else {
             $dataMessage[] = XML_RPC_encode($element);
         }
     }
     $message = new XML_RPC_Message($method, $dataMessage);
     $client =& $this->_getClient();
     // Send the XML-RPC message to the server.
     $response = $client->send($message, $this->timeout, $this->ssl ? 'https' : 'http');
     // Check for an error response.
     if ($response && $response->faultCode() == 0) {
         $result = XML_RPC_decode($response->value());
     } else {
         trigger_error('XML-RPC Error (' . $response->faultCode() . '): ' . $response->faultString() . ' in method ' . $method . '()', E_USER_ERROR);
     }
     return $result;
 }
예제 #29
0
/**
 * A function to handle XML-RPC advertisement view requests. 2.3 version
 *
 * @deprecated
 *
 * @param XML_RPC_Message $params An XML_RPC_Message containing the parameters. The expected parameters
 *                              are (in order):
 *                              - An XML_RPC_Value of type "string" containing the "what" value;
 *                              - An XML_RPC_Value of type "string" containing the "target" value;
 *                              - An XML_RPC_Value of type "string" containing the "source" value;
 *                              - An XML_RPC_Value of type "boolean" containing the "withText" value;
 *                              - An XML_RPC_Value of type "string" containing the viewer's IP address; and
 *                              - An XML_RPC_Value of type "struct" containing the viewer's cookie values
 *                                (indexed by cookie name);
 *                              - An XML_RPC_Value of type "array" containing the "context" value.
 * @return XML_RPC_Response The response. The XML_RPC_Value of the response can be one of
 *                          a number of different values:
 *                          - Error Code 1: The $params variable was not an XML_RPC_Value of
 *                            type "array".
 *                          - Error Code 2: The $params XML_RPC_Value "array" did not have 6
 *                            elements.
 *                          - An XML_RPC_Value of type "array" containing:
 *                            - An XML_RPC_Value of type "struct" with the HTML details required
 *                              for displaying the advertisement stored as in XML_RPC_Value of
 *                              type "string" in the "html" index, or an empty XML_RPC_Value if
 *                              there is no advertisement to display; and
 *                            - An empty XML_RPC_Value if there are no cookies to be set, or an
 *                              XML_RPC_Value of type "array", containing a number of
 *                              XML_RPC_Values of tpye "array", each with 3 items:
 *                              - An XML_RPC_Value of type "string" with the cookie name;
 *                              - An XML_RPC_Value of type "string" with the cookie value; and
 *                              - An XML_RPC_Value of type "string" with the cookie expiration time.
 */
function OA_Delivery_XmlRpc_View_Max($params)
{
    global $XML_RPC_erruser;
    global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array, $XML_RPC_Int;
    // Check the parameters exist
    $numParams = $params->getNumParams();
    if ($numParams < 6) {
        // Return an error
        $errorCode = $XML_RPC_erruser + 2;
        $errorMsg = 'Incorrect number of parameters';
        return new XML_RPC_Response(0, $errorCode, $errorMsg);
    }
    // Extract the what parameter
    $whatXmlRpcValue = $params->getParam(0);
    // Extract the target parameter
    $targetXmlRpcValue = $params->getParam(1);
    // Extract the source parameter
    $sourceXmlRpcValue = $params->getParam(2);
    // Extract the withText parameter
    $withTextXmlRpcValue = $params->getParam(3);
    // Extract the remoteAddress parameter
    $remoteAddressXmlRpcValue = $params->getParam(4);
    // Extract the tunnelled cookies
    $cookiesXmlRpcValue = $params->getParam(5);
    // Extract the context parameter, if any
    if ($numParams >= 7) {
        $contextXmlRpcValue = $params->getParam(6);
    } else {
        $contextXmlRpcValue = new XML_RPC_Value(array(), $XML_RPC_Array);
    }
    // Generate 0 campaignid parameter
    $campaignidXmlRpcValue = new XML_RPC_Value(0, $XML_RPC_Int);
    // Create environment array
    $remoteInfoXmlRpcValue = new XML_RPC_Value(array('remote_addr' => $remoteAddressXmlRpcValue, 'cookies' => $cookiesXmlRpcValue), $XML_RPC_Struct);
    // Recreate XML-RPC message
    $msg = new XML_RPC_Message('openads.view', array($remoteInfoXmlRpcValue, $whatXmlRpcValue, $campaignidXmlRpcValue, $targetXmlRpcValue, $sourceXmlRpcValue, $withTextXmlRpcValue, $contextXmlRpcValue));
    // Relay call to openads.view
    $xmlResponse = OA_Delivery_XmlRpc_View($msg);
    // Check for errors
    if (XML_RPC_Base::isError($xmlResponse)) {
        // Return error
        return $xmlResponse;
    }
    // Change the response
    $output = XML_RPC_decode($xmlResponse->value());
    $cookies = $output['cookies'];
    unset($output['cookies']);
    // Return XML-RPC response
    return new XML_RPC_Response(new XML_RPC_Value(array(XML_RPC_encode($output), XML_RPC_encode($cookies)), $XML_RPC_Array));
}
예제 #30
0
 function call($method)
 {
     $_args = $args = func_get_args();
     $server_channel = $this->config->get('default_channel');
     $channel = $this->_registry->getChannel($server_channel);
     if (!PEAR::isError($channel)) {
         $mirror = $this->config->get('preferred_mirror');
         if ($channel->getMirror($mirror)) {
             if ($channel->supports('xmlrpc', $method, $mirror)) {
                 $server_channel = $server_host = $mirror;
                 // use the preferred mirror
                 $server_port = $channel->getPort($mirror);
             } elseif (!$channel->supports('xmlrpc', $method)) {
                 return $this->raiseError("Channel {$server_channel} does not " . "support xml-rpc method {$method}");
             }
         }
         if (!isset($server_host)) {
             if (!$channel->supports('xmlrpc', $method)) {
                 return $this->raiseError("Channel {$server_channel} does not support " . "xml-rpc method {$method}");
             } else {
                 $server_host = $server_channel;
                 $server_port = $channel->getPort();
             }
         }
     } else {
         return $this->raiseError("Unknown channel '{$server_channel}'");
     }
     array_unshift($_args, $server_channel);
     // cache by channel
     $this->cache = $this->getCache($_args);
     $cachettl = $this->config->get('cache_ttl');
     // If cache is newer than $cachettl seconds, we use the cache!
     if ($this->cache !== null && $this->cache['age'] < $cachettl) {
         return $this->cache['content'];
     }
     $fp = false;
     if (extension_loaded("xmlrpc")) {
         $result = call_user_func_array(array(&$this, 'call_epi'), $args);
         if (!PEAR::isError($result)) {
             $this->saveCache($_args, $result);
         }
         return $result;
     } elseif (!($fp = fopen('XML/RPC.php', 'r', true))) {
         return $this->raiseError("For this remote PEAR operation you need to load the xmlrpc extension or install XML_RPC");
     }
     include_once 'XML/RPC.php';
     if ($fp) {
         fclose($fp);
     }
     array_shift($args);
     $username = $this->config->get('username');
     $password = $this->config->get('password');
     $eargs = array();
     foreach ($args as $arg) {
         $eargs[] = $this->_encode($arg);
     }
     $f = new XML_RPC_Message($method, $eargs);
     if ($this->cache !== null) {
         $maxAge = '?maxAge=' . $this->cache['lastChange'];
     } else {
         $maxAge = '';
     }
     $proxy_host = $proxy_port = $proxy_user = $proxy_pass = '';
     if ($proxy = parse_url($this->config->get('http_proxy'))) {
         $proxy_host = isset($proxy['host']) ? $proxy['host'] : null;
         if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') {
             $proxy_host = 'https://' . $proxy_host;
         }
         $proxy_port = isset($proxy['port']) ? $proxy['port'] : 8080;
         $proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null;
         $proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null;
     }
     $shost = $server_host;
     if ($channel->getSSL()) {
         $shost = "https://{$shost}";
     }
     $c = new XML_RPC_Client('/' . $channel->getPath('xmlrpc') . $maxAge, $shost, $server_port, $proxy_host, $proxy_port, $proxy_user, $proxy_pass);
     if ($username && $password) {
         $c->setCredentials($username, $password);
     }
     if ($this->config->get('verbose') >= 3) {
         $c->setDebug(1);
     }
     $r = $c->send($f);
     if (!$r) {
         return $this->raiseError("XML_RPC send failed");
     }
     $v = $r->value();
     if ($e = $r->faultCode()) {
         if ($e == $GLOBALS['XML_RPC_err']['http_error'] && strstr($r->faultString(), '304 Not Modified') !== false) {
             return $this->cache['content'];
         }
         return $this->raiseError($r->faultString(), $e);
     }
     $result = XML_RPC_decode($v);
     $this->saveCache($_args, $result);
     return $result;
 }