22 exit(
'Target not set');
27 if (isset(
$_GET[
'op']) &&
$_GET[
'op'] ==
'upload') {
29 } elseif (isset(
$_POST[
'op']) &&
$_POST[
'op'] ==
'doupload') {
34 $group = array(XOOPS_GROUP_ANONYMOUS);
39 require_once
$GLOBALS[
'xoops']->path(
'class/template.php');
47 $catcount = count($catlist);
53 $catshow = (!isset(
$_GET[
'cat_id'])) ? 0 : intval(
$_GET[
'cat_id']);
54 $catshow = (!empty($catshow) && in_array($catshow, array_keys($catlist))) ? $catshow : 0;
59 $catlist = array(
'0' =>
'--') + $catlist;
61 foreach ($catlist as $c_id => $c_name) {
63 if ($c_id == $catshow) {
64 $sel =
' selected="selected"';
66 $cat_options .=
'<option value="' . $c_id .
'"' .
$sel .
'>' . $c_name .
'</option>';
68 $xoopsTpl->assign(
'cat_options', $cat_options);
84 $storetype = $imgcat->getVar(
'imgcat_storetype');
85 if ($storetype ==
'db') {
86 $criteria->setSort(
'i.image_weight ASC, i.image_id');
90 $criteria->setSort(
'image_weight ASC, image_id');
94 $imgcount = count($images);
95 $max = ($imgcount > 10) ? 10 : $imgcount;
97 for (
$i = 0;
$i < $max;
$i++) {
98 if ($storetype ==
'db') {
99 $lcode =
'[img align=left id=' . $images[
$i]->getVar(
'image_id') .
']' . $images[
$i]->getVar(
'image_nicename') .
'[/img]';
100 $code =
'[img align=center id=' . $images[
$i]->getVar(
'image_id') .
']' . $images[
$i]->getVar(
'image_nicename') .
'[/img]';
101 $rcode =
'[img align=right id=' . $images[
$i]->getVar(
'image_id') .
']' . $images[
$i]->getVar(
'image_nicename') .
'[/img]';
102 $src = XOOPS_URL .
"/image.php?id=" . $images[
$i]->getVar(
'image_id');
104 $lcode =
'[img align=left]' .
XOOPS_UPLOAD_URL .
'/' . $images[
$i]->getVar(
'image_name') .
'[/img]';
105 $code =
'[img align=center]' .
XOOPS_UPLOAD_URL .
'/' . $images[
$i]->getVar(
'image_name') .
'[/img]';
106 $rcode =
'[img align=right]' .
XOOPS_UPLOAD_URL .
'/' . $images[
$i]->getVar(
'image_name') .
'[/img]';
109 $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));
112 include_once
$GLOBALS[
'xoops']->path(
'class/pagenav.php');
126 $xoopsTpl->display(
'db:system_imagemanager.html');
130 if (
$op ==
'upload') {
132 $imgcat_id = intval(
$_GET[
'imgcat_id']);
135 if (!is_object($imgcat)) {
140 if (! $imgcatperm_handler->checkRight(
'imgcat_write', $imgcat_id,
$xoopsUser->getGroups())) {
144 if (! $imgcatperm_handler->checkRight(
'imgcat_write', $imgcat_id, XOOPS_GROUP_ANONYMOUS)) {
151 echo
'</head><body><div style="text-align:center;"><input value="'._BACK.
'" type="button" onclick="javascript:history.go(-1);" /></div>';
155 require_once
$GLOBALS[
'xoops']->path(
'class/template.php');
157 $xoopsTpl->assign(
'show_cat', $imgcat_id);
160 $xoopsTpl->assign(
'target', htmlspecialchars(
$_GET[
'target'], ENT_QUOTES));
161 include_once
$GLOBALS[
'xoops']->path(
'class/xoopsformloader.php');
163 $form->setExtra(
'enctype="multipart/form-data"');
176 $xoopsTpl->display(
'db:system_imagemanager2.html');
180 if (
$op ==
'doupload') {
181 if (
$GLOBALS[
'xoopsSecurity']->check()) {
182 $image_nicename = isset(
$_POST[
'image_nicename']) ?
$_POST[
'image_nicename'] :
'';
183 $xoops_upload_file = isset(
$_POST[
'xoops_upload_file']) ?
$_POST[
'xoops_upload_file'] : array();
184 $imgcat_id = isset(
$_POST[
'imgcat_id']) ? intval(
$_POST[
'imgcat_id']) : 0;
185 include_once
$GLOBALS[
'xoops']->path(
'class/uploader.php');
189 if (!is_object($imgcat)) {
194 if (!$imgcatperm_handler->checkRight(
'imgcat_write', $imgcat_id,
$xoopsUser->getGroups())) {
198 if (!$imgcatperm_handler->checkRight(
'imgcat_write', $imgcat_id, XOOPS_GROUP_ANONYMOUS)) {
209 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>';
213 $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'));
215 if ($uploader->fetchMedia($xoops_upload_file[0])) {
216 if (!$uploader->upload()) {
217 $err = $uploader->getErrors();
221 $image->setVar(
'image_name', $uploader->getSavedFileName());
222 $image->setVar(
'image_nicename', $image_nicename);
223 $image->setVar(
'image_mimetype', $uploader->getMediaType());
224 $image->setVar(
'image_created', time());
225 $image->setVar(
'image_display', 1);
226 $image->setVar(
'image_weight', 0);
227 $image->setVar(
'imgcat_id', $imgcat_id);
228 if ($imgcat->getVar(
'imgcat_storetype') ==
'db') {
229 $fp = @fopen($uploader->getSavedDestination(),
'rb');
230 $fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
232 $image->setVar(
'image_body', $fbinary,
true);
233 @unlink($uploader->getSavedDestination());
241 $err .=
'<br />' . implode(
'<br />', $uploader->getErrors(
false));
246 echo
'</head><body><div style="text-align:center;"><input value="' .
_BACK .
'" type="button" onclick="javascript:history.go(-1);" /></div>';
250 header(
'location: imagemanager.php?cat_id=' . $imgcat_id .
'&target=' .
$target);