Пример #1
0
<?php

include "../util/session.php";
include_once "../util/mysql.php";
include "../mail/send.php";
include "../util/status.php";
include "../util/constants.php";
$dao = new DAO(false);
$user_id = $_POST["user_id"];
$group_id = $_POST["group_id"];
$member = DataObject::select_one($dao, "user", array("user_id", "user_email", "user_name"), array("user_id" => $user_id));
$group = DataObject::select_one($dao, "user_group", array("group_id", "group_name"), array("group_id" => $group_id));
if ($group != NULL) {
    if ($member != NULL) {
        if (NULL == DataObject::select_one($dao, "grouping_request", array("gr_id"), array("group_id" => $group_id, "user_id" => $user_id))) {
            $body = "<p>Hello " . $member->user_name . ",</p>\n\t\t\t\t<p>" . $user->user_name . " has asked you to join the group \"" . $group->group_name . "\".\n\t\t\t\t\tIf you would like to join, please click on this link: \n\t\t\t\t\t<a href=\"" . $SITE_URL . "script/grouping/confirm.php?group_id=" . $group_id . "\">Click here to join</a>.</p>\n\t\t\t\t<p>Best Wishes,<br>The Unify Team</p>";
            $request = DataObject::create($dao, "grouping_request", array("group_id" => $group_id, "user_id" => $user_id));
            $request->commit();
            //Put the request in the database. So long as this is here, the user can accept (only when logged in)
            mail_message($member->user_email, "Group Join Request", $body);
            echo Status::json(0, "Request sent :)");
        } else {
            echo Status::json(3, "Member has already been requested to join");
        }
    } else {
        echo Status::json(1, "Member not found");
    }
} else {
    echo Status::json(2, "Group not found");
}
Пример #2
0
#!/usr/bin/php -q
<?php 
//Scan database for notifications that have not been seen and are ready for departure
include_once "../util/mysql.php";
include "../mail/send.php";
include "../util/constants.php";
// chdir("..");
// error_log("\n\n");
// error_log("PHP_ini_loaded_file: ".php_ini_loaded_file());
// error_log("executable path: ".PHP_BINDIR);
// error_log("user: "******"Beginning to email notifications...");
$dao = new DAO(false);
$part = array("user_id", "user_email", "user_name", "notif_id", "notif_title", "notif_message", "notif_link");
$query = "SELECT user.user_id,user_email,user_name,notif_id,notif_title,notif_message,notif_link \n\t\t\t\tFROM notification \n\t\t\t\tJOIN user ON user.user_id=notification.user_id \n\t\t\t\tWHERE NOT notif_seen AND NOT notif_emailed\n\t\t\t\tAND notif_departure < NOW();";
$dao->myquery($query);
$notifications = $dao->fetch_all_obj();
foreach ($notifications as $notification) {
    $body = "<p>Hello " . $notification->user_name . ",</p>\n\t\t<p>" . $notification->notif_message . " <a href=\"" . $SITE_URL . "script/notification/see.php?notif_id=" . $notification->notif_id . "\">Click here to view</a>.</p>\n\t\t<p>Best Wishes,<br>The Unify Team</p>";
    mail_message($notification->user_email, $notification->notif_title, $body);
    $query = "UPDATE notification SET notif_emailed=\"1\" WHERE notif_id=\"" . $notification->notif_id . "\";";
    $dao->myquery($query);
}
error_log("Finished emailing notifications...");
Пример #3
0
<?php

