File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -795,6 +795,16 @@ private function careersPage()
795795 die ();
796796 }
797797
798+ if ($ this ->careerPortalTemplateRequiresCaptcha ($ template ['Content - Apply for Position ' ]))
799+ {
800+ $ captchaValue = isset ($ _POST ['captcha ' ]) ? $ _POST ['captcha ' ] : '' ;
801+ if (!$ this ->validateCareerPortalCaptcha ($ captchaValue ))
802+ {
803+ CommonErrors::fatal (COMMONERROR_MISSINGFIELDS , $ this , 'Invalid CAPTCHA response. Please try again. ' );
804+ return ;
805+ }
806+ }
807+
798808 // Check if this is a returning candidate
799809 $ candidateID = isset ($ _POST ['candidateID ' ]) ? intval ($ _POST ['candidateID ' ]) : -1 ;
800810 if ($ candidateID == -1 ) $ candidateID = false ;
@@ -1145,6 +1155,31 @@ private function outputCareerPortalCaptcha()
11451155 die ();
11461156 }
11471157
1158+ private function careerPortalTemplateRequiresCaptcha ($ templateContent )
1159+ {
1160+ return (strpos ($ templateContent , '<input-captcha req> ' ) !== false );
1161+ }
1162+
1163+ private function validateCareerPortalCaptcha ($ captchaValue )
1164+ {
1165+ $ expectedPhrase = isset ($ _SESSION ['careerPortalCaptcha ' ]) ? trim ((string ) $ _SESSION ['careerPortalCaptcha ' ]) : '' ;
1166+ $ submittedPhrase = trim ((string ) $ captchaValue );
1167+
1168+ $ this ->clearCareerPortalCaptchaPhrase ();
1169+
1170+ if ($ expectedPhrase === '' || $ submittedPhrase === '' )
1171+ {
1172+ return false ;
1173+ }
1174+
1175+ return (strcasecmp ($ submittedPhrase , $ expectedPhrase ) === 0 );
1176+ }
1177+
1178+ private function clearCareerPortalCaptchaPhrase ()
1179+ {
1180+ unset($ _SESSION ['careerPortalCaptcha ' ]);
1181+ }
1182+
11481183
11491184 private function _makeApplyValidator ($ template )
11501185 {
You can’t perform that action at this time.
0 commit comments