Ejemplo n.º 1
0
 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;
         }
     }
 }
Ejemplo n.º 2
0
 public function createFolder()
 {
     JRequest::checkToken() or die('Invalid Token to create folder');
     $folderName = str_replace(array('.', '-'), array('', '_'), strtolower(JRequest::getCmd('subFolderName')));
     if (empty($folderName)) {
         $this->browse();
         return false;
     }
     $directoryPath = JRequest::getString('acy_media_browser_files_path') . '/' . $folderName;
     $mediaFolders = acymailing_getFilesFolder('media', true);
     $allowed = false;
     foreach ($mediaFolders as $oneMedia) {
         if (preg_match('#^' . preg_quote($oneMedia) . '[a-z_0-9\\-/]*$#i', $directoryPath)) {
             $allowed = true;
             break;
         }
     }
     if (!$allowed) {
         acymailing_enqueueMessage('You are not allowed to create this folder', 'error');
         $this->browse();
         return false;
     }
     $directoryPath = str_replace('/', DS, $directoryPath);
     if (JFolder::exists(ACYMAILING_ROOT . $directoryPath)) {
         acymailing_enqueueMessage(JText::_('FOLDER_ALREADY_EXISTS'), 'warning');
         $this->browse();
         return false;
     }
     if (!JFolder::create(ACYMAILING_ROOT . $directoryPath)) {
         acymailing_enqueueMessage(JText::sprintf('WRITABLE_FOLDER', substr(ACYMAILING_ROOT . $directoryPath, 0, strrpos(ACYMAILING_ROOT . $directoryPath, DS)), 'error'));
         $this->browse();
         return false;
     }
     JRequest::setVar('selected_folder', JRequest::getString('acy_media_browser_files_path') . '/' . $folderName);
     $this->browse();
 }
