db_Delete("generic", "gen_type='sendmail' AND gen_datestamp < ".(time()-86400));
if (isset($_POST['save_email'])){
$qry = "0,'massmail', '".time()."', '".USERID."', '".$tp->toDB($_POST['email_subject'])."', '0', \"".$tp->toDB($_POST['email_body'])."\" ";
$message = $sql -> db_Insert("generic", $qry) ? LAN_SAVED : LAN_ERROR;
}
if (isset($_POST['update_email'])){
$qry = "gen_user_id = '".USERID."', gen_datestamp = '".time()."', gen_ip = '".$tp->toDB($_POST['email_subject'])."', gen_chardata= \"".$tp->toDB($_POST['email_body'])."\" WHERE gen_id = '".$_POST['update_id']."' ";
$message = $sql -> db_Update("generic", $qry) ? LAN_UPDATED : LAN_UPDATED_FAILED;
}
if (isset($_POST['delete'])){
$d_idt = array_keys($_POST['delete']);
$message = ($sql -> db_Delete("generic", "gen_id='".$d_idt[0]."'")) ? LAN_DELETED : LAN_DELETED_FAILED;
}
if (isset($_POST['edit'])){
$e_idt = array_keys($_POST['edit']);
if($sql -> db_Select("generic", "*", "gen_id='".$e_idt[0]."' ")){
$foo = $sql -> db_Fetch();
}
}
if (isset($_POST['submit'])) {
if ($_POST['email_to'] == "all" || $_POST['email_to'] == "admin") {
switch ($_POST['email_to']) {
case "admin":
$insert = "u.user_admin='1' ";
break;
case "all":
$insert = "u.user_ban='0' ";
break;
}
$qry = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id WHERE $insert ";
} elseif($_POST['email_to'] == "unverified"){
$qry = "SELECT u.* FROM #user AS u WHERE u.user_ban='2'";
} elseif($_POST['email_to'] == "self"){
$qry = "SELECT u.* FROM #user AS u WHERE u.user_id='".USERID."'";
} else {
$insert = "u.user_class REGEXP concat('(^|,)',{$_POST['email_to']},'(,|$)') AND u.user_ban='0' ";
$qry = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id WHERE $insert ";
}
$sql2 = new db;
$c = 0;
if($_POST['extended_1_name'] && $_POST['extended_1_value']){
$qry .= " AND ".$_POST['extended_1_name']." = '".$_POST['extended_1_value']."' ";
}
if($_POST['extended_2_name'] && $_POST['extended_2_value']){
$qry .= " AND ".$_POST['extended_2_name']." = '".$_POST['extended_2_value']."' ";
}
if($_POST['user_search_name'] && $_POST['user_search_value']){
$qry .= " AND u.".$_POST['user_search_name']." LIKE '%".$_POST['user_search_value']."%' ";
}
$qry .= " ORDER BY u.user_name";
$_POST['mail_id'] = time();
$sql->db_Select_gen($qry);
while ($row = $sql->db_Fetch()) {
$qry = "0,'sendmail', '".$_POST['mail_id']."', '".$row['user_id']."', '', '0', \"".$tp->toDB($_POST['email_subject'])."\" ";
if($sql2 -> db_Insert("generic", $qry)){
$c++;
}
}
$debug = (e_MENU == "debug") ? "?[debug]" : "";
$text = "
";
// --------------- Preview Email -------------------------->
if(is_numeric($_POST['email_to']))
{
$sql->db_Select("userclass_classes", "userclass_name", "userclass_id = '{$_POST['email_to']}'");
$row = $sql->db_Fetch();
$_to = MAILAN_23.$row['userclass_name'];
}
else
{
$_to = $_POST['email_to'];
}
$text .= "
";
$text .= ($_POST['email_cc']) ? "
": "";
$text .= ($_POST['email_bcc']) ? "
": "";
$text .= ($_POST['user_search_name'] && $_POST['user_search_value']) ? "
": "";
$text .= ($_POST['extended_1_name'] && $_POST['extended_1_value']) ? "
": "";
$text .= ($_POST['extended_2_name'] && $_POST['extended_2_value']) ? "
": "";
$text .="
";
$ns->tablerender(MAILAN_39." ($c) ", $text);
require_once(e_ADMIN."footer.php");
exit;
}
//. Update Preferences.
if (isset($_POST['updateprefs']) && getperms("0")) {
$pref['mailer'] = $_POST['mailer'];
if (strpos($_POST['sendmail'],'sendmail') !== FALSE) $pref['sendmail'] = $_POST['sendmail'];
$pref['smtp_server'] = $tp->toDB($_POST['smtp_server']);
$pref['smtp_username'] = $tp->toDB($_POST['smtp_username']);
$pref['smtp_password'] = $tp->toDB($_POST['smtp_password']);
$pref['smtp_keepalive'] = $_POST['smtp_keepalive'];
$pref['smtp_pop3auth'] = $_POST['smtp_pop3auth'];
$pref['mail_pause'] = $_POST['mail_pause'];
$pref['mail_pausetime'] = $_POST['mail_pausetime'];
$pref['mail_bounce_email'] = $_POST['mail_bounce_email'];
$pref['mail_bounce_pop3'] = $_POST['mail_bounce_pop3'];
$pref['mail_bounce_user'] = $_POST['mail_bounce_user'];
$pref['mail_bounce_pass'] = $_POST['mail_bounce_pass'];
$pref['mail_bounce_delete'] = $_POST['mail_bounce_delete'];
save_prefs();
$message = LAN_SETSAVED;
}
if (isset($message)) {
$ns->tablerender("", "".$message."
");
}
// ----------------- Actions ----------------------------------------------->
if((e_QUERY == "prefs") && getperms("0")){
show_prefs();
}
if((!e_QUERY && !$_POST['delete']) || $_POST['edit']){
show_mailform($foo);
}
if(e_QUERY == "list" || $_POST['delete'] ){
showList();
}
require_once(e_ADMIN."footer.php");
// ------------------- Display Mailout Form.--------------------------------->
function show_mailform($foo=""){
global $ns,$sql,$tp,$pref,$HANDLERS_DIRECTORY;
$email_subject = $foo['gen_ip'];
$email_body = $tp->toForm($foo['gen_chardata']);
$email_id = $foo['gen_id'];
$text = "";
if(strpos($_SERVER['SERVER_SOFTWARE'],"mod_gzip") && !is_readable(e_HANDLER."phpmailer/.htaccess")){
$warning = MAILAN_40." ".$HANDLERS_DIRECTORY."phpmailer/ ".MAILAN_41;
$ns -> tablerender(MAILAN_42, $warning);
}
$debug = (e_MENU == "debug") ? "?[debug]" : "";
$text .= "";
$ns->tablerender(MAILAN_15, $text);
}
// ------------------ Preferences -------------------------------------------->
function show_prefs(){
global $pref,$ns;
$text = "
";
$text .= "";
$caption = LAN_PREFS;
$ns->tablerender($caption, $text);
}
function showList()
{
global $sql,$ns,$tp;
$gen = new convert;
$qry ="SELECT g.*,u.* FROM #generic AS g LEFT JOIN #user AS u ON g.gen_user_id = u.user_id WHERE g.gen_type = 'massmail' ORDER BY g.gen_datestamp DESC";
// $count = $sql -> db_Select("generic", "*", "gen_type ='massmail' ORDER BY gen_datestamp DESC");
$count = $sql -> db_Select_gen($qry);
$text = "";
if (!$count)
{
$text = "
";
$ns -> tablerender("
".MAILAN_21."
", $text);
require_once(e_ADMIN."footer.php");
exit;
}
else
{
$text .= "
";
$ns -> tablerender("".MAILAN_21."
", $text);
}
function userclasses($name) {
global $sql;
$text .= "
".MAILAN_12."
".MAILAN_13."
".MAILAN_53."
".MAILAN_54." ";
$query = "SELECT uc.*, count(u.user_id) AS members
FROM #userclass_classes AS uc
LEFT JOIN #user AS u ON u.user_class REGEXP concat('(^|,)',uc.userclass_id,'(,|$)')
GROUP BY uc.userclass_id
";
$sql->db_Select_gen($query);
while ($row = $sql->db_Fetch()) {
$public = ($row['userclass_editclass'] == 0)? "(".MAILAN_10.")" : "";
$text .= "".MAILAN_55." - {$row['userclass_name']} $public [{$row['members']}] ";
}
$text .= " ";
return $text;
}
function mailout_adminmenu() {
$action = (e_QUERY) ? e_QUERY : "post";
if($action == "edit"){
$action = "post";
}
$var['post']['text'] = MAILAN_56;
$var['post']['link'] = e_SELF;
$var['post']['perm'] = "W";
$var['list']['text'] = LAN_SAVED;
$var['list']['link'] = e_SELF."?list";
$var['list']['perm'] = "W";
if(getperms("0")){
$var['prefs']['text'] = LAN_OPTIONS;
$var['prefs']['link'] = e_SELF."?prefs";
$var['prefs']['perm'] = "0";
}
show_admin_menu(MAILAN_15, $action, $var);
}
function sc_Select($container='sc_selector') {
$text ="
\n
";
return $text;
}
function headerjs()
{
$text = "
";
return $text;
}
?>