コード例 #1
0
 public static function processForm($formId)
 {
     $mainframe = JFactory::getApplication();
     $formId = (int) $formId;
     $db = JFactory::getDBO();
     $db->setQuery("SELECT `FormLayoutName`, `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
     $form = $db->loadObject();
     $lang = RSFormProHelper::getCurrentLanguage();
     $translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
     if ($translations) {
         foreach ($translations as $field => $value) {
             if (isset($form->{$field})) {
                 $form->{$field} = $value;
             }
         }
     }
     $invalid = RSFormProHelper::validateForm($formId);
     $post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     //Trigger Event - onBeforeFormValidation
     $mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid, 'formId' => $formId, 'post' => &$post)));
     $userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $_POST['form'] = $post;
     $RSadapter = RSFormProHelper::getLegacyAdapter();
     eval($form->ScriptProcess);
     if (!empty($invalid)) {
         return $invalid;
     }
     $post = $_POST['form'];
     //Trigger Event - onBeforeFormProcess
     $mainframe->triggerEvent('rsfp_f_onBeforeFormProcess', array(array('post' => &$post)));
     if (empty($invalid)) {
         // Cache enabled ?
         jimport('joomla.plugin.helper');
         $cache_enabled = JPluginHelper::isEnabled('system', 'cache');
         if ($cache_enabled) {
             RSFormProHelper::cleanCache();
         }
         $user = JFactory::getUser();
         $confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
         // Add to db (submission)
         $date = JFactory::getDate();
         $db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`='" . $date->toSql() . "', `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->escape($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->escape($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
         $db->execute();
         $SubmissionId = $db->insertid();
         $files = JRequest::get('files');
         if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
             $names = array();
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $names[] = $db->escape($fieldName);
             }
             $componentIds = array();
             if (!empty($names)) {
                 $db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
                 $results = $db->loadObjectList();
                 foreach ($results as $result) {
                     $componentIds[$result->PropertyValue] = $result->ComponentId;
                 }
             }
             $all_data = RSFormProHelper::getComponentProperties($componentIds);
             jimport('joomla.filesystem.file');
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $data = @$all_data[$componentIds[$fieldName]];
                 if (empty($data)) {
                     continue;
                 }
                 // Prefix
                 $prefix = uniqid('') . '-';
                 if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
                     $prefix = RSFormProHelper::isCode($data['PREFIX']);
                 }
                 // Path
                 $realpath = realpath($data['DESTINATION'] . DIRECTORY_SEPARATOR);
                 if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
                     $realpath .= DIRECTORY_SEPARATOR;
                 }
                 // Filename
                 $file = $realpath . $prefix . $files['form']['name'][$fieldName];
                 // Upload File
                 JFile::upload($files['form']['tmp_name'][$fieldName], $file);
                 // Add to db (submission value)
                 $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->escape($fieldName) . "', `FieldValue`='" . $db->escape($file) . "'");
                 $db->execute();
                 $emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
                 // Attach to user and admin email
                 if (in_array('useremail', $emails)) {
                     $userEmail['files'][] = $file;
                 }
                 if (in_array('adminemail', $emails)) {
                     $adminEmail['files'][] = $file;
                 }
             }
         }
         // birthDay Field
         if ($componentIds = RSFormProHelper::componentExists($formId, 211)) {
             $all_data = RSFormProHelper::getComponentProperties($componentIds);
             foreach ($all_data as $componentId => $data) {
                 $day = strpos($data['DATEORDERING'], 'D');
                 $month = strpos($data['DATEORDERING'], 'M');
                 $year = strpos($data['DATEORDERING'], 'Y');
                 $items = array();
                 if ($data['SHOWDAY'] == 'YES') {
                     if (isset($data['STORELEADINGZERO']) && $data['STORELEADINGZERO'] == 'YES') {
                         $post[$data['NAME']]['d'] = str_pad(@$post[$data['NAME']]['d'], 2, '0', STR_PAD_LEFT);
                     }
                     $items[$day] = @$post[$data['NAME']]['d'];
                 }
                 if ($data['SHOWMONTH'] == 'YES') {
                     if (isset($data['STORELEADINGZERO']) && $data['STORELEADINGZERO'] == 'YES') {
                         $post[$data['NAME']]['m'] = str_pad(@$post[$data['NAME']]['m'], 2, '0', STR_PAD_LEFT);
                     }
                     $items[$month] = @$post[$data['NAME']]['m'];
                 }
                 if ($data['SHOWYEAR'] == 'YES') {
                     $items[$year] = @$post[$data['NAME']]['y'];
                 }
                 ksort($items);
                 $hasValues = false;
                 foreach ($items as $item) {
                     if (!empty($item)) {
                         $hasValues = true;
                         break;
                     }
                 }
                 if (!$hasValues) {
                     $post[$data['NAME']] = '';
                 } else {
                     $post[$data['NAME']] = implode($data['DATESEPARATOR'], $items);
                 }
             }
         }
         //Trigger Event - onBeforeStoreSubmissions
         $mainframe->triggerEvent('rsfp_f_onBeforeStoreSubmissions', array(array('formId' => $formId, 'post' => &$post, 'SubmissionId' => $SubmissionId)));
         // Add to db (values)
         foreach ($post as $key => $val) {
             $val = is_array($val) ? implode("\n", $val) : $val;
             $val = RSFormProHelper::stripJava($val);
             $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->escape($key) . "', `FieldValue`='" . $db->escape($val) . "'");
             $db->execute();
         }
         //Trigger Event - onAfterStoreSubmissions
         $mainframe->triggerEvent('rsfp_f_onAfterStoreSubmissions', array(array('SubmissionId' => $SubmissionId, 'formId' => $formId)));
         // Send emails
         list($replace, $with) = RSFormProHelper::sendSubmissionEmails($SubmissionId);
         // RSForm! Pro Scripting - Thank You Message
         // performance check
         if (strpos($form->Thankyou, '{if ') !== false && strpos($form->Thankyou, '{/if}') !== false) {
             require_once dirname(__FILE__) . '/scripting.php';
             RSFormProScripting::compile($form->Thankyou, $replace, $with);
         }
         // Thank You Message
         $thankYouMessage = str_replace($replace, $with, $form->Thankyou);
         $form->ReturnUrl = str_replace($replace, $with, $form->ReturnUrl);
         // Set redirect link
         $u = RSFormProHelper::getURL();
         // Create the Continue button
         $continueButton = '';
         if ($form->ShowContinue) {
             // Create goto link
             $goto = 'document.location.reload();';
             // Cache workaround #1
             if ($cache_enabled) {
                 $goto = "document.location='" . addslashes($u) . "';";
             }
             if (!empty($form->ReturnUrl)) {
                 $goto = "document.location='" . addslashes($form->ReturnUrl) . "';";
             }
             // Continue button
             $continueButtonLabel = JText::_('RSFP_THANKYOU_BUTTON');
             if (strpos($continueButtonLabel, 'input')) {
                 $continueButton = JText::sprintf('RSFP_THANKYOU_BUTTON', $goto);
             } else {
                 if ($form->FormLayoutName == 'responsive') {
                     $continueButton .= '<div class="formResponsive">';
                 } else {
                     $continueButton .= '<br/>';
                 }
                 $continueButton .= '<input type="button" class="rsform-submit-button btn btn-primary" name="continue" value="' . JText::_('RSFP_THANKYOU_BUTTON') . '" onclick="' . $goto . '"/>';
                 if ($form->FormLayoutName == 'responsive') {
                     $continueButton .= '</div>';
                 }
             }
         }
         // get mappings data
         $db->setQuery("SELECT * FROM #__rsform_mappings WHERE formId = " . (int) $formId . " ORDER BY ordering ASC");
         $mappings = $db->loadObjectList();
         // get Post to another location
         $db->setQuery("SELECT * FROM #__rsform_posts WHERE form_id='" . (int) $formId . "' AND enabled='1'");
         $silentPost = $db->loadObject();
         $RSadapter = RSFormProHelper::getLegacyAdapter();
         eval($form->ScriptProcess2);
         $thankYouMessage .= $continueButton;
         //Mappings
         if (!empty($mappings)) {
             $lastinsertid = '';
             $replacewith = $with;
             array_walk($replacewith, array('RSFormProHelper', 'escapeSql'));
             foreach ($mappings as $mapping) {
                 //get the query
                 $query = RSFormProHelper::getMappingQuery($mapping);
                 //replace the placeholders
                 $query = str_replace($replace, $replacewith, $query);
                 //replace the last insertid placeholder
                 $query = str_replace('{last_insert_id}', $lastinsertid, $query);
                 if ($mapping->connection) {
                     $options = array('driver' => 'mysql', 'host' => $mapping->host, 'user' => $mapping->username, 'password' => $mapping->password, 'database' => $mapping->database);
                     if (RSFormProHelper::isJ('3.0')) {
                         $database = JDatabaseDriver::getInstance($options);
                     } else {
                         $database = JDatabase::getInstance($options);
                     }
                     //is a valid database connection
                     if (is_a($database, 'JException')) {
                         continue;
                     }
                     $database->setQuery($query);
                     $database->execute();
                     $lastinsertid = $database->insertid();
                 } else {
                     $db->setQuery($query);
                     $db->execute();
                     $lastinsertid = $db->insertid();
                 }
             }
         }
         if (!$form->Keepdata) {
             $db->setQuery("DELETE FROM #__rsform_submission_values WHERE SubmissionId = " . (int) $SubmissionId . " ");
             $db->execute();
             $db->setQuery("DELETE FROM #__rsform_submissions WHERE SubmissionId = " . (int) $SubmissionId . " ");
             $db->execute();
         }
         if ($silentPost && !empty($silentPost->url) && $silentPost->url != 'http://') {
             // url
             $url = $silentPost->url;
             // set the variables to be sent
             // the format of the variables is var1=value1&var2=value2&var3=value3
             $data = array();
             foreach ($post as $key => $value) {
                 if (is_array($value)) {
                     foreach ($value as $post2 => $value2) {
                         $data[] = urlencode($key) . '[]=' . urlencode($value2);
                     }
                 } else {
                     $data[] = urlencode($key) . '=' . urlencode($value);
                 }
             }
             // do we need to post silently?
             if ($silentPost->silent) {
                 $data = implode('&', $data);
                 $params = array('method' => $silentPost->method ? 'POST' : 'GET');
                 require_once dirname(__FILE__) . '/connect.php';
                 RSFormProConnect($url, $data, $params);
             } else {
                 // just try to redirect
                 if ($silentPost->method) {
                     @ob_end_clean();
                     // create form
                     $output = array();
                     $output[] = '<form id="formSubmit" method="POST" action="' . RSFormProHelper::htmlEscape($url) . '">';
                     foreach ($post as $key => $value) {
                         if (is_array($value)) {
                             foreach ($value as $post2 => $value2) {
                                 $output[] = '<input type="hidden" name="' . RSFormProHelper::htmlEscape($key) . '[]" value="' . RSFormProHelper::htmlEscape($value2) . '" />';
                             }
                         } else {
                             $output[] = '<input type="hidden" name="' . RSFormProHelper::htmlEscape($key) . '" value="' . RSFormProHelper::htmlEscape($value) . '" />';
                         }
                     }
                     $output[] = '</form>';
                     $output[] = '<script type="text/javascript">';
                     $output[] = 'function formSubmit() { if (typeof document.getElementById("formSubmit").submit == "function") { document.getElementById("formSubmit").submit(); } else { document.createElement("form").submit.call(document.getElementById("formSubmit")); } }';
                     $output[] = 'try { window.addEventListener ? window.addEventListener("load",formSubmit,false) : window.attachEvent("onload",formSubmit); }';
                     $output[] = 'catch (err) { formSubmit(); }';
                     $output[] = '</script>';
                     // echo form and submit it
                     echo implode("\r\n", $output);
                     die;
                 } else {
                     $data = implode('&', $data);
                     $mainframe->redirect($url . (strpos($url, '?') === false ? '?' : '&') . $data);
                 }
             }
         }
         //Trigger - After form process
         $mainframe->triggerEvent('rsfp_f_onAfterFormProcess', array(array('SubmissionId' => $SubmissionId, 'formId' => $formId)));
         if (!$form->ShowThankyou && $form->ReturnUrl) {
             $mainframe->redirect($form->ReturnUrl);
             return;
         }
         // SESSION quick hack - we base64 encode it here and decode it when we show it
         $session = JFactory::getSession();
         $formParams = new stdClass();
         $formParams->formProcessed = true;
         $formParams->submissionId = $SubmissionId;
         $formParams->thankYouMessage = base64_encode($thankYouMessage);
         $session->set('com_rsform.formparams.' . $formId, $formParams);
         // Cache workaround #2
         if ($cache_enabled) {
             $uniqid = uniqid('rsform');
             $u .= strpos($u, '?') === false ? '?skipcache=' . $uniqid : '&skipcache=' . $uniqid;
         }
         $mainframe->redirect($u);
     }
     return false;
 }
コード例 #2
0
ファイル: rsform.php プロジェクト: atikahmed/joomla-probid
 function processForm($formId)
 {
     $mainframe =& JFactory::getApplication();
     $formId = (int) $formId;
     $db = JFactory::getDBO();
     $db->setQuery("SELECT `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
     $form = $db->loadObject();
     $lang = RSFormProHelper::getCurrentLanguage();
     $translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
     if ($translations) {
         foreach ($translations as $field => $value) {
             if (isset($form->{$field})) {
                 $form->{$field} = $value;
             }
         }
     }
     $invalid = RSFormProHelper::validateForm($formId);
     //Trigger Event - onBeforeFormValidation
     $mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid)));
     $userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     $_POST['form'] = $post;
     $RSadapter = RSFormProHelper::getLegacyAdapter();
     eval($form->ScriptProcess);
     if (!empty($invalid)) {
         return $invalid;
     }
     $post = $_POST['form'];
     //Trigger Event - onBeforeFormProcess
     $mainframe->triggerEvent('rsfp_f_onBeforeFormProcess');
     if (empty($invalid)) {
         // Cache enabled ?
         jimport('joomla.plugin.helper');
         $cache_enabled = JPluginHelper::isEnabled('system', 'cache');
         if ($cache_enabled) {
             RSFormProHelper::cleanCache();
         }
         $user = JFactory::getUser();
         $confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
         // Add to db (submission)
         $db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`=NOW(), `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->getEscaped($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->getEscaped($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
         $db->query();
         $SubmissionId = $db->insertid();
         $files = JRequest::get('files');
         if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
             $names = array();
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $names[] = $db->getEscaped($fieldName);
             }
             $componentIds = array();
             if (!empty($names)) {
                 $db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
                 $results = $db->loadObjectList();
                 foreach ($results as $result) {
                     $componentIds[$result->PropertyValue] = $result->ComponentId;
                 }
             }
             $all_data = RSFormProHelper::getComponentProperties($componentIds);
             jimport('joomla.filesystem.file');
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $data = @$all_data[$componentIds[$fieldName]];
                 if (empty($data)) {
                     continue;
                 }
                 // Prefix
                 $prefix = uniqid('') . '-';
                 if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
                     $prefix = RSFormProHelper::isCode($data['PREFIX']);
                 }
                 // Path
                 $realpath = realpath($data['DESTINATION'] . DS);
                 if (substr($realpath, -1) != DS) {
                     $realpath .= DS;
                 }
                 // Filename
                 $file = $realpath . $prefix . $files['form']['name'][$fieldName];
                 // Upload File
                 JFile::upload($files['form']['tmp_name'][$fieldName], $file);
                 // Add to db (submission value)
                 $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->getEscaped($fieldName) . "', `FieldValue`='" . $db->getEscaped($file) . "'");
                 $db->query();
                 $emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
                 // Attach to user and admin email
                 if (in_array('useremail', $emails)) {
                     $userEmail['files'][] = $file;
                 }
                 if (in_array('adminemail', $emails)) {
                     $adminEmail['files'][] = $file;
                 }
             }
         }
         //Trigger Event - onBeforeStoreSubmissions
         $mainframe->triggerEvent('rsfp_f_onBeforeStoreSubmissions', array(array('formId' => $formId, 'post' => &$post, 'SubmissionId' => $SubmissionId)));
         // Add to db (values)
         foreach ($post as $key => $val) {
             $val = is_array($val) ? implode("\n", $val) : $val;
             $val = RSFormProHelper::stripJava($val);
             $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->getEscaped($key) . "', `FieldValue`='" . $db->getEscaped($val) . "'");
             $db->query();
         }
         //Trigger Event - onAfterStoreSubmissions
         $mainframe->triggerEvent('rsfp_f_onAfterStoreSubmissions', array(array('SubmissionId' => $SubmissionId, 'formId' => $formId)));
         // Send emails
         list($replace, $with) = RSFormProHelper::sendSubmissionEmails($SubmissionId);
         // Thank You Message
         $thankYouMessage = str_replace($replace, $with, $form->Thankyou);
         $form->ReturnUrl = str_replace($replace, $with, $form->ReturnUrl);
         // Set redirect link
         $u = RSFormProHelper::getURL();
         // Create the Continue button
         $continueButton = '';
         if ($form->ShowContinue) {
             // Create goto link
             $goto = 'document.location.reload();';
             // Cache workaround #1
             if ($cache_enabled) {
                 $goto = "document.location='" . addslashes($u) . "';";
             }
             if (!empty($form->ReturnUrl)) {
                 $goto = "document.location='" . addslashes($form->ReturnUrl) . "';";
             }
             // Continue button
             $continueButtonLabel = JText::_('RSFP_THANKYOU_BUTTON');
             if (strpos($continueButtonLabel, 'input')) {
                 $continueButton = JText::sprintf('RSFP_THANKYOU_BUTTON', $goto);
             } else {
                 $continueButton = '<br/><input type="button" class="rsform-submit-button" name="continue" value="' . JText::_('RSFP_THANKYOU_BUTTON') . '" onclick="' . $goto . '"/>';
             }
         }
         $RSadapter = RSFormProHelper::getLegacyAdapter();
         eval($form->ScriptProcess2);
         $thankYouMessage .= $continueButton;
         //Mappings
         //get mappings data
         $db->setQuery("SELECT * FROM #__rsform_mappings WHERE formId = " . (int) $formId . " ORDER BY ordering ASC ");
         $mappings = $db->loadObjectList();
         if (!empty($mappings)) {
             $lastinsertid = '';
             $replacewith = $with;
             array_walk($replacewith, array('RSFormProHelper', 'escapeSql'));
             foreach ($mappings as $mapping) {
                 //get the query
                 $query = RSFormProHelper::getMappingQuery($mapping);
                 //replace the placeholders
                 $query = str_replace($replace, $replacewith, $query);
                 //replace the last insertid placeholder
                 $query = str_replace('{last_insert_id}', $lastinsertid, $query);
                 if ($mapping->connection) {
                     $options = array('host' => $mapping->host, 'user' => $mapping->username, 'password' => $mapping->password, 'database' => $mapping->database);
                     $database = JDatabase::getInstance($options);
                     //is a valid database connection
                     if (is_a($database, 'JException')) {
                         continue;
                     }
                     $database->setQuery($query);
                     $database->query();
                     $lastinsertid = $database->insertid();
                 } else {
                     $db->setQuery($query);
                     $db->query();
                     $lastinsertid = $db->insertid();
                 }
             }
         }
         if (!$form->Keepdata) {
             $db->setQuery("DELETE FROM #__rsform_submission_values WHERE SubmissionId = " . (int) $SubmissionId . " ");
             $db->query();
             $db->setQuery("DELETE FROM #__rsform_submissions WHERE SubmissionId = " . (int) $SubmissionId . " ");
             $db->query();
         }
         //Trigger - After form process
         $mainframe->triggerEvent('rsfp_f_onAfterFormProcess', array(array('SubmissionId' => $SubmissionId, 'formId' => $formId)));
         if (!$form->ShowThankyou && $form->ReturnUrl) {
             $mainframe->redirect($form->ReturnUrl);
             return;
         }
         // SESSION quick hack - we base64 encode it here and decode it when we show it
         $session =& JFactory::getSession();
         $formParams = new stdClass();
         $formParams->formProcessed = true;
         $formParams->submissionId = $SubmissionId;
         $formParams->thankYouMessage = base64_encode($thankYouMessage);
         $session->set('com_rsform.formparams.' . $formId, $formParams);
         // Cache workaround #2
         if ($cache_enabled) {
             $uniqid = uniqid('rsform');
             $u .= strpos($u, '?') === false ? '?skipcache=' . $uniqid : '&skipcache=' . $uniqid;
         }
         $mainframe->redirect($u);
     }
     return false;
 }