-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata.php
87 lines (78 loc) · 2.69 KB
/
data.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*======================================================\
| FrontKanban |
|-------------------------------------------------------|
| Creator: Phương |
| Date : 01-Dec-2017 |
| Description: Frontaccounting Project Management Ext |
| Free software under GNU GPL |
| |
\======================================================*/
$page_security = 'SA_MANAGER';
$path_to_root = '../..';
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/modules/kanban/includes/PHPMailer/PHPMailerAutoload.php");
add_access_extensions();
if(!file_exists(company_path().'/kanban_data'))
mkdir(company_path().'/kanban_data');
define('DATA_FILE', company_path().'/kanban_data/'.$_SESSION['project']);
function save($data) {
// $encoded = json_encode($data, JSON_PRETTY_PRINT);
$encoded = preg_replace("/"/", '"', $data);
$f = fopen(DATA_FILE, 'w') or die ("could not open file");
flock($f, LOCK_EX); //lock file to handle multi access at the same time
fwrite($f, $encoded);
flock($f, LOCK_UN); // release lock
fclose($f);
}
function load() {
$fh = fopen(DATA_FILE, 'r');
$data = fread($fh, filesize(DATA_FILE));
print $data;
}
function get_all_users() {
$result = array();
foreach(get_users() as $row) {
$result[] = $row;
};
$result[] = $_SESSION['wa_current_user']->username;
$result[] = $_SESSION['wa_current_user']->name;
$result[] = $_SESSION['wa_current_user']->email;
echo json_encode($result);
}
function sendEmail($data) {
$host = get_company_pref('smtp_host');
$port = get_company_pref('smtp_port');
$user = get_company_pref('smtp_username');
$pass = get_company_pref('smtp_password');
$secure = get_company_pref('smtp_secure');
$sender = get_company_pref('smtp_sendername');
$mail = new PHPMailer;
$mail->IsHTML(true);
$mail->CharSet = "text/html; charset=UTF-8;";
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = $host;
$mail->Port = $port;
$mail->SMTPSecure = $secure;
$mail->SMTPAuth = true;
$mail->Username = $user;
$mail->Password = $pass;
$mail->setFrom($user, $sender);
$mail->addReplyTo('[email protected]', 'No Reply');
$mail->addAddress($data['recipient'], 'recipient');
$mail->Subject = $data['subject'];
$mail->Body = html_entity_decode($data['content']);
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo json_encode($data);
}
}
if (function_exists($_POST['action'])) {
$actionVar = $_POST['action'];
@$actionVar($_POST['data']);
}