File manager - Edit - /home/capoccitel/www/components/com_rtform/controllers/submitform.php
Back
<?php /** * @version CVS: 1.0.0 * @package Com_Rtform * @author Radius Theme <support@radiustheme.com> * @copyright 2016 RadiusTheme.com * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Submit controller class. * * @since 1.6 */ class RtformControllerSubmitForm extends JControllerForm { /** * Method to check out an item for editing and redirect to the edit form. * * @return void * * @since 1.6 */ public function edit() { $app = JFactory::getApplication(); // Get the previous edit id (if any) and the current edit id. $previousId = (int) $app->getUserState('com_rtform.edit.submit.id'); $editId = $app->input->getInt('id', 0); // Set the user id for the user to edit in the session. $app->setUserState('com_rtform.edit.submit.id', $editId); // Get the model. $model = $this->getModel('SubmitForm', 'RtformModel'); // Check out the item if ($editId) { $model->checkout($editId); } // Check in the previous user. if ($previousId) { $model->checkin($previousId); } // Redirect to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submitform&layout=edit', false)); } /** * Method to save a user's profile data. * * @return void * * @throws Exception * @since 1.6 */ public function save() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel('SubmitForm', 'RtformModel'); // Get the user data. $data = JFactory::getApplication()->input->get('jform', array(), 'array'); // Validate the posted data. $form = $model->getForm(); if (!$form) { throw new Exception($model->getError(), 500); } // Validate the posted data. $data = $model->validate($form, $data); // Check for errors. if ($data === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } $input = $app->input; $jform = $input->get('jform', array(), 'ARRAY'); // Save the data in the session. $app->setUserState('com_rtform.edit.submit.data', $jform); // Redirect back to the edit screen. $id = (int) $app->getUserState('com_rtform.edit.submit.id'); $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submitform&layout=edit&id=' . $id, false)); } // Attempt to save the data. $return = $model->save($data); // Check for errors. if ($return === false) { // Save the data in the session. $app->setUserState('com_rtform.edit.submit.data', $data); // Redirect back to the edit screen. $id = (int) $app->getUserState('com_rtform.edit.submit.id'); $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submitform&layout=edit&id=' . $id, false)); } // Check in the profile. if ($return) { $model->checkin($return); } // Start Mail $mail = JFactory::getMailer(); $app = JFactory::getApplication(); $jinput = JFactory::getApplication()->input; $rtform_params = JComponentHelper::getParams('com_rtform'); $recipient = $rtform_params->get('admin_email'); $enable_recaptcha = $rtform_params->get('enable_recaptcha'); $sitekey = $rtform_params->get('sitekey'); $secret = $rtform_params->get('secret'); $post = $jinput->get('jform','','array'); echo $name = $post['name']; $email = $post['email']; $appointment_date = $post['appointment_date']; $phone = $post['phone']; $main_message = $post['message']; echo $g_recaptcha = $_POST['g_recaptcha']; //send mail $message =''; $message .= JText::_('COM_RTFORM_LBL_EMAIL_YOUR_NAME'). $name; $message .= '<br>'.JText::_('COM_RTFORM_LBL_EMAIL_YOUR_EMAIL'). $email; $message .= '<br>'.JText::_('COM_RTFORM_LBL_EMAIL_APPT_DATE'). $appointment_date; $message .= '<br>'.JText::_('COM_RTFORM_LBL_EMAIL_PHONE_NO'). $phone; $message .= '<br>'.JText::_('COM_RTFORM_LBL_EMAIL_YOUR_MESSAGE'). $main_message; $subject = JText::_('COM_RTFORM_LBL_EMAIL_SUBJECT'). $name; //exit; $sender = array($email, $name); $mail->setSender($sender); $mail->addRecipient($recipient); $mail->setSubject($subject); $mail->isHTML(true); $mail->Encoding = 'base64'; $mail->setBody($message); // check secret key require_once "recaptchalib.php"; // your secret key // empty response $response = null; // check secret key $reCaptcha = new ReCaptcha($secret); if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"] ); } if($response != null && $response->success){ $sent = $mail->Send(); //$msg = "Email successfully sent!!!"; $this->setMessage(JText::_('COM_RTFORM_LBL_SUCCESS_MESSAGE')); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); $url = (empty($item->link) ? 'index.php?option=com_rtform&view=submissions' : $item->link); $this->setRedirect(JRoute::_($url, false)); }else{ //$msg = "Please fill the google reCaptcha!!!"; // Save the data in the session. $app->setUserState('com_rtform.edit.submit.data', $data); // Redirect back to the edit screen. $id = (int) $app->getUserState('com_rtform.edit.submit.id'); $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submitform&layout=edit&id=' . $id, false)); } // End Mail // Clear the profile id from the session. $app->setUserState('com_rtform.edit.submit.id', null); // Redirect to the list screen. $this->setMessage(JText::_('COM_RTFORM_ITEM_SAVED_SUCCESSFULLY')); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); $url = (empty($item->link) ? 'index.php?option=com_rtform&view=submissions' : $item->link); $this->setRedirect(JRoute::_($url, false)); // Flush the data from the session. $app->setUserState('com_rtform.edit.submit.data', null); } /** * Method to abort current operation * * @return void * * @throws Exception */ public function cancel() { $app = JFactory::getApplication(); // Get the current edit id. $editId = (int) $app->getUserState('com_rtform.edit.submit.id'); // Get the model. $model = $this->getModel('SubmitForm', 'RtformModel'); // Check in the item if ($editId) { $model->checkin($editId); } $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); $url = (empty($item->link) ? 'index.php?option=com_rtform&view=submissions' : $item->link); $this->setRedirect(JRoute::_($url, false)); } /** * Method to remove data * * @return void * * @throws Exception */ public function remove() { // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel('SubmitForm', 'RtformModel'); // Get the user data. $data = array(); $data['id'] = $app->input->getInt('id'); // Check for errors. if (empty($data['id'])) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_rtform.edit.submit.data', $data); // Redirect back to the edit screen. $id = (int) $app->getUserState('com_rtform.edit.submit.id'); $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submit&layout=edit&id=' . $id, false)); } // Attempt to save the data. $return = $model->delete($data); // Check for errors. if ($return === false) { // Save the data in the session. $app->setUserState('com_rtform.edit.submit.data', $data); // Redirect back to the edit screen. $id = (int) $app->getUserState('com_rtform.edit.submit.id'); $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_rtform&view=submit&layout=edit&id=' . $id, false)); } // Check in the profile. if ($return) { $model->checkin($return); } // Clear the profile id from the session. $app->setUserState('com_rtform.edit.submit.id', null); // Redirect to the list screen. $this->setMessage(JText::_('COM_RTFORM_ITEM_DELETED_SUCCESSFULLY')); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); $url = (empty($item->link) ? 'index.php?option=com_rtform&view=submissions' : $item->link); $this->setRedirect(JRoute::_($url, false)); // Flush the data from the session. $app->setUserState('com_rtform.edit.submit.data', null); } }
| ver. 1.6 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings