Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Web_Snippet_Legacy_Contact_ContactForms extends Web_Snippet_Legacy_Abstract {
- protected $_name = 'ContactForms';
- protected $_category = 'Web_Category_Legacy_Contact';
- /**
- * Parse it and return
- *
- * @return string
- */
- protected function dispatch() {
- $limit = $this->getProp('limit');
- require_once(self::getModx()->config['base_path'] . 'core/components/blank/lib/recaptchalib.php');
- $publickey = "intentionally left blank";
- $privatekey = "intentionally left blank";
- if (isset($_POST['formid'])) {
- $resp = recaptcha_check_answer(
- $privatekey
- , 'intentionally left blank'
- , $_POST["recaptcha_challenge_field"]
- , $_POST["recaptcha_response_field"]
- );
- if (!$resp->is_valid) {
- $captcha_fail = true;
- }
- }
- if (isset($_POST['formid']) && !isset($captcha_fail)) {
- $submitted_form = self::getModx()->getObject('modResource', array('id' => $_POST['formid']));
- $postal_code = $_POST['form']['postal'] = $_POST['form']['postal'] . $_POST['form']['postal1'];
- $_POST['form']['phone'] = $_POST['form']['phone'] . $_POST['form']['phone2'] . $_POST['form']['phone3'];
- unset($_POST['form']['postal1']);
- unset($_POST['form']['phone2']);
- unset($_POST['form']['phone3']);
- $fieldmap = array();
- $fieldmap['name'] = 'Name';
- $fieldmap['city'] = 'City';
- $fieldmap['title'] = 'Title';
- $fieldmap['province'] = 'Province';
- $fieldmap['address'] = 'Address';
- $fieldmap['email'] = 'Email';
- $fieldmap['postal'] = 'Postal Code';
- $fieldmap['phone'] = 'Phone Number';
- $fieldmap['productType'] = 'Interested Product Types';
- $fieldmap['moreInfo'] = 'I would like more information on';
- $fieldmap['comments'] = 'Comments';
- $fieldmap['school'] = 'School';
- $fieldmap['company'] = 'Company';
- $fieldmap['crossroads'] = 'Main Intersection';
- $fieldmap['propertytype'] = 'Property Type';
- $fieldmap['zoning'] = 'Zoning';
- $fieldmap['locationdetails'] = 'Location Details';
- if (self::getModx()->lang == 'fr') {
- switch ($submitted_form->get('id')) {
- case 86:
- $subject = 'Possibilité d\'affichage';
- break;
- case 87:
- $subject = 'Location d\'une propriété ou d\'un édifice';
- break;
- case 91:
- $subject = 'Demande de proposition';
- break;
- case 92:
- $subject = 'Demande d\'un fournisseur';
- break;
- case 90:
- $subject = 'Renseignements généraux';
- break;
- case 336:
- $subject = '';
- break;
- case 89:
- $subject = 'Demande d\'un étudiant';
- break;
- }
- $mail_subject = 'Requête via site Web : ' . $subject;
- } else {
- switch ($submitted_form->get('id')) {
- case 86:
- $subject = ' Advertising Opportunities';
- break;
- case 87:
- $subject = ' Leasing Property or Building';
- break;
- case 91:
- $subject = ' Request for Proposal';
- break;
- case 92:
- $subject = ' Supplier Request';
- break;
- case 90:
- $subject = ' General Information';
- break;
- case 336:
- $subject = '';
- break;
- case 89:
- $subject = 'Student Request';
- break;
- }
- $mail_subject = 'Website Inquiry: ' . $subject;
- ;
- }
- if (self::getModx()->lang == 'fr') {
- $fieldmap = array();
- $fieldmap['name'] = 'Nom ';
- $fieldmap['city'] = 'Ville ';
- $fieldmap['title'] = 'Titre ';
- $fieldmap['province'] = 'Province ';
- $fieldmap['address'] = 'Adresse ';
- $fieldmap['email'] = 'Courriel ';
- $fieldmap['postal'] = 'Code postal ';
- $fieldmap['phone'] = 'Téléphone ';
- $fieldmap['productType'] = 'Types de produits intéressées ';
- $fieldmap['moreInfo'] = 'Je voudrais plus d\'informations sur ';
- $fieldmap['comments'] = 'Commentaires ';
- $fieldmap['school'] = 'L\'école ';
- $fieldmap['company'] = 'Société ';
- $fieldmap['crossroads'] = 'Voie de circulation principale à proximité';
- $fieldmap['propertytype'] = 'Type de propriété ';
- $fieldmap['zoning'] = 'Zonage ';
- $fieldmap['locationdetails'] = 'Détails de l\'emplacement';
- $message = "Cette demande, reçue via le site 192.168.4.64 a été expédiée par " . htmlentities(filter_var($_POST['form']['name'])) . " le " . date('Y-m-d') . " à " . date('H:i:s') . " et concerne le formulaire intitulé " . $subject . ". Cette personne recevra également un avis automatique détaillant vos coordonnées afin qu'elle puisse effectuer un suivi auprès de vous. Veuillez répondre à l'intérieur de 24 à 48 heures ou transférez la demande à un autre membre de l'équipe afin de garantir le suivi de la demande.<br><br>\n\n";
- } else {
- $fieldmap = array();
- $fieldmap['name'] = 'Name';
- $fieldmap['city'] = 'City';
- $fieldmap['title'] = 'Title';
- $fieldmap['province'] = 'Province';
- $fieldmap['address'] = 'Address';
- $fieldmap['email'] = 'Email';
- $fieldmap['postal'] = 'Postal Code';
- $fieldmap['phone'] = 'Phone Number';
- $fieldmap['productType'] = 'Interested Product Types';
- $fieldmap['moreInfo'] = 'I would like more information on';
- $fieldmap['comments'] = 'Comments';
- $fieldmap['school'] = 'School';
- $fieldmap['company'] = 'Company';
- $fieldmap['crossroads'] = 'Main Intersection';
- $fieldmap['propertytype'] = 'Property Type';
- $fieldmap['zoning'] = 'Zoning';
- $fieldmap['locationdetails'] = 'Location Details';
- $message = "The following request from 192.168.4.64 has been sent by " . htmlentities(filter_var($_POST['form']['name'])) . " at " . date('Y-m-d H:i:s') . " regarding " . $subject . " . This person will have also received an automatic notification containing your contact information for follow-up purposes. Please respond within 24-48 hours or forward to another team member for the appropriate follow-up.<br><br>\n\n";
- }
- foreach ($_POST['form'] as $field_name => $form_data) {
- if (is_array($form_data)) {
- $message .= $fieldmap[$field_name] . ":<br>\n";
- foreach ($form_data as $val) {
- if (trim($val))
- $message .= htmlentities(filter_var($val), ENT_NOQUOTES) . "<br>\n";
- }
- $message .= "<br>\n";
- }
- else {
- if (trim($form_data))
- $message .= $fieldmap[$field_name] . ': ' . htmlentities(filter_var($form_data), ENT_NOQUOTES) . "<br>\n";
- }
- }
- $employee = self::getModx()->getObject('modResource', array('id' => $_POST['employeeid']));
- $con_subject = $mail_subject;
- if (self::getModx()->lang == 'fr') {
- $from = 'Info PATTISON';
- } else {
- $from = 'PATTISON Info';
- }
- if ($_SERVER['REMOTE_ADDR'] == '192.168.4.64') {
- mail('blank', html_entity_decode($con_subject), $message, "MIME-Version: 1.0\r\nContent-type: text/html; charset=ISO-8859-2\r\nFrom: \"" . $from . "\" <info_reply@192.168.4.64>");
- } else {
- mail($employee->getTVValue('Employee Email Address'), html_entity_decode($con_subject), $message, "MIME-Version: 1.0\r\nContent-type: text/html; charset=ISO-8859-2\r\nFrom: \"" . $from
- . "\" <info_reply@192.168.4.64>");
- }
- $alias_var = $GLOBALS['lang']['tv'][self::getModx()->lang]['alias'];
- $response_var = $GLOBALS['lang']['tv'][self::getModx()->lang]['formresponder'];
- $employee_title_var = $GLOBALS['lang']['tv'][self::getModx()->lang]['jobtitle'];
- $curr_page = self::getModx()->resource;
- $response = $submitted_form->getTVValue($response_var);
- $response = str_replace(chr(194), '', $response);
- $office_location = self::getModx()->getObject('modResource', array('id' => $employee->get('parent')));
- $response = str_replace(array('{name}', '{date}', '{contact-name}', '{contact-title}', '{contact-email}', '{office-city}', '{office-province}', '{office-postalcode}', '{office-address}', '{office-telephone}', '{office-fax}'), array(ucwords($_POST['form']['name']), date('d/m/Y'), $employee->get('pagetitle'), $employee->getTVValue($employee_title_var), $employee->getTVValue('Employee Email Address'), $office_location->getTVValue('Office City'), $office_location->getTVValue('Office Province'), $office_location->getTVValue('Office Postal Code'), $office_location->getTVValue('Office Address'), $office_location->getTVValue('Office Telephone Number'), $office_location->getTVValue('Office Fax Number')), $response);
- if (self::getModx()->lang == 'fr')
- $subject = 'Confirmation de votre demande : ' . $submitted_form->getTVValue('French Form Title');
- else
- $subject = 'Confirmation of your request: ' . $submitted_form->getTVValue('English Form Title');
- mail($_POST['form']['email'], html_entity_decode(strip_tags($subject)), $response, "MIME-Version: 1.0\r\nContent-type: text/html; charset=ISO-8859-2\r\nFrom: \"" . $from . "\" <info_reply@192.168.4.64>");
- header('Location: ' . $curr_page->getTVValue($alias_var) . '?sent-form=1');
- die;
- }
- $output = '<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>';
- if (self::getModx()->lang == 'en')
- $output .= '<p style="width: 350px; font-weight: bold;"><br>Thank you for your interest, you will be contacted by the appropriate employee when your request has been reviewed.</p>';
- else
- $output .= '<p style="width: 350px; font-weight: bold;">Je vous remercie de votre intérét, vous serez contacté par l\'employé approprié lorsque votre demande aura été examinée.</p>';
- $form_pages = self::getModx()->getCollection('modResource', array('parent' => self::getModx()->resource->get('id')));
- $forms = array();
- $name_var = $GLOBALS['lang']['tv'][self::getModx()->lang]['formtitle'];
- $output .= '<label for="topic">[[!get-lang-static?variable=topic]]:</label>
- <select id="topic" name="topic" onchange="$(\'.form\').hide(); $(\'#\' + $(this).val()).show(); if ($(\'div.form\').eq($(this).attr(\'selectedIndex\') - 1).attr(\'submittable\') != \'No\') { $(\'form input[type=submit]:visible\').before($(\'#captcha_container\').show()); Recaptcha.create(\'' . $publickey . '\', $(this).val() + \'_captcha_container\', { theme: \'clean\' }); }">
- <option value="">-- [[!get-lang-static?variable=selecttopic]] --</option>';
- foreach ($form_pages as $form) {
- $output .= '<option value="' . strtolower(str_replace(" ", "", $form->get('pagetitle'))) . '" ' . ($form->get('id') == $_POST['formid'] ? 'SELECTED' : '') . '>' . $form->getTVValue($name_var) . '</option>';
- }
- $output .= '</select>';
- $count = 1;
- foreach ($form_pages as $key => $form) {
- $name_var = $GLOBALS['lang']['tv'][self::getModx()->lang]['formtagline'];
- $output .= '<div class="form" id="' . strtolower(str_replace(" ", "", $form->get('pagetitle'))) . '" style="' . ($form->get('id') == $_POST['formid'] ? '' : 'display: none;') . '" submittable="' . $form->getTVValue('Submittable') . '">';
- $output .= '<div class="required" style="width: 375px; margin-right: 0px;">*[[!get-lang-static?variable=requiredfields]]</div>';
- $output .= '<form id="' . strtolower(str_replace(" ", "", $form->get('pagetitle'))) . '" action="[[!get-lang-tv?variable=alias]]" method="POST" onsubmit="return ' . strtolower(str_replace(" ", "", $form->get('pagetitle'))) . '_submit();">';
- $output .= '<input type="hidden" name="formid" value="' . $form->get('id') . '">';
- $output .= '<input type="hidden" id="employeeid" name="employeeid" value="' . $form->get('id') . '">';
- $output .= '
- <!-- RZAK:START:' . $form->get('pagetitle') . '-->
- ';
- $output .= self::getModx()->runSnippet($form->getTVValue('Form'), array('captcha_fail' => $captcha_fail, 'tagline' => $form->getTVValue($name_var), 'form_data' => $_POST['form'], 'form' => $form));
- $output .= '
- <!-- RZAK:END:' . $form->get('pagetitle') . '-->
- ';
- $output .= '<div id="' . strtolower(str_replace(" ", "", $form->get('pagetitle'))) . '_captcha_container"></div>';
- if ($form->getTVValue('Submittable') != 'No')
- $output .= '<br/><a style="margin-left: 115px;" href="#" onclick="$(\'form\').eq(' . $count . ').submit(); return false;" class="button">[[!get-lang-static?variable=submit]]</a>';
- $output .= '</form>';
- $output .= '</div>';
- $count++;
- }
- if ($_GET['form']) {
- $output .= '<script>
- $(\'#topic\').val(\'' . $_GET['form'] . '\');
- $(\'#\' + $(\'#topic\').val()).show();
- ';
- if ($_GET['form'] != 'jobopportunities')
- $output .= '
- $(\'form input[type=submit]:visible\').before($(\'#captcha_container\').show());
- Recaptcha.create(\'' . $publickey . '\', $(\'#topic\').val() + \'_captcha_container\', { theme: \'clean\' }); ';
- $output .= '</script>';
- }
- if ($_POST['formid']) {
- $output .= '<script>$(\'#topic\').trigger(\'onchange\');</script>';
- }
- $output .= '
- <div class="clear"></div>
- <div class="clear"></div>';
- return $output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement