C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RWF6OMG\mambots\content\mosimage.php


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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
/**
* @version $Id: mosimage.php 2424 2006-02-16 23:52:16Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined'_VALID_MOS' ) or die( 'Restricted access' );

$_MAMBOTS->registerFunction'onPrepareContent''botMosImage' );

/**
*/
function botMosImage$published, &$row, &$params$page=) {
    global 
$database$_MAMBOTS;
    
    
// simple performance check to determine whether bot should process further
    
if ( strpos$row->text'mosimage' ) === false ) {
        return 
true;
    }
    
     
// expression to search for
    
$regex '/{mosimage\s*.*?}/i';    

    
// check whether mosimage has been disabled for page
    // check whether mambot has been unpublished
    
if (!$published || !$params->get'image' )) {
        
$row->text preg_replace$regex''$row->text );
        return 
true;
    }
    
    
//count how many {mosimage} are in introtext if it is set to hidden.
    
$introCount=0;
    if ( ! 
$params->get'introtext' ) & ! $params->get'intro_only') ) 
    {
        
preg_match_all$regex$row->introtext$matches );
        
$introCount count $matches[0] );
    }

    
// find all instances of mambot and put in $matches
    
preg_match_all$regex$row->text$matches );

     
// Number of mambots
    
$count count$matches[0] );

     
// mambot only processes if there are any instances of the mambot in the text
     
if ( $count ) {
        
// check if param query has previously been processed
        
if ( !isset($_MAMBOTS->_content_mambot_params['mosimage']) ) {
            
// load mambot params info
            
$query "SELECT params"
            
"\n FROM #__mambots"
            
"\n WHERE element = 'mosimage'"
            
"\n AND folder = 'content'"
            
;
            
$database->setQuery$query );
            
$database->loadObject($mambot);
            
            
// save query to class variable
            
$_MAMBOTS->_content_mambot_params['mosimage'] = $mambot;
        }

        
// pull query data from class variable
        
$mambot $_MAMBOTS->_content_mambot_params['mosimage'];
        
         
$botParams = new mosParameters$mambot->params );

         
$botParams->def'padding' );
         
$botParams->def'margin' );
         
$botParams->def'link');

        
$images     processImages$row$botParams$introCount );

        
// store some vars in globals to access from the replacer
        
$GLOBALS['botMosImageCount']     = 0;
        
$GLOBALS['botMosImageParams']     =& $botParams;
        
$GLOBALS['botMosImageArray']     =& $images;
        
//$GLOBALS['botMosImageArray']     =& $combine;
        
        // perform the replacement
        
$row->text preg_replace_callback$regex'botMosImage_replacer'$row->text );

        
// clean up globals
        
unset( $GLOBALS['botMosImageCount'] );
        unset( 
$GLOBALS['botMosImageMask'] );
        unset( 
$GLOBALS['botMosImageArray'] );
        unset( 
$GLOBALS['botJosIntroCount'] );
        return 
true;
    }
}

function 
processImages ( &$row, &$params, &$introCount ) {
    global 
$mosConfig_absolute_path$mosConfig_live_site;

    
$images         = array();

    
// split on \n the images fields into an array
    
$row->images     explode"\n"$row->images );
    
$total             count$row->images );

    
$start $introCount
    for ( 
$i $start$i $total$i++ ) {
        
$img trim$row->images[$i] );

        
// split on pipe the attributes of the image
        
if ( $img ) {
            
$attrib explode'|'trim$img ) );
            
// $attrib[0] image name and path from /images/stories

            // $attrib[1] alignment
            
if ( !isset($attrib[1]) || !$attrib[1] ) {
                
$attrib[1] = '';
            }

            
// $attrib[2] alt & title
            
if ( !isset($attrib[2]) || !$attrib[2] ) {
                
$attrib[2] = 'Image';
            } else {
                
$attrib[2] = htmlspecialchars$attrib[2] );
            }

            
// $attrib[3] border
            
if ( !isset($attrib[3]) || !$attrib[3] ) {
                
$attrib[3] = 0;
            }

            
// $attrib[4] caption
            
if ( !isset($attrib[4]) || !$attrib[4] ) {
                
$attrib[4]    = '';
                
$border     $attrib[3];
            } else {
                
$border     0;
            }

            
// $attrib[5] caption position
            
if ( !isset($attrib[5]) || !$attrib[5] ) {
                
$attrib[5] = '';
            }

            
// $attrib[6] caption alignment
            
if ( !isset($attrib[6]) || !$attrib[6] ) {
                
$attrib[6] = '';
            }

            
// $attrib[7] width
            
if ( !isset($attrib[7]) || !$attrib[7] ) {
                
$attrib[7]     = '';
                
$width         '';
            } else {
                
$width         ' width: '$attrib[7] .'px;';
            }

            
// image size attibutes
            
$size '';
            if ( 
function_exists'getimagesize' ) ) {
                
$size     = @getimagesize$mosConfig_absolute_path .'/images/stories/'$attrib[0] );
                if (
is_array$size )) {
                    
$size ' width="'$size[0] .'" height="'$size[1] .'"';
                }
            }

            
// assemble the <image> tag
            
$image '<img src="'$mosConfig_live_site .'/images/stories/'$attrib[0] .'"'$size;
            
// no aligment variable - if caption detected
            
if ( !$attrib[4] ) {
                
$image .= $attrib[1] ? ' align="'$attrib[1] .'"' '';
            }
            
$image .=' hspace="6" alt="'$attrib[2] .'" title="'$attrib[2] .'" border="'$border .'" />';

            
// assemble caption - if caption detected
            
$caption '';
            if ( 
$attrib[4] ) {                
                
$caption '<div class="mosimage_caption"';
                if ( 
$attrib[6] ) {
                    
$caption .= ' style="text-align: '$attrib[6] .';"';
                }                
                if ( 
$attrib[6] ) {
                    
$caption .= ' align="'$attrib[6] .'">';
                }
                
$caption .= $attrib[4];
                
$caption .= '</div>';
            }
            
            
// final output
            
if ( $attrib[4] ) {
                
// initialize variables
                
$margin          '';
                
$padding         '';
                
$float            '';
                
$border_width     '';
                if ( 
$params->def'margin' ) ) {
                    
$margin         ' margin: '$params->def'margin' ).'px;';
                }                
                if ( 
$params->def'padding' ) ) {
                    
$padding         ' padding: '$params->def'padding' ).'px;';
                }                
                if ( 
$attrib[1] ) {
                    
$float             ' float: '$attrib[1] .';';
                }
                if ( 
$attrib[3] ) {
                    
$border_width    ' border-width: '$attrib[3] .'px;';
                }
                
                if ( 
$params->def'margin' ) || $params->def'padding' ) || $attrib[1] || $attrib[3] ) {
                    
$style ' style="'$border_width $float $margin $padding $width .'"';
                }
                
                
$img '<div class="mosimage" '$style .' align="center">'

                
// display caption in top position
                
if ( $attrib[5] == 'top' && $caption ) {
                    
$img .= $caption;
                }

                
$img .= $image;

                
// display caption in bottom position
                
if ( $attrib[5] == 'bottom' && $caption ) {
                    
$img .= $caption;
                }
                
$img .='</div>';
            } else {
                
$img $image;
            }

            
$images[] = $img;
        }
    }

    return 
$images;
}

/**
* Replaces the matched tags an image
* @param array An array of matches (see preg_match_all)
* @return string
*/
function botMosImage_replacer( &$matches ) {
    
$i $GLOBALS['botMosImageCount']++;

    return @
$GLOBALS['botMosImageArray'][$i];
}
?>