cms == 'Joomla') { $path = rtrim(JPATH_ADMINISTRATOR, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acym'.DIRECTORY_SEPARATOR; } elseif ($this->cms == 'WordPress') { $path = rtrim(__DIR__, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'back'.DIRECTORY_SEPARATOR; } include_once($path.'helpers'.DIRECTORY_SEPARATOR.'helper.php'); } function addPref() { $this->level = ucfirst($this->level); $allPref = acym_getDefaultConfigValues(); $allPref['level'] = $this->level; $allPref['version'] = $this->version; $allPref['smtp_port'] = ''; $allPref['from_name'] = acym_getCMSConfig('fromname'); $allPref['from_email'] = acym_getCMSConfig('mailfrom'); $allPref['bounce_email'] = acym_getCMSConfig('mailfrom'); $allPref['mailer_method'] = acym_getCMSConfig('mailer'); $allPref['sendmail_path'] = acym_getCMSConfig('sendmail'); $smtpinfos = explode(':', acym_getCMSConfig('smtphost')); $allPref['smtp_port'] = acym_getCMSConfig('smtpport'); $allPref['smtp_secured'] = acym_getCMSConfig('smtpsecure'); $allPref['smtp_auth'] = acym_getCMSConfig('smtpauth'); $allPref['smtp_username'] = acym_getCMSConfig('smtpuser'); $allPref['smtp_password'] = acym_getCMSConfig('smtppass'); $allPref['replyto_name'] = $allPref['from_name']; $allPref['replyto_email'] = $allPref['from_email']; $allPref['cron_sendto'] = $allPref['from_email']; $allPref['add_names'] = '1'; $allPref['encoding_format'] = '8bit'; $allPref['charset'] = 'UTF-8'; $allPref['word_wrapping'] = '150'; $allPref['hostname'] = ''; $allPref['embed_images'] = '0'; $allPref['embed_files'] = '1'; $allPref['editor'] = 'codemirror'; $allPref['multiple_part'] = '1'; $allPref['smtp_host'] = $smtpinfos[0]; if (isset($smtpinfos[1])) { $allPref['smtp_port'] = $smtpinfos[1]; } if (!in_array($allPref['smtp_secured'], ['tls', 'ssl'])) { $allPref['smtp_secured'] = ''; } $allPref['queue_nbmail'] = '40'; $allPref['queue_nbmail_auto'] = '70'; $allPref['queue_type'] = 'auto'; $allPref['queue_try'] = '3'; $allPref['queue_pause'] = '120'; $allPref['allow_visitor'] = '1'; $allPref['require_confirmation'] = '1'; $allPref['priority_newsletter'] = '3'; $allPref['allowed_files'] = 'zip,doc,docx,pdf,xls,txt,gzip,rar,jpg,jpeg,gif,xlsx,pps,csv,bmp,ico,odg,odp,ods,odt,png,ppt,swf,xcf,mp3,wma'; $allPref['confirm_redirect'] = ''; $allPref['subscription_message'] = '1'; $allPref['notification_unsuball'] = ''; $allPref['cron_next'] = '1251990901'; $allPref['confirmation_message'] = '1'; $allPref['welcome_message'] = '1'; $allPref['unsub_message'] = '1'; $allPref['cron_last'] = '0'; $allPref['cron_fromip'] = ''; $allPref['cron_report'] = ''; $allPref['cron_frequency'] = '900'; $allPref['cron_sendreport'] = '2'; $allPref['cron_fullreport'] = '1'; $allPref['cron_savereport'] = '2'; $allPref['uploadfolder'] = ACYM_UPLOAD_FOLDER; $allPref['notification_created'] = ''; $allPref['notification_accept'] = ''; $allPref['notification_refuse'] = ''; $allPref['forward'] = '0'; $allPref['priority_followup'] = '2'; $allPref['unsub_redirect'] = ''; $allPref['use_sef'] = '0'; $allPref['css_frontend'] = ''; $allPref['css_backend'] = ''; $allPref['last_import'] = ''; $allPref['unsub_reasons'] = serialize(['UNSUB_SURVEY_FREQUENT', 'UNSUB_SURVEY_RELEVANT']); $allPref['security_key'] = acym_generateKey(30); $allPref['export_excelsecurity'] = 1; $allPref['gdpr_export'] = 0; $allPref['gdpr_delete'] = 0; $allPref['anonymous_tracking'] = '0'; $allPref['anonymizeold'] = '0'; $allPref['trackingsystem'] = 'acymailing'; $allPref['trackingsystemexternalwebsite'] = 1; $allPref['generate_name'] = 1; $allPref['allow_modif'] = 'data'; $allPref['walk_through'] = '1'; $allPref['migration'] = '0'; $allPref['installcomplete'] = '0'; $allPref['Starter'] = '0'; $allPref['Essential'] = '1'; $allPref['Enterprise'] = '2'; $allPref['from_as_replyto'] = '1'; $allPref['templates_installed'] = '0'; $allPref['introjs'] = '[]'; $allPref['bounceVersion'] = 1; $allPref['numberThumbnail'] = 2; $allPref['daily_hour'] = '12'; $allPref['daily_minute'] = '00'; $allPref['social_icons'] = '{"facebook": "'.ACYM_MEDIA_URL.'images/logo/facebook.png", "twitter": "'.ACYM_MEDIA_URL.'images/logo/twitter.png", "instagram": "'.ACYM_MEDIA_URL.'images/logo/instagram.png", "linkedin": "'.ACYM_MEDIA_URL.'images/logo/linkedin.png", "pinterest": "'.ACYM_MEDIA_URL.'images/logo/pinterest.png", "vimeo": "'.ACYM_MEDIA_URL.'images/logo/vimeo.png", "wordpress": "'.ACYM_MEDIA_URL.'images/logo/wordpress.png", "youtube": "'.ACYM_MEDIA_URL.'images/logo/youtube.png"}'; $allPref['regacy'] = 1; $allPref['regacy_delete'] = 1; $allPref['regacy_forceconf'] = 0; $allPref['install_date'] = time(); $allPref['remindme'] = '[]'; $allPref['small_display'] = '0'; $query = "INSERT IGNORE INTO `#__acym_configuration` (`name`,`value`) VALUES "; foreach ($allPref as $namekey => $value) { $query .= '('.acym_escapeDB($namekey).','.acym_escapeDB($value).'),'; } $query = rtrim($query, ','); try { $res = acym_query($query); } catch (Exception $e) { $res = null; } if ($res === null) { acym_display(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error'); return false; } return true; } function updatePref() { try { $results = acym_loadObjectList("SELECT `name`, `value` FROM `#__acym_configuration` WHERE `name` IN ('version','level') LIMIT 2", 'name'); } catch (Exception $e) { $results = null; } if ($results === null) { acym_display(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error'); return false; } if ($results['version']->value == $this->version && $results['level']->value == $this->level) { return true; } $this->update = true; $this->fromLevel = $results['level']->value; $this->fromVersion = $results['version']->value; $query = "REPLACE INTO `#__acym_configuration` (`name`,`value`) VALUES ('level',".acym_escapeDB($this->level)."),('version',".acym_escapeDB($this->version)."),('installcomplete','0')"; acym_query($query); return true; } function updateSQL() { if (!$this->update) return; $config = acym_config(); if (version_compare($this->fromVersion, '6.0.3', '<')) { $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD COLUMN `bounce_details` LONGTEXT NULL'); $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD COLUMN `bounce_unique` MEDIUMINT(8) NOT NULL'); $this->updateQuery('ALTER TABLE #__acym_user_stat ADD COLUMN `bounce` TINYINT(4) NOT NULL'); $this->updateQuery('ALTER TABLE #__acym_user_stat ADD COLUMN `bounce_rule` VARCHAR(255) NULL'); $this->updateQuery( 'CREATE TABLE IF NOT EXISTS `#__acym_history` ( `user_id` INT NOT NULL, `date` INT NOT NULL, `ip` varchar(16) DEFAULT NULL, `action` varchar(50) NOT NULL, `data` text, `source` text, `mail_id` MEDIUMINT DEFAULT NULL, PRIMARY KEY (`user_id`,`date`) )' ); $this->updateQuery('ALTER TABLE #__acym_rule MODIFY `id` INT NOT NULL AUTO_INCREMENT'); $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `increment_stats` TINYINT(3) NOT NULL'); $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `execute_action_after` INT NOT NULL'); $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_NAME" WHERE `id` = 1 AND `name` = "Name"'); $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_EMAIL" WHERE `id` = 2 AND `name` = "Email"'); $this->updateQuery('UPDATE #__acym_field SET `backend_profile` = 1, `backend_listing` = 1 WHERE `id` IN (1, 2)'); $this->updateQuery('UPDATE #__acym_mail SET `thumbnail` = ""'); if ('WordPress' == 'WordPress') { $this->updateQuery('UPDATE #__acym_configuration SET `value` = '.acym_escapeDB(ACYM_UPLOAD_FOLDER).' WHERE `name` = "uploadfolder"'); $this->updateQuery('UPDATE #__acym_configuration SET `value` = '.acym_escapeDB(basename(WP_CONTENT_DIR).'/uploads/acymailing/logs/report_{year}_{month}.log').' WHERE `name` = "cron_savepath"'); } } if (version_compare($this->fromVersion, '6.1.0', '<')) { $this->updateQuery('DROP TABLE IF EXISTS `#__acym_automation_has_step`, `#__acym_step`, `#__acym_automation`'); $this->updateQuery( 'CREATE TABLE IF NOT EXISTS `#__acym_automation` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `description` LONGTEXT NULL, `active` TINYINT(3) NOT NULL, `report` TEXT NULL, `tree` LONGTEXT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB;' ); $this->updateQuery( 'CREATE TABLE IF NOT EXISTS `#__acym_step` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `triggers` LONGTEXT NULL, `automation_id` INT NOT NULL, `last_execution` INT NULL, `next_execution` INT NULL, PRIMARY KEY (`id`), CONSTRAINT `fk#__acym__step1` FOREIGN KEY(`automation_id`) REFERENCES `#__acym_automation` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE = InnoDB;' ); $this->updateQuery( 'CREATE TABLE IF NOT EXISTS `#__acym_condition` ( `id` INT NOT NULL AUTO_INCREMENT, `step_id` INT NOT NULL, `conditions` LONGTEXT NULL, PRIMARY KEY (`id`), CONSTRAINT `fk_#__acym_condition1` FOREIGN KEY (`step_id`) REFERENCES `#__acym_step` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE =InnoDB;' ); $this->updateQuery( 'CREATE TABLE IF NOT EXISTS `#__acym_action` ( `id` INT NOT NULL AUTO_INCREMENT, `condition_id` INT NOT NULL, `actions` LONGTEXT NULL, `filters` LONGTEXT NULL, `order` INT NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `fk_#__acym_action1` FOREIGN KEY (`condition_id`) REFERENCES `#__acym_condition` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE =InnoDB;' ); $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `automation` VARCHAR(50) NOT NULL'); $query = 'SELECT field.type AS type, userfield.user_id AS user_id, userfield.field_id AS field_id, userfield.value AS user_value FROM #__acym_user_has_field AS userfield JOIN #__acym_field AS field ON userfield.field_id = field.id WHERE field.type IN ("checkbox", "multiple_dropdown")'; $fieldValues = acym_loadObjectList($query); foreach ($fieldValues as $fieldValue) { $value = []; if ('checkbox' == $fieldValue->type) { $value = json_decode($fieldValue->user_value, true); $value = array_keys($value); } elseif ('multiple_dropdown' == $fieldValue->type) { $value = json_decode($fieldValue->user_value, true); } $value = implode(',', $value); $this->updateQuery('UPDATE #__acym_user_has_field SET `value` = '.acym_escapeDB($value).' WHERE user_id = '.intval($fieldValue->user_id).' AND field_id = '.intval($fieldValue->field_id)); } } if (version_compare($this->fromVersion, '6.1.2', '<')) { $this->updateQuery('ALTER TABLE #__acym_mail ADD `media_folder` VARCHAR(255) NULL'); $this->updateQuery('ALTER TABLE #__acym_field ADD `namekey` VARCHAR(255) NOT NULL'); $query = 'SELECT field.type AS type, userfield.user_id AS user_id, userfield.field_id AS field_id, userfield.value AS user_value FROM #__acym_user_has_field AS userfield JOIN #__acym_field AS field ON userfield.field_id = field.id WHERE field.type IN ("phone")'; $fieldValues = acym_loadObjectList($query); if (!empty($fieldValues)) { foreach ($fieldValues as $fieldValue) { $value = json_decode($fieldValue->user_value, true); $value = implode(',', $value); $this->updateQuery('UPDATE #__acym_user_has_field SET `value` = '.acym_escapeDB($value).' WHERE user_id = '.intval($fieldValue->user_id).' AND field_id = '.intval($fieldValue->field_id)); } } $fieldClass = acym_get('class.field'); $fields = acym_loadObjectList('SELECT * FROM #__acym_field'); foreach ($fields as $field) { if (!empty($field->namekey)) continue; $field->namekey = $fieldClass->generateNamekey($field->name); $fieldClass->save($field); } } if (version_compare($this->fromVersion, '6.1.3', '<')) { $this->updateQuery('UPDATE #__acym_user_has_list SET `status` = 1 WHERE `status` = 2'); } if (version_compare($this->fromVersion, '6.1.4', '<')) { $this->updateQuery('ALTER TABLE #__acym_mail ADD `headers` TEXT NULL'); $this->updateQuery('ALTER TABLE #__acym_mail ADD `autosave` LONGTEXT NULL'); $columns = acym_getColumns('condition'); if (!in_array('conditions', $columns)) { $this->updateQuery('ALTER TABLE #__acym_condition CHANGE `condition` `conditions` LONGTEXT NULL'); } $this->updateQuery('ALTER TABLE #__acym_automation ADD `admin` TINYINT(3) NULL'); } if (version_compare($this->fromVersion, '6.1.5', '<')) { $this->updateQuery('ALTER TABLE #__acym_mail ADD `preheader` VARCHAR(255) NULL'); $wrongRuleAddresses = acym_loadObjectList('SELECT `id`, `action_message` FROM `#__acym_rule` WHERE `action_message` LIKE "%\"forward_to\":\"\'%"'); if (!empty($wrongRuleAddresses)) { foreach ($wrongRuleAddresses as $oneRule) { $actions = json_decode($oneRule->action_message, true); $actions['forward_to'] = trim($actions['forward_to'], "'"); $this->updateQuery('UPDATE `#__acym_rule` SET `action_message` = '.acym_escapeDB(json_encode($actions)).' WHERE `id` = '.intval($oneRule->id)); } } $socialIcons = json_decode($config->get('social_icons', '{}'), true); if (!empty($socialIcons['google'])) { unset($socialIcons['google']); $newConfig = new stdClass(); $newConfig->social_icons = json_encode($socialIcons); $config->save($newConfig); } $mailsWithGoogle = acym_loadObjectList('SELECT `id`, `body` FROM `#__acym_mail` WHERE `body` LIKE "%googleplus%"'); foreach ($mailsWithGoogle as $oneMail) { $body = preg_replace('#]*googleplus[^>]*>[^<]*]*>[^<]*#Uis', '', $oneMail->body); if (empty($body)) continue; $this->updateQuery('UPDATE `#__acym_mail` SET `body` = '.acym_escapeDB($body).' WHERE `id` = '.intval($oneMail->id)); } $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_date` DATETIME DEFAULT NULL'); $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_ip` VARCHAR(16) DEFAULT NULL'); $mailClass = acym_get('class.mail'); $query = 'SELECT subject, id FROM #__acym_mail'; $mails = acym_loadObjectList($query); $mails = $mailClass->encode($mails); foreach ($mails as $oneMail) { $this->updateQuery('UPDATE #__acym_mail SET `subject` = '.acym_escapeDB($oneMail->subject).' WHERE `id` = '.intval($oneMail->id)); } } if (version_compare($this->fromVersion, '6.1.6', '<')) { $mailClass = acym_get('class.mail'); $mails = acym_loadObjectList('SELECT `id`, `name`, `body`, `autosave`, `preheader` FROM #__acym_mail'); $mails = $mailClass->encode($mails); foreach ($mails as $oneMail) { $this->updateQuery('UPDATE #__acym_mail SET `body` = '.acym_escapeDB($oneMail->body).', `autosave` = '.acym_escapeDB($oneMail->autosave).', `name` = '.acym_escapeDB($oneMail->name).', `preheader` = '.acym_escapeDB($oneMail->preheader).' WHERE `id` = '.intval($oneMail->id)); } } } function updateQuery($query) { try { $res = acym_query($query); } catch (Exception $e) { $res = null; } if ($res === null) { acym_enqueueNotification(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error', 0); } } }