Ejemplo n.º 3
0
    function updateSQL()
    {
        if (!$this->update) {
            return true;
        }
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        if (version_compare($this->fromVersion, '1.1.4', '<')) {
            $replace1 = "REPLACE(`params`, 'showhtml=1\nshowname=1', 'customfields=name,email,html' )";
            $replace2 = "REPLACE( {$replace1} , 'showhtml=0\nshowname=1', 'customfields=name,email' )";
            $replace3 = "REPLACE( {$replace2} , 'showhtml=1\nshowname=0', 'customfields=email,html' )";
            $replace4 = "REPLACE( {$replace3} , 'showhtml=0\nshowname=0', 'customfields=email' )";
            $this->updateQuery("UPDATE #__modules SET `params`= {$replace4} WHERE `module` = 'mod_acymailing' ");
        }
        if (version_compare($this->fromVersion, '1.2.1', '<')) {
            $this->updateQuery("UPDATE `#__acymailing_config` SET `value` = 'data' WHERE `value` = '0' AND `namekey` = 'allow_modif' LIMIT 1");
            $this->updateQuery("UPDATE `#__acymailing_config` SET `value` = 'all' WHERE `value` = '1' AND `namekey` = 'allow_modif' LIMIT 1");
        }
        if (version_compare($this->fromVersion, '1.2.2', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `sentby` INT UNSIGNED NULL DEFAULT NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `subject` VARCHAR( 250 ) NULL DEFAULT NULL");
            $this->updateQuery("DELETE FROM `#__plugins` WHERE `folder` = 'acymailing' AND `element` = 'autocontent'");
        }
        if (version_compare($this->fromVersion, '1.2.3', '<')) {
            $this->updateQuery("UPDATE `#__plugins` SET `folder` = 'system', `element`= 'regacymailing', `name` = 'AcyMailing : (auto)Subscribe during Joomla registration', `params`= REPLACE(`params`, 'lists=', 'autosub=' ) WHERE `folder` = 'user' AND `element` = 'acymailing'");
            $this->updateQuery("DELETE FROM `#__plugins` WHERE `folder` = 'acymailing' AND `element` = 'autocontent'");
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `stylesheet` TEXT NULL");
            if (is_dir(rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . ACYMAILING_COMPONENT . DS . 'plugins' . DS . 'plg_user_acymailing')) {
                JFolder::delete(rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . ACYMAILING_COMPONENT . DS . 'plugins' . DS . 'plg_user_acymailing');
            }
            if (is_dir(rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . ACYMAILING_COMPONENT . DS . 'plugins' . DS . 'plg_acymailing_autocontent')) {
                JFolder::delete(rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . ACYMAILING_COMPONENT . DS . 'plugins' . DS . 'plg_acymailing_autocontent');
            }
        }
        if (version_compare($this->fromVersion, '1.3.1', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_config` CHANGE `value` `value` TEXT NULL ");
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `listing` TINYINT NULL DEFAULT NULL ");
            $this->updateQuery("UPDATE `#__acymailing_fields` SET `listing` = 1 WHERE `namekey` IN ('name','email','html') ");
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `fromname` VARCHAR( 250 ) NULL , ADD `fromemail` VARCHAR( 250 ) NULL , ADD `replyname` VARCHAR( 250 ) NULL , ADD `replyemail` VARCHAR( 250 ) NULL ");
        }
        if (version_compare($this->fromVersion, '1.5.2', '<')) {
            $this->db->setQuery("SELECT `params` FROM #__plugins WHERE `element` = 'regacymailing' LIMIT 1");
            $existingEntry = $this->db->loadResult();
            $listids = 'None';
            if (preg_match('#autosub=(.*)#i', $existingEntry, $autosubResult)) {
                $listids = $autosubResult[1];
            }
            $this->updateQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('autosub'," . $this->db->Quote($listids) . ")");
        }
        if (version_compare($this->fromVersion, '1.5.3', '<')) {
            $this->updateQuery('UPDATE #__acymailing_config SET `value` = REPLACE(`value`,\'<sup style="font-size: 4px;">TM</sup>\',\'™\')');
        }
        if (version_compare($this->fromVersion, '1.6.2', '<')) {
            $this->updateQuery("UPDATE #__acymailing_config SET `value` = 'media/com_acymailing/upload' WHERE `namekey` = 'uploadfolder' AND `value` = 'components/com_acymailing/upload' ");
            $this->updateQuery("UPDATE #__acymailing_config SET `value` = 'media/com_acymailing/logs/report" . rand(0, 999999999) . ".log' WHERE `namekey` = 'cron_savepath' ");
            if (!ACYMAILING_J16) {
                $this->updateQuery("UPDATE #__plugins SET `params` = REPLACE(`params`,'components/com_acymailing/images','media/com_acymailing/images') ");
            } else {
                $this->updateQuery("UPDATE #__extensions SET `params` = REPLACE(`params`,'components\\/com_acymailing\\/images','media\\/com_acymailing\\/images') ");
            }
            $updateClass = acymailing_get('helper.update');
            $removeFiles = array();
            $removeFiles[] = ACYMAILING_FRONT . 'css' . DS . 'component_default.css';
            $removeFiles[] = ACYMAILING_FRONT . 'css' . DS . 'frontendedition.css';
            $removeFiles[] = ACYMAILING_FRONT . 'css' . DS . 'module_default.css';
            foreach ($removeFiles as $oneFile) {
                if (is_file($oneFile)) {
                    JFile::delete($oneFile);
                }
            }
            $fromFolders = array();
            $toFolders = array();
            $fromFolders[] = ACYMAILING_FRONT . 'css';
            $toFolders[] = ACYMAILING_MEDIA . 'css';
            $fromFolders[] = ACYMAILING_FRONT . 'templates' . DS . 'plugins';
            $toFolders[] = ACYMAILING_MEDIA . 'plugins';
            $fromFolders[] = ACYMAILING_FRONT . 'upload';
            $toFolders[] = ACYMAILING_MEDIA . 'upload';
            foreach ($fromFolders as $i => $oneFolder) {
                if (!is_dir($oneFolder)) {
                    continue;
                }
                if (is_dir($toFolders[$i])) {
                    $updateClass->copyFolder($oneFolder, $toFolders[$i]);
                }
            }
            $deleteFolders = array();
            $deleteFolders[] = ACYMAILING_FRONT . 'css';
            $deleteFolders[] = ACYMAILING_FRONT . 'images';
            $deleteFolders[] = ACYMAILING_FRONT . 'js';
            $deleteFolders[] = ACYMAILING_BACK . 'logs';
            foreach ($deleteFolders as $oneFolder) {
                if (!is_dir($oneFolder)) {
                    continue;
                }
                JFolder::delete($oneFolder);
            }
        }
        if (version_compare($this->fromVersion, '1.7.1', '<')) {
            $this->updateQuery("CREATE TABLE IF NOT EXISTS `#__acymailing_history` (`subid` INT UNSIGNED NOT NULL ,`date` INT UNSIGNED NOT NULL ,`ip` VARCHAR( 50 ) NULL ,\r\n\t\t\t\t\t\t\t\t`action` VARCHAR( 50 ) NOT NULL , `data` TEXT NULL , `source` TEXT NULL , INDEX ( `subid` , `date` ) ) ;");
        }
        if (version_compare($this->fromVersion, '1.7.3', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `metakey` TEXT NULL , ADD `metadesc` TEXT NULL ");
        }
        if (version_compare($this->fromVersion, '1.8.4', '<')) {
            $this->updateQuery("UPDATE `#__acymailing_config` as a, `#__acymailing_config` as b SET a.`value` = b.`value` WHERE a.`namekey`= 'queue_nbmail_auto' AND b.`namekey`= 'queue_nbmail' ");
            $this->updateQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>{survey}</p>') WHERE type = 'notification' AND `alias` IN ('notification_refuse','notification_unsub','notification_unsuball')");
        }
        if (version_compare($this->fromVersion, '1.8.5', '<')) {
            $metaFile = ACYMAILING_FRONT . 'metadata.xml';
            if (file_exists($metaFile)) {
                JFile::delete($metaFile);
            }
            $this->updateQuery('ALTER TABLE #__acymailing_url DROP INDEX url');
            $this->updateQuery('ALTER TABLE `#__acymailing_url` CHANGE `url` `url` TEXT NOT NULL');
            $this->updateQuery('ALTER TABLE `#__acymailing_url` ADD INDEX `url` ( `url` ( 250 ) ) ');
            $this->updateQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>Subscription : {user:subscription}</p>') WHERE type = 'notification' AND `alias` = 'notification_created'");
        }
        if (version_compare($this->fromVersion, '1.9.1', '<')) {
            $this->updateQuery('ALTER TABLE `#__acymailing_history` ADD `mailid` MEDIUMINT UNSIGNED NULL');
            $this->updateQuery('CREATE TABLE IF NOT EXISTS `#__acymailing_rules` (
				`ruleid` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
				`name` VARCHAR( 250 ) NOT NULL ,
				`ordering` SMALLINT UNSIGNED NULL ,
				`regex` VARCHAR( 250 ) NOT NULL ,
				`executed_on` TEXT NOT NULL ,
				`action_message` TEXT NOT NULL ,
				`action_user` TEXT NOT NULL ,
				`published` TINYINT UNSIGNED NOT NULL
				)');
            $this->updateQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>Subscription : {user:subscription}</p>') WHERE type = 'notification' AND `alias` IN ( 'notification_unsuball','notification_refuse','notification_unsub')");
            $this->updateQuery("REPLACE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('auto_bounce','0')");
        }
        if (version_compare($this->fromVersion, '3.0.1', '<')) {
            $this->updateQuery('ALTER TABLE `#__acymailing_mail` ADD `filter` TEXT NULL');
            $this->updateQuery("ALTER TABLE `#__acymailing_subscriber` CHANGE `userid` `userid` INT UNSIGNED NOT NULL DEFAULT '0'");
        }
        if (version_compare($this->fromVersion, '3.5.1', '<')) {
            if (file_exists(ACYMAILING_FRONT . 'sef_ext.php')) {
                JFile::delete(ACYMAILING_FRONT . 'sef_ext.php');
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_queue` ADD `paramqueue` VARCHAR( 250 ) NULL ");
            if (!ACYMAILING_J16) {
                $this->updateQuery("DELETE FROM `#__plugins` WHERE folder = 'acymailing' AND element LIKE 'tagvm%'");
            } else {
                $this->updateQuery("DELETE FROM `#__extensions` WHERE folder = 'acymailing' AND element LIKE 'tagvm%'");
            }
        }
        if (version_compare($this->fromVersion, '3.6.1', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_rules` CHANGE `regex` `regex` TEXT NOT NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_stats` ADD `bouncedetails` TEXT NULL");
        }
        if (version_compare($this->fromVersion, '3.7.1', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_userstats` ADD `ip` VARCHAR( 100 ) NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_urlclick` ADD `ip` VARCHAR( 100 ) NULL");
        }
        if (version_compare($this->fromVersion, '3.8.1', '<')) {
            $this->updateQuery("UPDATE #__acymailing_mail SET subject = CONCAT(subject,' ','{mainreport}') WHERE type = 'notification' AND alias = 'report' AND subject NOT LIKE '%mainreport%' LIMIT 1");
        }
        if (version_compare($this->fromVersion, '3.8.2', '<')) {
            $this->updateQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('optimize_listsub',0),('optimize_stats',0),('optimize_list',0),('optimize_mail',0),('optimize_userstats',0),('optimize_urlclick',0),('optimize_history',0),('optimize_template',0),('optimize_queue',0),('optimize_subscriber',0) ");
        }
        $file = ACYMAILING_FRONT . 'views' . DS . 'newsletter' . DS . 'metadata.xml';
        if (file_exists($file)) {
            JFile::delete($file);
        }
        $file = ACYMAILING_BACK . 'admin.acymailing.php';
        if (file_exists($file)) {
            JFile::delete($file);
        }
        if (version_compare($this->fromVersion, '4.0.0', '<')) {
            $this->db->setQuery("SELECT params,id FROM #__modules WHERE module = 'mod_acymailing'");
            $allModules = $this->db->loadObjectList();
            foreach ($allModules as $oneMod) {
                $newParams = preg_replace('#fieldsize=.*#i', 'fieldsize=80%', $oneMod->params);
                $newParams = preg_replace('#"fieldsize":"[^"]*"#i', '"fieldsize":"80%"', $newParams);
                $this->updateQuery("UPDATE #__modules SET params = " . $this->db->Quote($newParams) . " WHERE id = " . intval($oneMod->id));
            }
            $this->db->setQuery("SELECT options,fieldid FROM #__acymailing_fields WHERE type IN ('phone','text','date','file') AND options LIKE '%size%'");
            $allFields = $this->db->loadObjectList();
            foreach ($allFields as $oneField) {
                $options = unserialize($oneField->options);
                $options['size'] = intval($options['size'] * 5);
                $this->updateQuery("UPDATE #__acymailing_fields SET options = " . $this->db->Quote(serialize($options)) . " WHERE fieldid = " . intval($oneField->fieldid));
            }
        }
        if (is_dir(ACYMAILING_BACK . 'inc' . DS . 'openflash')) {
            JFolder::delete(ACYMAILING_BACK . 'inc' . DS . 'openflash');
        }
        if (is_dir(ACYMAILING_FRONT . 'inc' . DS . 'openflash')) {
            JFolder::delete(ACYMAILING_FRONT . 'inc' . DS . 'openflash');
        }
        if (version_compare($this->fromVersion, '4.2.0', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `thumb` VARCHAR( 250 ) NULL , ADD `readmore` VARCHAR( 250 ) NULL ");
            $this->db->setQuery("SELECT tempid, description FROM #__acymailing_template WHERE `thumb` IS NULL");
            $allTemplates = $this->db->loadObjectList();
            foreach ($allTemplates as $oneTemplate) {
                if (preg_match('#<img[^>]*src="([^"]*)"[^>]*>#Ui', $oneTemplate->description, $onethumb)) {
                    $this->updateQuery('UPDATE #__acymailing_template SET `description` = ' . $this->db->Quote(str_replace($onethumb[0], '', $oneTemplate->description)) . ', `thumb` = ' . $this->db->Quote($onethumb[1]) . ' WHERE tempid = ' . $oneTemplate->tempid);
                }
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_subscriber` ADD `confirmed_date` INT UNSIGNED NOT NULL DEFAULT '0', ADD `confirmed_ip` VARCHAR(100) NULL , ADD `lastopen_date` INT UNSIGNED NOT NULL DEFAULT '0', ADD `lastclick_date` INT UNSIGNED NOT NULL DEFAULT '0'");
            $this->updateQuery('UPDATE #__acymailing_subscriber as sub JOIN #__acymailing_history as hist ON sub.subid = hist.subid AND hist.action = "confirmed" SET sub.confirmed_date = hist.date, sub.confirmed_ip = hist.ip WHERE sub.confirmed_date = 0');
            $this->updateQuery('UPDATE #__acymailing_subscriber as sub JOIN #__acymailing_userstats as stats ON sub.subid = stats.subid SET sub.lastopen_date = stats.opendate WHERE sub.lastopen_date = 0');
            $this->updateQuery('UPDATE #__acymailing_subscriber as sub JOIN #__acymailing_urlclick as url ON sub.subid = url.subid SET sub.lastclick_date = url.date WHERE sub.lastclick_date = 0');
            $this->updateQuery('ALTER TABLE `#__acymailing_list` CHANGE `ordering` `ordering` SMALLINT UNSIGNED NULL DEFAULT \'0\'');
            $this->updateQuery('ALTER TABLE `#__acymailing_template` CHANGE `ordering` `ordering` SMALLINT UNSIGNED NULL DEFAULT \'0\'');
            $templateClass = acymailing_get('class.template');
            for ($i = 1; $i <= 10; $i++) {
                $templateClass->createTemplateFile($i);
            }
        }
        if (version_compare($this->fromVersion, '4.3.0', '<')) {
            if (!ACYMAILING_J16) {
                $queryReplace = "UPDATE `#__plugins` SET `name` = REPLACE(`name`,'(beta)','') WHERE `element` = 'acyeditor'";
            } else {
                $queryReplace = "UPDATE `#__extensions` SET `name` = REPLACE(`name`,'(beta)','') WHERE `element` = 'acyeditor'";
            }
            $this->updateQuery($queryReplace);
            if (!ACYMAILING_J16) {
                $this->db->setQuery("SELECT `params` FROM #__plugins WHERE `element` = 'urltracker' LIMIT 1");
                $pattern = '#trackingsystem=(.*)#i';
            } else {
                $this->db->setQuery("SELECT `params` FROM #__extensions WHERE `element` = 'urltracker' LIMIT 1");
                $pattern = '#"trackingsystem":"([^"]*)"#i';
            }
            $existingEntry = $this->db->loadResult();
            $trackingMode = 'acymailing';
            if (preg_match($pattern, $existingEntry, $autosubResult)) {
                $trackingMode = $autosubResult[1];
            }
            if ($trackingMode == 'googleacy') {
                $trackingMode = 'acymailing,google';
            }
            $this->updateQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('trackingsystem'," . $this->db->Quote($trackingMode) . ")");
        }
        if (version_compare($this->fromVersion, '4.3.1', '<')) {
            $query = 'CREATE TABLE IF NOT EXISTS `#__acymailing_geolocation` (`geolocation_id` int unsigned NOT NULL AUTO_INCREMENT, `geolocation_subid` int unsigned NOT NULL DEFAULT \'0\',';
            $query .= ' `geolocation_type` varchar(255) NOT NULL DEFAULT \'subscription\', `geolocation_ip` varchar(255) NOT NULL DEFAULT \'\', `geolocation_created` int unsigned NOT NULL DEFAULT \'0\',';
            $query .= ' `geolocation_latitude` decimal(9,6) NOT NULL DEFAULT \'0.000000\', `geolocation_longitude` decimal(9,6) NOT NULL DEFAULT \'0.000000\', `geolocation_postal_code` varchar(255) NOT NULL DEFAULT \'\',';
            $query .= ' `geolocation_country` varchar(255) NOT NULL DEFAULT \'\', `geolocation_country_code` varchar(255) NOT NULL DEFAULT \'\', `geolocation_state` varchar(255) NOT NULL DEFAULT \'\',';
            $query .= ' `geolocation_state_code` varchar(255) NOT NULL DEFAULT \'\', `geolocation_city` varchar(255) NOT NULL DEFAULT \'\',';
            $query .= ' PRIMARY KEY (`geolocation_id`), KEY `geolocation_type` (`geolocation_subid`, `geolocation_type`)) ;';
            $this->updateQuery($query);
        }
        if (version_compare($this->fromVersion, '4.3.3', '<')) {
            $this->updateQuery('UPDATE #__acymailing_list SET access_manage = CONCAT(",",access_manage) WHERE access_manage NOT IN ("all","none","")');
        }
        if (version_compare($this->fromVersion, '4.4.2', '<')) {
            $this->updateQuery('ALTER TABLE `#__acymailing_fields` ADD `frontlisting` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT \'0\', ADD `frontjoomlaprofile` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT \'0\', ADD `frontjoomlaregistration` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT \'0\', ADD `joomlaprofile` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT \'0\'');
            $this->updateQuery('UPDATE `#__acymailing_fields` SET `frontlisting`  = `listing`');
            if (!ACYMAILING_J16) {
                $this->db->setQuery("SELECT `params` FROM #__plugins WHERE `element` = 'regacymailing' LIMIT 1");
                $pattern = '#customfields=(.*)#i';
            } else {
                $this->db->setQuery("SELECT `params` FROM #__extensions WHERE `element` = 'regacymailing' LIMIT 1");
                $pattern = '#"customfields":"([^"]*)"#i';
            }
            $existingEntry = $this->db->loadResult();
            if (preg_match($pattern, $existingEntry, $pregResult)) {
                $existingEntries = explode(',', $pregResult[1]);
                foreach ($existingEntries as $fieldToDisplay) {
                    $this->updateQuery("UPDATE `#__acymailing_fields` SET frontjoomlaregistration=1 WHERE namekey=" . $this->db->Quote(trim($fieldToDisplay)));
                }
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_list` ADD `startrule` VARCHAR(50) NOT NULL DEFAULT '0'");
            if (is_dir(ACYMAILING_ROOT . 'plugins' . DS . 'editors' . DS . 'acyeditor' . DS . 'acyeditor' . DS . 'kcfinder')) {
                JFolder::delete(ACYMAILING_ROOT . 'plugins' . DS . 'editors' . DS . 'acyeditor' . DS . 'acyeditor' . DS . 'kcfinder');
            }
            if (is_dir(ACYMAILING_ROOT . 'plugins' . DS . 'editors' . DS . 'acyeditor' . DS . 'kcfinder')) {
                JFolder::delete(ACYMAILING_ROOT . 'plugins' . DS . 'editors' . DS . 'acyeditor' . DS . 'kcfinder');
            }
            if (is_dir(ACYMAILING_BACK . 'extensions' . DS . 'plg_editors_acyeditor' . DS . 'acyeditor' . DS . 'kcfinder')) {
                JFolder::delete(ACYMAILING_BACK . 'extensions' . DS . 'plg_editors_acyeditor' . DS . 'acyeditor' . DS . 'kcfinder');
            }
        }
        if (version_compare($this->fromVersion, '4.5.2', '<')) {
            $this->db->setQuery("SELECT * FROM #__acymailing_config WHERE namekey='acl_newsletters_manage'");
            $res = $this->db->query();
            if (!empty($res)) {
                $this->updateQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('acl_newsletters_lists', 'all'), ('acl_newsletters_attachments', 'all'), ('acl_newsletters_sender_informations', 'all'), ('acl_newsletters_meta_data','all')");
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `access` VARCHAR( 250 ) NOT NULL DEFAULT 'all'");
            $this->updateQuery("ALTER TABLE `#__acymailing_subscriber` ADD `lastopen_ip` VARCHAR( 100 ) NULL, ADD `lastsent_date` INT UNSIGNED NOT NULL DEFAULT '0'");
            $this->updateQuery("UPDATE #__acymailing_subscriber as sub JOIN #__acymailing_userstats as stats ON sub.subid = stats.subid SET sub.lastopen_ip = stats.ip WHERE stats.ip != ''");
            $this->updateQuery("UPDATE #__acymailing_subscriber as sub JOIN #__acymailing_userstats as stats ON sub.subid = stats.subid SET sub.lastsent_date = stats.senddate");
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` MODIFY `type` ENUM('news','autonews','followup','unsub','welcome','notification','joomlanotification') NOT NULL DEFAULT 'news'");
        }
        if (version_compare($this->fromVersion, '4.6.3', '<')) {
            $file = ACYMAILING_ROOT . 'plugins' . DS . 'editors' . DS . 'acyeditor' . DS . 'acyeditor_j30.xml';
            if (file_exists($file)) {
                JFile::delete($file);
            }
            $file = ACYMAILING_ROOT . 'plugins' . DS . 'system' . DS . 'acymailingclassmail' . DS . 'acymailingclassmail_j30.xml';
            if (file_exists($file)) {
                JFile::delete($file);
            }
            $config = acymailing_config();
            if ($config->get('mailer_method') == 'smtp_com') {
                $newConfig = new stdClass();
                $newConfig->mailer_method = 'smtp';
                $newConfig->smtp_host = 'retail.smtp.com';
                $newConfig->smtp_port = '2525';
                $newConfig->smtp_username = $config->get('smtp_com_username');
                $newConfig->smtp_password = $config->get('smtp_com_password');
                $newConfig->smtp_auth = 1;
                $newConfig->smtp_keepalive = 1;
                $newConfig->smtp_secured = '';
                $config->save($newConfig);
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_userstats` ADD `browser` VARCHAR( 255 ) DEFAULT NULL, ADD `browser_version` TINYINT UNSIGNED DEFAULT NULL, ADD `is_mobile` TINYINT UNSIGNED DEFAULT NULL, ADD `mobile_os` VARCHAR( 255 ) DEFAULT NULL, ADD `user_agent` VARCHAR( 255 ) DEFAULT NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `language` VARCHAR( 50 ) NOT NULL DEFAULT ''");
        }
        if (version_compare($this->fromVersion, '4.7.3', '<')) {
            try {
                $this->db->setQuery("SELECT * FROM #__acymailing_config WHERE namekey='acl_newsletters_manage'");
                $res = $this->db->query();
                if (!empty($res)) {
                    $this->updateQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('acl_newsletters_abtesting', 'all')");
                }
            } catch (Exception $e) {
                $res = null;
            }
            if ($res === null) {
                acymailing_enqueueMessage(isset($e) ? $e->getMessage() : substr(strip_tags($this->db->getErrorMsg()), 0, 200) . '...', 'error');
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `abtesting` VARCHAR( 250 ) DEFAULT NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_subscriber` ADD `source` VARCHAR( 250 ) NOT NULL DEFAULT ''");
        }
        if (version_compare($this->fromVersion, '4.8.2', '<')) {
            $tagsFile = JPATH_SITE . DS . 'plugins' . DS . 'acymailing' . DS . 'tagcontent' . DS . 'tagcontenttags.xml';
            if (file_exists($tagsFile)) {
                JFile::delete($tagsFile);
            }
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `thumb` VARCHAR( 250 ) DEFAULT NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `summary` TEXT NOT NULL DEFAULT ''");
            $this->updateQuery("ALTER TABLE `#__acymailing_template` ADD `category` VARCHAR( 250 ) NOT NULL DEFAULT ''");
            $this->updateQuery("ALTER TABLE `#__acymailing_list` ADD `category` VARCHAR( 250 ) NOT NULL DEFAULT ''");
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `access` VARCHAR( 250 ) NOT NULL DEFAULT 'all'");
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `fieldcat` INT( 11 ) NOT NULL DEFAULT '0'");
            $this->updateQuery("UPDATE `#__acymailing_template` SET body = REPLACE(body,'<tbody>','<tbody class=\"acyeditor_sortable\">') WHERE body LIKE '%acyeditor_%' ");
        }
        if (version_compare($this->fromVersion, '4.9.1', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_geolocation` ADD KEY `geolocation_ip_created` (`geolocation_ip`, `geolocation_created`)");
        }
        if (version_compare($this->fromVersion, '4.9.3', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_userstats` ADD `bouncerule` VARCHAR( 255 ) NULL");
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `listingfilter` TINYINT NULL DEFAULT NULL ");
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `frontlistingfilter` TINYINT NULL DEFAULT NULL ");
        }
        if (version_compare($this->fromVersion, '4.9.4', '<')) {
            $this->updateQuery("UPDATE #__acymailing_mail SET body = REPLACE(REPLACE(body, 'newsletter-4/top.png', 'newsletter-4/images/top.png'), 'newsletter-4/bottom.png', 'newsletter-4/images/bottom.png')");
        }
        if (version_compare($this->fromVersion, '5.0.0', '<')) {
            $this->db->setQuery('SELECT mailid, attach FROM #__acymailing_mail WHERE attach IS NOT NULL');
            $mails = $this->db->loadObjectList();
            if (!empty($mails)) {
                $query = 'INSERT INTO #__acymailing_mail (`mailid`,`attach`) VALUES ';
                $folderPath = acymailing_getFilesFolder();
                foreach ($mails as $oneMail) {
                    $attachments = unserialize($oneMail->attach);
                    foreach ($attachments as &$oneAttach) {
                        if (strpos($oneAttach->filename, $folderPath) === false) {
                            $oneAttach->filename = $folderPath . '/' . $oneAttach->filename;
                        }
                    }
                    $query .= '(' . $oneMail->mailid . ',' . $this->db->Quote(serialize($attachments)) . '),';
                }
                $query = rtrim($query, ',');
                $query .= ' ON DUPLICATE KEY UPDATE `attach` = VALUES(`attach`)';
                $this->updateQuery($query);
            }
            $config = acymailing_config();
            $newConfig = new stdClass();
            $newConfig->css_backend = '';
            $config->save($newConfig);
        }
        if (version_compare($this->fromVersion, '5.0.1', '<')) {
            $this->updateQuery("ALTER TABLE `#__acymailing_fields` ADD `frontform` TINYINT NULL DEFAULT 1");
            $this->updateQuery("UPDATE `#__acymailing_fields` SET frontform = backend");
        }
        if (version_compare($this->fromVersion, '5.1.0', '<')) {
            $this->updateQuery("CREATE TABLE IF NOT EXISTS `#__acymailing_action` (`action_id` int unsigned NOT NULL AUTO_INCREMENT,`name` varchar(255) DEFAULT NULL,`description` text,`frequency` int unsigned NOT NULL,\r\n\t`nextdate` int unsigned NOT NULL,`server` varchar(255) NOT NULL,`port` varchar(50) NOT NULL,`connection_method` varchar(10) NOT NULL DEFAULT '0',`secure_method` varchar(10) NOT NULL DEFAULT '0',\r\n\t`self_signed` tinyint NOT NULL DEFAULT '0',`username` varchar(255) NOT NULL,`password` varchar(50) NOT NULL,`userid` int unsigned DEFAULT NULL,`conditions` text,`actions` text,`report` text,\r\n\t`published` tinyint NOT NULL DEFAULT '0',`ordering` smallint unsigned NULL DEFAULT '0',PRIMARY KEY (`action_id`)) ;");
            $this->updateQuery("ALTER TABLE `#__acymailing_mail` ADD `favicon` text");
        }
    }
Ejemplo n.º 4
0
 function select()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $config =& acymailing_config();
     $uploadFolders = acymailing_getFilesFolder('upload', true);
     $uploadFolder = JRequest::getString('currentFolder', $uploadFolders[0]);
     $uploadPath = JPath::clean(ACYMAILING_ROOT . trim(str_replace('/', DS, trim($uploadFolder)), DS));
     $map = JRequest::getString('id');
     $uploadedFile = JRequest::getVar('uploadedFile', array(), 'files', 'array');
     if (!empty($uploadedFile) && !empty($uploadedFile['name'])) {
         $uploaded = acymailing_importFile($uploadedFile, $uploadPath, in_array($map, array('thumb', 'readmore')));
         if ($uploaded) {
             $doc = JFactory::getDocument();
             $script = 'parent.document.getElementById("' . $map . '").value = "' . str_replace(DS, '/', $uploadFolder) . '/' . $uploaded . '";';
             if (in_array($map, array('thumb', 'readmore'))) {
                 $script .= 'parent.document.getElementById("' . $map . 'preview").src = "' . JURI::root() . str_replace(DS, '/', $uploadFolder) . '/' . $uploaded . '";';
             } else {
                 $script .= 'parent.document.getElementById("' . $map . 'selection").innerHTML = "' . $uploaded . '";';
             }
             $script .= 'window.parent.SqueezeBox.close();';
             $doc->addScriptDeclaration($script);
         }
     }
     $this->assignRef('config', $config);
     $this->assignRef('uploadFolder', $uploadFolder);
     $this->assignRef('uploadFolders', $uploadFolders);
     $this->assignRef('uploadPath', $uploadPath);
     $this->assignRef('map', $map);
 }