本文整理汇总了PHP中t3lib_div::upload_copy_move方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::upload_copy_move方法的具体用法?PHP t3lib_div::upload_copy_move怎么用?PHP t3lib_div::upload_copy_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::upload_copy_move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Interface function. This will be called from the sprite manager to
* refresh all caches.
*
* @return void
*/
public function generate()
{
$this->generatorInstance = t3lib_div::makeInstance('t3lib_spritemanager_SpriteGenerator', 'GeneratorHandler');
$this->generatorInstance->setOmmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->setSpriteFolder(t3lib_SpriteManager::$tempPath)->setCSSFolder(t3lib_SpriteManager::$tempPath);
$iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
foreach ($iconsToProcess as $iconName => $iconFile) {
$iconsToProcess[$iconName] = t3lib_div::resolveBackPath('typo3/' . $iconFile);
}
$generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess);
if (!is_dir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6')) {
t3lib_div::mkdir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6');
}
t3lib_div::upload_copy_move($generatorResponse['spriteGifImage'], t3lib_div::dirname($generatorResponse['spriteGifImage']) . '/ie6/' . basename($generatorResponse['spriteGifImage']));
unlink($generatorResponse['spriteGifImage']);
t3lib_div::upload_copy_move($generatorResponse['cssGif'], t3lib_div::dirname($generatorResponse['cssGif']) . '/ie6/' . basename($generatorResponse['cssGif']));
unlink($generatorResponse['cssGif']);
$this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']);
parent::generate();
}
示例2: main_autoFix
/**
* Mandatory autofix function
* Will run auto-fix on the result array. Echos status during processing.
*
* @param array Result array from main() function
* @return void
*/
function main_autoFix($resultArray)
{
$limitTo = $this->cli_args['--AUTOFIX'][0];
if (is_array($resultArray['doubleFiles'])) {
if (!$limitTo || $limitTo === 'doubleFiles') {
echo 'FIXING double-usages of RTE files in uploads/: ' . LF;
foreach ($resultArray['RTEmagicFilePairs'] as $fileName => $fileInfo) {
// Only fix something if there is a usage count of more than 1 plus if both original and copy exists:
if ($fileInfo['count'] > 1 && $fileInfo['exists'] && $fileInfo['original_exists']) {
// Traverse all records using the file:
$c = 0;
foreach ($fileInfo['usedIn'] as $hash => $recordID) {
if ($c == 0) {
echo ' Keeping file ' . $fileName . ' for record ' . $recordID . LF;
} else {
// CODE below is adapted from "class.tx_impexp.php" where there is support for duplication of RTE images:
echo ' Copying file ' . basename($fileName) . ' for record ' . $recordID . ' ';
// Initialize; Get directory prefix for file and set the original name:
$dirPrefix = dirname($fileName) . '/';
$rteOrigName = basename($fileInfo['original']);
// If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
if ($rteOrigName && t3lib_div::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
// RTE:
// From the "original" RTE filename, produce a new "original" destination filename which is unused.
$fileProcObj = $this->getFileProcObj();
$origDestName = $fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
// Create copy file name:
$pI = pathinfo($fileName);
$copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === t3lib_div::getFileAbsFileName($origDestName) && $copyDestName === t3lib_div::getFileAbsFileName($copyDestName)) {
echo ' to ' . basename($copyDestName);
if ($bypass = $this->cli_noExecutionCheck($fileName)) {
echo $bypass;
} else {
// Making copies:
t3lib_div::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
t3lib_div::upload_copy_move(PATH_site . $fileName, $copyDestName);
clearstatcache();
if (@is_file($copyDestName)) {
$sysRefObj = t3lib_div::makeInstance('t3lib_refindex');
$error = $sysRefObj->setReferenceValue($hash, substr($copyDestName, strlen(PATH_site)));
if ($error) {
echo ' - ERROR: t3lib_refindex::setReferenceValue(): ' . $error . LF;
exit;
} else {
echo " - DONE";
}
} else {
echo ' - ERROR: File "' . $copyDestName . '" was not created!';
}
}
} else {
echo ' - ERROR: Could not construct new unique names for file!';
}
} else {
echo ' - ERROR: Maybe directory of file was not within "uploads/"?';
}
echo LF;
}
$c++;
}
}
}
} else {
echo 'Bypassing fixing of double-usages since --AUTOFIX was not "doubleFiles"' . LF;
}
}
if (is_array($resultArray['lostFiles'])) {
if ($limitTo === 'lostFiles') {
echo 'Removing lost RTEmagic files from folders inside uploads/: ' . LF;
foreach ($resultArray['lostFiles'] as $key => $value) {
$absFileName = t3lib_div::getFileAbsFileName($value);
echo 'Deleting file: "' . $absFileName . '": ';
if ($bypass = $this->cli_noExecutionCheck($absFileName)) {
echo $bypass;
} else {
if ($absFileName && @is_file($absFileName)) {
unlink($absFileName);
echo 'DONE';
} else {
echo ' ERROR: File "' . $absFileName . '" was not found!';
}
}
echo LF;
}
}
} else {
echo 'Bypassing fixing of double-usages since --AUTOFIX was not "lostFiles"' . LF;
}
}
示例3: download
private function download()
{
/**/
$erreur = '';
if ($this->formValue['formname'] == 'contact_default_cv' && isset($_FILES['cv'])) {
/* Vérification que le fichier est bien téléchargé */
Zend_Debug::dump($_FILES['cv']);
if ($_FILES['cv']['error'] > 0) {
$erreur .= 'Erreur lors du tansfert/n';
}
/* Test sur les extensions */
$extensions_valides = array('txt', 'doc', 'docx', 'pdf', 'odt');
$extension_upload = strtolower(substr(strrchr($_FILES['cv']['name'], '.'), 1));
$name_upload = strtolower(substr(strrchr($_FILES['cv']['name'], '.'), 0));
if (!in_array($extension_upload, $extensions_valides)) {
$erreur .= 'Extension non correcte /n';
}
Zend_Debug::dump($extension_upload, "extension");
if ($_FILES['cv']['size'] > 500 * 1024) {
$erreur .= 'Le fichier est trop gros./n';
}
Zend_Debug::dump($_FILES['cv']['size'], 'taille');
if ($erreur == '') {
/* Recherche d'un nom
* Vérification si le nom existe
*/
$fichier_temp = $_FILES['cv']['tmp_name'];
$fichier = $this->fileFunc->cleanFileName(basename($_FILES['cv']['name']));
$chemin = PATH_site . $this->upload;
if (!is_dir($chemin)) {
$erreur .= 'Répertoire n\'existe pas /n';
}
$file_path = $this->fileFunc->getUniqueName($fichier, $chemin);
if (t3lib_div::upload_copy_move($fichier_temp, $file_path)) {
// si l'upload est completement réussi
$file = str_replace(PATH_site, $_SERVER["SERVER_NAME"] . '/', $file_path);
$this->formValue['cv'] = $file;
Zend_Debug::dump($this->formValue['cv']);
} else {
$erreur .= 'Problème dans le téléchargement du fichier./n';
}
}
}
if ($erreur == '') {
return true;
} else {
return $erreur;
}
}
示例4: copyRecord_fixRTEmagicImages
/**
* Copies any "RTEmagic" image files found in record with table/id to new names.
* Usage: After copying a record this function should be called to search for "RTEmagic"-images inside the record. If such are found they should be duplicated to new names so all records have a 1-1 relation to them.
* Reason for copying RTEmagic files: a) if you remove an RTEmagic image from a record it will remove the file - any other record using it will have a lost reference! b) RTEmagic images keeps an original and a copy. The copy always is re-calculated to have the correct physical measures as the HTML tag inserting it defines. This is calculated from the original. Two records using the same image could have difference HTML-width/heights for the image and the copy could only comply with one of them. If you don't want a 1-1 relation you should NOT use RTEmagic files but just insert it as a normal file reference to a file inside fileadmin/ folder
*
* @param string Table name
* @param integer Record UID
* @return void
*/
function copyRecord_fixRTEmagicImages($table, $theNewSQLID)
{
global $TYPO3_DB;
// Creating fileFunc object.
if (!$this->fileFunc) {
$this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->include_filefunctions = 1;
}
// Select all RTEmagic files in the reference table from the table/ID
/* @var $TYPO3_DB t3lib_DB */
$recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string LIKE ' . $TYPO3_DB->fullQuoteStr('%/RTEmagic%', 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('images', 'sys_refindex') . ' AND tablename=' . $TYPO3_DB->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . intval($theNewSQLID), '', 'sorting DESC');
// Traverse the files found and copy them:
if (is_array($recs)) {
foreach ($recs as $rec) {
$filename = basename($rec['ref_string']);
$fileInfo = array();
if (t3lib_div::isFirstPartOfStr($filename, 'RTEmagicC_')) {
$fileInfo['exists'] = @is_file(PATH_site . $rec['ref_string']);
$fileInfo['original'] = substr($rec['ref_string'], 0, -strlen($filename)) . 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
$fileInfo['original_exists'] = @is_file(PATH_site . $fileInfo['original']);
// CODE from tx_impexp and class.rte_images.php adapted for use here:
if ($fileInfo['exists'] && $fileInfo['original_exists']) {
// Initialize; Get directory prefix for file and set the original name:
$dirPrefix = dirname($rec['ref_string']) . '/';
$rteOrigName = basename($fileInfo['original']);
// If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
if ($rteOrigName && t3lib_div::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
// RTE:
// From the "original" RTE filename, produce a new "original" destination filename which is unused.
$origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
// Create copy file name:
$pI = pathinfo($rec['ref_string']);
$copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === t3lib_div::getFileAbsFileName($origDestName) && $copyDestName === t3lib_div::getFileAbsFileName($copyDestName)) {
// Making copies:
t3lib_div::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
t3lib_div::upload_copy_move(PATH_site . $rec['ref_string'], $copyDestName);
clearstatcache();
// Register this:
$this->RTEmagic_copyIndex[$rec['tablename']][$rec['recuid']][$rec['field']][$rec['ref_string']] = substr($copyDestName, strlen(PATH_site));
// Check and update the record using the t3lib_refindex class:
if (@is_file($copyDestName)) {
$sysRefObj = t3lib_div::makeInstance('t3lib_refindex');
$error = $sysRefObj->setReferenceValue($rec['hash'], substr($copyDestName, strlen(PATH_site)), FALSE, TRUE);
if ($error) {
echo $this->newlog('t3lib_refindex::setReferenceValue(): ' . $error, 1);
}
} else {
$this->newlog('File "' . $copyDestName . '" was not created!', 1);
}
} else {
$this->newlog('Could not construct new unique names for file!', 1);
}
} else {
$this->newlog('Maybe directory of file was not within "uploads/"?', 1);
}
} else {
$this->newlog('Trying to copy RTEmagic files (' . $rec['ref_string'] . ' / ' . $fileInfo['original'] . ') but one or both were missing', 1);
}
}
}
}
}
示例5: isValid
/**
* Validation of given Params
*
* @param array $field
* @return bool
*/
public function isValid($field) {
if (isset($_FILES['tx_powermail_pi1']['name']['field'])) {
// session stuff
$uploadSession = array();
Tx_Powermail_Utility_Div::setSessionValue('upload', array(), true); // clean old session before
foreach ($_FILES['tx_powermail_pi1']['name']['field'] as $uid => $filename) {
// if no file given
if (empty($filename)) {
continue;
}
// Check extension
if (!$this->checkExtension($filename, $uid)) {
continue;
}
// Check filesize
if (!$this->checkFilesize($uid)) {
continue;
}
// create new filename with absolute path
$newFile = $this->basicFileFunctions->getUniqueName($filename, t3lib_div::getFileAbsFileName($this->settings['misc.']['file.']['folder']));
$uploadSession[] = $newFile; // create array for upload session
if (!t3lib_div::upload_copy_move($_FILES['tx_powermail_pi1']['tmp_name']['field'][$uid], $newFile)) {
$this->addError('upload_error', $uid);
$this->isValid = false;
}
}
// save uploaded filenames to session (to attach it later)
Tx_Powermail_Utility_Div::setSessionValue('upload', $uploadSession, true);
}
return $this->isValid;
}
示例6: createAction
/**
* Processes uploads
*
* @param mixed $file
* @return void
*/
public function createAction(Tx_Feupload_Domain_Model_File $file)
{
$ffunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$path = $ffunc->getUniqueName($_FILES['tx_feupload_upload']['name']['file']['file'], t3lib_div::getFileAbsFileName('uploads/feupload/'));
t3lib_div::upload_copy_move($_FILES['tx_feupload_upload']['tmp_name']['file']['file'], $path);
$file->setFile(basename($path));
if ($GLOBALS['TSFE']->fe_user->user) {
// This is because $GLOBALS['TSFE']->fe_user is of type
// tslib_feUserAuth
// and $GLOBALS['TSFE']->fe_user->user is an array.
$owner = $this->frontendUserRepository->findByUid($GLOBALS["TSFE"]->fe_user->user['uid']);
$file->setOwner($owner);
}
$visibility = $_POST['tx_feupload_upload']['visibility'];
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['feupload']);
$defaultVisibility = $extConf['defaultFileVisibility'];
// globalVisibilty set? ignore user preference
if (!empty($defaultVisibility) and in_array($defaultVisibility, array('public', 'login', 'groups'))) {
$visibility = $defaultVisibility;
}
switch ($visibility) {
case 'public':
$file->setVisibility(0);
break;
case 'login':
$file->setVisibility(-2);
break;
case 'groups':
$file->setVisibility(1);
foreach ($_POST['tx_feupload_upload']['groups'] as $groupId) {
$group = $this->frontendUserGroupRepository->findByUid($groupId);
if ($group) {
$file->addFrontendUserGroup($group);
}
}
break;
}
if ((bool) $this->userTS['appendGroups']) {
$groupIds = explode(',', $this->userTS['appendGroups']);
foreach ($groupIds as $groupId) {
$group = $this->frontendUserGroupRepository->findByUid($groupId);
if ($group) {
$file->addFrontendUserGroup($group);
}
}
}
/* @var $sessionHandler Tx_Feupload_Session_Folder */
$sessionHandler = t3lib_div::makeInstance('Tx_Feupload_Session_Folder');
$file->setFolder($sessionHandler->getCurrentFolder());
$this->fileRepository->add($file);
$this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('LLL:EXT:feupload/Resources/Private/Language/locallang.xml:flash.ok.file.uploaded.content'), Tx_Extbase_Utility_Localization::translate('LLL:EXT:feupload/Resources/Private/Language/locallang.xml:flash.ok.file.uploaded.title'), t3lib_FlashMessage::OK);
$this->redirect('new');
}
示例7: handleAjaxRequest
function handleAjaxRequest($oRequest)
{
require_once PATH_t3lib . "class.t3lib_basicfilefunc.php";
$oFile = t3lib_div::makeInstance("t3lib_basicFileFunctions");
$aFile = $GLOBALS["_FILES"]["rdt_swfupload"];
$sOriginalFileName = stripslashes($aFile["name"]);
$sFileName = $sOriginalFileName;
if ($this->defaultTrue("/usedenypattern") !== FALSE) {
if (!t3lib_div::verifyFilenameAgainstDenyPattern($sFileName)) {
die("FILE EXTENSION DENIED");
}
}
if ($this->defaultFalse("/cleanfilename") !== FALSE) {
$sFileName = strtolower($oFile->cleanFileName($sFileName));
}
$sTargetDir = $this->getTargetDir();
$sTarget = $sTargetDir . $sFileName;
if (!file_exists($sTargetDir)) {
if ($this->defaultFalse("/data/targetdir/createifneeded") === TRUE) {
// the target does not exist, we have to create it
$this->oForm->div_mkdir_deep_abs($sTargetDir);
}
}
if (!$this->defaultFalse("/overwrite")) {
$sExt = strpos($sFileName, '.') === FALSE ? '' : '.' . substr(strrchr($sFileName, "."), 1);
for ($i = 1; file_exists($sTarget); $i++) {
$sTarget = $sTargetDir . substr($sFileName, 0, strlen($sFileName) - strlen($sExt)) . '[' . $i . ']' . $sExt;
}
$sFileName = basename($sTarget);
}
$this->sUploadedFileName = $sFileName;
$this->aUploadedFileNameByOriginalFileName[$sOriginalFileName] = $sFileName;
t3lib_div::upload_copy_move($aFile["tmp_name"], $sTarget);
return array();
// die("OK: " . $sTarget);
}
示例8: func_upload
/**
* Upload of files (action=1)
*
* @param array $cmds['data'] is the ID-number (points to the global var that holds the filename-ref ($GLOBALS['HTTP_POST_FILES']['upload_'.$id]['name']). $cmds['target'] is the target directory
* @param string $id: $_FILES['upload_'.$id]
* @return string Returns the new filename upon success
*/
function func_upload($cmds, $id = false)
{
if ($id === false) {
$id = $cmds['data'];
}
if (!$this->isInit) {
return FALSE;
}
if (!$_FILES['upload_' . $id]['name']) {
return;
}
// filename of the uploaded file
$theFile = $_FILES['upload_' . $id]['tmp_name'];
// filesize of the uploaded file
$theFileSize = $_FILES['upload_' . $id]['size'];
// The original filename
$theName = tx_dam::file_makeCleanName($_FILES['upload_' . $id]['name']);
# $theName = $this->cleanFileName($_FILES['upload_'.$id]['name']);
// main log entry
$this->log['cmd']['upload'][$id] = array('errors' => array(), 'orig_filename' => $theName, 'target_file' => '', 'target_path' => $this->fileCmdMap['upload'][$id]['target']);
// Check if the file is uploaded
if (!(is_uploaded_file($theFile) && $theName)) {
$this->writelog(1, 2, 106, 'The uploaded file did not exist!', '', 'upload', $id);
return;
}
// check upload permissions
if (!$this->actionPerms['uploadFile']) {
$this->writelog(1, 1, 105, 'You are not allowed to upload files!', '', 'upload', $id);
return;
}
// check if the file size exceed permissions
$maxBytes = $this->getMaxUploadSize();
if (!($theFileSize < $maxBytes)) {
$this->writelog(1, 1, 104, 'The uploaded file exceeds the size-limit of %s (%s Bytes).', array(t3lib_div::formatSize($maxBytes), $maxBytes), 'upload', $id);
return;
}
// Check the target dir
$theTarget = $this->is_directory($cmds['target']);
// check if target is inside of a mount point
if (!($theTarget && $this->checkPathAgainstMounts($theTarget . '/'))) {
$this->writelog(1, 1, 103, 'Destination path "%s" was not within your mountpoints!', array($theTarget . '/'), 'upload', $id);
return;
}
// check if the file extension is allowed
$fI = t3lib_div::split_fileref($theName);
if (!$this->checkIfAllowed($fI['fileext'], $theTarget, $fI['file'])) {
$this->writelog(1, 1, 102, 'Fileextension "%s" is not allowed in "%s"!', array($fI['fileext'], $theTarget . '/'), 'upload', $id);
return;
}
// Create unique file name
$theNewFile = $this->getUniqueName($theName, $theTarget, $this->dontCheckForUnique);
if (!$theNewFile) {
$this->writelog(1, 1, 101, 'No unique filename available in "%s"!', array($theTarget . '/'), 'upload', $id);
return;
}
// move uploaded file to target location
t3lib_div::upload_copy_move($theFile, $theNewFile);
clearstatcache();
// moving file did not work
if (!@is_file($theNewFile)) {
$this->writelog(1, 1, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', array($theTarget . '/'), 'upload', $id);
return;
}
$this->internalUploadMap[$id] = $theNewFile;
$this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', array($theName, $theNewFile, $id), 'upload', $id);
// add file to log entry
$this->log['cmd']['upload'][$id]['target_file'] = $theNewFile;
return $theNewFile;
}
示例9: upload_copy_move
/**
* wrapper for t3lib_div::writeFile
* checks for overwrite settings
*
* @param string $targetFile the path and filename of the targetFile
* @param string $fileContents
*/
protected function upload_copy_move($sourceFile, $targetFile)
{
$overWriteMode = Tx_ExtensionBuilder_Service_RoundTrip::getOverWriteSettingForPath($targetFile, $this->extension);
if ($overWriteMode === -1) {
// skip creation
return;
}
if (!file_exists($targetFile) || $this->roundTripEnabled && $overWriteMode < 2) {
t3lib_div::upload_copy_move($sourceFile, $targetFile);
}
}
示例10: processFiles
/**
* Processes uploaded files
*
* @param string $theTable: the name of the table being edited
* @param string $theField: the name of the field
* @return array file names
*/
public function processFiles($theTable, $theField, array $fieldDataArray, $cmdKey)
{
if (is_array($GLOBALS['TCA'][$theTable]['columns'][$theField])) {
$uploadPath = $GLOBALS['TCA'][$theTable]['columns'][$theField]['config']['uploadfolder'];
}
$fileNameArray = array();
if ($uploadPath) {
if (count($fieldDataArray)) {
foreach ($fieldDataArray as $file) {
if (is_array($file)) {
if ($this->checkFilename($file['name'])) {
if ($file['submit_delete']) {
if ($cmdKey !== 'edit') {
if (@is_file(PATH_site . $uploadPath . '/' . $file['name'])) {
@unlink(PATH_site . $uploadPath . '/' . $file['name']);
}
}
} else {
$fileNameArray[] = $file['name'];
}
}
} else {
if ($this->checkFilename($file)) {
$fileNameArray[] = $file;
}
}
}
}
if (is_array($_FILES['FE']['name'][$theTable][$theField])) {
foreach ($_FILES['FE']['name'][$theTable][$theField] as $i => $filename) {
if ($filename && $this->checkFilename($filename) && $this->evalFileError($_FILES['FE']['error'][$theTable][$theField][$i])) {
$fI = pathinfo($filename);
if (t3lib_div::verifyFilenameAgainstDenyPattern($fI['name'])) {
$tmpFilename = basename($filename, '.' . $fI['extension']) . '_' . t3lib_div::shortmd5(uniqid($filename)) . '.' . $fI['extension'];
$cleanFilename = $this->fileFunc->cleanFileName($tmpFilename);
$theDestFile = $this->fileFunc->getUniqueName($cleanFilename, PATH_site . $uploadPath . '/');
$result = t3lib_div::upload_copy_move($_FILES['FE']['tmp_name'][$theTable][$theField][$i], $theDestFile);
$fI2 = pathinfo($theDestFile);
$fileNameArray[] = $fI2['basename'];
}
}
}
}
}
return $fileNameArray;
}
示例11: generateGraphic
/**
* The actual sprite generator, renders the command for Im/GM and executes
*
* @return void
*/
protected function generateGraphic()
{
$iconParameters = array();
$tempSprite = t3lib_div::tempnam($this->spriteName);
$filePath = array('mainFile' => PATH_site . $this->spriteFolder . $this->spriteName . '.png', 'gifFile' => NULL);
// create black true color image with given size
$newSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
imagesavealpha($newSprite, TRUE);
// make it transparent
imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));
foreach ($this->iconsData as $icon) {
$function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
if (function_exists($function)) {
$currentIcon = $function($icon['fileName']);
imagecopy($newSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
}
}
imagepng($newSprite, $tempSprite . '.png');
if ($this->generateGIFCopy) {
$filePath['gifFile'] = PATH_site . $this->spriteFolder . $this->spriteName . '.gif';
$gifSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
// make it transparent
imagefill($gifSprite, 0, 0, imagecolorallocate($gifSprite, 127, 127, 127));
foreach ($this->iconsData as $icon) {
$function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
if (function_exists($function)) {
$currentIcon = $function($icon['fileName']);
imagecopy($gifSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
}
}
imagecolortransparent($gifSprite, imagecolorallocate($gifSprite, 127, 127, 127));
imagegif($gifSprite, $tempSprite . '.gif');
}
t3lib_div::upload_copy_move($tempSprite . '.png', $filePath['mainFile']);
t3lib_div::unlink_tempfile($tempSprite . '.png');
if ($this->generateGIFCopy) {
t3lib_div::upload_copy_move($tempSprite . '.gif', $filePath['gifFile']);
t3lib_div::unlink_tempfile($tempSprite . '.gif');
}
}
示例12: main_autoFix
/**
* Mandatory autofix function
* Will run auto-fix on the result array. Echos status during processing.
*
* @param array Result array from main() function
* @return void
*/
function main_autoFix($resultArray)
{
foreach ($resultArray['multipleReferencesList'] as $key => $value) {
$absFileName = t3lib_div::getFileAbsFileName($key);
if ($absFileName && @is_file($absFileName)) {
echo 'Processing file: ' . $key . LF;
$c = 0;
foreach ($value as $hash => $recReference) {
if ($c == 0) {
echo ' Keeping ' . $key . ' for record "' . $recReference . '"' . LF;
} else {
// Create unique name for file:
$fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$newName = $fileFunc->getUniqueName(basename($key), dirname($absFileName));
echo ' Copying ' . $key . ' to ' . substr($newName, strlen(PATH_site)) . ' for record "' . $recReference . '": ';
if ($bypass = $this->cli_noExecutionCheck($recReference)) {
echo $bypass;
} else {
t3lib_div::upload_copy_move($absFileName, $newName);
clearstatcache();
if (@is_file($newName)) {
$sysRefObj = t3lib_div::makeInstance('t3lib_refindex');
$error = $sysRefObj->setReferenceValue($hash, basename($newName));
if ($error) {
echo ' ERROR: t3lib_refindex::setReferenceValue(): ' . $error . LF;
exit;
} else {
echo "DONE";
}
} else {
echo ' ERROR: File "' . $newName . '" was not created!';
}
}
echo LF;
}
$c++;
}
} else {
echo ' ERROR: File "' . $absFileName . '" was not found!';
}
}
}
示例13: addImage
/**
* add Image
*
* @param $name boolean
* @return string
*/
private function addImage($name = "event")
{
if ($_FILES['tx_nboevents_events']) {
$basicFileFunctions = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$fileName = $basicFileFunctions->getUniqueName($_FILES['tx_nboevents_events']['name'][$name]['images'], t3lib_div::getFileAbsFileName('uploads/tx_nboevents/'));
t3lib_div::upload_copy_move($_FILES['tx_nboevents_events']['tmp_name'][$name]['images'], $fileName);
return basename($fileName);
}
}
示例14: func_upload
/**
* Upload of files (action=1)
*
* @param array $cmds['data'] is the ID-number (points to the global var that holds the filename-ref ($_FILES['upload_'.$id]['name']). $cmds['target'] is the target directory, $cmds['charset'] is the the character set of the file name (utf-8 is needed for JS-interaction)
* @return string Returns the new filename upon success
*/
function func_upload($cmds)
{
if (!$this->isInit) {
return FALSE;
}
$id = $cmds['data'];
if ($_FILES['upload_' . $id]['name']) {
$theFile = $_FILES['upload_' . $id]['tmp_name'];
// filename of the uploaded file
$theFileSize = $_FILES['upload_' . $id]['size'];
// filesize of the uploaded file
$theName = $this->cleanFileName(stripslashes($_FILES['upload_' . $id]['name']), isset($cmds['charset']) ? $cmds['charset'] : '');
// The original filename
if (is_uploaded_file($theFile) && $theName) {
// Check the file
if ($this->actionPerms['uploadFile']) {
if ($theFileSize < $this->maxUploadFileSize * 1024) {
$fI = t3lib_div::split_fileref($theName);
$theTarget = $this->is_directory($cmds['target']);
// Check the target dir
if ($theTarget && $this->checkPathAgainstMounts($theTarget . '/')) {
if ($this->checkIfAllowed($fI['fileext'], $theTarget, $fI['file'])) {
$theNewFile = $this->getUniqueName($theName, $theTarget, $this->dontCheckForUnique);
if ($theNewFile) {
t3lib_div::upload_copy_move($theFile, $theNewFile);
clearstatcache();
if (@is_file($theNewFile)) {
$this->internalUploadMap[$id] = $theNewFile;
$this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', array($theName, $theNewFile, $id));
return $theNewFile;
} else {
$this->writelog(1, 1, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', array($theTarget . '/'));
}
} else {
$this->writelog(1, 1, 101, 'No unique filename available in "%s"!', array($theTarget . '/'));
}
} else {
$this->writelog(1, 1, 102, 'Extension of file name "%s" is not allowed in "%s"!', array($fI['file'], $theTarget . '/'));
}
} else {
$this->writelog(1, 1, 103, 'Destination path "%s" was not within your mountpoints!', array($theTarget . '/'));
}
} else {
$this->writelog(1, 1, 104, 'The uploaded file exceeds the size-limit of %s bytes', array($this->maxUploadFileSize * 1024));
}
} else {
$this->writelog(1, 1, 105, 'You are not allowed to upload files!', '');
}
} else {
$this->writelog(1, 2, 106, 'The upload has failed, no uploaded file found!', '');
}
} else {
$this->writelog(1, 2, 108, 'No file was uploaded!', '');
}
}
示例15: displayDetail
/**
* The function to display the detailview of one job
*
* @param bool $applyOnly Show only the apply form?
* @return string The content that is displayed on the website
*/
function displayDetail($applyOnly = false)
{
if (isset($this->piVars['ref']) && $this->piVars['ref']) {
// Find the job_uid by searching the reference number
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dmmjobcontrol_job', 'reference=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['ref'], 'tx_dmmjobcontrol_job') . ' AND ' . $this->whereAdd);
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->piVars['job_uid'] = $row['uid'];
}
}
if (isset($this->piVars['job_uid']) && $this->piVars['job_uid']) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dmmjobcontrol_job', 'uid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['job_uid'], 'tx_dmmjobcontrol_job') . ' AND ' . $this->whereAdd);
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// This sets the jobtitle as the page title (also for use in indexed search results)
if (isset($this->conf['substitutePageTitle']) && $this->conf['substitutePageTitle']) {
$GLOBALS['TSFE']->indexedDocTitle = $row['job_title'];
$GLOBALS['TSFE']->page['title'] = $row['job_title'];
$this->cObj->LOAD_REGISTER(array('JOBTITLE' => $row['job_title']), '');
$this->cObj->LOAD_REGISTER(array('JOBLOCATION' => $row['location']), '');
}
// Which fields are required?
if (isset($this->conf['apply.']['required']) && $this->conf['apply.']['required']) {
$this->requiredFields = t3lib_div::trimExplode(',', $this->conf['apply.']['required']);
}
// Get all the labels and job data
$labels = $this->getLabels();
$jobData = $this->getJobData($row);
if (isset($this->conf['hide_empty']) && $this->conf['hide_empty']) {
$markerArray = $this->hideEmpty($labels, $jobData, $row);
} else {
$markerArray = $labels + $jobData;
}
// Process the apply form: send out email
if (isset($this->piVars['apply_submit']) && ($applyOnly || $this->conf['apply.']['form'] != 0)) {
// Get the apply templates
$this->templateCode = $this->cObj->fileResource($this->conf['template.']['apply']);
if (is_null($this->templateCode)) {
return $this->pi_getLL('template_not_found');
}
// Spamblock?
if (isset($this->conf['apply.']['spamblock']) && $this->conf['apply.']['spamblock']) {
$session = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->prefixId);
if (!is_array($session['spamblock']) || !$this->piVars['sessioncheck'] || !in_array($this->piVars['sessioncheck'], $session['spamblock'])) {
$template['thanks'] = $this->cObj->getSubpart($this->templateCode, '###APPLY_THANKS_TEMPLATE###');
return $this->cObj->substituteMarkerArrayCached($template['thanks'], $markerArray);
}
}
// TODO: server-side check for $this->requiredFields
// Extend the markerArray with the posted values
$markerArray['###FULLNAME_VALUE###'] = $this->piVars['apply']['fullname'];
$markerArray['###EMAIL_VALUE###'] = $this->piVars['apply']['email'];
$markerArray['###MOTIVATION_VALUE###'] = $this->piVars['apply']['motivation'];
if (isset($this->conf['htmlmail']) && $this->conf['htmlmail']) {
$markerArray['###MOTIVATION_VALUE###'] = nl2br($this->piVars['apply']['motivation']);
}
// Extend the markerArray with user function?
if (isset($this->conf['applyArrayFunction']) && $this->conf['applyArrayFunction']) {
$funcConf = $this->conf['applyArrayFunction.'];
$funcConf['parent'] =& $this;
$markerArray = $this->cObj->callUserFunction($this->conf['applyArrayFunction'], $funcConf, $markerArray);
}
$subject = $this->pi_getLL('apply_email_subject') . $row['job_title'];
// HTML email body
$template['htmlEmail'] = $this->cObj->getSubpart($this->templateCode, '###HTML_EMAIL_TEMPLATE###');
$htmlBody = $this->cObj->substituteMarkerArrayCached($template['htmlEmail'], $markerArray);
// Plain text email boby
$template['textEmail'] = $this->cObj->getSubpart($this->templateCode, '###TEXT_EMAIL_TEMPLATE###');
$textBody = $this->cObj->substituteMarkerArrayCached($template['textEmail'], $markerArray);
// The uploaded files
$html_attachments = array();
$text_attachments = array();
if (isset($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file']) && $_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file']) {
if (isset($this->conf['apply.']['allowed_file_extensions']) && $this->conf['apply.']['allowed_file_extensions']) {
$allowed_file_extensions = $this->conf['apply.']['allowed_file_extensions'];
} else {
$allowed_file_extensions = 'doc,docx,pdf,odt,sxw,rtf';
}
foreach ($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file'] as $index => $name) {
if ($name) {
$fileInfo = pathinfo($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file'][$index]);
if (t3lib_div::inList($allowed_file_extensions, strtolower($fileInfo['extension'])) && t3lib_div::verifyFilenameAgainstDenyPattern($name)) {
$source = $_FILES['tx_dmmjobcontrol_pi1']['tmp_name']['apply']['file'][$index];
$destination = PATH_site . 'typo3temp/' . $fileInfo['basename'];
t3lib_div::upload_copy_move($source, $destination);
$html_attachments[] = $destination;
$text_attachments[] = $GLOBALS['TSFE']->baseUrlWrap('typo3temp/' . $fileInfo['basename']);
} else {
$htmlBody .= '<p><i>The uploaded file "' . $fileInfo['basename'] . '" was not attached because it was not in a valid file format.</i></p>';
$textBody .= "\n\nThe uploaded file " . $fileInfo['basename'] . " was not attached because it was not in a valid file format.";
}
}
}
}
// Is there a contact person added to the job?
if ($row['contact']) {
//.........这里部分代码省略.........