Ejemplo n.º 1
0
 public function form_fields()
 {
     $form_fields = array(array('title' => __('Reference ID', APP_TD), 'type' => 'text', 'name' => 'cp_sys_ad_conf_id', 'default' => cp_generate_id(), 'extra' => array('readonly' => 'readonly')), array('title' => __('Views Today', APP_TD), 'type' => 'text', 'name' => 'cp_daily_count', 'sanitize' => 'absint', 'default' => '0', 'extra' => array('readonly' => 'readonly')), array('title' => __('Views Total', APP_TD), 'type' => 'text', 'name' => 'cp_total_count', 'sanitize' => 'absint', 'default' => '0', 'extra' => array('readonly' => 'readonly')), array('title' => __('Submitted from IP', APP_TD), 'type' => 'text', 'name' => 'cp_sys_userIP', 'default' => appthemes_get_ip(), 'extra' => array('readonly' => 'readonly')));
     if (cp_payments_is_enabled()) {
         $form_fields[] = array('title' => __('Last Payment', APP_TD), 'type' => 'text', 'name' => 'cp_sys_total_ad_cost', 'default' => '0', 'desc' => APP_Currencies::get_current_symbol(), 'extra' => array('readonly' => 'readonly'));
     }
     return $form_fields;
 }
Ejemplo n.º 2
0
     }
 }
 // keep only numeric, commas or decimal values
 $postvals['cp_price'] = empty($_POST['cp_price']) ? '' : appthemes_clean_price($_POST['cp_price']);
 if (isset($postvals['cp_currency']) && !empty($postvals['cp_currency'])) {
     $price_curr = $postvals['cp_currency'];
 } else {
     $price_curr = $cp_options->curr_symbol;
 }
 // keep only values and insert/strip commas if needed
 if (!empty($_POST['tags_input'])) {
     $postvals['tags_input'] = appthemes_clean_tags($_POST['tags_input']);
     $_POST['tags_input'] = $postvals['tags_input'];
 }
 // store the user IP address, ID for later
 $postvals['cp_sys_userIP'] = appthemes_get_ip();
 $postvals['user_id'] = $current_user->ID;
 $ad_pack_id = isset($_POST['ad_pack_id']) ? appthemes_numbers_only($_POST['ad_pack_id']) : false;
 if ($ad_pack_id) {
     $postvals['pack_duration'] = cp_get_ad_pack_length($ad_pack_id);
 }
 $coupon = false;
 if (cp_payments_is_enabled()) {
     // see if the featured ad checkbox has been checked
     if (isset($_POST['featured_ad'])) {
         $postvals['featured_ad'] = $_POST['featured_ad'];
         // get the featured ad price into the array
         $postvals['cp_sys_feat_price'] = $cp_options->sys_feat_price;
     }
     // calculate the ad listing fee and put into a variable
     $postvals['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($_POST['cat'], $ad_pack_id, $postvals['cp_price'], $price_curr);
Ejemplo n.º 3
0
function cp_save_meta_box($post_id)
{
    global $wpdb, $post, $key;
    // make sure something has been submitted from our nonce
    if (!isset($_POST[$key . '_wpnonce'])) {
        return $post_id;
    }
    // verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times
    if (!wp_verify_nonce($_POST[$key . '_wpnonce'], basename(__FILE__))) {
        return $post_id;
    }
    // verify if this is an auto save routine.
    // if it is our form and it has not been submitted, dont want to do anything
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // lastly check to make sure this user has permissions to save post fields
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    // delete any images checked
    if (!empty($_POST['image'])) {
        cp_delete_image();
    }
    // update the image alt text
    if (!empty($_POST['attachments'])) {
        cp_update_alt_text();
    }
    // add a new image if one has been detected
    if ($attach_id = $_POST['new_ad_image_id']) {
        wp_update_post(array('ID' => $attach_id, 'post_parent' => $post_id));
    }
    // assemble the comma separated hidden fields back into an array so we can save them.
    $metafields = explode(',', $_POST['custom_fields_vals']);
    // loop through all custom meta fields and update values
    foreach ($metafields as $name) {
        //echo $name . ' <-- POST NAME<br/>';
        //echo $_POST["$name"] . ' <-- VALUE<br/><br/>';
        if (!isset($_POST[$name])) {
            delete_post_meta($post_id, $name);
        } else {
            if (is_array($_POST[$name])) {
                delete_post_meta($post_id, $name);
                foreach ($_POST[$name] as $checkbox_value) {
                    add_post_meta($post_id, $name, $checkbox_value);
                }
            } else {
                update_post_meta($post_id, $name, $_POST[$name]);
            }
        }
    }
    // give the ad a unique ID if it's a new ad listing
    if (!($cp_id = get_post_meta($post->ID, 'cp_sys_ad_conf_id', true))) {
        $cp_item_id = uniqid(rand(10, 1000), false);
        add_post_meta($post_id, 'cp_sys_ad_conf_id', $cp_item_id, true);
    }
    // save the IP address if it's a new ad listing
    if (!($cp_ip = get_post_meta($post->ID, 'cp_sys_userIP', true))) {
        add_post_meta($post_id, 'cp_sys_userIP', appthemes_get_ip(), true);
    }
    // set stats to zero so we at least have some data
    if (!($cp_dcount = get_post_meta($post->ID, 'cp_daily_count', true))) {
        add_post_meta($post_id, 'cp_daily_count', '0', true);
    }
    if (!($cp_tcount = get_post_meta($post->ID, 'cp_total_count', true))) {
        add_post_meta($post_id, 'cp_total_count', '0', true);
    }
    // set default ad duration, will need it to renew
    if (!($cp_ad_duration = get_post_meta($post->ID, 'cp_sys_ad_duration', true))) {
        $ad_length = get_option('cp_prun_period');
        add_post_meta($post_id, 'cp_sys_ad_duration', $ad_length, true);
    }
    // set ad cost to zero, will need it for free renew
    if (!($cp_tcost = get_post_meta($post->ID, 'cp_sys_total_ad_cost', true))) {
        add_post_meta($post_id, 'cp_sys_total_ad_cost', '0.00', true);
    }
}
Ejemplo n.º 4
0
 /**
  * Returns a transient key.
  *
  * @return string
  */
 protected function get_transient_key()
 {
     $user_key = is_user_logged_in() ? get_current_user_id() : appthemes_get_ip();
     $user_key = str_replace('.', '_', $user_key);
     return $this->checkout_type . '_' . $this->hash . '_' . $user_key;
 }
Ejemplo n.º 5
0
function appthemes_delete_visitor_transient($transient)
{
    $transient = $transient . '-' . appthemes_get_ip();
    return delete_transient($transient);
}
Ejemplo n.º 6
0
function cp_contact_ad_owner_email2($post_id, $files)
{
    $errors = new WP_Error();
    // check for required post data
    $expected = array('from_name', 'from_email', 'subject', 'message');
    foreach ($expected as $field_name) {
        if (empty($_POST[$field_name])) {
            $errors->add('empty_field', __('ERROR: All fields are required.', APP_TD));
            return $errors;
        }
    }
    // check for required anti-spam post data
    $expected_numbers = array('rand_total', 'rand_num', 'rand_num2');
    foreach ($expected_numbers as $field_name) {
        if (!isset($_POST[$field_name]) || !is_numeric($_POST[$field_name])) {
            $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD));
            return $errors;
        }
    }
    // verify captcha answer
    $rand_post_total = (int) $_POST['rand_total'];
    $rand_total = (int) $_POST['rand_num'] + (int) $_POST['rand_num2'];
    if ($rand_total != $rand_post_total) {
        $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD));
    }
    // verify email
    if (!is_email($_POST['from_email'])) {
        $errors->add('invalid_email', __('ERROR: Incorrect email address.', APP_TD));
    }
    // verify post
    $post = get_post($post_id);
    if (!$post) {
        $errors->add('invalid_post', __('ERROR: Ad does not exist.', APP_TD));
    }
    if ($errors->get_error_code()) {
        return $errors;
    }
    $mailto = get_the_author_meta('user_email', $post->post_author);
    $from_name = appthemes_filter(appthemes_clean($_POST['from_name']));
    $from_email = appthemes_clean($_POST['from_email']);
    $subject = appthemes_filter(appthemes_clean($_POST['subject']));
    $posted_message = appthemes_filter(appthemes_clean($_POST['message']));
    $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
    $siteurl = home_url('/');
    $permalink = get_permalink($post_id);
    $message = sprintf(__('Someone is interested in your ad listing: %s', APP_TD), $permalink) . "\r\n\r\n";
    $message .= '"' . wordwrap($posted_message, 70) . '"' . "\r\n\r\n";
    $message .= sprintf(__('Name: %s', APP_TD), $from_name) . "\r\n";
    $message .= sprintf(__('E-mail: %s', APP_TD), $from_email) . "\r\n\r\n";
    $message .= '-----------------------------------------' . "\r\n";
    $message .= sprintf(__('This message was sent from %s', APP_TD), $sitename) . "\r\n";
    $message .= $siteurl . "\r\n\r\n";
    $message .= __('Sent from IP Address: ', APP_TD) . appthemes_get_ip() . "\r\n\r\n";
    $email = array('to' => $mailto, 'subject' => $subject, 'message' => $message, 'from' => $from_email, 'from_name' => $from_name);
    $email = apply_filters('cp_email_user_ad_contact', $email, $post_id);
    APP_Mail_From::apply_once(array('email' => $email['from'], 'name' => $email['from_name'], 'reply' => true));
    $resumes = explode(',', $files[0]);
    $attachments = array();
    foreach ($resumes as $resume) {
        array_push($attachments, WP_CONTENT_DIR . '/themes/classiclean/server/files/' . $resume);
    }
    wp_mail($email['to'], $email['subject'], $email['message'], null, $attachments);
    return $errors;
}
Ejemplo n.º 7
0
function cp_contact_ad_owner_email($postID)
{
    // wp_mail doesn't seem to work with cc or bcc in headers (as of 2.9.2)
    // this is here for adding it later
    // $Cc = '*****@*****.**';
    // $Bcc = get_option('admin_email');
    // check to see if ad is legacy or not
    if (get_post_meta($postID, 'email', true)) {
        $mailto = get_post_meta($postID, 'email', true);
    } else {
        $mailto = get_the_author_meta('user_email');
    }
    $from_name = strip_tags($_POST['from_name']);
    $from_email = strip_tags($_POST['from_email']);
    //$mailto = '*****@*****.**'; // USED FOR TESTING
    $subject = strip_tags($_POST['subject']);
    $headers = "From: {$from_name} <{$from_email}> \r\n";
    $headers .= "Reply-To: {$from_name} <{$from_email}> \r\n";
    // $headers .= "Cc: $Cc \r\n";
    // $headers .= "BCC: $Bcc \r\n";
    // 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
    $sitename = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $siteurl = trailingslashit(get_option('home'));
    $permalink = get_permalink();
    $message = sprintf(__('Someone is interested in your ad listing: %s', 'appthemes'), $permalink) . "\r\n\r\n";
    // $message  = sprintf(__('From: %s - %s', 'appthemes'), $from_name, $from_email) . "\r\n\r\n";
    $fixPostMessage = stripslashes($_POST['message']);
    $message .= '"' . wordwrap(strip_tags($fixPostMessage), 70) . '"' . "\r\n\r\n\r\n";
    $message .= sprintf(__('Name: %s', 'appthemes'), $from_name) . "\r\n";
    $message .= sprintf(__('E-mail: %s', 'appthemes'), $from_email) . "\r\n\r\n\r\n\r\n";
    $message .= '-----------------------------------------' . "\r\n";
    $message .= sprintf(__('This message was sent from %s', 'appthemes'), $sitename) . "\r\n";
    $message .= $siteurl . "\r\n\r\n";
    $message .= __('Sent from IP Address: ', 'appthemes') . appthemes_get_ip() . "\r\n\r\n";
    // ok let's send the email
    wp_mail($mailto, $subject, $message, $headers);
}
Ejemplo n.º 8
0
                    <input type="button" name="goback" class="btn_orange" value="<?php 
