Example #1
0
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/false'));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method');
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true'));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and no tokens');
     $tokens = Controller::generateSecurityFields();
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true/' . urlencode($tokens[0]) . '/' . urlencode($tokens[1])));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and valid tokens');
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public static function renderSecurityFields()
 {
     if (self::$logger == null) {
         self::$logger = new Logger('RendererProviderHTML');
     }
     self::$logger->debug('>>renderSecurityFields()');
     $config = ConfigProvider::getInstance();
     $html = '';
     $fields = Controller::generateSecurityFields();
     if ($config->get('security.encrypt.http.fieldnames')) {
         $fieldname = base64_encode(SecurityUtils::encrypt('var1'));
     } else {
         $fieldname = 'var1';
     }
     $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $fields[0] . '"/>';
     if ($config->get('security.encrypt.http.fieldnames')) {
         $fieldname = base64_encode(SecurityUtils::encrypt('var2'));
     } else {
         $fieldname = 'var2';
     }
     $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $fields[1] . '"/>';
     self::$logger->debug('<<renderSecurityFields [' . $html . ']');
     return $html;
 }
Example #3
0
 /**
  * Renders the HTML <img> tag to the ViewImage controller, with all of the correct params to render the source
  * image in the desired resolution.
  *
  * @param $altText Set this value to render alternate text as part of the HTML link (defaults to no alternate text)
  *
  * @return string
  *
  * @since 1.0
  */
 public function renderHTMLLink($altText = '')
 {
     $config = ConfigProvider::getInstance();
     if ($this->secure->getBooleanValue()) {
         $params = Controller::generateSecurityFields();
         return '<img src="' . FrontController::generateSecureURL('act=Alpha\\Controller\\ImageController&source=' . $this->source . '&width=' . $this->width->getValue() . '&height=' . $this->height->getValue() . '&type=' . $this->sourceType->getValue() . '&quality=' . $this->quality->getValue() . '&scale=' . $this->scale->getValue() . '&secure=' . $this->secure->getValue() . '&var1=' . $params[0] . '&var2=' . $params[1]) . '"' . (empty($altText) ? '' : ' alt="' . $altText . '"') . ($config->get('cms.images.widget.bootstrap.responsive') ? ' class="img-responsive"' : '') . '/>';
     } else {
         return '<img src="' . FrontController::generateSecureURL('act=Alpha\\Controller\\ImageController&source=' . $this->source . '&width=' . $this->width->getValue() . '&height=' . $this->height->getValue() . '&type=' . $this->sourceType->getValue() . '&quality=' . $this->quality->getValue() . '&scale=' . $this->scale->getValue() . '&secure=' . $this->secure->getValue()) . '"' . (empty($altText) ? '' : ' alt="' . $altText . '"') . ($config->get('cms.images.widget.bootstrap.responsive') ? ' class="img-responsive"' : '') . '/>';
     }
 }