public function fetch($key)
 {
     $cacheFile = $this->getCacheFile($key);
     if (Shindig_File::exists($cacheFile) && Shindig_File::readable($cacheFile)) {
         return @file_get_contents($cacheFile);
     }
     return false;
 }
 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));
     }
 }
예제 #3
0
 private function loadContainers($containers)
 {
     if (!Shindig_File::exists($containers)) {
         throw new Exception("Invalid container path");
     }
     foreach (glob("{$containers}/*.js") as $file) {
         if (!Shindig_File::readable($file)) {
             throw new Exception("Could not read container config: {$file}");
         }
         if (is_dir($file)) {
             // support recursive loading of sub directories
             $this->loadContainers($file);
         } else {
             $this->loadFromFile($file);
         }
     }
 }
 /**
  * @param keyFile The file containing your private key for signing requests.
  */
 public function __construct($keyFile = null)
 {
     $this->keyName = 'http://' . $_SERVER["HTTP_HOST"] . Shindig_Config::get('web_prefix') . '/public.cer';
     if (!empty($keyFile)) {
         $rsa_private_key = false;
         $privateKey = null;
         try {
             if (Shindig_File::exists($keyFile)) {
                 if (Shindig_File::readable($keyFile)) {
                     $rsa_private_key = @file_get_contents($keyFile);
                 } else {
                     throw new Exception("Could not read keyfile ({$keyFile}), check the file name and permission");
                 }
             }
             if (!$rsa_private_key) {
                 $rsa_private_key = '';
             } else {
                 $phrase = Shindig_Config::get('private_key_phrase') != '' ? Shindig_Config::get('private_key_phrase') : null;
                 if (strpos($rsa_private_key, "-----BEGIN") === false) {
                     $privateKey .= "-----BEGIN PRIVATE KEY-----\n";
                     $chunks = str_split($rsa_private_key, 64);
                     foreach ($chunks as $chunk) {
                         $privateKey .= $chunk . "\n";
                     }
                     $privateKey .= "-----END PRIVATE KEY-----";
                 } else {
                     $privateKey = $rsa_private_key;
                 }
                 if (!($rsa_private_key = @openssl_pkey_get_private($privateKey, $phrase))) {
                     throw new Exception("Could not create the key");
                 }
             }
         } catch (Exception $e) {
             throw new Exception("Error loading private key: " . $e);
         }
         $this->privateKey = $rsa_private_key;
     }
 }
 /**
  * Loads the feature's xml content
  *
  * @param unknown_type $file
  * @return unknown
  */
 private function processFile($file)
 {
     $feature = null;
     if (!empty($file) && Shindig_File::exists($file)) {
         if ($content = file_get_contents($file)) {
             $feature = $this->parse($content, dirname($file));
         }
     }
     return $feature;
 }
예제 #6
0
 private function loadOsmlLibrary()
 {
     $container = $this->gadgetContext->getContainer();
     $containerConfig = $this->gadgetContext->getContainerConfig();
     $gadgetsFeatures = $containerConfig->getConfig($container, 'gadgets.features');
     if (!isset($gadgetsFeatures['osml'])) {
         throw new ExpressionException("Missing OSML configuration key in config/config.js");
     } elseif (!isset($gadgetsFeatures['osml']['library'])) {
         throw new ExpressionException("Missing OSML.Library configuration key in config/config.js");
     }
     $osmlLibrary = Shindig_Config::get('container_path') . str_replace('config/', '', $gadgetsFeatures['osml']['library']);
     if (!Shindig_File::exists($osmlLibrary)) {
         throw new ExpressionException("Missing OSML Library ({$osmlLibrary})");
     }
     $this->addTemplateLibrary(file_get_contents($osmlLibrary));
     $this->osmlLoaded = true;
 }