ТЕМА закрыта... Все решил сам... Заменяем весь код в файле /administrator/components/com_media/controllers/file.php на код ниже, в тотже каталог ложим файл watermark.png Функция накладывает watemark(по центру) только на картинки с расширением .jpg которые больше по высоте и ширене чем watermark.png мне этого хватает кто хочет пусь експерементирует... сюда кому чего нежалко R229815771129 Z404492136425 ....... Код (CODE): <?php /** * @version $Id: file.php 14401 2010-01-26 14:10:00Z louis $ * @package Joomla * @subpackage Content * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant to the * GNU General Public License, and as distributed it includes or is derivative * of works licensed under the GNU General Public License or other free or open * source software licenses. See COPYRIGHT.php for copyright notices and * details. */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die( 'Restricted access' ); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); /** * Weblinks Weblink Controller * * @package Joomla * @subpackage Weblinks * @since 1.5 */ class MediaControllerFile extends MediaController { /** * Upload a file * * @since 1.5 */ function upload() { global $mainframe; // Check for request forgeries JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); $file = JRequest::getVar( 'Filedata', '', 'files', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path' ); $format = JRequest::getVar( 'format', 'html', '', 'cmd'); $return = JRequest::getVar( 'return-url', null, 'post', 'base64' ); $err = null; // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Make the filename safe jimport('joomla.filesystem.file'); $file['name'] = JFile::makeSafe($file['name']); if (isset($file['name'])) { $filepath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.strtolower($file['name'])); function waterMark($original, $out, $watermark) { $znak_hw = getimagesize($watermark); $foto_hw = getimagesize($original); $znak = imagecreatefrompng ($watermark); $foto = imagecreatefromjpeg ($original); if ($foto_hw[0] > $znak_hw[0] and $foto_hw[1] > $znak_hw[1]) imagecopy ($foto,$znak, (($foto_hw[0]/2) - ($znak_hw[0]/2)), (($foto_hw[1]/2) - ($znak_hw[1]/2)), 0, 0, $znak_hw[0], $znak_hw[1]); imagejpeg ($foto, $out, "100"); imagedestroy ($znak); imagedestroy ($foto); } $watermark = JPATH_SITE . DS .'administrator'. DS .'components'. DS .'com_media'. DS .'controllers'. DS .'watermark.png'; if (strtolower(JFile::getExt($file['name'])) == 'jpg') waterMark($file['tmp_name'], $file['tmp_name'], $watermark); if (!MediaHelper::canUpload( $file, $err )) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); header('HTTP/1.0 415 Unsupported Media Type'); jexit('Error. Unsupported Media Type!'); } else { JError::raiseNotice(100, JText::_($err)); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (JFile::exists($filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'File already exists: '.$filepath)); header('HTTP/1.0 409 Conflict'); jexit('Error. File already exists'); } else { JError::raiseNotice(100, JText::_('Error. File already exists')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (!JFile::upload($file['tmp_name'], $filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); header('HTTP/1.0 400 Bad Request'); jexit('Error. Unable to upload file'); } else { JError::raiseWarning(100, JText::_('Error. Unable to upload file')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } else { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance(); $log->addEntry(array('comment' => $folder)); jexit('Upload complete'); } else { $mainframe->enqueueMessage(JText::_('Upload complete')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } } else { $mainframe->redirect('index.php', 'Invalid Request', 'error'); } } /** * Deletes paths from the current path * * @param string $listFolder The image directory to delete a file from * @since 1.5 */ function delete() { global $mainframe; JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Get some data from the request $tmpl = JRequest::getCmd( 'tmpl' ); $paths = JRequest::getVar( 'rm', array(), '', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path'); // Initialize variables $msg = array(); $ret = true; if (count($paths)) { foreach ($paths as $path) { if ($path !== JFile::makeSafe($path)) { JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); continue; } $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path); if (is_file($fullPath)) { $ret |= !JFile::delete($fullPath); } else if (is_dir($fullPath)) { $files = JFolder::files($fullPath, '.', true); $canDelete = true; foreach ($files as $file) { if ($file != 'index.html') { $canDelete = false; } } if ($canDelete) { $ret |= !JFolder::delete($fullPath); } else { JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!')); } } } } if ($tmpl == 'component') { // We are inside the iframe $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); } else { $mainframe->redirect('index.php?option=com_media&folder='.$folder); } } }
$file['tmp_name'] это файл-картинка который мы загружаем... Вообще это выглядит так: Код (CODE): <?php /** * @version $Id: file.php 14401 2010-01-26 14:10:00Z louis $ * @package Joomla * @subpackage Content * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant to the * GNU General Public License, and as distributed it includes or is derivative * of works licensed under the GNU General Public License or other free or open * source software licenses. See COPYRIGHT.php for copyright notices and * details. */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die( 'Restricted access' ); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); /** * Weblinks Weblink Controller * * @package Joomla * @subpackage Weblinks * @since 1.5 */ class MediaControllerFile extends MediaController { /** * Upload a file * * @since 1.5 */ function upload() { global $mainframe; // Check for request forgeries JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); $file = JRequest::getVar( 'Filedata', '', 'files', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path' ); $format = JRequest::getVar( 'format', 'html', '', 'cmd'); $return = JRequest::getVar( 'return-url', null, 'post', 'base64' ); $err = null; // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Make the filename safe jimport('joomla.filesystem.file'); $file['name'] = JFile::makeSafe($file['name']); if (isset($file['name'])) { $filepath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.strtolower($file['name'])); ?> Где то сдесь мы прикручиваем думаю то неважно: Код (CODE): <?php function waterMark($original, $watermark, $placement = 'bottom=5,right=5', $destination = null) { $info_o = @getImageSize($original); if (!$info_o) return false; $info_w = @getImageSize($watermark); if (!$info_w) return false; list ($vertical, $horizontal) = split(',', $placement,2); list($vertical, $sy) = split('=', trim($vertical),2); list($horizontal, $sx) = split('=', trim($horizontal),2); switch (trim($vertical)) { case 'bottom': $y = $info_o[1] - $info_w[1] - (int)$sy; break; case 'middle': $y = ceil($info_o[1]/2) - ceil($info_w[1]/2) + (int)$sy; break; default: $y = (int)$sy; break; } switch (trim($horizontal)) { case 'right': $x = $info_o[0] - $info_w[0] - (int)$sx; break; case 'center': $x = ceil($info_o[0]/2) - ceil($info_w[0]/2) + (int)$sx; break; default: $x = (int)$sx; break; } header("Content-Type: ".$info_o['mime']); $original = @imageCreateFromString(file_get_contents($original)); $watermark = @imageCreateFromString(file_get_contents($watermark)); $out = imageCreateTrueColor($info_o[0],$info_o[1]); imageCopy($out, $original, 0, 0, 0, 0, $info_o[0], $info_o[1]); if( ($info_o[0] > 250) && ($info_o[1] > 250) ) { imageCopy($out, $watermark, $x, $y, 0, 0, $info_w[0], $info_w[1]); } switch ($info_o[2]) { case 1: imageGIF($out); break; case 2: imageJPEG($out); break; case 3: imagePNG($out); break; } imageDestroy($out); imageDestroy($original); imageDestroy($watermark); return true; } waterMark($file['tmp_name'], $watermark=JPATH_SITE . DS .'watermark.png', $placement = 'bottom=5,right=5', $destination = null); ?> продолжение Код (CODE): <?php if (!MediaHelper::canUpload( $file, $err )) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); header('HTTP/1.0 415 Unsupported Media Type'); jexit('Error. Unsupported Media Type!'); } else { JError::raiseNotice(100, JText::_($err)); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (JFile::exists($filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'File already exists: '.$filepath)); header('HTTP/1.0 409 Conflict'); jexit('Error. File already exists'); } else { JError::raiseNotice(100, JText::_('Error. File already exists')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } if (!JFile::upload($file['tmp_name'], $filepath)) { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); header('HTTP/1.0 400 Bad Request'); jexit('Error. Unable to upload file'); } else { JError::raiseWarning(100, JText::_('Error. Unable to upload file')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } else { if ($format == 'json') { jimport('joomla.error.log'); $log = &JLog::getInstance(); $log->addEntry(array('comment' => $folder)); jexit('Upload complete'); } else { $mainframe->enqueueMessage(JText::_('Upload complete')); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return).'&folder='.$folder); } return; } } } else { $mainframe->redirect('index.php', 'Invalid Request', 'error'); } } /** * Deletes paths from the current path * * @param string $listFolder The image directory to delete a file from * @since 1.5 */ function delete() { global $mainframe; JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Get some data from the request $tmpl = JRequest::getCmd( 'tmpl' ); $paths = JRequest::getVar( 'rm', array(), '', 'array' ); $folder = JRequest::getVar( 'folder', '', '', 'path'); // Initialize variables $msg = array(); $ret = true; if (count($paths)) { foreach ($paths as $path) { if ($path !== JFile::makeSafe($path)) { JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); continue; } $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path); if (is_file($fullPath)) { $ret |= !JFile::delete($fullPath); } else if (is_dir($fullPath)) { $files = JFolder::files($fullPath, '.', true); $canDelete = true; foreach ($files as $file) { if ($file != 'index.html') { $canDelete = false; } } if ($canDelete) { $ret |= !JFolder::delete($fullPath); } else { JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!')); } } } } if ($tmpl == 'component') { // We are inside the iframe $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); } else { $mainframe->redirect('index.php?option=com_media&folder='.$folder); } } } ?>
из этого следует, что в параметрах (по умолчанию) функции написано от низа отступ 5 пикселей и от правого края то же 5 пикселей внимательнее смотри в код!!!!!!
up up up up Вот скрипт. Для того чтобы установить необходимо залить папку watermark в корень сайта а файл .htaccess в папку с изображениями на которые вы хотите чтобы накладывался водяной знак. Кто знает как сделать его по центру?