summaryrefslogtreecommitdiff
path: root/js/callbacks/testemail.php
blob: 788a12f1f1ee136e66ecc00242bda6dec4862354 (plain)
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
<?php

define('IN_FS', true);

header('Content-type: text/html; charset=utf-8');

require_once('../../header.php');
global $proj, $fs;

if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
  $user = new User(Cookie::val('flyspray_userid'));
  $user->check_account_ok();
} else {
  $user = new User(0, $proj);
}

// don't allow anonymous users to access this page at all
if ($user->isAnon()) {
  die(L('nopermission'));
}
load_translations();

if( !Post::has('csrftoken') ){
  http_response_code(428); # 'Precondition Required'
  die('missingtoken');
}elseif( Post::val('csrftoken')==$_SESSION['csrftoken']){
  # empty
}else{
  http_response_code(412); # 'Precondition Failed'
  die('wrongtoken');
}
if (!$user->perms('is_admin')){
  http_response_code(403); # 'Forbidden'
  die(L('nopermission'));
}

$notify = new Notifications;
$result=$notify->sendEmail($user->infos['email_address'],'test','testcontent',1);

if($result !=1){
  http_response_code(406); # 'Not Acceptable'
}
echo 'ok';
?>