forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifySubscribers.json.php
executable file
·46 lines (41 loc) · 1.31 KB
/
notifySubscribers.json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
if (!User::canUpload()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not notify"));
exit;
}
$user_id = User::getId();
// if admin bring all subscribers
if(User::isAdmin()){
$user_id = "";
}
require_once 'subscribe.php';
header('Content-Type: application/json');
$Subscribes = Subscribe::getAllSubscribes($user_id);
require_once $global['systemRootPath'] . 'objects/PHPMailer/PHPMailerAutoload.php';
$obj = new stdClass();
//Create a new PHPMailer instance
$mail = new PHPMailer;
setSiteSendMessage($mail);
//Set who the message is to be sent from
$mail->setFrom($config->getContactEmail());
//Set who the message is to be sent to
//$mail->addAddress($config->getContactEmail());
foreach ($Subscribes as $value) {
$mail->addBCC($value["email"]);
}
$obj->total = count($Subscribes);
//Set the subject line
$mail->Subject = 'Message From Site ' . $config->getWebSiteTitle();
$mail->msgHTML($_POST['message']);
//send the message, check for errors
if (!$mail->send()) {
$obj->error = __("Message could not be sent") . " " . $mail->ErrorInfo;
} else {
$obj->success = __("Message sent");
}
echo json_encode($obj);