"; // Select count of emails in queue per one message $query = "SELECT NotifyMsgs.ID, NotifyMsgs.Subj, COUNT(NotifyQueue.Email) AS `count_per_msg` FROM NotifyMsgs INNER JOIN NotifyQueue ON (NotifyQueue.Msg = NotifyMsgs.ID) GROUP BY NotifyMsgs.ID"; $res = db_res($query); if ( !mysql_num_rows($res) ) { echo " "; } else { while ($arr = mysql_fetch_array($res)) { echo " "; $queue_not_empty = true; } } echo "
Queue status:
There are no emails in queue
ID: {$arr['ID']} Subj: {$arr['Subj']} {$arr['count_per_msg']} emails

"; // Select count of messages in queue for cupid mails $arr_count = db_arr("SELECT COUNT(*) `count` FROM `NotifyQueue` WHERE `From` = 'ProfilesMsgText'"); $numrows = $arr_count['count']; if ( !$numrows ) { echo " "; } else { echo " "; $queue_not_empty = true; } echo "
Cupid mails status:
There are no emails in queue
{$numrows} emails

"; // If queue is not empty then show link to clear it if ( $queue_not_empty ) { echo "
Empty Queue

"; } echo " "; } function QueueMessage() { $msg_id = (int)$_POST['msgs_id']; $ret = ""; $query = "SELECT `ID` FROM `NotifyMsgs` WHERE `ID` = $msg_id"; $arr_arr = db_arr( $query ); if ( !$arr_arr ) { return "Failed to queue emails (ID: {$msg_id})."; } // Initially no emails queued $emails = 0; // Send to all emails in NotifyEmails table if ( $_POST['send_to_subscribers'] == 'on' ) { $res_eml = db_res( "SELECT `ID` FROM `NotifyEmails`" ); while ($arr_eml = mysql_fetch_array($res_eml)) { $res = db_res("SELECT `NotifyEmails`.`Email` FROM `NotifyQueue` INNER JOIN `NotifyEmails` ON (`NotifyQueue`.`Email` = `NotifyEmails`.`ID`) WHERE `NotifyQueue`.`Email` = {$arr_eml['ID']} AND `NotifyQueue`.`Msg` = $msg_id AND `From` = 'NotifyEmails'"); if ( $res && ($arr = mysql_fetch_array($res)) ) { $ret .= "Email(notify) {$arr['Email']} already exists in queue.
"; continue; } $res = db_res("INSERT INTO `NotifyQueue` SET `Email` = {$arr_eml['ID']}, `Msg` = $msg_id, `From` = 'NotifyEmails', `Creation` = NOW()"); if ( !$res ) { $ret .= "Email {$arr['Email']} was not added to queue.
"; continue; } $emails++; } } // Send to all profiles if ( $_POST['send_to_members'] == 'on' ) { // Sex filter $apply_filter = false; $vals = getFieldValues( 'Sex' ); foreach ( $vals as $v ) { if ( !isset($_POST["sex_{$v}"]) || $_POST["sex_{$v}"] != 'on' ) { $apply_filter = true; break; } } if ( $apply_filter ) { $sex_string_buffer = "'-1'"; foreach ( $vals as $v => $lang_val ) { if ( isset($_POST["sex_{$v}"]) && $_POST["sex_{$v}"] == 'on' ) $sex_string_buffer .= ",'{$v}'"; } } else { $sex_filter_sql = ''; } // Age filter $age_start = (int)$_POST['age_start']; $age_end = (int)$_POST['age_end']; if ( $age_start && $age_end ) { $date_start = (int)( date( "Y" ) - $age_start ); $date_end = (int)( date( "Y" ) - $age_end - 1 ); $date_start = $date_start . date( "-m-d" ); $date_end = $date_end . date( "-m-d" ); $age_filter_sql = "AND (TO_DAYS(`DateOfBirth`) BETWEEN TO_DAYS('{$date_end}') AND (TO_DAYS('{$date_start}')+1))"; } else { $age_filter_sql = ''; } // Country filter if ( $_POST['country'] != 'all' ) { $country = process_db_input($_POST['country']); $country_filter_sql = "AND `Country` = '{$country}'"; } else { $country_filter_sql = ''; } // Membership filter if ( $_POST['membership'] != 'all' ) { $membershipID = (int)$_POST['membership']; } else { $membershipID = -1; } $res_eml = db_res("SELECT `ID` FROM `Profiles` WHERE `Status` <> 'Unconfirmed' AND `EmailNotify` = 'NotifyMe' $sex_filter_sql $age_filter_sql $country_filter_sql"); while ($arr_eml = mysql_fetch_array($res_eml)) { // Dynamic membership filter $membership_info = getMemberMembershipInfo($arr_eml['ID']); if ( $membershipID != -1 && $membership_info['ID'] != $membershipID ) continue; $res = db_res("SELECT `Profiles`.`Email` FROM `NotifyQueue` INNER JOIN `Profiles` ON (`NotifyQueue`.`Email` = `Profiles`.`ID`) WHERE `NotifyQueue`.`Email` = {$arr_eml['ID']} AND `NotifyQueue`.`Msg` = $msg_id AND `From` = 'Profiles' "); if ( $res && ($arr = mysql_fetch_array($res)) ) { $ret .= "Email(profiles) {$arr['Email']} already exists in queue.
"; continue; } $res = db_res("INSERT INTO `NotifyQueue` SET `Email` = {$arr_eml['ID']}, `Msg` = $msg_id, `From` = 'Profiles', `Creation` = NOW()"); if ( !$res ) { $ret .= "Email {$arr['Email']} was not added to queue.
"; continue; } $emails++; } } $ret .= (int)$emails." emails was successfully added to queue."; return $ret; } function AddMessage() { $query = "INSERT INTO `NotifyMsgs` SET `Subj` = '". process_db_input($_POST['subj']) ."', `Text` = '". process_db_input(html2txt($_POST['body_html'])) ."',`HTML` = '". process_db_input($_POST['body_html']) ."'"; $res = db_res( $query ); if ( $res ) $_POST['msgs_id'] = mysql_insert_id(); return $res; } function UpdateMessage() { $query = "UPDATE `NotifyMsgs` SET `Subj` = '". process_db_input($_POST['subj']) ."', `Text` = '". process_db_input(html2txt($_POST['body_html'])) ."', `HTML` = '". process_db_input($_POST['body_html']) ."' WHERE ID = '". (int)$_POST['msgs_id'] ."'"; $res = db_res( $query ); return $res; } function PreviewMessage() { global $site; $body_html = process_pass_data( $_POST['body_html'] ); ContentBlockHead("Preview"); ?>
"; else $action_result .= "Message was not added.
"; } if ( !$demo_mode && $action == 'update' && $_POST['msgs_id'] && strlen($_POST['body_html']) ) { if ( UpdateMessage() ) $action_result .= "Message was updated.
"; else $action_result .= "Message was not updated.
"; } if ( !$demo_mode && $action == 'delete' && $_POST['msgs_id'] ) { if ( DeleteMessage() ) $action_result .= "Message was deleted.
"; else $action_result .= "Message was not deleted.
"; } if ( !$demo_mode && $action == 'empty' ) { if ( EmptyQueue() ) $action_result .= "Queue empty.
"; else $action_result .= "Queue emptying failed.
"; } if ( !$demo_mode && $action == 'queue' && $_POST['msgs_id'] ) { $action_result .= QueueMessage(); } if ( strlen($action_result) ) echo "
$action_result

\n"; PrintStatus(); // Print combobox with all messages ?>
Messages: 
 E-mail subject 
 HTML e-mail body 
 Text e-mail body 
 
 
 
Sex: $lang_v ) { echo "  "; } ?>
Age: from  to 
Country:
Membership level: