function cp_contactformpp_translate_json($str)
{
    $form_data = json_decode(cp_contactformpp_cleanJSON($str));
    $form_data[1][0]->title = __($form_data[1][0]->title, 'cpcfwpp');
    $form_data[1][0]->description = __($form_data[1][0]->description, 'cpcfwpp');
    for ($i = 0; $i < count($form_data[0]); $i++) {
        $form_data[0][$i]->title = __($form_data[0][$i]->title, 'cpcfwpp');
        $form_data[0][$i]->userhelpTooltip = __($form_data[0][$i]->userhelpTooltip, 'cpcfwpp');
        $form_data[0][$i]->userhelp = __($form_data[0][$i]->userhelp, 'cpcfwpp');
        if ($form_data[0][$i]->ftype == 'fCommentArea') {
            $form_data[0][$i]->userhelp = __($form_data[0][$i]->userhelp, 'cpcfwpp');
        } else {
            if ($form_data[0][$i]->ftype == 'fradio' || $form_data[0][$i]->ftype == 'fcheck' || $form_data[0][$i]->ftype == 'fradio') {
                for ($j = 0; $j < count($form_data[0][$i]->choices); $j++) {
                    $form_data[0][$i]->choices[$j] = __($form_data[0][$i]->choices[$j], 'cpcfwpp');
                }
            }
        }
    }
    $str = json_encode($form_data);
    return $str;
}
           <em>This feature is available in the <a href="http://wordpress.dwbooster.com/forms/cp-contact-form-with-paypal#download">pro version</a>.</em>
        </td>
        </tr>  
                   
     </table>  

  </div>    
 </div>    
 

 <div id="metabox_basic_settings" class="postbox" >
  <h3 class='hndle' style="padding:5px;"><span>Form Builder</span></h3>
  <div class="inside">   
     <em>* Note: The Form Builder is read-only in this version.</em>
     <input type="hidden" name="form_structure" id="form_structure" size="180" value="<?php 
echo str_replace("\r", "", str_replace("\n", "", esc_attr(cp_contactformpp_cleanJSON(cp_contactformpp_get_option('form_structure', CP_CONTACTFORMPP_DEFAULT_form_structure)))));
?>
" />
     
     <link href="<?php 
echo plugins_url('css/style.css', __FILE__);
?>
" type="text/css" rel="stylesheet" />   
     <link href="<?php 
