Esempio n. 1
1
function deal_expire_process($postid)
{
    global $wpdb, $transection_db_table_name, $deal_db_table_name;
    $deal_db_table_name = $wpdb->prefix . "posts";
    $recent_posts = get_post($postid);
    $store_name = get_option('blogname');
    $sellsql = "select count(*) from {$transection_db_table_name} where post_id=" . $postid . " and status=1";
    $sellsqlinfo = $wpdb->get_var($sellsql);
    if (get_post_meta($postid, 'coupon_end_date_time', true) != "") {
        if (date("Y-m-d H:i:s") >= date("Y-m-d H:i:s", get_post_meta($postid, 'coupon_end_date_time', true))) {
            if (get_post_meta($postid, 'is_expired', true) == '0') {
                $recent_posts = update_post_meta($postid, 'is_expired', 1);
                $fromEmail = get_site_emailId();
                $fromEmailName = get_site_emailName();
                $deal_link = get_permalink($postid);
                $loginurl = get_option('siteurl') . '/?ptype=login';
                $siteurl = get_option('siteurl');
                $post_detail = get_post($postid);
                $to_seller_email = get_post_meta($postid, 'owner_email', true);
                $to_seller_name = get_post_meta($postid, 'owner_name', true);
                $user_log_details = get_userdata($post_detail->post_author);
                if (get_post_meta($postid, 'coupon_end_date_time', true) != '') {
                    $post_date = date('Y-m-d H:i:s', get_post_meta($postid, 'coupon_end_date_time', true));
                }
                if (get_option('ptthemes_deal_expire_notify_seller') == 'Yes' || get_option('ptthemes_deal_expire_notify_seller') == '') {
                    global $wpdb;
                    $expire_email_subject = get_option('deal_exp_success_email_subject');
                    $expire_email_content = get_option('deal_exp_success_email_content');
                    $search_expire_array = array('[#to_name#]', '[#deal_link#]', '[#deal_title#]', '[#login_url#]', '[#user_login#]', '[#user_email#]', '[#site_url#]', '[#from_name#]', '[#post_date#]');
                    $replace_expire_array = array($to_seller_name, $deal_link, $post_detail->post_title, $loginurl, $user_log_details->user_login, $user_log_details->user_email, $siteurl, $fromEmailName, $post_date);
                    $expire_email_content = str_replace($search_expire_array, $replace_expire_array, $expire_email_content);
                    templ_sendEmail($to_seller_email, $to_seller_name, $fromEmail, $fromEmailName, $expire_email_subject, $expire_email_content, $extra = '');
                }
                if (get_option('ptthemes_deal_expire_notify_admin') == 'Yes' || get_option('ptthemes_deal_expire_notify_admin') == '') {
                    global $wpdb;
                    $expire_email_subject = get_option('deal_expadmin_success_email_subject');
                    $expire_email_content = get_option('deal_expadmin_success_email_content');
                    $search_expire_array = array('[#to_name#]', '[#deal_link#]', '[#deal_title#]', '[#site_url#]', '[#from_name#]', '[#post_date#]');
                    $replace_expire_array = array($fromEmailName, $deal_link, $post_detail->post_title, $siteurl, $fromEmailName, $post_date);
                    $expire_email_content = str_replace($search_expire_array, $replace_expire_array, $expire_email_content);
                    $search_expire_sub_array = array('[#site_name#]');
                    $replace_expire_sub_array = array($store_name);
                    $expire_email_subject = str_replace($search_expire_sub_array, $replace_expire_sub_array, $expire_email_subject);
                    if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
                        templ_sendEmail($fromEmail, $fromEmailName, $to_seller_email, $to_seller_name, $expire_email_subject, $expire_email_content, $extra = '');
                    }
                }
            }
        }
    }
}
Esempio n. 2
0
<?php

