This file is indexed.

/usr/share/horde/ansel/lib/ImageGenerator.php is in php-horde-ansel 3.0.5+debian0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/**
 * Base class for the creation of various image views.
 *
 * New thumbnail generators can be dropped in and will be made available by
 * Ansel providing:
 *
 *   1. The class name is as: Ansel_ImageGenerator_{type}Thumb and filename
 *      matches, i.e. {type}Thumb.php where {type} is the unique name for your
 *      thumbnail type.
 *
 *   2. Implements a _create() method that applies the effects to the image
 *      (see existing generators for how this works).
 *
 *   3. If a matching "stack" generator is desired, that should be named
 *      similarly: Ansel_ImageGenerator_{type}ThumbStack with matching filename:
 *      {type}ThumbStack.php
 *
 *
 * Copyright 2007-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 * @package Ansel
 */
class Ansel_ImageGenerator
{
    /**
     * Ansel_Image object that this view is created from.
     *
     * @var Ansel_Image
     */
    protected $_image = null;

    /**
     * Parameters for this view
     *
     * @var array
     */
    protected $_params = array();

    /**
     * Image dimensions
     *
     * @var array
     */
    protected $_dimensions = array();

    /**
     * Cache the style
     *
     * @var Ansel_Style
     */
    protected $_style;

    /**
     * Array of required, supported features for this ImageGenerator to work
     *
     * @var array
     */
    public  $need = array();

    /**
     * Human readable title for this thumbnail style.
     *
     * @var string
     */
    public $title;

    /**
     * Const'r
     *
     * @return Horde_ImageGenerator
     */
    public function __construct($params)
    {
        $this->_params = $params;
        if (!empty($params['image'])) {
            $this->_image = $params['image'];
        }
        $this->_style = $params['style'];
    }

    /**
     * Create and cache the view.
     *
     * @return mixed  Views used as gallery key images return Horde_Image,
     *                other views return boolean
     */
    public function create()
    {
        if (!empty($this->_image)) {
            // Make sure to load the image.
            $this->_image->load('full');
            $img = $this->_image->getHordeImage();
            $this->_dimensions = $img->getDimensions();
        }

        return $this->_create();
    }

    /**
     * Horde_ImageGenerator factory
     *
     * @param string $type   The type of concrete instance to return.
     * @param array $params  Additional parameters needed for the instance.
     *
     * @return Ansel_ImageGenerator
     * @throws Ansel_Exception
     */
    static public function factory($type, $params = array())
    {
        $type = basename($type);
        $class = 'Ansel_ImageGenerator_' . $type;
        if (class_exists($class)) {
            $view = new $class($params);
            // Check that the image object supports what we need for the effect.
            foreach ($view->need as $need) {
                if (!Ansel::isAvailable($need)) {
                    $err = sprintf(_("This install does not support the %s feature. Please contact your administrator."), $need);
                    Horde::log($err, 'ERR');
                    throw new Ansel_Exception($err);
                }
            }
            return $view;
        } else {
            $err = sprintf(_("Unable to load the definition of %s."), $class);
            Horde::log($err, 'ERR');
            throw new Ansel_Exception($err);
        }
    }

   /**
    * Utility function to return an array of Horde_Images to use in building a
    * stack. Returns a random set of 5 images from the gallery, or the
    * explicitly set key image plus 4 others.
    *
    * @return array An array of Horde_Image objects.
    */
    protected function _getStackImages()
    {
        $images = array();
        $gallery = $this->_params['gallery'];

        // Make sure we have images. We can't go deeper into subgalleries
        // since some of them may not have HORDE_PERMS::READ and the
        // keyimage-thumbnails are generated by the first user who views
        // them, using their perms.
        if (!$gallery->countImages() && $gallery->hasSubGalleries()) {
            return array();
        }

        $cnt = min(5, $gallery->countImages());
        $default = $gallery->get('default');
        if (!empty($default) && $default > 0) {
            try {
                $img = $gallery->getImage($default);
                $img->load('screen');
                $images[] = $img->getHordeImage();
                $cnt--;
            } catch (Ansel_Exception $e) {
                Horde::log($e, 'ERR');
            }
        }

        for ($i = 0; $i < $cnt; $i++) {
            $rnd = mt_rand(0, $cnt);
            try {
                $temp = $gallery->getImages($rnd, 1);
                if (count($temp)) {
                    $aimg = array_shift($temp);
                    $aimg->load('screen');
                    $images[] = $aimg->getHordeImage();
                }
            } catch (Ansel_Exception $e) {
                Horde::log($e, 'ERR');
            }
        }

        // Reverse the array to ensure the requested key image
        // is the last in the array (so it will appear on the top of
        // the stack.
        return array_reverse($images);
    }

}