Q & A on upload page

Discuss of AVS script, custom modifications or anything related to this video script

Q & A on upload page

Postby dargre » Sat Feb 12, 2011 5:06 am

Upload page doesn't allow to use captcha as captcha is based on session value, while upload page is submitted via javascript ajax.

Here's funny substition of captcha asking for last letter of random word.
It can be helpful against some abusing autosubmitters...

Edit file "upload.php". Above the line:
Code: Select all
$smarty->assign('self_title', $seo['upload_title']);

add array of different words, any number, 10-20 about.
Take care about last char of words to have it as different as possible.
Code: Select all
$words = array( 'word1', 'word2', 'word3', 'word4', 'word5', 'word6');
$smarty->assign('verification_word', $words[rand(0, count($words)-1)]);



Edit file "templates/frontend/your_template/upload_video.tpl"
ABove the line:
Code: Select all
<div id="upload_loader" style="display: none;">

add this code:
Code: Select all
      <div class="separator">
                        <label for="signup_verification">{t c='global.verification'}:</label>
                        What is last char of the the word: <b><span id="verification_word" style="font-wieght:bold;color:#FF0000;">{$verification_word}</span> ? <input name="verification_code" type="text" value="" size="3" maxlength="1" style="text-align:center;" id="verification_code" />
         <span id="verify_error" class="error" style="display: none;">Invalid code.</span>
                </div>


Edit file "templates/frontend/your_template/js/jquery.upload-0.1.js"
Find the line:
Code: Select all
$("#upload_video_submit").click(function(event){

and then inside this function, find below this line:
Code: Select all
if ( !error ) {

Above it add this code:
Code: Select all
      var verify         = $("input[id='verification_code']").val();
      var verify_word      = $("span[id='verification_word']").html();
      var verify_error    = $("span[id='verify_error']");

      if( verify != verify_word.substring(verify_word.length-1)) {
            error   = true;
            $(verify_error).fadeIn();
      } else {
            if ( $(verify_error).is(':visible') ) {
                $(verify_error).hide();
            }   
        }


This is very basic Q & A, but working and you can try.

Good luck.
Thank you,
Nuevolab Team
dargre
 
Posts: 332
Joined: Mon Sep 07, 2009 3:47 am

Return to AVS

Who is online

Users browsing this forum: No registered users and 0 guests