include_once "../util/no_errors.php";
include "../util/session.php";
include "../mail/send.php";
$feedback_content = $_POST["feedback_content"];
$success = mail_message("*****@*****.**", "Site Feedback", "<p>A user has sent feedback about the site.</p><p>" . $user->user_email . ":<br>" . $feedback_content . "</p>");
$status = new stdClass();
$status->message = $success ? "Feedback sent" : "Failure to send feedback";
$status->code = $success ? 0 : 1;
echo json_encode($status);
echo "<h3>Thank you!</h3>";
echo "We'll get back to you by " . $deadline_str . ".<br/><br/>";
echo "Here is a copy of your order:<br/><br/>";
$subtotal = 0;
//Show what's in the cart
if ($_SESSION['cart']) {
    foreach ($_SESSION['cart'] as $id => $quantity) {
        $title = $_SESSION['inventory'][$id]['title'];
        $line_item_price = $_SESSION['inventory'][$id]['price'];
        $product_price = $line_item_price * $quantity;
        echo "Title: " . $title . "<br/>";
        echo "Price: \$" . number_format($line_item_price, 2) . "<br/><br/>";
        $subtotal += $product_price;
    }
}
echo "The subtotal is \$" . number_format($subtotal, 2) . "<br/>";
$tax = $subtotal * 0.08;
//cost with tax
echo "Tax= \$" . number_format($tax, 2) . "<br/>";
$shipping = 5.0;
//price for flat-rate shipping
echo "Shipping= \$" . number_format($shipping, 2) . "<br/><br/>";
$grand_total = $subtotal + $tax + $shipping;
echo "The total cost for your order is \$" . number_format($grand_total, 2) . "<br/><br/>";
echo "ORDER #" . time() . "<br/>";
echo "Order Date: " . date("F d, Y h:i a") . "<br/>";
echo "Name: " . $customer_firstname . " " . $customer_lastname . "<br/>";
echo "Email: " . $customer_email . "<br/>";
//DOCUMENT_ROOT is the file path leading up to the template name.
mail_message($customer_firstname, $customer_email, $grand_total);
include $_SERVER['DOCUMENT_ROOT'] . "/template_bottom.inc";
Пример #5
0
    $email_message = "";
    $email_addresses = array();
    if ($clean_key_value_pairs['form_type'] == 'permission_slip') {
        $error = permission_form_message($clean_key_value_pairs, $email_to, $email_subject, $email_message);
        array_push($email_addresses, $email_to);
        array_push($email_addresses, $email_to1);
    } else {
        $error = contact_form_message($clean_key_value_pairs, $email_to, $email_subject, $email_message);
        array_push($email_addresses, $email_to);
    }
    if (empty($error)) {
        //$jasonStrResponse .= mail_message($email_to1, $clean_key_value_pairs['subject'], $email_message);
        //$jasonStrResponse .= mail_message($email_to, $clean_key_value_pairs['subject'], $email_message);
        //$jasonStrResponse .= mail_message($email_to1, $email_subject, $email_message);
        //$jasonStrResponse .= mail_message($email_to, $email_subject, $email_message);
        error_log("About to send the message. email_addresses = " . print_r($email_address, 1), 0);
        foreach ($email_addresses as $email_address) {
            error_log("About to send the message. email_address = " . $email_address, 0);
            $jasonStrResponse .= mail_message($email_address, $email_subject, $email_message);
        }
    } else {
        $jasonStrResponse .= '{"error": "' . $error . '"}';
    }
    error_log("jasonStr = " . $jasonStr, 0);
    error_log("jasonStrResponse = " . $jasonStrResponse, 0);
    //echo '{"data": {"senderName":"'.$sender_name.'", "emailFrom":"'.$email_from.'", "subject":"'.$email_subject.'", "category":"'.$category.'", "message":"'.$email_message.'"} }';
    //echo '{"data": {"cat" : "meow 1"}}';
    //echo $jasonStr;
    echo $jasonStrResponse;
}
// end if ($_SERVER["REQUEST_METHOD"] == "POST")
Пример #6
0
    }
    // if
    $content = ob_get_contents();
    ob_end_clean();
    $content = "<pre>\n{$content}\n</pre>\n";
    if ($noexecmsg) {
        if (defined('LOG_NAME')) {
            $fp = fopen(LOG_NAME, 'a');
            fwrite($fp, "{$content}\n");
            fclose($fp);
        }
        // if
        // Весь выведенный на экран текст отправляем по мылу
        mail_message($content, LOG_TO, 'Отчёт ' . date('d.m.Y H:i:s O'));
        // Посылаем смс о выполнении скрипта на мобилу
        sms_message("Кол-во сообщений: {$nomsg}, обработано: {$noexecmsg}");
        // Всем пользоваетелям, кроме админа, рассылаем отчёты
        while (list($key, $val) = each($runs)) {
            $pos = strpos($mail_to[$key], LOG_TO);
            if ($pos === False) {
                mail_message("<pre>\n{$run_welcome}{$val}\n</pre>\n", $mail_to[$key], "{$key}: " . date('d.m.Y H:i:s O'));
            }
        }
        // while
    }
    // if
    //if ( $PHP_SELF )	// Если запуск из веб-сервера, то вывести в броузер
    echo $content;
    exit;
}
// if
Пример #7
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . "/template_top.inc";
$name = $_GET['name'];
$subject = $_GET['subject'];
list_evites($e, $subject);
foreach ($name as $key => $n) {
    //assign email variable to make life easier
    $e = $_GET['email'][$key];
    if (!($n && $e) || !filter_var($e, FILTER_VALIDATE_EMAIL)) {
        echo "{$n} at {$e} could not be invited, INVALID EMAIL<br>";
    } else {
        mail_message($n, $e, $subject, $_SERVER['DOCUMENT_ROOT'] . "eviteemail_template2.txt");
        echo "{$n} at {$e} is invited<br><br>";
    }
}
/*This function requires a single name and a single email address, which have already
  been validated, and a template file.*/
