Location: PHPKode > projects > VSecure > send_message.php
<?php
/*******************************************************************/
/*                         Vsecurity                               */
/*        Copyrights(C)2001 Jan Vilimek(hide@address.com)         */
/*               See GPL license in file license.txt               */
/*           and http://www.guanoweb.cz for more details           */
/*                                                                 */
/* Function: Secure your pages  (send_message)                     */
/* for instalation see readme.txt                                  */
/*******************************************************************/
/*sends a mail to all users (or part of those)*/

/*if you have large database, then increase this value (-1 - unlimited)*/
//@set_time_limit(600);

include dirname(__FILE__)."/security.php";

xhtml_header("VSecure send message",true,true);

if ($user_status!="admin")
 {
 alert("Acces not allowed....");
 die("acces not allowed...");
 }

if ($action=="send")
 {
 
 $qw="SELECT login,email,name FROM `$VSecure_tbl_usr` ";
 if (($filter!="")||($sql_qw!="")||($only_logins!="")) $qw.="WHERE ";
 if ($only_logins!="")
  {
  $only_logins=explode (" ", $only_logins);
  $i=0;
  $lg="";
  while ($only_logins[$i])
   {
   if (strlen($only_logins[$i])!=32)$only_logins[$i]=md5($only_logins[$i]);
   if ($i==0) $qw.="login = '".$only_logins[$i]."' ";else $qw.=" OR login = '".$only_logins[$i]."' ";
   $lg.=" ".$only_logins[$i];
   $i++;
   }
  $only_logins=$lg;
  }else
  {
  if ($filter!="")$qw.="status = '$filter' ";
  if ($sql_qw!="") $qw.="AND ".$sql_qw;
  }
 $result= mysql_query ($qw , $MySQL_link)
 or echo_error(__FILE__,__LINE__,ERR_MYSQL,"Can not read user logins");
 $all_usrs=mysql_num_rows($result);
 //echo $qw;
 
 while ($row=mysql_fetch_array($result))
  {
  if (load_user_data("send_message",$row['login'])!="NO")
   {
   if ($st!="")
    {
    if (($from=="==")? (load_user_data("state",$row['login'])==$st):(load_user_data("state",$row['login'])!=$st))
     {
	 $sndm=true;
	 }else
	 {
	 $all_usrs--;
	 $sndm=false;
	 }
    }else $sndm=true;
   if ($sndm)
    {
	
    $multipleextras="From: ".$VSecure_conf['admin_email']."\nReply-To: ".$VSecure_conf['admin_email']."\nX-Mailer: autobot PHP/" . phpversion();
    if (!@mail($row['email'], $subject, $message,$multipleextras))$failed_mess++;
//	echo $row['name'];
	}
   }else $all_usrs--;
  }
 alert("All messages: $all_usrs ;Messages sent: ".($all_usrs-$failed_mess).";");
 }

?>

<div style="text-align:center;"><h3> Send message</h3>
<a href="index.php" title="<?php echo $VSecure_Administration;?>" style="font-weight: bolder; font-size: larger;"><?php echo $VSecure_Administration;?></a>
<br />

<form action="send_message.php" method="post">
<input type="hidden" name="action" value="send" />
Subject : <input class="folder" type="text" name="subject" size="64" maxlength="255" /><br /><br />
<textarea cols="80" rows="30" name="message" style="border:1px solid black;text-weight:bold;">
**********************
Enter your text here.*
                     *
                     *
**********************

Best Wishes
Your <?php echo $VSecure_conf["admin_name"].", ".$SERVER_NAME;?>

--------------------------------------------------------------------------------
*
Pokud nechcete již více dostávat jakékoliv informace z našeho serveru, prosím pøihlašte se a v sekci USER zmìòte volbu UPOZORÒOVÁNÍ SERVERU na NE, nebo kliknìte na odkaz dole.
*
If you don't want to receive more any further message, please login on our pages and change REPORT FROM SERVER option to NO, or click on link below.

http://<?php 

/*CHANGE THIS ADDRESS TO YOUR OWN DESTINATION*/
echo $VSecure_conf['unsubscribe_path']."?uslogin=\$current_login";

?>

*** Prosím, neodpovídejte na tento mail / Please do not reply to this mail ****
</textarea>
<br /><br />
Using filtr:<br/>
<div style="border:1px solid black;margin:15px;padding:5px;">
 User status &nbsp; <select name="filter" size="1">
						<option value="" SELECTED>ALL</option>
<?php
$i=0;
while ($VSecure_conf['status_level'][$i])
 {
?>						<option value="<?php echo $VSecure_conf['status_level'][$i];?>"><?php echo $VSecure_conf['status_level'][$i];?></option>
<?php
 $i++;
 } ?>
 
                    </select>
&nbsp; Citizens
<select name="from" size="1">
						<option value="==" SELECTED>from</option>
						<option value="!=">NOT from</option>
                    </select>					
&nbsp;
<select name="st" size="1">
						<option value="" SELECTED>all countries</option>
						<?php echo $VSecure_states_options;?>
                    </select>					
<br />
Further conditions (if don't know MySQL WHERE syntax, leave empty.):<br />
<input type="text" name="sql_qw" size="64" maxlength="255" />
<br />
Send ONLY to following user or users divided by space (axcepted only md5 hash):<br />
<textarea cols="64" rows="1" name="only_logins" style="border:1px solid black;text-weight:bold;">
<?php echo $only_logins;?>
</textarea>
</div>
<div style="border:1px solid black;margin:15px;padding:5px;background:#ffffff;">
<input type="submit">
</div>
</form>
</div>
Return current item: VSecure