mailing.php
<?php
$autoload='external';
function mailing_send()
{
if(!perms_check('admin', 'mailing'))
{
redirect('index.php?module=error&error=auth_error');
}
$db=new dbquery;
if(function_exists
(mail)) {
$message = read_text_rest($_POST['message']."\n\n-- -- -- -- -- -- -- --\n\n".$conf['mailing_signature']);
$subject=read_text_rest($conf['adress'].' - '.$_POST['subject']);
if($_POST['how'] == 'all')
{
$db->query("SELECT * FROM $conf[prefix_users]users WHERE mailing = 1 and active = 1") or $db->err(__FILE__, __LINE__);
while($d = $db->fetch_object())
{
if(!mail($d->mail, $subject, $message, "From: $conf[mailing_from]r\n"."Reply-To: $conf[mailing_reply_to]r\n"."X-Mailer: PHP/".phpversion())) {
redirect('index.php?module=admin&action=mailing&what=notsent');
}
}
}
elseif($_POST['how'] == 'users')
{
for($i = 0; $i < count($_REQUEST['users']); $i++) {
SQLvalidate($_REQUEST['users'][$i]);
$db->query("SELECT * FROM $conf[prefix_users]users WHERE mailing = 1 and active = 1 and id = ".$_REQUEST['users'][$i]) or $db->err(__FILE__, __LINE__);
$u = $db->fetch_object();
if(!mail($u->mail, $_POST['subject'], $message, "From: $conf[mailing_from]r\n"."Reply-To: $conf[mailing_reply_to]r\n"."X-Mailer: PHP/".phpversion())) {
redirect('index.php?module=admin&action=mailing&what=notsent');
}
}
}
elseif($_POST['how'] == 'groups')
{
$db2=new dbquery;
for($i = 0; $i < count($_REQUEST['groups']); $i++) {
SQLvalidate($_REQUEST['groups'][$i]);
$db2->query("SELECT * FROM $conf[prefix_users]users WHERE mailing = 1 and active = 1 and gid = $_REQUEST[groups][$i]") or $db->err(__FILE__, __LINE__);
while($u = $db2->fetch_object())
{
if(!mail($u->mail, $_POST['subject'], $message, "From: $conf[mailing_from]r\n"."Reply-To: $conf[mailing_reply_to]r\n"."X-Mailer: PHP/".phpversion())) {
redirect('index.php?module=admin&action=mailing&what=notsent');
}
}
}
}
redirect('index.php?module=admin&action=mailing&what=sent');
}
redirect('index.php?module=admin&action=mailing&what=notsent');
}
?>
mailing_external.php
<?php
function lost_password()
{
$db=new dbquery;
if($_POST['login'] or $_POST['email'])
{
if($_POST['login'])
$sql="login='$_POST[login]'";
if($_POST['email'])
$sql="mail='$_POST[email]'";
$db->query("SELECT * FROM $conf[prefix_users]users WHERE $sql") or $db->err(__FILE__, __LINE__);
if($db->num_rows()==0)
{
redirect('index.php?module=error&error=login_error1');
}
$d=$db->fetch_object();
$id_=$d->id;
$link=$conf['adres'].'index.php?module=images&function=lost_password_send&id='.$id_.'&code='.$code;
$title=string_template
($lang['lost_pass_title'], array('adress'=>$conf['adress'])); $message=string_template
($lang['lost_pass_msg'], array('link'=>$link));
if([email
="!@mail($d-mail"]!@mail($d->mail[/email
], $title, $message, "From: $conf[mailing_from]")) {
redirect('index.php?module=error&error=mailing_error');
}
else
{
redirect('index.php?module=info&info=lost_pass_info1');
}
}
redirect('index.php');
}
function lost_password_send()
{
SQLvalidate($_GET['id']);
if($_GET['id'] && $_GET['code'])
{
$db->query("SELECT * FROM $conf[prefix_users]users WHERE id=$_GET[id]") or $db->err(__FILE__, __LINE__);
if($db->num_rows()==0)
{
redirect('index.php?module=error&error=login_error1');
}
$d=$db->fetch_object();
if(md5($d->pass)!=$_GET['code']) {
redirect('index.php?module=error&error=lost_pass_error1');
}
$title=string_template
($lang['lost_pass_title'], array('adress'=>$conf['adress'])); $message=string_template
($lang['lost_pass_send'], array('login'=>$d->login, 'pass'=>$pass_));
if([email
="!@mail($d-mail"]!@mail($d->mail[/email
], $title, $message, "From: $conf[mailing_from]")) {
redirect('index.php?module=error&error=mailing_error');
}
else
{
$db->query("UPDATE $conf[prefix_users]users SET pass='$pass' WHERE id=$_GET[id]") or $db->err(__FILE__, __LINE__);
redirect('index.php?module=info&info=lost_pass_info2');
}
}
redirect('index.php');
}
?>
i jeszcze jedno maling.php
<?php
if(!perms_check('admin', 'mailing'))
{
redirect('index.php?module=error&error=auth_error');
}
if($_GET['what'] == 'sent')
{
$content = $lang['mailing_sent'];
}
elseif(!function_exists
(mail) or
$_GET['what'] == 'notsent') {
$content = $lang['mailing_error'];
}
else
{
//groups list
//adding admins
$groups_list = '<option value="3">'.groups_get_name_by_id(3).'</option>\n';
//adding users
$groups_list .= '<option value="2">'.groups_get_name_by_id(2).'</option>\n';
//adding rest
$query = "SELECT * FROM $conf[prefix_groups]groups WHERE type != -1 ORDER BY type ASC";
{
$name = groups_get_name_by_id($g->id);
$groups_list .= "<option value=\"$g->id\">$name</option>\n";
}
//
$users_list = NULL;
//users list
$query = "SELECT * FROM $conf[prefix_users]users ORDER BY login ASC";
{
$users_list .= "<option value=\"$u->id\">$u->login</option>\n";
}
//
$content = string_template
(read_file
($theme_path.'admin/mailing_form.php'), array("groups_list" => $groups_list, "users_list" => $users_list)); }
$content=string_template
(read_file
($theme_path.'middle_no_right.php'), array('theme_path' => $theme_path, 'content' => $content, 'description' => $lang['mailing_mailing']));
?>