Example #1
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function run()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', "appError"));
     set_exception_handler(array('App', "appException"));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     //导入类库
     Vendor('Zend.Amf.Server');
     //实例化AMF
     $server = new Zend_Amf_Server();
     $actions = explode(',', C('APP_AMF_ACTIONS'));
     foreach ($actions as $action) {
         $server->setClass($action . 'Action');
     }
     echo $server->handle();
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
 public function index()
 {
     // Require Zend_Amf_Server
     require_once 'Zend/Amf/Server.php';
     // *ZAMFBROWSER IMPLEMENTATION*
     // Require the ZendAmfServiceBrowser class, required to retrieve the list of methods on the ZendAMF server.
     require_once Kohana::find_file('vendor/ZamfBrowser', 'ZendAmfServiceBrowser');
     // Start Server
     $server = new Zend_Amf_Server();
     // $server->addDirectory( SHAREDPATH.Kohana::config('zendamf.services_path') );
     $services_path = APPPATH . Kohana::config('zendamf.services_path');
     $files = Kohana::list_files($services_path, FALSE);
     foreach ($files as $file) {
         $class = pathinfo($file, PATHINFO_FILENAME);
         $server->setClass($class);
     }
     // // do class mapping
     $vo_path = APPPATH . Kohana::config('zendamf.vo_path');
     $files = Kohana::list_files($vo_path, FALSE);
     foreach ($files as $file) {
         $class = pathinfo($file, PATHINFO_FILENAME);
         $server->setClassMap($class, $class);
     }
     // *ZAMFBROWSER IMPLEMENTATION*
     // Add the ZendAmfServiceBrowser class to the list of available classes.
     $server->setClass("ZendAmfServiceBrowser");
     // *ZAMFBROWSER IMPLEMENTATION*
     // Set this reference the class requires to the server object.
     // ZendAmfServiceBrowser::setAmfServer( $server );
     ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;
     // Handle the AMF request
     echo $server->handle();
 }
Example #3
0
 public function indexAction()
 {
     $server = new Zend_Amf_Server();
     $server->addDirectory(APPLICATION_PATH . '/amf/services');
     self::registerVO($server, "vo.Test", "Amf_VO_Test");
     self::registerVO($server, "vo.ByteArray", "Amf_VO_ByteArray");
     echo $server->handle();
 }
Example #4
0
 public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $server = new Zend_Amf_Server();
     $server->addDirectory(APPLICATION_PATH . '/services/');
     $server->setProduction(FALSE);
     echo $server->handle();
 }
Example #5
0
 public function indexAction()
 {
     $this->_helper->layout->setLayout('json');
     $this->getHelper('ViewRenderer')->setNoRender();
     $server = new Zend_Amf_Server();
     $server->addDirectory(dirname(__FILE__) . '/../services/');
     echo $server->handle();
 }
 public function amfAction()
 {
     $server = new Zend_Amf_Server();
     require_once APPLICATION_PATH . '/auth/Auth.php';
     $server->setAuth(new Auth());
     $server->addDirectory(APPLICATION_PATH . '/services/');
     $response = $server->handle();
     echo $response;
 }
Example #7
0
File: amf.php Project: 4u4v/think
 /**
  * PHPRpc控制器架构函数
  * @access public
  */
 public function __construct()
 {
     //导入类库
     think\loader::import('vendor.zend.amf.server');
     //实例化AMF
     $server = new \Zend_Amf_Server();
     $server->setClass($this);
     echo $server->handle();
     return;
 }
Example #8
0
 protected function _callService($method, $class = 'Zend_Amf_Resource_testclass')
 {
     $request = new Zend_Amf_Request();
     $request->setObjectEncoding(0x3);
     $this->_server->setClass($class);
     $newBody = new Zend_Amf_Value_MessageBody("{$class}.{$method}", "/1", array("test"));
     $request->addAmfBody($newBody);
     $this->_server->handle($request);
     $response = $this->_server->getResponse();
     return $response;
 }
Example #9
0
 protected function _callService($method, $class = 'ZendTest\\AMF\\TestAsset\\testclass')
 {
     $request = new \Zend\AMF\Request\StreamRequest();
     $request->setObjectEncoding(0x3);
     $this->_server->setClass($class);
     $newBody = new \Zend\AMF\Value\MessageBody("{$class}.{$method}", "/1", array("test"));
     $request->addAmfBody($newBody);
     $this->_server->handle($request);
     $response = $this->_server->getResponse();
     return $response;
 }