global $wpdb, $transection_db_table_name;
foreach ($_POST as $field => $value) {
    $ipnData["{$field}"] = $value;
}
$transid = intval($ipnData['x_invoice_num']);
$pnref = $ipnData['x_trans_id'];
$amount = doubleval($ipnData['x_amount']);
$result = intval($ipnData['x_response_code']);
$respmsg = $ipnData['x_response_reason_text'];
$customer_email = $ipnData['x_email'];
$customer_name = $ipnData['x_first_name'];
$item_name = $ipnData['c_name'];
$fromEmail = get_site_emailId();
$fromEmailName = get_site_emailName();
if ($result == '1') {
    // Valid IPN transaction.
    $transifo = get_deal_trans_info($transid);
    $postid = $transifo['post_id'];
    if ($transifo['deal_type'] == '3' || $transifo['deal_type'] == '4' || $transifo['deal_type'] == '5') {
        $coupon_code_arr = explode(",", get_post_meta($postid, 'coupon_code', true));
        $coup = array_shift($coupon_code_arr);
        update_post_meta($postid, "coupon_code", implode(",", $coupon_code_arr));
        if (get_post_meta($postid, 'used_coupon_code', true) == "") {
            update_post_meta($postid, "used_coupon_code", $coup);
        } else {
            $old_used_coupon = get_post_meta($postid, 'used_coupon_code', true);
            $coupon = $old_used_coupon . "," . $coup;
            update_post_meta($postid, "used_coupon_code", $coupon);
        }
/**
 * Handles registering a new user.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @param string $user_login User's username for logging in.
 * @param string $user_email User's email address to send password and add.
 * @global object $wpdb WordPress Database object.
 * @return int|WP_Error Either user's ID or error on failure.
 */
function geodir_register_new_user($user_login, $user_email)
{
    global $wpdb;
    $errors = new WP_Error();
    $user_login = sanitize_user($user_login);
    $user_login = str_replace(",", "", $user_login);
    $user_email = str_replace(",", "", $user_email);
    /**
     * Filter the user registration email.
     *
     * @since 1.0.0
     *
     * @param string $user_email User registration email.
     */
    $user_email = apply_filters('user_registration_email', $user_email);
    if (get_option('geodir_allow_cpass')) {
        $user_pass = $_REQUEST['user_pass'];
        $user_pass2 = $_REQUEST['user_pass2'];
        // Check the password
        if ($user_pass != $user_pass2) {
            $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
        } elseif (strlen($user_pass) < 7) {
            $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
        }
    }
    // Check the username
    if ($user_login == '') {
        $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
    } elseif (!validate_username($user_login)) {
        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
        $user_login = '';
    } elseif (username_exists($user_login)) {
        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
    }
    // Check the e-mail address
    if ($user_email == '') {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
    } elseif (!is_email($user_email)) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'geodirectory'));
        $user_email = '';
    } elseif (email_exists($user_email)) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
    }
    /**
     * Called when registering a new user.
     *
     * This is a WordPress core hook.
     *
     * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post
     * @since 1.0.0
     */
    do_action('register_post', $user_login, $user_email, $errors);
    /**
     * Filter the registration error messages.
     *
     * @since 1.0.0
     *
     * @param object $errors Registration error messages.
     */
    $errors = apply_filters('registration_errors', $errors);
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!isset($user_pass) || $user_pass == '') {
        $user_pass = wp_generate_password(12, false);
    }
    $user_id = wp_create_user($user_login, $user_pass, $user_email);
    $user_web = '';
    /*$user_add1 = $_POST['user_add1'];
      $user_add2 = $_POST['user_add2'];
      $user_city = $_POST['user_city'];
      $user_state = $_POST['user_state'];
      $user_country = $_POST['user_country'];
      $user_postalcode = $_POST['user_postalcode'];
      $user_web = $_POST['user_web'];
      $user_phone = $_POST['user_phone'];
      $user_twitter = $_POST['user_twitter'];	*/
    $user_fname = sanitize_user($_POST['user_fname']);
    $user_fname = str_replace(",", "", $user_fname);
    /**
     * Filter the submitted user meta.
     *
     * @since 1.0.0
     *
     * @param int $user_id User ID.
     */
    $user_address_info = apply_filters('geodir_manage_user_meta', array("user_add1" => '', "user_add2" => '', "user_city" => '', "user_state" => '', "user_country" => '', "user_postalcode" => '', "user_phone" => '', "user_twitter" => '', "first_name" => $user_fname, "last_name" => ''), $user_id);
    foreach ($user_address_info as $key => $val) {
        update_user_meta($user_id, $key, $val);
        // User Address Information Here
    }
    //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here
    $userName = $user_fname;
    update_user_meta($user_id, 'first_name', $userName);
    // User Address Information Here
    //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here
    // Changed by vikas sharma to enable all type of characters in author permalink...
    $user_nicename = sanitize_title($userName);
    $updateUsersql = $wpdb->prepare("update {$wpdb->users} set user_url=%s, user_nicename=%s, display_name=%s  where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
    $wpdb->query($updateUsersql);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
        return $errors;
    }
    global $upload_folder_path;
    if ($user_id) {
        /**
         * Called after registering a user and before the registration email is sent.
         *
         * @since 1.0.0
         * @param int $user_id The user ID of the registered user.
         */
        do_action('geodir_user_register', $user_id);
        ///////REGISTRATION EMAIL START//////
        $fromEmail = geodir_get_site_email_id();
        $fromEmailName = get_site_emailName();
        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
<p>' . __('Username:'******'geodirectory') . ' ' . $user_login . '</p>
<p>' . __('Password:'******'geodirectory') . ' ' . $user_pass . '</p>');
        /////////////customer email//////////////
        //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email
        geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);
        /// registration email
        //////REGISTRATION EMAIL END////////
    }
    if (get_option('ptthemes_auto_login')) {
        $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
        return $errors;
    }
    return array($user_id, $user_pass);
}
function geodir_clientEmail($page_id, $user_id, $message_type, $custom_1 = '')
{
    if ($message_type == 'claim_approved') {
        $subject = get_option('geodir_claim_approved_email_subject');
        $client_message = get_option('geodir_claim_approved_email_content');
    } elseif ($message_type == 'claim_rejected') {
        $subject = get_option('geodir_claim_rejected_email_subject');
        $client_message = get_option('geodir_claim_rejected_email_content');
    } elseif ($message_type == 'claim_requested') {
        $subject = get_option('geodir_claim_email_subject');
        $client_message = get_option('geodir_claim_email_content');
    } elseif ($message_type == 'auto_claim') {
        $subject = get_option('geodir_claim_auto_approve_email_subject');
        $client_message = get_option('geodir_claim_auto_approve_email_content');
    }
    $transaction_details = $custom_1;
    $approve_listing_link = '<a href="' . home_url() . '/?geodir_ptype=verify&rs=' . $custom_1 . '">' . CLAIM_VERIFY_TEXT . '</a>';
    $fromEmail = get_option('site_email');
    $fromEmailName = get_site_emailName();
    if (function_exists('get_property_price_info_listing')) {
        $pkg_limit = get_property_price_info_listing($page_id);
        $alivedays = $pkg_limit['days'];
    } else {
        $alivedays = 'unlimited';
    }
    $productlink = get_permalink($page_id);
    $post_info = get_post($page_id);
    $post_date = date('dS F,Y', strtotime($post_info->post_date));
    $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
    $site_login_url = get_option('siteurl') . '?geodir_signup=true';
    $loginurl_link = '<a href="' . $site_login_url . '">login</a>';
    $siteurl = home_url();
    $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
    $user_info = get_userdata($user_id);
    $user_email = $user_info->user_email;
    $display_name = $user_info->first_name;
    if (!$display_name) {
        $display_name = get_the_author_meta('display_name', $user_id);
    }
    $user_login = $user_info->user_login;
    $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
    if ($number_of_grace_days == '') {
        $number_of_grace_days = 1;
    }
    if ($post_info->post_type == 'event') {
        $post_type = 'event';
    } else {
        $post_type = 'listing';
    }
    $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . CLAIM_RENEW_LINK . '</a>';
    $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#approve_listing_link#]', '[#transaction_details#]');
    $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $approve_listing_link, $transaction_details);
    $client_message = str_replace($search_array, $replace_array, $client_message);
    $subject = str_replace($search_array, $replace_array, $subject);
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
    $headers .= 'To: ' . $display_name . ' <' . $user_email . '>' . "\r\n";
    $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
    // strip slashes from subject & message text
    $subject = stripslashes_deep($subject);
    $client_message = stripslashes_deep($client_message);
    @wp_mail($user_email, $subject, $client_message, $headers);
    /*To client email*/
}
Esempio n. 5
0
function widget_retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'templatic'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'templatic'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'templatic'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    ////////////////////////////////////
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login like \"{$user_login}\" or user_email like \"{$user_login}\"");
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key', 'templatic'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = '<p><b>' . __('Your login Information :', 'templatic') . '</b></p>';
    $message .= '<p>' . sprintf(__('Username: %s', 'templatic'), $user->user_login) . "</p>";
    $message .= '<p>' . sprintf(__('Password: %s', 'templatic'), $new_pass) . "</p>";
    $message .= '<p>You can login to : <a href="' . get_option('siteurl') . '/' . "\">Login</a> or the URL is :  " . get_option('siteurl') . "/?ptype=login</p>";
    $message .= '<p>Thank You,<br> ' . get_option('blogname') . '</p>';
    $user_email = $user_data->user_email;
    $user_name = $user_data->user_nicename;
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $title = sprintf(__('[%s] Your new password', 'templatic'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '');
    ///forgot password email
    return true;
}
Esempio n. 6
0
/**
 * Handles registering a new user.
 *
 * @param string $user_login User's username for logging in
 * @param string $user_email User's email address to send password and add
 * @return int|WP_Error Either user's ID or error on failure.
 */
