-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
104 lines (76 loc) · 1.9 KB
/
functions.php
File metadata and controls
104 lines (76 loc) · 1.9 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
use PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require "includes/phpmailer/Exception.php";
require "includes/phpmailer/phpmailer.php";
require "includes/phpmailer/SMTP.php";
require "playground.php";
function query($sql) {
global $con;
if ($result = $con->query($sql)) {
//$user = $result->fetch_assoc();
return $result;
}
else {
echo "query failed: ".$sql."<br>";
echo $con->error."<br>";
return false;
}
}
//todo
function get_option($option_name) {
}
function update_option($option_name, $value) {
}
function is_user_logged_in() {
if(isset($_SESSION["user_id"])) {
return true;
}
else {
return false;
}
}
function pre($arr) {
echo "<pre>";
print_r($arr);
echo "</pre>";
}
function redirect_with_data($url , $custom_data) {
$str = "?";
foreach($_POST as $k => $v) {
if( strpos($k, "pass") === false )
$str .= "$k=$v&";
}
foreach($custom_data as $k => $v) {
$str .= "$k=$v&";
}
$str = rtrim($str , "&");
$redirect_to = $url.$str;
header("location: $redirect_to");
exit;
}
function rget($key) {
if(isset($_GET[$key])) {
return $_GET[$key];
}
else {
return "";
}
}
function my_mail($to , $title , $message) {
$mail = new PHPMailer(true);
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp1.example.com';
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom("ADMIN_EMAIL", "EMAIL_FROM");
$mail->addAddress($to); // Add a recipient
$mail->Subject = $title;
$mail->Body = $message;
$mail->send();
}