Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- require_once 'common.php';
- //require_once '../lib/editor.php';
- require '../lib/template.php';
- require_once("../lib/translator.php");
- set_time_limit(150);
- $translator = new Translator(1);
- $sent =(int)$sent;
- $id = (int)$id;
- $email_template = (int) $email_template;
- $email_from = SQLdecode($email_from);
- $email_toname = SQLdecode($email_toname);
- if(($email_from == "") or (!ereg("^.+@.+\\..+$", $email_from)))
- $email_from = "webmaster@".$SERVER_NAME;
- foreach($HTTP_POST_VARS as $sForm => $value) {
- //$postedValue = htmlentities( stripslashes( $HTTP_POST_VARS[$sForm] ) ) ;
- //$postedValue = htmlspecialchars( stripslashes( $HTTP_POST_VARS[$sForm] ) ) ;
- $postedValue = stripslashes( $HTTP_POST_VARS[$sForm] ) ;
- if($sForm=="EditorDefault") $content=$postedValue;
- }
- $contentReal=SQLdecode($content);
- $content=SQLdecode($content);
- //$content = $EditorContent1;
- $subject = $email_subject;
- /// remove slash - wrong preview
- if (get_magic_quotes_gpc()){
- $subject = stripslashes($subject);
- $content = stripslashes($content);
- }
- /*
- function mailque($dbconn, $email, $subject, $body, $headers) {
- $body=SQLdecode($body);
- $email=SQLdecode($email);
- $subject=SQLdecode($subject);
- $headers=SQLdecode($headers);
- $SQL = "insert into que (
- que_email,
- que_subject,
- que_body,
- que_headers
- )
- values
- (
- '$email',
- '$subject',
- '$body',
- '$headers'
- )";
- if(!pg_exec($dbconn, $SQL))
- echo "Error at ".$email."<br>";
- }
- $dbconnmail = pg_connect("host=localhost port=5432 user=maillist dbname=maillist");
- */
- // editor staff replace
- $content=str_replace("http://".$HTTP_HOST.dirname($PHP_SELF)."/", "", $content);
- $content=str_replace("\\\"","\"",$content);
- $content=str_replace("&","&",$content);
- $content=str_replace("/userimages/","http://".$HTTP_HOST."/userimages/",$content);
- // special chars replace
- $content=str_replace("€","€",$content);
- $content=str_replace("©","©",$content);
- $content=str_replace("®","®",$content);
- $content=str_replace("™","™",$content);
- $content=str_replace("’","'",$content);
- $content=str_replace("–","—",$content);
- if($sent == 1) {
- $subject;
- if (!$id) {
- $new_id = db_getid();
- $SQL = "insert into maillist_email(email_from, email_id, email_template, email_subject, email_html, email_images, email_name, email_date ) values ('".$email_from."',".$new_id.", $email_template, '".SQLDecode($email_subject)."', '".SQLDecode($contentReal)."','".SQLDecode($uploadedImages)."','".SQLDecode($email_name)."', '".date("Y.m.d h:i", strtotime("now"))."')";
- db_exec($DB_LINK, $SQL);
- $id = $new_id;
- }
- $SQLWHERE = " AND (";
- for ($i = 0; $i < count($mlgroup); $i++)
- $SQLWHERE .= ($i > 0 ? " OR " : "").db_concat(array("','", "maillist_group", "','"))." LIKE '%,".$mlgroup[$i].",%'";
- $SQLWHERE .= ")";
- if(count($mlgroup)){
- $SQL = "select distinct UPPER(TRIM(maillist_email)) as mailtosend, max(maillist_name) as finalname from maillist where maillist_active=".db_set_boolean(true)." ".$SQLWHERE." group by mailtosend ";
- $RES1 = db_exec($DB_LINK, $SQL);
- $NR=db_numrows($RES1);
- for($br=0;$br<$NR;$br++){
- if(checkEmail(db_result($RES1, $br, "mailtosend"))){
- $t = new Template("../email_templates", "remove");
- $SQL = "SELECT template_file FROM maillist_template, maillist_email WHERE email_id=".$id." AND email_template=template_id";
- $RS = db_exec(1, $SQL);
- $tf = db_result($RS, 0, "template_file");
- $t->set_file(array("page" => $tf));
- $t->set_var(array(
- "DATE" => date("F d Y", strtotime("now")),
- "NAME" => db_result($RES1, $br, "finalname"),
- "TITLE" => $subject,
- "BODY" => $content,
- "EMAILID"=> $id,
- "HOST" =>"http://".$HTTP_HOST,
- "DEAR" => $translator->translate("DEAR"),
- "Click_here" => $translator->translate("Click_here"),
- "removed_from_maillist" => $translator->translate("removed_from_maillist"),
- "Recomend_to_friend" => $translator->translate("Recomend_to_friend"),
- "EMAIL" => db_result($RES1, $br, "mailtosend")
- ));
- $t->parse("OUT", array("page"));
- $maillist_email = $t->get_var("OUT");
- mail(db_result($RES1, $br, "mailtosend"), $subject, $maillist_email, "From: $email_from\nContent-Type: text/html;\n charset=utf-8;\n");
- //mailque($dbconnmail, db_result($RES1, $br, "mailtosend"), $subject, $maillist_email, "From: (".$email_from.")\nContent-Type: text/html;\n charset=utf-8;\n");
- }
- if ($br>0 && $br%2==0) {sleep(15);}
- }
- }
- if(checkEmail($email_to)){
- $NR++;
- $t1 = new Template("../email_templates", "remove");
- $SQL1 = "SELECT template_file FROM maillist_template, maillist_email WHERE email_id=".$id." AND email_template=template_id";
- $RS1 = db_exec(1, $SQL1);
- $tf = db_result($RS1, 0, "template_file");
- $t1->set_file(array("page" => $tf));
- $t1->set_var(array(
- "DATE" => date("F d Y", strtotime("now")),
- "NAME" => $email_toname,
- "TITLE" => $subject,
- "BODY" => $content,
- "EMAILID"=> $id,
- "HOST" =>"http://".$HTTP_HOST,
- "EMAIL" => $email_to
- ));
- $t1->parse("OUT", array("page"));
- $maillist_email = $t1->get_var("OUT");
- mail($email_to, $subject, $maillist_email, "From: ($email_from)\nContent-Type: text/html;\n charset=utf-8;\n");
- }
- $resmessage = "Email Sent to ".($NR)." emails";
- }
- // preview the email
- if($sent == 2){
- $t = new Template("../email_templates", "remove");
- $SQL = "SELECT template_file FROM maillist_template WHERE template_id=$email_template";
- $RS = db_exec(1, $SQL);
- $tf = db_result($RS, 0, "template_file");
- $t->set_file(array("page" => $tf));
- $t->set_var(array(
- "DATE" => date("F d Y", strtotime("now")),
- "NAME" => "Sir/Madam",
- "TITLE" => $subject,
- "BODY" => $content,
- "HOST" => "http://".$HTTP_HOST,
- "EMAIL" => ""
- ));
- $t->parse("OUT", array("page"));
- $previewcontent = $t->get_var("OUT");
- echo $previewcontent;
- }
- // update in db
- if($sent == 3) {
- if($id){
- $SQL = "update maillist_email set email_from='".$email_from."',email_template = $email_template, email_subject = '".SQLDecode($email_subject)."', email_html = '".SQLDecode($contentReal)."', email_images='".SQLDecode($uploadedImages)."', email_date = '".date("Y.m.d h:i", strtotime("now"))."', email_name = '".SQLDecode($email_name)."' where email_id=$id";
- $resmessage = "Email Updated";
- }else{
- $SQL = "insert into maillist_email(email_from,email_id, email_template, email_subject, email_html, email_images, email_name, email_date ) values ('".$email_from."',".db_getid().", $email_template, '".SQLDecode($email_subject)."', '".SQLDecode($contentReal)."','".SQLDecode($uploadedImages)."','".SQLDecode($email_name)."', '".date("Y.m.d h:i", strtotime("now"))."')";
- $resmessage = "Email Added";
- }
- db_exec($DB_LINK, $SQL);
- }
- db_close();
- if($sent != 2 && $sent > 0){
- ?>
- <HTML>
- <HEAD>
- <link rel="stylesheet" href="style.css">
- <TITLE>Message</TITLE>
- </HEAD>
- <BODY bgcolor="#ffffff">
- <table height="100%" border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="#000000">
- <tr><td>
- <?
- echo "<center><h3>".$resmessage."</h3><br><br> <input type=button value='OK' onclick='window.close()'></center>";
- ?>
- </td>
- </tr>
- </TABLE>
- </BODY>
- </HTML>
- <?
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement