本文整理汇总了PHP中acymailing_createDir函数的典型用法代码示例。如果您正苦于以下问题:PHP acymailing_createDir函数的具体用法?PHP acymailing_createDir怎么用?PHP acymailing_createDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acymailing_createDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
function store()
{
JRequest::checkToken() or die('Invalid Token');
$plugin = JRequest::getString('plugin');
$plugin = preg_replace('#[^a-zA-Z0-9]#Uis', '', $plugin);
$body = JRequest::getVar('templatebody', '', '', 'string', JREQUEST_ALLOWRAW);
if (empty($body)) {
acymailing_display(JText::_('FILL_ALL'), 'error');
return;
}
$pluginsFolder = ACYMAILING_MEDIA . 'plugins';
if (!file_exists($pluginsFolder)) {
acymailing_createDir($pluginsFolder);
}
try {
jimport('joomla.filesystem.file');
$status = JFile::write($pluginsFolder . DS . $plugin . '.php', $body);
} catch (Exception $e) {
$status = false;
}
if ($status) {
acymailing_display(JText::_('JOOMEXT_SUCC_SAVED'), 'success');
} else {
acymailing_display(JText::sprintf('FAIL_SAVE', $pluginsFolder . DS . $plugin . '.php'), 'error');
}
}
示例2: resizePictures
function resizePictures($input)
{
$this->destination = ACYMAILING_MEDIA . 'resized' . DS;
acymailing_createDir($this->destination);
$content = acymailing_absoluteURL($input);
preg_match_all('#<img([^>]*)>#Ui', $content, $results);
if (empty($results[1])) {
return $input;
}
$replace = array();
foreach ($results[1] as $onepicture) {
if (strpos($onepicture, 'donotresize') !== false) {
continue;
}
if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) {
continue;
}
$imageUrl = $path[1];
$base = str_replace(array('http://www.', 'https://www.', 'http://', 'https://'), '', ACYMAILING_LIVE);
$replacements = array('https://www.' . $base, 'http://www.' . $base, 'https://' . $base, 'http://' . $base);
foreach ($replacements as $oneReplacement) {
if (strpos($imageUrl, $oneReplacement) === false) {
continue;
}
$imageUrl = str_replace(array($oneReplacement, '/'), array(ACYMAILING_ROOT, DS), urldecode($imageUrl));
break;
}
$newPicture = $this->generateThumbnail($imageUrl);
if (!$newPicture) {
$newDimension = 'max-width:' . $this->maxWidth . 'px;max-height:' . $this->maxHeight . 'px;';
if (strpos($onepicture, 'style="') !== false) {
$replace[$onepicture] = preg_replace('#style="([^"]*)"#Uis', 'style="' . $newDimension . '$1"', $onepicture);
} else {
$replace[$onepicture] = ' style="' . $newDimension . '" ' . $onepicture;
}
continue;
}
$newPicture['file'] = preg_replace('#^' . preg_quote(ACYMAILING_ROOT, '#') . '#i', ACYMAILING_LIVE, $newPicture['file']);
$newPicture['file'] = str_replace(DS, '/', $newPicture['file']);
$replaceImage = array();
$replaceImage[$path[1]] = $newPicture['file'];
if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) {
foreach ($resultsSize[0] as $i => $oneArg) {
$newVal = strtolower($resultsSize[1][$i]) == 'width' ? $newPicture['width'] : $newPicture['height'];
if ($newVal > $resultsSize[3][$i]) {
continue;
}
$replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg);
}
}
$replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture);
}
if (!empty($replace)) {
$input = str_replace(array_keys($replace), $replace, $content);
}
return $input;
}
示例3: resizePictures
function resizePictures($input)
{
$this->destination = ACYMAILING_MEDIA . 'resized' . DS;
acymailing_createDir($this->destination);
$content = acymailing_absoluteURL($input);
preg_match_all('#<img([^>]*)>#Ui', $content, $results);
if (empty($results[1])) {
return $input;
}
$replace = array();
foreach ($results[1] as $onepicture) {
if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) {
continue;
}
$imageUrl = $path[1];
$otheracymailinglive = str_replace('http://www.', 'http://', ACYMAILING_LIVE);
if ($otheracymailinglive == ACYMAILING_LIVE) {
$otheracymailinglive = str_replace('http://', 'http://www.', ACYMAILING_LIVE);
}
if (strpos($imageUrl, ACYMAILING_LIVE) !== false || strpos($imageUrl, $otheracymailinglive) !== false) {
$imageUrl = str_replace(array(ACYMAILING_LIVE, $otheracymailinglive, '/'), array(ACYMAILING_ROOT, ACYMAILING_ROOT, DS), urldecode($imageUrl));
}
$newPicture = $this->generateThumbnail($imageUrl);
if (!$newPicture) {
continue;
}
$newPicture['file'] = str_replace(array(ACYMAILING_ROOT, DS), array(ACYMAILING_LIVE, '/'), $newPicture['file']);
$replaceImage = array();
$replaceImage[$path[1]] = $newPicture['file'];
if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) {
foreach ($resultsSize[0] as $i => $oneArg) {
$newVal = strtolower($resultsSize[1][$i]) == 'width' ? $newPicture['width'] : $newPicture['height'];
if ($newVal > $resultsSize[3][$i]) {
continue;
}
$replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg);
}
}
$replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture);
}
if (!empty($replace)) {
$input = str_replace(array_keys($replace), $replace, $content);
}
return $input;
}
示例4: _convertbase64pictures
private function _convertbase64pictures(&$html)
{
if (!preg_match_all('#<img[^>]*src=("data:image/([^;]{1,5});base64[^"]*")([^>]*)>#Uis', $html, $resultspictures)) {
return;
}
jimport('joomla.filesystem.file');
$dest = ACYMAILING_MEDIA . 'resized' . DS;
acymailing_createDir($dest);
foreach ($resultspictures[2] as $i => $extension) {
$pictname = md5($resultspictures[1][$i]) . '.' . $extension;
$picturl = ACYMAILING_LIVE . 'media/' . ACYMAILING_COMPONENT . '/resized/' . $pictname;
$pictPath = $dest . $pictname;
$pictCode = trim($resultspictures[1][$i], '"');
if (file_exists($pictPath)) {
$html = str_replace($pictCode, $picturl, $html);
continue;
}
$getfunction = '';
switch ($extension) {
case 'gif':
$getfunction = 'ImageCreateFromGIF';
break;
case 'jpg':
case 'jpeg':
$getfunction = 'ImageCreateFromJPEG';
break;
case 'png':
$getfunction = 'ImageCreateFromPNG';
break;
}
if (empty($getfunction) || !function_exists($getfunction)) {
continue;
}
$img = $getfunction($pictCode);
if (in_array($extension, array('gif', 'png'))) {
imagealphablending($img, false);
imagesavealpha($img, true);
}
ob_start();
switch ($extension) {
case 'gif':
$status = imagegif($img);
break;
case 'jpg':
case 'jpeg':
$status = imagejpeg($img, null, 100);
break;
case 'png':
$status = imagepng($img, null, 0);
break;
}
$imageContent = ob_get_clean();
$status = $status && JFile::write($pictPath, $imageContent);
if (!$status) {
continue;
}
$html = str_replace($pictCode, $picturl, $html);
}
}
示例5: uploadThumbnail
function uploadThumbnail(&$element)
{
$config =& acymailing_config();
$app = JFactory::getApplication();
$files = JRequest::getVar('pictures', array(), 'files', 'array');
if (empty($files)) {
return;
}
jimport('joomla.filesystem.file');
$uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
$uploadFolder = trim($uploadFolder, DS . ' ') . DS;
$uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
acymailing_createDir($uploadPath, true);
if (!is_writable($uploadPath)) {
@chmod($uploadPath, '0755');
if (!is_writable($uploadPath)) {
$app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
}
}
$allowedExtensions = array('jpg', 'gif', 'png', 'jpeg', 'ico', 'bmp');
foreach ($files['name'] as $id => $filename) {
if (empty($filename)) {
continue;
}
$extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
if (!in_array($extension, $allowedExtensions)) {
$app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $extension, implode(', ', $allowedExtensions)), 'notice');
continue;
}
$pictname = strtolower(substr(JFile::makeSafe($filename), 0, strrpos($filename, '.') + 1));
$pictname = preg_replace('#[^0-9a-z]#i', '_', $pictname);
$pictfullname = $pictname . '.' . $extension;
if (file_exists($uploadPath . $pictfullname)) {
$pictfullname = $pictname . time() . '.' . $extension;
}
if (!JFile::upload($files['tmp_name'][$id], $uploadPath . $pictfullname)) {
if (!move_uploaded_file($files['tmp_name'][$id], $uploadPath . $pictfullname)) {
$app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', '<b><i>' . $files['tmp_name'][$id] . '</i></b>', '<b><i>' . $uploadPath . $pictfullname . '</i></b>'), 'error');
continue;
}
}
$pictureField = str_replace(DS, '/', $uploadFolder) . $pictfullname;
if (!empty($pictureField)) {
$element->{$id} = $pictureField;
}
}
}
示例6: saveForm
function saveForm()
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$config =& acymailing_config();
$mail = new stdClass();
$mail->mailid = acymailing_getCID('mailid');
$formData = JRequest::getVar('data', array(), '', 'array');
foreach ($formData['mail'] as $column => $value) {
if ($app->isAdmin() or in_array($column, $this->allowedFields)) {
acymailing_secureField($column);
if ($column == 'params') {
$mail->{$column} = $value;
} else {
$mail->{$column} = strip_tags($value, '<ADV>');
}
}
}
$mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
$acypluginsHelper = acymailing_get('helper.acyplugins');
$acypluginsHelper->cleanHtml($mail->body);
$mail->attach = array();
$attachments = JRequest::getVar('attachments', array(), 'files', 'array');
if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) {
jimport('joomla.filesystem.file');
$uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
$uploadFolder = trim($uploadFolder, DS . ' ') . DS;
$uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
acymailing_createDir($uploadPath, true);
if (!is_writable($uploadPath)) {
@chmod($uploadPath, '0755');
if (!is_writable($uploadPath)) {
$app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
}
}
foreach ($attachments['name'] as $id => $filename) {
if (empty($filename)) {
continue;
}
$attachment = new stdClass();
$attachment->filename = strtolower(JFile::makeSafe($filename));
$attachment->size = $attachments['size'][$id];
if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) {
$app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice');
continue;
}
$attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
if (!JFile::upload($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
$app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', '<b><i>' . $attachments['tmp_name'][$id] . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>'), 'error');
continue;
}
}
$mail->attach[] = $attachment;
}
}
if (isset($mail->filter)) {
$mail->filter = array();
$filterData = JRequest::getVar('filter');
foreach ($filterData['type'] as $num => $oneType) {
if (empty($oneType)) {
continue;
}
$mail->filter['type'][$num] = $oneType;
$mail->filter[$num][$oneType] = $filterData[$num][$oneType];
}
}
$toggleHelper = acymailing_get('helper.toggle');
if (!empty($mail->type) && $mail->type == 'followup' && !empty($mail->mailid)) {
$oldMail = $this->get($mail->mailid);
if (!empty($mail->published) and !$oldMail->published) {
$this->_publishfollowup($mail);
}
if ($oldMail->senddate != $mail->senddate) {
$text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED');
$text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY'));
$app->enqueueMessage($text, 'notice');
}
}
if (preg_match('#<a[^>]*subid=[0-9].*</a>#Uis', $mail->body, $pregResult)) {
$app->enqueueMessage('There is a personal link in your Newsletter ( ' . $pregResult[0] . ' ) instead of a tag...<br/>Please make sure to not copy/paste the link you received in your e-mail as it may break your unsubscribe or confirmation links.<br/>Use our tags instead!', 'notice');
}
$mailid = $this->save($mail);
if (!$mailid) {
return false;
}
JRequest::setVar('mailid', $mailid);
$status = true;
if (!empty($formData['listmail'])) {
$receivers = array();
$remove = array();
foreach ($formData['listmail'] as $listid => $receiveme) {
if (!empty($receiveme)) {
$receivers[] = $listid;
} else {
$remove[] = $listid;
}
}
$listMailClass = acymailing_get('class.listmail');
$status = $listMailClass->save($mailid, $receivers, $remove);
//.........这里部分代码省略.........
示例7: copyFolder
function copyFolder($from, $to)
{
$return = true;
$allFiles = JFolder::files($from);
foreach ($allFiles as $oneFile) {
if (file_exists($to . DS . 'index.html') and $oneFile == 'index.html') {
continue;
}
if (JFile::copy($from . DS . $oneFile, $to . DS . $oneFile) !== true) {
$this->errors[] = 'Could not copy the file from ' . $from . DS . $oneFile . ' to ' . $to . DS . $oneFile;
$return = false;
}
if (ACYMAILING_J30 && substr($oneFile, -4) == '.xml') {
$data = file_get_contents($to . DS . $oneFile);
if (strpos($data, '<install ') !== false) {
$data = str_replace(array('<install ', '</install>', 'version="1.5"', '<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/plugin-install.dtd">'), array('<extension ', '</extension>', 'version="2.5"', ''), $data);
JFile::write($to . DS . $oneFile, $data);
}
}
}
$allFolders = JFolder::folders($from);
if (!empty($allFolders)) {
foreach ($allFolders as $oneFolder) {
if (!acymailing_createDir($to . DS . $oneFolder)) {
continue;
}
if (!$this->copyFolder($from . DS . $oneFolder, $to . DS . $oneFolder)) {
$return = false;
}
}
}
return $return;
}
示例8: createDir
static function createDir($dir, $report = true)
{
return acymailing_createDir($dir, $report);
}
示例9: handlepict
function handlepict(&$content, $templatepath)
{
$content = acymailing_absoluteURL($content);
if (!preg_match_all('#<img[^>]*src="([^"]*)"#i', $content, $pictures)) {
return true;
}
$pictFolder = rtrim($templatepath, DS) . DS . 'images';
if (!acymailing_createDir($pictFolder)) {
return false;
}
$replace = array();
foreach ($pictures[1] as $onePict) {
if (isset($replace[$onePict])) {
continue;
}
$location = str_replace(array(ACYMAILING_LIVE, '/'), array(ACYMAILING_ROOT, DS), $onePict);
if (strpos($location, 'http') === 0) {
continue;
}
if (!file_exists($location)) {
continue;
}
$filename = basename($location);
while (file_exists($pictFolder . DS . $filename)) {
$filename = rand(0, 99) . $filename;
}
if (JFile::copy($location, $pictFolder . DS . $filename) !== true) {
acymailing_display('Could not copy the file from ' . $location . ' to ' . $pictFolder . DS . $filename, 'error');
return false;
}
$replace[$onePict] = 'images/' . $filename;
}
$content = str_replace(array_keys($replace), $replace, $content);
return true;
}
示例10: _createUploadFolder
private function _createUploadFolder()
{
$folderPath = JPath::clean(ACYMAILING_ROOT . trim(html_entity_decode('media' . DS . 'com_acymailing' . DS . 'import'))) . DS;
if (!is_dir($folderPath)) {
acymailing_createDir($folderPath, true, true);
}
if (!is_writable($folderPath)) {
@chmod($folderPath, '0755');
if (!is_writable($folderPath)) {
acymailing_enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $folderPath), 'notice');
}
}
return $folderPath;
}
示例11: _displayHTML
private function _displayHTML()
{
$app = JFactory::getApplication();
$mediaFolders = acymailing_getFilesFolder('media', true);
$receivedFolder = $app->getUserStateFromRequest(ACYMAILING_COMPONENT . ".acyeditor.selected_folder", 'selected_folder', '', 'string');
$defaultFolder = reset($mediaFolders);
if (!empty($receivedFolder)) {
$allowed = false;
foreach ($mediaFolders as $oneMedia) {
if (preg_match('#^' . preg_quote(rtrim($oneMedia, '/')) . '[a-z_0-9\\-/]*$#i', $receivedFolder)) {
$allowed = true;
break;
}
}
if ($allowed) {
$defaultFolder = $receivedFolder;
} else {
acymailing_display('You are not allowed to access this folder', 'error');
}
}
$uploadPath = JPath::clean(ACYMAILING_ROOT . trim(str_replace('/', DS, trim($defaultFolder)), DS));
$uploadedImage = JRequest::getVar('uploadedImage', array(), 'files', 'array');
if (!empty($uploadedImage)) {
if (!empty($uploadedImage['name'])) {
$this->imageName = acymailing_importFile($uploadedImage, $uploadPath, true);
if (!empty($this->imageName)) {
$uploadMessage = 'success';
} else {
$uploadMessage = 'error';
}
} else {
$uploadMessage = 'error';
$this->message = JText::_('BROWSE_FILE');
}
}
$pictToDelete = JRequest::getString('pictName', '');
if (!empty($pictToDelete) && file_exists($uploadPath . DS . $pictToDelete) && empty($uploadedImage)) {
$db = JFactory::getDBO();
$db->setQuery('SELECT mailid FROM #__acymailing_mail WHERE body LIKE \'%src="' . ACYMAILING_LIVE . $defaultFolder . '/' . $pictToDelete . '"%\'');
$checkPictNews = acymailing_loadResultArray($db);
$db->setQuery('SELECT tempid FROM #__acymailing_template WHERE body LIKE \'%src="' . ACYMAILING_LIVE . $defaultFolder . '/' . $pictToDelete . '"%\'');
$checkPictTemplate = acymailing_loadResultArray($db);
if (!empty($checkPictNews) || !empty($checkPictTemplate)) {
foreach ($checkPictNews as $k => $oneNews) {
$checkPictNews[$k] = '<a href="" onclick="window.parent.document.location.href=\'' . acymailing_completeLink(($app->isAdmin() ? '' : 'front') . 'newsletter&task=edit&mailid=' . $oneNews) . '\'">' . $oneNews . '</a>';
}
if ($app->isAdmin()) {
foreach ($checkPictTemplate as $k => $oneTmpl) {
$checkPictTemplate[$k] = '<a href="" onclick="window.parent.document.location.href=\'' . acymailing_completeLink('template&task=edit&tempid=' . $oneTmpl) . '\'">' . $oneTmpl . '</a>';
}
}
acymailing_display(JText::sprintf('ACY_CANT_DELETE', !empty($checkPictNews) ? implode($checkPictNews, ', ') : '-', !empty($checkPictTemplate) ? implode($checkPictTemplate, ', ') : '-'), 'error');
} else {
if (JFile::delete($uploadPath . DS . $pictToDelete)) {
acymailing_display(JText::_('ACY_DELETED_PICT_SUCCESS'), 'success');
} else {
acymailing_display(JText::_('ACY_DELETED_PICT_ERROR'), 'error');
}
}
}
?>
<div id="acy_media_browser">
<!-- <br style="font-size:1px"/> -->
<table id="acy_media_browser_table" style="height:420px;">
<tr>
<td style="width:65%; vertical-align:top;">
<?php
$folders = acymailing_generateArborescence($mediaFolders);
foreach ($folders as $folder) {
$this->values[] = JHTML::_('select.option', $folder, $folder);
}
echo '<div style="display:inline-block;width:100%;">';
echo '<form method="post" action="index.php?option=com_acymailing&ctrl=' . (JFactory::getApplication()->isAdmin() ? '' : 'front') . 'editor&task=createFolder" >';
echo '<div id="acy_media_browser_path_dropdown" >';
echo JHTML::_('select.genericlist', $this->values, 'acy_media_browser_files_path', 'class="inputbox chzn-done" size="1" onchange="changeFolder(this.value)" style="width:350px; min-height:19px;" ', 'value', 'text', $defaultFolder) . '<br />';
echo '</div>';
echo '<div id="acy_media_browser_global_create_folder" >';
echo '<div id="acy_media_browser_create_folder" >';
echo '<button id="create_folder_btn" class="btn" onclick="displayAppropriateField(this.id)" type="button" style="width:100%;" >' . JText::_('CREATE_FOLDER') . '</button>';
echo '</div>';
echo '<div id="acy_media_browser_area_create_folder" style=\'display:none;\'>';
echo '<input id="subFolderName" name="subFolderName" type="text" placeholder="' . JText::_('FOLDER_NAME') . '" name="text" required="required" />';
echo '<input type="submit" class="btn btn-primary" value="' . JText::_('ACY_APPLY') . '" />';
echo '</div>';
echo '</div>';
echo JHTML::_('form.token');
echo '</form>';
echo '</div>';
acymailing_createDir($uploadPath);
$files = JFolder::files($uploadPath);
echo '<ul id="acy_media_browser_list">';
if (!empty($uploadMessage) && !empty($this->message)) {
if ($uploadMessage == 'success') {
acymailing_display($this->message);
} elseif ($uploadMessage == 'error') {
acymailing_display($this->message, 'error');
}
}
$images = array();
//.........这里部分代码省略.........
示例12: _displayHTML
private function _displayHTML()
{
$config =& acymailing_config();
$message = '';
$mediaFolder = $config->get('mediafolder', 'media/com_acymailing/upload');
$mediaFolder = explode(',', $mediaFolder);
$receivedFolder = JRequest::getVar('selected_folder', array(), '', 'array');
if (!empty($receivedFolder)) {
$defaultFolder = $receivedFolder[0];
} else {
if (isset($mediaFolder[0])) {
$defaultFolder = $mediaFolder[0];
}
}
if (isset($defaultFolder)) {
$tempPath = trim($defaultFolder, DS . ' ') . DS;
$tempPath = JPath::clean($tempPath);
$uploadFolderTemp = array();
$uploadFolderTemp[0] = $tempPath;
$uploadFolderTemp = $this->_generateSpecificFolders($uploadFolderTemp);
$tempPath = $uploadFolderTemp[0];
$uploadPath = JPath::clean(ACYMAILING_ROOT . $tempPath);
$defaultFolder = $this->_generateSpecificFolders(array(), $defaultFolder);
$defaultFolder = trim($defaultFolder, DS . ' ');
} else {
$uploadPath = '';
}
$uploadedImage = JRequest::getVar('uploadedImage', array(), 'files', 'array');
if (!empty($uploadedImage)) {
if (!empty($uploadedImage['name'])) {
if ($this->_importImage($uploadedImage, $uploadPath)) {
$uploadMessage = 'success';
} else {
$uploadMessage = 'error';
}
} else {
$uploadMessage = 'error';
$this->message = JText::_('BROWSE_FILE');
}
}
?>
<div id="acy_media_browser" >
<!-- <br style="font-size:1px"/> -->
<table id="acy_media_browser_table" style="height:420px;">
<tr>
<td style="width:65%; vertical-align:top;">
<?php
$selectedFolder = $defaultFolder;
$scannedFolders = $this->_generateArborescence($mediaFolder);
$folders = $this->_mergeFoldersLists($scannedFolders, $mediaFolder);
$folders = $this->_generateSpecificFolders($folders);
$folders = array_unique($folders);
foreach ($folders as $folder) {
$this->values[] = JHTML::_('select.option', $folder, $folder);
}
echo '<div id="acy_media_browser_path_dropdown" >';
echo JHTML::_('select.genericlist', $this->values, 'acy_media_browser_files_path', 'class="inputbox chzn-done" size="1" onchange="changeFolder(this.value)" style="width:350px" ', 'value', 'text', $selectedFolder) . '<br/>';
echo '</div>';
acymailing_createDir($uploadPath);
$files = JFolder::files($uploadPath);
$defaultFolder = $defaultFolder . '/';
echo '<ul id="acy_media_browser_list">';
if (!empty($uploadMessage)) {
if ($uploadMessage == 'success') {
acymailing_display($this->message);
} else {
if ($uploadMessage == 'error') {
acymailing_display($this->message, 'error');
}
}
}
$images = array();
$imagesFound = false;
foreach ($files as $k => $file) {
if (strrpos($file, '.') === false) {
continue;
}
$ext = strtolower(substr($file, strrpos($file, '.') + 1));
$extensions = array('jpg', 'jpeg', 'png', 'gif');
if (!in_array($ext, $extensions)) {
continue;
}
$imagesFound = true;
$images[] = $file;
$imageSize = getimagesize($uploadPath . $file);
?>
<li id="acy_media_browser_images_<?php
echo $k;
?>
" style="position: relative; height: 135px; width:135px; display:inline-block; margin:14px; margin-top:7px; box-shadow: 0px 2px 2px 2px rgba(0, 0, 0, 0.2);" onmouseover="toggleImageInfo(<?php
echo $k;
?>
, 'display')" onmouseout="toggleImageInfo(<?php
echo $k;
?>
, 'hide')" >
<img id="acy_media_browser_image_<?php
echo $k;
?>
//.........这里部分代码省略.........
示例13: file
function file()
{
$app = JFactory::getApplication();
$importFile = JRequest::getVar('importfile', array(), 'files', 'array');
if (empty($importFile['name'])) {
$app->enqueueMessage(JText::_('BROWSE_FILE'), 'notice');
return false;
}
$fileError = $_FILES['importfile']['error'];
if ($fileError > 0) {
switch ($fileError) {
case 1:
acymailing_display('The uploaded file exceeds the upload_max_filesize directive in php configuration.', 'error');
return false;
case 2:
acymailing_display('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 'error');
return false;
case 3:
acymailing_display('The uploaded file was only partially uploaded.', 'error');
return false;
case 4:
acymailing_display('No file was uploaded.', 'error');
return false;
}
}
$this->forceconfirm = JRequest::getInt('import_confirmed');
$this->charsetConvert = JRequest::getString('charsetconvert', '');
$this->generatename = JRequest::getInt('generatename');
$this->overwrite = JRequest::getInt('overwriteexisting');
$this->importblocked = JRequest::getInt('importblocked');
jimport('joomla.filesystem.file');
$config =& acymailing_config();
$newConfig = new stdClass();
$newConfig->import_params_file = $this->forceconfirm . ',' . $this->generatename . ',' . $this->importblocked . ',' . $this->overwrite;
$paramTmp = array();
if ($this->forceconfirm == 1) {
$paramTmp[] = 'import_confirmed';
}
if ($this->generatename == 1) {
$paramTmp[] = 'generatename';
}
if ($this->overwrite == 1) {
$paramTmp[] = 'overwriteexisting';
}
if ($this->importblocked == 1) {
$paramTmp[] = 'importblocked';
}
$newConfig->import_params_file = implode(',', $paramTmp);
$config->save($newConfig);
$uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
$uploadFolder = trim($uploadFolder, DS . ' ') . DS;
$uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
acymailing_createDir($uploadPath);
if (!is_writable($uploadPath)) {
@chmod($uploadPath, '0755');
if (!is_writable($uploadPath)) {
$app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
}
}
$attachment = new stdClass();
$attachment->filename = strtolower(JFile::makeSafe($importFile['name']));
$attachment->size = $importFile['size'];
if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)$#Ui', $attachment->filename)) {
$app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice');
return false;
}
$attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
if (!JFile::upload($importFile['tmp_name'], $uploadPath . $attachment->filename)) {
if (!move_uploaded_file($importFile['tmp_name'], $uploadPath . $attachment->filename)) {
$app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', '<b><i>' . $importFile['tmp_name'] . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>'), 'error');
}
}
$contentFile = file_get_contents($uploadPath . $attachment->filename);
if (!$contentFile) {
$app->enqueueMessage(JText::sprintf('FAIL_OPEN', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>'), 'error');
return false;
}
unlink($uploadPath . $attachment->filename);
$toTest = array();
if (empty($this->charsetConvert)) {
$encodingHelper = acymailing_get('helper.encoding');
$this->charsetConvert = $encodingHelper->detectEncoding($contentFile);
}
$result = $this->_handleContent($contentFile);
$this->_displaySubscribedResult();
return $result;
}
示例14: cleanHtml
function cleanHtml(&$html)
{
$pregreplace = array();
$pregreplace['#<tr([^>"]*>([^<]*<td[^>]*>[ \\n\\s]*<img[^>]*>[ \\n\\s]*</ *td[^>]*>[ \\n\\s]*)*</ *tr)#Uis'] = '<tr style="line-height: 0px;" $1';
$pregreplace['#<td(((?!style|>).)*>[ \\n\\s]*(<a[^>]*>)?[ \\n\\s]*<img[^>]*>[ \\n\\s]*(</a[^>]*>)?[ \\n\\s]*</ *td)#Uis'] = '<td style="line-height: 0px;" $1';
$pregreplace['#<xml>.*</xml>#Uis'] = '';
$newbody = preg_replace(array_keys($pregreplace), $pregreplace, $html);
if (!empty($newbody)) {
$html = $newbody;
}
if (preg_match_all('#<img[^>]*src=("data:image/([^;]{1,5});base64[^"]*")([^>]*)>#Uis', $html, $resultspictures)) {
jimport('joomla.filesystem.file');
$dest = ACYMAILING_MEDIA . 'resized' . DS;
acymailing_createDir($dest);
foreach ($resultspictures[2] as $i => $extension) {
$pictname = md5($resultspictures[1][$i]) . '.' . $extension;
$picturl = ACYMAILING_LIVE . 'media/' . ACYMAILING_COMPONENT . '/resized/' . $pictname;
$pictPath = $dest . $pictname;
$pictCode = trim($resultspictures[1][$i], '"');
if (file_exists($pictPath)) {
$html = str_replace($pictCode, $picturl, $html);
continue;
}
$getfunction = '';
switch ($extension) {
case 'gif':
$getfunction = 'ImageCreateFromGIF';
break;
case 'jpg':
case 'jpeg':
$getfunction = 'ImageCreateFromJPEG';
break;
case 'png':
$getfunction = 'ImageCreateFromPNG';
break;
}
if (empty($getfunction) || !function_exists($getfunction)) {
continue;
}
$img = $getfunction($pictCode);
ob_start();
switch ($extension) {
case 'gif':
$status = imagegif($img);
break;
case 'jpg':
case 'jpeg':
$status = imagejpeg($img, null, 100);
break;
case 'png':
$status = imagepng($img, null, 0);
break;
}
$imageContent = ob_get_clean();
$status = $status && JFile::write($pictPath, $imageContent);
if (!$status) {
continue;
}
$html = str_replace($pictCode, $picturl, $html);
}
}
}
示例15: _generateArborescence
private function _generateArborescence($folders)
{
$folderList = array();
foreach ($folders as $folder) {
$folderPath = JPath::clean(ACYMAILING_ROOT . trim(str_replace('/', DS, trim($folder)), DS));
if (!file_exists($folderPath)) {
acymailing_createDir($folderPath);
}
$subFolders = JFolder::listFolderTree($folderPath, '', 15);
$folderList[] = trim($folder, '/ ');
foreach ($subFolders as $oneFolder) {
$subFolder = str_replace(ACYMAILING_ROOT, '', $oneFolder['relname']);
$subFolder = str_replace(DS, '/', $subFolder);
$folderList[] = ltrim($subFolder, '/');
}
}
return array_unique($folderList);
}