/** * JAVA Applet upload * @param Kategorie id of destination category */ function Upload_AppletReceive_Backend($catid) { // If the applet checks for the serverProtocol, it issues a HEAD request // -> Simply return an empty doc. if ($_SERVER['REQUEST_METHOD'] == 'HEAD') { jexit(); } $config = Joom_getConfig(); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); $debugoutput = ''; //The Applet recognize an error with the text 'JOOMGALLERYUPLOADERROR' //and shows them within an JS alert box //check common requirements //no catid if ($catid == 0) { jexit('JOOMGALLERYUPLOADERROR ' . JText::_('JGA_JUPLOAD_YOU_MUST_SELECT_CATEGORY')); } //non common title if (!$config->jg_useorigfilename && empty($this->gentitle)) { jexit('JOOMGALLERYUPLOADERROR ' . JText::_('JGA_JUPLOAD_PICTURE_MUST_HAVE_TITLE')); } //Category path $catpath = Joom_GetCatPath($catid); foreach ($_FILES as $file => $fileArray) { //If 'delete originals' chosen in backend and the picture //shall be uploaded resized this will be done locally in the applet //then only the detail picture will be uploaded //therefore adjust path of destination category if ($config->jg_delete_original && $config->jg_resizetomaxwidth) { $no_original = true; $picpath = $config->jg_pathimages; } else { $no_original = false; $picpath = $config->jg_pathoriginalimages; } $screenshot = $fileArray["tmp_name"]; $screenshot_name = $fileArray["name"]; $screenshot_name = Joom_FixFilename($screenshot_name); $tag = strtolower(JFile::getExt($screenshot_name)); //check the possible available memory for picture resizing //if not available echo error message and continue with next picture if ($this->Upload_CheckMemory($debugoutput, $screenshot, $tag) == false) { $this->debug = 1; continue; } //Create new filename //if generic filename setted in backend use them if ($config->jg_useorigfilename) { $screenshot_name = Joom_FixFilename($screenshot_name); $newfilename = $this->Upload_GenFilename($screenshot_name, $tag); } else { $screenshot_name = Joom_FixFilename($this->gentitle); $newfilename = $this->Upload_GenFilename($screenshot_name, $tag); } //Move uploaded picture in destination folder (original or details) if (strlen($screenshot) > 0 && $screenshot != 'none') { $returnval = JFile::upload($screenshot, JPATH_ROOT . DS . $picpath . $catpath . $newfilename); if (!$returnval) { $debugoutput .= JText::_('JGA_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $picpath . $catpath . $newfilename . '<br />'; $this->debug = 1; continue; } Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $picpath . $catpath . $newfilename)); if (!$returnval) { $debugoutput .= JPath::clean(JPATH_ROOT . DS . $picpath . $catpath . $newfilename) . ': ' . JText::_('JGA_CHECK_PERMISSIONS'); $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, null, null); $this->debug = 1; continue; } //Create thumbnail $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality); if (!$returnval) { $debugoutput .= JText::_('JGA_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename; $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $this->debug = 1; continue; } $debugoutput .= JText::_('JGA_THUMBNAIL_CREATED') . "\n"; //evtl. create detail picture //not if 'delete originals' and resize setted in backend //In this case the applet made the resize and upload the detail picture if (!$no_original) { if ($config->jg_resizetomaxwidth && ($this->create_special_gif != 1 || $tag != 'gif' && $tag != 'png')) { $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true); if (!$returnval) { $debugoutput .= JText::_('JGA_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename; continue; } $debugoutput .= JText::_('JGA_RESIZED_TO_MAXWIDTH') . "\n"; } else { $returnval = JFile::copy($picpath . $catpath . $newfilename, $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT); if (!$returnval) { $debugoutput .= JText::_('JGA_PROBLEM_COPYING ') . $config->jg_pathimages . $catpath . $newfilename; $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $this->debug = 1; continue; } } $returnval = Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename)); if (!$returnval) { $debugoutput .= JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename . ' ' . JText::_('JGA_CHECK_PERMISSIONS'); $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $this->debug = 1; continue; } } //Delete original picture only if setted in upload window //not if setted in backend if ($config->jg_delete_original == 2 && $this->original_delete == 1) { if (JFile::delete(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename)) { $debugoutput .= JText::_('JGA_ORIGINAL_DELETED'); } else { $debugoutput .= JText::_('JGA_PROBLEM_DELETING_ORIGINAL') . ': ' . JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages) . ' ' . JText::_('JGA_CHECK_PERMISSIONS'); $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $this->debug = 1; } } //new entry for ordering $ordering = $this->Upload_GetOrdering($config->jg_uploadorder, $catid); $batchtime = mktime(); if ($config->jg_useorigfilename) { $fileextensionlength = strlen($tag); $filenamelength = strlen($screenshot_name); $imgname = substr($screenshot_name, -$filenamelength, -$fileextensionlength - 1); } else { $imgname = $this->gentitle; } $query = "INSERT INTO #__joomgallery(id, catid, imgtitle, imgauthor,\n imgtext, imgdate, imgcounter, imgvotes,\n imgvotesum, published, imgfilename, imgthumbname,\n checked_out,owner,approved, ordering)\n VALUES\n (NULL, '{$catid}', '{$imgname}', '{$this->photocred}',\n '{$this->gendesc}', '{$batchtime}', '0', '0',\n '0', '1', '{$newfilename}', '{$newfilename}',\n '0', '" . $user->get('id') . "', 1, '{$ordering}')"; $database->setQuery($query); if (!$database->query()) { $debugoutput .= $database->getErrorMsg(); $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $picpath . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $this->debug = 1; } } else { $debugoutput .= JText::_('JGA_WRONG_FILENAME'); $this->debug = 1; } } if ($this->debug) { echo "\nJOOMGALLERYUPLOADERROR\n"; } else { echo "\nJOOMGALLERYUPLOADSUCCESS\n"; } echo $debugoutput; jexit(); }
/** * creates images from the original one or moves the existing ones * into the folders of their category * [jimport('joomla.filesystem.file') has to be called afore] * @param object holds information about the new image * @param string original image * @param string detail image * @param string thumbnail * @param boolean true if a new filename shall be generated * @param boolean true if the image shall be copied into the new directory, not moved * @return boolean true if success */ function Joom_Migrate_MoveAndResizeImage($row, $origimage, $detailimage = null, $thumbnail = null, $newfilename = false, $copy = false) { //some checks if (!isset($row->id)) { return false; } if (!isset($row->imgfilename)) { return false; } if (!isset($row->catid) || $row->catid == 0) { return false; } if (!isset($row->catpath)) { $row->catpath = Joom_GetCatpath($row->catid); } if (!isset($row->imgtitle)) { $row->imgtitle = str_replace(JFile::getExt($row->imgfilename), '', $row->imgfilename); } if (!isset($row->imgauthor)) { $row->imgauthor = ''; } if (!isset($row->imgtext)) { $row->imgtext = ''; } if (!isset($row->imgdate)) { $row->imgdate = mktime(); } if (!isset($row->imgcounter)) { $row->imgcounter = 0; } if (!isset($row->imgvotes)) { $row->imgvotes = 0; } if (!isset($row->imgvotesum)) { $row->imgvotesum = 0; } if (!isset($row->published)) { $row->published = 0; } if (!isset($row->imgthumbname)) { $row->imgthumbname = $row->imgfilename; } if (!isset($row->checked_out)) { $row->checked_out = 0; } if (!isset($row->owner)) { $user =& JFactory::getUser(); $row->owner = $user->get('id'); } if (!isset($row->approved)) { $row->approved = 1; } if (!isset($row->useruploaded)) { $row->useruploaded = 0; } if (!isset($row->ordering)) { $row->ordering = 0; } if ($newfilename) { //TODO } //new images $neworigimage = JPATH_ROOT . DS . $this->_config->jg_pathoriginalimages . $row->catpath . $row->imgfilename; $newdetailimage = JPATH_ROOT . DS . $this->_config->jg_pathimages . $row->catpath . $row->imgfilename; $newthumbnail = JPATH_ROOT . DS . $this->_config->jg_paththumbs . $row->catpath . $row->imgfilename; $result = array(); //copy or move original image into the folder of the original images if ($copy) { $result['orig'] = JFile::copy(JPath::clean($origimage), JPath::clean($neworigimage)); if (!$result['orig']) { $this->Joom_Migrate_SetError('Could not copy original image'); } } else { $result['orig'] = JFile::move(JPath::clean($origimage), JPath::clean($neworigimage)); if (!$result['orig']) { $this->Joom_Migrate_SetError('Could not move original image'); } } if (is_null($detailimage)) { //create new detail image $debug_output = ''; $result['detail'] = Joom_ResizeImage($debug_output, $neworigimage, $newdetailimage, false, $this->_config->jg_maxwidth, false, $this->_config->jg_thumbcreation, $this->_config->jg_thumbquality, true); if (!$result['detail']) { $this->Joom_Migrate_SetError('Could not create detail image'); } } else { //copy or move existing detail image if ($copy) { $result['detail'] = JFile::copy(JPath::clean($detailimage), JPath::clean($newdetailimage)); if (!$result['detail']) { $this->Joom_Migrate_SetError('Could not copy detail image'); } } else { $result['detail'] = JFile::move(JPath::clean($detailimage), JPath::clean($newdetailimage)); if (!$result['detail']) { $this->Joom_Migrate_SetError('Could not move original image'); } } } if (is_null($thumbnail)) { //create new thumbnail $debug_output = ''; $result['thumb'] = Joom_ResizeImage($debug_output, $neworigimage, $newthumbnail, $this->_config->jg_useforresizedirection, $this->_config->jg_thumbwidth, $this->_config->jg_thumbheight, $this->_config->jg_thumbcreation, $this->_config->jg_thumbquality); if (!$result['thumb']) { $this->Joom_Migrate_SetError('Could not create thumbnail'); } } else { //copy or move existing thumbnail if ($copy) { $result['thumb'] = JFile::copy(JPath::clean($detailimage), JPath::clean($newdetailimage)); if (!$result['thumb']) { $this->Joom_Migrate_SetError('Could not copy thumbnail'); } } else { $result['thumb'] = JFile::move(JPath::clean($thumbnail), JPath::clean($newthumbnail)); if (!$result['thumb']) { $this->Joom_Migrate_SetError('Could not move thumbnail'); } } } //delete original image if configured in JoomGallery if ($this->_config->jg_delete_original == 1) { $result['delete_orig'] = JFile::delete($neworiginalimage); if (!$result['delete_orig']) { $this->Joom_Migrate_SetError('Could not delete original image'); } } //create database entry $query = "INSERT INTO #__joomgallery\n (id, catid, imgtitle, imgauthor, imgtext, imgdate, imgcounter, imgvotes, imgvotesum,\n published, imgfilename, imgthumbname, checked_out, owner, approved, useruploaded, ordering)\n VALUES\n (" . $row->id . ",\n " . $row->catid . ",\n '" . $row->imgtitle . "',\n '" . $row->imgauthor . "',\n '" . $row->imgtext . "',\n '" . $row->imgdate . "',\n " . $row->imgcounter . ",\n " . $row->imgvotes . ",\n " . $row->imgvotesum . ",\n " . $row->published . ",\n '" . $row->imgfilename . "',\n '" . $row->imgthumbname . "',\n " . $row->checked_out . ",\n " . $row->owner . ",\n " . $row->approved . ",\n " . $row->useruploaded . ",\n " . $row->ordering . ")"; $this->_db->setQuery($query); $result['db'] = $this->_db->query(); if (!$result['db']) { $this->Joom_Migrate_SetError($this->_db->getErrorMsg(), true); } if (!in_array(false, $result)) { $this->Joom_Migrate_WriteLogfile('Image successfully migrated: ' . $row->id . ' Title: ' . $row->imgtitle); return true; } else { $this->Joom_Migrate_WriteLogfile(' -> Error migrating image: ' . $row->id . ' Title: ' . $row->imgtitle); return false; } }
/** * Single upload * The user choose single picture files and upload them * concurrent uploads can be modified in backend * @param Category ID */ function Upload_Singles($catid) { $config = Joom_getConfig(); $mainframe =& JFactory::getApplication('site'); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); jimport('joomla.filesystem.file'); $debugoutput = ''; //no user logged in if (!$user->get('id')) { $mainframe->redirect(JRoute::_('index.php?option=com_joomgallery' . _JOOM_ITEMID, false), JText::_('JGS_YOU_ARE_NOT_LOGGED')); } $catpath = Joom_GetCatPath($catid); $debugoutput .= '<p />'; for ($i = 0; $i < $config->jg_maxuploadfields; $i++) { $screenshot = $this->arrscreenshot["tmp_name"][$i]; $screenshot_name = $this->arrscreenshot["name"][$i]; $screenshot_filesize = $this->arrscreenshot["size"][$i]; $ii = $i + 1; //Any picture entry at position? //(4=UPLOAD_ERR_NO_FILE constant since PHP 4.3.0) //if not continue with next entry if ($this->arrscreenshot['error'][$i] == 4) { continue; } //Check for path exploits, and replace spaces $screenshot_name = Joom_FixFilename($screenshot_name); // Get extension $tag = strtolower(JFile::getExt($screenshot_name)); if ($config->jg_useruploadnumber == 1) { $filecounter = $i + 1; $praefix = substr($screenshot_name, 0, strpos(strtolower($screenshot_name), $tag) - 1); $newfilename = $this->Upload_GenFilename($praefix, $tag, $filecounter); } else { $newfilename = $this->Upload_GenFilename($screenshot_name, $tag); } //Picture size must not exceed the setting in backend //except for Admin/SuperAdmin if ($screenshot_filesize > $config->jg_maxfilesize && !$this->adminlogged) { $debugoutput .= JText::_('JGS_ALERT_MAX_ALLOWED_FILESIZE') . " " . $config->jg_maxfilesize . " " . JText::_('JGS_ALERT_BYTES'); continue; } //Check for right format if ($tag == 'jpeg' || $tag == 'jpg' || $tag == 'jpe' || $tag == 'gif' || $tag == 'png') { $debugoutput .= '<hr />Position: ' . $ii . '<br />'; $debugoutput .= $ii . ". " . $screenshot_name . "<br />"; //if picture already exists if (file_exists(JPath::clean(JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename))) { $debugoutput .= JText::_('JGS_ALERT_SAME_PICTURE_ALREADY_EXIST'); continue; } // We'll assume that this file is ok because with open_basedir, // we can move the file, but may not be able to access it until it's moved $returnval = JFile::upload($screenshot, JPATH_ROOT . DS . $config->jg_pathoriginalimages . DS . $catpath . $newfilename); if (!$returnval) { $debugoutput .= JText::_('JGS_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename . '<br />'; continue; } $debugoutput .= JText::_('JGS_UPLOAD_COMPLETE') . '...<br />'; if (!($img_info = getimagesize(JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename)))) { // getimagesize didn't find a valid image or this is // some sort of hacking attempt JFile::delete(JPATH_ROOT . DS . $config->jg_pathoriginalimages . DS . $catpath . $newfilename); jexit(); } //check the possible available memory for picture resizing //if not available echo error message and continue with next picture if ($this->Upload_CheckMemory($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . DS . $catpath . $newfilename, $tag) == false) { $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, null); continue; } // create thumb $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality); if (!$returnval) { $debugoutput .= JText::_('JGS_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename; $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, null); continue; } $debugoutput .= JText::_('JGS_THUMBNAIL_CREATED') . '...<br />'; //create detail picture if ($config->jg_resizetomaxwidth && ($config->jg_special_gif_upload == 0 || $this->create_special_gif != 1 || $tag != 'gif' && $tag != 'png')) { $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true); if (!$returnval) { $debugoutput .= JText::_('JGS_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename; $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); continue; } $debugoutput .= JText::_('JGS_RESIZED_TO_MAXWIDTH') . '<br />'; } else { $returnval = JFile::copy($config->jg_pathoriginalimages . $catpath . $newfilename, $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT); if (!$returnval) { $debugoutput .= JText::_('JGS_PROBLEM_COPYING ') . $config->jg_pathimages . $catpath . $newfilename; $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); continue; } } if ($config->jg_delete_original_user == 1 || $config->jg_delete_original_user == 2 && $this->original_delete == 1) { if (JFile::delete(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename)) { $debugoutput .= JText::_('JGS_ORIGINAL_DELETED') . '<br />'; } else { $debugoutput .= JText::_('JGS_PROBLEM_DELETING_ORIGINAL') . ' - ' . JText::_('JGS_CHECK_PERMISSIONS'); $this->Upload_Rollback($debugoutput, null, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); continue; } } $ordering = $this->Upload_GetOrdering($config->jg_uploadorder, $catid); $row = new mosjoomgallery($database); if (!$row->bind($_POST, JText::_('JGS_APPROVED_OWNER_PUBLISHED'))) { $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; jexit(); } $row->imgdate = mktime(); $row->owner = $user->get('id'); $row->published = 1; //Upload from admin/superadmin are approved if ($config->jg_approve == 1 && !$this->adminlogged) { $row->approved = 0; } else { $row->approved = 1; } $row->imgfilename = $newfilename; $row->imgthumbname = $newfilename; $row->useruploaded = 1; $row->ordering = $ordering; //Wenn im Backend die Vergabe von lfd. Nummern eingestellt wurde //wird dem Bildtitel die lfd. Nummer (+1) hinzugefügt if ($config->jg_useruploadnumber) { $row->imgtitle = $row->imgtitle . '_' . $filecounter; } if (!$row->store()) { $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename); $debugoutput .= $row->getError(); continue; } else { // E-Mail ueber ein neues Bild an die User, die global als User Email-Empfang // erlaubt haben TODO -> In Backend-Konfig einstellen bzw. deaktivieren /* TODO // portierung: /administrator/components/com_messages/tables/message.php anstatt administrator/components/com_messages/messages.class.php require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_messages'.DS.'tables'.DS.'message.php' ); $database->setQuery("SELECT id FROM #__users WHERE sendEmail='1'"); $users = $database->loadResultArray(); foreach ($users as $user_id) { $msg = new TableMessage($database); // portierung: TableMessage anstatt mosMessage $msg->send($user->get('id'), $user_id, JText::_('JGS_NEW_PICTURE_UPLOADED'), sprintf( JText::_('JGS_NEW_CONTENT_SUBMITTED') . " %s " . JText::_('JGS_TITLED') ." %s.", $user->get('username'), $row->imgtitle)); } */ $debugoutput .= JText::_('JGS_ALERT_PICTURE_SUCCESSFULLY_ADDED') . '<br />'; $debugoutput .= JText::_('JGS_NEW_FILENAME') . ': ' . $newfilename . '<br /><br />'; } } else { $debugoutput .= JText::_('JGS_ALERT_INVALID_IMAGE_TYPE'); continue; } } echo $debugoutput; ?> <p> <img src="<?php echo _JOOM_LIVE_SITE . 'components/com_joomgallery/assets/images/arrow.png'; ?> " class="pngfile jg_icon" alt="arrow" /> <a href="<?php echo JRoute::_('index.php?option=com_joomgallery&func=showupload' . _JOOM_ITEMID); ?> "> <?php echo JText::_('JGS_MORE_UPLOADS'); ?> </a> </p> <p> <img src="<?php echo _JOOM_LIVE_SITE . 'components/com_joomgallery/assets/images/arrow.png'; ?> " class="pngfile jg_icon" alt="arrow" /> <a href="<?php echo JRoute::_('index.php?option=com_joomgallery&func=userpanel' . _JOOM_ITEMID); ?> "> <?php echo JText::_('JGS_BACK_TO_USER_PANEL'); ?> </a> </p> <p> <img src="<?php echo _JOOM_LIVE_SITE . 'components/com_joomgallery/assets/images/arrow.png'; ?> " class="pngfile jg_icon" alt="arrow" /> <a href="<?php echo JRoute::_('index.php?option=com_joomgallery&startpage=1' . _JOOM_ITEMID); ?> "> <?php echo JText::_('JGS_BACK_TO_GALLERY'); ?> </a> </p> <?php }
/** * recreates thumbnails of the selected images * if original image is existent, detail image will be recreated, too. */ function Joom_Recreate() { jimport('joomla.filesystem.file'); $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $config = Joom_GetConfig(); $cids = $mainframe->getUserStateFromRequest('joom.recreate.ids', 'id', array(), 'array'); $thumb_count = $mainframe->getUserState('joom.recreate.thumbcount'); $img_count = $mainframe->getUserState('joom.recreate.imgcount'); $row = new mosjoomgallery($database); // before first loop check for selected images if (is_null($thumb_count) and !count($cids)) { return array(false, JText::_('JGA_NO_IMAGES_SELECTED')); } //Check the maximum execution time of the script //set secure setting of the real execution time $max_execution_time = @ini_get('max_execution_time'); //try to set the max execution time to 60s if lower than //if not succesful the return value will be the old time, so use this if ($max_execution_time < 60) { #@ini_set('max_execution_time','60'); $max_execution_time = @ini_get('max_execution_time'); } $maxtime = (int) $max_execution_time * 0.8; $starttime = time(); $debugoutput = ''; //loop through selected images foreach ($cids as $key => $cid) { $row->load($cid); //catpath for category $catpath = Joom_GetCatPath($row->catid); $orig = JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $row->imgfilename; $img = JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $row->imgfilename; $thumb = JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $row->imgthumbname; //check if there is an original image if (JFile::exists($orig)) { $orig_existent = true; } else { //if not, use detail image to create thumbnail $orig_existent = false; if (JFile::exists($img)) { $orig = $img; } else { JError::raiseWarning(100, JText::sprintf('JGA_IMG_NOT_EXISTENT', $img)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.count', null); return false; } } //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($thumb); $return = Joom_ResizeImage($debugoutput, $orig, $thumb, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_THUMB', $thumb)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return false; } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_THUMB', $row->id, $row->imgtitle)); $thumb_count++; if ($orig_existent) { //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($img); $return = Joom_ResizeImage($debugoutput, $orig, $img, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_IMG', $img)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); return false; } } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_IMG', $row->id, $row->imgtitle)); $img_count++; unset($cids[$key]); //check remaining time $timeleft = -(time() - $starttime - $maxtime); if ($timeleft <= 0 and count($cids)) { $mainframe->setUserState('joom.recreate.cids', $cids); $mainframe->setUserState('joom.recreate.thumbcount', $thumb_count); $mainframe->setUserState('joom.recreate.imgcount', $img_count); $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&task=recreate', JText::_('JGA_REDIRECT')); } } $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return array($thumb_count, $img_count); }