开发者

Call a php file in webroot from a controller using cake php

开发者 https://www.devze.com 2023-03-16 01:06 出处:网络
I have a php file in webroot.which returns an array of filenames.So I want to call this php file from a controller.can u give me an ideaa how ll I do this...??the content of this php file is given bel

I have a php file in webroot.which returns an array of filenames.So I want to call this php file from a controller.can u give me an ideaa how ll I do this...??the content of this php file is given below:

<?php
//if($_SERVER['REMOTE_ADDR']=='10.1.31.77'){debugbreak();}    
include ("../vendors/xmlrpc.inc");
?>
<html>
<head>
<title>XML-RPC PHP Demo</title>
</head>
<body>
<h1>XML-RPC PHP Demo</h1>

<?php

$client = new xmlrpc_client('/individual-trade-server-manager/list-binaries-on-trade-server.php',
                            '125.20.11.245', 80);
//$client->return_type = 'phpvals';                                                                                                                                                                                                           
//$client->setDebug ( 2 );                                                                                                                                                                                                                    
$strin开发者_StackOverflowgToEcho = 'Hello World';
// Send a message to the server.                                                                                                                                                                                                              
$message = new xmlrpcmsg('rpc.FnListAllBinaryFiles',array(php_xmlrpc_encode ( $stringToEcho )));
$result = $client->send($message);

// Process the response.                                                                                                                                                                                                                      
if (!$result) {
  print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
  print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
    $result->faultString();
} else {

  $output=php_xmlrpc_decode($result->value());
  $output=explode('*',$output);
  //echo "<pre>";
 // print_r($output);
}
//echo "<pre>";
// print_r($output);
?>
<table>
<tr><th>Binary Filenames</th></tr>
<?php
foreach($output as $val)
{
    //echo "<pre>";
 //print_r($val);
?>
<tr><td><?php echo $val; ?></td></tr>
<?php
}
?>
</table>
</body></html>

So i just want call this page from a controller so how ll i call this page,and set this this $output array in the controller.

thanks in advance


I would suggest you create a class with static function in the vendors folder.

The static function will return your array and you will be able to invoke the method from your controller using Myclass::mymethod();

0

精彩评论

暂无评论...
验证码 换一张
取 消