Example #10
0
    public function testLogout()
    {
        $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole"));
        $this->_acl->addRole(new Role\GenericRole("testrole"));
        $this->_acl->allow("testrole", null, null);
        $this->_server->setAcl($this->_acl);
        $resp = $this->_callServiceAuth("testuser", "");
        $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage);
        $this->assertContains("hello", $resp[1]->getData());

        // After logout same request should not be allowed
        $this->setUp();
        $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole"));
        $this->_server->setAcl($this->_acl);
        $request = new Request\StreamRequest();
        $request->setObjectEncoding(0x03);
        $this->_addLogout($request);
        $this->_addServiceCall($request);
        $this->_server->handle($request);
        $resp = $this->_server->getResponse()->getAmfBodies();

        $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage);
        $data = $resp[1]->getData();
        $this->assertTrue($data instanceof Messaging\ErrorMessage);
        $this->assertContains("not allowed", $data->faultString);
    }
Example #11
0
 public function testLogout()
 {
     Zend_Session::$_unitTestEnabled = true;
     $this->_server->setAuth(new RightPassword("testuser", "testrole"));
     $this->_acl->addRole(new Zend_Acl_Role("testrole"));
     $this->_acl->allow("testrole", null, null);
     $this->_server->setAcl($this->_acl);
     $resp = $this->_callServiceAuth("testuser", "");
     $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
     $this->assertContains("hello", $resp[1]->getData());
     // After logout same request should not be allowed
     $this->setUp();
     $this->_server->setAuth(new RightPassword("testuser", "testrole"));
     $this->_server->setAcl($this->_acl);
     $request = new Zend_Amf_Request();
     $request->setObjectEncoding(0x3);
     $this->_addLogout($request);
     $this->_addServiceCall($request);
     $this->_server->handle($request);
     $resp = $this->_server->getResponse()->getAmfBodies();
     $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
     $data = $resp[1]->getData();
     $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
     $this->assertContains("not allowed", $data->faultString);
 }
Example #12
0
 protected function _dispatch($method, $params = null, $source = null)
 {
     $st = microtime(true);
     $content = $params[0];
     $mypre = "{$source}-{$method}";
     if ($content->lang == 4) {
         ServerConfig::setLang('en');
     }
     if ($content->lang == 3) {
         ServerConfig::setLang('zh');
     }
     CrabTools::mydump($params[0], REQ_DATA_ROOT . $mypre . '.param');
     Logger::info("{$source}::{$method}");
     try {
         $ret = parent::_dispatch($method, $params, $source);
         $parastr = print_r($params, true);
         $et = microtime(true);
         $cost = $et - $st;
         $cost = ceil(1000000 * $cost);
         Logger::info("{$source}::{$method}  {$cost} ,  [{$ret['status']}]  [{$ret['msg']}] {$parastr}");
         CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp');
         return $ret;
     } catch (Exception $e) {
         CrabTools::myprint($e, REQ_DATA_ROOT . $mypre . '.exp');
         return array('status' => 'error', 'msg' => 'exe exception');
     }
     Logger::error('Method "' . $method . '" auth failed' . " sk={$session_key} platform_id={$platform_id} ");
     return array('status' => 'error', 'msg' => 'auth failed');
 }