function mail_message($n, $e, $subject, $template_file)
{
    /*Extracts the message content from $template_file.
     */
    #get template contents, and replace variables with data
    $email_message = file_get_contents($template_file);
    $email_message = str_replace("#NAME#", $n, $email_message);
    $email_message = str_replace("#SUBJECT#", $subject, $email_message);
    #construct the email headers
    $to = $e;
    $from = "*****@*****.**";
    $email_subject = "CONTACT #" . time() . ": " . "Party Invitation";
    $headers = "From: " . $from . "\r\n";
Пример #8
0
     //If the confirmation has already been sent, just resend it. Don't craete a new confimation
     if (NULL != DataObject::select_one($dao, "confirmation", array("conf_id"), array("user_email" => $user_email))) {
         $send_email = true;
     } else {
         $conf = DataObject::create($dao, "confirmation", array("conf_rnd" => $rnd, "user_id" => $user->get_primary_id(), "user_email" => $user_email));
         if ($conf->commit()) {
             $send_email = true;
         } else {
             redirect("../../register/", array_merge(array("m" => "6"), $_POST));
             //This should never happen
         }
     }
     if ($send_email) {
         $subject = "Confirm your account";
         $body = "<p>Hello " . $user_name . ",</p>" . "<p>Thank you for joining Unify! Trust me, this is the best decision you've ever made.</p>" . "<p>Click <a href=\"" . $SITE_URL . "confirm.php?rnd={$rnd}\">CONFIRM</a> to confirm your account and to start using Unify.<br><br>" . "Click <a href=\"" . $SITE_URL . "unconfirm.php?rnd={$rnd}\">UNCONFIRM</a> if you have no idea why you are receiving this email." . " This will prevent this email address being used on Unify.</p>" . "<p>Best Wishes,<br>" . "The Unify Team</p>";
         $success = mail_message($user_email, $subject, $body);
         if (!$success) {
             redirect("../../register/", array_merge(array("m" => "5"), $_POST));
             //Could not send email
         } else {
             redirect("../../welcome/", array("m" => "4"));
             //Successful
         }
     } else {
         redirect("../../register/", array_merge(array("m" => "6"), $_POST));
         //Could not create account (insert into database)
     }
 } else {
     redirect("../../register/", array_merge(array("m" => "6"), $_POST));
     //Could not create account (insert into database)
 }
Пример #9
0
    $query = "SELECT user_email,user_id,user_name FROM user WHERE user_email=\"{$user_email}\";";
    $dao->myquery($query);
    if ($dao->fetch_num_rows() == 1) {
        //Store intent to reset in the database with a checksum as the old password?
        $user = $dao->fetch_one_obj();
        $names = explode(" ", $user->user_name);
        if (count($names) == 0) {
            $user_first_name = $user->user_name;
        } else {
            $user_first_name = $names[0];
        }
        $conf_rnd = md5("lsdfuh.uh3" . rand(0, 10000000) . "g.adugi213y");
        $query = "INSERT INTO reset_request VALUES (NULL,\"{$user->user_id}\",\"{$conf_rnd}\")" . "ON DUPLICATE KEY UPDATE conf_rnd=\"{$conf_rnd}\";";
        $dao->myquery($query);
        $body = "<p>Hello {$user_first_name},</p>" . "<p>It appears you are having trouble remembering your password for Unify. " . "As such, someone (hopefully you) has requested that you reset your password. " . "If you have no idea what's going on, feel free to take no further action, " . "it's possible someone entered your email by mistake or is dillberately trying to " . "confuse you. However, if you really do want to reset your password, click the " . "link below!</p>" . "<p><a href=\"http://unify.lukebarnard.co.uk/reset-password/confirm.php?user_id={$user->user_id}&conf_rnd={$conf_rnd}\">RESET YOUR PASSWORD</a></p>" . "<p>Best Wishes,<br>" . "The Unify Team</p>";
        if (mail_message($user_email, "Password Reset", $body)) {
            echo "A message has been sent to your email account. When you get the email, click on the link it contains and you will be taken to a page where you can reset your password. ";
        } else {
            echo "Something has gone wrong when trying to email you. <a href=\".\">Try again?</a>";
        }
    } else {
        echo "Your email could not be found in our database. Perhaps you made a mistake when typing it? <a href=\".\">Try again?</a>";
    }
} else {
    ?>
		<div id="main">
			<p>
				Please enter your email below so that a reset link can be sent to your email address. This is to confirm
				that the email address belongs to you.
			</p>
			<form method="POST">