Add a refresh button for Image Verification

notexa 02 Sep, 2007
Below I'll explain how you can add a refresh button next to the image verification image. Usefull for people when they can't read the verification tag.

Look for:
    if ( trim($paramsvalues->imagever) == 'Yes' ) {
        $imver = '<input name="chrono_verification" type="text" id="chrono_verification" value="">
              <img src="'.$mosConfig_live_site
            .'/administrator/components/com_chronocontact/chrono_verification.php">';
    }


Replace this with:
    if ( trim($paramsvalues->imagever) == 'Yes' ) {
        $imver = '<script type="text/javascript">
        function RefreshImageVer(imgverform) {
                var randnum = Math.random();
                var newverimage = \''.$mosConfig_live_site.'/administrator/components/com_chronocontact/chrono_verification.php?\'+randnum;
                imgverform.imgver.src=newverimage;
        }
</script>
        <input name="chrono_verification" type="text" id="chrono_verification" value="">
              <img src="'.$mosConfig_live_site
            .'/administrator/components/com_chronocontact/chrono_verification.php" name="imgver" id="imgver">
              <input type="button" value="refresh" onclick="RefreshImageVer(this.form);" />';
    }


And presto, one refresh button ready to go.

Tested in IE7 and Fx2<br><br>Post edited by: notexa, at: 2007/09/02 02:35
GreyHead 02 Sep, 2007
Hi notexta,

Thanks, added to the Hints & Tips FAQs here.

Bob
adrianmak 03 Sep, 2007
I tried the code replacement but no refresh button shown even though I refresh browser many times.<br><br>Post edited by: adrianmak, at: 2007/09/03 02:32
notexa 03 Sep, 2007
Could you attach the php file in which you made the changes ?
Then I'll have a look at it.

ps. The normal image verification is working ?
bhyland 20 Nov, 2007
Hi Notexa,

I'm trying to get this to work under rel. 2.3.6, having problems so I thought I'd reach out to see if you still had this working or does it need some changes in the new release? I have a another thread on my issue and Bob has been kind enough to have been helping with suggestions but I thoguht I'd check in to see if you still have this working?

Thanks

Brian
Max_admin 22 Nov, 2007
Hi Brian,

What types of problems you have ? at the latest version we changed the verification script path so could you remove /administrator from the paths ?

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bhyland 22 Nov, 2007
Hi Max,

To avoid creating a another thread on my questions, I had originally been working with Bob over on this thread


I know both you and Bob are bust helping us all but if you get a chance to jump on over to this thread I'm hoping you might be able to help...

Thanks

Brian<br><br>Post edited by: GreyHead, at: 2007/11/23 00:06
GreyHead 23 Nov, 2007
Hi Brian,

Sorry, I'm away on the road for the weekend and don't have Joomla on this laptop. Hopefully Max will chip in.

Bob
Max_admin 23 Nov, 2007
Hi Brian,

Iam working on a new solution for this!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 23 Nov, 2007
This is the code with few modifications and should work very fine with V2.3.6 :


if ( trim($paramsvalues->imagever) == 'Yes' ) {
        $imver = ' <script type="text/javascript">			
        function loadchronocap(){
			document.getElementById(\'imgbutton\').value = \'Loading\';
			document.getElementById(\'imgbutton\').disabled = true;
			img = document.getElementById(\'imgver\'); 
			//Change the image
			img.src = \''.$mosConfig_live_site.'/components/com_chronocontact/chrono_verification.php?imtype='.$paramsvalues->imtype.'&p=\' + Math.random();
			document.getElementById(\'imgbutton\').value = \'Refresh image\';
			document.getElementById(\'imgbutton\').disabled = false;
		}					
		</script>
		<input name="chrono_verification" type="text" id="chrono_verification" value="">
              
			<div id="imgajax"><img name="imgver" id="imgver" src="'.$mosConfig_live_site
            .'/components/com_chronocontact/chrono_verification.php?imtype='.$paramsvalues->imtype.'"></div>
			<input type="button" id="imgbutton" value="Refresh image" onclick="loadchronocap()">
		';
    }


Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 24 Nov, 2007
Hi Max,

Nice solution🙂

Bob
Max_admin 24 Nov, 2007
Thanks Bob!!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bhyland 26 Nov, 2007
Hi Max,

MANY THANKS!!! This worked a charm🙂 thanks for the great support.

Brian
joayala 09 Jan, 2008
Hi all,

I would like to add this function to my forms, but I can't find "ChronoForm.php" file, I guess that is "ChronoContact.php" file but I'm not sure.

Can you update the FAQ question about this giving us the right path to get the file that we must change?

Thanks in advance!
Jos
GreyHead 09 Jan, 2008
Hi Jos,

You are correct, I've fixed the fax. sorry for the typo.

Bob
joayala 10 Jan, 2008
Hi Bob,
I tried to apply this adjustment but nothing happens, maybe because my "ChronoContact.php" is little different that in FAQ... this is my code:


if ( trim($paramsvalues->imagever) == 'Yes' ) {
$imver = '<input name="chrono_verification" type="text" id="chrono_verification" value="">
  <img src="'.$mosConfig_live_site
.'/components/com_chronocontact/chrono_verification.php?imtype='.$paramsvalues->imtype.'">';
}


Any clue?

Thanks in advance
Jos
GreyHead 10 Jan, 2008
Hi Jos,

It's late here now and Max has tweaked the imageverification code a bit in 2.3.7. I'll have a look in the morning when my brain is awake.

Bob
joayala 10 Jan, 2008
Thanks Bob... :laugh:
GreyHead 10 Jan, 2008
Hi Jos,

Fixed a couple of problems in the FAQ code that were out of date. Please try this - find this code in chronocontact.php (around line 70 in 2.3.7)
    if ( trim($paramsvalues->imagever) == 'Yes' ) {
        $imver = '<input name="chrono_verification" type="text" id="chrono_verification" value="">
              <img src="' . $mosConfig_live_site . '/components/com_chronocontact/chrono_verification.php?imtype=' . $paramsvalues->imtype . '">';
    }
and replace it with this:
    if ( trim($paramsvalues->imagever) == 'Yes' ) {
    	$imver_url = $mosConfig_live_site
            .'/components/com_chronocontact/chrono_verification.php?imtype='
            .$paramsvalues->imtype;
        $imver = '<script type="text/javascript">
            function RefreshImageVer(imgverform) {
                var randnum = Math.random();
                var newverimage = \''.$imver_url.'\'+randnum;
                imgverform.imgver.src=newverimage;
            }
            </script>
            <input name="chrono_verification" type="text" id="chrono_verification" value="">
                <img src="'.$imver_url.'" name="imgver" id="imgver">
            <input type="button" value="refresh" onclick="RefreshImageVer(this.form);" />';
    }
There is still a little bug with this. When you refresh the image changes to the 'Without fonts' version. I think this is because $_GET['imtype'] isn't preserved with the JavaScript refresh. Maybe this can be fixed later but it isn't a big issue.

Bob
jvince 10 Jan, 2008
Will the image refresh become a standard feature?
Thanks,

- Vince
GreyHead 10 Jan, 2008
Hi Vince,

Not sure what Max has planned. Personally I'd like to see it there (and an easier way of managing the layout of the imageverification block too).

Bob
joayala 11 Jan, 2008
Thank you very much for your help Bob, I will try.

Regards
Jos

BTW... now I'm using 2.3.7, I paid for a License but with the update I get again the "Chorno" link at the bottom, can you help me with that?<br><br>Post edited by: joayala, at: 2008/01/11 01:05
GreyHead 11 Jan, 2008
Hi Jos,

I've just sent you an email about the link.

Bob
This topic is locked and no more replies can be posted.