Example #13
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function run()
 {
     //导入类库
     Vendor('Zend.Amf.Server');
     //实例化AMF
     $server = new Zend_Amf_Server();
     $actions = explode(',', C('APP_AMF_ACTIONS'));
     foreach ($actions as $action) {
         $server->setClass($action . 'Action');
     }
     echo $server->handle();
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
Example #14
0
 protected function _dispatch($method, $params = null, $source = null)
 {
     $content = $params[0];
     ServerConfig::setLang($content->lang);
     return parent::_dispatch($method, $params, $source);
     $auth = $content->auth;
     if ($platform_id != null || $this->authOrkut($platform_id, $auth)) {
         return parent::_dispatch($method, $params, $source);
     }
     Logger::error('Method "' . $method . '" auth failed' . " auth={$auth} platform_id={$platform_id} ");
     return array('status' => 'error', 'msg' => 'auth failed');
 }
 public function indexAction()
 {
     // action body
     $server = new Zend_Amf_Server();
     $server->setClass('Default_Model_Account');
     $server->setClass('Default_Model_Transaction');
     $server->setClass('Default_Model_HelloWorld');
     $server->setClassMap('AccountVO', 'Default_Model_Vo_Account');
     $server->setClassMap('TransactionVO', 'Default_Model_Vo_Transaction');
     echo $server->handle();
 }
Example #16
0
 /**
  * Run the AMF server
  */
 public function run()
 {
     $enable = $this->get_enable();
     if (empty($enable)) {
         die;
     }
     include "Zend/Loader.php";
     Zend_Loader::registerAutoload();
     //retrieve the api name
     $classpath = optional_param('classpath', 'user', PARAM_ALPHA);
     require_once dirname(__FILE__) . '/../../' . $classpath . '/external.php';
     /// run the Zend AMF server
     $server = new Zend_Amf_Server();
     $debugmode = get_config($this->get_protocolid(), 'debug');
     if (!empty($debugmode)) {
         $server->setProduction(false);
     } else {
         $server->setProduction(true);
     }
     $server->setClass($classpath . "_external");
     $response = $server->handle();
     echo $response;
 }
Example #17
0
 public function load()
 {
     $folder = 'AmfServices';
     defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__)));
     require_once dirname(__FILE__) . '/../lib/amf/browser/ZendAmfServiceBrowser.php';
     set_include_path(dirname(__FILE__) . '/../lib/amf/library' . PATH_SEPARATOR . get_include_path());
     require_once dirname(__FILE__) . '/../lib/amf/library/Zend/Amf/Server.php';
     $server = new \Zend_Amf_Server();
     set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/' . $folder . '/'), get_include_path())));
     $service_path = $this->container->getParameter('service_path');
     if (empty($service_path)) {
         $folder = APPLICATION_PATH . '/' . $folder . '/';
     } else {
         $folder = getcwd() . '/../src/' . $service_path . '/Services/AmfServices/';
         $folderPath = '/src/' . $service_path . '/Services/AmfServices/';
     }
     if (!is_dir($folder)) {
         echo 'path is undefined <br /> create: ' . $folderPath;
         die;
     }
     if (count(glob($folder . '*.php')) < 1) {
         echo 'no services defined';
         die;
     }
     foreach (glob($folder . '*.php') as $filename) {
         $service = basename($filename, ".php");
         $filerawname = basename($filename);
         if (file_exists($folder . $filerawname)) {
             include_once $folder . $filerawname;
             $server->setClass($service);
         }
     }
     $server->setClass("ZendAmfServiceBrowser");
     \ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;
     return $server->handle();
 }
	public function indexAction()
	{			
		$server = new Zend_Amf_Server();
		
		//set amf server session namespace
		$server->setSession(Security_Model_Session_Manager::ADMIN_SESSION_NAME);
		
		$server->setProduction(false);
		
		//set service root directory
		$server->addDirectory(realpath(dirname(__FILE__) . '/../services/amf/'));
		
		//set value object class mapping
		$server->setClassMap('LoginVO', 'Security_Model_Auth_Vo_LoginVO');
		$server->setClassMap('SessionVO', 'Security_Model_Auth_Vo_SessionVO');
		
		echo($server->handle());
	}
Example #19
0
 protected function _dispatch($method, $params = null, $source = null)
 {
     $data = $this->_verifySignature($source . '.' . $method, $params[0]);
     $params = array((array) $data);
     try {
         $return = parent::_dispatch($method, $params, $source);
     } catch (Zend_Exception $e) {
         throw $e;
     } catch (Exception $e) {
         $return = array('success' => false, 'error' => $e->getMessage());
     }
     if (is_array($return)) {
         $obj = new StdClass();
         foreach ($return as $key => $value) {
             $obj->{$key} = $value;
         }
         $return = $obj;
     }
     return $this->_return($return);
 }
