Ejemplo n.º 1
0
 static function resetpassword($activation)
 {
     if ('none' == shopp_setting('account_system')) {
         return;
     }
     $user_data = false;
     $activation = preg_replace('/[^a-z0-9]/i', '', $activation);
     $errors = array();
     if (empty($activation) || !is_string($activation)) {
         $errors[] = new ShoppError(Shopp::__('Invalid key'));
     }
     $RecoveryCustomer = new ShoppCustomer($activation, 'activation');
     if (empty($RecoveryCustomer->id)) {
         $errors[] = new ShoppError(Shopp::__('Invalid key'));
     }
     if (!empty($errors)) {
         return false;
     }
     // Generate a new random password
     $password = wp_generate_password();
     do_action_ref_array('password_reset', array($RecoveryCustomer, $password));
     $RecoveryCustomer->password = wp_hash_password($password);
     if ('wordpress' == shopp_setting('account_system')) {
         $user_data = get_userdata($RecoveryCustomer->wpuser);
         wp_set_password($password, $user_data->ID);
     }
     $RecoveryCustomer->activation = '';
     $RecoveryCustomer->save();
     $subject = apply_filters('shopp_reset_password_subject', Shopp::__('[%s] New Password', get_option('blogname')));
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     $_[] = 'To: ' . $RecoveryCustomer->email;
     $_[] = 'Subject: ' . $subject;
     $_[] = 'Content-type: text/html';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Your new password for %s:', get_bloginfo('url')) . '</p>';
     $_[] = '';
     $_[] = '<ul>';
     if ($user_data) {
         $_[] = '<li>' . Shopp::__('Login name: %s', $user_data->user_login) . '</li>';
     }
     $_[] = '<li>' . Shopp::__('Password: %s', $password) . '</li>';
     $_[] = '</ul>';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Click here to login: %s', Shopp::url(false, 'account')) . '</p>';
     $message = apply_filters('shopp_reset_password_message', $_);
     if (!Shopp::email(join("\n", $message))) {
         shopp_add_error(Shopp::__('The e-mail could not be sent.'));
         Shopp::redirect(add_query_arg('acct', 'recover', Shopp::url(false, 'account')));
     } else {
         shopp_add_error(Shopp::__('Check your email address for your new password.'));
     }
     unset($_GET['acct']);
 }
