/** * Copies all files from a folder to the /media folder. * It will NOT delete the media from the FTP-location * @param string Absolute path to the sourcefolder * @param string Absolute path to destination folder, defaults to Joomla /media folder */ function handleFTP($source, $destination = '') { global $ziplist, $mainframe; //Create unique install directory $tmpdir = uniqid('rsginstall_'); //Set destinatiopn if (!$destination) { $copyDir = JPath::clean(JPATH_ROOT . '/media/' . $tmpdir . '/'); } else { $copyDir = JPath::clean($destination . '/' . $tmpdir . '/'); } mkdir($copyDir); //Store dirname for cleanup at the end. $this->extractDir = $tmpdir; //Check for trailing slash in source path and add one if necessary $source = JPath::clean($source); //check source directory if (!file_exists($source) or !is_dir($source)) { echo $source . JText::_('_RSGALLERY_FU_FTP_DIR_NOT_EXIST'); $mainframe->redirect('index2.php?option=com_rsgallery2&task=batchupload', $source . JText::_('_RSGALLERY_FU_FTP_DIR_NOT_EXIST')); } //Read files from FTP-directory $files = JFolder::files($source, ''); if (!$files) { $mainframe->redirect('index2.php?option=com_rsgallery2&task=batchupload', JText::_('No valid images found in ') . $source . JText::_('. Please check the path.')); } //Create imagelist from FTP-directory foreach ($files as $file) { if (is_dir($source . $file)) { continue; } else { if (!in_array(fileHandler::getImageType($source . $file), $this->allowedFiles)) { continue; } else { //Add filename to list and copy to "/media/rsginstall_subdir" $list[] = $file; copy($source . $file, $copyDir . $file); } } } if (count($list) == 0) { echo JText::_('No files found to process!'); } else { return $list; } }
function batchupload_2($ziplist, $extractDir) { /* Info for javascript on input element names and values: Step 2 Button: Upload --> task=save_batchupload Delete checkbox name: delete[1] Item title field name: ptitle[] Gallery select name: category[] Description area name: descr[] */ global $rsgOption; JHTML::_('behavior.mootools'); $database = JFactory::getDBO(); //Get variables from form $selcat = rsgInstance::getInt('selcat', null); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); $batchmethod = rsgInstance::getVar('batchmethod', null); ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm, missingCat = false, categories = $$('#adminForm input[name^=category]', '#adminForm select[name^=category]'); for (i=0 ; i<categories.length ; i++) { if (categories[i].value <= 0) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "+' (#'+i+')'); return; missingCat = true; break; } } if (pressbutton == 'save_batchupload'){ if (missingCat == true) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "); } else { form.submit(); } } } //--> </script> <form action="index2.php" method="post" name="adminForm" id="adminForm"> <table class="adminform"> <tr> <th colspan="5" class="sectionname"><font size="4"><?php echo JText::_('Step 2'); ?> </font></th> </tr> <tr> <?php // Initialize k (the column reference) to zero. $k = 0; $i = 0; foreach ($ziplist as $filename) { $k++; //Check if filename is dir if (is_dir(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename)) { continue; } else { //Check if file is allowed $allowed_ext = array('gif', 'jpg', 'png'); $allowedVideo_ext = array('flv', 'avi', 'mov'); $ext = fileHandler::getImageType(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename); if (in_array($ext, $allowedVideo_ext)) { // build preview image $basePath = JPATH_SITE . '/media/' . $extractDir . '/'; require_once JPATH_RSGALLERY2_ADMIN . 'includes/video.utils.php'; Ffmpeg::capturePreviewImage($basePath . $filename, $basePath . $filename . '.png'); $displayImage = $filename . '.png'; $i++; } else { if (!in_array($ext, $allowed_ext)) { continue; } else { $displayImage = $filename; $i++; } } } ?> <td align="center" valign="top" bgcolor="#CCCCCC"> <table class="adminform" border="0" cellspacing="1" cellpadding="1"> <tr> <th colspan="2"> </th> </tr> <tr> <td colspan="2" align="right"><?php echo JText::_('Delete'); ?> #<?php echo $i - 1; ?> : <input type="checkbox" name="delete[<?php echo $i - 1; ?> ]" value="true" /></td> </tr> <tr> <td align="center" colspan="2"><img src="<?php echo JURI_SITE . "/media/" . $extractDir . "/" . $displayImage; ?> " alt="" border="1" width="100" align="center" /></td> </tr> <input type="hidden" value="<?php echo $filename; ?> " name="filename[]" /> <tr> <td><?php echo JText::_('Title'); ?> </td> <td> <input type="text" name="ptitle[]" size="15" /> </td> </tr> <tr> <td><?php echo JText::_('Gallery'); ?> </td> <td><?php if ($selcat == 1 && $xcat !== '0') { ?> <input type="text" name="cat_text" value="<?php echo htmlspecialchars(stripslashes(galleryUtils::getCatnameFromId($xcat))); ?> " readonly /> <input type="hidden" name="category[]" value="<?php echo $xcat; ?> " /> <?php } else { echo galleryUtils::galleriesSelectList(null, 'category[]', false); } ?> </td> </tr> <tr> <td><?php echo JText::_('Description'); ?> </td> <td><textarea cols="15" rows="2" name="descr[]"></textarea></td> </tr> </table> </td> <?php if ($k == 5) { echo "</tr><tr>"; $k = 0; } } ?> </table> <input type="hidden" name="teller" value="<?php echo $i; ?> " /> <input type="hidden" name="extractdir" value="<?php echo $extractDir; ?> " /> <input type="hidden" name="option" value="com_rsgallery2" /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="save_batchupload" /> </form> <?php }