Example #20
0
 protected function _dispatch($method, $params = null, $source = null)
 {
     $content = $params[0];
     return parent::_dispatch($method, $params, $source);
     $auth = $content->auth;
     ServerConfig::setLang($content->lang);
     if ($content->platform_id != null) {
         $platform_id = $content->platform_id;
     } else {
         if ($content->user_id != null) {
             $user_id = $content->user_id;
             $platform_id = AutoIncIdGenerator::getPlatformId($user_id);
         }
     }
     $vk = new Vk($platform_id);
     if ($vk->auth($auth)) {
         return parent::_dispatch($method, $params, $source);
     }
     Logger::error('Method "' . $method . '" auth failed' . " sk={$session_key} platform_id={$platform_id} ");
     return array('status' => 'error', 'msg' => 'auth failed');
 }
	public function indexAction()
	{			
		$acl = new Zend_Acl();
		$acl->addRole(new Zend_Acl_Role('administrator'));
		Zend_Session::regenerateId();
		
		$server = new Zend_Amf_Server();
		
		//set amf server session namespace
		$server->setSession();
		$server->setProduction(false);
		$server->setAcl($acl);
		
		//set service root directory
		$server->addDirectory(realpath(dirname(__FILE__) . '/../services/amf/'));
		
		echo($server->handle());
	}
Example #22
0
 protected function _dispatch($method, $params = null, $source = null)
 {
     $content = $params[0];
     ServerConfig::setLang($content->lang);
     return parent::_dispatch($method, $params, $source);
     /*
     
     $session_key = $content->auth;
     if($content->platform_id !=null)
     {
     $platform_id = $content->platform_id;
     }
     else if($content->user_id !=null)
     {
     $user_id = $content->user_id;
     $platform_id = AutoIncIdGenerator::getPlatformId($user_id);
     }
     if($platform_id != null && $this->authRenren($platform_id,$session_key) ){
     return parent::_dispatch($method, $params, $source );
     }
     Logger::error('Method "' . $method . '" auth failed'." sk=$session_key platform_id=$platform_id ");
     return array('status'=>'error','msg'=>'auth failed');
     */
 }
Example #23
0
<?php 
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", "on");
require_once 'Zend/Amf/Server.php';
require_once 'Tutorials.php';
$server = new Zend_Amf_Server();
$server->setClass("Tutorials");
echo $server->handle();
Example #24
0
<?php

define('FANWE_ROOT', str_replace('services/fanwe.php', '', str_replace('\\', '/', __FILE__)));
require FANWE_ROOT . 'core/fanwe.php';
@set_include_path(FANWE_ROOT . 'services/');
require "Zend/Amf/Server.php";
require "fanwe.service.php";
$fanwe =& FanweService::instance();
$fanwe->initialize();
$server = new Zend_Amf_Server();
$server->setClass('FanweAmfService');
echo $server->handle();
Example #25
0
 /**
  * addFunction() test
  *
  * Call as method call
  *
  * Expects:
  * - function:
  * - namespace: Optional; has default;
  *
  * Returns: void
  */
 public function testAddFunction()
 {
     try {
         $this->_server->addFunction('Zend_Amf_Server_testFunction', 'test');
     } catch (Exception $e) {
         $this->fail('Attachment should have worked');
     }
     $methods = $this->_server->listMethods();
     $this->assertTrue(in_array('test.Zend_Amf_Server_testFunction', $methods), var_export($methods, 1));
     try {
         $this->_server->addFunction('nosuchfunction');
         $this->fail('nosuchfunction() should not exist and should throw an exception');
     } catch (Exception $e) {
         // do nothing
     }
     $server = new Zend_Amf_Server();
     try {
         $server->addFunction(array('Zend_Amf_Server_testFunction', 'Zend_Amf_Server_testFunction2'), 'zsr');
     } catch (Exception $e) {
         $this->fail('Error attaching array of functions: ' . $e->getMessage());
     }
     $methods = $server->listMethods();
     $this->assertTrue(in_array('zsr.Zend_Amf_Server_testFunction', $methods));
     $this->assertTrue(in_array('zsr.Zend_Amf_Server_testFunction2', $methods));
 }
Example #26
0
<?php

