static function processImportedImage($filePath) { $fullPath = $filePath; if (!igUploadHelper::checkExtension($fullPath, false)) { return false; } if (!igUploadHelper::checkIsImage($fullPath, false)) { return false; } $slash = strrpos($fullPath, DIRECTORY_SEPARATOR) + 1; $filename = substr($fullPath, $slash); $filename = igUploadHelper::replaceSpecial($filename); //get the folder path $increment = igFileHelper::getFileIncrement('igallery_img'); $folderName = igFileHelper::getFolderName($increment); igFileHelper::makeFolder(IG_ORIG_PATH . '/' . $folderName); $destFolderPath = IG_ORIG_PATH . '/' . $folderName; //make the filename $destFile = igFileHelper::addIncrement($filename, $increment); $destFile = igFileHelper::checkUniqueName($destFolderPath, $destFile); $destPath = $destFolderPath . '/' . $destFile; $imageinfo = getimagesize($fullPath); $params = JComponentHelper::getParams('com_igallery'); $maxServerWidth = $params->get('server_max_width', 2100); $maxServerHeight = $params->get('server_max_height', 1600); if ($imageinfo[0] > $maxServerWidth || $imageinfo[1] > $maxServerHeight) { if (!igFileHelper::makeImage($fullPath, $destPath, $maxServerWidth, $maxServerHeight, 95, false)) { return false; } } else { if (!JFile::copy($fullPath, $destPath)) { igFileHelper::raiseError($fullPath . ' -> ' . $destPath . ' ' . JText::_('Error Moving File To Directory'), false); return false; } } $fileData = array(); $fileData['filename'] = $destFile; if ($params->get('import_exif_data', 0) == 1) { $fileData['exif_des'] = igFileHelper::getExifData($fullPath); } if ($params->get('import_iptc_data', 0) == 1) { $fileData['iptc_des'] = igFileHelper::getIptcData($fullPath); } if ($params->get('import_iptc_tags', 0) == 1) { $fileData['iptc_tags'] = igFileHelper::getIptcTags($fullPath); } return $fileData; }
static function upload_file($fileName, $tmpPath, $uploadError, $destDir, $refresh) { if (!igUploadHelper::checkFileError($uploadError, $fileName, $refresh)) { return false; } if (!igUploadHelper::checkMaxFilesize($tmpPath, $fileName, $refresh)) { return false; } if (!igUploadHelper::checkExtension($fileName, $refresh)) { return false; } if (!igUploadHelper::checkIsImage($tmpPath, $refresh)) { return false; } $fileNameClean = igUploadHelper::replaceSpecial($fileName); $fileNameUnique = igUploadHelper::makeUniqueName($destDir, $fileNameClean); if (!igUploadHelper::moveFile($tmpPath, $destDir, $fileNameUnique, $refresh)) { return false; } return $fileNameUnique; }
function display($tpl = null) { $pathVar = JRequest::getVar('path'); $regex = array('#[^ A-Za-z0-9:_\\\\/-]#'); $pathVar = preg_replace($regex, '', $pathVar); $fullPath = JPATH_SITE . $pathVar; $filesArray = JFolder::files($fullPath); $count = count($filesArray); for ($i = 0; $i < $count; $i++) { if (!igUploadHelper::checkExtension($filesArray[$i], false, false)) { unset($filesArray[$i]); } else { $filesArray[$i] = $fullPath . '/' . $filesArray[$i]; $filesArray[$i] = str_replace('\\', '*', $filesArray[$i]); } } $filesArray = array_values($filesArray); $headJs = ' window.addEvent(\'load\', function() { var fileNames = ['; for ($i = 0; $i < count($filesArray); $i++) { $headJs .= '\'' . $filesArray[$i] . '\', '; } $headJs = substr($headJs, 0, -2); $headJs .= '] '; $headJs .= ' var importClass = new Class ({ Implements: Options, options: {}, initialize: function(options) { this.setOptions(options); this.index = 0; this.doRequest(); }, doRequest: function() { this.serverUrl = \'index.php?option=com_igallery&task=image.serverImport&format=raw&catid=' . JRequest::getInt('catid') . '&path=\' + this.options.fileNames[this.index]; this.serverAjax = new Request({url:this.serverUrl, method: \'get\', onComplete: function(response) { if(response != 1) { $(\'error_msg\').innerHTML = \'Error, response from server:<br /> \' + response; return; } $(\'fileProgress\').set(\'html\', this.index + 1); if(this.index < this.options.fileNames.length - 1) { this.index ++; this.doRequest(); } else { window.parent.location = \'index.php?option=com_igallery&view=images&catid=' . JRequest::getInt('catid') . '\' } }.bind(this) }); this.serverAjax.send(); } }) var importClass1 = new importClass({fileNames: fileNames}); });'; $document = JFactory::getDocument(); $document->addScriptDeclaration($headJs); ?> <p><?php echo JText::_('IMPORTING_IMAGES'); ?> ...</p> <p><span id="fileProgress">1</span> / <?php echo count($filesArray); ?> </p> <div id="error_msg"></div> <?php }