Plugin Directory

Changeset 702419


Ignore:
Timestamp:
04/23/2013 06:41:08 PM (13 years ago)
Author:
joshua.strebel
Message:

General code cleanup, proper use of nounces

Location:
pagely-reseller-management/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • pagely-reseller-management/trunk/assets/js/pp-api.js

    r601740 r702419  
    1212
    1313    // account form validation
    14     var validator = $("#pagely_form_acc").validate({   
     14    $("#acc_submit").click( function(event) {
     15       
     16        acc_form_validate();
     17        }
     18    );
     19   
     20    var acc_form_validate = function () {
     21   
     22        $("#pagely_form_acc").validate({   
    1523        rules: {
    1624            "pagely_order[mobile]": {
     
    5866    }
    5967   
    60     });
     68     });
     69     
     70    };
    6171   
    6272    // post-submit callback for account
     
    7484            var error = responseObj.message;
    7585            done_waiting();
    76             //$('#form_msg').html('<p class="alert">'+error+'</p>').addClass('error').effect("highlight", {}, 3000);
     86            $('.form_msg').html('<p class="alert alert-error">'+error+'</p>').addClass('error');
    7787           
    7888            if (error) {
     
    165175           
    166176            done_waiting();
    167             //$('#form_msg').html('<p class="alert">'+error+'</p>').addClass('error').effect("highlight", {}, 3000);
     177            $('.form_msg').html('<p class="alert alert-error">'+error+'</p>').addClass('error');
    168178           
    169179            $( "#pp_dialog" ).html('<p class="alert alert-danger">'+error+'</p>');
     
    219229            data: {
    220230                action: "pagely_jax_purchase_cart_callback",
    221                 ppjaxnounce: $('#_wpnonce').val(),
     231                ppjaxnounce: $('#pagely_order_cart_nounce').val(),
     232
    222233            },
    223234            success: function(data) {
     
    266277    });
    267278   
    268     // domain remote validation
    269     $('#po_domain').blur( function (){
    270         $('#po_domain').addClass('remote');
     279
     280   // domain remote validation
     281   $.fn.validate_domain = function(el) {
     282
     283      $('#po_domain').addClass('remote');
    271284        $.ajax({
    272285            url: pagelyJax.ajaxurl,
     
    274287            data: {
    275288                action: "pagely_jax_formvalidate_callback",
    276                 ppjaxnounce: $('#_wpnonce').val(),
     289                ppjaxnounce: $('#pagely_order_acc_nounce').val(),
    277290                field: "pagely_order[domain]",
    278                 value: $(this).val()
     291                value: $(el).val()
    279292            },
    280293            success: function(data) {
     
    282295                if (data.result == 3) {
    283296                    //error
    284                     $('#po_domain').siblings('p.help-block').remove();
    285                     $('#po_domain').removeClass().addClass('error required');
    286                     $( "#po_domain" ).parent('.controls').append('<p class="help-block alert alert-danger">'+data.message+'</p>');
     297                    $(el).siblings('p.help-block').remove();
     298                    $(el).removeClass().addClass('error required');
     299                    $(el).parent('.controls').append('<p class="help-block alert alert-danger">'+data.message+'</p>');
    287300                   
    288301                   
    289302                } else {
    290303                    //success
    291                     $('#po_domain').removeClass().addClass('valid required');
    292                     $('#po_domain').siblings('p.help-block').remove();
    293 
    294                     $('#_wpnonce').val(pagelyJax.ppjaxnounce);
     304                    $(el).removeClass().addClass('valid required');
     305                    $(el).siblings('p.help-block').remove();
     306                    //$('#_wpnonce').val(pagelyJax.ppjaxnounce);
    295307                }
    296308                   
    297309            } 
    298         });                 
     310        }); 
     311
     312    };
     313   
     314   // call in field blur
     315    $('#po_domain').blur( function (){
     316        $.fn.validate_domain(this);
    299317   });
    300318   
     319
     320   
    301321   // email remote validation
    302    $('#po_email').blur( function (){
    303         $('#po_email').addClass('remote');
     322   $.fn.validate_email = function(el) {
     323    $('#po_email').addClass('remote');
    304324        $.ajax({
    305325            url: pagelyJax.ajaxurl,
     
    307327            data: {
    308328                action: "pagely_jax_formvalidate_callback",
    309                 ppjaxnounce: $('#_wpnonce').val(),
     329                ppjaxnounce: $('#pagely_order_acc_nounce').val(),
    310330                field: "pagely_order[email]",
    311                 value: $(this).val()
     331                value: $(el).val()
    312332            },
    313333            success: function(data) {
     
    315335                if (data.result == 3) {
    316336                    //error
    317                     $('#po_email').siblings('p.help-block').remove();
    318                     $('#po_email').removeClass().addClass('error required');
     337                    $(el).siblings('p.help-block').remove();
     338                    $(el).removeClass().addClass('error required');
    319339
    320340                    if (data.message == "That email address is already in use.") {
    321                         $( "#po_email" ).parent('.controls').append('<p class="help-block alert alert-danger">Existing customer? <a href="https://atomic.pagely.com">Login</a> to add a new site.</p>');
     341                        $( el ).parent('.controls').append('<p class="help-block alert alert-danger">Existing customer? <a href="https://atomic.pagely.com">Login</a> to add a new site.</p>');
    322342                    }
    323343                } else {
    324344                    //success
    325                     $('#po_email').removeClass().addClass('valid required email');
    326                     $('#po_email').siblings('p.help-block').remove();
    327 
    328                     $('#_wpnonce').val(pagelyJax.ppjaxnounce);
     345                    $(el).removeClass().addClass('valid required email');
     346                    $(el).siblings('p.help-block').remove();
     347
     348                    //$('#_wpnonce').val(pagelyJax.ppjaxnounce);
    329349                }
    330350                   
    331351            } 
    332         });                 
     352        });         
     353   };
     354   
     355   $('#po_email').blur( function (){
     356        $.fn.validate_email(this);
    333357   });
    334358
     
    360384            data: {
    361385                action: "pagely_jax_gopaypal_callback",
    362                 ppjaxnounce: $('#_wpnonce').val(),
     386                ppjaxnounce: $('#pagely_order_pay_nounce').val(),
     387
    363388            },
    364389            success: function(response) {
     
    399424        $("#state_drop").hide().removeClass('required').attr('name','');
    400425        if (str != null) {
    401             $("#po_state_text").show().addClass('required').attr('name','subscription[billing_state]').val(''+str).effect("highlight", {}, 3000);
     426            $("#po_state_text").show().addClass('required').attr('name','subscription[billing_state]').val(''+str);
    402427        } else {
    403             $("#po_state_text").show().addClass('required').attr('name','subscription[billing_state]').val('').effect("highlight", {}, 3000);
     428            $("#po_state_text").show().addClass('required').attr('name','subscription[billing_state]').val('');
    404429   
    405430        }
     
    498523                action: "pagely_jax_generic_callback",
    499524                ppdo: "clear_session",
    500                 ppjaxnounce: $('#_wpnonce').val(),
     525                //ppjaxnounce: $('#_wpnonce').val(),
    501526            },
    502527            success: function() {
  • pagely-reseller-management/trunk/inc/helpers.php

    r601734 r702419  
    2525************************/
    2626function pagely_order_form($slug) {
    27     // check if page is ssl, else redirect.
     27   
     28    // load the class           
     29    $pagely = PagelyApi::init();
     30   
     31    // check if page is ssl and in live mode, else redirect.
     32
    2833    $location = "https://" . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
    29     if ( !is_ssl() ) {
     34    if ( !is_ssl() && !$pagely->_is_sandbox() ) {
    3035   
    3136        echo "<script type='text/javascript'>window.location = '$location'</script>";
    3237        die();
    3338    }
    34     // load the class           
    35     $pagely = PagelyApi::init();
     39
    3640   
    3741    if (isset($_GET['complete']) && $_GET['complete'] == 'true') {
  • pagely-reseller-management/trunk/partner-api.php

    r634731 r702419  
    44Plugin URI: https://docs-api.pagely.com/reseller-plugin/
    55Description: For Pagely Resellers
    6 Version: 3.1.1
     6Version: 3.1.2
    77Author: joshua.strebel
    8 Author URI: http://page.ly
     8Author URI: https://page.ly
    99
    1010*/
     
    8383   
    8484   var $live_endpoint           = 'https://api.pagely.com/v1';
    85    var $sandbox_endpoint        = 'https://sandbox-api.pagely.com/v1';
     85  // var $sandbox_endpoint      = 'https://sandbox-api.pagely.com/v1';
     86   var $sandbox_endpoint        = 'http://api.hcs/v1';
     87
    8688
    8789   var $api_endpoint            = '';
     
    210212                wp_localize_script( 'pp-form-js', 'pagelyJax', array(
    211213                        'ajaxurl' => admin_url( 'admin-ajax.php' ),
    212                         'ppjaxnounce' => wp_create_nonce( 'chickendinner' ),
     214                        //'ppjaxnounce' => wp_create_nonce( 'chickendinner' ),
    213215                        'pp_portal_url' => $this->pp_portal_url,
    214216                        'session_data' => json_encode( $this->_get_pp_session() ),
     
    241243        if ($allow_signups == 1) {
    242244            return true;
     245        } else {
     246            return false;
     247        }
     248    }
     249   
     250    //are signups on?
     251    function _get_trial_length() {
     252        $api_options = get_option('pp_api');
     253        $free_trial_days = $api_options['free_trial_days'];
     254        if ($free_trial_days > 0) {
     255            return $free_trial_days;
    243256        } else {
    244257            return false;
     
    394407                'pp_api',                                   
    395408                array( $pagely_options['support_url'], 'support_url' ) 
    396             );
     409            );
     410           
     411       
     412            // free_trial length
     413            if ($pagely_options['reseller_id'] == 1) {
     414                if (!isset($pagely_options['free_trial_days'])) { $pagely_options['free_trial_days'] = 0; }
     415                add_settings_field( 
     416                    'free_trial_days',                                   
     417                    'Length of Free Trial (Days)',                       
     418                    array(&$this, '_pagely_options_field_free_trial'),                 
     419                    'partner-api',                         
     420                    'pp_api',                                   
     421                    array( $pagely_options['free_trial_days'], 'free_trial_days' ) 
     422                );
     423            }
    397424           
    398425            // order_by
     
    457484                    <option value='1' {$checked2}>Price: High-to-Low</option>
    458485                </select>";
    459     }
     486    }
     487   
     488    // free trial days_dropdown
     489    function _pagely_options_field_free_trial($args) { 
     490
     491        $args[0] == 0 ? $checked1 = "selected='selected'" : $checked1 = '';
     492        $args[0] == 5 ? $checked2 = "selected='selected'" : $checked2 = '';
     493        $args[0] == 10 ? $checked3 = "selected='selected'" : $checked3 = '';
     494        $args[0] == 15 ? $checked4 = "selected='selected'" : $checked4 = '';
     495        $args[0] == 30 ? $checked5 = "selected='selected'" : $checked5 = '';
     496
     497        echo "<select id='{$args[1]}' name='pp_api[{$args[1]}]'>
     498                    <option value='0' {$checked1}>0</option>
     499                    <option value='5' {$checked2}>5</option>
     500                    <option value='10' {$checked3}>10</option>
     501                    <option value='15' {$checked4}>15</option>
     502                    <option value='30' {$checked5}>30</option>
     503                </select>";
     504    } 
    460505   
    461506    // api key field
     
    486531                    <option value='0' {$checked1}>No</option>
    487532                    <option value='1' {$checked2}>Yes</option>
    488                 </select> <span class='description'>Will show a maintence message on cart pages.</span>";
     533                </select> <span class='description'>Will show a maintenance message on cart pages.</span>";
    489534    }
    490535   
     
    508553                                    <th scope='col' id='price' class='manage-column column-price'>Price</th>
    509554                                    <th scope='col' id='featured' class='manage-column column-featured'>Featured</th>
     555                                    <th scope='col' id='hidden' class='manage-column column-hidden'>*Hidden</th>
    510556                                </tr>
    511557                            </thead>";
    512558                           
    513559            foreach ($all_plans->objects as $p) {
    514                 if ($p->active == "1" && $p->visible == "1") {
     560                if ($p->active == "1") {
    515561                    $checked = '';
    516562                    $checkradio = '';
     
    518564                        if ( in_array($p->id,$args[0]) ) { $checked = "checked='checked'";}
    519565                    }
     566                   
     567                    $visible = $p->visible == 0 ? '<span style="color:#ccc">Yes</span>' : '<span style="color:green;">No</span>';
     568                   
    520569                    if ( isset($args[0]['plan_default']) && $args[0]['plan_default'] == $p->id) {$checkradio = "checked='checked'";}       
    521570                    echo "<tr>
     
    526575                                <td>".$this->_cash($p->price)."</td>
    527576                                <td><input type='radio' name='pp_api[{$args[1]}][plan_default]' value='{$p->id}' {$checkradio}/></td>
     577                                <td>{$visible}</td>
    528578                            </tr>";
    529579                }
    530580            }
    531581           
    532             echo "</table><span class='description'>These are all the hosting plans that are active in our system for your account. You may choose 3 at any one time to list for sale via this plugin. If you wish to modify or create plans, visit the <a href='https://photon.pagely.com'>API Portal</a>.</span>";
     582            echo "</table><span class='description'>These are all the hosting plans that are active in our system for your account. You may choose 3 at any one time to list for sale via this plugin. If you wish to modify or create plans, visit the <a href='https://photon.pagely.com'>API Portal</a>.</span> <strong>*Hidden</strong> plans may be purchased by the customer here, but are hidden from within the dashboard. Use case is for plans you only want new customers to see.";
    533583        } else {
    534584       
     
    750800                $str .= "<tr class='total'>
    751801                            <td class='desc'>Total in USD</td>
    752                             <td class='price'>".$this->_cash(cart_total())."</strong>/mo</td>
     802                            <td class='price'>".$this->_cash($this->_cart_total())."</strong>/mo</td>
    753803                        </tr>
    754804                    </table>"; 
     
    9721022        header( "Content-Type: application/json" );
    9731023
    974         $nonce = $_POST['ppjaxnounce'];
    9751024        $field = $_POST['field'];
    9761025        // check to see if the submitted nonce matches with the generated nonce we created earlier
    977         if ( ! wp_verify_nonce( $nonce, 'chickendinner' ) ) {
    978             echo "nounce fail";
     1026       
     1027        // check nounce on submission
     1028        $form['pagely_order_acc_nounce'] = $_POST['ppjaxnounce'];
     1029        if ( ! wp_verify_nonce( $form['pagely_order_acc_nounce'], 'pagely_account_submit' ) ) {
     1030            $msg = "Nounce Check failed. Possible automated submission. die()";
     1031           
     1032            $result = array();
     1033            $result = (object)$result;
     1034            $result->result = 3;
     1035            $result->message = $msg;
     1036            echo json_encode($result);
    9791037            die();
    980         } 
     1038        }
    9811039       
    9821040        switch($field) {
     
    10121070            $form[$k] = trim($v);
    10131071        }
     1072       
     1073        $form['pagely_order_acc_nounce'] = $_POST['pagely_order_acc_nounce'];
     1074        // check nounce on submission
     1075        if ( ! wp_verify_nonce( $form['pagely_order_acc_nounce'], 'pagely_account_submit' ) ) {
     1076            $msg = "Nounce Check failed. Possible automated submission. die()";
     1077           
     1078            $result = array();
     1079            $result = (object)$result;
     1080            $result->result = 3;
     1081            $result->message = $msg;
     1082            echo json_encode($result);
     1083            die();
     1084        }
     1085
    10141086        $this->_set_pp_session( array('last_activity' =>  time() ) );
    10151087        $this->_set_pp_session( array('last_action' => 'accformsubmit') );
     
    10181090        $result = (object)$result;
    10191091        $result->result = 2;
    1020         $result->message = "";
     1092        $result->message = "Data saved in session.";
    10211093        // expects json back
    10221094        echo json_encode($result);
     
    10361108       
    10371109        // never trust user input, rebuild the post array before sending.
     1110        $form['first_name'] = isset($form['first_name']) ? $form['first_name'] : '';
     1111        $form['last_name'] = isset($form['last_name']) ? $form['last_name'] : '';
     1112
    10381113        $params['name']         =   $form['first_name'] .' '. $form['last_name'];
    1039         $params['username']     =   $form['email'];
    1040         $params['company_name'] =   $form['company_name'];
    1041         $params['email']            =   $form['email'];
    1042         $params['phone']            =   $form['mobile'];
    1043         $params['twitter']      =   $form['twitter'];
    1044         $params['affiliate_code']   = $form['affiliate_code']
    1045         $params['auth_q']           = $form['squestion'];   
    1046         $params['auth_q_answer']    = $form['sanswer'];
     1114        $params['username']     =   isset($form['email']) ? $form['email'] : '';
     1115        $params['company_name'] =   isset($form['company_name']) ? $form['company_name'] : '';
     1116        $params['email']            =   isset($form['email']) ? $form['email'] : '';
     1117        $params['phone']            =   isset($form['mobile']) ? $form['mobile'] : '';
     1118        $params['twitter']      =   isset($form['twitter']) ? $form['twitter'] : '';
     1119        $params['affiliate_code']   = isset($form['affiliate_code']) ? $form['affiliate_code'] : '';   
     1120        $params['auth_q']           = isset($form['squestion']) ? $form['squestion'] : ''
     1121        $params['auth_q_answer']    = isset($form['sanswer']) ? $form['sanswer'] : ''
    10471122       
    10481123       
     
    10641139        if ($result->result == 2) {
    10651140            // successfully created an account
     1141           
    10661142            // store some values in the session
     1143            $form['promo_code']     = isset($form['promo_code']) ? $form['promo_code'] : '';
     1144            $form['domain_type'] = isset($form['domain_type']) ? $form['domain_type'] : 0;
     1145            $form['domain']     = isset($form['domain']) ?  $form['domain'] : '';
     1146           
    10671147            $this->_set_pp_session( array('account_id' => $result->id) );
    10681148            $this->_set_pp_session( array('domain' => strtolower($form['domain'])) );
     
    11261206    */ 
    11271207    function _pagely_jax_gopaypal_callback() { 
     1208        header( "Content-Type: application/json" );
     1209       
     1210        $params = array();
     1211        $this->_set_pp_session( array('last_activity' =>  time() ) );
     1212        $this->_set_pp_session( array('last_action' => 'paypal') );
     1213       
     1214        $form['pagely_order_pay_nounce'] = $_POST['ppjaxnounce'];
     1215       
     1216        // check nounce on submission
     1217        if ( ! wp_verify_nonce( $form['pagely_order_pay_nounce'], 'pagely_pay_submit' ) ) {
     1218            $msg = "Paypal Nounce Check failed. Possible automated submission. die()";
     1219           
     1220            $result = array();
     1221            $result = (object)$result;
     1222            $result->result = 3;
     1223            $result->message = $msg;
     1224            echo json_encode($result);
     1225            die();
     1226        }
    11281227       
    11291228        // first we need to send the account data
     
    11381237            }
    11391238        }
    1140        
    1141         $params = array();
    1142         $this->_set_pp_session( array('last_activity' =>  time() ) );
    1143         $this->_set_pp_session( array('last_action' => 'paypal') );
    1144         header( "Content-Type: application/json" );
    1145        
    1146         $nonce = $_POST['ppjaxnounce'];
    1147         // check to see if the submitted nonce matches with the generated nonce we created earlier
    1148         if ( ! wp_verify_nonce( $nonce, 'chickendinner' ) ) {
    1149         //  echo "nounce fail";
    1150         //  die();
    1151         }
    11521239       
    11531240       
     
    11891276    function _pagely_jax_payformsubmit_callback() {
    11901277   
     1278        header( "Content-Type: application/json" );
     1279       
     1280        $form = $_POST['pagely_order'];
     1281        foreach ($form as $k => $v) {
     1282            $form[$k] = strip_tags(trim($v));
     1283        }
     1284       
     1285
     1286        $form['pagely_order_pay_nounce'] = $_POST['pagely_order_pay_nounce'];
     1287        // check nounce on submission
     1288       
     1289        if ( ! wp_verify_nonce( $form['pagely_order_pay_nounce'], 'pagely_pay_submit' ) ) {
     1290            $msg = "Nounce Check failed. Possible automated submission. die()";
     1291           
     1292            $result = array();
     1293            $result = (object)$result;
     1294            $result->result = 3;
     1295            $result->message = $msg;
     1296            echo json_encode($result);
     1297            die();
     1298        }
     1299       
    11911300        // first we need to send the account data
    11921301        $act_id = $this->_get_pp_session('account_id');
     1302       
    11931303        if ( !$act_id ) {
    11941304            $account_result = $this->_send_account_data();
     
    12031313        $this->_set_pp_session( array('last_activity' =>  time() ) );
    12041314        $this->_set_pp_session( array('last_action' => 'payformsubmit') );
    1205         header( "Content-Type: application/json" );
    1206 
    1207         $nonce = $_POST['ppjaxnounce'];
    1208         // check to see if the submitted nonce matches with the generated nonce we created earlier
    1209         if ( ! wp_verify_nonce( $nonce, 'chickendinner' ) ) {
    1210         //  echo "nounce fail";
    1211         //  die();
    1212         }
    1213        
    1214         $form = $_POST['pagely_order'];
    1215         foreach ($form as $k => $v) {
    1216             $form[$k] = strip_tags(trim($v));
    1217         }
    1218 
     1315       
     1316       
     1317       
     1318        $form['billing_name'] = isset($form['billing_name']) ? $form['billing_name'] : '';
    12191319        $name = explode(' ',$form['billing_name']);
    12201320        // never trust user input, rebuild the post array before sending.
    12211321        $params['account_id']           = $this->_get_pp_session('account_id');
    1222         $params['type']                 = $form['type'];
     1322        $params['type']                 = isset($form['type']) ? $form['type'] : '';
    12231323        $params['name']                 = '';
    1224         $params['cc_number']            = $form['cc_number'];   
    1225         $params['cc_exp_month']         = $form['cc_exp_month'];
    1226         $params['cc_exp_year']          = $form['cc_exp_year'];
    1227         $params['cc_ccv']                   = $form['cc_ccv'];
    1228         $params['cc_first_name']        = $name[0];
    1229         $params['cc_last_name']         = $name[1];
    1230         $params['cc_address']           = $form['cc_address'];
    1231         $params['cc_country']           = $form['cc_country']
    1232         $params['cc_city']              = $form['cc_city'];
    1233         $params['cc_state']             = $form['cc_state'];   
    1234         $params['cc_zip']                   = $form['cc_zip']
     1324        $params['cc_number']            = isset($form['cc_number']) ? $form['cc_number'] : ''
     1325        $params['cc_exp_month']         = isset($form['cc_exp_month']) ? $form['cc_exp_month'] : '';
     1326        $params['cc_exp_year']          = isset($form['cc_exp_year']) ? $form['cc_exp_year'] : '';
     1327        $params['cc_ccv']                   = isset($form['cc_ccv']) ? $form['cc_ccv'] : '';
     1328        $params['cc_first_name']        = isset($name[0]) ? $name[0] : ''
     1329        $params['cc_last_name']         = isset($name[1]) ? $name[1] : ''
     1330        $params['cc_address']           = isset($form['cc_address']) ? $form['cc_address'] : '';
     1331        $params['cc_country']           = isset($form['cc_country']) ? $form['cc_country'] : '';   
     1332        $params['cc_city']              = isset($form['cc_city']) ? $form['cc_city'] : ''
     1333        $params['cc_state']             = isset($form['cc_state']) ? $form['cc_state'] : '';   
     1334        $params['cc_zip']                   = isset($form['cc_zip']) ? $form['cc_zip'] : '';   
    12351335        $params['promocode']                = $this->_get_pp_session('promo_code');
    1236         $params['client_ip']                = $_SERVER['REMOTE_ADDR'];
     1336        $params['client_ip']                = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    12371337        //print_r($params);
    12381338        $uri = '/account_profiles/single';
     
    12581358            if ($this->_get_pp_session('paid') == 1 && !$this->_get_pp_session('domain_queued')) {
    12591359                $domain_push = $this->_put_domain($params);
    1260                
     1360                $domain_push = json_decode($domain_push);
    12611361                if($domain_push->result != 2) {
    12621362                    // there was an error pushing the domain to the install queue
    12631363                    //contact support
    1264                     $this->_support_email($to ='[email protected]',$from,$subj= "failed install",$msg = $domain_push->result);
     1364                    $this->_support_email($to ='[email protected]',$to,$subj= "failed install",$msg = $domain_push->result);
    12651365                }
    12661366            }
     
    12971397        $params['site_email']           = $this->_get_pp_session('email');
    12981398        $params['promocode']                = $this->_get_pp_session('promo_code');
    1299         $params['plan_id']              = $this->_get_pp_session('plan_id');   
     1399        $params['plan_id']              = $this->_get_pp_session('plan_id');
     1400        $params['run_trial']                = $this->_get_trial_length();
    13001401        $uri = '/domains/single/';
    13011402        $json = $this->_pagely_api_request($method = 'PUT',$uri, $params );
     
    14261527        header( "Content-Type: application/json" );
    14271528
    1428         $nonce = $_POST['ppjaxnounce'];
    14291529        //array of all pagely_order inputs
    1430         $form = $_POST['pagely_order'];
     1530        $form = $_POST['pagely_order']['product_upgrades'];
    14311531        foreach ($form as $k => $v) {
    14321532            if (is_array($v)) {
     
    14391539        }
    14401540        // array of products to be added to cart
    1441         $items = $_POST['pagely_order']['product_upgrades'];
    1442         // check to see if the submitted nonce matches with the generated nonce we created earlier
    1443         if ( ! wp_verify_nonce( $nonce, 'chickendinner' ) ) {
    1444             //  echo "nounce fail";
    1445             //  die();
    1446         }
     1541        $items = $form;
     1542       
     1543       
     1544        // check nounce on submission
     1545        $form['pagely_order_cart_nounce'] = $_POST['pagely_order_cart_nounce'];
     1546        if ( ! wp_verify_nonce( $form['pagely_order_cart_nounce'], 'pagely_cart_submit' ) ) {
     1547            $msg = "Nounce Check failed. Possible automated submission. die()";
     1548           
     1549            $result = array();
     1550            $result = (object)$result;
     1551            $result->result = 3;
     1552            $result->message = $msg;
     1553            echo json_encode($result);
     1554            die();
     1555        }
     1556       
    14471557       
    14481558       
     
    15821692            $params['hash']     = sha1($time.$this->pagely_api_sec); // not used yet
    15831693            // pass an object ID as needed
    1584             $params['id']           = $params['id']; // should be object id, like domain_id = 1099; can be empty on PUT
     1694            $params['id']           = isset($params['id']) ? $params['id'] : ''; // should be object id, like domain_id = 1099; can be empty on PUT
    15851695            break;
    15861696        }
  • pagely-reseller-management/trunk/readme.txt

    r634731 r702419  
    33Tags: admin, administration, plugin, website reseller, hosting, Wordpress, CMS, page.ly,pagely Wordpress Hosting
    44Requires at least: 3.4
    5 Tested up to: 3.4.1
     5Tested up to: 3.5.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    2020Read [the documentation here](https://docs-api.pagely.com/reseller-plugin/).
    2121== Changelog ==
     22= 3.1.2 =
     23Proper use of nounces, some code cleanup.
    2224= 3.1.1 =
    2325A bit of code cleanup.
  • pagely-reseller-management/trunk/views/cart.php

    r591718 r702419  
    11        <!-- Cart -->
    2                         <div class="cartwrapper <?php if ($this->_get_pp_session('domain_queued')) { ?>minicart<? } ?> well">
    3                             <table id="<?php if ($this->_get_pp_session('domain_queued')) {?>powerupcart<?php } else {?>totals<? } ?>" class="table table-bordered table-striped">
     2                        <div class="cartwrapper <?php if ($this->_get_pp_session('domain_queued')) { ?>minicart<?php } ?> well">
     3                            <table id="<?php if ($this->_get_pp_session('domain_queued')) {?>powerupcart<?php } else {?>totals<?php } ?>" class="table table-bordered table-striped">
    44                                <thead>
    55                                    <tr>
     
    1919                                        <?php if ($this->_get_pp_session('domain_queued')) { ?>
    2020                                        <small><a href="" class="removeitem btn btn-mini btn-danger" rel="<?=$k?>">Remove</a></small>
    21                                         <? } ?>
     21                                        <?php } ?>
    2222                                    </td>
    2323                                    <td class="<?=$item['id'];?> price span1">
    24                                         <? if($item['price'] > 0) { ?>
    25                                             <?php echo $this->_cash($item['price']);?> <? if ($item['recurring']) { echo '/<em class="cycle">mo</em>'; } ?>
    26                                             <? } else {?>-<? }?>
     24                                        <?php if($item['price'] > 0) { ?>
     25                                            <?php echo $this->_cash($item['price']);?> <?php if ($item['recurring']) { echo '/<em class="cycle">mo</em>'; } ?>
     26                                            <?php } else {?>-<?php }?>
    2727                                        </td>
    2828                                </tr>
     
    4040                            </table>
    4141   
    42                         <? } else { ?> <!-- /Cart Items -->
     42                        <?php } else { ?> <!-- /Cart Items -->
    4343                                <tr class="empty total_row">
    4444                                    <td colspan="2"><em>Empty</em></td>
    4545                                </tr>
    4646                            </table>
    47                         <? } ?>
     47                        <?php } ?>
    4848                        <?php if ($this->_get_pp_session('domain_queued') && $this->_cart_total_items() > 0) { ?>
    4949                            <div class="form-actions purchase_cart">
    5050                            <button class="btn btn-primary btn-large" id="pagely_purchase_cart" <?php if($this->_cart_total_items() == 0) {?>disabled<?php }?>>Purchase &raquo;</button>
    5151                            </div>     
    52                         <? } ?>
     52                        <?php } ?>
    5353
    5454                        <input type="hidden" name="action" value="pagely_jax_purchase_cart_callback"/>
  • pagely-reseller-management/trunk/views/complete.php

    r591718 r702419  
    33    <div class="hero-unit">
    44        <h2>Order Complete. Thank You.</h2>
    5         <p>Please allow a few moments for your new site to provision and then check your email for your welcome information. <strong>Thanks again and Welcome Aboard!</strong></p>
     5        <p>Please allow a few moments for your new site to provision and then <strong>check your email</strong> for your welcome information. <strong>Thanks again and Welcome Aboard!</strong></p>
     6       
    67        <?php if( isset($_GET['product_fails']) ) { ?>
    78            <p class="error">Unfortunately there was an error when purchasing (<?php echo $_GET['product_fails']?>) additional upgrade items. You may try again when you login to your new site.</p>
    8         <? } ?>
     9        <?php } ?>
    910        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="btn">Return to Home</a>
    1011    </div>
  • pagely-reseller-management/trunk/views/order-form.php

    r613039 r702419  
    1212
    1313<div id="pp">
    14 <? if($this->_is_sandbox()) {?><p class="alert">SANDBOX MODE</p><? } ?>
     14<?php if($this->_is_sandbox()) {?><p class="alert">SANDBOX MODE</p><?php } ?>
    1515<?php $session = $this->_get_pp_session(); // grab the session
    1616
    1717        if ( $this->_signups_on() ) {
    18             if ($session['order_complete']) {           
     18            if ( isset($session['order_complete']) ) {         
    1919                echo $this->_get_view( PP_PLUGIN_ASSETS_PATH . 'views/complete.php');               
    2020                $this->_clear_pp_session();
    2121
    22             } else if (!isset($session['account_id']) || $session['paid'] == 0 ) { // determine which view snippet to load
     22            } else if (!isset($session['account_id']) || (!isset($session['paid']) || $session['paid'] == 0) ) { // determine which view snippet to load
    2323             
    2424               echo $this->_get_view( PP_PLUGIN_ASSETS_PATH . 'views/order_step1.php');
    2525           
    26             } else if ($session['domain_queued'] == 1 && $session['paid'] == 1 && !$session['order_complete']) {
     26            } else if ($session['domain_queued'] == 1 && $session['paid'] == 1 && !isset($session['order_complete']) ) {
    2727           
    2828                echo $this->_get_view( PP_PLUGIN_ASSETS_PATH . 'views/order_step3.php');
     
    4747<button id="session">show session</button>
    4848</p>
    49 <? } ?>
     49<?php } ?>
    5050<div id="pp_dialog"></div>
  • pagely-reseller-management/trunk/views/order_step1.php

    r613039 r702419  
    22<!--<div id="progress"><span class="meter" style="width:33%"><span class="progress_title">Sign-Up Progress 1/3</span>
    33</span></div>-->
    4 
    5 
    64<?php
     5
    76$preselected_plan = $this->_get_pp_session('preselected_plan');                         
    87$plans = $this->_get_plans();
    98
    109$form = $this->_get_pp_session('acc_form_post');
     10$posted_from_dff_page = false;
     11// we dont want to use a nounce here since the referrer may be cached.
     12
     13
     14$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     15$referer_parse = parse_url($referer);
     16$this_site = str_replace(array('http://','https://'),'',site_url());
     17
     18if (!empty($_POST) && $referer_parse['host'] == $this_site && isset($_POST['auto_submit']) ) {
     19    $posted_from_dff_page = true;
     20    $form = $_POST['pagely_order'];
     21   
     22} else {
     23    // blow out and incoming post data from other sites
     24    $_POST = array();
     25}
     26
     27
     28
    1129
    1230if (is_array($plans)) { ?>
    1331
     32<div class="form_msg"></div>
    1433<section id="pagely_account_form" class="">
    1534    <form method="post" action="" id="pagely_form_acc" class="pagely_form form-horizontal" autocomplete="off">
     
    1837        <fieldset id="choose_plan">
    1938            <legend>New Account Setup</legend>         
    20             <?php if ( is_array($form) ) { ?>
     39            <?php if ( is_array($form) && !$posted_from_dff_page ) { ?>
    2140                <div class="alert alert-info"><h4 class="alert-heading">Your account is pending.</h4>
    2241                <p>Please verify the information below is correct and proceed with payment to complete setup.</p>
    2342                </div>
    24             <?  }?>
    25             <div id="form_msg"></div>
     43            <?php  }?>
     44           
    2645
    2746
     
    142161              <?php if (isset($form['sanswer']) ) { ?>
    143162                <input id="" name="pagely_order[sanswer]" type="password" class="span3 required" value="<?php echo $form['sanswer']; ?>">
    144               <? } else { ?>
     163              <?php } else { ?>
    145164
    146165                    <input id="" name="pagely_order[sanswer]" type="text" class="span3 required" value="">
    147               <? } ?>
     166              <?php } ?>
    148167              </div>
    149168            </div>
     
    161180           </div><!--well-->
    162181       
     182           
     183
    163184   
    164185            <div class="form-actions create_account">
    165                 <input type="submit" class="btn btn-primary btn-large form-submit" value="<?php _e('Continue') ?>" tabindex=""/>
     186                <input id="acc_submit" type="submit" class="btn btn-primary btn-large form-submit" value="<?php _e('Continue') ?>" tabindex=""/>
    166187                <span class="hide waiting"><img src="<?php echo PP_PLUGIN_ASSETS; ?>/assets/gfx/ajax-loader.gif" /> Processing...</span>
    167188            </div>
    168             <?php wp_nonce_field('chickendinner'); ?>
     189            <?php wp_nonce_field('pagely_account_submit','pagely_order_acc_nounce'); ?>
    169190            <input type="hidden" name="action" value="pagely_jax_accformsubmit_callback"/>
    170191            <input type="hidden" id="pagely_affiliate_code" name="pagely_order[affiliate_code]" value=""/>     
     
    192213                        <p><button id="pay_by_paypal" class="btn btn-large btn-success">PayPal</button></p>
    193214                        <p class="lead">Pay easily from your Paypal Account</p>
     215                        <?php wp_nonce_field('pagely_pay_submit','pagely_order_pay_nounce'); ?>
     216
    194217                    </div>
    195218                </div>
     
    324347                <p class="tos_notice pull-right"><em><small>By continuing you are agreeing to our <a id="tos" class="inline" href="#tos">Terms of Service</a> &amp; <a id="privacy" class="" href="">Privacy Policy</a></small></em></p>
    325348        </div>
    326         <?php wp_nonce_field('chickendinner'); ?>
     349        <?php wp_nonce_field('pagely_pay_submit','pagely_order_pay_nounce'); ?>
    327350        <input type="hidden" value="cc" name="pagely_order[type]"/>
    328351        <input type="hidden" name="action" value="pagely_jax_payformsubmit_callback"/>
     
    330353        </form>
    331354</section>
    332 <? } else { ?>
     355<?php } else { ?>
    333356<p class="alert alert-warning">Problem with the API. Someone will be flogged momentarily.</p>
    334357<?php } ?>
     358
     359<?php
     360    if ($posted_from_dff_page) {
     361        ?>
     362        <script>
     363        jQuery(document).ready(function($) {
     364            jQuery.fn.validate_domain('#po_domain');
     365            jQuery.fn.validate_email('#po_email');
     366            //jQuery('#pagely_form_acc').valid();
     367            jQuery('#acc_submit').val('Verify and Continue');       
     368            });
     369        </script>
     370        <?php
     371        //$submit_it = false;
     372    }
     373?>
    335374<!-- /basic account page -->
  • pagely-reseller-management/trunk/views/order_step3.php

    r591718 r702419  
    77   
    88            <h2>Success! Your order is in queue for setup. Check your email for some welcome messages.</h2>
    9             <p>Thank you for your purchase. New sites typically take 2-5 minutes to provision. If you do not receive a welcome email shortly please <a href="<? echo $this->_supportsite();?>">contact support</a>. Thanks and Welcome aboard!</p>
     9            <p>Thank you for your purchase. New sites typically take 2-5 minutes to provision. If you do not receive a welcome email shortly please <a href="<?php echo $this->_supportsite();?>">contact support</a>. Thanks and Welcome aboard!</p>
    1010        <?php } else {?>
    1111            <h2>Your Order has been received.</h2>
     
    1919            <legend>Optional Hosting Upgrades</legend>
    2020            <p class="lead">PowerUp your website with these available upgrades. <a href="?complete=true" class="btn btn-mini">No Thanks, I'm done.</a></p>
     21            <?php if ($this->_get_trial_length() > 0) { ?>
     22                <p class="alert"><span class="label label-warning">Heads Up</span> PowerUps will be billed immediately and are not part of the <?php echo $this->_get_trial_length();?> day trial.</p>
     23            <?php } ?>
    2124           
    2225            <fieldset id="powerups">
     
    3033                                        <td class="span1"><input type="checkbox" id="u<?php echo $p->id?>" name="pagely_order[product_upgrades][]" value="<?php echo $p->id?>" /></td>
    3134                                        <td class="desc"><p><strong><label for="u<?php echo $p->id?>"><?php _e($p->name);?></label></strong><?php _e(stripslashes($p->desc));?></p></td>       
    32                                         <td class="price"><?php echo $this->_cash($p->price);?><?php if ( 1 == $p->recurring) {?>/<em class="cycle">mo</em><? } ?></td>
     35                                        <td class="price"><?php echo $this->_cash($p->price);?><?php if ( 1 == $p->recurring) {?>/<em class="cycle">mo</em><?php } ?></td>
    3336                                    </tr>
    3437                                <?php    } ?>
     
    3942                                </div>
    4043                                <!-- /products list -->
    41                                 <?php wp_nonce_field('chickendinner'); ?>
     44                                <?php wp_nonce_field('pagely_cart_submit','pagely_order_cart_nounce'); ?>
    4245                                <input type="hidden" name="action" value="pagely_jax_addtocart_callback"/>
    4346                            </form>
     
    4548                   
    4649                        <div id="cartholder" class="span4 offset1">                     
    47                         <? echo $this->_get_view( PP_PLUGIN_ASSETS_PATH . 'views/cart.php'); ?>
     50                        <?php echo $this->_get_view( PP_PLUGIN_ASSETS_PATH . 'views/cart.php'); ?>
    4851                        </div>
    4952                </div> 
Note: See TracChangeset for help on using the changeset viewer.