gateway.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /*
  3. $Id: gateway.php,v 1.4 2005/07/05 07:40:54 pmineault Exp $
  4. The gateway is a customized entry point to your flash
  5. services.
  6. Things you can set here:
  7. - setBaseClassPath(string path) The absolute path to your services on the server
  8. - setLooseMode(bool mode) If true, output buffering is enabled and error_reporting
  9. is lowered to circumvent a number of documented NetConnection.BadVersion errors
  10. - setCharsetHandler(string mode, string phpCharset, string sqlCharset)
  11. mode can be one of
  12. - none don't do anything
  13. - iconv uses the iconv libray for reencoding
  14. - mbstring uses the mbstring library for reencoding
  15. - recode uses the recode library for reencoding
  16. - utf8_decode uses the XML function utf8_decode and encode for
  17. reencoding - ISO-8859-1 only
  18. phpCharset is the charset that the system assumes the PHP strings will be in.
  19. sqlCharset is the charset of sql result sets used (only when outputting results
  20. to flash client)
  21. wsCharset (web service charset) has been eliminated from this release, UTF-8
  22. is assumed as the remote encoding. When using PHP5 SoapClient, the SoapClient
  23. object will be initialized with "encoding" => phpCharset. When using nusoap,
  24. soapclient->soap_defencoding will be initialized with phpCharset.
  25. The following settings are recommended (try the first setting appropriate for
  26. your language, if it doesn't work try the second):
  27. * English:
  28. $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
  29. * Western european languages (French, Spanish, German, etc.):
  30. $gateway->setCharsetHandler( "iconv", "ISO-8859-1", "ISO-8859-1" );
  31. $gateway->setCharsetHandler( "utf8_decode", "ISO-8859-1", "ISO-8859-1" );
  32. * Eastern european languages (Russian and other slavic languages):
  33. $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
  34. $gateway->setCharsetHandler( "iconv", "your codepage", "your codepage" );
  35. * Oriental languages (Chinese, japanese, korean):
  36. $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
  37. $gateway->setCharsetHandler( "iconv", "big5", "big5" );
  38. $gateway->setCharsetHandler( "iconv", "CP950", "CP950" );
  39. $gateway->setCharsetHandler( "iconv", "Shift_JIS", "Shift_JIS" );
  40. $gateway->setCharsetHandler( "iconv", "CP932", "CP932" );
  41. $gateway->setCharsetHandler( "iconv", "CP949", "CP949" );
  42. * Other languages:
  43. $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
  44. See all the possible codepages for iconv here:
  45. http://www.gnu.org/software/libiconv/
  46. iconv is included by default in php5, but not in php4 although most
  47. hosts have it installed. utf8_decode is of some use for Western European languages,
  48. but please remember that it won't work with settings other than ISO-8859-1.
  49. The other methods also require seldom-used extensions but were included
  50. just in case your particular host only supports them.
  51. - setWebServiceHandler(string handler)
  52. Handler can be one of:
  53. - php5 (that is, PHP5 SoapClient)
  54. - pear
  55. - nusoap
  56. This is used for webservices when working with http:// service names in
  57. new Service(). For php5 and pear, you will need to have it installed on your
  58. server. For nusoap, you need nusoap.php instead in ./lib relative to this file.
  59. If you have PHP5 and the SOAP extension installed it is highly recommended that
  60. you use it as it is _much_ faster than NuSOAP or PEAR::SOAP
  61. Things you may want to disable for production environments:
  62. - disableStandalonePlayer()
  63. Disables the standalone player by filtering out its User-Agent string
  64. - disableServiceDescription()
  65. Disable service description from Macromedia's service browser
  66. - disableTrace()
  67. Disables remote tracing
  68. - disableDebug()
  69. Stops debug info from being sent (independant of remote trace setting)
  70. */
  71. error_log("service connection");
  72. //You can set this constant appropriately to disable traces and debugging headers
  73. //You will also have the constant available in your classes, for changing
  74. //the mysql server info for example
  75. define("PRODUCTION_SERVER", true);
  76. //Include things that need to be global, for integrating with other frameworks
  77. include "globals.php";
  78. //Include framework
  79. include "core/amf/app/Gateway.php";
  80. $gateway = new Gateway();
  81. //Set where the services classes are loaded from, *with trailing slash*
  82. //$servicesPath defined in globals.php
  83. $gateway->setClassPath($servicesPath);
  84. //Set where class mappings are loaded from (ie: for VOs)
  85. //$voPath defined in globals.php
  86. $gateway->setClassMappingsPath($voPath);
  87. //Read above large note for explanation of charset handling
  88. //The main contributor (Patrick Mineault) is French,
  89. //so don't be afraid if he forgot to turn off iconv by default!
  90. // $gateway->setCharsetHandler("utf8_decode", "UISO-8859-1", "ISO-8859-1");
  91. // Modif CJ
  92. $gateway->setCharsetHandler("utf8_decode", "UTF-8", "UTF-8");
  93. //Error types that will be rooted to the NetConnection debugger
  94. $gateway->setErrorHandling(E_ALL ^ E_NOTICE);
  95. if(PRODUCTION_SERVER)
  96. {
  97. //Disable profiling, remote tracing, and service browser
  98. $gateway->disableDebug();
  99. // Keep the Flash/Flex IDE player from connecting to the gateway. Used for security to stop remote connections.
  100. $gateway->disableStandalonePlayer();
  101. }
  102. //If you are running into low-level issues with corrupt messages and
  103. //the like, you can add $gateway->logIncomingMessages('path/to/incoming/messages/');
  104. //and $gateway->logOutgoingMessages('path/to/outgoing/messages/'); here
  105. //$gateway->logIncomingMessages('in/');
  106. //$gateway->logOutgoingMessages('out/');
  107. //Explicitly disable the native extension if it is installed
  108. //$gateway->disableNativeExtension();
  109. //Enable gzip compression of output if zlib is available,
  110. //beyond a certain byte size threshold
  111. $gateway->enableGzipCompression(25*1024);
  112. //Service now
  113. $gateway->service();
  114. ?>