Example #1
0
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);
        }
    }
}
Example #2
0
<?php

// aggiungere nuovo protocollo per template
include ADMIN_DIR . 'panels/admin.defaultpanels.php';
include ADMIN_DIR . 'includes/panels.prototypes.php';
require SMARTY_DIR . 'SmartyValidate.class.php';
utils_nocache_headers();
define('MOD_ADMIN_PANEL', 1);
function wp_nonce_ays()
{
    die('We apologize, an error occurred.');
}
/*
function admin_is_user_loggedin() {
	return ($u=user_loggedin()) && utils_checkreferer() ;
}
*/
function main()
{
    // general setup
    global $panel, $action, $lang, $smarty, $fp_admin, $fp_admin_action;
    $panels = admin_getpanels();
    $panel = isset($_GET['p']) ? $_GET['p'] : $panels[0];
    define('ADMIN_PANEL', $panel);
    $smarty->assign('panel', $panel);
    if (!admin_panelexists($panel)) {
        trigger_error('Requested panel does not exists!', E_USER_ERROR);
    }
    $panelprefix = "admin.{$panel}";
    $panelpath = ADMIN_DIR . "panels/{$panel}/{$panelprefix}.php";
    $fp_admin = null;