Esempio n. 1
0
 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');
     }
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 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;
         }
     }
 }
Esempio n. 6
0
 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);
     }
     if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) {
         $mail->mailid = $mailid;
         $this->_publishfollowup($mail);
     }
     return $status;
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 static function createDir($dir, $report = true)
 {
     return acymailing_createDir($dir, $report);
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
    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();
        $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 . DS . $file);
            ?>
							<li class="acy_media_browser_images" id="acy_media_browser_images_<?php 
            echo $k;
            ?>
" onmouseover="toggleImageInfo(<?php 
            echo $k;
            ?>
, 'display')" onmouseout="toggleImageInfo(<?php 
            echo $k;
            ?>
, 'hide')">
								<img class="acy_media_browser_image" id="acy_media_browser_image_<?php 
            echo $k;
            ?>
" src="<?php 
            echo ACYMAILING_LIVE . $defaultFolder . '/' . $file;
            ?>
"/>
								<a href="#" onclick="displayImageFromUrl('<?php 
            echo ACYMAILING_LIVE . $defaultFolder . '/' . $file;
            ?>
', 'success', '<?php 
            echo $file;
            ?>
', '<?php 
            echo $imageSize[0];
            ?>
', '<?php 
            echo $imageSize[1];
            ?>
'); return false;">
									<div id="acy_media_browser_image_info_<?php 
            echo $k;
            ?>
"
										 style="box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.2); text-shadow:1px 1px 1px #ffffff; border:2px solid #fff; padding-top:40px; text-align:center; vertical-align:middle; color:#333; font-weight:bold; position:absolute; top:0px; left:0px; bottom:0px; right:0px; display:none; background-color: rgba(255,255,255,0.8);">
										<img class="acy_media_browser_delete" id="acy_media_browser_delete_<?php 
            echo $k;
            ?>
" src="<?php 
            echo ACYMAILING_LIVE . 'media' . DS . ACYMAILING_COMPONENT . DS . 'images' . DS . 'editor' . DS . 'delete.png';
            ?>
" onclick="confirmDeletePicture('<?php 
            echo $file;
            ?>
')"/>
										<?php 
            echo $file;
            ?>
<br/>
										<span class="acy_media_browser_image_size"><?php 
            echo $imageSize[0] . 'x' . $imageSize[1];
            ?>
 - <?php 
            echo round(filesize($uploadPath . DS . $file) * 0.0009765625, 2) . ' ko';
            ?>
<br/></span>
									</div>
								</a>
							</li>
							<?php 
        }
        if (!$imagesFound) {
            acymailing_display(JText::_('NO_FILE_FOUND'), 'warning');
        }
        ?>

						</ul>

						<!-- Here we give the possibility to import a file or specify and url -->
						<div id="acy_media_browser_actions">
							<div id="acy_media_browser_containing_block">
								<div id="acy_media_browser_buttons_block">
									<button type="button" class="btn" id="upload_image_btn" onclick="displayAppropriateField(this.id)"> <?php 
        echo JText::_('UPLOAD_NEW_IMAGE');
        ?>
</button>
									<?php 
        echo JText::_('ACY_OR');
        ?>
									<button type="button" class="btn" id="import_from_url_btn" onclick="displayAppropriateField(this.id)"> <?php 
        echo JText::_('INSERT_IMAGE_FROM_URL');
        ?>
 </button>
								</div>
								<div id="acy_media_browser_hidden_elements">
									<div id="upload_image" style="position: relative; padding-top:5px;	display:none; text-align: center;">
										<form method="post" name="adminForm" id="adminForm" enctype="multipart/form-data" style="margin:0px; margin-top:3px;">
											<input type="file" style="width:auto;" name="uploadedImage"/><br/>
											<input type="hidden" name="task" value="browse"/>
											<input type="hidden" name="selected_folder" value="<?php 
        echo htmlspecialchars($defaultFolder, ENT_COMPAT, 'UTF-8');
        ?>
"/>
											<?php 
        echo JHTML::_('form.token');
        ?>
										</form>
										<button class="btn btn-primary" type="button" onclick="submitbutton();"> <?php 
        echo JText::_('IMPORT');
        ?>
 </button>
										<span style="position:absolute; top:5px; left:5px;" id="acy_back_from_upload" onclick="displayAppropriateField(this.id)"><a href="javascript:void(0);">&#8592 <?php 
        echo JText::_('MEDIA_BACK');
        ?>
</a></span>
									</div>
									<div id="import_from_url" style="padding-top:9px; position:relative; ">
										<input type="text" id="acy_media_browser_url_input" class="inputbox" oninput="testImage(this.value, displayImageFromUrl)" value="http://"/>
										<?php 
        ?>
										<div id="acy_media_browser_insert_message"></div>
										<span style="position:absolute; top:5px; left:5px;" id="acy_back_from_url" onclick="displayAppropriateField(this.id)"><a href="javascript:void(0);">&#8592 <?php 
        echo JText::_('MEDIA_BACK');
        ?>
</a></span>
									</div>
								</div>
							</div>
						</div>
					</td>
					<!-- IMAGE INFORMATION -->
					<td id="acy_media_browser_image_details_row">
						<div id="acy_media_browser_image_details">
							<div id="acy_media_browser_image_selected" style=" max-width:230px; max-height:190px; display:none;	margin:auto; margin-bottom:10px;"></div>
							<div id="acy_media_browser_image_selected_info" style=""></div>
							<div id="acy_media_browser_image_selected_details">
								<label for="acy_media_browser_image_title" style="float:left;"><?php 
        echo JText::_('ACY_TITLE');
        ?>
</label>
								<input type="text" id="acy_media_browser_image_title" class="inputbox" style="width:100%" value=""/>
								<?php 
        $imageZone = JRequest::getVar('image_zone', array(), '', 'array');
        if (!empty($imageZone)) {
            ?>
									<label for="acy_media_browser_image_target"><?php 
            echo JText::_('ACY_LINK');
            ?>
</label>
									<input type="text" id="acy_media_browser_image_target" placeholder="<?php 
            echo ACYMAILING_LIVE;
            ?>
..." class="inputbox" style="width:100%" value=""/>
								<?php 
        } else {
            ?>
									<label for="acy_media_browser_image_width" style="display:inline;"><?php 
            echo JText::_('CAPTCHA_WIDTH');
            ?>
</label>    <input type="text" id="acy_media_browser_image_width" style="width:23%;" value="" oninput="calculateSize(0, this.value)"/>
									<br/><label for="acy_media_browser_image_height" style="display:inline;"><?php 
            echo JText::_('CAPTCHA_HEIGHT');
            ?>
</label>    <input type="text" id="acy_media_browser_image_height" style="width:22%;" value="" oninput="calculateSize(this.value, 0)"/>
									<br/><label for="acy_media_browser_image_align" style="display:inline;"><?php 
            echo JText::_('ALIGNMENT');
            ?>
</label>
									<select id="acy_media_browser_image_align" class="chzn-done" style="width:50%">
										<option value=""><?php 
            echo JText::_('NOT_SET');
            ?>
</option>
										<option value="left"><?php 
            echo JText::_('ACY_LEFT');
            ?>
</option>
										<option value="right"><?php 
            echo JText::_('ACY_RIGHT');
            ?>
</option>
									</select><br/>
									<label for="acy_media_browser_image_margin" style="display:inline;"><?php 
            echo JText::_('ACY_MARGIN');
            ?>
</label>    <input type="text" style="width:23%;" id="acy_media_browser_image_margin" value=""/><br/>
									<label for="acy_media_browser_image_border" style="display:inline;"><?php 
            echo JText::_('ACY_BORDER');
            ?>
</label>    <input type="text" style="width:23%;" id="acy_media_browser_image_border" value=""/><br/>
									<label for="acy_media_browser_image_class" style="display:inline;"><?php 
            echo JText::_('ACY_CLASS');
            ?>
</label>    <input type="text" style="width:50%;" id="acy_media_browser_image_class" value=""/>
									<input type="hidden" id="acy_media_browser_image_linkhref" value=""/>
								<?php 
        }
        ?>
							</div>
							<button class="btn btn-primary" type="button" onclick="validateImage();window.parent.SqueezeBox.close();" style=" position:absolute; bottom:6px; right:6px; "><?php 
        echo JText::_('INSERT');
        ?>
 </button>
						</div>
					</td>
				</tr>
			</table>

			<div class="confirmBoxMM" id="confirmBoxMM" style="display: none;">
				<div id="acy_popup_content">
					<span class="confirmTxtMM" id="confirmTxtMM"></span>
					<button class="acy_popup_cancel_button" id="confirmCancelMM" onclick="document.getElementById('confirmBoxMM').style.display='none';">
						<?php 
        echo JText::_('ACY_CANCEL');
        ?>
					</button>
					<button class="acy_popup_delete_button" id="confirmOkMM">
						<?php 
        echo JText::_('ACY_DELETE');
        ?>
					</button>
				</div>
			</div>


		</div>
		<?php 
        $imageZone = JRequest::getVar('image_zone', array(), '', 'array');
        if ($imageZone) {
            echo '<script>checkSelected(true);</script>';
        } else {
            echo '<script>checkSelected();</script>';
        }
        if (isset($uploadMessage) && $uploadMessage == 'success' && file_exists(ACYMAILING_ROOT . rtrim($defaultFolder, '/') . '/' . $this->imageName)) {
            $imageSize = getimagesize(ACYMAILING_LIVE . rtrim($defaultFolder, '/') . '/' . $this->imageName);
            echo '<script> displayImageFromUrl(\'' . ACYMAILING_LIVE . rtrim($defaultFolder, '/') . '/' . $this->imageName . '\',\'success\', \'' . $this->imageName . '\',' . $imageSize[0] . ',' . $imageSize[1] . ');</script>';
        }
    }
Esempio n. 12
0
    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;
            ?>
" src="<?php 
            echo ACYMAILING_LIVE . $defaultFolder . $file;
            ?>
" height="135" width="135" style="height: 135px; width:135px;"></img>
											<a href="#" onclick="displayImageFromUrl('<?php 
            echo ACYMAILING_LIVE . $defaultFolder . $file;
            ?>
', 'success', '<?php 
            echo $file;
            ?>
', '<?php 
            echo $imageSize[0];
            ?>
', '<?php 
            echo $imageSize[1];
            ?>
'); return false;" >
													<div id="acy_media_browser_image_info_<?php 
            echo $k;
            ?>
" style="box-shadow: 0px 3px 3px 3px rgba(0, 0, 0, 0.3); padding-top:40px; text-align:center; vertical-align:middle; color: white; position:absolute; top:0px; left:0px; bottom:0px; right:0px; display:none; background-color: rgba(0,0,0,0.5);">
														<?php 
            echo $file;
            ?>
<br/>
														<span class="acy_media_browser_image_size" ><?php 
            echo $imageSize[0] . 'x' . $imageSize[1];
            ?>
 - <?php 
            echo round(filesize($uploadPath . $file) * 0.0009765625, 2) . ' ko';
            ?>
<br/></span>
													</div>
											</a>
										</li>
										<?php 
        }
        if (!$imagesFound) {
            echo '<div class="alert">';
            echo JText::_('NO_FILE_FOUND');
            echo '</div>';
        }
        ?>
									</ul>

									<!-- Here we give the possibility to import a file or specify and url -->
										<div id="acy_media_browser_actions" >
											<div id="acy_media_browser_containing_block">
												<div id="acy_media_browser_buttons_block" >
														<button type="button"  class="btn" id="upload_image_btn" onclick="displayAppropriateField(this.id)"> <?php 
        echo JText::_('UPLOAD_NEW_IMAGE');
        ?>
