Ejemplo n.º 1
0
 /**
  * @return NewsletterSubscription
  */
 static function instance()
 {
     if (self::$instance == null) {
         self::$instance = new NewsletterSubscription();
     }
     return self::$instance;
 }
Ejemplo n.º 2
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');
         }
     }
 }
Ejemplo n.º 3
0
 function hook_wp_loaded()
 {
     global $newsletter, $wpdb;
     switch ($newsletter->action) {
         case 'v':
             // TODO: Change to Newsletter::instance()->get:email(), not urgent
             $email = $this->get_email((int) $_GET['id']);
             if (empty($email)) {
                 die('Email not found');
             }
             if ($email->private == 1) {
                 die('Email not found');
             }
             $user = NewsletterSubscription::instance()->get_user_from_request();
             header('Content-Type: text/html;charset=UTF-8');
             header('X-Robots-Tag: noindex,nofollow,noarchive');
             header('Cache-Control: no-cache,no-store,private');
             if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
                 include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
                 die;
             }
             echo $newsletter->replace($email->message, $user, $email->id);
             die;
     }
 }
Ejemplo n.º 4
0
 public function actionUnsuscribe($token)
 {
     $entry = unserialize(base64_decode($token));
     if (!($model = NewsletterSubscription::model()->findByAttributes(array('id' => (int) $entry['id'], 'email' => $entry['email'])))) {
         throw new CHttpException(403);
     } else {
         $model->delete();
     }
     $this->render('unsuscribe');
 }
