本文整理汇总了PHP中Shindig_Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Shindig_Config::get方法的具体用法?PHP Shindig_Config::get怎么用?PHP Shindig_Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shindig_Config
的用法示例。
在下文中一共展示了Shindig_Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: __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();
}
示例3: 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
示例4: 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;
}
示例5: 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>";
}
}
示例6: 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);
}
}
示例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');
}
}
示例8: 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;
}
}
示例9: 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;
}
示例10: __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));
}
}
示例11: 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);
}
示例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'];
}
示例13: 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;
}
示例14: __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();
}
}
示例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;
}