</button>
														<?php 
        echo JText::_('ACY_OR');
        ?>
														<button type="button"  class="btn" id="import_from_url_btn" onclick="displayAppropriateField(this.id)"> <?php 
        echo JText::_('INSERT_IMAGE_FROM_URL');
        ?>
 </button>
												</div>
												<div id="acy_media_browser_hidden_elements">
														<div id="upload_image" style="position: relative; padding-top:5px;	display:none; text-align: center;">
															<form method="post"  name="adminForm" id="adminForm" enctype="multipart/form-data" style="margin:0px; margin-top:3px;" >
																	<input type="file" style="width:auto;" name="uploadedImage" /><br/>
																	<?php 
        ?>
															</form>
															<button class="btn btn-primary" type="button" onclick="submitbutton();"> <?php 
        echo JText::_('IMPORT');
        ?>
 </button>
															<span style="position:absolute; top:5px; left:5px;" id="acy_back_from_upload" onclick="displayAppropriateField(this.id)" ><a href="javascript:void(0);">&#8592 <?php 
        echo JText::_('MEDIA_BACK');
        ?>
</a></span>
														</div>
														<div id="import_from_url" style="padding-top:9px; position:relative; ">
															<input type="text" id="acy_media_browser_url_input" class="inputbox" oninput="testImage(this.value, displayImageFromUrl)" value="http://" />
															<?php 
        ?>
															<div id="acy_media_browser_insert_message"></div>
															<span style="position:absolute; top:5px; left:5px;" id="acy_back_from_url" onclick="displayAppropriateField(this.id)" ><a href="javascript:void(0);">&#8592 <?php 
        echo JText::_('MEDIA_BACK');
        ?>
</a></span>
														</div>
												</div>
											</div>
									</div>
								</td>
								<!-- IMAGE INFORMATION -->
								<td id="acy_media_browser_image_details_row" >
									<div id="acy_media_browser_image_details"  >
											<div id="acy_media_browser_image_selected" style=" max-width:230px; max-height:190px; display:none;	margin:auto; margin-bottom:10px;"></div>
										<div id="acy_media_browser_image_selected_info" style=""></div>
									<div id="acy_media_browser_image_selected_details" >
										<label for="acy_media_browser_image_title" style="float:left;"><?php 
        echo JText::_('ACY_TITLE');
        ?>
</label>
										<input type="text" id="acy_media_browser_image_title" class="inputbox" style="width:100%"  value="" />
										<?php 
        $imageZone = JRequest::getVar('image_zone', array(), '', 'array');
        if (!empty($imageZone)) {
            ?>
												<label for="acy_media_browser_image_target"><?php 
            echo JText::_('ACY_LINK');
            ?>
</label>
												<input type="text" id="acy_media_browser_image_target" placeholder="<?php 
            echo ACYMAILING_LIVE;
            ?>
..." class="inputbox" style="width:100%"  value="" />
											<?php 
        } else {
            ?>
															<label for="acy_media_browser_image_width" style="display:inline;"><?php 
            echo JText::_('CAPTCHA_WIDTH');
            ?>
</label>	<input type="text" id="acy_media_browser_image_width"  style="width:23%;"  value="" oninput="calculateSize(0, this.value)" />
															<label for="acy_media_browser_image_height" style="display:inline;"><?php 
            echo JText::_('CAPTCHA_HEIGHT');
            ?>
</label>	<input type="text" id="acy_media_browser_image_height"  style="width:22%;"  value="" oninput="calculateSize(this.value, 0)" />
															<label for="acy_media_browser_image_align" style="display:inline;"><?php 
            echo JText::_('ALIGNMENT');
            ?>
</label>
															<select id="acy_media_browser_image_align" class="chzn-done" style="width:50%">
																	<option value=""><?php 
            echo JText::_('NOT_SET');
            ?>
</option>
																	<option value="left"><?php 
            echo JText::_('ACY_LEFT');
            ?>
</option>
																	<option value="right"><?php 
            echo JText::_('ACY_RIGHT');
            ?>
</option>
															</select><br/>
										<label for="acy_media_browser_image_margin" style="display:inline;"><?php 
            echo JText::_('ACY_MARGIN');
            ?>
</label>	<input type="text" style="width:23%;"  id="acy_media_browser_image_margin"  value="" /><br/>
										<label for="acy_media_browser_image_border" style="display:inline;"><?php 
            echo JText::_('ACY_BORDER');
            ?>
</label>	<input type="text" style="width:23%;"  id="acy_media_browser_image_border"  value="" />
												<?php 
        }
        ?>
											</div>
										<button class="btn btn-primary" type="button" onclick="validateImage();window.parent.SqueezeBox.close();" style=" position:absolute; bottom:6px; right:6px; "><?php 
        echo JText::_('INSERT');
        ?>
 </button>
							 </div>
						</td>
				</tr>
		 	</table>
		</div>
		<?php 
        $imageZone = JRequest::getVar('image_zone', array(), '', 'array');
        if ($imageZone) {
            echo '<script>checkSelected(true);</script>';
        } else {
            echo '<script>checkSelected();</script>';
        }
        if (isset($uploadMessage) && $uploadMessage == 'success') {
            $imageSize = getimagesize(ACYMAILING_LIVE . $defaultFolder . $this->imageName);
            echo '<script> displayImageFromUrl(\'' . ACYMAILING_LIVE . $defaultFolder . $this->imageName . '\',\'success\', \'' . $this->imageName . '\',' . $imageSize[0] . ',' . $imageSize[1] . ');</script>';
        }
    }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
 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);
         }
     }
 }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
	function saveReport(){
		$config = acymailing_config();
		$saveReport = $config->get('cron_savereport');
		if(empty($saveReport)) return;

		$reportPath = JPath::clean(ACYMAILING_ROOT.trim(html_entity_decode($config->get('cron_savepath'))));
		acymailing_createDir(dirname($reportPath),true,true);

		file_put_contents($reportPath, "\r\n"."\r\n".str_repeat('*',150)."\r\n".str_repeat('*',20).str_repeat(' ',5).acymailing_getDate(time()).str_repeat(' ',5).str_repeat('*',20)."\r\n".implode("\r\n",$this->messages), FILE_APPEND);
		if($saveReport == 2 AND !empty($this->detailMessages)){
			@file_put_contents($reportPath, "\r\n"."---- Details ----"."\r\n".implode("\r\n",$this->detailMessages), FILE_APPEND);
		}
	}
Esempio n. 17
0
 function file()
 {
     $app =& JFactory::getApplication();
     $importFile = JRequest::getVar('importfile', array(), 'files', 'array');
     if (empty($importFile['name'])) {
         $app->enqueueMessage(JText::_('BROWSE_FILE'), 'notice');
         return false;
     }
     $this->forceconfirm = JRequest::getInt('import_confirmed');
     $this->charsetConvert = JRequest::getString('charsetconvert', '');
     $this->generatename = JRequest::getInt('generatename');
     $this->overwrite = JRequest::getInt('overwriteexisting');
     jimport('joomla.filesystem.file');
     $config =& acymailing_config();
     $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 = null;
     $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', $importFile['tmp_name'], $uploadPath . $attachment->filename), 'error');
         }
     }
     $contentFile = file_get_contents($uploadPath . $attachment->filename);
     if (!$contentFile) {
         $app->enqueueMessage(JText::sprintf('FAIL_OPEN', $uploadPath . $attachment->filename), '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;
 }
 function checkFields(&$data, &$subscriber)
 {
     foreach ($data as $column => $value) {
         $column = trim(strtolower($column));
         if ($this->allowModif || !in_array($column, $this->restrictedFields)) {
             acymailing_secureField($column);
             if (is_array($value)) {
                 if (isset($value['day']) || isset($value['month']) || isset($value['year'])) {
                     $value = (empty($value['year']) ? '0000' : intval($value['year'])) . '-' . (empty($value['month']) ? '00' : $value['month']) . '-' . (empty($value['day']) ? '00' : $value['day']);
                 } else {
                     $value = implode(',', $value);
                 }
             }
             $subscriber->{$column} = trim(strip_tags($value));
             if (!is_numeric($subscriber->{$column})) {
                 if (function_exists('mb_detect_encoding') && mb_detect_encoding($subscriber->{$column}, 'UTF-8', true) != 'UTF-8') {
                     $subscriber->{$column} = utf8_encode($subscriber->{$column});
                 } elseif (!function_exists('mb_detect_encoding') && !preg_match('%^(?:[\\x09\\x0A\\x0D\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$%xs', $subscriber->{$column})) {
                     $subscriber->{$column} = utf8_encode($subscriber->{$column});
                 }
             }
         }
     }
     if (!acymailing_level(3) || empty($_FILES)) {
         return;
     }
     jimport('joomla.filesystem.file');
     $config = acymailing_config();
     $uploadFolder = trim(JPath::clean(html_entity_decode(acymailing_getFilesFolder())), DS . ' ') . DS;
     $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder . 'userfiles' . DS);
     acymailing_createDir(JPath::clean(ACYMAILING_ROOT . $uploadFolder), true);
     acymailing_createDir($uploadPath, true);
     foreach ($_FILES as $typename => $type) {
         $type2 = isset($type['name']['subscriber']) ? $type['name']['subscriber'] : $type['name'];
         if (empty($type2)) {
             continue;
         }
         foreach ($type2 as $fieldname => $filename) {
             if (empty($filename)) {
                 continue;
             }
             acymailing_secureField($fieldname);
             $attachment = new stdClass();
             $filename = JFile::makeSafe(strtolower(strip_tags($filename)));
             $attachment->filename = time() . rand(1, 999) . '_' . $filename;
             while (file_exists($uploadPath . $attachment->filename)) {
                 $attachment->filename = time() . rand(1, 999) . '_' . $filename;
             }
             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)) {
                 echo "<script>alert('" . JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')) . "');window.history.go(-1);</script>";
                 exit;
             }
             $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
             $tmpFile = isset($type['name']['subscriber']) ? $_FILES[$typename]['tmp_name']['subscriber'][$fieldname] : $_FILES[$typename]['tmp_name'][$fieldname];
             if (!JFile::upload($tmpFile, $uploadPath . $attachment->filename)) {
                 echo "<script>alert('" . JText::sprintf('FAIL_UPLOAD', '<b><i>' . $tmpFile . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>') . "');window.history.go(-1);</script>";
                 exit;
             }
             $subscriber->{$fieldname} = $attachment->filename;
         }
     }
 }
