/** * The function that will be executed when the form is submitted * */ function onsubmit($option, $params, $row) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $doc =& JFactory::getDocument(); $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}"); $mainframe->enqueuemessage('$_POST: ' . print_r($_POST, true)); $messages = array(); /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } $url_values = array(); /// add main fields if (trim($row->extra2)) { $extras2 = explode("\n", $row->extra2); foreach ($extras2 as $extra2) { $values = array(); $values = explode("=", $extra2); if ($values[1]) { $v = urlencode(trim($values[1])); $url_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', ''); } } } if (trim($row->extra1)) { $extras = explode("\n", $row->extra1); foreach ($extras as $extra) { // Note: accept only the first parameter pair on each line $values = explode("=", $extra, 2); if (isset($values[1])) { $url_values[$values[0]] = trim($values[1]); } } } $query = JURI::buildQuery($url_values); $uri = $params->get('target_url') . '?' . $query; $parts['query'] = $query; $parts['scheme'] = 'http'; $parts['host'] = 'bobjanes.com'; //$parts['host'] = $params->get('target_url'); //$uri = JURI::toString($parts); $MyForm =& CFChronoForm::getInstance(); $MyForm->formrow->redirecturl = $uri; $messages[] = '<b>cf_redirect debug info</b>'; $messages[] = '$url: ' . print_r($uri, true); $messages[] = '$_POST: ' . print_r($_POST, true); /* * Build query into url and set CF redirect url */ $helper->showCFDebugMessage('Redirect URL set'); if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }
/** * The function that will be executed when the form is submitted * */ function onsubmit($option, $params, $row) { global $mainframe; if (!function_exists('curl_init')) { $mainframe->enqueuemessage("CURL problem : the CURL function was not found on this server.<br />\n Sorry, but the CURL plugin cannot be used on this site as it is currently set up.", 'error'); return; } require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $doc =& JFactory::getDocument(); $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}"); $messages = array(); /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } $curl_values = array(); /// add main fields if (trim($row->extra2)) { $extras2 = explode("\n", $row->extra2); foreach ($extras2 as $extra2) { $values = array(); $values = explode("=", $extra2); if ($values[1]) { $v = urlencode(trim($values[1])); $curl_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', ''); } } } if (trim($row->extra1)) { $extras = explode("\n", $row->extra1); foreach ($extras as $extra) { // Note: accept only the first parameter pair on each line $values = explode("=", $extra, 2); $curl_values[$values[0]] = trim($values[1]); } } $query = JURI::buildQuery($curl_values); $messages[] = '<b>cf_CURL debug info</b>'; $messages[] = '$curl_values: ' . print_r($query, true); $messages[] = '$params->target_url: ' . print_r($params->get('target_url'), true); $ch = curl_init($params->get('target_url')); $messages[] = '$ch: ' . print_r($ch, true); curl_setopt($ch, CURLOPT_HEADER, $params->get('header_in_response')); // set to 0 to eliminate header info from response curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($ch, CURLOPT_POSTFIELDS, $query); // use HTTP POST to send form data curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $response = curl_exec($ch); //execute post and get results curl_close($ch); $messages[] = 'CURL response: ' . print_r($response, true); $helper->showCFDebugMessage('CURL transaction executed'); /*********do the after onsubmit code**********/ if (!empty($row->extra5)) { eval("?>" . $row->extra5); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }