C_Dynamic_Thumbnails_Controller

Class C_Dynamic_Thumbnails_Controller.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/dynamic_thumbnails/package.module.dynamic_thumbnails.php  
  1. class C_Dynamic_Thumbnails_Controller extends C_MVC_Controller 
  2. static $_instances = array(); 
  3. function define($context = FALSE) 
  4. parent::define($context); 
  5. $this->implement('I_Dynamic_Thumbnails_Controller'); 
  6. /** 
  7. * Returns an instance of this class 
  8. * @param string $context 
  9. * @return C_Dynamic_Thumbnails_Controller 
  10. */ 
  11. static function get_instance($context = FALSE) 
  12. if (!isset(self::$_instances[$context])) { 
  13. $klass = get_class(); 
  14. self::$_instances[$context] = new $klass($context); 
  15. return self::$_instances[$context]; 
  16. function index_action() 
  17. $dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance(); 
  18. $uri = $_SERVER['REQUEST_URI']; 
  19. $params = $dynthumbs->get_params_from_uri($uri); 
  20. $request_params = $params; 
  21. if ($params != null) { 
  22. $storage = C_Gallery_Storage::get_instance(); 
  23. // Note, URLs should always include quality setting when returned by Gallery Storage component 
  24. // this sanity check is mostly for manually testing URLs 
  25. if (!isset($params['quality'])) { 
  26. // Note: there's a problem when doing this as using the same set of parameters to *retrieve* the image path/URL will lead to a different filename than the one tha was used to *generate* it (which went through here) 
  27. // The statement above about URLs always containing quality setting is not true anymore, this is because we need to retrieve default quality from the imgQuality and thumbquality settings, depending on "full" or "thumbnail" request in the ngglegacy storage 
  28. //$params['quality'] = 100; 
  29. $image_id = $params['image']; 
  30. $size = $dynthumbs->get_size_name($params); 
  31. $abspath = $storage->get_image_abspath($image_id, $size, true); 
  32. $valid = true; 
  33. // Render invalid image if hash check fails 
  34. if ($abspath == null) { 
  35. $uri_plain = $dynthumbs->get_uri_from_params($request_params); 
  36. $hash = wp_hash($uri_plain); 
  37. if (strpos($uri, $hash) === false) { 
  38. $valid = false; 
  39. $filename = $this->object->find_static_file('invalid_image.png'); 
  40. $this->set_content_type('image/png'); 
  41. readfile($filename); 
  42. $this->render(); 
  43. if ($valid) { 
  44. $storage->render_image($image_id, $size);