[ Index ]
 

Code source de Seagull 0.6.1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/rpc/ -> server.php (source)

   1  <?php
   2  /**
   3   * XML RPC server.
   4   *
   5   * @author Demian Turner <demian@phpkitchen.com>
   6   * @author James Floyd <jgfloyd@btinternet.com>
   7   */
   8  
   9  $rootDir = dirname(__FILE__) . '/../..';
  10  $varDir = dirname(__FILE__) . '/../../var';
  11  
  12  //  check for lib cache
  13  define('SGL_CACHE_LIBS', (is_file($varDir . '/ENABLE_LIBCACHE.txt'))
  14      ? true
  15      : false);
  16  
  17  require_once $rootDir .'/lib/SGL/FrontController.php';
  18  SGL_FrontController::init();
  19  
  20  require_once 'XML/RPC/Server.php';
  21  
  22  /**
  23   * Method to return dispatcher map containing information
  24   * about defined SGL XML-RPC methods.
  25   *
  26   * @return array dispacher map
  27   *
  28   * Array
  29   * (
  30   *     (
  31   *         [agencies.getStats] => Array
  32   *             (
  33   *                 [function] => SGL_XML_RPC_Server_myFunctionName
  34   *                 [signature] => Array
  35   *                     (
  36   *                         [0] => Array
  37   *                             (
  38   *                                 [0] => boolean
  39   *                                 [1] => int
  40   *                                 [2] => struct
  41   *                                 [3] => struct
  42   *                             )
  43   *                     )
  44   *                 [docstring] => Accepts one int parameter, returns true if agency is successfully deactivated.
  45   *             )
  46   *     )
  47   */
  48  function SGL_XML_RPC_getDispatchMap()
  49  {
  50      $map = array();
  51  
  52      // scan services folder
  53      require_once 'File/Util.php';
  54      $rpcModuleDir = SGL_LIB_DIR . '/SGL/XML/RPC/services';
  55      $aFiles = SGL_Util::listDir($rpcModuleDir, FILE_LIST_FILES, $sort = FILE_SORT_NONE);
  56  
  57      foreach ($aFiles as $file) {
  58          require_once $rpcModuleDir . '/' . $file;
  59  
  60          // formulate expected method name
  61          $actionName = substr($file, 0, strlen(substr($file, 0, strrpos($file, '.'))));
  62          $functionName = 'SGL_XML_RPC_Server_' . $actionName;
  63  
  64          if (function_exists($functionName)) {
  65              $aliasVar = $actionName . '_alias';
  66              $signatureVar = $actionName . '_sig';
  67              $docstringVar = $actionName . '_doc';
  68  
  69              // check required config values are set
  70              if (isset(${$aliasVar}) && isset(${$signatureVar}) && isset(${$docstringVar})) {
  71  
  72                  // Build map values
  73                  $map[${$aliasVar}] = array(
  74                      "function"  => $functionName,
  75                      "signature" => ${$signatureVar},
  76                      "docstring" => ${$docstringVar},
  77                      );
  78              } else {
  79                  echo 'SGL_XML_RPC_Server_' . $file . ' required param not defined!!';
  80              }
  81          } else {
  82              echo 'SGL_XML_RPC_Server_' . $file . ' method not defined!!';
  83          }
  84      }
  85      return $map;
  86  }
  87  
  88  /**
  89   * Cache wrapper for SGL_XML_RPC_getDispatchMap method.
  90   *
  91   * @return array dispacher map
  92   */
  93  function SGL_XML_RPC_getDispatchMap_cache()
  94  {
  95      require_once 'Cache/Lite/Function.php';
  96      $options = array(
  97          'cacheDir' => SGL_CACHE_DIR,
  98          'lifeTime' => 0
  99      );
 100  
 101      $cache = new Cache_Lite_Function($options);
 102      return $cache->call('SGL_XML_RPC_getDispatchMap');
 103  }
 104  
 105  $map = SGL_XML_RPC_getDispatchMap_cache();
 106  #$map = SGL_XML_RPC_getDispatchMap();
 107  new XML_RPC_Server($map, $serviceNow = 1, $debug = 0);
 108  ?>


Généré le : Fri Mar 30 01:27:52 2007 par Balluche grâce à PHPXref 0.7