function prefs_smarty_validate() { global $_RUN; if (SmartyValidate::is_init() && SmartyValidate::is_valid($_POST)) { SmartyValidate::clear(); // And set the preferences $ok = ""; $errors['PARAMS'] = "Incorrect parameters specified..\n"; $data['name'] = $_POST['name']; $data['email'] = $_POST['email']; $data['theme_id'] = $_POST['theme']; $data['gender'] = $_POST['gender']; $data['city'] = $_POST['city']; $data['country'] = $_POST['country']; $data['tag'] = $_POST['tag']; $data['dob'] = $_POST['dob_Year'] . "-" . $_POST['dob_Month'] . "-" . $_POST['dob_Day']; if (isset($inform)) { $data['inform'] = $_POST['inform']; } if (isset($login_pass)) { $data['login_pass'] = $_POST['login_pass']; } $user_id = decrypt_get_vars($_POST['uid']); $data['user_id'] = $user_id; comm_send_to_server("SETPREFS", $data, $ok, $errors); $result = sql_query("SELECT * FROM perihelion.u_users WHERE id=" . $user_id); $tmp = sql_fetchrow($result); session_reinit($tmp); $template = new Smarty(); $template->display($_RUN['theme_path'] . "/preferences-success.tpl"); return true; } return false; }
function Init($root) { // Set up all Smarty default settings $this->template_dir = $root . '/templates'; $this->compile_dir = $root . '/tmp/compiled'; $this->cache_dir = $root . '/tmp/cache'; //$this->config_dir = $root . '/text/'.LANGUAGE; $this->_file_perms = 0664; $this->plugins_dir[] = $root . '/include/smarty'; //$this->load_filter("output", "varreplace"); // Initialize SmartyValidate SmartyValidate::connect($this); // Make global variables accessible from within smarty templates /* foreach ($GLOBALS as $k=>$v) { if ($k != "smarty") $this->_tpl_vars[$k] = $v; } */ }
function contact_form() { global $smarty, $lang, $fp_config; if (empty($_POST)) { $smarty->assign('success', system_geterr('contact')); $smarty->assign_by_ref('panelstrings', $lang['contact']); // new form, we (re)set the session data SmartyValidate::connect($smarty, true); // register our validators SmartyValidate::register_validator('name', 'name', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('email', 'email', 'isEmail', true, false, 'trim'); SmartyValidate::register_validator('www', 'url', 'isURL', true, false, 'trim'); SmartyValidate::register_validator('content', 'content', 'notEmpty', false, false); } else { utils_nocache_headers(); // validate after a POST SmartyValidate::connect($smarty); if (!empty($_POST['url']) && strpos($_POST['url'], 'http://') === false) { $_POST['url'] = 'http://' . $_POST['url']; } // custom hook here!! // we'll use comment actions, anyway if (SmartyValidate::is_valid($_POST) && ($arr = contact_form_validate())) { $msg = "Name: \n{$arr['name']} \n\n"; if (isset($arr['email'])) { $msg .= "Email: {$arr['email']}\n\n"; } if (isset($arr['url'])) { $msg .= "WWW: {$arr['url']}\n\n"; } $msg .= "Content:\n{$arr['content']}\n"; $success = @utils_mail(isset($arr['email']) ? $arr['email'] : $fp_config['general']['email'], "Contact sent through {$fp_config['general']['title']} ", $msg); system_seterr('contact', $success ? 1 : -1); utils_redirect(basename(__FILE__)); } else { $smarty->assign('values', $_POST); } } }
/** * Validate the form * * @param array $dirty reference to unverified $_POST * @param object smarty template * @param string $form the name of the form being validated * @return bool */ static function formValidate(&$dirty, $tpl, $form = null) { if (!isset($form)) { $form = self::$form; } if (!empty($dirty) && SmartyValidate::is_registered_form($form)) { // Check token if (!empty($dirty['token'])) { if (!in_array($dirty['token'], $_SESSION['_sux0r_tokens'])) { return false; } } unset($dirty['token']); // Validate self::connect($tpl); if (self::is_valid($dirty, $form)) { SmartyValidate::disconnect(true); return true; } } return false; }
/** * Project: SmartyValidate: Form Validator for the Smarty Template Engine * File: function.validate.php * Author: Monte Ohrt <monte at newdigitalgroup dot com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://www.phpinsider.com/php/code/SmartyValidate/ * @copyright 2001-2005 New Digital Group, Inc. * @author Monte Ohrt <monte at newdigitalgroup dot com> * @package SmartyValidate */ function smarty_function_validate($params, &$smarty) { $_init_params = $smarty->get_template_vars('validate_init'); if (isset($_init_params)) { $params = array_merge($_init_params, $params); } static $_halt = array(); static $_is_init = null; $_form = isset($params['form']) ? $params['form'] : 'default'; $_sess =& $_SESSION['SmartyValidate'][$_form]; if (!isset($_is_init)) { $_is_init = $_sess['is_init']; } if (!SmartyValidate::is_registered_form($_form)) { trigger_error("SmartyValidate: [validate plugin] form '{$_form}' is not registered."); return false; } if (isset($_halt[$_form]) && $_halt[$_form]) { return; } if (!class_exists('SmartyValidate')) { $smarty->trigger_error("validate: missing SmartyValidate class"); return; } if (!isset($_SESSION['SmartyValidate'])) { $smarty->trigger_error("validate: SmartyValidate is not initialized, use connect() first"); return; } if (isset($params['id'])) { if (($_validator_key = SmartyValidate::is_registered_validator($params['id'], $_form)) === false) { $smarty->trigger_error("validate: validator id '" . $params['id'] . "' is not registered."); return; } } else { if (strlen($params['field']) == 0) { $smarty->trigger_error("validate: missing 'field' parameter"); return; } if (strlen($params['criteria']) == 0) { $smarty->trigger_error("validate: missing 'criteria' parameter"); return; } } if (isset($params['trim'])) { $params['trim'] = SmartyValidate::_booleanize($params['trim']); } if (isset($params['empty'])) { $params['empty'] = SmartyValidate::_booleanize($params['empty']); } if (isset($params['halt'])) { $params['halt'] = SmartyValidate::_booleanize($params['halt']); } if (isset($_sess['validators']) && is_array($_sess['validators'])) { if (isset($params['id'])) { if ($_is_init) { $_sess['validators'][$_validator_key]['message'] = $params['message']; } } else { foreach ($_sess['validators'] as $_key => $_field) { if ($_field['field'] == $params['field'] && $_field['criteria'] == $params['criteria']) { // field exists $_validator_key = $_key; break; } } } if (!$_is_init) { if (!$_sess['is_error']) { // no validation error return; } if (!isset($_sess['validators'][$_validator_key]['valid']) || !$_sess['validators'][$_validator_key]['valid']) { // not valid, show error and reset $_halt[$_form] = isset($_sess['validators'][$_validator_key]['halt']) ? $_sess['validators'][$_validator_key]['halt'] : false; $_echo = true; if (isset($params['assign'])) { $smarty->assign($params['assign'], $_sess['validators'][$_validator_key]['message']); } elseif (isset($params['append'])) { // bb $smarty->append($params['append'], $_sess['validators'][$_validator_key]['message']); $smarty->append($params['append'], array($_sess['validators'][$_validator_key]['field'] => $_sess['validators'][$_validator_key]['message']), true); } else { // no assign or append, so echo message echo $_sess['validators'][$_validator_key]['message']; } } } else { if (isset($params['id'])) { $_sess['validators'][$_validator_key] = array_merge($_sess['validators'][$_validator_key], $params); } else { $_params = $params; $_params['valid'] = false; $_sess['validators'][] = $_params; } } } $_sess['is_init'] = false; }
#check for session availability #if( isset($_SESSION['loginUsername']) ) { $user = new Authentication(); #check whether user has a session if (!$user->sessionAuthenticate()) { $smarty->assign('sessionMsg', $user->msg); $content = $smarty->fetch('./logon/tm0.logon.logon_err.tpl.html'); unset($path); #this avoids execution of the wanted content script include_once './config/disconnect.inc.php'; } else { #check whether user is required to change their passwoard #session chg_pass avoids execution of the whole if statement every time script is run #its set when user changes password successfully or when they rnt required to change their password $path = $_GET['path']; if (!isset($_SESSION['chg_pass']) && substr_count($path, 'chg_pass') != 1 && $user->chgPassStatus($db, $_SESSION['loginUsername'])) { $smarty->assign('chg_pass', "You are required to change your Password"); // new form, we (re)set the session data SmartyValidate::connect($smarty, true); // register our validators SmartyValidate::register_validator('password', 'oldpassword', 'notEmpty'); SmartyValidate::register_validator('password1', 'newpassword:6:-1', 'isLength'); SmartyValidate::register_validator('password2', 'newpassword:confpassword', 'isEqual'); // fetch form $chg_pass_content = $smarty->fetch('./user/user.chg_pass.tpl.html'); } } } ?>
case 'N': default: if (empty($_REQUEST['submit'])) { SmartyValidate::connect($tpl); SmartyValidate::register_form('conf_user_permissions', true); SmartyValidate::register_criteria('isValueUnique', 'validate_unique', 'conf_user_permissions'); SmartyValidate::register_criteria('isNotEqual', 'validate_not_equal', 'conf_user_permissions'); SmartyValidate::register_criteria('isNotSubCat', 'validate_not_sub_category', 'conf_user_permissions'); SmartyValidate::register_validator('v_CATEGORY_ID', 'CATEGORY_ID:0', 'isNotEqual', true, false, null, 'conf_user_permissions'); SmartyValidate::register_validator('v_CATEGORY_ID_U', "CATEGORY_ID:user_permission:0:USER_ID", 'isValueUnique', false, false, null, 'conf_user_permissions'); SmartyValidate::register_validator('v_CATEGORY_ID_S', "CATEGORY_ID", 'isNotSubCat', false, false, null, 'conf_user_permissions'); } else { SmartyValidate::connect($tpl); $data = get_table_data('user_permission'); $data['USER_ID'] = $u; if (SmartyValidate::is_valid($data, 'conf_user_permissions')) { // Check if category is parent to existing categories. $child_categories = find_child_categories(); if ($child_categories > 0) { $tpl->assign('CHILD_CATEGORIES', $child_categories); $tpl->assign('WARN', true); $category = $db->GetOne("SELECT `TITLE` FROM `{$tables['category']['name']}` WHERE `ID` = " . $db->qstr($data['CATEGORY_ID'])); $tpl->assign('CATEGORY', $category); } else { $id = $db->GenID($tables['user_permission']['name'] . '_SEQ'); $data['ID'] = $id; if (db_replace('user_permission', $data, 'ID') > 0) { $tpl->assign('posted', 'Permission granted.'); } else { $tpl->assign('sql_error', $db->ErrorMsg()); }
$vMsg = array(); $vMsg['site_url'] = $vMsg['site_success'] = $vMsg['site_confirm'] = Pommo::_T('Must be a valid URL'); $vMsg['list_name'] = $vMsg['site_name'] = Pommo::_T('Cannot be empty.'); $smarty->assign('vMsg', $vMsg); // populate _POST with info from database (fills in form values...) $dbVals = PommoAPI::configGet(array('site_success', 'site_confirm', 'list_exchanger', 'list_confirm')); $dbVals['site_url'] = $pommo->_config['site_url']; $dbVals['site_name'] = $pommo->_config['site_name']; $dbVals['list_name'] = $pommo->_config['list_name']; $smarty->assign($dbVals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); if (SmartyValidate::is_valid($_POST, 'general')) { // __ FORM IS VALID PommoAPI::configUpdate($_POST); $pommo->reloadConfig(); $json->success(Pommo::_T('Configuration Updated.')); } else { // __ FORM NOT VALID $json->add('fieldErrors', $smarty->getInvalidFields('general')); $json->fail(Pommo::_T('Please review and correct errors with your submission.')); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/general.tpl'); Pommo::kill();
SmartyValidate::register_validator('v_email', 'email', 'isEmail'); SmartyValidate::register_validator('v_password', 'password', 'notEmpty'); SmartyValidate::register_validator('v_confirm_password', 'password:confirm_password', 'isEqual'); $smarty->display('add.tpl'); } else { SmartyValidate::connect($smarty); // validate after a POST if (SmartyValidate::is_valid($_POST)) { // no errors, done with SmartyValidate if (array_key_exists('submit', $_POST)) { //var_dump($_POST); exit; $_SESSION['firstname'] = $_POST['firstname']; $_SESSION['lastname'] = $_POST['lastname']; $_SESSION['mobile_number'] = $_POST['mobile_number']; $_SESSION['email'] = $_POST['email']; $_SESSION['password'] = $_POST['password']; $_SESSION['group'] = $_POST['role']; $obj->insertAuditTrail($_SESSION['login'], 'ADD_USER', $_SESSION['firstname'] . ' ' . $_SESSION['lastname'] . ' added as user'); } SmartyValidate::disconnect(); header("Location: controllers/regprocess.php"); } else { $smarty->assign('title', 'mHealth Admin Registration'); $smarty->assign('topic', 'Admin Registration Failed'); $smarty->assign('view', $view); $smarty->assign('category', $category); // error, redraw the form $smarty->assign($_POST); $smarty->display('add.tpl'); } }
$price[$link_type_int['normal_plus']] = PAY_NORMAL_PLUS; } if (PAY_RECPR > 0) { $price[$link_type_int['reciprocal']] = PAY_RECPR; } if ($action == 'pay') { if (empty($_REQUEST['submit'])) { if (!empty($_SERVER['HTTP_REFERER'])) { $_SESSION['return'] = $_SERVER['HTTP_REFERER']; } SmartyValidate::connect($tpl); SmartyValidate::register_form('pay_link', true); SmartyValidate::register_validator('v_quantity', 'quantity', 'isInt', false, false, 'trim', 'pay_link'); } else { SmartyValidate::connect($tpl); if (SmartyValidate::is_valid($_REQUEST, 'pay_link')) { $pay_data = array(); $pay_id = $db->GenID($tables['payment']['name'] . '_SEQ'); $pay_data['ID'] = $pay_id; $pay_data['LINK_ID'] = $data['ID']; $pay_data['IPADDRESS'] = get_client_ip(); $pay_data['QUANTITY'] = $_REQUEST['quantity']; $pay_data['AMOUNT'] = $price[$data['LINK_TYPE']]; $pay_data['TOTAL'] = (int) $pay_data['QUANTITY'] * (double) $pay_data['AMOUNT']; $pay_data['UM'] = PAY_UM; $pay_data['PAY_DATE'] = gmdate('Y-m-d H:i:s'); $pay_data['CONFIRMED'] = -1; if (db_replace('payment', $pay_data, 'ID') > 0) { $action = 'paypal'; $tpl->assign('PAYMENT', $pay_data); } else {
/** * Project: SmartyValidate: Form Validator for the Smarty Template Engine * File: SmartyValidate.class.php * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://www.phpinsider.com/php/code/SmartyValidate/ * @copyright 2001-2004 ispi of Lincoln, Inc. * @author Monte Ohrt <*****@*****.**> * @package SmartyValidate * @version 2.1-dev */ function smarty_function_validate($params, &$smarty) { static $_halt = array(); $_form = isset($params['form']) ? $params['form'] : 'default'; if (!SmartyValidate::is_registered_form($_form)) { trigger_error("SmartyValidate: [validate plugin] form '{$_form}' is not registered."); return false; } if (isset($_halt[$_form]) && $_halt[$_form]) { return; } if (!class_exists('SmartyValidate')) { $smarty->trigger_error("validate: missing SmartyValidate class"); return; } if (!isset($_SESSION['SmartyValidate'])) { $smarty->trigger_error("validate: SmartyValidate is not initialized, use connect() first"); return; } if (strlen($params['field']) == 0) { $smarty->trigger_error("validate: missing 'field' parameter"); return; } if (strlen($params['criteria']) == 0) { $smarty->trigger_error("validate: missing 'criteria' parameter"); return; } if (isset($params['trim'])) { $params['trim'] = SmartyValidate::_booleanize($params['trim']); } else { $params['trim'] = false; } if (isset($params['empty'])) { $params['empty'] = SmartyValidate::_booleanize($params['empty']); } else { $params['empty'] = false; } if (isset($params['halt'])) { $params['halt'] = SmartyValidate::_booleanize($params['halt']); } else { $params['halt'] = false; } if (strlen($params['criteria']) == 0) { $smarty->trigger_error("validate: parameter 'criteria' missing."); return; } $_sess =& $_SESSION['SmartyValidate'][$_form]['validators']; $_found = false; if (isset($_sess) && is_array($_sess)) { foreach ($_sess as $_key => $_field) { if ($_field['field'] == $params['field'] && $_field['criteria'] == $params['criteria']) { // field exists $_found = true; if (isset($_sess[$_key]['valid']) && !$_sess[$_key]['valid']) { // not valid, show error and reset $_halt[$_form] = $params['halt']; $_echo = true; if (!isset($params['assign']) && !isset($params['append'])) { // no assign or append, so echo message echo $_sess[$_key]['message']; } $_sess[$_key]['valid'] = null; break; } } } } if (!$_found) { // create $_sess[] = $params; } }
$tmpvar['ids'][] = $row['id']; $tmpvar['names'][] = $row['name']; } $template->assign("themes_ids", $tmpvar['ids']); $template->assign("themes_names", $tmpvar['names']); if (!SmartyValidate::is_init() && !isset($_POST['submit'])) { SmartyValidate::init(); SmartyValidate::register_criteria("validate_email"); SmartyValidate::register_criteria("validate_login"); SmartyValidate::register_criteria("validate_specie"); SmartyValidate::register_criteria("validate_sector"); SmartyValidate::register_criteria("validate_planet"); $template->display($_RUN['theme_path'] . "/register.tpl"); } else { if (SmartyValidate::is_valid($_POST)) { SmartyValidate::clear(); $ok = ""; $errors['PARAMS'] = "Incorrect parameters specified..\n"; $data['tag'] = $_POST['tag']; $data['name'] = $_POST['name']; $data['email'] = $_POST['email']; $data['inform'] = $_POST['inform']; $data['gender'] = $_POST['gender']; $data['city'] = $_POST['city']; $data['country'] = $_POST['country']; $data['species'] = $_POST['species']; $data['planet'] = $_POST['planet']; $data['sector'] = $_POST['sector']; $data['login_name'] = $_POST['login_name']; $data['login_pass'] = $_POST['login_pass']; if (comm_send_to_server("REGISTER", $data, $ok, $errors) == 1) {
$data['NOFOLLOW'] = $_POST['NOFOLLOW'] == '1' ? '1' : '0'; $data['RECPR_REQUIRED'] = $_POST['RECPR_REQUIRED'] == '1' ? '1' : '0'; if (strlen(trim($data['URL'])) > 0 && !preg_match('#^http[s]?:\\/\\/#i', $data['URL'])) { $data['URL'] = "http://" . $data['URL']; } if (strlen(trim($data['RECPR_URL'])) > 0 && !preg_match('#^http[s]?:\\/\\/#i', $data['RECPR_URL'])) { $data['RECPR_URL'] = "http://" . $data['RECPR_URL']; } if (trim($data['EXPIRY_DATE']) == '') { $data['EXPIRY_DATE'] = ''; } else { if (strtotime($data['EXPIRY_DATE']) != -1) { $data['EXPIRY_DATE'] = date('Y-m-d H:i:s', strtotime($data['EXPIRY_DATE'])); } } if (SmartyValidate::is_valid($data, 'dir_links_edit')) { if (empty($id)) { $id = $db->GenID($tables['link']['name'] . '_SEQ'); } if ($data['FEATURED'] == '1') { $AllowedFeat = check_allowed_feat($data['CATEGORY_ID']); $tpl->assign('AllowedFeat', $AllowedFeat); } if (ENABLE_PAGERANK) { require_once 'include/pagerank.php'; $data['PAGERANK'] = get_page_rank($data['URL']); if (!empty($data['RECPR_URL'])) { $data['RECPR_PAGERANK'] = get_page_rank($data['RECPR_URL']); } } $data['ID'] = $id;
SmartyValidate::register_validator('v_PASSWORD', 'PASSWORD:4:25', 'isLength', true, false, 'trim', 'conf_profile'); SmartyValidate::register_validator('v_PASSWORDC', 'PASSWORD:PASSWORDC', 'isEqual', true, false, 'trim', 'conf_profile'); SmartyValidate::register_validator('v_EMAIL', 'EMAIL', 'isEmail', false, false, 'trim', 'conf_profile'); } else { SmartyValidate::connect($tpl); $data = get_table_data('user'); $error = 0; if (!isset($data['SUBMIT_NOTIF'])) { $data['SUBMIT_NOTIF'] = 0; } if (!isset($data['PAYMENT_NOTIF'])) { $data['PAYMENT_NOTIF'] = 0; } $data['ID'] = $_SESSION['user_id']; $data['PASSWORDC'] = $_REQUEST['PASSWORDC']; if (SmartyValidate::is_valid($data, 'conf_profile')) { unset($data['PASSWORDC']); if (empty($data['PASSWORD'])) { $data['PASSWORD'] = $db->GetOne("SELECT `PASSWORD` FROM `{$tables['user']['name']}` WHERE `ID` = " . $db->qstr($data['ID'])); } else { $data['PASSWORD'] = encrypt_password($data['PASSWORD']); } $mode = "UPDATE"; $where = " `ID` = " . $db->qstr($data['ID']); if (!DEMO && $db->AutoExecute($tables['user']['name'], $data, $mode, $where) > 0) { $tpl->assign('posted', true); } } } $tpl->assign($data); $content = $tpl->fetch('conf_profile.tpl');
/** * test if a value is a valid range * * @param string $value the value being tested * @param string $fuction the function to test against * @param boolean $empty if field can be empty */ function _is_custom($form, $value, $function, $empty = false, &$params, &$formvars) { if (SmartyValidate::is_registered_criteria($function, $form)) { if (!function_exists($function)) { trigger_error("SmartyValidate: function '{$function}' does not exist."); return false; } return $function($value, $empty, $params, $formvars); } else { trigger_error("SmartyValidate: criteria function '{$function}' is not registered."); return false; } }
default: if ($id) { $where = "WHERE `ID` != " . $db->qstr($id); } if (empty($_POST['submit'])) { SmartyValidate::disconnect(); SmartyValidate::connect($tpl, true); SmartyValidate::register_criteria('isEmailAndAddLinkValid', 'validate_email_and_add_link'); SmartyValidate::register_validator('v_VALIDATE_EMAIL_TYPE', 'TPL_TYPE', 'isEmailAndAddLinkValid', false, false, 'trim'); SmartyValidate::register_validator('v_TITLE', 'TITLE', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('v_SUBJECT', 'SUBJECT', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('v_BODY', 'BODY', 'notEmpty', false, false, 'trim'); } else { SmartyValidate::connect($tpl); $data = get_table_data('email_tpl'); if (SmartyValidate::is_valid($data)) { if (empty($id)) { $id = $db->GenID($tables['email_tpl']['name'] . '_SEQ'); } $data['ID'] = $id; if ($db->Replace($tables['email_tpl']['name'], $data, 'ID', true) > 0) { $tpl->assign('posted', true); if (isset($_SESSION['return'])) { @header('Location: ' . $_SESSION['return']); @exit; } } else { $tpl->assign('sql_error', $db->ErrorMsg()); } } }
$vMsg['admin_username'] = Pommo::_T('Cannot be empty.'); $vMsg['admin_email'] = Pommo::_T('Invalid email address'); $vMsg['admin_password2'] = Pommo::_T('Passwords must match.'); $smarty->assign('vMsg', $vMsg); // populate _POST with info from database (fills in form values...) $dbVals = PommoAPI::configGet(array('admin_username')); $dbVals['admin_email'] = $pommo->_config['admin_email']; $smarty->assign($dbVals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); if (SmartyValidate::is_valid($_POST, 'users')) { // __ FORM IS VALID // convert password to MD5 if given... if (!empty($_POST['admin_password'])) { $_POST['admin_password'] = md5($_POST['admin_password']); } PommoAPI::configUpdate($_POST); unset($_POST['admin_password'], $_POST['admin_password2']); $pommo->reloadConfig(); $json->success(Pommo::_T('Configuration Updated.')); } else { // __ FORM NOT VALID $json->add('fieldErrors', $smarty->getInvalidFields('users')); $json->fail(Pommo::_T('Please review and correct errors with your submission.')); } }
*********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php'); $smarty = new PommoTemplate(); $smarty->prepareForForm(); $current = PommoMailing::isCurrent(); if (!SmartyValidate::is_registered_form() || empty($_POST)) { // ___ USER HAS NOT SENT FORM ___ SmartyValidate::connect($smarty, true); SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, 'trim'); $vMsg = array(); $vMsg['email'] = Pommo::_T('Invalid email address'); $smarty->assign('vMsg', $vMsg); } else { // ___ USER HAS SENT FORM ___ SmartyValidate::connect($smarty); if (SmartyValidate::is_valid($_POST) && !$current) { // __ FORM IS VALID Pommo::requireOnce($pommo->_baseDir . 'inc/classes/mailctl.php'); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php'); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/validate.php'); // get a copy of the message state // composition is valid (via preview.php) $state = $pommo->_session['state']['mailing']; // create temp subscriber $subscriber = array('email' => $_POST['email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 0, 'data' => $_POST['d']); PommoValidate::subscriberData($subscriber['data'], array('active' => FALSE, 'ignore' => TRUE, 'log' => false)); $key = PommoSubscriber::add($subscriber); if (!$key) { $logger->addErr('Unable to Add Subscriber'); } else { // temp subscriber created
SmartyValidate::register_validator('v_NAME', 'NAME:4:25', 'isLength', false, false, 'trim', 'conf_users_edit'); SmartyValidate::register_validator('v_PASSWORD', 'PASSWORD:4:25', 'isLength', true, false, 'trim', 'conf_users_edit'); SmartyValidate::register_validator('v_PASSWORDC', 'PASSWORD:PASSWORDC', 'isEqual', true, false, 'trim', 'conf_users_edit'); SmartyValidate::register_validator('v_EMAIL', 'EMAIL', 'isEmail', false, false, 'trim', 'conf_users_edit'); SmartyValidate::register_validator('v_EMAIL_U', 'EMAIL:user:'******'isValueUnique', false, false, 'trim', 'conf_users_edit'); } else { SmartyValidate::connect($tpl); $data = get_table_data('user'); if (!isset($data['SUBMIT_NOTIF'])) { $data['SUBMIT_NOTIF'] = 0; } if (!isset($data['PAYMENT_NOTIF'])) { $data['PAYMENT_NOTIF'] = 0; } $data['PASSWORDC'] = $_REQUEST['PASSWORDC']; if (SmartyValidate::is_valid($data, 'conf_users_edit')) { unset($data['PASSWORDC']); if (empty($id)) { $id = $db->GenID($tables['user']['name'] . '_SEQ'); } $data['ID'] = $id; if ($action == 'E') { if (empty($data['PASSWORD'])) { $data['PASSWORD'] = $db->GetOne("SELECT `PASSWORD` FROM `{$tables['user']['name']}` WHERE `ID` = " . $db->qstr($id)); } else { $data['PASSWORD'] = encrypt_password($data['PASSWORD']); } } else { $data['PASSWORD'] = encrypt_password($data['PASSWORD']); } if ($db->Replace($tables['user']['name'], $data, 'ID', true) > 0) {
function index() { session_start(); global $db, $prefix; include "header.php"; $tpl = new Template(); smartyValidate::connect($tpl, empty($_POST)); SmartyValidate::register_form('fare_search'); //set $origin = intval($_REQUEST["origin"]); $destination = intval($_REQUEST["destination"]); if ($_POST["departure"]) { $departure = tounixdate($_POST["departure"]); } else { $departure = $_GET["departure"]; } $faretype = intval($_REQUEST["faretype"]); $class = intval($_REQUEST["class"]); $airline = intval($_REQUEST["airline"]); $tpl->assign("origin", $origin); $tpl->assign("destination", $destination); $tpl->assign("class", $class); $tpl->assign("faretype", $faretype); //fare type $qtype = $db->query("SELECT * FROM travel_faretype"); while (list($type_id, $type_name) = $db->fetch_row($qtype)) { $type_opt[$type_id] = $type_name; } //Origin $qorigin = $db->query("SELECT origin_id,origin_name FROM travel_origin ORDER BY origin_name ASC "); $origin_opt = array(); while (list($origin_id, $origin_name) = $db->fetch_row($qorigin)) { $origin_opt[$origin_id] = $origin_name; } //Destination $qdestination = $db->query("SELECT destination_id,destination_name FROM travel_destination JOIN\r\n\t{$prefix}_fares ON destination_id=fare_destination\r\n\tORDER BY destination_name ASC"); $destination_opt = array(); while (list($destination_id, $destination_name) = $db->fetch_array($qdestination)) { $destination_opt[$destination_id] = $destination_name; } // Airlines $qairline = $db->query("SELECT airline_id,airline_name FROM travel_airline"); $airline_opt = array(); while (list($airline_id, $airline_name) = $db->fetch_array($qairline)) { $airline_opt[$airline_id] = $airline_name; } // Class $qclass = $db->query("SELECT class_id,class_name FROM travel_class"); $class_opt = array(); while (list($class_id, $class_name) = $db->fetch_array($qclass)) { $class_opt[$class_id] = $class_name; } if (!isset($_GET[page]) && empty($_POST)) { $tpl->assign("origin_opt", $origin_opt); $tpl->assign("destination_opt", $destination_opt); $tpl->assign("airline_opt", $airline_opt); $tpl->assign("class_opt", $class_opt); $tpl->assign("type_opt", $type_opt); $tpl->assign("lang", $lang); $tpl->display("search/search.tpl"); } else { if (SmartyValidate::is_valid($_POST)) { // no errors, done with SmartyValidate $tpl->assign($_POST); $tpl->assign("origin_opt", $origin_opt); $tpl->assign("destination_opt", $destination_opt); $tpl->assign("airline_opt", $airline_opt); $tpl->assign("class_opt", $class_opt); $tpl->assign("type_opt", $type_opt); $tpl->assign("lang", $lang); $tpl->display("search/search.tpl"); SmartyValidate::disconnect(); $origin = intval($_REQUEST["origin"]); $destination = intval($_REQUEST["destination"]); if ($_POST["departure"]) { $departure = tounixdate($_POST["departure"]); } else { $departure = $_GET["departure"]; } $faretype = intval($_REQUEST["faretype"]); $class = intval($_REQUEST["class"]); $airline = intval($_REQUEST["airline"]); //goto("index.php?m=search&op=search&origin=$origin&destination=$destination&departure=$departure&faretype=$faretype&class=$class&airline=$airline","Processing"); $faretype = intval($_REQUEST["faretype"]); $class = intval($_REQUEST["class"]); $airline = intval($_REQUEST["airline"]); $query = "SELECT * FROM " . $prefix . "_fares," . $prefix . "_fares_origin\r\n\t\t\tWHERE fare_id= fares_fare AND fares_origin ={$origin} \tAND fare_destination='{$destination}'"; if (!empty($faretype)) { $query .= " AND fare_type={$faretype}"; } if (!empty($class)) { $query .= " AND fare_class={$class}"; } if (!empty($airline)) { $query .= " AND fare_airline={$airline}"; } if (!empty($departure)) { $query .= " AND {$departure} BETWEEN fare_dept_start AND fare_dept_end"; } $qsearch = $db->query($query); $num_record = $db->row_count($qsearch); if ($num_record < 1) { $tpl->assign("norecord", "norecord"); $tpl->assign("lang", $lang); $tpl->display("search/search_result.tpl"); include "footer.php"; exit; } if (isset($_GET['page'])) { $page = intval($_GET['page']); } else { $page = 1; } $currentpage = $page; $perpage = 10; $start = ($page - 1) * $perpage; $pages = ceil($num_record / $perpage); $starting_no = $start + 1; if ($num_record - $start < $perpage) { $end_count = $num_record; } elseif ($num_record - $start >= $perpage) { $end_count = $start + $perpage; } if ($pages > 1) { $page_link = makepagelink("index.php?m=search&origin={$origin}&destination={$destination}&departure={$departure}&class={$class}&faretype={$faretype}&airline={$airline}", $page, $pages); } else { $page_link = ""; } $result = $db->query("{$query} AND fare_active=1 ORDER BY fare_adultfare ASC limit {$start},{$perpage}"); while ($row = $db->fetch_array($result)) { $indexx = $row[fare_id]; $info[$indexx] = $row; $info[$indexx]["airline"] = getrow("airline_name", "travel_airline", "airline_id", "{$row['fare_airline']}"); } $originName = getrow("origin_name", "" . $prefix . "_origin", "origin_id", "{$origin}"); $destinationName = getrow("destination_name", "" . $prefix . "_destination", "destination_id", "{$destination}"); $tpl->assign("lang", $lang); $tpl->assign("fareinfo", $info); $tpl->assign("found", $num_record); $tpl->assign("destinationName", $destinationName); $tpl->assign("originName", $originName); $tpl->assign("page_link", $page_link); $tpl->assign("end_count", $end_count); $tpl->assign("starting_no", $starting_no); $tpl->assign("currentpage", "{$currentpage}/{$pages}"); $tpl->display("search/search_result.tpl"); } else { $tpl->assign("origin_opt", $origin_opt); $tpl->assign("destination_opt", $destination_opt); $tpl->assign("airline_opt", $airline_opt); $tpl->assign("class_opt", $class_opt); $tpl->assign("type_opt", $type_opt); $tpl->assign("lang", $lang); $tpl->assign($_POST); $tpl->display("search/search.tpl"); } } include "footer.php"; }
SmartyValidate::register_validator('v_TITLE', 'TITLE', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('v_URL', 'URL', 'isURL', false, false, 'trim'); SmartyValidate::register_validator('v_EMAIL', 'EMAIL', 'isEmail', false, false, 'trim'); SmartyValidate::register_validator('v_check_email', 'EMAIL', 'checkEmail', false, false, null); SmartyValidate::register_validator('v_CATEGORY_ID', 'CATEGORY_ID:0', 'isNotEqual', true, false, 'trim'); } else { SmartyValidate::connect($tpl); $data = get_table_data('email'); $data['DATE_SENT'] = gmdate('Y-m-d H:i:s'); if (strlen(trim($data['URL'])) > 0 && !preg_match('#^http[s]?:\\/\\/#i', $data['URL'])) { $data['URL'] = "http://" . $data['URL']; } $full_data = $data; $full_data['CATEGORY_ID'] = $_REQUEST['CATEGORY_ID']; $full_data['DESCRIPTION'] = $_REQUEST['DESCRIPTION']; if (SmartyValidate::is_valid($full_data)) { // Generate Link ID first $link_id = $db->GenID($tables['link']['name'] . '_SEQ'); $email_data = $full_data; $email_data['ADD_RECIPROCAL_URL'] = "http://" . $_SERVER['HTTP_HOST'] . DIRECTORY_ROOT . "/add_reciprocal.php?id=" . $link_id; $tmpl = $db->GetRow("SELECT `SUBJECT`, `BODY` FROM `{$tables['email_tpl']['name']}` WHERE `ID` = " . $db->qstr($_REQUEST['EMAIL_TPL_ID'])); $mail = get_emailer(); $mail->Body = replace_email_vars($tmpl['BODY'], $email_data); $mail->Subject = replace_email_vars($tmpl['SUBJECT'], $email_data); $mail->AddAddress($email_data['EMAIL'], $email_data['NAME']); if (!DEMO) { $sent = $mail->Send(); } else { $sent = true; } if ($sent) {
} else { if (ENABLE_PAGERANK == 0) { $_REQUEST['SHOW_PAGERANK'] = 0; } if ($_REQUEST['SHOW_PAGERANK'] == 0 && $_REQUEST['DEFAULT_SORT'] == 'P') { $_REQUEST['DEFAULT_SORT'] = 'H'; } foreach ($conf as $i => $row) { if ($conf[$i]['CONFIG_GROUP'] != $_REQUEST['c']) { unset($conf[$i]); } else { $conf[$i]['VALUE'] = $_REQUEST[$row['ID']]; } } SmartyValidate::connect($tpl); if (SmartyValidate::is_valid($_REQUEST, 'conf_settings')) { $posted = true; if (!DEMO) { $errors = 0; $cust_msg = ''; foreach ($conf as $row) { $posted = $db->AutoExecute($tables['config']['name'], $row, 'UPDATE', '`ID` = ' . $db->qstr($row['ID'])); if (!$posted) { break; } } $tpl->assign('posted', $posted); } } } foreach ($conf as $i => $val) {
$p['subscribe_web'] = $messages['subscribe']['web']; $p['subscribe_email'] = $messages['subscribe']['email']; $p['unsubscribe_sub'] = $messages['unsubscribe']['sub']; $p['unsubscribe_msg'] = $messages['unsubscribe']['msg']; $p['unsubscribe_web'] = $messages['unsubscribe']['web']; $p['unsubscribe_email'] = $messages['unsubscribe']['email']; $p['confirm_sub'] = $messages['confirm']['sub']; $p['confirm_msg'] = $messages['confirm']['msg']; $p['activate_sub'] = $messages['activate']['sub']; $p['activate_msg'] = $messages['activate']['msg']; $p['update_sub'] = $messages['update']['sub']; $p['update_msg'] = $messages['update']['msg']; $smarty->assign($p); } else { // ___ USER HAS SENT FORM ___ if (SmartyValidate::is_valid($_POST, 'messages')) { // __ FORM IS VALID $messages = array(); $messages['subscribe'] = array(); $messages['subscribe']['sub'] = $_POST['subscribe_sub']; $messages['subscribe']['msg'] = $_POST['subscribe_msg']; $messages['subscribe']['web'] = $_POST['subscribe_web']; $messages['subscribe']['email'] = isset($_POST['subscribe_email']) ? true : false; $messages['unsubscribe'] = array(); $messages['unsubscribe']['sub'] = $_POST['unsubscribe_sub']; $messages['unsubscribe']['msg'] = $_POST['unsubscribe_msg']; $messages['unsubscribe']['web'] = $_POST['unsubscribe_web']; $messages['unsubscribe']['email'] = isset($_POST['unsubscribe_email']) ? true : false; $messages['confirm'] = array(); $messages['confirm']['sub'] = $_POST['confirm_sub']; $messages['confirm']['msg'] = $_POST['confirm_msg'];
function register_object($obj_name, &$object) { return parent::register_object($obj_name, $object); }
/** * get or set the smarty object instance * * @param string $value the value being tested */ function _smarty_assign($vars = array()) { $_smarty_obj =& SmartyValidate::_object_instance('Smarty', $_dummy); if(!is_object($_smarty_obj)) { trigger_error("SmartyValidate: [assign] no valid smarty object found, call connect() first."); return false; } if(!empty($vars)) { $_smarty_obj->assign($vars); } foreach($_SESSION['SmartyValidate'] as $_key => $_val) { $_info[$_key]['is_error'] = isset($_SESSION['SmartyValidate'][$_key]['is_error']) ? $_SESSION['SmartyValidate'][$_key]['is_error'] : null; } $_smarty_obj->assign('validate', $_info); }
SmartyValidate::register_validator('maxRuntime', 'maxRuntime', 'isInt', false, false, 'trim', 'mailings'); $vMsg = array(); $vMsg['maxRuntime'] = Pommo::_T('Enter a number.'); $vMsg['list_fromname'] = Pommo::_T('Cannot be empty.'); $vMsg['list_fromemail'] = $vMsg['list_frombounce'] = Pommo::_T('Invalid email address'); $smarty->assign('vMsg', $vMsg); // populate _POST with info from database (fills in form values...) $dbVals = PommoAPI::configGet(array('list_fromname', 'list_fromemail', 'list_frombounce', 'list_charset', 'public_history', 'maxRuntime')); $dbVals['demo_mode'] = !empty($pommo->_config['demo_mode']) && $pommo->_config['demo_mode'] == "on" ? 'on' : 'off'; $smarty->assign($dbVals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); if (SmartyValidate::is_valid($_POST, 'mailings')) { // __ FORM IS VALID PommoAPI::configUpdate($_POST); $pommo->reloadConfig(); $json->success(Pommo::_T('Configuration Updated.')); } else { // __ FORM NOT VALID $json->add('fieldErrors', $smarty->getInvalidFields('mailings')); $json->fail(Pommo::_T('Please review and correct errors with your submission.')); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/mailings.tpl'); Pommo::kill();
SmartyValidate::register_validator('list_name', 'list_name', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('site_name', 'site_name', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('site_url', 'site_url', 'isURL'); SmartyValidate::register_validator('admin_password', 'admin_password', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('admin_password2', 'admin_password:admin_password2', 'isEqual'); SmartyValidate::register_validator('admin_email', 'admin_email', 'isEmail'); $formError = array(); $formError['list_name'] = $formError['site_name'] = $formError['admin_password'] = Pommo::_T('Cannot be empty.'); $formError['admin_password2'] = Pommo::_T('Passwords must match.'); $formError['site_url'] = Pommo::_T('Must be a valid URL'); $formError['admin_email'] = Pommo::_T('Must be a valid email'); $smarty->assign('formError', $formError); } else { // ___ USER HAS SENT FORM ___ SmartyValidate::connect($smarty); if (SmartyValidate::is_valid($_POST)) { // __ FORM IS VALID if (isset($_POST['installerooni'])) { // drop existing poMMo tables foreach (array_keys($dbo->table) as $key) { $table = $dbo->table[$key]; $sql = 'DROP TABLE IF EXISTS ' . $table; $dbo->query($sql); } if (isset($_REQUEST['debugInstall'])) { $dbo->debug(TRUE); } $install = PommoInstall::parseSQL(); if ($install) { // installation of DB went OK, set configuration values to user supplied ones $pass = $_POST['admin_password'];
/** * Project: SmartyValidate: Form Validator for the Smarty Template Engine * File: SmartyValidate.class.php * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://www.phpinsider.com/php/code/SmartyValidate/ * @copyright 2001-2004 ispi of Lincoln, Inc. * @author Monte Ohrt <*****@*****.**> * @package SmartyValidate * @version 1.6 */ function smarty_function_validate($params, &$smarty) { if (!class_exists('SmartyValidate')) { $smarty->trigger_error("validate: missing SmartyValidate class"); return; } if (strlen($params['field']) == 0) { $smarty->trigger_error("validate: missing 'field' parameter"); return; } if (strlen($params['criteria']) == 0) { $smarty->trigger_error("validate: missing 'criteria' parameter"); return; } if (isset($params['trim'])) { $params['trim'] = SmartyValidate::booleanize($params['trim']); } else { $params['trim'] = false; } if (isset($params['empty'])) { $params['empty'] = SmartyValidate::booleanize($params['empty']); } else { $params['empty'] = false; } switch ($params['criteria']) { case 'notEmpty': case 'isInt': case 'isFloat': case 'isNumber': case 'isPrice': case 'isEmail': case 'isCCNum': case 'isCCExpDate': case 'isDate': break; case 'isEqual': if (strlen($params['field2']) == 0) { $smarty->trigger_error("validate: isEqual missing 'field2' parameter"); return; } break; case 'isRange': if (strlen($params['low']) == 0) { $smarty->trigger_error("validate: missing 'low' parameter"); return; } if (strlen($params['high']) == 0) { $smarty->trigger_error("validate: missing 'high' parameter"); return; } break; case 'isLength': if (strlen($params['min']) == 0) { $smarty->trigger_error("validate: missing 'min' parameter"); return; } if (strlen($params['max']) == 0) { $smarty->trigger_error("validate: missing 'max' parameter"); return; } break; case 'isRegExp': if (strlen($params['expression']) == 0) { $smarty->trigger_error("validate: isRegExp missing 'expression' parameter"); return; } break; case 'isCustom': if (strlen($params['function']) == 0) { $smarty->trigger_error("validate: isCustom missing 'function' parameter"); return; } if (!preg_match('!^\\w+(::\\w+)?$!', $params['function'])) { $smarty->trigger_error("validate: isCustom invalid 'function' parameter"); return; } break; default: $smarty->trigger_error("validate: unknown criteria '" . $params['criteria'] . "'"); return; break; } $_form = isset($params['form']) ? $params['form'] : 'default'; $_sess =& $_SESSION['SmartyValidate'][$_form]['validators']; $_found = false; if (isset($_sess) && is_array($_sess)) { foreach ($_sess as $_key => $_field) { if ($_field['field'] == $params['field'] && $_field['criteria'] == $params['criteria']) { // field exists $_found = true; if (isset($_sess[$_key]['valid']) && !$_sess[$_key]['valid']) { // not valid, show error and reset $_echo = true; if (isset($params['assign'])) { $smarty->assign($params['assign'], $_sess[$_key]['message']); $_echo = false; } if (isset($params['append'])) { $smarty->append($params['append'], $_sess[$_key]['message']); $_echo = false; } if ($_echo) { // no assign or append, so echo message echo $_sess[$_key]['message']; } $_sess[$_key]['valid'] = null; break; } } } } if (!$_found) { // create $_sess[] = $params; } }
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) { // ___ USER HAS NOT SENT FORM ___ SmartyValidate::register_form('exchanger', true); SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger'); $vMsg = array(); $vMsg['email'] = Pommo::_T('Invalid email address'); $smarty->assign('vMsg', $vMsg); $dbvals = array('exchanger' => $exchanger, 'email' => Pommo::$_config['admin_email']); $smarty->assign($dbvals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Json.php'; $json = new Pommo_Json(); if (SmartyValidate::is_valid($_POST, 'exchanger')) { // __ FORM IS VALID require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; $msg = Pommo_Helper_Messages::testExchanger($_POST['email'], $exchanger) ? Pommo::_T('Mail Sent.') : Pommo::_T('Error Sending Mail'); $json->success($msg); } else { // __ FORM NOT VALID $json->addMsg(Pommo::_T('Please review and correct errors with your submission.')); $json->add('fieldErrors', $smarty->getInvalidFields('exchanger')); $json->fail(); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/ajax.testexchanger.tpl'); Pommo::kill();
if (strlen(trim($data['RECPR_URL'])) > 0 && !preg_match('#^http[s]?:\\/\\/#i', $data['RECPR_URL'])) { $data['RECPR_URL'] = "http://" . $data['RECPR_URL']; } /*if (VISUAL_CONFIRM == 1 && !empty ($_POST['CAPTCHA'])) $data = array_merge ($data, array ('CAPTCHA' => $_POST['CAPTCHA']));*/ if (VISUAL_CONFIRM > 0) { $rc_resp = validateReCaptcha(); if ($rc_resp === true) { $tpl->assign('reCaptchaError', 1); } else { $tpl->assign('reCaptchaError', $rc_resp); } } else { $rc_resp = true; } if (SmartyValidate::is_valid($data, 'submit_link') && $rc_resp === true) { if (ENABLE_PAGERANK) { require_once 'include/pagerank.php'; $data['PAGERANK'] = get_page_rank($data['URL']); if (!empty($data['RECPR_URL'])) { $data['RECPR_PAGERANK'] = get_page_rank($data['RECPR_URL']); } } $id = $db->GenID($tables['link']['name'] . '_SEQ'); $data['ID'] = !empty($id) ? intval($id) : ''; $data['LINK_TYPE'] = $link_type_int[$link_type]; switch ($link_type) { case 'free': $data['NOFOLLOW'] = 1; break; case 'featured':