Esempio n. 19
0
 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;
         }
     }
     $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;
 }
Esempio n. 20
0
 function createTemplateFile($id)
 {
     if (file_exists(ACYMAILING_TEMPLATE . 'css' . DS . 'template_' . $id . '.css')) {
         return ACYMAILING_TEMPLATE . 'css' . DS . 'template_' . $id . '.css';
     }
     $classTemplate = acymailing_get('class.template');
     $template = $classTemplate->get($id);
     if (empty($template->tempid)) {
         return '';
     }
     $css = $classTemplate->buildCSS($template->styles, $template->stylesheet);
     if (empty($css)) {
         return '';
     }
     jimport('joomla.filesystem.file');
     acymailing_createDir(ACYMAILING_TEMPLATE . 'css');
     if (JFile::write(ACYMAILING_TEMPLATE . 'css' . DS . 'template_' . $id . '.css', $css)) {
         return ACYMAILING_TEMPLATE . 'css' . DS . 'template_' . $id . '.css';
     } else {
         acymailing_display('Could not create the file ' . ACYMAILING_TEMPLATE . 'css' . DS . 'template_' . $id . '.css', 'error');
         return '';
     }
 }
Esempio n. 21
0
 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);
             }
         }
     }
     $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     $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, $mail->body);
     if (!empty($newbody)) {
         $mail->body = $newbody;
     }
     $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', $attachments['tmp_name'][$id], $uploadPath . $attachment->filename), '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) {
             $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED');
             $text .= ' ' . $toggleHelper->toggleText('add', $mail->mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED'));
             $app->enqueueMessage($text, 'notice');
         }
         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');
         }
     }
     $mailid = $this->save($mail);
     if (!$mailid) {
         return false;
     }
     JRequest::setVar('mailid', $mailid);
     if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) {
         $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED');
         $text .= ' ' . $toggleHelper->toggleText('add', $mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED'));
         $app->enqueueMessage($text, 'notice');
     }
     $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);
     }
     return $status;
 }