Ejemplo n.º 2
0
 public function email($addressee, $address, $subject, array $templates = array())
 {
     global $is_IIS;
     shopp_debug("ShoppPurchase::email(): {$addressee},{$address},{$subject}," . _object_r($templates));
     // Build the e-mail message data
     $email['from'] = Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     if ($is_IIS) {
         $email['to'] = Shopp::email_to($address);
     } else {
         $email['to'] = Shopp::email_to($address, $addressee);
     }
     $email['subject'] = $subject;
     $email['receipt'] = $this->receipt();
     $email['url'] = get_bloginfo('url');
     $email['sitename'] = get_bloginfo('name');
     $email['orderid'] = $this->id;
     $email = apply_filters('shopp_email_receipt_data', $email);
     $email = apply_filters('shopp_purchase_email_message', $email);
     $this->message = array_merge($this->message, $email);
     // Load and process the template file
     $defaults = array('email.php', 'order.php', 'order.html');
     $emails = array_merge((array) $templates, $defaults);
     $template = Shopp::locate_template($emails);
     if (!file_exists($template)) {
         shopp_add_error(Shopp::__('A purchase notification could not be sent because the template for it does not exist.'), SHOPP_ADMIN_ERR);
         return false;
     }
     // Send the email
     if (Shopp::email($template, $this->message)) {
         shopp_debug('A purchase notification was sent to: ' . $this->message['to']);
         return true;
     }
     shopp_debug('A purchase notification FAILED to be sent to: ' . $this->message['to']);
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Send new customer notification emails
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @return void
  **/
 public function notification()
 {
     // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     // we want to reverse this for the plain text arena of emails.
     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     $business = shopp_setting('business_name');
     $merchant = shopp_setting('merchant_email');
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from($merchant, $business);
     $_[] = 'To: ' . Shopp::email_to($merchant);
     $_[] = 'Subject: ' . Shopp::__('[%s] New Customer Registration', $blogname);
     $_[] = '';
     $_[] = Shopp::__('New customer registration on your &quot;%s&quot; store:', $blogname);
     $_[] = Shopp::__('E-mail: %s', stripslashes($this->email));
     $_ = apply_filters('shopp_merchant_new_customer_notification', $_);
     if (!Shopp::email(join("\n", $_))) {
         shopp_add_error('The new account notification e-mail could not be sent.', SHOPP_ADMIN_ERR);
     } else {
         shopp_debug('A new account notification e-mail was sent to the merchant.');
     }
     if (empty($this->password)) {
         return;
     }
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from($merchant, $business);
     $_[] = 'To: ' . $this->email;
     $_[] = 'Subject: ' . Shopp::__('[%s] New Customer Registration', $blogname);
     $_[] = '';
     $_[] = Shopp::__('New customer registration on your &quot;%s&quot; store:', $blogname);
     $_[] = Shopp::__('E-mail: %s', stripslashes($this->email));
     $_[] = Shopp::__('Password: %s', $this->password);
     $_[] = '';
     $_[] = Shopp::url(false, 'account', ShoppOrder()->security());
     $_ = apply_filters('shopp_new_customer_notification', $_);
     if (!Shopp::email(join("\n", $_))) {
         shopp_add_error('The customer&apos;s account notification e-mail could not be sent.', SHOPP_ADMIN_ERR);
     } else {
         shopp_debug('A new account notification e-mail was sent to the customer.');
     }
 }
Ejemplo n.º 4
0
/**
 * @deprecated Use Shopp::email()
 **/
function shopp_email($template, $data = array())
{
    return Shopp::email($template, $data);
}
Ejemplo n.º 5
0
 /**
  * Resets a customer/user password with a valid activation key
  *
  * @since 1.0
  *
  * @param string $activation The activation key
  * @return void
  **/
 static function resetpassword($activation)
 {
     if ('none' == shopp_setting('account_system') || ShoppCustomer()->loggedin()) {
         return;
     }
     $user_data = false;
     $activation = preg_replace('/[^a-z0-9]/i', '', $activation);
     $errors = array();
     if (empty($activation) || !is_string($activation)) {
         $errors[] = shopp_add_error(Shopp::__("Invalid password reset key. Try copy/pasting the url in password reset email into your web browser's address bar."));
     } else {
         $RecoveryCustomer = new ShoppCustomer($activation, 'activation');
         if (empty($RecoveryCustomer->id)) {
             $errors[] = shopp_add_error(Shopp::__("Invalid password reset key. Try copy/pasting the url in password reset email into your web browser's address bar."));
         }
     }
     if (!empty($errors)) {
         return false;
     }
     // Generate a new random password
     $password = wp_generate_password(12, false);
     do_action_ref_array('password_reset', array($RecoveryCustomer, $password));
     $RecoveryCustomer->password = wp_hash_password($password);
     if ('wordpress' == shopp_setting('account_system')) {
         $user_data = get_userdata($RecoveryCustomer->wpuser);
         wp_set_password($password, $user_data->ID);
     }
     $RecoveryCustomer->activation = '';
     $RecoveryCustomer->save();
     $subject = apply_filters('shopp_reset_password_subject', Shopp::__('[%s] New Password', get_option('blogname')));
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     $_[] = 'To: ' . $RecoveryCustomer->email;
     $_[] = 'Subject: ' . $subject;
     $_[] = 'Content-type: text/html';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Your new password for %s:', get_bloginfo('url')) . '</p>';
     $_[] = '';
     $_[] = '<ul>';
     if (apply_filters('shopp_reset_password_wpuser', true) && !empty($user_data->user_login)) {
         $_[] = '<li>' . Shopp::__('Login: %s', $user_data->user_login) . '</li>';
     } elseif (!empty($RecoveryCustomer->email)) {
         $_[] = '<li>' . Shopp::__('Login: %s', $RecoveryCustomer->email) . '</li>';
     }
     $_[] = '<li>' . Shopp::__('Password: %s', $password) . '</li>';
     $_[] = '</ul>';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Click here to login: %s', Shopp::url(false, 'account')) . '</p>';
     $message = apply_filters('shopp_reset_password_message', $_);
     if (!Shopp::email(join("\n", $message))) {
         shopp_add_notice(Shopp::__('Your password was reset to: ' . $password));
     } else {
         shopp_add_notice(Shopp::__('Your new password has been emailed to you for your records. Your password was reset to: ' . $password));
     }
     unset($_GET['acct']);
     // Auto-login
     $RecoveryCustomer->login();
     // Login the customer
     if (!empty($user_data)) {
         // Log the WordPress user in
         ShoppLogin::wpuser($user_data);
     }
     // Show notice after login in case of failures during login
     shopp_add_notice(Shopp::__('You are now logged into your account.'));
     if (apply_filters('shopp_reset_password_redirect', true)) {
         shopp_add_notice(Shopp::__('If you wish, please use the form below to change your password to one of your choosing.'));
         Shopp::redirect(add_query_arg('profile', '', Shopp::url(false, 'account')));
     }
 }
Ejemplo n.º 6
0
    if (isset($_GET['_shopp_upgrade_notice'])) {
        ?>
			<?php 
        check_admin_referer('shopp_upgrade_notice');
        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
        $homeurl = wp_specialchars_decode(get_option('home'), ENT_QUOTES);
        $admin = get_bloginfo('admin_email');
        $site = parse_url($homeurl);
        $_ = array();
        $_[] = 'From: "' . $blogname . '" <' . shopp_setting('merchant_email') . '>';
        $_[] = 'To: ' . $admin;
        $_[] = sprintf('Subject: Shopp Upgraded on %s', $site['host']);
        $_[] = '';
        $_[] = sprintf(__('The Shopp installation on %1$s has been upgraded to %2$s and requires a database upgrade. Please login to %1$s and perform the upgrade by deactivating and reactivating the Shopp plugin.', 'Shopp'), $homeurl, ShoppVersion::release());
        $message = apply_filters('shopp_upgrade_notice_message', join("\n", $_));
        if (Shopp::email($message)) {
            shopp_debug('A Shopp upgrade notification was sent.');
        }
        Shopp::_em('### Upgrade Notice Sent

An upgrade notice has been sent to the site administrator.');
        ?>
		<?php 
    } else {
        ?>

			<div class="error"><?php 
        Shopp::_em('### Contact Your Site Administrator

You will need to notify a site administrator to perform the upgrade.');
        ?>
Ejemplo n.º 7
0
 /**
  * Generates and sends an email of an error to the recipient list
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @param ShoppError $error The error object
  * @return void
  **/
 public function notify($error)
 {
     // Use bitwise & (NOT &&) to detect if the error level is in the subscribed types
     if (!($error->level & $this->types)) {
         return;
     }
     $url = parse_url(get_bloginfo('url'));
     $_ = array();
     $_[] = 'From: "' . get_bloginfo('sitename') . '" <shopp@' . $url['host'] . '>';
     $_[] = 'To: ' . $this->recipients;
     $_[] = 'Subject: ' . __('Shopp Notification', 'Shopp');
     $_[] = 'Content-type: text/html';
     $_[] = '';
     $_[] = __('This is an automated notification message generated by the Shopp installation at ' . get_bloginfo('url') . '.', 'Shopp');
     $_[] = '';
     $_[] = $error->message();
     $_[] = '';
     if (isset($error->debug['file']) && defined('WP_DEBUG')) {
         $_[] = 'DEBUG: ' . basename($error->debug['file']) . ', line ' . $error->debug['line'];
     }
     Shopp::email(join("\n", $_));
 }