} } $onerow->thumburl .= '?cache=' . time(); $onerow->defaultthumburl = '../' . DEFAULT_GALLERY_PATH . str_replace('%2F', '/', rawurlencode($file['filepath'] . IM_PREFIX . $file['filename'])) . '?nocache=' . time(); $onerow->thumb = '<img src="' . $onerow->defaultthumburl . '" alt="' . $file['filename'] . '" />'; $onerow->filename_input = $file['filename']; $onerow->title_input = $this->CreateInputText($id, 'filetitle', $file['title'], 30, 100); $onerow->comment = $file['comment']; $onerow->comment_input = $this->CreateTextArea(0, $id, $file['comment'], 'filecomment', 'fake" style="height:4em;', '', '', '', '40', '4'); // class filled with fake and style-info to overrule the theme-css if ($this->GetPreference('editfiledates')) { $onerow->filedate_input = $this->CreateInputText($id, 'filedate', substr($file['filedate'], 0, 10), 10, 10); } else { $onerow->filedate_input = $file['filedate']; } Gallery_utils::CreateThumbnail('../' . DEFAULT_GALLERY_PATH . $file['filepath'] . '/' . IM_PREFIX . $file['filename'], '../' . DEFAULT_GALLERY_PATH . $file['filepath'] . '/' . $file['filename'], IM_THUMBWIDTH, IM_THUMBHEIGHT, 'sc'); $onerow->deletelink = $this->CreateLink($id, 'multiaction', $returnid, $themeObject->DisplayImage('icons/system/delete.gif', $this->Lang('delete'), '', '', 'systemicon'), array('multiaction' => 'delete', 'fid' => $file['fileid'], 'origaction' => 'editgallery'), $this->Lang('areyousure')); $onerow->fields = Gallery_utils::Getcustomfields($params['fid'], 0, $id); $onerow->file .= '?cache=' . filemtime($onerow->file); $smarty->assign('image', $onerow); $smarty->assign('id', $id); $smarty->assign('file', $this->Lang('item')); $smarty->assign('title', $this->Lang('title')); $smarty->assign('comment', $this->Lang('comment')); $smarty->assign('filedate', $this->Lang('date')); $smarty->assign('cover', $this->Lang('albumcover')); $smarty->assign('active', $this->Lang('active')); $smarty->assign('rotateclockwise', $this->CreateLink($id, 'do_rotateimage', $returnid, '<img src="../modules/Gallery/images/clockwise.png" alt="' . $this->Lang('rotateclockwise') . '" title="' . $this->Lang('rotateclockwise') . '" />', array('fid' => $params['fid'], 'degr' => 270))); $smarty->assign('rotateanticlockwise', $this->CreateLink($id, 'do_rotateimage', $returnid, '<img src="../modules/Gallery/images/anticlockwise.png" alt="' . $this->Lang('rotateanticlockwise') . '" title="' . $this->Lang('rotateanticlockwise') . '" />', array('fid' => $params['fid'], 'degr' => 90))); $smarty->assign('formstart', $this->CreateFormStart($id, 'do_editimage', $returnid, 'post', '', false, '', $params)); // edit thumbs
$rec->comment = $row['comment']; $rec->active = $row['active']; if ($galleryinfo['thumbwidth'] > 0) { $rec->thumb = DEFAULT_GALLERYTHUMBS_PATH . $row['fileid'] . '-' . $galleryinfo['templateid'] . substr($row['filename'], strrpos($row['filename'], '.')); } else { $rec->thumb = DEFAULT_GALLERY_PATH . $row['filepath'] . IM_PREFIX . $row['filename']; } $rec->isdir = false; $paramslink['dir'] = str_replace('%2F', '/', rawurlencode($row['filepath'])); $prettyurl = $urlprefix . '/' . $paramslink['dir'] . ($targetpage != '' ? $targetpage : $returnid); $rec->galleryid = $row['galleryid']; $rec->gallery_url = $this->CreateFrontendLink($id, $targetpage != '' ? $targetpage : $returnid, 'default', '', $paramslink, '', true, true, '', false, $prettyurl); $rec->fields = Gallery_utils::Getcustomfields($rec->fileid, $rec->isdir, '', 1); $itemcount++; $imgcount++; Gallery_utils::CreateThumbnail($rec->thumb, DEFAULT_GALLERY_PATH . trim($row['filepath'] . '/' . $row['filename'], '/'), $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbwidth'] : IM_THUMBWIDTH, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbheight'] : IM_THUMBHEIGHT, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['resizemethod'] : 'sc'); array_push($images, $rec); } } } else { $params['module_message'] = $this->Lang('message_wrongdir', htmlspecialchars($params['dir'])); $smarty->assign('hideparentlink', true); } // Expose the list to smarty. Use "by_ref" to save memory. $smarty->assign_by_ref('images', $images); // and a count of records $smarty->assign('imagecount', $imgcount . ' ' . ($imgcount == 1 ? $this->Lang('image') : $this->Lang('images'))); $smarty->assign('itemcount', $itemcount); $smarty->assign('numimages', $imgcount); $smarty->assign('numdirs', $itemcount - $imgcount); $smarty->assign('pages', 1);
//session_start(); //ini_set("html_errors", "0"); // Check the upload if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) { echo 'ERROR:invalid upload'; exit(0); } // Check the uploaddirectory $root_path = str_replace('\\', '/', $config['root_path']) . '/'; if (!isset($_SESSION['uploaddir']) || !is_dir($root_path . $_SESSION['uploaddir'])) { echo 'ERROR:invalid uploaddirectory'; exit(0); } // cleanup the filename, copied some code from munge_string_to_url() and modified to exclude the extension $pos = strrpos($_FILES['Filedata']['name'], '.'); include '../lib/replacement.php'; $alias = substr($_FILES['Filedata']['name'], 0, $pos); $alias = str_replace($toreplace, $replacement, $alias); $alias = preg_replace('/[^a-z0-9-_]+/i', '-', $alias); $alias = trim($alias . substr($_FILES['Filedata']['name'], $pos), '-'); $filename = $_SESSION['uploaddir'] . '/' . $alias; $thumbname = $_SESSION['uploaddir'] . '/thumb_' . $alias; $thumbid = urlencode(base64_encode($thumbname)); if (Gallery_utils::CreateThumbnail('../' . $thumbname, $_FILES['Filedata']['tmp_name'], get_site_preference('thumbnail_width', 96), get_site_preference('thumbnail_height', 96), 'sc')) { move_uploaded_file($_FILES['Filedata']['tmp_name'], str_replace('/', DIRECTORY_SEPARATOR, $root_path . $filename)); echo 'FILEID:' . $thumbid; // Return the file id to the script } else { echo 'File corrupt: ' . $alias; } exit(0);
$prettyurl = $urlprefix . '/' . $paramslink['dir'] . (isset($paramslink['start']) ? $paramslink['start'] . '-' . $paramslink['number'] . '-' : '') . (isset($paramslink['show']) ? $paramslink['show'] . '-' : '') . ($targetpage != '' ? $targetpage : $returnid); $rec->file = $this->CreateFrontendLink($id, $targetpage != '' ? $targetpage : $returnid, 'default', '', $paramslink, '', true, true, '', false, $prettyurl); $rec->isdir = true; } elseif ($galleryinfo['thumbwidth'] > 0) { $rec->thumb = DEFAULT_GALLERYTHUMBS_PATH . $rec->fileid . '-' . $galleryinfo['templateid'] . substr($item['filename'], strrpos($item['filename'], '.')); $originalimage = DEFAULT_GALLERY_PATH . $key; $imgcount++; } else { $rec->thumb = DEFAULT_GALLERY_PATH . (empty($item['filepath']) ? '' : $item['filepath'] . '/') . IM_PREFIX . $item['filename']; $originalimage = DEFAULT_GALLERY_PATH . $key; $imgcount++; } // get the public custom fields for this item $rec->fields = Gallery_utils::Getcustomfields($rec->fileid, $rec->isdir, '', 1); if ($rec->thumb != $folderpath) { Gallery_utils::CreateThumbnail($rec->thumb, $originalimage, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbwidth'] : IM_THUMBWIDTH, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbheight'] : IM_THUMBHEIGHT, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['resizemethod'] : 'sc'); } array_push($images, $rec); } } // Sort array $images // second parameter of _ArraySort is an array of strings, which contains: // n for number, s for string // + for ascending, - for descending // fieldname $sortarray = explode('/', 'n+fileorder/' . $galleryinfo['sortitems']); $images = Gallery_utils::ArraySort($images, $sortarray, false); $itemcount = count($images); // Get the images we want $images = array_splice($images, $start - 1, $number); } else {
} if (!empty($params['x2']) && !empty($params['y2'])) { // get image info $image = Gallery_utils::Getimagebyid($params['fid']); // get templateproperties for thumbsizes if ($params['template'] == 0) { $tplthumb = array('templateid' => 0, 'thumbname' => '../' . DEFAULT_GALLERY_PATH . $image['filepath'] . IM_PREFIX . $image['filename'], 'thumbwidth' => IM_THUMBWIDTH, 'thumbheight' => IM_THUMBHEIGHT, 'resizemethod' => 'sc'); } else { $db = $this->GetDB(); $query = "SELECT *\n\t\t\t\tFROM " . cms_db_prefix() . "module_gallery_templateprops\n\t\t\t\tWHERE templateid=?"; $result = $db->Execute($query, array($params['template'])); if ($result && $result->RecordCount() > 0) { $templateprops = $result->GetArray(); $tplthumb = $templateprops[0]; $tplthumb['thumbname'] = '../' . DEFAULT_GALLERYTHUMBS_PATH . $params['fid'] . '-' . $params['template'] . substr($image['filename'], strrpos($image['filename'], '.')); } else { $params = array('fid' => $params['fid'], 'mode' => 'edit', 'active_tab' => 'thumbs', 'module_error' => lang('sqlerror', 'do_editthump.php')); $this->Redirect($id, 'editimage', '', $params); } } // update thumbnail @unlink($tplthumb['thumbname']); $thumbcr = Gallery_utils::CreateThumbnail($tplthumb['thumbname'], '../' . DEFAULT_GALLERY_PATH . $image['filepath'] . $image['filename'], $tplthumb['thumbwidth'], $tplthumb['thumbheight'], $tplthumb['resizemethod'], $params['x1'] * $params['scale'], $params['y1'] * $params['scale'], $params['x2'] * $params['scale'], $params['y2'] * $params['scale']); } if (isset($params['applybutton2'])) { $params = array('fid' => $params['fid'], 'mode' => 'edit', 'template' => $params['template'], 'active_tab' => 'thumbs', 'module_message' => $this->Lang('thumbupdated')); $this->Redirect($id, 'editimage', '', $params); } else { $params = array('gid' => $params['gid'], 'mode' => 'edit', 'module_message' => $this->Lang('thumbupdated')); $this->Redirect($id, 'editgallery', '', $params); }
<?php if (!$gCms) { exit; } if (!$this->CheckPermission('Use Gallery')) { echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } if (!isset($params['gid'])) { $params['module_error'] = lang('missingparams'); $this->Redirect($id, 'defaultadmin', '', $params); return; } $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); $gallerypath = $params['gid'] == 1 ? '' : trim($galleryinfo['filepath'] . '/' . $galleryinfo['filename'], '/'); $gallery = Gallery_utils::Getgalleryfiles($gallerypath); foreach ($gallery as $file) { if (substr($file['filename'], -1) != '/') { $thumbname = '../' . DEFAULT_GALLERYTHUMB_PATH . $file['fileid'] . '-' . $params['templateid'] . substr($file['filename'], strrpos($file['filename'], '.')); Gallery_utils::CreateThumbnail($thumbname, '../' . DEFAULT_GALLERY_PATH . (empty($file['filepath']) ? '' : $file['filepath'] . '/') . $file['filename'], $galleryinfo['thumbwidth'], $galleryinfo['thumbheight'], $galleryinfo['resizemethod']); } } $this->Redirect($id, 'editgallery', '', array('gid' => $params['gid'], 'mode' => "edit", 'module_message' => $this->Lang('thumbscreated')));