Location: PHPKode > projects > Warp.cms - php/mysql content management > warp_121/ax_cxapp.php
<?php

// [warp administration module - contact messenger v.1.2.1] 
// xantis.warp.cms - version 1.2
// (c) 2002 xantis - all rights reserved
// this code is registered and protected by international copyrights laws


//####### Register Globals !

extract($HTTP_ENV_VARS);
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);

//#########################

$xnt_control_var = 'xnt2002warp.cms';

require("lib_adv.php");




//####################################################################### contacting app


function xcx_contacting_app () {

//----- secure checks
global	$wxu, $wxp;
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;

//---- cfg
global	$arr_var_result, $ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---- local
global $var_cxapp_op, $var_cxapp_eml_type, $var_cxapp_eml, $var_cxapp_subj, $var_cxapp_msg ;


$var_cxapp_eml = trim($var_cxapp_eml);

$var_cxapp_subj = trim($var_cxapp_subj);
$var_cxapp_subj = stripslashes($var_cxapp_subj);

$var_cxapp_msg = trim($var_cxapp_msg);
$var_cxapp_msg = stripslashes($var_cxapp_msg);

$varx_ymail_headers  = "MIME-Version: 1.0\r\n";
$varx_ymail_headers .= "Content-type: text/html; charset=iso-8859-1\r\n";



if ( empty($var_cxapp_subj) OR empty($var_cxapp_msg) ) {
	xtext_admin_error ('<br>ERROR : Empty fields are not allowed [`Subject` or `Message`] !');
	die('');
} //end if

switch ($var_cxapp_eml_type) {
	case '1':
		// only to the specified custom e-mail address
		if (empty($var_cxapp_eml)) {
			xtext_admin_error ('<br>ERROR : E-mail field cannot be empty for the option `Custom e-mail address` !');
			die('');
		} //end if
		if ( (!stristr($var_cxapp_eml, '@')) OR (!stristr($var_cxapp_eml, '.')) ) {
			xtext_admin_error ('<br>ERROR : E-mail address is not valid for the option `Custom e-mail address` !');
			die('');
		} //end if

		xnewline();
		xcenter_start();
		xtable_start_brd ('550');

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtable_start ('');
						xtable_row_start ();
							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xpict ("$ax_website_addr"."$ax_picts_dir".'/'.'contact_app.gif', '30', '30');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_title_admin ('&nbsp;Warp Contact Messenger&nbsp;');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_admin ('&nbsp;-Sending Report&nbsp;');
							xtable_column_end ();
						xtable_row_end ();
					xtable_end();
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Subject`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin (htmlspecialchars($var_cxapp_subj));
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Message [HTML Code]`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ($var_cxapp_msg);
				xtable_column_end ();
			xtable_row_end ();


			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail has been sent to the following recipients&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					mail($var_cxapp_eml, $var_cxapp_subj, $var_cxapp_msg, $varx_ymail_headers);
					xtext_admin (htmlspecialchars($var_cxapp_eml).'<br>');
					xhr_line ('100%');
					xtext_admin ('<i>Total : (1) recipient(s)</i>');
				xtable_column_end ();
			xtable_row_end ();
		xtable_end();
		xnewline();
		xtext_link_admin ('Return To Contact Form', "$ax_website_addr".'ax_cxapp.php', '_self');
		xcenter_end();
		xnewline();
		xnewline();
		break;
	case '2':
		// to all users that have been subscribed to receive e-mails
		xnewline();
		xcenter_start();
		xtable_start_brd ('550');

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtable_start ('');
						xtable_row_start ();
							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xpict ("$ax_website_addr"."$ax_picts_dir".'/'.'contact_app.gif', '30', '30');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_title_admin ('&nbsp;Warp Contact Messenger&nbsp;');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_admin ('&nbsp;-Sending Report&nbsp;');
							xtable_column_end ();
						xtable_row_end ();
					xtable_end();
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Subject`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin (htmlspecialchars($var_cxapp_subj));
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Message [HTML Code]`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ($var_cxapp_msg);
				xtable_column_end ();
			xtable_row_end ();


			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail has been sent to the following recipients&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xmysql_read_data_ax (" SELECT usr_email FROM users WHERE (w_subscr='y') ORDER BY id ASC ");
					//$arr_var_result
					for ($i=0; $i<count($arr_var_result); $i++) {
						$var_cxapp_eml = $arr_var_result[$i];
						mail($var_cxapp_eml, $var_cxapp_subj, $var_cxapp_msg, $varx_ymail_headers);
						xtext_admin (htmlspecialchars($var_cxapp_eml).'<br>');
					} //end for
					xhr_line ('100%');
					xtext_admin ('<i>Total : ('.count($arr_var_result).') recipient(s)</i>');
				xtable_column_end ();
			xtable_row_end ();
		xtable_end();
		xnewline();
		xtext_link_admin ('Return To Contact Form', "$ax_website_addr".'ax_cxapp.php', '_self');
		xcenter_end();
		xnewline();
		xnewline();
		break;
	case '3':
		// to all users with no exception
		xnewline();
		xcenter_start();
		xtable_start_brd ('550');

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtable_start ('');
						xtable_row_start ();
							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xpict ("$ax_website_addr"."$ax_picts_dir".'/'.'contact_app.gif', '30', '30');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_title_admin ('&nbsp;Warp Contact Messenger&nbsp;');
							xtable_column_end ();

							xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_admin ('&nbsp;-Sending Report&nbsp;');
							xtable_column_end ();
						xtable_row_end ();
					xtable_end();
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Subject`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin (htmlspecialchars($var_cxapp_subj));
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail `Message [HTML Code]`&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ($var_cxapp_msg);
				xtable_column_end ();
			xtable_row_end ();


			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xtext_admin ('<b>E-mail has been sent to the following recipients&nbsp;:</b>');
				xtable_column_end ();
			xtable_row_end ();

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_tx_color");
					xmysql_read_data_ax (" SELECT usr_email FROM users ORDER BY id ASC ");
					//$arr_var_result
					for ($i=0; $i<count($arr_var_result); $i++) {
						$var_cxapp_eml = $arr_var_result[$i];
						mail($var_cxapp_eml, $var_cxapp_subj, $var_cxapp_msg, $varx_ymail_headers);
						xtext_admin (htmlspecialchars($var_cxapp_eml).'<br>');
					} //end for
					xhr_line ('100%');
					xtext_admin ('<i>Total : ('.count($arr_var_result).') recipient(s)</i>');
				xtable_column_end ();
			xtable_row_end ();
		xtable_end();
		xnewline();
		xtext_link_admin ('Return To Contact Form', "$ax_website_addr".'ax_cxapp.php', '_self');
		xcenter_end();
		xnewline();
		xnewline();

		break;
	default :
		xtext_admin_error ('<br>ERROR : Invalid option for `Send To` !');
		die('');
} //end switch


} //end function


//#########################################################################################



//####################################################################### main


function xcx_contacting_showed () {

//----- secure checks
global	$wxu, $wxp;
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;

//---- cfg
global	$arr_var_result, $ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---- local
global $var_cxapp_op, $var_cxapp_eml_type, $var_cxapp_eml, $var_cxapp_subj, $var_cxapp_msg ;



	echo ('<br>');
	xcenter_start ();

	xform_start ('xcxapp_form', "$ax_website_addr".'ax_cxapp.php');

	xform_hidden ('var_cxapp_op', 'do_cx');

	xtable_start_brd('650');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");

				xtable_start ('');
					xtable_row_start ();
						xtable_column_start_vcenter ('1', '', "$ax_tx_color");
							xpict ("$ax_website_addr"."$ax_picts_dir".'/'.'contact_app.gif', '30', '30');
						xtable_column_end ();

						xtable_column_start_vcenter ('1', '', "$ax_tx_color");
								xtext_title_admin ('&nbsp;Warp Contact Messenger&nbsp;');
						xtable_column_end ();

						xtable_column_start_vcenter ('1', '', "$ax_tx_color");
							xtext_admin ('&nbsp;-Contact Form&nbsp;');
						xtable_column_end ();
					xtable_row_end ();
				xtable_end();

			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			$hmy_warn_txt_f_full = 'The `Contact Messenger` tool can be used to send e-mail messages to a specific e-mail address or to the registered users of the warp.cms website, using the registered e-mail addresses from the user accounts [users accounts are stored in table `users`].';
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_qe.'">'.'<b>Info : </b>'.xhtml_text ($hmy_warn_txt_f_full, 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");

				//sed to
				xnewline();
				xtext_admin ('&nbsp;&nbsp;<b>Send to :</b>');
				xcenter_start();

					xtable_start ('');
						xtable_row_start ();
							xtable_column_start_vcenter ('1', '', "$ax_tx_color");

								xform_radio_bttn_chk ('var_cxapp_eml_type', '1');
								xtext_admin ('<i>Custom e-mail address &nbsp;&nbsp;</i>');
								xform_text_box ('var_cxapp_eml', '100', '40', '');
								xnewline();
								xform_radio_bttn ('var_cxapp_eml_type', '2');
								xtext_admin ('<i>All users that have been subscribed for contacting </i>');
								xnewline();
								xform_radio_bttn ('var_cxapp_eml_type', '3');
								xtext_admin ('<i>All users with no exception </i>');

							xtable_column_end ();
						xtable_row_end ();
					xtable_end();

				xcenter_end();

				//subj
				xnewline();
				xnewline();
				xtext_admin ('&nbsp;&nbsp;<b>Subject :</b>');
				xcenter_start();
					xform_text_box ('var_cxapp_subj', '150', '75', htmlspecialchars('{Enter Subject Here}'));
				xcenter_end();

				//msg
				xnewline();
				xtext_admin ('&nbsp;&nbsp;<b>Message [HTML Code] :</b>');
				xcenter_start();
					$cx_hlckx_msg_plus = " \n<br>\n<br>\n<br>\n".
								"----------------------------------------------------<br>\n".
								"Info:<br>\n".
								"----------------------------------------------------<br>\n".
								"This e-mail is not spam !<br>\n".
								"If you wish to receive no more e-mails in the future from this ".
								"website go to the following address, log into your profile and ".
								"unsubscribe from receiving messages from this website :<br>\n".
								"<a href=\"$ax_website_addr\" target=\"_blank\">$ax_website_addr</a><br>\n".
								"----------------------------------------------------<br>\n" ;
					xform_text_area ('var_cxapp_msg', '60', '10', htmlspecialchars($cx_hlckx_msg_plus));
				xcenter_end();

				//bttn
				xnewline();
				xcenter_start();
					xform_send_bttn ('Send Message');
				xcenter_end();

			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

	xform_end();


	xcenter_end ();
	xnewline ();


} //end function


//#########################################################################################


//---------------------------------------------------------page header
xheader (':: warp.cms.admin .:. Contact Messenger ::', 'admin');
//---------------------------------------------------------


if ( (empty($var_cxapp_op)) OR ($var_cxapp_op == 'intro') ) {
	//--------------------------
	xcx_contacting_showed ();
	//--------------------------
} //end if
else {
	//--------------------------
	xcx_contacting_app ();
	//--------------------------
} //end else


//---------------------------------------------------------page footer
xfooter ();
//---------------------------------------------------------


//end of php code
?>
Return current item: Warp.cms - php/mysql content management