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); } } }
function commentform() { global $smarty, $lang, $fpdb, $fp_params; $comment_formid = 'fp-comments'; $smarty->assign('comment_formid', $comment_formid); if (!empty($_POST)) { # utils_nocache_headers(); // add http to url if (!empty($_POST['url']) && strpos($_POST['url'], 'http://') === false) { $_POST['url'] = 'http://' . $_POST['url']; } // custom hook here!! if ($arr = comment_validate()) { global $fp_config; $id = comment_save($fp_params['entry'], $arr); do_action('comment_post', $fp_params['entry'], array($id, $arr)); $q = new FPDB_Query(array('id' => $fp_params['entry'], 'fullparse' => false), null); list($entryid, $e) = $q->getEntry(); if ($fp_config['general']['notify'] && !user_loggedin()) { global $post; $comm_mail = isset($arr['email']) ? "<{$arr['email']}>" : ''; $from_mail = $fp_config['general']['email']; $post = $e; // plugin such as prettyurls might need this... $lang = lang_load('comments'); $mail = str_replace(array('%toname%', '%fromname%', '%frommail%', '%entrytitle%', '%commentlink%', '%content%', '%blogtitle%'), array($fp_config['general']['author'], $arr['name'], $comm_mail, $e['subject'], get_comments_link($entryid) . '#' . $id, $arr['content'], $fp_config['general']['title']), $lang['comments']['mail']); @utils_mail($from_mail, "New comment on {$fp_config['general']['title']}", $mail); } // if comment is valid, this redirect will clean the postdata $location = str_replace('&', '&', get_comments_link($entryid)) . '#' . $id; utils_redirect($location, true); exit; } else { $smarty->assign('values', $_POST); } } // Cookies $smarty->assign('cookie', array('name' => @$_COOKIE['comment_author_' . COOKIEHASH], 'email' => @$_COOKIE['comment_author_email_' . COOKIEHASH], 'url' => @$_COOKIE['comment_author_url_' . COOKIEHASH])); }