|
From: <go...@us...> - 2013-10-31 16:19:45
|
Revision: 12223
http://sourceforge.net/p/xoops/svn/12223
Author: goffy
Date: 2013-10-31 16:19:43 +0000 (Thu, 31 Oct 2013)
Log Message:
-----------
deleted not needed file (goffy)
Removed Paths:
-------------
XoopsModules/xnewsletter/trunk/xNewsletter/include/sendletter.php
Deleted: XoopsModules/xnewsletter/trunk/xNewsletter/include/sendletter.php
===================================================================
--- XoopsModules/xnewsletter/trunk/xNewsletter/include/sendletter.php 2013-10-30 22:40:04 UTC (rev 12222)
+++ XoopsModules/xnewsletter/trunk/xNewsletter/include/sendletter.php 2013-10-31 16:19:43 UTC (rev 12223)
@@ -1,305 +0,0 @@
-<?php
-/**
- * ****************************************************************************
- * - A Project by Developers TEAM For Xoops - ( http://www.xoops.org )
- * ****************************************************************************
- * XNEWSLETTER - MODULE FOR XOOPS
- * Copyright (c) 2007 - 2012
- * Goffy ( wedega.com )
- *
- * You may not change or alter any portion of this comment or credits
- * of supporting developers from this source code or any supporting
- * source code which is considered copyrighted (c) material of the
- * original comment or credit authors.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * ---------------------------------------------------------------------------
- * @copyright Goffy ( wedega.com )
- * @license GPL 2.0
- * @package xNewsletter
- * @author Goffy ( web...@we... )
- *
- * Version : $Id $
- * ****************************************************************************
- */
-
-if (!defined("XOOPS_ROOT_PATH")) {
- die("XOOPS root path not defined");
-}
-
-require_once( XOOPS_ROOT_PATH."/class/mail/phpmailer/class.phpmailer.php" );
-require_once( XOOPS_ROOT_PATH."/class/mail/phpmailer/class.pop3.php" );
-require_once( XOOPS_ROOT_PATH."/class/mail/phpmailer/class.smtp.php" );
-
-global $XoopsTpl;
-
-if (!isset($xoopsTpl) || !is_object($xoopsTpl)) {
- include_once(XOOPS_ROOT_PATH."/class/template.php");
- $xoopsTpl = new XoopsTpl();
-}
-
-$op = xNewsletter_CleanVars($_REQUEST, 'op', 'list', 'string');
-$letter_id = xNewsletter_CleanVars($_REQUEST, 'letter_id', 0, 'int');
-
-if ($letter_id == 0) {
- redirect_header("letter.php", 3, _AM_XNEWSLETTER_SEND_ERROR_NO_LETTERID);
-}
-
-//get template path
-$template_path = XOOPS_ROOT_PATH.'/modules/xNewsletter/language/'.$GLOBALS['xoopsConfig']['language'].'/templates/';
-if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH.'/modules/xNewsletter/language/english/templates/';
-if (!is_dir($template_path)) {
- redirect_header("letter.php", 5, str_replace("%p",$template_path, _AM_XNEWSLETTER_SEND_ERROR_INALID_TEMPLATE_PATH));
-}
-
-$obj_letter =& $letterHandler->get($letter_id);
-if (count($obj_letter)==0)
- redirect_header("letter.php", 3, _AM_XNEWSLETTER_SEND_ERROR_NO_LETTERID);
-
-//read categories
-$letter_cats = $obj_letter->getVar("letter_cats");
-if ( $letter_cats == "") { //no cats
- redirect_header("letter.php", 3, _MA_XNEWSLETTER_LETTER_NONEAVAIL);
-}
-
-if ($op=="send_test") {
- //check for valid email for testing
- $letter_email_test = $obj_letter->getVar("letter_email_test");
- if ($letter_email_test=="")
- redirect_header("letter.php", 3, _AM_XNEWSLETTER_SEND_ERROR_NO_EMAIL);
-}
-
-//read data of account
-$obj_account = $accountsHandler->get($obj_letter->getVar("letter_account"));
-$account_type = $obj_account->getVar("accounts_type");
-$account_yourname = $obj_account->getVar("accounts_yourname");
-$account_yourmail = $obj_account->getVar("accounts_yourmail");
-$account_username = $obj_account->getVar("accounts_username");
-$account_password = $obj_account->getVar("accounts_password");
-$account_server_out = $obj_account->getVar("accounts_server_out");
-$account_port_out = $obj_account->getVar("accounts_port_out");
-$account_securetype_out = $obj_account->getVar("accounts_securetype_out");
-
-//create basic mail body
-$letter_title = $obj_letter->getVar("letter_title");
-$letter_content = $obj_letter->getVar("letter_content", "n");
-
-$tpl = new XoopsTpl();
-$tpl->assign('content', $letter_content);
-$tpl->assign('unsubscribe_url', XOOPS_URL.'/modules/xNewsletter/');
-
-// read template
-$letter_template = $obj_letter->getVar("letter_template");
-
-//get emails of subscribers
-$recipients = array();
-if ($op=="send_test") {
- $recipients[] = array(
- "address"=> $letter_email_test,
- "firstname" => "John",
- "lastname" => "Doe",
- "subscr_sex" => "Mr.",
- "subscriber_id" => "0",
- "catsubscr_id" => "0",
- "subscriber_actkey" => "Test"
- );
-} else {
- //read all subscribers
- $sql = "SELECT subscr_id, subscr_email, subscr_firstname, subscr_lastname, subscr_sex, subscr_actkey ";
- $sql .= "FROM ".$xoopsDB->prefix("xnewsletter_subscr")." INNER JOIN ".$xoopsDB->prefix("xnewsletter_catsubscr")." ON subscr_id = catsubscr_subscrid ";
- $sql .= "WHERE subscr_activated=1 AND (((catsubscr_catid) In (";
- $sql .= str_replace("|",",",$letter_cats);
- $sql .= "))) GROUP BY subscr_id, subscr_email, subscr_firstname, subscr_lastname, subscr_sex;";
-
- $subscribers = $xoopsDB->query($sql) or die();
-
- while ($subscriber = mysql_fetch_assoc($subscribers)) {
- //echo "subscr_email:".$subscriber["subscr_email"]
- $subscr_id = $subscriber["subscr_id"];
- if ($op == 'resend_letter') {
- //read subscribers, where send failed
- $protocol_crit = new CriteriaCompo();
- $protocol_crit->add(new Criteria("protocol_letter_id", $letter_id));
- $protocol_crit->add(new Criteria("protocol_subscriber_id", $subscr_id));
- $protocol_crit->add(new Criteria("protocol_success", 1));
- $protocol_numrows = $protocolHandler->getCount($protocol_crit);
- if ($protocol_numrows > 0) $subscr_id = 0; //letter already successfully sent
- }
- if ($subscr_id > 0) {
- if ($subscriber["subscr_actkey"] == "") {
- $u = $subscrHandler->get($subscr_id);
- $subscriber["subscr_actkey"] = xoops_makepass();
- $u->setVar("subscr_actkey", $subscriber["subscr_actkey"] );
- $subscrHandler->insert($u);
- unset($u);
- }
- $recipients[] = array(
- "address"=> $subscriber["subscr_email"],
- "firstname" => $subscriber["subscr_firstname"],
- "lastname" => $subscriber["subscr_lastname"],
- "subscr_sex" => $subscriber["subscr_sex"],
- "subscriber_id" => $subscriber["subscr_id"],
- "subscriber_actkey" => $subscriber["subscr_actkey"]
- );
- }
- }
-}
-//read attachments
-$attachment_crit = new CriteriaCompo();
-$attachment_crit->add(new Criteria("attachment_letter_id", $letter_id));
-$attachment_crit->setSort("attachment_id");
-$attachment_crit->setOrder("ASC");
-$att_numrows= $attachmentHandler->getCount($attachment_crit);
-if ($att_numrows > 0) {
- $attachment_arr = $attachmentHandler->getall($attachment_crit);
- foreach (array_keys($attachment_arr) as $attid) {
- $uploaddir = XOOPS_UPLOAD_PATH.$xoopsModuleConfig['xn_attachment_path'].$letter_id."/";
- $attachments[] = $uploaddir.$attachment_arr[$attid]->getVar("attachment_name");
- }
-} else {
- $attachments = array();
-}
-
-$senderuid = $xoopsUser->uid();
-$count_total = 0;
-$count_err = 0;
-
-try {
-
- if ($account_type == _AM_ACCOUNTS_TYPE_VAL_PHP_SENDMAIL) {
- $pop = new POP3();
- $pop->Authorise($account_server_out, $account_port_out, 30, $account_username, $account_password, 1);
- }
-
- $mail = new PHPMailer();
-
- $mail->CharSet = _CHARSET; //use xoops default character set
-
- if ($account_type == _AM_ACCOUNTS_TYPE_VAL_PHP_SENDMAIL) {
- //$mail->IsSendmail(); Fix Error
- }
-
- $mail->Username = $account_username; // SMTP account username
- $mail->Password = $account_password; // SMTP account password
-
- if ($account_type == _AM_ACCOUNTS_TYPE_VAL_POP3) {
- $mail->IsSMTP();
- //$mail->SMTPDebug = 2;
- $mail->Host = $account_server_out;
- }
-
- if ($account_type == _AM_ACCOUNTS_TYPE_VAL_SMTP || $account_type == _AM_ACCOUNTS_TYPE_VAL_GMAIL) {
- $mail->Port = $account_port_out; // set the SMTP port
- $mail->Host = $account_server_out; //sometimes necessary to repeat
- }
-
- if ($account_securetype_out !="") {
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = $account_securetype_out; // sets the prefix to the server
- }
-
- $mail->SetFrom($account_yourmail, $account_yourname);
- $mail->AddReplyTo($account_yourmail, $account_yourname);
- $mail->Subject = $letter_title;
-
- foreach ($recipients as $recipient) {
- $subscriber_id = $recipient["subscriber_id"];
-
- $tpl->assign('sex', $recipient["subscr_sex"]);
- $tpl->assign('firstname', $recipient["firstname"]);
- $tpl->assign('lastname', $recipient["lastname"]);
- $tpl->assign('subscr_email', $recipient["address"]);
-
- $code = XOOPS_URL . "||" . $subscriber_id . "||" . $recipient["subscriber_actkey"] . "||" . $recipient["address"];
- $code = base64_encode( $code );
- $link = XOOPS_URL . "/modules/xNewsletter/subscription.php?op=unsub&email=" . $recipient["address"] . "&actkey=" . $code;
- $tpl->assign('unsubscribe_link', $link);
-
- $body = $tpl->fetch($template_path.$letter_template.'.html');
-
- $mail->AddAddress($recipient["address"], $recipient["firstname"]." ".$recipient["lastname"]);
-
- //$mail->AltBody = _AM_XNEWSLETTER_LETTER_EMAIL_ALTBODY;
-
- $mail->MsgHTML($body);
- $mail->AltBody = strip_tags($body . "\n" . $link);
-
- foreach ($attachments as $attachment) {
- if ( file_exists($attachment)) $mail->AddAttachment($attachment);
- }
- $count_total ++;
- $mail->Send();
- $protocol_status = _AM_XNEWSLETTER_SEND_SUCCESS;
- $protocol_success = "1";
- //create item in protocol for this email
- $text_clean = array("<strong>", "</strong>", "<br/>", "<br />");
- $protocol_status = str_replace($text_clean,"",$protocol_status);
-
- $protocolHandler =& xoops_getModuleHandler("xNewsletter_protocol", "xNewsletter");
- $obj_protocol =& $protocolHandler->create();
- $obj_protocol->setVar("protocol_letter_id", $letter_id);
- $obj_protocol->setVar("protocol_subscriber_id", $subscriber_id);
- $obj_protocol->setVar("protocol_status", $protocol_status);
- $obj_protocol->setVar("protocol_success", $protocol_success);
- $obj_protocol->setVar("protocol_submitter", $senderuid);
- $obj_protocol->setVar("protocol_created", time());
-
- if ($protocolHandler->insert($obj_protocol)) {
- //create protocol is ok
- } else {
- echo $obj_protocol->getHtmlErrors();
- }
-
- $mail->ClearAddresses();
-
- }
-
- unset($mail);
-
-} catch (phpmailerException $e) {
- $protocol_status = _AM_XNEWSLETTER_SEND_ERROR_PHPMAILER . $e->errorMessage(); //error messages from PHPMailer
- $count_err ++;
- $protocol_success = "0";
-} catch (Exception $e) {
- $protocol_status = _AM_XNEWSLETTER_SEND_ERROR_PHPMAILER . $e->getMessage(); //error messages from anything else!
- $count_err ++;
- $protocol_success = "0";
-}
-
-//create final protocol item
-if ($count_err > 0) {
- $protocol_status = _AM_XNEWSLETTER_SEND_ERROR_NUMBER;
- $protocol_status = str_replace("%e",$count_err,$protocol_status);
- $protocol_status = str_replace("%t",$count_total,$protocol_status);
- $protocol_success = 0;
-} else {
- $protocol_success = 1;
- if ($op=="send_test") {
- $protocol_status = _AM_XNEWSLETTER_SEND_SUCCESS_TEST;
- } else {
- $protocol_status = _AM_XNEWSLETTER_SEND_SUCCESS_NUMBER;
- $protocol_status = str_replace("%t",$count_total,$protocol_status);
- }
-
-}
-//create item in protocol
-$protocolHandler =& xoops_getModuleHandler("xNewsletter_protocol", "xNewsletter");
-$obj_protocol =& $protocolHandler->create();
-$obj_protocol->setVar("protocol_letter_id", $letter_id);
-$obj_protocol->setVar("protocol_subscriber_id", "0");
-$obj_protocol->setVar("protocol_status", $protocol_status);
-$obj_protocol->setVar("protocol_success", $protocol_success);
-$obj_protocol->setVar("protocol_submitter", $senderuid);
-$obj_protocol->setVar("protocol_created", time());
-
-if ($protocolHandler->insert($obj_protocol)) {
- //create protocol is ok
- redirect_header("letter.php", 3, $protocol_status);
-} else {
- echo $obj_protocol->getHtmlErrors();
-}
-
-?>
\ No newline at end of file
|