AAAAcomponents/com_chronoforms/form_actions/load_security_question/load_security_question.php000060400000003621151401600670035156 0ustar00home/academiac/www/administrator 'anti_spam', 'title' => 'Anti SPAM'); var $details = array('title' => 'Load Security Question', 'tooltip' => 'Display the security question, you need a "Security Question Input" as one of your form fields.'); function run($form, $actiondata){ $mainframe = JFactory::getApplication(); $session = JFactory::getSession(); $uri = JFactory::getURI(); $params = new JParameter($actiondata->params); //extract questions $q_as = explode("\n", $actiondata->content1); $rand = rand(0, count($q_as) - 1); $choosen = explode("=", $q_as[$rand]); //add a session prefix, useful if more than 1 form is opened by the same user $session_key_field = ""; $answers = explode(",", trim($choosen[1])); foreach($answers as $k => $answer){ $answers[$k] = strtolower($answer); } if((bool)$params->get('session_key', 1) === true){ $session_key = $form->getSessionToken(); $session->set("chrono_security_answers_".$session_key, $answers, md5('chrono')); //$session_key_field = ''; }else{ $session->set("chrono_security_answers", $answers, md5('chrono')); $session_key_field = ""; } $form->form_details->content = str_replace('{chrono_security_question}', $session_key_field.trim($choosen[0]), $form->form_details->content); } function load($clear){ if($clear){ $action_params = array( 'content1' => '', 'enabled' => 1, 'session_key' => 1 ); } return array('action_params' => $action_params); } } ?>