mirror of
				https://github.com/Mibew/mibew.git
				synced 2025-10-27 00:36:52 +03:00 
			
		
		
		
	Add captcha to pre-chat survey
This commit is contained in:
		
							parent
							
								
									845d250b88
								
							
						
					
					
						commit
						3ee7fca025
					
				| @ -65,6 +65,16 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { | ||||
| 			$info = getparam("info"); | ||||
| 			$email = getparam("email"); | ||||
| 			$referrer = urldecode(getparam("referrer")); | ||||
| 			if ($settings["surveyaskcaptcha"] == "1") { | ||||
| 				$captcha = getparam('captcha'); | ||||
| 				$original = isset($_SESSION["mibew_captcha"]) | ||||
| 					? $_SESSION["mibew_captcha"] | ||||
| 					: ""; | ||||
| 				$survey_captcha_failed = empty($original) | ||||
| 					|| empty($captcha) | ||||
| 					|| $captcha != $original; | ||||
| 				unset($_SESSION['mibew_captcha']); | ||||
| 			} | ||||
| 
 | ||||
| 			if($settings['usercanchangename'] == "1" && isset($_POST['name'])) { | ||||
| 				$newname = getparam("name"); | ||||
| @ -93,10 +103,18 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { | ||||
| 			exit; | ||||
| 		} | ||||
| 
 | ||||
| 		if($settings['enablepresurvey'] == '1' && !(isset($_POST['survey']) && $_POST['survey'] == 'on')) { | ||||
| 		$show_survey = $settings['enablepresurvey'] == '1' | ||||
| 			&& ( | ||||
| 			    !(isset($_POST['survey']) && $_POST['survey'] == 'on') | ||||
| 			    || ($settings["surveyaskcaptcha"] == "1" && !empty($survey_captcha_failed)) | ||||
| 			); | ||||
| 		if($show_survey) { | ||||
| 			$page = array(); | ||||
| 			setup_logo(); | ||||
| 			setup_survey($visitor['name'], $email, $groupid, $info, $referrer); | ||||
| 			if (!empty($survey_captcha_failed)) { | ||||
| 			    $errors[] = getlocal('errors.captcha'); | ||||
| 			} | ||||
| 			setup_survey($visitor['name'], $email, $groupid, $info, $referrer, can_show_captcha()); | ||||
| 			expand("styles", getchatstyle(), "survey.tpl"); | ||||
| 			exit; | ||||
| 		} | ||||
|  | ||||
| @ -308,7 +308,7 @@ function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info | ||||
| 	$page['referrer'] = urlencode(topage($referrer)); | ||||
| } | ||||
| 
 | ||||
| function setup_survey($name, $email, $groupid, $info, $referrer) | ||||
| function setup_survey($name, $email, $groupid, $info, $referrer, $canshowcaptcha) | ||||
| { | ||||
| 	global $settings, $page; | ||||
| 
 | ||||
| @ -317,6 +317,7 @@ function setup_survey($name, $email, $groupid, $info, $referrer) | ||||
| 	$page['formgroupid'] = $groupid; | ||||
| 	$page['forminfo'] = topage($info); | ||||
| 	$page['referrer'] = urlencode(topage($referrer)); | ||||
| 	$page['showcaptcha'] = ($settings["surveyaskcaptcha"] == "1" && $canshowcaptcha) ? "1" : ""; | ||||
| 
 | ||||
| 	if ($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") { | ||||
| 		$link = connect(); | ||||
|  | ||||
| @ -628,6 +628,7 @@ $settings = array( | ||||
| 	'surveyaskmail' => '0', | ||||
| 	'surveyaskgroup' => '1', | ||||
| 	'surveyaskmessage' => '0', | ||||
| 	'surveyaskcaptcha' => '0', | ||||
| 	'enablepopupnotification' => '0', | ||||
| 	'showonlineoperators' => '0', | ||||
| 	'enablecaptcha' => '0', | ||||
|  | ||||
| @ -491,6 +491,8 @@ settings.saved=Changes saved | ||||
| settings.sendmessagekey=Send messages with: | ||||
| settings.show_online_operators.description=Can slow down the update rate of the list | ||||
| settings.show_online_operators=Show online operators on "List of awaiting visitors" page | ||||
| settings.survey.askcaptcha.description=Protection against automated spam (captcha) | ||||
| settings.survey.askcaptcha=Force visitor to enter a verification code | ||||
| settings.survey.askgroup.description=Show/hide department selection field in the survey | ||||
| settings.survey.askgroup=Allows a visitor to choose department/group  | ||||
| settings.survey.askmail.description=Show/hide email field in the survey | ||||
|  | ||||
| @ -487,6 +487,8 @@ settings.saved= | ||||
| settings.sendmessagekey=Посылать сообщение по: | ||||
| settings.show_online_operators.description=Может замедлить обновление списка | ||||
| settings.show_online_operators=Показывать доступных операторов на странице ожидающих посетителей | ||||
| settings.survey.askcaptcha.description=Защита от автоматизированного спама (captcha) | ||||
| settings.survey.askcaptcha=Завершать опрос только после ввода специального кода с картинки | ||||
| settings.survey.askgroup.description=Показать/спрятать выбор группы в диалоге перед началом чата | ||||
| settings.survey.askgroup=Позволять посетителю выбирать группу операторов | ||||
| settings.survey.askmail.description=Показать/спрятать поле ввода адреса электронной почты | ||||
|  | ||||
| @ -29,7 +29,7 @@ $options = array( | ||||
| 	'enableban', 'usercanchangename', 'enablegroups', 'enablestatistics', 'enablejabber', | ||||
| 	'enablessl', 'forcessl', | ||||
| 	'enablepresurvey', 'surveyaskmail', 'surveyaskgroup', 'surveyaskmessage', | ||||
| 	'enablepopupnotification', 'showonlineoperators', | ||||
| 	'surveyaskcaptcha', 'enablepopupnotification', 'showonlineoperators', | ||||
| 	'enablecaptcha'); | ||||
| 
 | ||||
| loadsettings(); | ||||
|  | ||||
| @ -57,7 +57,7 @@ if ($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'l | ||||
| } | ||||
| if ($show == 'survey') { | ||||
| 	loadsettings(); | ||||
| 	setup_survey("Visitor", "", "", "", "http://google.com"); | ||||
| 	setup_survey("Visitor", "", "", "", "http://google.com", false); | ||||
| 	setup_logo(); | ||||
| 	expand("../styles", "$preview", "$show.tpl"); | ||||
| 	exit; | ||||
|  | ||||
| @ -139,6 +139,12 @@ ${if:showmessage} | ||||
| 				</td> | ||||
| 			</tr> | ||||
| ${endif:showmessage}			 | ||||
| ${if:showcaptcha} | ||||
| 			<tr> | ||||
| 				<td class="text"><img src="captcha.php"/></td> | ||||
| 				<td><input type="text" name="captcha" size="50" maxlength="15" value="" class="username"/></td> | ||||
| 			</tr> | ||||
| ${endif:showcaptcha} | ||||
| 			<tr> | ||||
| 				<td colspan="2" align="right"> | ||||
| 					<table cellspacing="0" cellpadding="0" border="0"> | ||||
|  | ||||
| @ -108,6 +108,15 @@ ${if:showmessage} | ||||
| 		<tr><td height="7" colspan="3"></td></tr> | ||||
| ${endif:showmessage}			 | ||||
| 
 | ||||
| ${if:showcaptcha} | ||||
| 		<tr> | ||||
| 		    <td class="text"><img src="captcha.php"/></td> | ||||
| 		    <td width="20"></td> | ||||
| 			<td><input type="text" name="captcha" size="50" maxlength="15" value="" class="field"/></td> | ||||
| 		</tr> | ||||
| 		<tr><td height="7" colspan="3"></td></tr> | ||||
| ${endif:showcaptcha} | ||||
| 
 | ||||
| 	</table></td><td bgcolor="#E8A400"><img src="${webimroot}/images/free.gif" width="1" height="1" border="0" alt="" /></td></tr><tr><td><img class="tplimage icrnlb" src="${webimroot}/images/free.gif" border="0" alt=""/></td><td style="background-image: url(${tplroot}/images/winbg.gif)" class="bgcy"><img src="${webimroot}/images/free.gif" width="1" height="1" border="0" alt="" /></td><td><img class="tplimage icrnrb" src="${webimroot}/images/free.gif" border="0" alt=""/></td></tr></table> | ||||
| 
 | ||||
| </td> | ||||
|  | ||||
| @ -39,7 +39,9 @@ | ||||
| 		</div></div></div></div></div></div></div></div> | ||||
| 	</div> | ||||
| 	<div id="content-wrapper"> | ||||
| 	 | ||||
| 		${if:errors} | ||||
| 			${errors} | ||||
| 		${endif:errors} | ||||
| 		<form name="surveyForm" method="post" action="${webimroot}/client.php" /> | ||||
| 		<input type="hidden" name="style" value="${styleid}"/> | ||||
| 		<input type="hidden" name="info" value="${form:info}"/> | ||||
| @ -72,6 +74,12 @@ | ||||
| 				<td valign="top"><textarea name="message" tabindex="0" cols="45" rows="2">${form:message}</textarea></td> | ||||
| 			</tr> | ||||
| 		${endif:showmessage}			 | ||||
|                 ${if:showcaptcha} | ||||
|                         <tr> | ||||
|                                 <td><img src="captcha.php"/></td> | ||||
|                                 <td><input type="text" name="captcha" size="50" maxlength="15" value="" class="username"/></td> | ||||
|                         </tr> | ||||
|                 ${endif:showcaptcha} | ||||
| 		</table>		 | ||||
| 		<a href="javascript:document.surveyForm.submit();" class="but" id="sndmessagelnk">${msg:presurvey.submit}</a> | ||||
| 		<div class="clear"> </div> | ||||
|  | ||||
| @ -63,6 +63,12 @@ | ||||
| 								<td><textarea name="message" class="field" tabindex="0" cols="45" rows="2" style="overflow:auto">${form:message}</textarea></td> | ||||
| 							</tr> | ||||
| 						${endif:showmessage} | ||||
|                                                 ${if:showcaptcha} | ||||
|                                                     <tr> | ||||
|                                                             <td class="text"><img src="captcha.php"/></td> | ||||
|                                                             <td><input type="text" name="captcha" size="50" maxlength="15" value="" class="field"/></td> | ||||
|                                                     </tr> | ||||
|                                                 ${endif:showcaptcha} | ||||
| 					</table> | ||||
| 				</td> | ||||
| 			</tr> | ||||
|  | ||||
| @ -173,6 +173,15 @@ require_once('inc_errors.php'); | ||||
| 				<div class="fdescr"> — <?php echo getlocal('settings.survey.askmessage.description') ?></div>
 | ||||
| 				<br clear="all"/> | ||||
| 			</div> | ||||
| 
 | ||||
| 			<div class="subfield undersurvey"> | ||||
| 				<div class="flabel"><?php echo getlocal('settings.survey.askcaptcha') ?></div>
 | ||||
| 				<div class="fvalue"> | ||||
| 					<input type="checkbox" name="surveyaskcaptcha" value="on"<?php echo form_value_cb('surveyaskcaptcha') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
 | ||||
| 				</div> | ||||
| 				<div class="fdescr"> — <?php echo getlocal('settings.survey.askcaptcha.description') ?></div>
 | ||||
| 				<br clear="all"/> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="field"> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user