<?php
$sumfingIncl=true;
require '../config.thing.php';
// Get options
$set = get_adm_opts();
include 'translate.php';

if(!isset($_POST['uid']) || empty($_POST['uid'])) die(_("Bad request"));
$admin = $_POST['uid'];

if(($_POST['subject'] == '') || ($_POST['emailbody'] == '')) die(_("Attention! Title and message must be filled in!"));

// Check for admin
$checkuser = is_user_fakeid($admin);
$from = $checkuser->email; // admin email for messages
if($checkuser->isadmin != 1) die(_("Access denied"));
unset($checkuser);

// Users array with data
$users = get_users_emails($admin);

$subject = $_POST['subject'];
$message = $_POST['emailbody'];

// Loop emails out
foreach($users as $emails) {
	$to[] = $emails;	
}

// Replace link
$message = str_replace("[APPLINK]",'<a href="'.MY_APP_URL.'">'.MY_APP_URL.'</a>',$message);
$message = nl2br($message);

//  [NAME], [PRIZE] and [APPLINK] 
$out=send_emails($to,$subject,$message);
echo $out;

	
?>