echo plugins_url('css/cupertino/jquery-ui-1.8.20.custom.css', __FILE__);
?>
" type="text/css" rel="stylesheet" />   
        
     <script>
         $contactFormPPQuery = jQuery.noConflict();
         $contactFormPPQuery(document).ready(function() {
echo $CP_CPP_global_form_count;
?>
" /><input type="hidden" name="cp_contactformpp_pform_process" value="1" /><input type="hidden" name="cp_contactformpp_id" value="<?php 
echo $id;
?>
" /><input type="hidden" name="cp_ref_page" value="<?php 
esc_attr(cp_contactformpp_get_FULL_site_url);
?>
" /><input type="hidden" name="form_structure<?php 
echo $CP_CPP_global_form_count;
?>
" id="form_structure<?php 
echo $CP_CPP_global_form_count;
?>
" size="180" value="<?php 
echo str_replace('"', '&quot;', str_replace("\r", "", str_replace("\n", "", esc_attr(cp_contactformpp_cleanJSON(cp_contactformpp_translate_json(cp_contactformpp_get_option('form_structure', CP_CONTACTFORMPP_DEFAULT_form_structure, $id)))))));
?>
" />
<div id="fbuilder">
  <div id="fbuilder<?php 
echo $CP_CPP_global_form_count;
?>
">
      <div id="formheader<?php 
echo $CP_CPP_global_form_count;
?>
"></div>
      <div id="fieldlist<?php 
echo $CP_CPP_global_form_count;
?>
"></div>
Exemplo n.º 4
0
function cp_contact_form_paypal_check_posted_data()
{
    global $wpdb;
    if (isset($_GET) && array_key_exists('cp_contact_form_paypal_post', $_GET)) {
        if ($_GET["cp_contact_form_paypal_post"] == 'loadcoupons') {
            cp_contactformpp_load_discount_codes();
        }
    }
    if (isset($_GET['cp_contactformpp']) && $_GET['cp_contactformpp'] == 'captcha') {
        @(include_once dirname(__FILE__) . '/captcha/captcha.php');
        exit;
    }
    if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['cp_contactformpp_post_options']) && is_admin()) {
        cp_contactformpp_save_options();
        return;
    }
    if ('POST' != $_SERVER['REQUEST_METHOD'] || !isset($_POST['cp_contactformpp_pform_process'])) {
        if ('GET' != $_SERVER['REQUEST_METHOD'] || !isset($_GET['hdcaptcha_cp_contact_form_paypal_post'])) {
            return;
        }
    }
    if (isset($_POST["cp_contactformpp_id"])) {
        define("CP_CONTACTFORMPP_ID", $_POST["cp_contactformpp_id"]);
    }
    @session_start();
    if (!isset($_GET['hdcaptcha_cp_contact_form_paypal_post']) || $_GET['hdcaptcha_cp_contact_form_paypal_post'] == '') {
        $_GET['hdcaptcha_cp_contact_form_paypal_post'] = @$_POST['hdcaptcha_cp_contact_form_paypal_post'];
    }
    if (cp_contactformpp_get_option('cv_enable_captcha', CP_CONTACTFORMPP_DEFAULT_cv_enable_captcha) != 'false' && ($_GET['hdcaptcha_cp_contact_form_paypal_post'] != $_SESSION['rand_code'] || $_SESSION['rand_code'] == '')) {
        echo 'captchafailed';
        exit;
    }
    // if this isn't the real post (it was the captcha verification) then echo ok and exit
    if ('POST' != $_SERVER['REQUEST_METHOD'] || !isset($_POST['cp_contactformpp_pform_process'])) {
        echo 'ok';
        exit;
    }
    // get price and discounts
    $price = cp_contactformpp_get_option('request_cost', CP_CONTACTFORMPP_DEFAULT_COST);
    $discount_note = "";
    $coupon = false;
    // get form info
    //---------------------------
    $form_data = json_decode(cp_contactformpp_cleanJSON(cp_contactformpp_get_option('form_structure', CP_CONTACTFORMPP_DEFAULT_form_structure)));
    $fields = array();
    foreach ($form_data[0] as $item) {
        $fields[$item->name] = $item->title;
    }
    // grab posted data
    //---------------------------
    $buffer = "";
    foreach ($_POST as $item => $value) {
        if (isset($fields[$item])) {
            $buffer .= $fields[$item] . ": " . (is_array($value) ? implode(", ", $value) : $value) . "\n\n";
            $params[$item] = $value;
        }
    }
    $buffer_A = $buffer;
    cp_contactformpp_add_field_verify(CP_CONTACTFORMPP_POSTS_TABLE_NAME, 'posted_data');
    // insert into database
    //---------------------------
    $to = cp_contactformpp_get_option('cu_user_email_field', CP_CONTACTFORMPP_DEFAULT_cu_user_email_field);
    $rows_affected = $wpdb->insert(CP_CONTACTFORMPP_POSTS_TABLE_NAME, array('formid' => CP_CONTACTFORMPP_ID, 'time' => current_time('mysql'), 'ipaddr' => $_SERVER['REMOTE_ADDR'], 'notifyto' => $_POST[$to], 'paypal_post' => serialize($params), 'posted_data' => serialize($params), 'data' => $buffer_A . ($coupon ? "\n\nCoupon code:" . $coupon->code . $discount_note : "")));
    if (!$rows_affected) {
        echo 'Error saving data! Please try again.';
        echo '<br /><br />Error debug information: ' . mysql_error();
        exit;
    }
    $myrows = $wpdb->get_results("SELECT MAX(id) as max_id FROM " . CP_CONTACTFORMPP_POSTS_TABLE_NAME);
    // save data here
    $item_number = $myrows[0]->max_id;
    ?>
<html>
<head><title>Redirecting to Paypal...</title></head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" name="ppform3" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="<?php 
    echo cp_contactformpp_get_option('paypal_email', CP_CONTACTFORMPP_DEFAULT_PAYPAL_EMAIL);
    ?>
" />
<input type="hidden" name="item_name" value="<?php 
    echo cp_contactformpp_get_option('paypal_product_name', CP_CONTACTFORMPP_DEFAULT_PRODUCT_NAME) . $discount_note;
    ?>
" />
<input type="hidden" name="item_number" value="<?php 
    echo $item_number;
    ?>
" />
<input type="hidden" name="amount" value="<?php 
    echo $price;
    ?>
" />
<input type="hidden" name="page_style" value="Primary" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="<?php 
    echo cp_contactformpp_get_option('fp_return_page', CP_CONTACTFORMPP_DEFAULT_fp_return_page);
    ?>
">
<input type="hidden" name="cancel_return" value="<?php 
    echo $_POST["cp_ref_page"];
    ?>
" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="<?php 
    echo strtoupper(cp_contactformpp_get_option('currency', CP_CONTACTFORMPP_DEFAULT_CURRENCY));
    ?>
" />
<input type="hidden" name="lc" value="<?php 
    echo cp_contactformpp_get_option('paypal_language', CP_CONTACTFORMPP_DEFAULT_PAYPAL_LANGUAGE);
    ?>
" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input type="hidden" name="notify_url" value="<?php 
    echo cp_contactformpp_get_FULL_site_url();
    ?>
/?cp_contactformpp_ipncheck=1&itemnumber=<?php 
    echo $item_number;
    ?>
" />
<input type="hidden" name="ipn_test" value="1" />
<input class="pbutton" type="hidden" value="Buy Now" /></div>
</form>
<script type="text/javascript">
document.ppform3.submit();
</script>
</body>
</html>
<?php 
    exit;
}