_e('Go back', 'appthemes');
?>
" onclick="history.back()" />
                    <input type="submit" name="step2" id="step2" class="btn_orange" value="<?php 
_e('Proceed ', 'appthemes');
?>
 &rsaquo;&rsaquo;" />
                </p>

                    <input type="hidden" id="oid" name="oid" value="<?php 
echo $_POST['oid'];
?>
" />
                    <input type="hidden" id="pack" name="pack" value="<?php 
echo $_POST['pack'];
?>
" />
                    <input type="hidden" id="total_cost" name="total_cost" value="<?php 
echo $total_cost;
?>
" />
                    <input type="hidden" id="cp_sys_userIP" name="cp_sys_userIP" value="<?php 
echo appthemes_get_ip();
?>
" />
                    

	    </form>

		<div class="clear"></div>
Ejemplo n.º 9
0
/**
 * Convert transactions to format of new AppThemes Payments.
 *
 * @since 3.3
 */
function cp_upgrade_transactions_330()
{
    global $wpdb;
    if (!current_theme_supports('app-payments')) {
        return;
    }
    // legacy orders
    $legacy_orders = $wpdb->get_results("SELECT * FROM {$wpdb->cp_order_info} ");
    if (!$legacy_orders) {
        return;
    }
    foreach ($legacy_orders as $legacy_order) {
        // create new post for order
        $new_order_post = array('post_title' => __('Transaction', APP_TD), 'post_content' => __('Transaction Data', APP_TD), 'post_status' => $legacy_order->payment_status == 'Completed' ? APPTHEMES_ORDER_ACTIVATED : APPTHEMES_ORDER_PENDING, 'post_type' => APPTHEMES_ORDER_PTYPE, 'post_date' => date('Y-m-d H:i:s', strtotime($legacy_order->payment_date)), 'post_author' => $legacy_order->user_id ? $legacy_order->user_id : 1);
        $new_order_id = wp_insert_post($new_order_post);
        if (!$new_order_id) {
            continue;
        }
        // set correct slug
        wp_update_post(array('ID' => $new_order_id, 'post_name' => $new_order_id));
        $price = empty($legacy_order->mc_gross) || !is_numeric($legacy_order->mc_gross) ? 0 : $legacy_order->mc_gross;
        // add meta fields for order
        $new_order_postmeta = array('currency' => $legacy_order->mc_currency, 'total_price' => $price, 'gateway' => $legacy_order->payment_type == 'banktransfer' ? 'bank-transfer' : 'paypal', 'transaction_id' => $legacy_order->txn_id, 'bt-sentemail' => '1', 'ip_address' => appthemes_get_ip(), 'first_name' => $legacy_order->first_name, 'last_name' => $legacy_order->last_name, 'street' => $legacy_order->street, 'city' => $legacy_order->city, 'state' => $legacy_order->state, 'postcode' => $legacy_order->zipcode, 'country' => $legacy_order->residence_country);
        foreach ($new_order_postmeta as $meta_key => $meta_value) {
            add_post_meta($new_order_id, $meta_key, $meta_value, true);
        }
        $order = appthemes_get_order($new_order_id);
        if (!$order) {
            continue;
        }
        if (!empty($legacy_order->ad_id) && $legacy_order->ad_id > 0) {
            $order->add_item(CP_ITEM_LISTING, $price, $legacy_order->ad_id);
        } else {
            $order->add_item(CP_ITEM_MEMBERSHIP, $price);
        }
        // remove legacy entry
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->cp_order_info} WHERE id = %d", $legacy_order->id));
    }
}
Ejemplo n.º 10
0
/**
 * Sends email to ad author from contact form.
 *
 * @param int $post_id
 *
 * @return object
 */