Ejemplo n.º 5
0
 function hook_init()
 {
     add_shortcode('newsletter_profile', array($this, 'shortcode_profile'));
     add_shortcode('newsletter_subscription', array($this, 'shortcode_subscription'));
     add_shortcode('newsletter_field', array($this, 'shortcode_field'));
     $action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
     if (empty($action) || is_admin()) {
         return;
     }
     if ($action == 's') {
         $user = $this->subscribe();
         if ($user->status == 'E') {
             $this->show_message('error', $user->id);
         }
         if ($user->status == 'C') {
             $this->show_message('confirmation', $user->id);
         }
         if ($user->status == 'S') {
             $this->show_message('confirmed', $user->id);
         }
     } else {
         if ($action == 'c') {
             $user = NewsletterSubscription::instance()->confirm();
             $this->show_message('confirmed', $user);
         } else {
             if ($action == 'u') {
                 $user = $this->get_user_from_request();
                 if ($user == null) {
                     die('No subscriber found.');
                 }
                 $this->show_message('unsubscription', $user->id);
             } else {
                 if ($action == 'uc') {
                     $user = $this->unsubscribe();
                     if ($user->status == 'E') {
                         $this->show_message('error', $user->id);
                     } else {
                         $this->show_message('unsubscribed', $user);
                     }
                 } else {
                     if ($action == 'p' || $action == 'pe') {
                         $user = $this->get_user_from_request();
                         if ($user == null) {
                             die('No subscriber found.');
                         }
                         $this->show_message('profile', $user);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
<?php

header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
    require_once '../../../../wp-load.php';
}
$user = NewsletterSubscription::instance()->check_user();
if ($user == null) {
    die('No subscriber found.');
}
NewsletterSubscription::instance()->show_message('profile', $user);
Ejemplo n.º 7
0
    ?>
<div class="newsletter-notice">
    I never asked before and I'm curious: <a href="http://wordpress.org/extend/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
    (few seconds required). (account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
    <div class="newsletter-dismiss"><a href="<?php 
    echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=rate');
    ?>
">Dismiss</a></div>
    <div style="clear: both"></div>
</div>
<?php 
}
?>

<?php 
if (isset($dismissed['newsletter-page']) && $dismissed['newsletter-page'] != 1 && empty(NewsletterSubscription::instance()->options['url'])) {
    ?>
<div class="newsletter-notice">
    Create a page with your blog style to show the subscription form and the subscription messages. Go to the
    <a href="?page=newsletter_subscription_options">subscription panel</a> to
    configure it.
    <div class="newsletter-dismiss"><a href="<?php 
    echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page');
    ?>
">Dismiss</a></div>
    <div style="clear: both"></div>
</div>
<?php 
}
?>
Ejemplo n.º 8
0
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
    if (empty($options_lists['list_' . $i])) {
        continue;
    }
    $lists['' . $i] = '(' . $i . ') ' . $options_lists['list_' . $i];
}
if ($controls->is_action('resend')) {
    $user = NewsletterUsers::instance()->get_user($controls->button_data);
    $opts = get_option('newsletter');
    NewsletterSubscription::instance()->mail($user->email, $newsletter->replace($opts['confirmation_subject'], $user), $newsletter->replace($opts['confirmation_message'], $user));
    $controls->messages = 'Activation email resent to ' . $user->email;
}
if ($controls->is_action('resend_welcome')) {
    $user = NewsletterUsers::instance()->get_user($controls->button_data);
    $opts = get_option('newsletter');
    NewsletterSubscription::instance()->mail($user->email, $newsletter->replace($opts['confirmed_subject'], $user), $newsletter->replace($opts['confirmed_message'], $user));
    $controls->messages = 'Welcome email resent.';
}
if ($controls->is_action('remove')) {
    $wpdb->query($wpdb->prepare("delete from " . NEWSLETTER_USERS_TABLE . " where id=%d", $controls->button_data));
    unset($controls->data['subscriber_id']);
}
// We build the query condition
$where = "where 1=1";
$query_args = array();
$text = trim($controls->data['search_text']);
if ($text != '') {
    $query_args[] = '%' . $text . '%';
    $query_args[] = '%' . $text . '%';
    $query_args[] = '%' . $text . '%';
    $where .= " and (email like %s or name like %s or surname like %s)";
Ejemplo n.º 9
0
 function widget($args, $instance)
 {
     global $newsletter;
     extract($args);
     echo $before_widget;
     // Filters are used for WPML
     if (!empty($instance['title'])) {
         $title = apply_filters('widget_title', $instance['title'], $instance);
         echo $before_title . $title . $after_title;
     }
     $buffer = apply_filters('widget_text', $instance['text'], $instance);
     $options = get_option('newsletter');
     $options_profile = get_option('newsletter_profile');
     if (stripos($instance['text'], '<form') === false) {
         $form = NewsletterSubscription::instance()->get_form_javascript();
         $form .= '<div class="newsletter newsletter-widget">';
         $form .= NewsletterWidget::get_widget_form();
         $form .= '</div>';
         // Canot user directly the replace, since the form is different on the widget...
         if (strpos($buffer, '{subscription_form}') !== false) {
             $buffer = str_replace('{subscription_form}', $form, $buffer);
         } else {
             if (strpos($buffer, '{subscription_form_') !== false) {
                 // TODO: Optimize with a method to replace only the custom forms
                 $buffer = $newsletter->replace($buffer);
             } else {
                 $buffer .= $form;
             }
         }
     } else {
         $buffer = str_ireplace('<form', '<form method="post" action="' . esc_attr(plugins_url('newsletter/do/subscribe.php')) . '" onsubmit="return newsletter_check(this)"', $buffer);
         $buffer = str_ireplace('</form>', '<input type="hidden" name="nr" value="widget"/></form>', $buffer);
     }
     // That replace all the remaining tags
     $buffer = $newsletter->replace($buffer);
     echo $buffer;
     echo $after_widget;
 }
Ejemplo n.º 10
0
global $logger;
unset($_SESSION['bookingDetails']);
$logger->LogInfo(__FILE__);
$logger->LogDebug("Script is starting ...");
$errorMessage = "";
$successMessage = "";
if (sizeof($_POST) > 0) {
    $logger->LogInfo("Processing newsletter subscription ...");
    $systemConfiguration->assertReferer();
    if (isset($_POST['email'])) {
        $emailAddress = trim($_POST['email']);
        $logger->LogDebug("Email address for newsletter was specified.");
        $logger->LogDebug($emailAddress);
        $subscription = NewsletterSubscription::fetchFromDbForEmail($emailAddress);
        if ($subscription == null) {
            $subscription = new NewsletterSubscription();
        }
        $subscription->email = $emailAddress;
        $subscription->isActive = true;
        $logger->LogDebug("Saving subscription ...");
        if ($subscription->save()) {
            $logger->LogDebug("Saving is successful.");
            $successMessage = HOME_BOX_BOTTOM_LEFT_SUCCESS;
        } else {
            $logger->LogError("Saving FAILED!");
            $logger->LogError($subscription->errors);
            $errorMessage = BOOKING_DETAILS_EMAIL_INVALID;
        }
    }
}
$logger->LogDebug("Starting HTML ...");
<?php

// TODO: Uncomment
include "access.php";
include_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
$id = 0;
$errors = array();
$logger->LogInfo("Attempting to deactivate newsletter subscription ...");
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = intval($_GET['id']);
    if (!NewsletterSubscription::deactivate($id)) {
        $logger->LogError("Error deactivating newsletter subscription.");
        foreach (NewsletterSubscription::$staticErrors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        header("Location: newsletter_subscriptions_list.php");
    }
} else {
    $errors[] = "Invalid request: Newsletter Subscription id was not set";
    $logger->LogError("Newsletter Subscription id is not set.");
}
include "header.php";
?>


</td>
</tr>
Ejemplo n.º 12
0
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
    require_once '../../../../wp-load.php';
}
if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
    $user = NewsletterSubscription::instance()->unsubscribe();
    if ($user->status == 'E') {
        NewsletterSubscription::instance()->show_message('unsubscription_error', $user);
    } else {
        NewsletterSubscription::instance()->show_message('unsubscribed', $user);
    }
} else {
    $url = plugins_url('newsletter') . '/do/unsubscribe.php?';
    foreach ($_REQUEST as $name => $value) {
        $url .= urlencode($name) . '=' . urlencode($value) . '&';
    }
    $url .= '&ts=' . time();
    ?>
<!DOCTYPE html>
    <html>
        <head>
            <script>
                location.href = location.href + "&ts=<?php 
    echo time();
    ?>
Ejemplo n.º 13
0
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
    require_once '../../../../wp-load.php';
}
if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
    $user = NewsletterSubscription::instance()->confirm();
    if ($user->status == 'E') {
        NewsletterSubscription::instance()->show_message('error', $user->id);
    } else {
        NewsletterSubscription::instance()->show_message('confirmed', $user);
    }
} else {
    $url = plugins_url('newsletter') . '/do/confirm.php?';
    foreach ($_REQUEST as $name => $value) {
        $url .= urlencode($name) . '=' . urlencode($value) . '&';
    }
    $url .= '&ts=' . time();
    ?>
<!DOCTYPE html>
    <html>
        <head>
            <script>
                location.href = location.href + "&ts=<?php 
    echo time();
    ?>
 public function isValid()
 {
     $this->errors = array();
     if (!preg_match(Client::$EMAIL_REGEX, $this->email)) {
         $this->setError(BOOKING_DETAILS_EMAIL_INVALID);
     } else {
         $sub = NewsletterSubscription::fetchFromDbForEmail($this->email);
         if ($sub != null && $sub->id != $this->id) {
             $this->setError("Subscription with email: " . $this->email . " already exists");
         }
     }
     return sizeof($this->errors) == 0;
 }
Ejemplo n.º 15
0
 function hook_subscription_user_register($wp_user_id)
 {
     global $wpdb;
     // If the integration is disabled...
     if ($this->options['subscribe'] == 0) {
         return;
     }
     // If not forced and the user didn't choose the newsletter...
     if ($this->options['subscribe'] != 1) {
         if (!isset($_REQUEST['newsletter'])) {
             return;
         }
     }
     $this->logger->info('Adding a registered WordPress user (' . $wp_user_id . ')');
     $wp_user = $wpdb->get_row($wpdb->prepare("select * from {$wpdb->users} where id=%d limit 1", $wp_user_id));
     if (empty($wp_user)) {
         $this->logger->error('User not found?!');
         return;
     }
     // Yes, some registration procedures allow empty email
     if (!$this->is_email($wp_user->user_email)) {
         return;
     }
     $_REQUEST['ne'] = $wp_user->user_email;
     $_REQUEST['nr'] = 'registration';
     // Upon registration there is no last name and first name, sorry.
     // $status is determined by the opt in
     $user = NewsletterSubscription::instance()->subscribe(null, $this->options['confirmation'] == 1);
     // Now we associate it with wp
     $this->set_user_wp_user_id($user->id, $wp_user_id);
 }
Ejemplo n.º 16
0
<?php

header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
    include '../../../../wp-load.php';
}
$user = NewsletterSubscription::instance()->check_user();
if ($user == null || $user->status != 'C') {
    echo 'Subscriber not found, sorry.';
    die;
}
$options_main = get_option('newsletter_main', array());
setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
header('Location: ' . $options_main['lock_url']);
die;
Ejemplo n.º 17
0
 public function actionGetsubs($key, $limit, $offset)
 {
     $subscriptions = NewsletterSubscription::model()->findAll(array('limit' => $limit, 'offset' => $offset, 'order' => 'id ASC'));
     $this->render('getsubs', array('subs' => $subscriptions));
     Yii::app()->end();
 }
Ejemplo n.º 18
0
            die('Invalid sex value');
        }
        NewsletterUsers::instance()->set_user_field($user->id, 'sex', $value);
        break;
        // Should be managed by Feed by Mail
    // Should be managed by Feed by Mail
    case 'feed':
        if (isset($value) && ($value === '0' || $value === '1')) {
            NewsletterUsers::instance()->set_user_field($user->id, 'feed', $value);
        } else {
            die('Invalid feed value');
        }
        break;
}
if (strpos($field, 'preference_') === 0) {
    $idx = (int) substr($field, 11);
    $options_profile = get_option('newsletter_profile');
    if ($options_profile['list_' . $idx . '_status'] == 0) {
        die('Not allowed field.');
    }
    if (isset($value) && ($value === '0' || $value === '1')) {
        NewsletterUsers::instance()->set_user_field($user->id, 'list_' . $idx, $value);
    } else {
        die('Invalid preference value');
    }
}
if (isset($url)) {
    header("Location: {$url}");
} else {
    NewsletterSubscription::instance()->show_message('profile', $user, NewsletterSubscription::instance()->options['profile_saved']);
}
Ejemplo n.º 19
0
            </div>


            <div id="tabs-5">

                <p>This panel shows the form HTML code generated by Newsletter if you want to copy it as starting point for a custom form.</p>

                <h3>Standard form code</h3>
                <textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php 
echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form());
?>
</textarea>

                <h3>Widget form code</h3>
                <textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php 
echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form());
?>
</textarea>

            </div>

            <div id="tabs-6">

                <table class="form-table">
                    <tr>
                        <th>Subscription form style</th>
                        <td>
                            <?php 
$controls->select('style', $module->get_styles());
?>
                        </td>
Ejemplo n.º 20
0
 function grab()
 {
     global $wpdb, $current_user, $newsletter;
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return;
     }
     for ($i = 0; $i < $this->rules_max; $i++) {
         if (!isset($this->options['rule_' . $i . '_enabled'])) {
             continue;
         }
         if ($this->options['rule_' . $i . '_enabled'] != 1) {
             continue;
         }
         $field = trim($this->options['rule_' . $i . '_check_field']);
         if (empty($field) || !isset($_POST[$field])) {
             continue;
         }
         $value = $this->options['rule_' . $i . '_check_value'];
         //if (!empty($value) && $value != $_POST[$field])
         //    continue;
         add_option($this->prefix . '_data', array(), null, 'no');
         $data = array();
         $data['ip'] = $_SERVER['REMOTE_ADDR'];
         $data['time'] = time();
         if (isset($this->options['rule_' . $i . '_auto'])) {
             foreach ($_POST as $key => $value) {
                 if (!NewsletterModule::is_email($value)) {
                     continue;
                 }
                 $_REQUEST['ne'] = $value;
                 $user = NewsletterSubscription::instance()->subscribe();
                 $data['email'] = $value;
                 update_option($this->prefix . '_data', $data);
                 return;
             }
         } else {
             if (is_user_logged_in()) {
                 get_currentuserinfo();
             }
             $email = sanitize_email($_POST[$this->options['rule_' . $i . '_email_field']]);
             if (empty($email) && is_user_logged_in()) {
                 $email = $current_user->user_email;
             }
             $check = sanitize_text_field($_POST[$this->options['rule_' . $i . '_check_field']]);
             if (!Newsletter::is_email($email)) {
                 continue;
             }
             $_REQUEST['ne'] = $email;
             $user = NewsletterSubscription::instance()->subscribe();
             $data['email'] = $email;
             update_option($this->prefix . '_data', $data);
             if (!empty($current_user->user_email) && $check === 'No, I can remember') {
                 $wpdb->query($wpdb->prepare("update " . NEWSLETTER_USERS_TABLE . " set status='U', email=%s", $current_user->user_email));
             } else {
                 if (!empty($current_user->user_email) && $check === 'Yes, I want Updates') {
                     $wpdb->query($wpdb->prepare("update " . NEWSLETTER_USERS_TABLE . " set status='C', email=%s", $current_user->user_email));
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
if (!isset($module->options['antibot'])) {
    $module->options['antibot'] = 0;
}
if ($module->options['antibot'] == 0 || $module->options['antibot'] == 1 && isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
    $user = NewsletterSubscription::instance()->subscribe();
    if ($user->status == 'E') {
        NewsletterSubscription::instance()->show_message('error', $user->id);
    }
    if ($user->status == 'C') {
        NewsletterSubscription::instance()->show_message('confirmed', $user->id);
    }
    if ($user->status == 'A') {
        NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
    }
    if ($user->status == 'S') {
        NewsletterSubscription::instance()->show_message('confirmation', $user->id);
    }
} else {
    ?>
<!DOCTYPE html>
    <html>
        <head>

        </head>
        <body onload="document.getElementById('form').action = '?ts=<?php 
    echo time();
    ?>
';document.getElementById('form').submit()">
            <form id="form" action="<?php 
    echo plugins_url('newsletter');
    ?>
Ejemplo n.º 22
0
<?php

// This page is used to show subscription messages to users along the various
// subscription and unsubscription steps.
//
// This page is used ONLY IF, on main configutation, you have NOT set a specific
// WordPress page to be used to show messages and when there are no alternative
// URLs specified on single messages.
//
// To create an alternative to this file, just copy the page-alternative.php on
//
//   wp-content/extensions/newsletter/subscription/page.php
//
// and modify that copy.
include '../../../../wp-load.php';
$module = NewsletterSubscription::instance();
$user = $module->get_user_from_request();
$message_key = $module->get_message_key_from_request();
$message = $newsletter->replace($module->options[$message_key . '_text'], $user);
$message .= $module->options[$message_key . '_tracking'];
$alert = stripslashes($_REQUEST['alert']);
// Force the UTF-8 charset
header('Content-Type: text/html;charset=UTF-8');
if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/subscription/page.php')) {
    include WP_CONTENT_DIR . '/extensions/newsletter/subscription/page.php';
    die;
}
redirect_to_page(HOME . '/successubscription?message=' . $message);
?>
<html>
    <head>
Ejemplo n.º 23
0
    <div class="notice">
        <a href="<?php 
    echo $_SERVER['REQUEST_URI'] . '&dismiss=rate';
    ?>
" class="dismiss">&times;</a>
        <p>
            We never asked before and we're curious: <a href="http://wordpress.org/extend/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
            (few seconds required - account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
        </p>
    </div>
<?php 
}
?>

<?php 
if (NEWSLETTER_DEBUG || !isset($dismissed['newsletter-page']) && empty(NewsletterSubscription::instance()->options['url'])) {
    ?>
    <div class="notice">
        <a href="<?php 
    echo $_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page';
    ?>
" class="dismiss">&times;</a>
        <p>
            You should create a blog page to show the subscription form and the subscription messages. Go to the
            <a href="?page=newsletter_subscription_options">subscription panel</a> to
            configure it.
        </p>
    </div>
<?php 
}
?>
<?php

// TODO: Uncomment
include "access.php";
require_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
$newsletterSubscriptions = NewsletterSubscription::fetchAllFromDb();
include "header.php";
?>

</td>
  </tr> 
  
  <tr>
    <td valign="top" >    
    <fieldset>
	    <legend class="TitleBlue11pt">Newsletter Subscriptions</legend>
	    	<table cellspacing="1" border="0" cellpadding="3" width="100%">				
				<tr bgcolor="#747471">
					<td scope="col" align="center"><b><font color="white"
						face="Verdana, Arial, Helvetica, sans-serif" size="2">Email</font></b>
					</td>												
					<td scope="col" align="center"><b><font color="white"
						face="Verdana, Arial, Helvetica, sans-serif" size="2">Active</font></b>
					</td>
					<td scope="col" align="center"><b><font color="white"
						face="Verdana, Arial, Helvetica, sans-serif" size="2">Subscription Date</font></b>
					</td>					
					<td scope="col" align="center">&nbsp;</td>					
				</tr>
Ejemplo n.º 25
0
 function hook_wp_loaded()
 {
     global $newsletter, $wpdb;
     switch ($newsletter->action) {
         case 's':
             if (isset($this->options['antibot_disable']) || NewsletterModule::antibot_form_check()) {
                 $user = NewsletterSubscription::instance()->subscribe();
                 if ($user->status == 'E') {
                     NewsletterSubscription::instance()->show_message('error', $user->id);
                 }
                 if ($user->status == 'C') {
                     NewsletterSubscription::instance()->show_message('confirmed', $user->id);
                 }
                 if ($user->status == 'A') {
                     NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
                 }
                 if ($user->status == 'S') {
                     NewsletterSubscription::instance()->show_message('confirmation', $user->id);
                 }
             } else {
                 NewsletterModule::request_to_antibot_form('Subscribe');
             }
             die;
         case 'u':
             $user = NewsletterSubscription::instance()->get_user_from_request();
             if ($user == null) {
                 NewsletterSubscription::instance()->show_message('unsubscription_error', null);
             } else {
                 NewsletterSubscription::instance()->show_message('unsubscription', $user);
             }
             die;
             break;
         case 'uc':
             if ($this->antibot_form_check()) {
                 $user = NewsletterSubscription::instance()->unsubscribe();
                 if ($user->status == 'E') {
                     NewsletterSubscription::instance()->show_message('unsubscription_error', $user);
                 } else {
                     NewsletterSubscription::instance()->show_message('unsubscribed', $user);
                 }
                 return;
             } else {
                 $this->request_to_antibot_form('Unsubscribe');
             }
             die;
             break;
         case 'p':
         case 'pe':
             $user = NewsletterSubscription::instance()->check_user();
             if ($user == null) {
                 die('No subscriber found.');
             }
             NewsletterSubscription::instance()->show_message('profile', $user);
             die;
             break;
         case 'c':
             if ($this->antibot_form_check()) {
                 $user = NewsletterSubscription::instance()->confirm();
                 if ($user->status == 'E') {
                     NewsletterSubscription::instance()->show_message('error', $user->id);
                 } else {
                     setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
                     NewsletterSubscription::instance()->show_message('confirmed', $user);
                 }
             } else {
                 $this->request_to_antibot_form('Confirm');
             }
             die;
             break;
         case 'ul':
             $user = NewsletterSubscription::instance()->check_user();
             if ($user == null || $user->status != 'C') {
                 echo 'Subscriber not found, sorry.';
                 die;
             }
             $options = $this->get_options('lock');
             setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
             header('Location: ' . $options['url']);
             die;
             break;
         default:
             return;
     }
     die;
 }
Ejemplo n.º 26
0
    $controls->messages = 'Notices restored.';
}
if ($controls->is_action('trigger_followup')) {
    NewsletterFollowup::instance()->send();
    $controls->messages = 'Follow up delivery engine triggered.';
}
if ($controls->is_action('engine_on')) {
    wp_clear_scheduled_hook('newsletter');
    wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
    $controls->messages = 'Delivery engine reactivated.';
}
if ($controls->is_action('upgrade')) {
    // TODO: Compact them in a call to Newsletter which should be able to manage the installed modules
    Newsletter::instance()->upgrade();
    NewsletterUsers::instance()->upgrade();
    NewsletterSubscription::instance()->upgrade();
    NewsletterEmails::instance()->upgrade();
    NewsletterStatistics::instance()->upgrade();
    if (method_exists('NewsletterFollowup', 'upgrade')) {
        NewsletterFollowup::instance()->upgrade();
    }
    $controls->messages = 'Upgrade forced!';
}
if ($controls->is_action('upgrade_old')) {
    $row = $wpdb->get_row("select * from " . NEWSLETTER_USERS_TABLE . " limit 1");
    if (!isset($row->id)) {
        $row = $wpdb->query("alter table " . NEWSLETTER_USERS_TABLE . " drop primary key");
        $row = $wpdb->query("alter table " . NEWSLETTER_USERS_TABLE . " add column id int not null auto_increment primary key");
        $row = $wpdb->query("alter table " . NEWSLETTER_USERS_TABLE . " add unique email (email)");
    }
    $controls->messages = 'Done.';
Ejemplo n.º 27
0
 /**
  * Replace any kind of newsletter placeholder in a text.
  */
 function replace($text, $user = null, $email_id = null, $referrer = null)
 {
     global $wpdb;
     $this->logger->debug('Replace start');
     if (is_array($user)) {
         $user = $this->get_user($user['id']);
     }
     $email = null;
     if (is_numeric($email_id)) {
         $email = $this->get_email($email_id);
     }
     $text = apply_filters('newsletter_replace', $text, $user, $email);
     //$text = str_replace('{home_url}', get_option('home'), $text);
     //$text = str_replace('{blog_url}', get_option('home'), $text);
     $text = $this->replace_url($text, 'BLOG_URL', get_option('home'));
     $text = $this->replace_url($text, 'HOME_URL', get_option('home'));
     $text = str_replace('{blog_title}', get_option('blogname'), $text);
     $text = str_replace('{blog_description}', get_option('blogdescription'), $text);
     $text = $this->replace_date($text);
     if ($user != null) {
         $options_profile = get_option('newsletter_profile');
         $text = str_replace('{email}', $user->email, $text);
         if (empty($user->name)) {
             $text = str_replace(' {name}', '', $text);
             $text = str_replace('{name}', '', $text);
         } else {
             $text = str_replace('{name}', $user->name, $text);
         }
         switch ($user->sex) {
             case 'm':
                 $text = str_replace('{title}', $options_profile['title_male'], $text);
                 break;
             case 'f':
                 $text = str_replace('{title}', $options_profile['title_female'], $text);
                 break;
             case 'n':
                 $text = str_replace('{title}', $options_profile['title_none'], $text);
                 break;
             default:
                 $text = str_replace('{title}', '', $text);
         }
         $text = str_replace('{surname}', $user->surname, $text);
         $text = str_replace('{last_name}', $user->surname, $text);
         $full_name = trim($user->name . ' ' . $user->surname);
         if (empty($full_name)) {
             $text = str_replace(' {full_name}', '', $text);
             $text = str_replace('{full_name}', '', $text);
         } else {
             $text = str_replace('{full_name}', $full_name, $text);
         }
         $text = str_replace('{token}', $user->token, $text);
         $text = str_replace('%7Btoken%7D', $user->token, $text);
         $text = str_replace('{id}', $user->id, $text);
         $text = str_replace('%7Bid%7D', $user->id, $text);
         $text = str_replace('{ip}', $user->ip, $text);
         $text = str_replace('{key}', $user->id . '-' . $user->token, $text);
         $text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
         if (strpos($text, '{profile_form}') !== false) {
             $text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form($user), $text);
         }
         for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
             $p = 'profile_' . $i;
             $text = str_replace('{profile_' . $i . '}', $user->{$p}, $text);
         }
         //            $profile = $wpdb->get_results("select name,value from " . $wpdb->prefix . "newsletter_profiles where newsletter_id=" . $user->id);
         //            foreach ($profile as $field) {
         //                $text = str_ireplace('{np_' . $field->name . '}', htmlspecialchars($field->value), $text);
         //            }
         //
         //            $text = preg_replace('/\\{np_.+\}/i', '', $text);
         $base = empty($this->options_main['url']) ? get_option('home') : $this->options_main['url'];
         $id_token = '&amp;ni=' . $user->id . '&amp;nt=' . $user->token;
         $nk = $user->id . '-' . $user->token;
         $options_subscription = NewsletterSubscription::instance()->options;
         if (!empty($options_subscription['action_url'])) {
             $home_url = home_url();
             //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
             $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
             $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=uc&nk=' . $nk);
             //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
             $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=u&nk=' . $nk);
             $text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
             // Obsolete.
             $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
             $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
             $text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
             $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
             if (empty($options_profile['profile_url'])) {
                 $text = $this->replace_url($text, 'PROFILE_URL', $home_url . '?na=p&nk=' . $nk);
             } else {
                 $text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&amp;nt=' . $user->token));
             }
             //$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
             $text = $this->replace_url($text, 'UNLOCK_URL', $home_url . '?na=ul&nk=' . $nk);
             if (!empty($email_id)) {
                 $text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email_id . '&amp;nk=' . $nk);
             }
         } else {
             //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
             $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/confirm.php') . '?nk=' . $nk);
             $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/unsubscribe.php') . '?nk=' . $nk);
             //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
             $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', plugins_url('newsletter/do/unsubscription.php') . '?nk=' . $nk);
             $text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
             // Obsolete.
             $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
             $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
             $text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
             $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
             if (empty($options_profile['profile_url'])) {
                 $text = $this->replace_url($text, 'PROFILE_URL', plugins_url('newsletter/do/profile.php') . '?nk=' . $nk);
             } else {
                 $text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&amp;nt=' . $user->token));
             }
             //$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
             $text = $this->replace_url($text, 'UNLOCK_URL', plugins_url('newsletter/do/unlock.php') . '?nk=' . $nk);
             if (!empty($email_id)) {
                 $text = $this->replace_url($text, 'EMAIL_URL', plugins_url('newsletter/do/view.php') . '?id=' . $email_id . '&amp;nk=' . $nk);
             }
         }
         for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
             $text = $this->replace_url($text, 'LIST_' . $i . '_SUBSCRIPTION_URL', self::add_qs($base, 'nm=ls&amp;nl=' . $i . $id_token));
             $text = $this->replace_url($text, 'LIST_' . $i . '_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=lu&amp;nl=' . $i . $id_token));
         }
         // Profile fields change links
         $text = $this->replace_url($text, 'SET_SEX_MALE', NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nf=sex&nv=m');
         $text = $this->replace_url($text, 'SET_SEX_FEMALE', NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nf=sex&nv=f');
         $text = $this->replace_url($text, 'SET_FEED', NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nv=1&nf=feed');
         $text = $this->replace_url($text, 'UNSET_FEED', NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nv=0&nf=feed');
         for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
             $text = $this->replace_url($text, 'SET_PREFERENCE_' . $i, NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nv=1&nf=preference_' . $i);
             $text = $this->replace_url($text, 'UNSET_PREFERENCE_' . $i, NEWSLETTER_CHANGE_URL . '?nk=' . $nk . '&nv=0&nf=preference_' . $i);
         }
     }
     if (strpos($text, '{subscription_form}') !== false) {
         $text = str_replace('{subscription_form}', NewsletterSubscription::instance()->get_subscription_form($referrer), $text);
     } else {
         for ($i = 1; $i <= 10; $i++) {
             if (strpos($text, "{subscription_form_{$i}}") !== false) {
                 $text = str_replace("{subscription_form_{$i}}", NewsletterSubscription::instance()->get_form($i), $text);
                 break;
             }
         }
     }
     $this->logger->debug('Replace end');
     return $text;
 }
Ejemplo n.º 28
0
<?php

/**
 * This is a generic viewer for sent emails. It is not binded to one shot emails, it can display even the emails from
 * updates or feed by mail module.
 */
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
include '../../../../wp-load.php';
// TODO: Change to Newsletter::instance()->get:email(), not urgent
$email = Newsletter::instance()->get_email((int) $_GET['id']);
if (empty($email)) {
    die('Email not found');
}
$user = NewsletterSubscription::instance()->get_user_from_request();
if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
    include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
    die;
}
echo $newsletter->replace($email->message, $user, $email->id);
Ejemplo n.º 29
0
/**
 * Block an email address from all newsletters
 *
 * @param string $email The email address to block
 *
 * @return boolean True on success, false on failure
 */
function newsletter_unsubscribe_all_email($email)
{
    $result = false;
    if (!empty($email) && newsletter_is_email_address($email)) {
        // get subscription
        $subscription = newsletter_get_subscription($email);
        if (empty($subscription)) {
            $subscription = new NewsletterSubscription();
            $subscription->title = $email;
            if (!$subscription->save()) {
                return false;
            }
            // remove all existing subscriptions
            remove_entity_relationships($subscription->getGUID(), NewsletterSubscription::SUBSCRIPTION);
            // add to general blacklist
            $site = elgg_get_site_entity();
            $result = (bool) add_entity_relationship($subscription->getGUID(), NewsletterSubscription::GENERAL_BLACKLIST, $site->getGUID());
        }
    }
    return $result;
}
Ejemplo n.º 30
0
            if (empty($nl_user->wp_user_id)) {
                $module->logger->info('Linked');
                $module->set_user_wp_user_id($nl_user->id, $wp_user->id);
                continue;
            }
        }
        $module->logger->info('New subscriber created');
        // Create a new subscriber
        $nl_user = array();
        $nl_user['email'] = $module->normalize_email($wp_user->user_email);
        $nl_user['name'] = $wp_user->user_login;
        $nl_user['status'] = $controls->data['align_wp_users_status'];
        $nl_user['wp_user_id'] = $wp_user->id;
        $nl_user['referrer'] = 'wordpress';
        // Adds the force subscription preferences
        $preferences = NewsletterSubscription::instance()->options['preferences'];
        if (is_array($preferences)) {
            foreach ($preferences as $p) {
                $nl_user['list_' . $p] = 1;
            }
        }
        $module->save_user($nl_user);
        $count++;
    }
    $controls->messages = count($wp_users) . ' ' . __('WordPress users processed', 'newsletter-users') . '. ';
    $controls->messages .= $count . ' ' . __('subscriptions added', 'newsletter-users') . '.';
}
if ($controls->is_action('bounces')) {
    $lines = explode("\n", $controls->data['bounced_emails']);
    $total = 0;
    $marked = 0;