예제 #1
0
 function upgrade()
 {
     parent::upgrade();
     if ($this->old_version < '1.0.2') {
         // Locked content configuration migration
         $old_options = Newsletter::instance()->get_options();
         if (isset($old_options['lock_message']) || isset($old_options['lock_ids']) || isset($old_options['lock_url'])) {
             $this->options['ids'] = $old_options['lock_ids'];
             $this->options['url'] = $old_options['lock_url'];
             $this->options['message'] = $old_options['lock_message'];
             $this->options['enabled'] = 1;
             $this->save_options($this->options);
             unset($old_options['lock_ids']);
             unset($old_options['lock_url']);
             unset($old_options['lock_message']);
             Newsletter::instance()->save_options($old_options);
         }
         $old_options = NewsletterSubscription::instance()->get_options('lock');
         if (!empty($old_options)) {
             $this->options['ids'] = $old_options['ids'];
             $this->options['url'] = $old_options['url'];
             $this->options['message'] = $old_options['message'];
             $this->options['enabled'] = 1;
             $this->save_options($this->options);
             NewsletterSubscription::instance()->delete_options('lock');
         }
     }
 }
예제 #2
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     // This before table creation or update for compatibility
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column date created timestamp not null default current_timestamp");
     // Just for test since it will be part of statistics module
     // This table stores clicks and email opens. An open is registered with a empty url.
     $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) {$charset_collate}");
     // References
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column email_id int not null default 0");
     // Future... see the links table
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column ip varchar(20) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column country varchar(4) not null default ''");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `email_id` (`email_id`)");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `user_id` (`user_id`)");
     // Stores the link of every email to create short links
     //        $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_links (id int auto_increment, primary key (id)) $charset_collate");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column email_id int not null default 0");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column token varchar(10) not null default ''");
     //        $this->upgrade_query("alter table {$wpdb->prefix}newsletter_links add column text varchar(255) not null default ''");
     //$this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) $charset_collate");
 }
예제 #3
0
 function upgrade()
 {
     parent::upgrade();
     if ($this->old_version < '1.0.0') {
         // Locked content configuration migration
         $old_options = $old_options = NewsletterSubscription::instance()->get_options();
         if (isset($old_options['wp_welcome'])) {
             $this->options['welcome'] = $old_options['wp_welcome'];
         }
         if (isset($old_options['wp_delete'])) {
             $this->options['delete'] = $old_options['wp_delete'];
         }
         if (isset($old_options['subscribe_wp_users_label'])) {
             $this->options['subscribe_label'] = $old_options['subscribe_wp_users_label'];
         }
         if (isset($old_options['subscribe_wp_users'])) {
             $this->options['subscribe'] = $old_options['subscribe_wp_users'];
         }
         if (isset($old_options['wp_send_confirmation'])) {
             $this->options['confirmation'] = $old_options['wp_send_confirmation'];
         }
         $this->save_options($this->options);
         unset($old_options['wp_welcome']);
         unset($old_options['wp_delete']);
         unset($old_options['subscribe_wp_users_label']);
         unset($old_options['subscribe_wp_users']);
         unset($old_options['wp_send_confirmation']);
         NewsletterSubscription::instance()->save_options($old_options);
     }
 }
