当前位置: 首页>>代码示例>>PHP>>正文


PHP OSCOM::setSite方法代码示例

本文整理汇总了PHP中osCommerce\OM\Core\OSCOM::setSite方法的典型用法代码示例。如果您正苦于以下问题:PHP OSCOM::setSite方法的具体用法?PHP OSCOM::setSite怎么用?PHP OSCOM::setSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osCommerce\OM\Core\OSCOM的用法示例。


在下文中一共展示了OSCOM::setSite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 public static function initialize()
 {
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Content-Type: application/json; charset=utf-8');
     if (empty($_GET)) {
         echo json_encode(array('rpcStatus' => self::STATUS_NO_MODULE));
         exit;
     }
     $site = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true))));
     $application = HTML::sanitize(basename(key(array_slice($_GET, 2, 1, true))));
     if (!OSCOM::siteExists($site)) {
         echo json_encode(array('rpcStatus' => self::STATUS_CLASS_NONEXISTENT));
         exit;
     }
     OSCOM::setSite($site);
     if (!OSCOM::siteApplicationExists($application)) {
         echo json_encode(array('rpcStatus' => self::STATUS_CLASS_NONEXISTENT));
         exit;
     }
     OSCOM::setSiteApplication($application);
     call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'initialize'));
     if (!call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'hasAccess'), $application)) {
         echo json_encode(array('rpcStatus' => self::STATUS_NO_ACCESS));
         exit;
     }
     if (count($_GET) < 3) {
         echo json_encode(array('rpcStatus' => self::STATUS_NO_ACTION));
         exit;
     }
     $rpc_called = false;
     $rpc = array('RPC');
     for ($i = 3, $n = count($_GET); $i < $n; $i++) {
         $subrpc = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true))));
         if (self::siteApplicationRPCExists(implode('\\', $rpc) . '\\' . $subrpc)) {
             call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\' . implode('\\', $rpc) . '\\' . $subrpc, 'execute'));
             $rpc[] = $subrpc;
             $rpc_called = true;
         } else {
             break;
         }
     }
     if ($rpc_called === false) {
         echo json_encode(array('rpcStatus' => self::STATUS_NO_ACTION));
         exit;
     }
     exit;
 }
开发者ID:digitaldevelopers,项目名称:oscommerce,代码行数:48,代码来源:Controller.php

示例2: initialize

    public static function initialize() {
      header('Content-Type: application/json; charset=utf-8');
      header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
      header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
      header('Cache-Control: no-store, no-cache, must-revalidate');
      header('Cache-Control: post-check=0, pre-check=0', false);
      header('Pragma: no-cache');

      try {
        if ( empty($_GET) ) {
          throw new \Exception(self::STATUS_NO_MODULE);
        } elseif ( count($_GET) < 3 ) {
          throw new \Exception(self::STATUS_NO_ACTION);
        }

        $site = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true))));
        $application = HTML::sanitize(basename(key(array_slice($_GET, 2, 1,  true))));

        if ( !OSCOM::siteExists($site) ) {
          throw new \Exception(self::STATUS_CLASS_NONEXISTENT);
        }

        OSCOM::setSite($site);

        if ( !OSCOM::siteApplicationExists($application) ) {
          throw new \Exception(self::STATUS_CLASS_NONEXISTENT);
        }

        OSCOM::setSiteApplication($application);

        ob_start( function($buffer) {
          foreach ( headers_list() as $h ) {
            if ( stripos($h, 'Location:') !== false ) {
              header_remove('Location');

              \osCommerce\OM\Core\HttpRequest::setResponseCode(403);

              $buffer = json_encode(array('rpcStatus' => constant('osCommerce\\OM\\Core\\Site\\RPC\\Controller::STATUS_REDIRECT_DETECTED')));

              break;
            }
          }

          return $buffer;
        });

        call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'initialize'));

        ob_end_flush();

        if ( !call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'hasAccess'), $application)) {
          throw new \Exception(self::STATUS_NO_ACCESS);
        }

        $rpc_called = false;

        $rpc = array('RPC');

        for ( $i = 3, $n = count($_GET); $i < $n; $i++ ) {
          $subrpc = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true))));

          if ( self::siteApplicationRPCExists(implode('\\', $rpc) . '\\' . $subrpc) ) {
            call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\' . implode('\\', $rpc) . '\\' . $subrpc, 'execute'));

            $rpc[] = $subrpc;

            $rpc_called = true;
          } else {
            break;
          }
        }

        if ( $rpc_called === false ) {
          throw new \Exception(self::STATUS_NO_ACTION);
        }
      } catch ( \Exception $e ) {
        HttpRequest::setResponseCode(403);

        echo json_encode(array('rpcStatus' => $e->getMessage()));
      }

      exit;
    }
开发者ID:haraldpdl,项目名称:oscommerce,代码行数:83,代码来源:Controller.php


注:本文中的osCommerce\OM\Core\OSCOM::setSite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。