-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.php
142 lines (115 loc) · 3.6 KB
/
util.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
require_once("config.php");
require_once("lib\swift_required.php");
function verifikasiPassword( $real){
$password = "kamilRidwanWalkot";
if($password===$real){
setcookie("preman-login",1);
header('Location:listPengaduanAdmin.php');
die();
}
else{
header('Location:homeAdmin.php?error=1');
die();
}
return;
}
function terimaPengaduan($judul, $nama_pelapor, $telepon_pelapor,$tid, $isi, $link_foto){
connectDatabase();
$query = "INSERT INTO `pengaduan` (`judul`,`nama_pelapor`,`telepon_pelapor`,`tanggal`,`tid`,`isi`,`link_foto`) VALUES('$judul','$nama_pelapor','$telepon_pelapor',CURDATE(),$tid,'$isi','$link_foto');";
$result = mysql_query($query);
return $result;
}
function uploadPengaduan(){
$i=0;
$allowed = array('gif','png' ,'jpg');
$filename = $_FILES['imgSrc']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed) ) {
return in_array($ext,$allowed);
}
while(file_exists("images/$i-{$_FILES['imgSrc']["name"]}")){
$i++;
}
move_uploaded_file ($_FILES['imgSrc'] ['tmp_name'],
"images/$i-{$_FILES['imgSrc'] ['name']}");
$imgSrc = "images/$i-{$_FILES['imgSrc'] ['name']}";
return $imgSrc;
}
/*
function kirimEmail( $nama_pelapor, $msg){
$subject="[PREMAN] Aduan dari ".$nama_pelapor;
$to = "[email protected]";
$headers = "From: [email protected]\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$msg = $isi;
mail($to,$subject,$msg,$headers);
}
*/
function cekIsLogin(){
if (isset($_COOKIE["preman-login"]))
{
return $_COOKIE['preman-login'] == 1;
}
return false;
}
function connectDatabase(){
global $db_host, $db_username, $db_password, $db_name;
mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name);
}
function tambahDatabaseTaman( $nama_taman){
connectDatabase();
$query = "INSERT INTO `taman`(`nama`) VALUES('".$nama_taman."');";
$result = mysql_query($query);
return $result;
}
function hapusDatabaseTaman( $id){
connectDatabase();
$query = "DELETE FROM `taman` WHERE `taman`.`id`=".$id.";";
$result = mysql_query($query);
echo $result;
return $result;
}
function bacaDatabaseTaman(){
connectDatabase();
$query = "SELECT * FROM `taman`";
$result = mysql_query($query);
return $result;
}
function logout(){
setcookie('preman-login', null, -1);
}
function updateDatabaseTaman($id,$nama){
connectDatabase();
$query = "UPDATE `taman` SET `nama`='$nama' WHERE `id`=$id;";
return mysql_query($query);
}
function kirimEmail($nama_pelapor,$msg){
$transport = Swift_SmtpTransport::newInstance('ssl://smtp.gmail.com', 465)
->setUsername('[email protected]')
->setPassword('mendingngodingaja')
;
/*
You could alternatively use a different transport such as Sendmail or Mail:
// Sendmail
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
// Mail
$transport = Swift_MailTransport::newInstance();
*/
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance()
// Give the message a subject
->setSubject('[PREMAN] Laporan Terbaru dari '.$nama_pelapor)
// Set the From address with an associative array
->setFrom(array('[email protected]' => 'Sistem Pengaduan Ruang Taman'))
// Set the To addresses with an associative array
->setTo(array('[email protected]', '[email protected]' => 'Muhammad Reza Irvanda'))
// Give it a body
->setBody($msg)
;
$result = $mailer->send($message);
return $result;
}
?>