error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", "on");
// Modify include_path to include the Zend library
// this is because they assume that their folder is in the path
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . "../zend_framework/library");
date_default_timezone_set('America/Boise');
require_once "Zend/Amf/Server.php";
require_once 'Zend/Amf/Value/ByteArray.php';
$server = new Zend_Amf_Server();
class Tester
{
    public function Gimme()
    {
        $ret = "howdy";
        // do a bunch of mcrypt calls on $ret here
        return new Zend_Amf_Value_ByteArray($ret);
    }
}
//adding our class to Zend AMF Server
$server->setClass("Tester");
// Change this to true when released to production
$server->setProduction(false);
echo $server->handle();
Example #27
0
 /**
  * @group ZF-6130
  */
 public function testServerShouldCastObjectArgumentsToAppropriateType()
 {
     $server = new Zend_Amf_Server();
     $server->addDirectory(dirname(__FILE__) . '/_files/zf-6130/services');
     // Create a mock message
     $message = new Zend_Amf_Value_Messaging_RemotingMessage();
     $message->operation = 'createEmployee';
     $message->source = 'EmployeeService';
     // original raw request used "destination"
     $message->body = array(array('office' => 322, 'departmentid' => 3, 'street' => 32, 'zipcode' => 32, 'state' => 32, 'lastname' => 4, 'firstname' => 2, 'photofile' => 322, 'city' => 32, 'id' => 1, 'title' => 4, 'officephone' => 233, 'email' => 32, 'cellphone' => 22));
     $body = new Zend_Amf_Value_MessageBody(null, "", $message);
     $request = new Zend_Amf_Request();
     $request->addAmfBody($body);
     $request->setObjectEncoding(0x3);
     $response = $server->handle($request);
     $employee = EmployeeService::$employee;
     $this->assertNotNull($employee);
     $this->assertNotEquals(1, $employee->id);
     $this->assertRegexp('/[a-z0-9]{3,}/', $employee->id);
 }
Example #28
0
<?php

error_reporting(E_ALL);
require_once 'Zend/Amf/Server.php';
require_once 'QosPortalService.php';
require_once 'QosDataService.php';
require_once 'QosUserService.php';
require_once 'QosReportsService.php';
require_once 'QosCommentService.php';
require_once 'QosDbCheck.php';
require_once 'QosImportErrorService.php';
require_once 'QosExportService.php';
$server = new Zend_Amf_Server();
$server->setClass("QosPortalService");
$server->setClass("QosDataService");
$server->setClass("QosUserService");
$server->setClass("QosReportsService");
$server->setClass("QosCommentService");
$server->setClass("QosDbCheck");
$server->setClass("QosImportErrorService");
$server->setClass("QosExportService");
$server->setProduction(false);
$server->setClassMap("VOUser", "VOUser");
$server->setClassMap("VOReport", "VOReport");
$server->setClassMap("VOCartesianChartReport", "VOCartesianChartReport");
$server->setClassMap("VOTableReport", "VOTableReport");
$server->setClassMap("VOMultiviewReport", "VOMultiviewReport");
$server->setClassMap("VOCategory", "VOCategory");
$server->setClassMap("VOReportType", "VOReportType");
$server->setClassMap("VOKpi", "VOKpi");
$server->setClassMap("VOKpiType", "VOKpiType");
<?php

require_once 'Zend/Amf/Server.php';
$server = new Zend_Amf_Server();
$server->addFunction('sayHello');
$server->setClass("World");
echo $server->handle();
function sayHello($name, $age)
{
    return 'Hello ' . $name . ",your age is " . $age;
}
class World
{
    public function hello()
    {
        return 'Hello World';
    }
}
Example #30
0
require_once "service/Supertoto.php";
require_once "service/Players.php";
require_once "service/Sports.php";
// Error Reporting
error_reporting(E_ALL | E_STRICT);
// Turn to off when released to production
ini_set("display_errors", "on");
//set up your zend 1.7 location
ini_set("include_path", "../../zend/library");
// Zend Framework Includes
require_once "Zend/Loader.php";
require_once 'Zend/Auth.php';
require_once "Zend/Amf/Server.php";
require_once "Zend/dbcontrol/StoredConnections.php";
Zend_Loader::registerAutoload();
Zend_Session::start();
Zend_Session::regenerateId();
$server = new Zend_Amf_Server();
$server->setClass("Bookhouse");
$server->setClass("Bets");
$server->setClass("Sports");
$server->setClass("Groups");
$server->setClass("Teams");
$server->setClass("Prebuild");
$server->setClass("Events");
$server->setClass("Supertoto");
$server->setClass("Players");
$server->setClass("Login");
// Change this to true when released to production
$server->setProduction(false);
echo $server->handle();