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. public 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. public 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. $image_id = $params['image']; 
  27. $size = $dynthumbs->get_size_name($params); 
  28. $abspath = $storage->get_image_abspath($image_id, $size, true); 
  29. $valid = true; 
  30. // Render invalid image if hash check fails 
  31. if ($abspath == null) { 
  32. $uri_plain = $dynthumbs->get_uri_from_params($request_params); 
  33. $hash = wp_hash($uri_plain); 
  34. if (strpos($uri, $hash) === false) { 
  35. $valid = false; 
  36. $filename = $this->object->find_static_file('invalid_image.png'); 
  37. $this->set_content_type('image/png'); 
  38. readfile($filename); 
  39. $this->render(); 
  40. if ($valid) { 
  41. $storage->render_image($image_id, $size);