Esempio n. 1
0
<?php

include '../../login/dbc.php';
session_start();
require 'PHPMailer-master/PHPMailerAutoload.php';
function checkEmail($str)
{
    return preg_match("/^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4})\$/", $str);
}
switch ($_GET['action']) {
    case 'sendInvite':
        sendInvite();
        break;
    case 'sendConfirmation':
        send_confirmation();
        break;
}
function sendInvite()
{
    function get_include_contents($filename, $variablesToMakeLocal)
    {
        extract($variablesToMakeLocal);
        if (is_file($filename)) {
            ob_start();
            include $filename;
            return ob_get_clean();
        }
        return false;
    }
    $emailData = $_POST['emailData'];
    foreach ($emailData as $key) {
function put_user_in_db_list($list_id)
{
    global $all_lists;
    $email_address = $_GET['email'];
    //check for existing by email address
    tep_db_list_connect();
    $existing_email_query = tep_db_list_query("select id, email from " . PHPLIST_TABLE_PREFIX . "user_user where email = '" . $email_address . "'");
    $history_systeminfo_text = "\nHTTP_USER_AGENT = " . $_SERVER["HTTP_USER_AGENT"] . "\nREMOTE_ADDR = " . $_SERVER["REMOTE_ADDR"] . "";
    $history_detail_text = "";
    $getListName_query = tep_db_list_query('SELECT name FROM ' . PHPLIST_TABLE_PREFIX . 'list WHERE id = "' . $list_id . '"');
    $getListName = tep_db_fetch_array($getListName_query);
    $listName = $getListName['name'];
    $firstname = $_GET['name'];
    if (isset($_GET['subscribe'])) {
        //subscribe logic
        if (tep_db_num_rows($existing_email_query) < 1) {
            //no existing user by email address found (therefore a new user - no id or email found)
            //generate unique id and add new user to database
            $id = md5(uniqid(mt_rand(0, 1000) . $email_address));
            //insert the new user into phplist
            tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "user_user (email, confirmed, subscribepage, entered, modified, disabled, uniqid, htmlemail) \n\t\t\tvalues ('" . $email_address . "', 1, " . PHPLIST_SPAGE . ", now(), now(), 0, '" . $id . "', " . PHPLIST_HTMLEMAIL . ")");
            //get the new user's phplist id
            $user_query = tep_db_list_query("select id from " . PHPLIST_TABLE_PREFIX . "user_user where email = '" . $email_address . "'");
            $user = tep_db_fetch_array($user_query);
            //subscribe the new user to the correct list
            tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "listuser (userid, listid, entered) values (" . $user['id'] . ", " . $list_id . ", now())");
            //generating history
            $history_detail_text .= "\nSubscribepage = " . PHPLIST_SPAGE . "\n";
            $history_detail_text .= "" . $attribute_name[name] . " = " . $firstname . "\n";
            tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "user_user_history (userid, ip, date, summary, detail, systeminfo) values (" . $user['id'] . ", '" . $_SERVER["REMOTE_ADDR"] . "', '" . date('Y-m-d H:i:s') . "', 'Update through osC', '" . $history_detail_text . "', '" . $history_systeminfo_text . "')");
            //create history post
            $all_lists .= $listName . ', ';
            $return = '1';
        } else {
            //subscribe the existing user if disabled
            $existing_email = tep_db_fetch_array($existing_email_query);
            //existing user by email found
            tep_db_list_query("update " . PHPLIST_TABLE_PREFIX . "user_user set disabled = 0, confirmed = 1 where id = " . $existing_email['id'] . "");
            //check to see if they already are subscribed to the correct list
            $list_query = tep_db_list_query("select * from " . PHPLIST_TABLE_PREFIX . "listuser where userid = " . $existing_email['id'] . " and listid = " . $list_id . "");
            if ($list = tep_db_num_rows($list_query) < 1) {
                //no existing subscription to the newsletter found
                //generating history, previous subscriptions
                $history_detail_text .= "\n\nList subscriptions:\n";
                //subscribe the new user to the correct list
                tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "listuser (userid, listid, entered) values (" . $existing_email['id'] . ", " . $list_id . ", now())");
                $all_lists .= $listName . ', ';
                send_confirmation($HTTP_POST_VARS['name'], $_GET['email'], $listName);
                $return = '1';
            } else {
                $all_lists .= $listName . ', ';
                $return = '2';
            }
            tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "user_user_history (userid, ip, date, summary, detail, systeminfo) values (" . $existing_email['id'] . ", '" . $_SERVER["REMOTE_ADDR"] . "', '" . date('Y-m-d H:i:s') . "', 'Update through osC', '" . $history_detail_text . "', '" . $history_systeminfo_text . "')");
            //create history post
        }
        tep_db_list_close();
        tep_db_connect();
        return $return;
    } else {
        if (isset($_GET['unsubscribe'])) {
            //unsubscribe logic
            if (tep_db_num_rows($existing_email_query) > 0) {
                $history_detail_text = "\n";
                $existing_email = tep_db_fetch_array($existing_email_query);
                $testid = $existing_email['id'];
                $delete_subscription_query = tep_db_list_query("delete from " . PHPLIST_TABLE_PREFIX . "listuser where listid = '" . $list_id . "' and userid = '" . $existing_email['id'] . "'");
                mysql_query("delete from " . PHPLIST_TABLE_PREFIX . "listuser where listid = '" . $list_id . "' and userid = '" . $existing_email['id'] . "'") or die(mysql_error());
                tep_db_list_query("insert into " . PHPLIST_TABLE_PREFIX . "user_user_history (userid, ip, date, summary, detail, systeminfo) values (" . $existing_email['id'] . ", '" . $_SERVER["REMOTE_ADDR"] . "', '" . date('Y-m-d H:i:s') . "', 'Update through osC', '" . $history_detail_text . "', '" . $history_systeminfo_text . "')");
                //create history post
                $all_lists .= $listName . ', ';
                tep_db_list_close();
                tep_db_connect();
                return '3';
            }
        }
    }
    tep_db_list_close();
}
Esempio n. 3
0
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package bookingwp
 */
$result = Ipn();
if ($result) {
    wp_reset_query();
    $booking = new WP_Query(array('post_type' => 'bookings', 'meta_key' => 'token', 'meta_value' => $result['item_number'], 'posts_per_page' => 1));
    while ($booking->have_posts()) {
        $booking->the_post();
        set_booked(get_the_id());
        send_confirmation(get_the_id());
        $message = 'reservation id = ' . get_the_id() . ' code ' . $result['item_number'] . "\r\n";
        $message .= 'payment status = ' . $result['payment_status'] . "\r\n";
        $message .= 'details = ' . $result['item_name'] . "\r\n";
        $subject = 'Conferma pagamento Paypal #' . $result['item_number'];
        //$headers = 'From: IPN Notification <*****@*****.**>' . "\r\n";
        $headers[] = 'From: IPN Notification <' . booking_get_option('bookingwp_paypal_email') . '>';
        $headers[] = 'Bcc: IPN <' . booking_get_option('bookingwp_paypal_email') . '>';
        //$headers[] = 'Cc: iluvwp@wordpress.org'; // note you can just use a simple email address
        wp_mail('*****@*****.**', $subject, $message, $headers);
    }
} else {
    wp_redirect(get_bloginfo('siteurl'), '301');
    exit;
}
Esempio n. 4
0
if (!validate_email($email)) {
    die("We have an error in the email address!");
}
// Check to see if the two passwords are exactly the same.
if ($pass1 != $pass2) {
    die("Passwords do not match!");
}
// We have an error again!
// Create the digest of the password
$digest = md5(trim($pass1));
// If we are here then this user must be ok to add to the table
$query = "INSERT INTO users (user_id, user_name, email, password, confirmed) VALUES ( 'NULL', '{$user_name}', '{$email}', '{$digest}', 'false' )";
if (!@mysql_query($query, $connection)) {
    showerror();
} else {
    send_confirmation($user_name, $email);
    header("Location: createdone.php?email=" . $email);
}
function send_confirmation($user_name, $email)
{
    // Create a new template, and specify that the template files are
    // in the same directory as the as the php files.
    $template = new HTML_Template_IT("./templates");
    // Load the email template file
    $template->loadTemplatefile("confirmemail.tpl", true, true);
    $template->setVariable("USERNAME", $user_name);
    $template->setVariable("EMAIL", $email);
    $to = $email;
    // Setup the headers.
    $headers["From"] = "*****@*****.**";
    $headers["Subject"] = "Fitness Log Confirmation Email";