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); } } }
*/ /********************************** INITIALIZATION METHODS *********************************/ require '../bootstrap.php'; Pommo::init(); $logger =& Pommo::$_logger; $dbo =& Pommo::$_dbo; /********************************** SETUP TEMPLATE, PAGE *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Template.php'; $smarty = new Pommo_Template(); $smarty->prepareForForm(); $exchanger = current(Pommo_Api::configGet(array('list_exchanger'))); SmartyValidate::connect($smarty); 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';
} else { $tpl->assign('sql_error', $db->ErrorMsg()); } 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.');
#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'); } } } ?>
function Init($locations) { // Set up all Smarty default settings $root = any($locations["root"], "."); $tmpdir = any($locations["tmp"], "./tmp"); $this->setTemplateDir($root . '/templates'); $this->setCompileDir($tmpdir . '/compiled'); $this->setCacheDir($tmpdir . '/cache'); //$this->config_dir = $root . '/text/'.LANGUAGE; $this->_file_perms = 0664; $filepaths = file_find_paths("include/smarty/plugins"); foreach ($filepaths as $fp) { $this->addPluginsDir($fp); } //$this->load_filter("output", "varreplace"); if (class_exists("SmartyValidate")) { // 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; } */ }