本文整理汇总了PHP中xmlrpc_set_type函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_set_type函数的具体用法?PHP xmlrpc_set_type怎么用?PHP xmlrpc_set_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_set_type函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: createFromNative
/**
* Factory method that constructs the appropriate XML-RPC encoded type value
*
* @param mixed Value to be encode
* @param string Explicit XML-RPC type as enumerated in the XML-RPC spec (defaults to automatically selected type)
* @return mixed The encoded value
*/
public static function createFromNative($value, $explicitType)
{
$type = strtolower($explicitType);
$availableTypes = array('datetime', 'base64', 'struct');
if (in_array($type, $availableTypes)) {
if ($type == 'struct') {
if (!is_array($value)) {
throw new XML_RPC2_Exception('With struct type, value has to be an array');
}
// Because of http://bugs.php.net/bug.php?id=21949
// is some cases (structs with numeric indexes), we need to be able to force the "struct" type
// (xmlrpc_set_type doesn't help for this, so we need this ugly hack)
$new = array();
while (list($k, $v) = each($value)) {
$new["xml_rpc2_ugly_struct_hack_{$k}"] = $v;
// with this "string" prefix, we are sure that the array will be seen as a "struct"
}
return $new;
}
$value2 = (string) $value;
if (!xmlrpc_set_type($value2, $type)) {
throw new XML_RPC2_Exception('Error returned from xmlrpc_set_type');
}
return $value2;
}
return $value;
}
开发者ID:altesien,项目名称:FinalProject,代码行数:34,代码来源:Value.php
示例2: serialize
/** {@inheritdoc} */
public function serialize($method, array $params = [])
{
$toBeVisited = [&$params];
while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
$type = gettype($value);
if ($type === 'array') {
foreach ($value as &$child) {
$toBeVisited[] =& $child;
}
} elseif ($type === 'object') {
if ($value instanceof DateTime) {
$value = $value->format('Ymd\\TH:i:s');
xmlrpc_set_type($value, 'datetime');
} elseif ($value instanceof Base64Interface) {
$value = $value->getDecoded();
xmlrpc_set_type($value, 'base64');
} else {
$value = get_object_vars($value);
}
} elseif ($type === 'resource') {
throw SerializationException::invalidType($value);
}
array_shift($toBeVisited);
}
return xmlrpc_encode_request($method, $params, ['encoding' => 'UTF-8', 'escaping' => 'markup', 'verbosity' => 'no_white_space']);
}
开发者ID:Banjerr,项目名称:infusionWholesaler,代码行数:27,代码来源:NativeSerializer.php
示例3: xmlrpc_getText
function xmlrpc_getText($method_name, $params)
{
$uid =& $params[0];
/* remote user (for snitch) */
$r_uid = addslashes($params[1]);
/* is snitch enabled for the remote user? */
$isSnitch = $params[2];
# error_log(date("[m/d/Y h:i:s] ") . "planworld.plan.getText: L:${uid}, R:${r_uid}, S:${isSnitch} (${_SERVER['REMOTE_ADDR']})\n", 3, "/tmp/planworld.log");
$r_user = User::factory($r_uid);
// error_log(date("[m/d/Y h:i:s] ") . "planworld.plan.getText: ${r_user->getUsername()}\n", 3, "/tmp/planworld.log");
if (is_string($uid) && Planworld::isUser(addslashes($uid))) {
$user = User::factory($uid);
} else {
# error_log(date("[m/d/Y h:i:s] ") . "planworld.plan.getText: No such user: ${uid}\n", 3, "/tmp/planworld.log");
return array('faultCode' => 800, 'faultString' => 'No such user');
}
if (!$user->getWorld()) {
$err = "[This user's plan is not available]";
# error_log(date("[m/d/Y h:i:s] ") . "planworld.plan.getText: Plan not available: ${uid}\n", 3, "/tmp/planworld.log");
xmlrpc_set_type($err, 'base64');
/* $err used to be passed by reference but that is deprecated. --JLO2 */
return $err;
}
if ($isSnitch) {
$user->addSnitchView($r_user);
}
$text = $user->getPlan($r_user);
xmlrpc_set_type($text, 'base64');
return $text;
}
开发者ID:jlodom,项目名称:planworld,代码行数:30,代码来源:index.php
示例4: fixUpTypes
/**
* Fixes up
*/
protected function fixUpTypes($response)
{
if (is_array($response)) {
foreach ($response as &$value) {
$value = $this->fixUpTypes($value);
}
}
if ($response instanceof DateTime) {
$response = $response->format("Ymd\\TH:i:s");
xmlrpc_set_type($response, 'datetime');
}
return $response;
}
开发者ID:bdunogier,项目名称:xmlrpcbundle,代码行数:16,代码来源:ResponseGenerator.php
示例5: dateChange
function dateChange($method_name, $params, $app_data)
{
$date_str = $params[0]->scalar;
$date = strptime($date_str, "%Y%m%dT%H:%M:%S");
foreach ($params[1] as $name => $val) {
if ($name == "date") {
continue;
}
$date[$name] = $val;
}
$ret = sprintf("%04d%02d%02dT%02d:%02d:%02d", $date["tm_year"] + 1900, $date["tm_mon"] + 1, $date["tm_mday"], $date["tm_hour"], $date["tm_min"], $date["tm_sec"]);
xmlrpc_set_type($ret, "datetime");
return $ret;
}
开发者ID:david7482,项目名称:libsoup,代码行数:14,代码来源:xmlrpc-server.php
示例6: run_easy_tests
function run_easy_tests($server, $debug = 0, $output = null)
{
global $decl_1, $decl_2, $decl_3, $decl_4;
run_test($server, $debug, $output, "interopEchoTests.echoString", "That government is best, which governs least");
run_test($server, $debug, $output, "interopEchoTests.echoBoolean", true);
run_test($server, $debug, $output, "interopEchoTests.echoInteger", 42);
run_test($server, $debug, $output, "interopEchoTests.echoFloat", 3.1416);
run_test($server, $debug, $output, "interopEchoTests.echoStruct", array("varFloat" => 1.2345, "varInt" => 186000, "varString" => "a string"));
run_test($server, $debug, $output, "interopEchoTests.echoStringArray", array($decl_1, $decl_2, $decl_3, $decl_4));
run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", array(23, 234, 1, 0, -10, 999));
run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", array(2.45, 9.9999));
run_test($server, $debug, $output, "interopEchoTests.echoStructArray", array(array("varFloat" => 1.2345, "varInt" => 186000, "varString" => "a string"), array("varFloat" => 10.98765, "varInt" => 3200, "varString" => "happy little string")));
$foo = "some base64 string";
xmlrpc_set_type(&$foo, "base64");
run_test($server, $debug, $output, "interopEchoTests.echoBase64", $foo);
$foo = "19980717T14:08:55";
xmlrpc_set_type(&$foo, "datetime");
run_test($server, $debug, $output, "interopEchoTests.echoDate", $foo);
run_no_param_test($server, $debug, $output, "interopEchoTests.noInParams");
}
开发者ID:neymanna,项目名称:fusionforge,代码行数:20,代码来源:interop-client.php
示例7: add_param
/**
* Add a parameter to the array of parameters.
*
* @param string $argument A transport ID, as defined in lib.php
* @param string $type The argument type, can be one of:
* none
* empty
* base64
* boolean
* datetime
* double
* int
* string
* array
* struct
* In its weakly-typed wisdom, PHP will (currently)
* ignore everything except datetime and base64
* @return bool True on success
*/
function add_param($argument, $type = 'string')
{
$allowed_types = array('none', 'empty', 'base64', 'boolean', 'datetime', 'double', 'int', 'i4', 'string', 'array', 'struct');
if (!in_array($type, $allowed_types)) {
return false;
}
if ($type != 'datetime' && $type != 'base64') {
$this->params[] = $argument;
return true;
}
// Note weirdness - The type of $argument gets changed to an object with
// value and type properties.
// bool xmlrpc_set_type ( string &value, string type )
xmlrpc_set_type($argument, $type);
$this->params[] = $argument;
return true;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:36,代码来源:client.php
示例8: date
<?php
$params = date("Ymd\\TH:i:s", time());
xmlrpc_set_type($params, 'datetime');
echo xmlrpc_encode($params);
开发者ID:gleamingthecube,项目名称:php,代码行数:5,代码来源:ext_xmlrpc_tests_bug18916.php
示例9: logDebug
logDebug($uploadfile);
$image_filename = basename($_FILES['Filedata']['name']);
$media_id = '';
$error_msg = 'there was a problem with the server';
logDebug('number of files uploaded ' . count($_FILES));
foreach ($_FILES as $key => $value) {
logDebug("Key: {$key}; Value: {$value}");
}
/* here's where we actually do the work */
if ($auth[0] != null) {
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile)) {
logDebug("File is valid, and was successfully uploaded.");
/* open and read in the image file data */
$handle = fopen($uploadfile, "r");
$media_binary = fread($handle, filesize($uploadfile));
xmlrpc_set_type(&$media_binary, "base64");
fclose($handle);
unlink($uploadfile);
/* build the args for the XML-RPC query */
$zapi_query = array($image_filename, $image_filename, "", $media_binary);
/* send it to the zoto server */
$result = zapi_call($zapi_key, $zapi_auth, $zapi_function, $zapi_query);
if (is_array($result)) {
foreach ($result as $key => $value) {
logDebug("Key: {$key}; Value: {$value}");
}
if ($result[0] == '0') {
$upload_success = true;
global $media_id;
$media_id = $result[1];
} else {
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:31,代码来源:upload.php
示例10: validatePDF_2
function validatePDF_2($magic, $callback_URL, $fileID, $file)
{
global $hotdir, $max_processing_seconds, $INP, $NPDF_ERR, $NPDF, $ORIG_ERR, $ORIG_OK, $PROC_ERR, $PROC_OK, $REP_ERR, $REP_OK, $INP_absolute, $xmlrpc, $DEBUG;
ignore_user_abort();
// function may take a long time
set_time_limit($max_processing_seconds + 10);
// does not work in safe mode
ini_set("max_execution_time", $max_processing_seconds + 10);
// does not work in safe mode
if ($DEBUG) {
informAdmin("DEBUG: called validatePDF_2( {$magic}, {$callback_URL}, {$fileID}, {$file} )");
}
// security issue
$file = basename($file);
// to avoid s.th. like '../../../etc/passwd'
// wait for pitstop to process the file
$file_log = "{$file}_log.pdf";
// PitStop names reports like this
$start_time = time();
while (file_exists(cleanPath("{$hotdir}/{$INP}/{$file}")) && $start_time + $max_processing_seconds > time()) {
clearstatcache();
sleep(5);
}
// MISCONCEPTION - PitStop removes the input file before all other files have been written to disk. Especially the Report takes longer.
// wait for report to appear
$report_present = false;
while (!$report_present && $start_time + $max_processing_seconds > time()) {
clearstatcache();
$report_present = file_exists(cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$REP_OK}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}"));
sleep(5);
}
if ($start_time + $max_processing_seconds <= time()) {
// cleanup - not all files will be present, thus neglect warnings
cleanup($file);
informAdmin("validation tooks too long. PitStop server not running? HotDir is '{$hotdir}' and input folder is named '{$INP}'");
return false;
// validation tooks too long
}
sleep(5);
// let PitStop write all files
clearstatcache();
$valid = 2;
// validation was aborted
// PitStop has removed the file, now check the result
if (file_exists(cleanPath("{$hotdir}/{$NPDF}/{$file}"))) {
$reportFileName = cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}");
$valid = false;
}
if (file_exists(cleanPath("{$hotdir}/{$ORIG_ERR}/{$file}"))) {
$reportFileName = cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}");
$valid = false;
}
if (file_exists(cleanPath("{$hotdir}/{$ORIG_OK}/{$file}"))) {
$reportFileName = cleanPath("{$hotdir}/{$REP_OK}/{$file_log}");
$valid = true;
}
if ($valid === 2) {
// cleanup - not all files will be present, thus neglect warnings
cleanup($file);
informAdmin("validation was aborted. Input file was removed, but result is not present.");
return false;
}
if ($DEBUG) {
if ($valid) {
$temp = "pdf file is valid";
} else {
$temp = "file is not valid";
}
informAdmin("DEBUG: validation process completed.\n{$temp}");
}
// PitStop may produce reports with 350 pages and more. These reports can be as large as 8 MiB.
// If pdftk (http://www.pdftk.com) is available, truncate the report; otherwise do not send, if too large
$data = truncate_pdf($reportFileName);
// call the callback function to announce results of validation
$server = parse_url($callback_URL);
$server['port'] = $server['port'] ? $server['port'] : 80;
if ($xmlrpc['pear']) {
// use XML_RPC impl. to contact the callback function, which in turn will commit the result to the database
$client = new XML_RPC_Client($server['path'], $server['host'], $server['port']);
$params = array(new XML_RPC_Value($data, 'base64'), new XML_RPC_Value($valid, 'boolean'), new XML_RPC_Value($magic, 'int'), new XML_RPC_Value($fileID, 'int'));
$xmlrpc_message = new XML_RPC_Message('validatePDF_callback', $params);
if ($DEBUG) {
$client->setDebug(1);
ob_start();
}
$client->send($xmlrpc_message);
if ($DEBUG) {
informAdmin("server reports:\n" . ob_get_contents());
ob_end_clean();
}
} elseif ($xmlrpc['internal']) {
// use internal impl. to contact the callback function, which in turn will commit the result to the database
xmlrpc_set_type($data, "base64");
// converts the string to an object with encoding 'base64'
$params = array($data, $valid, $magic, $fileID);
$output = array('output_type' => 'php');
xu_rpc_http_concise(array(method => 'validatePDF_callback', args => $params, host => $server['host'], uri => $server['path'], port => $server['port'], debug => 0, output => $output));
}
if ($DEBUG) {
informAdmin("DEBUG: callback function validatePDF_callback() at {$callback_URL} was called.");
//.........这里部分代码省略.........
开发者ID:alexzita,项目名称:alex_blog,代码行数:101,代码来源:validatePDF.php
示例11: xmlrpc_set_type
<?php
$a = '~~~~~~~~~~~~~~~~~~';
$ok = xmlrpc_set_type($a, 'datetime');
var_dump($ok);
echo "Done\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:6,代码来源:ext_xmlrpc_tests_bug42189.php
示例12: date
<?php
$d = date(DATE_ISO8601);
xmlrpc_set_type($d, 'datetime');
echo xmlrpc_encode_request('method.call', array('date' => $d));
$d = '2008-01-01 20:00:00';
xmlrpc_set_type($d, 'datetime');
echo xmlrpc_encode_request('method.call', array('date' => $d));
开发者ID:gleamingthecube,项目名称:php,代码行数:8,代码来源:ext_xmlrpc_tests_bug45226.php
示例13: _setXmlrpcType
/**
* Set the correct type for each element in an array
*
* @param array $array
*
* @since 2.2
*/
private function _setXmlrpcType(&$array)
{
foreach ($array as $key => $element) {
if (is_a($element, '\\DateTime')) {
$array[$key] = $element->format("Ymd\\TH:i:sO");
xmlrpc_set_type($array[$key], 'datetime');
} elseif (is_array($element)) {
$this->_setXmlrpcType($array[$key]);
}
}
}
开发者ID:SerjPopov,项目名称:wordpress-xmlrpc-client,代码行数:18,代码来源:WordpressClient.php
示例14: setType
/**
* @param mixed $value
* @param string $type base64 or datetime
* @return bool
*/
public static function setType(&$value, $type)
{
xmlrpc_set_type($value, $type);
}
开发者ID:blar,项目名称:xmlrpc,代码行数:9,代码来源:Xmlrpc.php
示例15: prepare_string
/**
* Return a Trans object so that a potentially non XML-safe string can be sent
* into the XML-RPC stream.
* e.g. a password can contains the & character, so the password string must be encoded.
*/
function prepare_string($pass)
{
xmlrpc_set_type($pass, 'base64');
return $pass;
}
开发者ID:pulse-project,项目名称:pulse,代码行数:10,代码来源:xmlrpc.inc.php
示例16: end_test
}
end_test('Data encoding (large array)', 'manual encoding', $out);
begin_test('Data encoding (large array)', 'automatic encoding');
$encoder = new Encoder();
for ($i = 0; $i < $num_tests; $i++) {
$value = $encoder->encode($data, array('auto_dates'));
$out = $value->serialize();
}
end_test('Data encoding (large array)', 'automatic encoding', $out);
if (function_exists('xmlrpc_set_type')) {
begin_test('Data encoding (large array)', 'xmlrpc-epi encoding');
for ($i = 0; $i < $num_tests; $i++) {
for ($j = 0; $j < 10; $j++) {
foreach ($keys as $k) {
xmlrpc_set_type($data[$j][$k][4], 'datetime');
xmlrpc_set_type($data[$j][$k][8], 'datetime');
}
}
$out = xmlrpc_encode($data);
}
end_test('Data encoding (large array)', 'xmlrpc-epi encoding', $out);
}
// test 'old style' data decoding vs. 'automatic style' decoding
$dummy = new Request('');
$out = new Response($value);
$in = '<?xml version="1.0" ?>' . "\n" . $out->serialize();
begin_test('Data decoding (large array)', 'manual decoding');
for ($i = 0; $i < $num_tests; $i++) {
$response = $dummy->ParseResponse($in, true);
$value = $response->value();
$result = array();
开发者ID:TsobuEnterprise,项目名称:phpxmlrpc,代码行数:31,代码来源:benchmark.php
示例17: base64
/**
* This method returns an XML-RPC base64 object from a given binary string.
*
* @param string $binary
*
* @return object
*/
public static function base64($binary)
{
xmlrpc_set_type($binary, 'base64');
return $binary;
}
开发者ID:darkaonline,项目名称:ripcord,代码行数:12,代码来源:Ripcord.php
注:本文中的xmlrpc_set_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论