C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RU7MSUA\html\imagemanager.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
// $Id: imagemanager.php,v 1.12.6.4 2005/06/04 01:58:07 phppp Exp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

include './mainfile.php';
if (!isset(
$_REQUEST['target'])) {
    exit();
}
$target $_REQUEST['target'];
$op 'list';
if (isset(
$_GET['op']) && $_GET['op'] == 'upload') {
    
$op 'upload';
} elseif (isset(
$_POST['op']) && $_POST['op'] == 'doupload') {
    
$op 'doupload';
}

$wysiwyg = empty($_REQUEST['wysiwyg'])?0:1;
//echo "<br />wysiwyg:".$wysiwyg;
if (!is_object($xoopsUser)) {
    
$group = array(XOOPS_GROUP_ANONYMOUS);
} else {
    
$group =& $xoopsUser->getGroups();
}
if (
$op == 'list') {
    
$xoopsTpl->assign('lang_imgmanager'_IMGMANAGER);
    
$target htmlspecialchars($_GET['target'], ENT_QUOTES);
    
$xoopsTpl->assign('target'$target);
    
$imgcat_handler =& xoops_gethandler('imagecategory');
    
$catlist =& $imgcat_handler->getList($group'imgcat_read'1);
    
$catcount count($catlist);
    
$xoopsTpl->assign('lang_align'_ALIGN);
    
$xoopsTpl->assign('lang_add'_ADD);
    
$xoopsTpl->assign('lang_close'_CLOSE);
    if (
$catcount 0) {
        
$xoopsTpl->assign('lang_go'_GO);
        
$catshow = !isset($_GET['cat_id']) ? intval($_GET['cat_id']);
        
$catshow = (!empty($catshow) && in_array($catshowarray_keys($catlist))) ? $catshow 0;
        
$xoopsTpl->assign('show_cat'$catshow);
        if (
$catshow 0) {
            
$xoopsTpl->assign('lang_addimage'_ADDIMAGE);
        }
        
$catlist = array('0' => '--') + $catlist;
        
$cat_options '';
        foreach (
$catlist as $c_id => $c_name) {
            
$sel '';
            if (
$c_id == $catshow) {
                
$sel ' selected="selected"';
            }
            
$cat_options .= '<option value="'.$c_id.'"'.$sel.'>'.$c_name.'</option>';
        }
        
$xoopsTpl->assign('cat_options'$cat_options);
        if (
$catshow 0) {
            
$image_handler xoops_gethandler('image');
            
$criteria = new CriteriaCompo(new Criteria('imgcat_id'$catshow));
            
$criteria->add(new Criteria('image_display'1));
            
$total $image_handler->getCount($criteria);
            if (
$total 0) {
                
$imgcat_handler =& xoops_gethandler('imagecategory');
                
$imgcat =& $imgcat_handler->get($catshow);
                
$xoopsTpl->assign('image_total'$total);
                
$xoopsTpl->assign('lang_image'_IMAGE);
                
$xoopsTpl->assign('lang_imagename'_IMAGENAME);
                
$xoopsTpl->assign('lang_imagemime'_IMAGEMIME);
                
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
                
$criteria->setLimit(10);
                
$criteria->setStart($start);
                
$storetype $imgcat->getVar('imgcat_storetype');
                if (
$storetype == 'db') {
                    
$images =& $image_handler->getObjects($criteriafalsetrue);
                } else {
                    
$images =& $image_handler->getObjects($criteriafalsefalse);
                }
                
$imgcount count($images);
                
$max = ($imgcount 10) ? 10 $imgcount;

                for (
$i 0$i $max$i++) {
                    if (
$storetype == 'db') {
                        if(!empty(
$wysiwyg)){
                            
$lcode "\\\"".XOOPS_URL.'/image.php?id='.$images[$i]->getVar('image_id')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"left\\\"";
                            
$code "\\\"".XOOPS_URL.'/image.php?id='.$images[$i]->getVar('image_id')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"center\\\"";
                            
$rcode "\\\"".XOOPS_URL.'/image.php?id='.$images[$i]->getVar('image_id')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"right\\\"";
                        }else{
                            
$lcode '[img align=left id='.$images[$i]->getVar('image_id').']'.$images[$i]->getVar('image_nicename').'[/img]';
                            
$code '[img id='.$images[$i]->getVar('image_id').']'.$images[$i]->getVar('image_nicename').'[/img]';
                            
$rcode '[img align=right id='.$images[$i]->getVar('image_id').']'.$images[$i]->getVar('image_nicename').'[/img]';
                        }
                        
$src XOOPS_URL."/image.php?id=".$images[$i]->getVar('image_id');
                    } else {
                        if(!empty(
$wysiwyg)){
                            
$lcode "\\\"".XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"left\\\"";
                            
$code "\\\"".XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"center\\\"";
                            
$rcode "\\\"".XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name')."\\\", \\\"".$images[$i]->getVar('image_nicename')."\\\",\\\"right\\\"";
                        }else{
                            
$lcode '[img align=left]'.XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name').'[/img]';
                            
$code '[img]'.XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name').'[/img]';
                            
$rcode '[img align=right]'.XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name').'[/img]';
                        }
                        
$src XOOPS_UPLOAD_URL.'/'.$images[$i]->getVar('image_name');
                    }
                    
$xoopsTpl->append('images', array('id' => $images[$i]->getVar('image_id'), 'nicename' => $images[$i]->getVar('image_nicename'), 'mimetype' => $images[$i]->getVar('image_mimetype'), 'src' => $src'lxcode' => $lcode'xcode' => $code'rxcode' => $rcode));
                }
                if (
$total 10) {
                    include_once 
XOOPS_ROOT_PATH.'/class/pagenav.php';
                    
$nav = new XoopsPageNav($total10$start'start''target='.$target.'&amp;cat_id='.$catshow);
                    
$xoopsTpl->assign('pagenav'$nav->renderNav());
                }
            } else {
                
$xoopsTpl->assign('image_total'0);
            }
        }
        
$xoopsTpl->assign('xsize'600);
        
$xoopsTpl->assign('ysize'400);
    } else {
        
$xoopsTpl->assign('xsize'400);
        
$xoopsTpl->assign('ysize'180);
    }
    
$xoopsTpl->assign('wysiwyg'$wysiwyg);

    
$xoopsTpl->display('db:system_imagemanager.html');
    exit();
}

