Location: PHPKode > scripts > Weight Loss Recipe Book > weight-loss-recipe-book/wlrb_files/functions/functions_mailing_list.php
<?php
	function replace_mailing_list_vars($content,$in_html=1,$issue='') {
		global $cm_options;
		$content = str_replace('%7B','{',$content);
		$content = str_replace('%7D','}',$content);
		$content = str_replace('{issue_number}',$issue['mailing_list_archive_order'],$content);
		$content = str_replace('{issue_title}',$issue['mailing_list_archive_subject'],$content);
		$content = str_replace('{admin_email}',$_SESSION['cm_admin_email'],$content); 
		$content = str_replace('{admin_name}',$_SESSION['cm_admin_name'],$content); 
		$content = str_replace('{current_date_full}',date('F jS, Y'),$content); 
		$content = str_replace('{current_date}',date('n/j/Y'),$content); 
		$content = str_replace('{current_time}',date('g:i a'),$content); 
		$content = str_replace('{current_year}',date('Y'),$content); 
		$content = str_replace('{absolute_url}',$settings['absolute_url'],$content); 
		$content = str_replace('{email_admin}',$cm_options['admin_email'],$content); 
		$content = str_replace('{email_orders}',$cm_options['orders_email'],$content); 
		$content = str_replace('{email_contact}',$cm_options['contact_email'],$content); 
		$content = str_replace('{company_name}',$cm_options['business_name'],$content); 
		$content = str_replace('{company_address_1}',$cm_options['business_address_1'],$content);
		$content = str_replace('{company_address_2}',$cm_options['business_address_2'],$content);
		$content = str_replace('{company_city}',$cm_options['business_city'],$content);
		$content = str_replace('{company_state}',$cm_options['business_state'],$content);
		$content = str_replace('{company_zip}',$cm_options['business_zip'],$content);
		$content = str_replace('{company_phone_local}',$cm_options['store_phone_local'],$content);
		$content = str_replace('{company_phone_toll_free}',$cm_options['store_phone_toll_free'],$content);
		$content = str_replace('{home_page_url}',$cm_options['home_page'],$content);
		$content = str_replace('{home_page_name}',$cm_options['home_page_name'],$content);
		if ($signature == '') {
			if ($in_html != 1) {
				$content = str_replace('{signature}',$cm_options['email_signature_txt'],$content);
				$content = str_replace('{admin_signature}',$_SESSION['cm_admin_email_sig_txt'],$content);
			} else {
				$content = str_replace('{signature}',$cm_options['email_signature_html'],$content);
				$content = str_replace('{admin_signature}',$_SESSION['cm_admin_email_sig_html'],$content);
			}
		}
		return $content;
	}
	
	function generateListIssue($list_id,$issue_id) {
		global $settings;
		$result = mysql_query('
			SELECT *
			FROM mailing_lists
			WHERE mailing_lists_id = "' . $list_id . '"');
		$list = mysql_fetch_array($result);
		$result = mysql_query('
			SELECT *
			FROM mailing_list_archive
			WHERE mailing_list_archive_id = "' . $issue_id . '"');
		$issue = mysql_fetch_array($result);
		$subject = $list['mailing_lists_subject'];
		$subject = str_replace('{issue_number}',$issue['mailing_list_archive_order'],$subject);
		$subject = str_replace('{issue_title}',$issue['mailing_list_archive_subject'],$subject);
		$html_content = replace_mailing_list_vars($issue['mailing_list_archive_content_html'],1,$issue);
		$html_content = '
			<head>
				<link rel="stylesheet" type="text/css" href="' . $settings['absolute_url'] . '/projects/styles/mailing-list-templates.css">
			</head><body>' . $html_content . '</body>';
		$txt_content = replace_mailing_list_vars($issue['mailing_list_archive_content_txt'],0,$issue);
		$issue['subject'] = $subject;
		$issue['html_content'] = $html_content;
		$issue['txt_content'] = $txt_content;
		$issue['from'] = $list['mailing_lists_admin_email'];
		$issue['issue_id'] = $issue['mailing_list_archive_id'];
		return $issue;
	}
	
	function sendListIssue($subscriber_array,$issue_array,$send_date,$noupdate=0) {
		$to = $subscriber_array['mailing_list_subscribers_email'];
		$from = $issue_array['from'];
		$subject = $issue_array['subject'];
		if ($subscriber_array['mailing_list_subscribers_prefers_text_email'] != 1) {
			$is_html = 1;
			$message = $issue_array['html_content'];
		} else {
			$message = $issue_array['txt_content'];
		}
		$message = str_replace('%7Bid%7D',$subscriber_array['mailing_list_subscribers_id'],$message);
		$message = str_replace('{id}',$subscriber_array['mailing_list_subscribers_id'],$message);
		sendEmail($to, $subject, $message,$issue_array['from'], $extra_headers, $is_html,'',$send_date);
		$new_number_sent = $subscriber_array['mailing_list_subscribers_num_sent'] + 1;
		if ($noupdate != 1) {
			$update = mysql_query('
				UPDATE mailing_list_subscribers
				SET  mailing_list_subscribers_num_sent = "' . $new_number_sent . '"');
			$update = mysql_query('
				UPDATE mailing_list_archive
				SET mailing_list_archive_been_sent = 1
				WHERE mailing_list_archive_id = "' . $issue_array['issue_id'] . '"');
		}
		return true;
	}
?>
Return current item: Weight Loss Recipe Book