function register_new_user($user_login, $user_email)
{
    global $wpdb;
    $errors = new WP_Error();
    $user_login = sanitize_user($user_login);
    $user_email = apply_filters('user_registration_email', $user_email);
    // Check the username
    if ($user_login == '') {
        $errors->add('empty_username', __('ERROR: Please enter a username.', 'templatic'));
    } elseif (!validate_username($user_login)) {
        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'templatic'));
        $user_login = '';
    } elseif (username_exists($user_login)) {
        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'templatic'));
    }
    // Check the e-mail address
    if ($user_email == '') {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'templatic'));
    } elseif (!is_email($user_email)) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'templatic'));
        $user_email = '';
    } elseif (email_exists($user_email)) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'templatic'));
    }
    do_action('register_post', $user_login, $user_email, $errors);
    $errors = apply_filters('registration_errors', $errors);
    if ($errors->get_error_code()) {
        return $errors;
    }
    $user_pass = wp_generate_password(12, false);
    $user_id = wp_create_user($user_login, $user_pass, $user_email);
    global $upload_folder_path;
    global $form_fields_usermeta;
    foreach ($form_fields_usermeta as $fkey => $fval) {
        $fldkey = "{$fkey}";
        ${$fldkey} = $_POST["{$fkey}"];
        if ($fval['type'] == 'upload') {
            if ($_FILES[$fkey]['name'] && $_FILES[$fkey]['size'] > 0) {
                $dirinfo = wp_upload_dir();
                $path = $dirinfo['path'];
                $url = $dirinfo['url'];
                $destination_path = $path . "/";
                $destination_url = $url . "/";
                $src = $_FILES[$fkey]['tmp_name'];
                $file_ame = date('Ymdhis') . "_" . $_FILES[$fkey]['name'];
                $target_file = $destination_path . $file_ame;
                if (move_uploaded_file($_FILES[$fkey]["tmp_name"], $target_file)) {
                    $image_path = $destination_url . $file_ame;
                } else {
                    $image_path = '';
                }
                $_POST[$fkey] = $image_path;
                ${$fldkey} = $image_path;
            }
        }
        update_usermeta($user_id, $fkey, ${$fldkey});
        // User Custom Metadata Here
    }
    $userName = $_POST['user_fname'];
    update_usermeta($user_id, 'first_name', $_POST['user_fname']);
    // User First Name Information Here
    update_usermeta($user_id, 'last_name', $_POST['user_lname']);
    // User Last Name Information Here
    $user_nicename = get_user_nice_name($_POST['user_fname'], $_POST['user_lname']);
    //generate nice name
    $updateUsersql = "update {$wpdb->users} set user_url=\"{$user_web}\", user_nicename=\"{$user_nicename}\", display_name=\"{$userName}\"  where ID=\"{$user_id}\"";
    $wpdb->query($updateUsersql);
    if ($user_id) {
        ///////REGISTRATION EMAIL START//////
        $fromEmail = get_site_emailId();
        $fromEmailName = get_site_emailName();
        $store_name = get_option('blogname');
        $client_message = get_option('registration_success_email_content');
        if ($client_message == "") {
            $client_message = "<p>Dear [#user_name#],</p>\n<p>Your registration completed successfully. You can now login here [#site_login_url#] using the following credentials:</p><p>Username: [#user_login#]</p><p>Password: [#user_password#]</p>\n<p>Or using the URL: [#site_login_url_link#] .</p><br /><p>Thanks!</p>\n<p>[#site_name#]</p>";
        }
        $subject = get_option('registration_success_email_subject');
        if ($subject == "") {
            $subject = "Registration completed successfully";
        }
        $store_login = '******' . site_url() . '/?ptype=login">' . site_url() . '/?ptype=login</a>';
        $store_login_link = site_url() . '/?ptype=login';
        /////////////customer email//////////////
        $search_array = array('[#user_name#]', '[#user_login#]', '[#user_password#]', '[#site_name#]', '[#site_login_url#]', '[#site_login_url_link#]');
        $replace_array = array($userName, $user_login, $user_pass, $store_name, $store_login, $store_login_link);
        $client_message = str_replace($search_array, $replace_array, $client_message);
        if (get_option('pttthemes_send_mail') == 'Enable') {
            templ_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, $subject, $client_message, $extra = '');
        }
        ///To clidne email
        $redirect_to = wp_redirect(site_url() . '/?reg=1&ptype=login');
        //////REGISTRATION EMAIL END////////
    }
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'templatic'), get_option('admin_email')));
        return $errors;
    } else {
        $redirect_to = wp_redirect(site_url() . '/?reg=1&ptype=login');
    }
    return array($user_id, $user_pass);
}
Esempio n. 7
0
 /**
  * @todo could be a duplicate of geodir_sendEmail.
  *
  * @since 1.0.0
  * @package GeoDirectory
  * @param string $fromEmail Sender email address.
  * @param string $fromEmailName Sender name.
  * @param string $toEmail Receiver email address.
  * @param string $toEmailName Receiver name.
  * @param string $to_subject Email subject.
  * @param string $to_message Email content.
  * @param string $extra Not being used.
  * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
  * @param string $post_id The post ID.
  * @param string $user_id The user ID.
  */
 function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
 {
     $login_details = '';
     if ($message_type == 'send_friend') {
         $subject = stripslashes(get_option('email_friend_subject'));
         $message = stripslashes(get_option('email_friend_content'));
     } elseif ($message_type == 'send_enquiry') {
         $subject = get_option('email_enquiry_subject');
         $message = get_option('email_enquiry_content');
     } elseif ($message_type == 'forgot_password') {
         $subject = get_option('forgot_password_subject');
         $message = get_option('forgot_password_content');
         $login_details = $to_message;
     } elseif ($message_type == 'registration') {
         $subject = get_option('registration_success_email_subject');
         $message = get_option('registration_success_email_content');
         $login_details = $to_message;
     }
     $to_message = nl2br($to_message);
     $sitefromEmail = get_option('site_email');
     $sitefromEmailName = get_site_emailName();
     $productlink = get_permalink($post_id);
     $post_info = get_post($post_id);
     $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
     $siteurl = home_url();
     $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
     $loginurl = home_url() . '/?ptype=login';
     $loginurl_link = '<a href="' . $loginurl . '">login</a>';
     if ($fromEmail == '') {
         $fromEmail = get_option('site_email');
     }
     if ($fromEmailName == '') {
         $fromEmailName = get_option('site_email_name');
     }
     $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
     $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
     $message = str_replace($search_array, $replace_array, $message);
     $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
     $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
     $subject = str_replace($search_array, $replace_array, $subject);
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
     $headers .= "Reply-To: " . $fromEmail . "\r\n";
     //$headers .= 'To: '.$toEmailName.' <'.$toEmail.'>' . "\r\n";
     $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
     @wp_mail($toEmail, $subject, $message, $headers);
     ///////// ADMIN BCC EMIALS
     if ($message_type == 'registration') {
         $message_raw = explode(__("Password:"******"</p>", $message_raw[1], 2);
         $message = $message_raw[0] . __('Password:'******'geodirectory') . ' **********</p>' . $message_raw2[1];
     }
     $adminEmail = get_bloginfo('admin_email');
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
     $headers .= "Reply-To: " . $fromEmail . "\r\n";
     //$headers .= 'To: <'.$adminEmail.'>' . "\r\n";
     $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
     if ($message_type == 'registration' && get_option('bcc_new_user')) {
         $subject .= ' - ADMIN BCC COPY';
         @wp_mail($adminEmail, $subject, $message, $headers);
     }
     if ($message_type == 'send_friend' && get_option('bcc_friend')) {
         $subject .= ' - ADMIN BCC COPY';
         @wp_mail($adminEmail, $subject, $message, $headers);
     }
     if ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
         $subject .= ' - ADMIN BCC COPY';
         @wp_mail($adminEmail, $subject, $message, $headers);
     }
 }
/**
 * Send an email to the receiver when a compliment get posted.
 *
 * @since 0.0.2
 * @package BuddyPress_Compliments
 *
 * @param array $args Sender and Receiver user ID.
 * @return bool
 */
function bp_compliments_new_compliment_email_notification($args = array())
{
    //    $args = '';
    $defaults = array('receiver_id' => bp_displayed_user_id(), 'sender_id' => bp_loggedin_user_id());
    $r = wp_parse_args($args, $defaults);
    if ('no' == bp_get_user_meta((int) $r['receiver_id'], 'notification_on_compliments', true)) {
        return false;
    }
    $sender_name = bp_core_get_user_displayname($r['sender_id']);
    $compliment_link = bp_core_get_user_domain($r['receiver_id']) . BP_COMPLIMENTS_SLUG . '/?bpc_read=true&bpc_sender_id=' . $r['sender_id'];
    $receiver_ud = bp_core_get_core_userdata($r['receiver_id']);
    // Set up and send the message
    $to = $receiver_ud->user_email;
    $subject = '[' . wp_specialchars_decode(bp_get_option('blogname'), ENT_QUOTES) . '] ' . sprintf(__('%s has sent you a %s', 'bp-compliments'), $sender_name, BP_COMP_SINGULAR_NAME);
    $message = sprintf(__('%s has sent you a %s.

To view %s\'s %s: %s', 'bp-compliments'), $sender_name, BP_COMP_SINGULAR_NAME, $sender_name, BP_COMP_SINGULAR_NAME, $compliment_link);
    // Add notifications link if settings component is enabled
    if (bp_is_active('settings')) {
        $settings_link = bp_core_get_user_domain($r['receiver_id']) . BP_SETTINGS_SLUG . '/notifications/';
        $message .= sprintf(__('

---------------------
To disable these notifications please log in and go to:
%s', 'bp-compliments'), $settings_link);
    }
    // check for GeoDirectory plugin settings first
    if (function_exists('geodir_sendEmail')) {
        $sitefromEmail = get_option('site_email');
        $sitefromEmailName = get_site_emailName();
    } else {
        $sitefromEmail = get_option('admin_email');
        $sitefromEmailName = stripslashes(get_option('blogname'));
    }
    /**
     * Filters the notification from email.
     *
     * @since 1.0.6
     * @package BuddyPress_Compliments
     *
     * @param string $sitefromEmail Notification from email.
     */
    $sitefromEmail = apply_filters('bp_compliments_notification_from_email', $sitefromEmail);
    /**
     * Filters the notification from name.
     *
     * @since 1.0.6
     * @package BuddyPress_Compliments
     *
     * @param string $sitefromEmail Notification from name.
     */
    $sitefromEmailName = apply_filters('bp_compliments_notification_from_name', $sitefromEmailName);
    $headers = array();
    $headers[] = 'Content-type: text/html; charset=UTF-8';
    $headers[] = 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>';
    // Send the message
    /**
     * Filters the notification receiver email.
     *
     * @since 0.0.1
     * @package BuddyPress_Compliments
     *
     * @param string $to Notification receiver email.
     */
    $to = apply_filters('bp_compliments_notification_to', $to);
    /**
     * Filters the notification subject.
     *
     * @since 0.0.1
     * @package BuddyPress_Compliments
     *
     * @param string $to Notification subject.
     * @param string $sender_name Sender Name.
     */
    $subject = apply_filters('bp_compliments_notification_subject', $subject, $sender_name);
    /**
     * Filters the notification message.
     *
     * @since 0.0.1
     * @package BuddyPress_Compliments
     *
     * @param string $message Notification message.
     * @param string $sender_name Compliment Sender Name.
     * @param string $compliment_link Compliment Link.
     */
    $message = apply_filters('bp_compliments_notification_message', $message, $sender_name, $compliment_link);
    wp_mail($to, $subject, $message, $headers);
}
Esempio n. 9
0
/**
 * Called when post updated.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @param int $post_ID The post ID.
 * @param object $post_after The post object after update.
 * @param object $post_before The post object before update.
 */
function geodir_function_post_updated($post_ID, $post_after, $post_before)
{
    $post_type = get_post_type($post_ID);
    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
        // send notification to client when post moves from draft to publish
        if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
            $post_author_data = get_userdata($post_author_id);
            $to_name = geodir_get_client_name($post_author_id);
            $from_email = geodir_get_site_email_id();
            $from_name = get_site_emailName();
            $to_email = $post_author_data->user_email;
            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
                $to_email = $post_author_data->user_email;
            }
            $message_type = 'listing_published';
            if (get_option('geodir_post_published_email_subject') == '') {
                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', GEODIRECTORY_TEXTDOMAIN));
            }
            if (get_option('geodir_post_published_email_content') == '') {
                update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", GEODIRECTORY_TEXTDOMAIN));
            }
            /**
             * Called before sending the email when listing gets published.
             *
             * @since 1.0.0
             * @package GeoDirectory
             * @param object $post_after The post object after update.
             * @param object $post_before The post object before update.
             */
            do_action('geodir_before_listing_published_email', $post_after, $post_before);
            if (is_email($to_email)) {
                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
            }
            /**
             * Called after sending the email when listing gets published.
             *
             * @since 1.0.0
             * @package GeoDirectory
             * @param object $post_after The post object after update.
             * @param object $post_before The post object before update.
             */
            do_action('geodir_after_listing_published_email', $post_after, $post_before);
        }
    }
}
function geodir_payment_clientEmail($post_id, $user_id, $message_type, $extra = '')
{
    $login_details = '';
    $to_message = '';
    $to_subject = '';
    if ($message_type == 'payment_success') {
        $subject = stripslashes(get_option('geodir_post_payment_success_client_email_subject'));
        $message = stripslashes(get_option('geodir_post_payment_success_client_email_content'));
    }
    if ($message_type == 'expiration') {
        $subject = stripslashes(get_option('geodir_renew_email_subject'));
        $message = stripslashes(get_option('geodir_renew_email_content'));
    }
    $number_of_grace_days = get_option('geodir_listing_preexpiry_notice_days');
    if ($number_of_grace_days == '') {
        $number_of_grace_days = 1;
    }
    $alivedays = geodir_get_post_meta($post_id, 'alive_days', true);
    $user_info = get_userdata($user_id);
    $toEmail = $user_info->user_email;
    $toEmailName = $user_info->display_name;
    $user_login = $user_info->user_login;
    $user_email = $user_info->user_email;
    $to_message = nl2br($to_message);
    $sitefromEmail = get_option('site_email');
    $sitefromEmailName = get_site_emailName();
    $productlink = get_permalink($post_id);
    $post_info = get_post($post_id);
    $posted_date = $post_info->post_date;
    $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
    $siteurl = home_url();
    $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
    $loginurl = home_url() . '/?geodir_signup=true';
    $loginurl_link = '<a href="' . $loginurl . '">login</a>';
    $fromEmail = get_option('site_email');
    $fromEmailName = get_option('site_email_name');
    $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#transaction_details#]', '[#number_of_grace_days#]', '[#number_of_days#]', '[#username#]', '[#user_email#]');
    $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $extra, $number_of_grace_days, $alivedays, $user_login, $user_email);
    $message = str_replace($search_array, $replace_array, $message);
    $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]');
    $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date);
    $subject = str_replace($search_array, $replace_array, $subject);
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
    $headers .= "Reply-To: " . $fromEmail . "\r\n";
    //$headers .= 'To: '.$toEmailName.' <'.$toEmail.'>' . "\r\n";
    $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
    @wp_mail($toEmail, $subject, $message, $headers);
    // send bcc to admin for expired listing
    if ($message_type == 'expiration' && get_option('geodir_bcc_expire')) {
        $adminEmail = get_bloginfo('admin_email');
        $subject .= ' - ADMIN BCC COPY';
        @wp_mail($adminEmail, $subject, $message, $headers);
    }
}
Esempio n. 11
0
function geodir_ipn_handler_2co()
{
    global $Cart, $General;
    $req = '';
    foreach ($_POST as $field => $value) {
        $ipnData["{$field}"] = $value;
        $req .= "&{$field}={$value}";
    }
    $postid = intval($ipnData['x_invoice_num']);
    $pnref = $ipnData['x_trans_id'];
    $amount = geodir_get_currency_sym() . doubleval($ipnData['x_amount']);
    $result = intval($ipnData['x_response_code']);
    $respmsg = $ipnData['x_response_reason_text'];
    $customer_email = $ipnData['x_email'];
    $customer_name = $ipnData['x_first_name'];
    $fromEmail = get_option('site_email');
    $fromEmailName = get_site_emailName();
    $subject = "Acknowledge for Place Listing ID #{$postid} payment";
    // get current post status
    $current_post_status = get_post_status($postid);
    if ($result == '1') {
        /* Valid IPN transaction.*/
        $post_default_status = geodir_new_post_default_status();
        if ($post_default_status == '') {
            $post_default_status = 'publish';
        }
        set_property_status($postid, $post_default_status);
        $productinfosql = $wpdb->prepare("select ID,post_title,guid,post_author from {$wpdb->posts} where ID = %d", array($postid));
        $productinfo = $wpdb->get_results($productinfosql);
        foreach ($productinfo as $productinfoObj) {
            $post_title = '<a href="' . $productinfoObj->guid . '">' . $productinfoObj->post_title . '</a>';
            $aid = $productinfoObj->post_author;
            $userInfo = get_author_info($aid);
            $to_name = $userInfo->user_nicename;
            $to_email = $userInfo->user_email;
        }
        $message = __('<p>payment for Place Listing ID #' . $postid . ' confirmation.<br></p><p><b>You may find the details below:</b></p><p>----</p><p>Place Listing Id : ' . $postid . '</p><p>Place Listing Title : ' . $post_title . '</p><p>User Name : ' . $to_name . '</p><p>User Email : ' . $to_email . '</p><p>Paid Amount :       ' . $amount . '</p><p>Transaction ID :       ' . $pnref . '</p><p>Result Code : ' . $result . '</p><p>Response Message : ' . $respmsg . '</p><p>----</p><br><br><p>Thank you.</p>', GEODIRPAYMENT_TEXTDOMAIN);
        $subject = get_option('post_payment_success_admin_email_subject');
        if (!$subject) {
            $subject = __("Place Listing Submitted and Payment Success Confirmation Email", GEODIRPAYMENT_TEXTDOMAIN);
        }
        $content = get_option('post_payment_success_admin_email_content');
        $store_name = get_option('blogname');
        $fromEmail = get_option('site_email');
        $search_array = array('[#to_name#]', '[#information_details#]', '[#site_name#]');
        $replace_array = array($fromEmail, $message, $store_name);
        /*$message = str_replace($search_array,$replace_array,$content);*/
        geodir_payment_adminEmail($postid, $aid, 'payment_success', $message);
        /* email to admin*/
        geodir_payment_clientEmail($postid, $aid, 'payment_success', $message);
        /* email to client*/
        /*@wp_mail($fromEmail,$subject,$message,$headerarr);*/
        /* email to admin*/
        // Extend expire date start
        $invoice_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . INVOICE_TABLE . " WHERE post_id = %d AND is_current=%s", array($postid, '1')));
        $invoice_id = $invoice_info->id;
        $invoice_package_id = '';
        if (!empty($invoice_info) && isset($invoice_info->package_id)) {
            $invoice_package_id = $invoice_info->package_id;
            $invoice_alive_days = $invoice_info->alive_days;
            $invoice_status = $invoice_info->status;
        }
        $geodir_post_info = geodir_get_post_info($postid);
        if (!empty($geodir_post_info)) {
            $post_package_id = $geodir_post_info->package_id;
            $post_expire_date = $geodir_post_info->expire_date;
            if (!empty($invoice_package_id) && $invoice_alive_days > 0 && $invoice_package_id == $post_package_id && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) >= strtotime(date('Y-m-d')) && $current_post_status == 'publish') {
                $alive_days = (int) ($geodir_post_info->alive_days + $invoice_alive_days);
                $expire_date = date('Y-m-d', strtotime($post_expire_date . "+" . $invoice_alive_days . " days"));
            } else {
                $alive_days = (int) $geodir_post_info->alive_days;
                if (strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) < strtotime(date('Y-m-d'))) {
                    $alive_days = $invoice_alive_days;
                }
                $expire_date = $alive_days > 0 ? date('Y-m-d', strtotime(date('Y-m-d') . "+" . $alive_days . " days")) : 'Never';
            }
            geodir_save_post_meta($postid, 'alive_days', $alive_days);
            geodir_save_post_meta($postid, 'expire_date', $expire_date);
        }
        // Extend expire date start	end
        /*############ SET THE INVOICE STATUS START ############*/
        // update invoice statuse and transactio details
        $transaction_details = $message;
        geodir_update_invoice_status($invoice_id, 'Paid');
        geodir_update_invoice_transaction_details($invoice_id, $transaction_details);
        /*############ SET THE INVOICE STATUS END ############*/
        if ($ct_on && file_exists($child_dir . '/library/includes/success.php')) {
            include_once $child_dir . '/library/includes/success.php';
        } else {
            include_once TEMPLATEPATH . '/library/includes/success.php';
        }
        exit;
        return true;
    } else {
        if ($result != '1') {
            $message = __('<p>payment for Place Listing ID #' . $postid . ' incompleted.<br>because of ' . $respmsg . '</p><p><b>You may find the details below:</b></p><p>----</p><p>Place Listing Id : ' . $postid . '</p><p>Place Listing Title : ' . $post_title . '</p><p>User Name : ' . $to_name . '</p><p>User Email : ' . $to_email . '</p><p>Paid Amount :       ' . $amount . '</p><p>Transaction ID :       ' . $pnref . '</p><p>Result Code : ' . $result . '</p><p>Response Message : ' . $respmsg . '</p><p>----</p><br><br><p>Thank you.</p>', GEODIRPAYMENT_TEXTDOMAIN);
            $subject = get_option('post_payment_success_client_email_subject');
            if (!$subject) {
                $subject = __("Place Listing Submitted and Payment Success Confirmation Email", GEODIRPAYMENT_TEXTDOMAIN);
            }
            $content = get_option('post_payment_success_client_email_content');
            $store_name = get_option('blogname');
            $search_array = array('[#to_name#]', '[#information_details#]', '[#site_name#]');
            $replace_array = array($to_name, $message, $store_name);
            /*$message = str_replace($search_array,$replace_array,$content);*/
            geodir_payment_adminEmail($postid, $aid, 'payment_success', $message);
            /* email to admin*/
            geodir_payment_clientEmail($postid, $aid, 'payment_success', $message);
            /* email to client*/
            /*@wp_mail($to_email,$subject,$message,$headerarr);*/
            /* email to client*/
            /*############ SET THE INVOICE STATUS START ############*/
            global $wpdb;
            $invoice_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . INVOICE_TABLE . " WHERE post_id = %d AND is_current=%s", array($postid, '1')));
            $invoice_id = $invoice_info->id;
            // update invoice statuse and transactio details
            $transaction_details = $message;
            geodir_update_invoice_status($invoice_id, 'Unpaid');
            geodir_update_invoice_transaction_details($invoice_id, $transaction_details);
            /*############ SET THE INVOICE STATUS END ############*/
            if ($ct_on && file_exists($child_dir . '/library/includes/success.php')) {
                include_once $child_dir . '/library/includes/success.php';
            } else {
                include_once TEMPLATEPATH . '/library/includes/success.php';
            }
            exit;
            return false;
        }
    }
}
Esempio n. 12
0
function save_deal($post_id)
{
    global $post;
    if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], 'deal_panel')) {
        return $post_id;
    }
    $uploadpath = wp_upload_dir();
    $tmpfolder = $uploadpath['baseurl'] . '/tmp/';
    $imgstr = '';
    if ($_POST["file_info"] != '') {
        foreach ($_POST["file_info"] as $key => $val) {
            $imagepath = $tmpfolder . $key . '.jpg';
            $imgstr .= '<a href="' . $imagepath . '" target="_blank" ><img src="' . $imagepath . '" height="100" width="100" alt="" /></a> &nbsp; &nbsp;';
        }
    }
    $user_fname = $_POST['owner_name'];
    $user_email = $_POST['owner_email'];
    $deal_title = '<a href="' . $_POST['link_url'] . '">' . $_POST['post_title'] . '</a>';
    $deal_desc = $_POST['post_content'];
    $coupon_website = $_POST['coupon_website'];
    $no_of_coupon = $_POST['no_of_coupon'];
    $our_price = $_POST['our_price'];
    $current_price = $_POST['current_price'];
    $coupon_type = $_POST['coupon_type'];
    if ($_POST['coupon_entry'] == 'coupon_entry_0') {
        $single_coupon_code = $_POST['coupon_code1'];
    } else {
        $coupon_code = $_POST['coupon_code'];
    }
    //echo  $coupon_code= $_POST['coupon_code'];
    $coupon_address = $_POST['coupon_address'];
    $coupon_link = $_POST['coupon_link'];
    $mediafilename = $_POST['media_file'];
    if ($coupon_type == '1') {
        $coupon_type = 'Custom Link Deal';
    } elseif ($coupon_type == '2') {
        $coupon_type = 'Fixed Deal';
    } elseif ($coupon_type == '3') {
        $coupon_type = 'Custom Generated Deal';
    } elseif ($coupon_type == '4') {
        $coupon_type = 'Physical Barcode Deal';
    } elseif ($coupon_type == '5') {
        $coupon_type = 'Physical Product Deal';
    }
    // Start All Transection Details With Deal
    if ($coupon_type == '4' || $coupon_type == '5') {
        if ($coupon_address != "") {
            $transaction_details = sprintf(__("\n\t\t\t<p><h3>Deal Details</h3> \r</p>\n\t\t\t<p><strong>Deal Title: </strong>%s \r\t</p>\n\t\t\t<p><strong>Deal Desc: </strong>%s \r\t</p>\n\t\t\t<p><strong>Deal Type: </strong>%s \r\t</p>\n\t\t\t<p><strong>Original Price: </strong>%s \r\t</p>\n\t\t\t<p><strong>Current Price: </strong>%s \r\t</p>\n\t\t\t<p><strong>Store Address:</strong> %s \r\t</p>\n\t\t\t", 'templatic'), $deal_title, $deal_desc, $coupon_code, get_currency_sym() . $current_price, get_currency_sym() . $our_price, $current_price, $coupon_address);
        } else {
            $transaction_details = sprintf(__("\n\t\t\t<p><h3>Deal Details </h3> \r</p>\n\t\t\t<p><strong>Deal Title:</strong> %s \r</p>\n\t\t\t<p><strong>Deal Desc:</strong> %s \r\t</p>\n\t\t\t<p><strong>Deal Type: </strong>%s \r\t</p>\n\t\t\t<p><strong>Original Price: </strong>%s \r\t</p>\n\t\t\t<p><strong>Current Price: </strong>%s \r\t</p>\n\t\t\t", 'templatic'), $deal_title, $deal_desc, $coupon_code, $coupon_type, get_currency_sym() . $current_price, get_currency_sym() . $our_price);
        }
    } else {
        $transaction_details = sprintf(__("\n\t\t<p><h3>Deal Details </h3>\r</p>\n\t\t<p><strong>Deal Title:</strong> %s \r</p>\n\t\t<p><strong>Deal Coupon:</strong> %s \r\t</p>\n\t\t<p><strong>Deal Type:</strong> %s \r\t</p>\n\t\t<p><strong>Original Price: </strong>%s \r\t</p>\n\t\t<p><strong>Current Price: </strong>%s \r\t</p>\n\t\t", 'templatic'), $deal_title, $single_coupon_code, $coupon_type, get_currency_sym() . $current_price, get_currency_sym() . $our_price);
    }
    // End All Transection Details With Deal
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $store_name = get_option('blogname');
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    if ($_POST["status"] != "") {
        global $post;
        $pre = get_post_meta($post->ID, 'status', true);
        if ($pre != $_POST["status"]) {
            update_post_meta($post->ID, "status", $_POST["status"]);
            if ($_POST["status"] == '2') {
                update_post_meta($post->ID, "is_show", '1');
            }
            if ($_POST["status"] == '1' || $_POST["status"] == '2') {
                $client_message = get_option('req_accept_success_email_content');
                $users_details = sprintf(__("\n\t\t\t\t\t\t<p><h3>Seller Details</h3> \r</p>\n\t\t\t\t\t\t<p><strong>Name:</strong> %s \r\t</p>\n\t\t\t\t\t\t<p><strong>Email:</strong> %s \r\t</p>", 'templatic'), $user_fname, $user_email);
                $subject = get_option('req_accept_success_email_subject');
                $search_array = array('[#to_name#]', '[#site_name#]', '[#deal_details#]', '[#seller_details#]');
                $replace_array = array($user_fname . ",", $store_name, $transaction_details, $users_details);
                $email_seller_content = str_replace($search_array, $replace_array, $client_message);
                if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
                    templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_fname, $subject, $email_seller_content, $extra = '');
                }
            } else {
                if ($_POST["status"] == '3') {
                    $fromEmail = get_site_emailId();
                    $fromEmailName = get_site_emailName();
                    $store_name = get_option('blogname');
                    $client_message = get_option('req_reject_success_email_content');
                    $subject = get_option('req_reject_success_email_subject');
                    $search_array = array('[#to_name#]', '[#site_name#]');
                    $replace_array = array($user_fname . ",", $store_name);
                    $email_seller_content = str_replace($search_array, $replace_array, $client_message);
                    if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
                        templ_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, $subject, $email_seller_content, $extra = '');
                    }
                } else {
                    // Do nothing
                }
            }
        } else {
            if ($_POST["status"] == '2') {
                update_post_meta($post->ID, "is_show", '1');
            }
        }
    } else {
        delete_post_meta($post->ID, "status", $_POST["status"]);
    }
    if ($_POST["owner_name"] != "") {
        update_post_meta($post->ID, "owner_name", $_POST["owner_name"]);
    } else {
        delete_post_meta($post->ID, "owner_name", $_POST["owner_name"]);
    }
    if ($_POST["_wp_attached_file"] != "") {
        update_post_meta($post->ID, "_wp_attached_file", $_POST["_wp_attached_file"]);
    } else {
        delete_post_meta($post->ID, "_wp_attached_file", $_POST["_wp_attached_file"]);
    }
    if ($_POST["owner_email"] != "") {
        update_post_meta($post->ID, "owner_email", $_POST["owner_email"]);
    } else {
        delete_post_meta($post->ID, "owner_email", $_POST["owner_email"]);
    }
    if ($_POST["thankyou_page_url"] != "") {
        update_post_meta($post->ID, "thankyou_page_url", $_POST["thankyou_page_url"]);
    } else {
        delete_post_meta($post->ID, "thankyou_page_url", $_POST["thankyou_page_url"]);
    }
    if ($_POST["coupon_website"] != "") {
        update_post_meta($post->ID, "coupon_website", $_POST["coupon_website"]);
    } else {
        delete_post_meta($post->ID, "coupon_website", $_POST["coupon_website"]);
    }
    if ($_POST["no_of_coupon"] != "") {
        update_post_meta($post->ID, "no_of_coupon", $_POST["no_of_coupon"]);
    } else {
        delete_post_meta($post->ID, "no_of_coupon", $_POST["no_of_coupon"]);
    }
    if ($_POST["coupon_type"] != "") {
        update_post_meta($post->ID, "coupon_type", $_POST["coupon_type"]);
    } else {
        delete_post_meta($post->ID, "coupon_type", $_POST["coupon_type"]);
    }
    if ($_POST["coupon_entry"] != "") {
        update_post_meta($post->ID, "coupon_entry", $_POST["coupon_entry"]);
        if ($_POST["coupon_entry"] == "coupon_entry_0") {
            update_post_meta($post->ID, "coupon_code", $_POST["coupon_code1"]);
        } else {
            update_post_meta($post->ID, "coupon_code", $_POST["coupon_code"]);
        }
    } else {
        delete_post_meta($post->ID, "coupon_entry", $_POST["coupon_entry"]);
        delete_post_meta($post->ID, "coupon_code", $_POST["coupon_code"]);
    }
    if ($_POST["min_purchases"] != "") {
        update_post_meta($post->ID, "min_purchases", $_POST["min_purchases"]);
    } else {
        delete_post_meta($post->ID, "min_purchases", $_POST["min_purchases"]);
    }
    if ($_POST["max_purchases_user"] != "") {
        update_post_meta($post->ID, "max_purchases_user", $_POST["max_purchases_user"]);
    } else {
        delete_post_meta($post->ID, "max_purchases_user", $_POST["max_purchases_user"]);
    }
    if ($_POST["shhiping_address"] != "") {
        update_post_meta($post->ID, "shhiping_address", $_POST["shhiping_address"]);
    } else {
        delete_post_meta($post->ID, "shhiping_address", $_POST["shhiping_address"]);
    }
    if ($_POST["shipping_cost"] != "") {
        update_post_meta($post->ID, "shipping_cost", $_POST["shipping_cost"]);
    } else {
        delete_post_meta($post->ID, "shipping_cost", $_POST["shipping_cost"]);
    }
    if ($_POST["geo_latitude"] != "") {
        update_post_meta($post->ID, "geo_latitude", $_POST["geo_latitude"]);
    } else {
        delete_post_meta($post->ID, "geo_latitude", $_POST["geo_latitude"]);
    }
    if ($_POST["geo_longitude"] != "") {
        update_post_meta($post->ID, "geo_longitude", $_POST["geo_longitude"]);
    } else {
        delete_post_meta($post->ID, "geo_longitude", $_POST["geo_longitude"]);
    }
    if ($_POST["coupon_type"] == "3" || $_POST["coupon_type"] == "4") {
        if ($_POST["coupon_code"] == "") {
            $sys_gen_coupon = '';
            if ($single_coupon_code == '') {
                for ($c = 0; $c < $_POST["no_of_coupon"]; $c++) {
                    $user_coup = wp_generate_password(3, false);
                    $sys_gen_coupon .= $post->ID . $user_coup . ",";
                }
                $sys_gen_coupon = trim($sys_gen_coupon, ",");
            } else {
                $sys_gen_coupon = $single_coupon_code;
            }
            update_post_meta($post->ID, "coupon_code", $sys_gen_coupon);
        } else {
            $totcop = $_POST["coupon_code"];
            if ($_POST["used_coupon_code"] != "") {
                $totcop .= "," . $_POST["used_coupon_code"];
            }
            $totalcpoarr = explode(",", $totcop);
            if (sizeof($totalcpoarr) == $_POST["no_of_coupon"]) {
            } elseif ($_POST["no_of_coupon"] > sizeof($totalcpoarr)) {
                $totorigcop = $_POST["coupon_code"];
                $extra_coupon = $_POST["no_of_coupon"] - sizeof($totalcpoarr);
                for ($c = 0; $c < $extra_coupon; $c++) {
                    $user_coup = wp_generate_password(3, false);
                    $sys_gen_coupon .= $post->ID . $user_coup . ",";
                }
                $sys_gen_coupon = trim($sys_gen_coupon, ",");
                $addextra = $totorigcop . "," . $sys_gen_coupon;
                update_post_meta($post->ID, "coupon_code", $addextra);
            }
        }
    }
    if ($_POST["used_coupon_code"] != "") {
        update_post_meta($post->ID, "used_coupon_code", $_POST["used_coupon_code"]);
    } else {
        delete_post_meta($post->ID, "used_coupon_code", $_POST["used_coupon_code"]);
    }
    if ($_POST["coupon_address"] != "") {
        update_post_meta($post->ID, "coupon_address", $_POST["coupon_address"]);
    } else {
        delete_post_meta($post->ID, "coupon_address", $_POST["coupon_address"]);
    }
    if ($_POST["coupon_link"] != "") {
        update_post_meta($post->ID, "coupon_link", $_POST["coupon_link"]);
    } else {
        delete_post_meta($post->ID, "coupon_link", $_POST["coupon_link"]);
    }
    if ($_POST["file_name"] != "") {
        update_post_meta($post->ID, "file_name", $_POST["file_name"]);
    } else {
        delete_post_meta($post->ID, "file_name", $_POST["file_name"]);
    }
    if ($_POST["coupon_start_date"] != "" && $_POST["coupon_start_time_hh"] != "" && $_POST["coupon_start_time_mm"] != "" && $_POST["coupon_start_time_ss"] != "") {
        //echo $_POST["coupon_start_date"]." ".$_POST["coupon_start_time_hh"].":".$_POST["coupon_start_time_mm"].":".$_POST["coupon_start_time_ss"];
        $coupon_start_date_time = strtotime($_POST["coupon_start_date"] . " " . $_POST["coupon_start_time_hh"] . ":" . $_POST["coupon_start_time_mm"] . ":" . $_POST["coupon_start_time_ss"]);
        update_post_meta($post->ID, "coupon_start_date_time", $coupon_start_date_time);
    } else {
        delete_post_meta($post->ID, "coupon_start_date_time", $coupon_start_date_time);
    }
    if ($_POST["enddate"] != "" || isset($_POST["enddate"])) {
        update_post_meta($post->ID, "coupon_end_date_time", '');
        update_post_meta($post->ID, "enddate", '0');
        if (get_post_meta($post->ID, 'is_expired', true) != '0') {
            update_post_meta($post->ID, "is_expired", '0');
        }
    } else {
        if ($_POST["coupon_end_date"] != "" && $_POST["coupon_end_time_hh"] != "" && $_POST["coupon_end_time_mm"] != "" && $_POST["coupon_end_time_ss"] != "") {
            $_POST["coupon_end_date"] . " " . $_POST["coupon_end_time_hh"] . ":" . $_POST["coupon_end_time_mm"] . ":" . $_POST["coupon_end_time_ss"];
            $coupon_end_date_time = strtotime($_POST["coupon_end_date"] . " " . $_POST["coupon_end_time_hh"] . ":" . $_POST["coupon_end_time_mm"] . ":" . $_POST["coupon_end_time_ss"]);
            update_post_meta($post->ID, "coupon_end_date_time", $coupon_end_date_time);
            if (get_post_meta($post->ID, 'is_expired', true) != '0') {
                update_post_meta($post->ID, "is_expired", '0');
            }
        } else {
            update_post_meta($post->ID, "coupon_end_date_time", "");
        }
        update_post_meta($post->ID, "enddate", '');
    }
    //update_post_meta($post->ID, "is_expired", $_POST["is_expired"]);
    if ($_POST["is_expired"] != "") {
        //update_post_meta($post->ID, "is_expired", $_POST["is_expired"]);
    } else {
        //update_post_meta($post->ID, "is_expired", '0');
    }
    if ($_POST["our_price"] != "") {
        update_post_meta($post->ID, "our_price", $_POST["our_price"]);
    } else {
        delete_post_meta($post->ID, "our_price", $_POST["our_price"]);
    }
    if ($_POST["current_price"] != "") {
        update_post_meta($post->ID, "current_price", $_POST["current_price"]);
    } else {
        delete_post_meta($post->ID, "current_price", $_POST["current_price"]);
    }
    global $post, $meta_boxes, $key;
    if (!wp_verify_nonce($_POST[$key . '_wpnonce'], plugin_basename(__FILE__))) {
        return $post_id;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    foreach ($meta_boxes as $meta_box) {
        update_post_meta($post_id, $meta_box['name'], $_POST[$meta_box['name']]);
    }
}