if (
$op == 'upload') {
    
$imgcat_handler =& xoops_gethandler('imagecategory');
    
$imgcat_id intval($_GET['imgcat_id']);
    
$imgcat =& $imgcat_handler->get($imgcat_id);
    
$error false;
    if (!
is_object($imgcat)) {
        
$error true;
    } else {
        
$imgcatperm_handler =& xoops_gethandler('groupperm');
        if (
is_object($xoopsUser)) {
            if (!
$imgcatperm_handler->checkRight('imgcat_write'$imgcat_id$xoopsUser->getGroups())) {
                
$error true;
            }
        } else {
            if (!
$imgcatperm_handler->checkRight('imgcat_write'$imgcat_idXOOPS_GROUP_ANONYMOUS)) {
                
$error true;
            }
        }
    }
    if (
$error != false) {
        
xoops_header(false);
        echo 
'</head><body><div style="text-align:center;"><input value="'._BACK.'" type="button" onclick="javascript:history.go(-1);" /></div>';
        
xoops_footer();
        exit();
    }
    
$xoopsTpl->assign('show_cat'$imgcat_id);
    
$xoopsTpl->assign('lang_imgmanager'_IMGMANAGER);
    
$xoopsTpl->assign('target'htmlspecialchars($_GET['target'], ENT_QUOTES));
    include_once 
XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
    
$form = new XoopsThemeForm('''image_form''imagemanager.php''post'true);
    
$form->setExtra('enctype="multipart/form-data"');
    
$form->addElement(new XoopsFormText(_IMAGENAME'image_nicename'20255), true);
    
$form->addElement(new XoopsFormLabel(_IMAGECAT$imgcat->getVar('imgcat_name')));
    
$form->addElement(new XoopsFormFile(_IMAGEFILE'image_file'$imgcat->getVar('imgcat_maxsize')), true);
    
$form->addElement(new XoopsFormLabel(_IMGMAXSIZE$imgcat->getVar('imgcat_maxsize')));
    
$form->addElement(new XoopsFormLabel(_IMGMAXWIDTH$imgcat->getVar('imgcat_maxwidth')));
    
$form->addElement(new XoopsFormLabel(_IMGMAXHEIGHT$imgcat->getVar('imgcat_maxheight')));
    
$form->addElement(new XoopsFormHidden('imgcat_id'$imgcat_id));
    
$form->addElement(new XoopsFormHidden('op''doupload'));
    
$form->addElement(new XoopsFormHidden('target'$target));
    
$form->addElement(new XoopsFormButton('''img_button'_SUBMIT'submit'));
    
$form->assign($xoopsTpl);
    
$xoopsTpl->assign('lang_close'_CLOSE);
    
$xoopsTpl->display('db:system_imagemanager2.html');
    exit();
}

if (
$op == 'doupload') {
    if (
$GLOBALS['xoopsSecurity']->check()) {
        
$image_nicename = isset($_POST['image_nicename']) ? $_POST['image_nicename'] : '';
        
$xoops_upload_file = isset($_POST['xoops_upload_file']) ? $_POST['xoops_upload_file'] : array();
        
$imgcat_id = isset($_POST['imgcat_id']) ? intval($_POST['imgcat_id']) : 0;
        include_once 
XOOPS_ROOT_PATH.'/class/uploader.php';
        
$imgcat_handler =& xoops_gethandler('imagecategory');
        
$imgcat =& $imgcat_handler->get($imgcat_id);
        
$error false;
        if (!
is_object($imgcat)) {
            
$error true;
        } else {
            
$imgcatperm_handler =& xoops_gethandler('groupperm');
            if (
is_object($xoopsUser)) {
                if (!
$imgcatperm_handler->checkRight('imgcat_write'$imgcat_id$xoopsUser->getGroups())) {
                    
$error true;
                }
            } else {
                if (!
$imgcatperm_handler->checkRight('imgcat_write'$imgcat_idXOOPS_GROUP_ANONYMOUS)) {
                    
$error true;
                }
            }
        }
    }
    else {
        
$error true;
    }
    if (
$error != false) {
        
xoops_header(false);
        echo 
'</head><body><div style="text-align:center;">'.implode('<br />'$GLOBALS['xoopsSecurity']->getErrors()).'<br /><input value="'._BACK.'" type="button" onclick="javascript:history.go(-1);" /></div>';
        
xoops_footer();
        exit();
    }
    
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif''image/jpeg''image/pjpeg''image/x-png''image/png'), $imgcat->getVar('imgcat_maxsize'), $imgcat->getVar('imgcat_maxwidth'), $imgcat->getVar('imgcat_maxheight'));
    
$uploader->setPrefix('img');
    if (
$uploader->fetchMedia($xoops_upload_file[0])) {
        if (!
$uploader->upload()) {
            
$err $uploader->getErrors();
        } else {
            
$image_handler =& xoops_gethandler('image');
            
$image =& $image_handler->create();
            
$image->setVar('image_name'$uploader->getSavedFileName());
            
$image->setVar('image_nicename'$image_nicename);
            
$image->setVar('image_mimetype'$uploader->getMediaType());
            
$image->setVar('image_created'time());
            
$image->setVar('image_display'1);
            
$image->setVar('image_weight'0);
            
$image->setVar('imgcat_id'$imgcat_id);
            if (
$imgcat->getVar('imgcat_storetype') == 'db') {
                
$fp = @fopen($uploader->getSavedDestination(), 'rb');
                
$fbinary = @fread($fpfilesize($uploader->getSavedDestination()));
                @
fclose($fp);
                
$image->setVar('image_body'addslashes($fbinary));
                @
unlink($uploader->getSavedDestination());
            }
            if (!
$image_handler->insert($image)) {
                
$err sprintf(_FAILSAVEIMG$image->getVar('image_nicename'));
            }
        }
    } else {
        
$err sprintf(_FAILFETCHIMG0);
        
$err .= '<br />'.implode('<br />'$uploader->getErrors(false));
    }
    if (isset(
$err)) {
        
xoops_header(false);
        
xoops_error($err);
        echo 
'</head><body><div style="text-align:center;"><input value="'._BACK.'" type="button" onclick="javascript:history.go(-1);" /></div>';
        
xoops_footer();
        exit();
    }
    
header('location: imagemanager.php?cat_id='.$imgcat_id.'&target='.$target);
}

?>