function cp_contact_ad_owner_email($post_id)
{
    $errors = new WP_Error();
    // check for required post data
    $expected = array('from_name', 'from_email', 'subject', 'message');
    foreach ($expected as $field_name) {
        if (empty($_POST[$field_name])) {
            $errors->add('empty_field', __('ERROR: All fields are required.', APP_TD));
            return $errors;
        }
    }
    // check for required anti-spam post data
    $expected_numbers = array('rand_total', 'rand_num', 'rand_num2');
    foreach ($expected_numbers as $field_name) {
        if (!isset($_POST[$field_name]) || !is_numeric($_POST[$field_name])) {
            $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD));
            return $errors;
        }
    }
    // verify captcha answer
    $rand_post_total = (int) $_POST['rand_total'];
    $rand_total = (int) $_POST['rand_num'] + (int) $_POST['rand_num2'];
    if ($rand_total != $rand_post_total) {
        $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD));
    }
    // verify email
    if (!is_email($_POST['from_email'])) {
        $errors->add('invalid_email', __('ERROR: Incorrect email address.', APP_TD));
    }
    // verify post
    $post = get_post($post_id);
    if (!$post) {
        $errors->add('invalid_post', __('ERROR: Ad does not exist.', APP_TD));
    }
    if ($errors->get_error_code()) {
        return $errors;
    }
    $author_email = get_the_author_meta('user_email', $post->post_author);
    $from_name = appthemes_filter(appthemes_clean($_POST['from_name']));
    $from_email = appthemes_clean($_POST['from_email']);
    $subject = appthemes_filter(appthemes_clean($_POST['subject']));
    $posted_message = appthemes_filter(appthemes_clean($_POST['message']));
    $blogname = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
    $site_url = home_url('/');
    $permalink = get_permalink($post_id);
    $message = html('p', sprintf(__('Someone is interested in your ad listing: %s', APP_TD), html_link($permalink))) . PHP_EOL;
    $message .= html('p', '"' . wordwrap(nl2br($posted_message), 70) . '"') . PHP_EOL;
    $message .= html('p', sprintf(__('Name: %s', APP_TD), $from_name) . '<br />' . sprintf(__('E-mail: %s', APP_TD), $from_email)) . PHP_EOL;
    $message .= html('p', __('-----------------', APP_TD) . '<br />' . sprintf(__('This message was sent from %s', APP_TD), $blogname) . '<br />' . html_link($site_url)) . PHP_EOL;
    $message .= html('p', sprintf(__('Sent from IP Address: %s', APP_TD), appthemes_get_ip())) . PHP_EOL;
    $email = array('to' => $author_email, 'subject' => $subject, 'message' => $message, 'from' => $from_email, 'from_name' => $from_name);
    $email = apply_filters('cp_email_user_ad_contact', $email, $post_id);
    APP_Mail_From::apply_once(array('email' => $email['from'], 'name' => $email['from_name'], 'reply' => true));
    appthemes_send_email($email['to'], $email['subject'], $email['message']);
    return $errors;
}
Ejemplo n.º 11
0
 /**
  * Sets listing internal data.
  *
  * return void
  */
 protected function set_internal_data()
 {
     global $cp_options, $current_user;
     $listing = $this->get_listing_obj();
     // add items needed for function that displays listing preview
     $this->posted_fields['fid'] = $this->form_id;
     $this->posted_fields['cat'] = $this->category_id;
     // set listing unique id
     if ($unique_id = get_post_meta($listing->ID, 'cp_sys_ad_conf_id', true)) {
         $this->posted_fields['cp_sys_ad_conf_id'] = $unique_id;
     } else {
         $this->posted_fields['cp_sys_ad_conf_id'] = cp_generate_id();
     }
     // set user IP
     $this->posted_fields['cp_sys_userIP'] = appthemes_get_ip();
     // set listing duration
     if ($this->posted_fields['ad_pack_id']) {
         $this->posted_fields['cp_sys_ad_duration'] = cp_get_ad_pack_length($this->posted_fields['ad_pack_id']);
     } else {
         $this->posted_fields['cp_sys_ad_duration'] = $cp_options->prun_period;
     }
     $listing_price_currency = !empty($this->posted_fields['cp_currency']) ? $this->posted_fields['cp_currency'] : $cp_options->curr_symbol;
     $coupon = false;
     // legacy coupon value
     if (cp_payments_is_enabled()) {
         // see if the featured ad checkbox has been checked
         if (!empty($this->posted_fields['featured_ad'])) {
             $this->posted_fields['featured_ad'] = 1;
             // save featured ad price
             $this->posted_fields['cp_sys_feat_price'] = $cp_options->sys_feat_price;
         }
         // calculate the ad listing fee and put into a variable
         $this->posted_fields['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($this->category_id, $this->posted_fields['ad_pack_id'], $this->posted_fields['cp_price'], $listing_price_currency);
         $featured_price = isset($this->posted_fields['cp_sys_feat_price']) ? $this->posted_fields['cp_sys_feat_price'] : 0;
         $this->posted_fields['cp_sys_total_ad_cost'] = cp_calc_ad_cost($this->category_id, $this->posted_fields['ad_pack_id'], $featured_price, $this->posted_fields['cp_price'], $coupon, $listing_price_currency);
         $this->posted_fields['cp_sys_total_ad_cost_no_benefit'] = $this->posted_fields['cp_sys_total_ad_cost'];
         // apply membership benefit
         if ($cp_options->enable_membership_packs && ($membership = cp_get_user_membership_package($current_user->ID))) {
             $this->posted_fields['membership_pack'] = $membership->ID;
             // update the total cost based on the membership pack ID and current total cost
             $this->posted_fields['cp_sys_total_ad_cost'] = cp_calculate_membership_package_benefit($membership->ID, $this->posted_fields['cp_sys_total_ad_cost']);
             // add featured cost to static pack type
             if ($featured_price && $membership->pack_type == 'static') {
                 $this->posted_fields['cp_sys_total_ad_cost'] += $featured_price;
             }
         }
     }
     // prevent from minus prices if bigger discount applied
     if (!isset($this->posted_fields['cp_sys_total_ad_cost']) || $this->posted_fields['cp_sys_total_ad_cost'] < 0) {
         $this->posted_fields['cp_sys_total_ad_cost'] = 0;
     }
 }