Serious back-end validation needed in next release
Here are my suggestion for an improvement.
VERSION: ClassiPress 3.0.5
AFFECTED CODE:
step-functions.php - line 695
step3.php
THE SITUATION:
I noticed ClassiPress rely only on jQuery.validation to validate input on Insert Ad forms. Thus, if there is a javascript error occured or javascript is disabled, one can submit the form up till the end of the ad submission process
even with errors. (such as submitting blank form)
Related thread: This thread here is an example of such problem. The javascript error affect validation.
ClassiPress did send email to Admin and the ad poster regarding the new (false) ad submission. All related operation when creating an ad listing is carried out; Although the returned post_id==0 (refer
step-functions.php - starting line 695 to 745)
MY SUGGESTIONS:
1. Stopping unnecessary execution of code if returned post_id==0
add exception on
step-functions.php - after line 695
Code:
if( $post_id == 0 ) return 0;
add exception on
step3.php - after line 43
Code:
if( $post_id != 0 ):
...
endif;
// just before removing the temp session option from the database : line 90
Note: You may add custom error message saying that the submission didn't happen. Because post_id==0.
2. Prevent user from submitting the form (if the form is not validated)
Actually
step2.php needs a lot of improvement on validation. It seems that even if the fields value are null, the process seems to validate and allow submission to proceed. This should not happen. (I leave this to ClassiPress development team for next release)
For an express alternative solution, you can use the following:
Replace the submit button like so:
step1.php - line 98:
Code:
<script>document.write('<input type="submit" name="step1" id="step1" class="btn_orange" value="<?php _e('Continue ››','appthemes'); ?>" />');</script>
<noscript><ul class="errors"><li><b><?php _e('This form requires javascript support to work. Please enable javascript on your browser.','appthemes');?></b></li></ul></noscript>
Hope this info helps.
Nik Ahmad
Beezby.com