예제 #4
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     // This before table creation or update for compatibility
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column newsletter_id user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats change column date created timestamp not null default current_timestamp");
     // Just for test since it will be part of statistics module
     // This table stores clicks and email opens. An open is registered with a empty url.
     $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_stats (id int auto_increment, primary key (id)) {$charset_collate}");
     // References
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column user_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column email_id int not null default 0");
     // Future... see the links table
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column ip varchar(20) not null default ''");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column country varchar(4) not null default ''");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `email_id` (`email_id`)");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_stats` ADD INDEX `user_id` (`user_id`)");
     if (empty($this->options['key'])) {
         $this->options['key'] = md5($_SERVER['REMOTE_ADDR'] . rand(100000, 999999) . time());
         $this->save_options($this->options);
     }
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_emails` ADD COLUMN `open_count` int UNSIGNED NOT NULL DEFAULT 0");
     $this->upgrade_query("ALTER TABLE `{$wpdb->prefix}newsletter_emails` ADD COLUMN `click_count`  int UNSIGNED NOT NULL DEFAULT 0");
     $this->upgrade_query("alter table {$wpdb->prefix}newsletter_emails change column read_count open_count int not null default 0");
 }
예제 #5
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column `type` `type` varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
     $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column private tinyint(1) not null default 0");
     // Force a token to email without one already set.
     $token = self::get_token();
     $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token='" . $token . "' where token=''");
     return true;
 }
예제 #6
0
 function __construct($module)
 {
     $this->module = $module;
     if (defined('NEWSLETTER_LOG_LEVEL')) {
         $this->level = NEWSLETTER_LOG_LEVEL;
     } else {
         $this->level = get_option('newsletter_log_level', self::ERROR);
     }
     $secret = get_option('newsletter_logger_secret');
     if (strlen($secret) < 8) {
         $secret = NewsletterModule::get_token(8);
         update_option('newsletter_logger_secret', $secret);
     }
     if (!wp_mkdir_p(NEWSLETTER_LOG_DIR)) {
         $this->level = self::NONE;
     }
     $this->file = NEWSLETTER_LOG_DIR . '/' . $module . '-' . $secret . '.txt';
 }
예제 #7
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_USERS_TABLE . " (id int auto_increment, `email` varchar(100) not null default '', primary key (id), unique key email (email)) {$charset_collate}");
     // User personal data
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column name varchar(100) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column surname varchar(100) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column sex char(1) not null default 'n'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " change column sex sex char(1) not null default 'n'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column status char(1) not null default 'S'");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column token varchar(50) not null default ''");
     // Feed by mail
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column feed tinyint(4) not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column feed_time bigint(20) not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column country varchar(4) not null default ''");
     // List/Preferences
     for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column list_{$i} tinyint(4) not null default 0");
     }
     // Profiles
     for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column profile_{$i} varchar(255) not null default ''");
     }
     // TODO: Still makes sense the referrer?
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column referrer varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column http_referer varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column wp_user_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column ip varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column test tinyint(4) not null default 0");
     // TODO: Flow module should add that it self (?)
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column flow tinyint(4) not null default 0");
     // Old problems...
     $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " convert to character set utf8");
     $this->upgrade_query("update " . NEWSLETTER_USERS_TABLE . " set sex='n' where sex='' or sex=' '");
     if ($this->old_version < '1.0.5') {
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column unsub_email_id int not null default 0");
         $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " add column unsub_time int not null default 0");
     }
 }
예제 #8
0
 function get_options($sub = '')
 {
     if ($sub == '') {
         // For compatibility the options are wrongly named
         return get_option('newsletter', array());
     }
     if ($sub == 'profile') {
         // For compatibility the options are wrongly named
         return get_option('newsletter_profile', array());
     }
     return parent::get_options($sub);
 }
예제 #9
0
파일: edit.php 프로젝트: taeche/SoDoEx
        $query .= ")";
    }
    $email['query'] = $query;
    if ($controls->is_action('test')) {
        $email['total'] = 0;
    } else {
        $email['total'] = $wpdb->get_var(str_replace('*', 'count(*)', $query));
    }
    $email['sent'] = 0;
    $email['last_id'] = 0;
    $email['send_on'] = $controls->data['send_on'];
    if ($controls->is_action('editor')) {
        $email['editor'] = $email['editor'] == 0 ? 1 : 0;
    }
    // Cleans up of tag
    $email['message'] = NewsletterModule::clean_url_tags($email['message']);
    $res = Newsletter::instance()->save_email($email);
    if ($res === false) {
        $controls->errors = 'Unable to save. Try to deactivate and reactivate the plugin may be the database is out of sync.';
    }
    $controls->data['message'] = $email['message'];
    $controls->messages .= 'Saved.<br>';
}
if ($controls->is_action('send')) {
    $wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'sending'), array('id' => $email_id));
    $email['status'] = 'sending';
    $controls->messages .= "Email added to the queue.";
}
if ($controls->is_action('pause')) {
    $wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'paused'), array('id' => $email_id));
    $email['status'] = 'paused';
예제 #10
0
     if (empty($controls->data['confirmed_subject'])) {
         $controls->data['confirmed_subject'] = $defaults['confirmed_subject'];
     }
     if (empty($controls->data['confirmed_message'])) {
         $controls->data['confirmed_message'] = $defaults['confirmed_message'];
     }
     if (empty($controls->data['unsubscribed_text'])) {
         $controls->data['unsubscribed_text'] = $defaults['unsubscribed_text'];
     }
     $controls->data['confirmed_message'] = NewsletterModule::clean_url_tags($controls->data['confirmed_message']);
     $controls->data['confirmed_text'] = NewsletterModule::clean_url_tags($controls->data['confirmed_text']);
     $controls->data['confirmation_text'] = NewsletterModule::clean_url_tags($controls->data['confirmation_text']);
     $controls->data['confirmation_message'] = NewsletterModule::clean_url_tags($controls->data['confirmation_message']);
     $controls->data['unsubscription_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscription_text']);
     $controls->data['unsubscribed_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_text']);
     $controls->data['unsubscribed_message'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_message']);
     $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
     $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
     $module->save_options($controls->data);
     $controls->messages = 'Saved.';
 }
 if ($controls->is_action('create')) {
     $page = array();
     $page['post_title'] = 'Newsletter';
     $page['post_content'] = '[newsletter]';
     $page['post_status'] = 'publish';
     $page['post_type'] = 'page';
     $page['comment_status'] = 'closed';
     $page['ping_status'] = 'closed';
     $page['post_category'] = array(1);
     // Insert the post into the database
예제 #11
0
}
if ($controls->is_action('bounces')) {
    $lines = explode("\n", $controls->data['bounced_emails']);
    $total = 0;
    $marked = 0;
    $error = 0;
    $not_found = 0;
    $already_bounced = 0;
    $results = '';
    foreach ($lines as &$email) {
        $email = trim($email);
        if (empty($email)) {
            continue;
        }
        $total++;
        $email = NewsletterModule::normalize_email($email);
        if (empty($email)) {
            $results .= '[INVALID] ' . $email . "\n";
            $error++;
            continue;
        }
        $user = NewsletterUsers::instance()->get_user($email);
        if ($user == null) {
            $results .= '[NOT FOUND] ' . $email . "\n";
            $not_found++;
            continue;
        }
        if ($user->status == 'B') {
            $results .= '[ALREADY BOUNCED] ' . $email . "\n";
            $already_bounced++;
            continue;
예제 #12
0
파일: grabber.php 프로젝트: kfwebdev/wp-atd
 function record()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return;
     }
     if (is_admin() && strpos($_SERVER['REQUEST_URI'], 'admin.php') !== false) {
         return;
     }
     if (!isset($this->options['record'])) {
         return;
     }
     if (!current_user_can('manage_options')) {
         return;
     }
     // Check if there is an email
     foreach ($_POST as $key => $value) {
         if (!NewsletterModule::is_email($value)) {
             continue;
         }
         add_option($this->prefix . '_record', '', null, 'no');
         update_option($this->prefix . '_record', stripslashes_deep($_POST));
         return;
     }
 }
예제 #13
0
     if (empty($controls->data['confirmation_message'])) {
         $controls->data['confirmation_message'] = $defaults['confirmation_message'];
     }
     if (empty($controls->data['confirmed_text'])) {
         $controls->data['confirmed_text'] = $defaults['confirmed_text'];
     }
     if (empty($controls->data['confirmed_subject'])) {
         $controls->data['confirmed_subject'] = $defaults['confirmed_subject'];
     }
     if (empty($controls->data['confirmed_message'])) {
         $controls->data['confirmed_message'] = $defaults['confirmed_message'];
     }
     $controls->data['confirmed_message'] = NewsletterModule::clean_url_tags($controls->data['confirmed_message']);
     $controls->data['confirmed_text'] = NewsletterModule::clean_url_tags($controls->data['confirmed_text']);
     $controls->data['confirmation_text'] = NewsletterModule::clean_url_tags($controls->data['confirmation_text']);
     $controls->data['confirmation_message'] = NewsletterModule::clean_url_tags($controls->data['confirmation_message']);
     $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
     $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
     // Checkboxes patch
     $options = get_option('newsletter', array());
     for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
         unset($options['preferences_' . $i]);
     }
     update_option('newsletter', $options);
     $module->merge_options($controls->data);
     $controls->messages = 'Saved.';
 }
 if ($controls->is_action('create')) {
     $page = array();
     $page['post_title'] = 'Newsletter';
     $page['post_content'] = '[newsletter]';
예제 #14
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     // WP does not manage composite primary key when it tries to upgrade a table...
     $suppress_errors = $wpdb->suppress_errors(true);
     dbDelta("CREATE TABLE " . $wpdb->prefix . "newsletter_sent (\n            email_id int(10) unsigned NOT NULL DEFAULT '0',\n            user_id int(10) unsigned NOT NULL DEFAULT '0',\n            status tinyint(1) unsigned NOT NULL DEFAULT '0',\n            open tinyint(1) unsigned NOT NULL DEFAULT '0',\n            time int(10) unsigned NOT NULL DEFAULT '0',\n            error varchar(100) NOT NULL DEFAULT '',\n\t    ip varchar(100) NOT NULL DEFAULT '',\n            PRIMARY KEY (email_id,user_id),\n            KEY user_id (user_id),\n            KEY email_id (email_id)\n          ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
     $wpdb->suppress_errors($suppress_errors);
     if ('utf8mb4' === $wpdb->charset) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     //wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     //wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     // If the original options has already saved once
     if (isset($options['smtp_host'])) {
         $smtp_options['enabled'] = $options['smtp_enabled'];
         $smtp_options['test_email'] = $options['smtp_test_email'];
         $smtp_options['host'] = $options['smtp_host'];
         $smtp_options['pass'] = $options['smtp_pass'];
         $smtp_options['port'] = $options['smtp_port'];
         $smtp_options['user'] = $options['smtp_user'];
         $smtp_options['secure'] = $options['smtp_secure'];
         $this->save_options($smtp_options, 'smtp');
         unset($options['smtp_enabled']);
         unset($options['smtp_test_email']);
         unset($options['smtp_pass']);
         unset($options['smtp_port']);
         unset($options['smtp_user']);
         unset($options['smtp_secure']);
         unset($options['smtp_host']);
         $this->save_options($options);
     }
     $this->init_options('smtp');
     return true;
 }
예제 #15
0
 function __construct()
 {
     parent::__construct('feed', '1.0.0');
 }
예제 #16
0
파일: module.php 프로젝트: taeche/SoDoEx
 /**
  * NEVER CHANGE THIS METHOD SIGNATURE, USER BY THIRD PARTY PLUGINS.
  *
  * Saves a new user on the database. Return false if the email (that must be unique) is already
  * there. For a new users set the token and creation time if not passed.
  *
  * @param array|object $user
  */
 function save_user($user, $return_format = OBJECT)
 {
     if (is_object($user)) {
         $user = (array) $user;
     }
     if (empty($user['id'])) {
         $existing = $this->get_user($user['email']);
         if ($existing != null) {
             return false;
         }
         if (empty($user['token'])) {
             $user['token'] = NewsletterModule::get_token();
         }
         //if (empty($user['created'])) $user['created'] = time();
         // Database default
         //if (empty($user['status'])) $user['status'] = 'S';
     }
     // Due to the unique index on email field, this can fail.
     return $this->store->save(NEWSLETTER_USERS_TABLE, $user, $return_format);
 }
예제 #17
0
 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     if ($charset_collate != 'utf8mb4') {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     return true;
 }
예제 #18
0
    }
    if (!$found) {
        echo 'The "newsletter" schedule was not found, email delivery won\'t work.';
    }
}
?>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                Delivery Engine
                            </td>
                            <td>
                                <?php 
echo NewsletterModule::format_scheduler_time('newsletter');
?>
                                <?php 
$controls->button('trigger', 'Trigger now');
?>
                                <p class="description">
                                    If inactive or always in "running now" status your blog has a problem: <a href="http://www.thenewsletterplugin.com/how-to-make-the-wordpress-cron-work" target="_blank">read more here</a>.
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td>Collected samples</td>
                            <td>
                                <?php 
echo count($calls);
?>