• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Shindig_Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Shindig_Config的典型用法代码示例。如果您正苦于以下问题:PHP Shindig_Config类的具体用法?PHP Shindig_Config怎么用?PHP Shindig_Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getCacheDir

 private function getCacheDir($key)
 {
     // use the first 2 characters of the hash as a directory prefix
     // this should prevent slowdowns due to huge directory listings
     // and thus give some basic amount of scalability
     return Shindig_Config::get('cache_root') . '/' . $this->prefix . '/' . substr($key, 0, 2);
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:7,代码来源:CacheStorageFile.php


示例2: doPost

 public function doPost()
 {
     try {
         // we support both a raw http post (without application/x-www-form-urlencoded headers) like java does
         // and a more php / curl safe version of a form post with 'request' as the post field that holds the request json data
         if (isset($GLOBALS['HTTP_RAW_POST_DATA']) || isset($_POST['request'])) {
             $requestParam = urldecode(isset($_POST['request']) ? $_POST['request'] : $GLOBALS['HTTP_RAW_POST_DATA']);
             if (get_magic_quotes_gpc()) {
                 $requestParam = stripslashes($requestParam);
             }
             $request = json_decode($requestParam);
             if ($request == $requestParam) {
                 throw new Exception("Malformed json string");
             }
             $handler = new MetadataHandler();
             $response = $handler->process($request);
             echo json_encode(array('gadgets' => $response));
         } else {
             throw new Exception("No post data set");
         }
     } catch (Exception $e) {
         header("HTTP/1.0 500 Internal Server Error", true, 500);
         echo "<html><body><h1>Internal Server Error</h1><br />";
         if (Shindig_Config::get('debug')) {
             echo $e->getMessage() . "<br /><pre>";
             print_r(debug_backtrace());
             echo "</pre>";
         }
         echo "</body></html>";
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:31,代码来源:MetadataServlet.php


示例3: __construct

 /**
  * Enables output buffering so we can do correct header handling in the destructor
  *
  */
 public function __construct()
 {
     // set our default cache time (config cache time defaults to 24 hours aka 1 day)
     $this->cacheTime = Shindig_Config::get('cache_time');
     // to do our header magic, we need output buffering on
     ob_start();
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:11,代码来源:HttpServlet.php


示例4: getDb

 public function getDb()
 {
     try {
         $fileName = sys_get_temp_dir() . '/' . $this->jsonDbFileName;
         if (file_exists($fileName)) {
             if (!is_readable($fileName)) {
                 throw new SocialSpiException("Could not read temp json db file: {$fileName}, check permissions", ResponseError::$INTERNAL_ERROR);
             }
             $cachedDb = file_get_contents($fileName);
             $jsonDecoded = json_decode($cachedDb, true);
             if ($jsonDecoded == $cachedDb || $jsonDecoded == null) {
                 throw new SocialSpiException("Failed to decode the json db", ResponseError::$INTERNAL_ERROR);
             }
             return $jsonDecoded;
         } else {
             $jsonDb = Shindig_Config::get('jsondb_path');
             if (!file_exists($jsonDb) || !is_readable($jsonDb)) {
                 throw new SocialSpiException("Could not read json db file: {$jsonDb}, check if the file exists & has proper permissions", ResponseError::$INTERNAL_ERROR);
             }
             $dbConfig = @file_get_contents($jsonDb);
             $contents = preg_replace('/(?<!http:|https:)\\/\\/.*$/m', '', preg_replace('@/\\*.*?\\*/@s', '', $dbConfig));
             $jsonDecoded = json_decode($contents, true);
             if ($jsonDecoded == $contents || $jsonDecoded == null) {
                 throw new SocialSpiException("Failed to decode the json db", ResponseError::$INTERNAL_ERROR);
             }
             $this->saveDb($jsonDecoded);
             return $jsonDecoded;
         }
     } catch (Exception $e) {
         throw new SocialSpiException("An error occured while reading/writing the json db: " . $e->getMessage(), ResponseError::$INTERNAL_ERROR);
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:32,代码来源:JsonDbOpensocialService.php


示例5: getJsUrl

 /**
  * generates the library string (core:caja:etc.js) including a checksum of all the
  * javascript content (?v=<md5 of js>) for cache busting
  *
  * @param array $features
  * @param Gadget $gadget
  * @return string the list of libraries in core:caja:etc.js?v=checksum> format
  */
 protected function getJsUrl($features)
 {
     if (!is_array($features) || !count($features)) {
         return 'null';
     }
     $registry = $this->context->getRegistry();
     // Given the JsServlet automatically expends the js library, we just need
     // to include the "leaf" nodes of the features.
     $ret = $features;
     foreach ($features as $feature) {
         $depFeatures = $registry->features[$feature]['deps'];
         $ret = array_diff($ret, $depFeatures);
     }
     $ret = implode(':', $ret);
     $cache = Cache::createCache(Shindig_Config::get('feature_cache'), 'FeatureCache');
     if (($md5 = $cache->get(md5('getJsUrlMD5'))) === false) {
         $features = $registry->features;
         // Build a version string from the md5() checksum of all included javascript
         // to ensure the client always has the right version
         $inlineJs = '';
         foreach ($features as $feature => $content) {
             $inlineJs .= $registry->getFeatureContent($feature, $this->context, true);
         }
         $md5 = md5($inlineJs);
         $cache->set(md5('getJsUrlMD5'), $md5);
     }
     $ret .= ".js?v=" . $md5;
     return $ret;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:37,代码来源:GadgetRenderer.php


示例6: fetch_private_cert

 protected function fetch_private_cert(&$request)
 {
     $file = Shindig_Config::get('private_key_file');
     if (!(file_exists($file) && is_readable($file))) {
         throw new Exception("Error loding private key");
     }
     $private_key = @file_get_contents($file);
     if (!$private_key) {
         throw new Exception("Error loding private key");
     }
     $phrase = Shindig_Config::get('private_key_phrase');
     if (strpos($private_key, '-----BEGIN') === false) {
         $tmp .= "-----BEGIN PRIVATE KEY-----\n";
         $chunks .= str_split($private_key, 64);
         foreach ($chunks as $chunk) {
             $tmp .= $chunk . "\n";
         }
         $tmp .= "-----END PRIVATE KEY-----";
         $private_key = $tmp;
     }
     if (!($rsa_private_key = @openssl_pkey_get_private($private_key, $phrase))) {
         throw new Exception("Could not create the key");
     }
     return $rsa_private_key;
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:25,代码来源:OAuthSignature_Method_RSA_SHA1_opOpenSocialPlugin.class.php


示例7: register

 /**
  * Register our dom node observers that will remove the javascript, but only
  * if this view should be sanitized
  *
  * @param GadgetRewriter $gadgetRewriter
  */
 public function register(GadgetRewriter &$gadgetRewriter)
 {
     $sanitizeViews = Shindig_Config::get('sanitize_views');
     // Only hook up our dom node observers if this view should be sanitized
     if (in_array($this->context->getView(), $sanitizeViews)) {
         $gadgetRewriter->addObserver('script', $this, 'rewriteScript');
     }
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:14,代码来源:SanitizeRewriter.php


示例8: doGet

 /**
  * Handles the get file request, only called on url = /public.crt
  * so this function has no logic other then to output the cert
  */
 public function doGet()
 {
     $file = Shindig_Config::get('public_key_file');
     if (!file_exists($file) || !is_readable($file)) {
         throw new Exception("Invalid public key location ({$file}), check config and file permissions");
     }
     $this->setLastModified(filemtime($file));
     readfile($file);
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:13,代码来源:CertServlet.php


示例9: readable

 public static function readable($file)
 {
     // only really check if check_file_exists == true, big performance hit on production systems, but also much safer :)
     if (Shindig_Config::get('check_file_exists')) {
         return is_readable($file);
     } else {
         return true;
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:9,代码来源:File.php


示例10: fetchRequest

 public function fetchRequest(RemoteContentRequest $request)
 {
     $outHeaders = array();
     if ($request->hasHeaders()) {
         $headers = explode("\n", $request->getHeaders());
         foreach ($headers as $header) {
             if (strpos($header, ':')) {
                 $key = trim(substr($header, 0, strpos($header, ':')));
                 $val = trim(substr($header, strpos($header, ':') + 1));
                 if (strcmp($key, "User-Agent") != 0 && strcasecmp($key, "Transfer-Encoding") != 0 && strcasecmp($key, "Cache-Control") != 0 && strcasecmp($key, "Expries") != 0 && strcasecmp($key, "Content-Length") != 0) {
                     $outHeaders[$key] = $val;
                 }
             }
         }
     }
     $outHeaders['User-Agent'] = "Shindig PHP";
     $options = array();
     $options['timeout'] = Shindig_Config::get('curl_connection_timeout');
     // configure proxy
     $proxyUrl = Shindig_Config::get('proxy');
     if (!empty($proxyUrl)) {
         $options['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
         $proxy = parse_url($proxyUrl);
         if (isset($proxy['host'])) {
             $options['proxy_host'] = $proxy['host'];
         }
         if (isset($proxy['port'])) {
             $options['proxy_port'] = $proxy['port'];
         }
         if (isset($proxy['user'])) {
             $options['proxy_user'] = $proxy['user'];
         }
         if (isset($proxy['pass'])) {
             $options['proxy_pass'] = $proxy['pass'];
         }
     }
     $client = new Zend_Http_Client();
     $client->setConfig($options);
     $client->setUri($request->getUrl());
     $client->setHeaders($outHeaders);
     if ($request->getContentType()) {
         $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, $request->getContentType());
     }
     if ($request->isPost()) {
         $client->setMethod(Zend_Http_Client::POST);
         $client->setRawData($request->getPostBody());
     } else {
         $client->setMethod(Zend_Http_Client::GET);
     }
     $response = $client->request();
     $request->setHttpCode($response->getStatus());
     $request->setContentType($response->getHeader('Content-Type'));
     $request->setResponseHeaders($response->getHeaders());
     $request->setResponseContent($response->getBody());
     $request->setResponseSize(strlen($response->getBody()));
     return $request;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:57,代码来源:opShindigRemoteContentFetcher.class.php


示例11: __construct

 public function __construct($file = false)
 {
     if (!$file) {
         $file = Shindig_Config::get('base_path') . '/blacklist.txt';
     }
     if (Shindig_File::exists($file)) {
         $this->rules = explode("\n", @file_get_contents($file));
     }
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:9,代码来源:BasicGadgetBlacklist.php


示例12: handleListMethods

 public function handleListMethods(RequestItem $request)
 {
     $containerConfig = new ContainerConfig(Shindig_Config::get('container_path'));
     $gadgetConfig = $containerConfig->getConfig('default', 'gadgets.features');
     if (!isset($gadgetConfig['osapi.services']) || count($gadgetConfig['osapi.services']) == 1) {
         // this should really be set in config/container.js, but if not, we build a complete default set so at least most of it works out-of-the-box
         $gadgetConfig['osapi.services'] = array('gadgets.rpc' => array('container.listMethods'), 'http://%host%/social/rpc' => array("messages.update", "albums.update", "activities.delete", "activities.update", "activities.supportedFields", "albums.get", "activities.get", "mediaitems.update", "messages.get", "appdata.get", "system.listMethods", "people.supportedFields", "messages.create", "mediaitems.delete", "mediaitems.create", "people.get", "people.create", "albums.delete", "messages.delete", "appdata.update", "activities.create", "mediaitems.get", "albums.create", "appdata.delete", "people.update", "appdata.create"), 'http://%host%/gadgets/api/rpc' => array('cache.invalidate'));
     }
     return $gadgetConfig['osapi.services'];
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:10,代码来源:SystemHandler.php


示例13: __construct

 public function __construct($context, MakeRequest $makeRequest = null)
 {
     $this->context = $context;
     if (isset($makeRequest)) {
         $this->makeRequest = $makeRequest;
     } else {
         $makeRequestClass = Shindig_Config::get('makerequest_class');
         $this->makeRequest = new $makeRequestClass();
     }
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:10,代码来源:ProxyBase.php


示例14: getProxyUrl

 /**
  * Produces the proxied version of a URL if it falls within the content-rewrite params and
  * will append a refresh param to the proxied url based on the expires param, and the gadget
  * url so that the proxy server knows to rewrite it's content or not
  *
  * @param string $url
  */
 private function getProxyUrl($url)
 {
     if (strpos(strtolower($url), 'http://') === false && strpos(strtolower($url), 'https://') === false) {
         $url = $this->baseUrl . $url;
     }
     $url = Shindig_Config::get('web_prefix') . '/gadgets/proxy?url=' . urlencode($url);
     $url .= '&refresh=' . (isset($this->rewrite['expires']) && is_numeric($this->rewrite['expires']) ? $this->rewrite['expires'] : '3600');
     $url .= '&gadget=' . urlencode($this->context->getUrl());
     return $url;
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:17,代码来源:ContentRewriter.php


示例15: fetchFromWeb

 /**
  * Retrieves a gadget specification from the Internet, processes its views and
  * adds it to the cache.
  */
 private function fetchFromWeb($url, $ignoreCache)
 {
     $remoteContentRequest = new RemoteContentRequest($url);
     $remoteContentRequest->getOptions()->ignoreCache = $ignoreCache;
     $remoteContent = new BasicRemoteContent();
     $spec = $remoteContent->fetch($remoteContentRequest);
     $gadgetSpecParserClass = Shindig_Config::get('gadget_spec_parser');
     $gadgetSpecParser = new $gadgetSpecParserClass();
     $gadgetSpec = $gadgetSpecParser->parse($spec->getResponseContent(), $this->context);
     return $gadgetSpec;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:15,代码来源:BasicGadgetSpecFactory.php


示例16: fetch

 /**
  * Fetches the content and returns it as-is using the headers as returned
  * by the remote host.
  *
  * @param string $url the url to retrieve
  */
 public function fetch($url)
 {
     // TODO: Check to see if we can just use MakeRequestOptions::fromCurrentRequest
     $st = isset($_GET['st']) ? $_GET['st'] : (isset($_POST['st']) ? $_POST['st'] : false);
     $body = isset($_GET['postData']) ? $_GET['postData'] : (isset($_POST['postData']) ? $_POST['postData'] : false);
     $authz = isset($_GET['authz']) ? $_GET['authz'] : (isset($_POST['authz']) ? $_POST['authz'] : null);
     $headers = isset($_GET['headers']) ? $_GET['headers'] : (isset($_POST['headers']) ? $_POST['headers'] : null);
     $params = new MakeRequestOptions($url);
     $params->setSecurityTokenString($st)->setAuthz($authz)->setRequestBody($body)->setHttpMethod('GET')->setFormEncodedRequestHeaders($headers)->setNoCache($this->context->getIgnoreCache());
     $result = $this->makeRequest->fetch($this->context, $params);
     $httpCode = (int) $result->getHttpCode();
     $cleanedResponseHeaders = $this->makeRequest->cleanResponseHeaders($result->getResponseHeaders());
     $isShockwaveFlash = false;
     foreach ($cleanedResponseHeaders as $key => $val) {
         header("{$key}: {$val}", true);
         if (strtoupper($key) == 'CONTENT-TYPE' && strtolower($val) == 'application/x-shockwave-flash') {
             // We're skipping the content disposition header for flash due to an issue with Flash player 10
             // This does make some sites a higher value phishing target, but this can be mitigated by
             // additional referer checks.
             $isShockwaveFlash = true;
         }
     }
     if (!$isShockwaveFlash && !Shindig_Config::get('debug')) {
         header('Content-Disposition: attachment;filename=p.txt');
     }
     $lastModified = $result->getResponseHeader('Last-Modified') != null ? $result->getResponseHeader('Last-Modified') : gmdate('D, d M Y H:i:s', $result->getCreated()) . ' GMT';
     $notModified = false;
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified && !isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $if_modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
         // Use the request's Last-Modified, otherwise fall back on our internal time keeping (the time the request was created)
         $lastModified = strtotime($lastModified);
         if ($lastModified <= $if_modified_since) {
             $notModified = true;
         }
     }
     if ($httpCode == 200) {
         // only set caching headers if the result was 'OK'
         $this->setCachingHeaders($lastModified);
         // was the &gadget=<gadget url> specified in the request? if so parse it and check the rewrite settings
         if (isset($_GET['gadget'])) {
             $this->rewriteContent($_GET['gadget'], $result);
         }
     }
     // If the cached file time is within the refreshInterval params value, return not-modified
     if ($notModified) {
         header('HTTP/1.0 304 Not Modified', true);
         header('Content-Length: 0', true);
     } else {
         header("HTTP/1.1 {$httpCode} " . $result->getHttpCodeMsg());
         // then echo the content
         echo $result->getResponseContent();
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:59,代码来源:ProxyHandler.php


示例17: getPrefsQueryString

 /**
  * Returns the user preferences in &up_<name>=<val> format
  *
  * @param array $libs array of features this gadget requires
  * @param Gadget $gadget
  * @return string the up_<name>=<val> string to use in the redirection url
  */
 private function getPrefsQueryString($prefs)
 {
     $ret = '';
     foreach ($prefs as $pref) {
         $ret .= '&';
         $ret .= Shindig_Config::get('userpref_param_prefix');
         $ret .= urlencode($pref['name']);
         $ret .= '=';
         $ret .= urlencode($pref['value']);
     }
     return $ret;
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:19,代码来源:GadgetUrlRenderer.php


示例18: getIframeURL

 private function getIframeURL(Shindig_Gadget $gadget, GadgetContext $context)
 {
     $v = $gadget->getChecksum();
     $view = $gadget->getView($context->getView());
     $up = '';
     foreach ($gadget->gadgetSpec->userPrefs as $pref) {
         $up .= '&up_' . urlencode($pref['name']) . '=' . urlencode($pref['value']);
     }
     $locale = $context->getLocale();
     //Note: putting the URL last, else some browsers seem to get confused (reported by hi5)
     return Shindig_Config::get('default_iframe_prefix') . 'container=' . $context->getContainer() . ($context->getIgnoreCache() ? '&nocache=1' : '&v=' . $v) . ($context->getModuleId() != 0 ? '&mid=' . $context->getModuleId() : '') . '&lang=' . $locale['lang'] . '&country=' . $locale['country'] . '&view=' . $view['view'] . $up . '&url=' . urlencode($context->getUrl());
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:12,代码来源:MetadataHandler.php


示例19: __construct

 public function __construct()
 {
     try {
         $service = trim(Shindig_Config::get('invalidate_service'));
         if (!empty($service)) {
             $cache = Cache::createCache(Shindig_Config::get('data_cache'), 'RemoteContent');
             $this->service = new $service($cache);
         }
     } catch (ConfigException $e) {
         // Do nothing. If invalidate service is not specified in the config file.
         // All the requests to the handler will throw not implemented exception.
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:13,代码来源:InvalidateHandler.php


示例20: OAuthFetcherFactoryInit

 /**
  * Initialize the OAuth factory with a default implementation of
  * BlobCrypter and consumer keys/secrets read from oauth.js
  */
 public function OAuthFetcherFactoryInit($fetcher)
 {
     try {
         $BBC = new BasicBlobCrypter();
         $this->oauthCrypter = new BasicBlobCrypter(srand($BBC->MASTER_KEY_MIN_LEN));
         $specFactory = new BasicGadgetSpecFactory();
         $OAuthStore = Shindig_Config::get('oauth_store');
         $basicStore = new BasicGadgetOAuthTokenStore(new $OAuthStore(), $specFactory);
         $basicStore->initFromConfigFile($fetcher);
         $this->tokenStore = $basicStore;
     } catch (Exeption $e) {
     }
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:17,代码来源:OAuthFetcherFactory.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Shineisp_Commons_Utilities类代码示例发布时间:2022-05-23
下一篇:
PHP ShellDispatcher类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap