$doc =& JFactory::getDocument(); if (!defined('SIMPLEFORM2')) { if ($inclJquery) { $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.js'); } $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.form.js'); $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.simpleform.js'); } $doc->addScriptDeclaration($script); } defined('SIMPLEFORM2') or define('SIMPLEFORM2', 1); $task = JRequest::getCmd('task'); $post = (array) JRequest::get('post'); $moduleID = (int) JRequest::getInt('moduleID'); $form = new simpleForm2(); $form->set('id', $id); $form->set('moduleID', $module->id); $form->set('_key', $params->get('domainKey', '')); $form->parse($params->get('simpleCode', '')); if ($task == 'sendForm' && count($post) > 0 && $moduleID == (int) $module->id) { $form->set('defaultError', JText::_('Enter value for')); $result = $form->processRequest($post); if ($result !== false) { $ok = $form->sendEmail($result, $params); if ($ok) { echo $params->get('okText', JText::_('Form succeed')); return true; } else { echo '<script type="text/javascript">jQuery(document).ready(function(){alert("' . $form->getError() . '");});</script>'; } } else {
} ); return false; }); }); '; $styles = 'div.sfCopyr{margin:10px 0;border-top:1px solid #ccc;text-align:right;}' . "\n" . 'div.sfCopyr a{color:#ccc;}'; $config =& JFactory::getConfig(); $cache = $params->get('cache', 0); $sysCache = $config->getValue('config.caching'); if ($cache == 1 && $sysCache == 1) { echo '<script type="text/javascript" src="' . JURI::root() . 'modules/mod_simpleform2/ajax/jquery.js"></script>' . "\n"; echo '<script type="text/javascript" src="' . JURI::root() . 'modules/mod_simpleform2/ajax/jquery.form.js"></script>' . "\n"; echo '<style type="text/css"> ' . $styles . ' </style>' . "\n"; echo '<script type="text/javascript"> ' . $script . ' </script>'; } else { $doc =& JFactory::getDocument(); $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.js'); $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.form.js'); $doc->addScriptDeclaration($script); $doc->addStyleDeclaration($styles); } $form = new simpleForm2($params->get('simpleCode', '')); $form->set('id', $id); $form->set('moduleID', $module->id); $form->set('_key', $params->get('domainKey', '')); $form->render();
die; break; case 'sendForm': $moduleID = (int) JRequest::getInt('moduleID', 0); if ($moduleID == 0) { sfEcho('!' . JText::_('Form not found')); } $module =& JTable::getInstance('module'); $module->load($moduleID); if (!$module->id || $module->id != $moduleID) { sfEcho('!' . JText::_('Form not found')); } $params = new JParameter($module->params); require_once JPATH_BASE . DS . 'modules' . DS . 'mod_simpleform2' . DS . 'simpleform2.class.php'; $form = new simpleForm2($params->get('simpleCode', ''), true); $form->set('defaultError', JText::_('Enter value for')); $result = $form->processRequest($_POST); if ($result !== false) { $mailFrom = $params->get('sfMailForm', null); $mailTo = $params->get('sfMailTo', null); $subject = $params->get('sfMailSubj', '--== SimpleForm2 e-mail ==--'); $subject = html_entity_decode($subject, ENT_QUOTES); $now =& JFactory::getDate(); $url = JURI::root(); $url = str_replace('modules/mod_simpleform2/', '', $url); $url = JRequest::getVar('url', $url); $date = $now->toFormat('%d.%m.%Y %H:%M:%S'); $ip = $form->getUserIp(); $body = $form->getTemplate('mail_form', array('url' => $url, 'date' => $date, 'ip' => $ip, 'rows' => $result)); $body = stripslashes(html_entity_decode($body, ENT_QUOTES)); if (!$mailFrom || !$mailTo) {
sfEcho('!' . JText::_('Form not found')); } $module =& JTable::getInstance('module'); $module->load($moduleID); if (!$module->id || $module->id != $moduleID) { sfEcho('!' . JText::_('Form not found')); } if (class_exists('JParameter')) { $params = new JParameter($module->params); } else { $params = new JRegistry(); $params->loadJSON($module->params); } require_once JPATH_BASE . DS . 'modules' . DS . 'mod_simpleform2' . DS . 'simpleform2.class.php'; $form = new simpleForm2(); $form->set('moduleID', $module->id); $form->parse($params->get('simpleCode', '')); require_once JPATH_BASE . DS . 'modules' . DS . 'mod_simpleform2' . DS . 'kcaptcha' . DS . 'kcaptcha.php'; } switch ($task) { case 'captcha': @ob_end_clean(); $captcha = null; foreach ($form->elements as $elem) { if ($elem->type == 'captcha') { $captcha = $elem; break; } } if (is_null($captcha)) { sfEcho('!' . JText::_('Form has no captcha'));