| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package NKTI::general; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
61352
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
20
|
|
|
5
|
1
|
|
|
1
|
|
371
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
4876
|
|
|
|
1
|
|
|
|
|
47
|
|
|
6
|
1
|
|
|
1
|
|
552
|
use DateTime; |
|
|
1
|
|
|
|
|
382878
|
|
|
|
1
|
|
|
|
|
339
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export. |
|
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use NKTI::general ':all'; |
|
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
18
|
|
|
|
|
|
|
# will save memory. |
|
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( cetak cetak_r cetak_pre ) ]); |
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
21
|
|
|
|
|
|
|
our @EXPORT = qw(cetak cetak_r cetak_pre); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Define Version : |
|
24
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
25
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Create Subroutine for Get OS Server Information : |
|
28
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
29
|
|
|
|
|
|
|
sub os_server_info { |
|
30
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
31
|
|
|
|
|
|
|
# Prepare to get Operating System Information : |
|
32
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
33
|
0
|
|
|
0
|
0
|
0
|
my $server_signature = lc $ENV{'SERVER_SIGNATURE'}; |
|
34
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
35
|
|
|
|
|
|
|
# Scalar for placing result : |
|
36
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
37
|
0
|
|
|
|
|
0
|
my $data = undef; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Check IF $server_signature match "Win32" : |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
0
|
if ($server_signature =~ m/win32/) { |
|
|
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
$data = 'mswin'; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Check IF $server_signature match "unix" : |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
elsif ($server_signature =~ m/unix|debian|ubuntu|centos/) { |
|
48
|
0
|
|
|
|
|
0
|
$data = 'unix'; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check IF $server_signature match unknown : |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
else { |
|
54
|
0
|
|
|
|
|
0
|
$data = 'other'; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Return Result : |
|
58
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
59
|
0
|
|
|
|
|
0
|
return $data; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
# End of Create Subroutine for Get OS Server Information |
|
62
|
|
|
|
|
|
|
# =========================================================================================================== |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Create Subroutine for get OS Client Information : |
|
65
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
66
|
|
|
|
|
|
|
sub os_info { |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Define self : |
|
69
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
70
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Using Modules : |
|
73
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
74
|
0
|
|
|
|
|
0
|
my $check_modules = $self->try_module('HTTP::BrowserDetect'); |
|
75
|
0
|
0
|
|
|
|
0
|
unless ($check_modules) { |
|
|
0
|
|
|
|
|
0
|
|
|
76
|
1
|
|
|
1
|
|
769
|
use HTTP::BrowserDetect; |
|
|
1
|
|
|
|
|
20761
|
|
|
|
1
|
|
|
|
|
366
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Prepare to get OS Client Information : |
|
80
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
81
|
0
|
|
|
|
|
0
|
my $user_agent = $ENV{'HTTP_USER_AGENT'}; |
|
82
|
0
|
|
|
|
|
0
|
my $ua = HTTP::BrowserDetect->new($user_agent); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Scalar for placing result : |
|
85
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
86
|
0
|
|
|
|
|
0
|
my $data = ''; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Check IF $ua->os_string is true : |
|
89
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
90
|
0
|
0
|
|
|
|
0
|
if ($ua->os_string) { |
|
91
|
0
|
|
|
|
|
0
|
$data .= lc $ua->os_string; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
# End of check IF $ua->os_string is true. |
|
94
|
|
|
|
|
|
|
# ================================================================= |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Check IF $ua->os_string is false : |
|
97
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
98
|
|
|
|
|
|
|
else { |
|
99
|
0
|
|
|
|
|
0
|
$data .= 'unknown'; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
# End of check IF $ua->os_string is false. |
|
102
|
|
|
|
|
|
|
# ================================================================= |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Return Result : |
|
105
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
106
|
0
|
|
|
|
|
0
|
return $data; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
# End of Create Subroutine for get OS Client Information |
|
109
|
|
|
|
|
|
|
# =========================================================================================================== |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Create Subroutine for Get Browser Information : |
|
112
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
113
|
|
|
|
|
|
|
sub browser_info { |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Prepare to get Browser Information : |
|
116
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
117
|
1
|
|
|
1
|
0
|
90
|
my $browser = $ENV{'HTTP_USER_AGENT'}; |
|
118
|
1
|
|
|
|
|
14
|
my $ua = HTTP::BrowserDetect->new($browser); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Scalar for placing result : |
|
121
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
122
|
1
|
|
|
|
|
83
|
my $data = ''; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Check IF $ua->browser_string is true : |
|
125
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
126
|
1
|
50
|
|
|
|
5
|
if ($ua->browser_string) { |
|
127
|
0
|
|
|
|
|
0
|
$data .= lc $ua->browser_string; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
# End of check IF $ua->browser_string is true. |
|
130
|
|
|
|
|
|
|
# ================================================================= |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Check IF $ua->browser_string is false : |
|
133
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
134
|
|
|
|
|
|
|
else { |
|
135
|
1
|
|
|
|
|
9
|
$data .= 'unknown'; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
# End of check IF $ua->browser_string is false. |
|
138
|
|
|
|
|
|
|
# ================================================================= |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Return Data : |
|
141
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
142
|
1
|
|
|
|
|
8
|
return $data; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
# End of Create Subroutine for Get Browser Information |
|
145
|
|
|
|
|
|
|
# =========================================================================================================== |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Create Subroutine for Delimiter Directory : |
|
148
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
149
|
|
|
|
|
|
|
sub delimiter_dir { |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Run Subroutine "os_server_info()" : |
|
152
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
153
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
154
|
0
|
|
|
|
|
|
my $os_information = $self->os_server_info(); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Scalar for placing result : |
|
157
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
158
|
0
|
|
|
|
|
|
my $data = ''; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# Switch for conditions $os_information : |
|
161
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
162
|
0
|
0
|
|
|
|
|
if ($os_information == 'mswin') { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$data = '\\'; |
|
164
|
|
|
|
|
|
|
} elsif ($os_information == 'unix') { |
|
165
|
0
|
|
|
|
|
|
$data = '/'; |
|
166
|
|
|
|
|
|
|
} elsif ($os_information == 'other') { |
|
167
|
0
|
|
|
|
|
|
$data = '/'; |
|
168
|
|
|
|
|
|
|
} else { |
|
169
|
0
|
|
|
|
|
|
$data = '/'; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
# End of switch for conditions $os_information. |
|
172
|
|
|
|
|
|
|
# ================================================================ |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Return Result : |
|
175
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
176
|
0
|
|
|
|
|
|
return $data; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
# End of Create Subroutine for Delimiter Directory |
|
179
|
|
|
|
|
|
|
# =========================================================================================================== |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# Create Subroutine for get database config : |
|
182
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
183
|
|
|
|
|
|
|
sub get_dbconfig_php { |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# Define arguments subroutine : |
|
186
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
187
|
0
|
|
|
0
|
1
|
|
my ($self, $dirloc, $file_loc) = @_; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# Using Modules : |
|
190
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
191
|
0
|
|
|
|
|
|
my $check_modules = $self->try_module('NKTI::general::file::read'); |
|
192
|
0
|
0
|
|
|
|
|
unless ($check_modules) { |
|
|
0
|
|
|
|
|
|
|
|
193
|
1
|
|
|
1
|
|
530
|
use NKTI::general::file::read; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
1007
|
|
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Define scalar for location file Database Config : |
|
197
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
198
|
0
|
|
|
|
|
|
my $file_dbconfig = $dirloc . $file_loc; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# Run subroutine for get database config : |
|
201
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
202
|
0
|
|
|
|
|
|
my $get_dbconfig = NKTI::general::file::read->new($file_dbconfig, 'dbconf'); |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Return Result : |
|
205
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
206
|
0
|
|
|
|
|
|
return $get_dbconfig; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
# End of Create Subroutine for get database config |
|
209
|
|
|
|
|
|
|
# =========================================================================================================== |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Subroutine for get protocols : |
|
212
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
213
|
|
|
|
|
|
|
sub get_protocol { |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# Prepare to get Protocol used : |
|
216
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
217
|
|
|
|
|
|
|
#my $get_protocol = (defined $ENV{'HTTPS'} || $ENV{'SERVER_PORT'} == '443') ? "https:" : "http:"; |
|
218
|
0
|
|
|
0
|
1
|
|
my $get_protocol = undef; |
|
219
|
0
|
0
|
0
|
|
|
|
if (defined $ENV{'HTTPS'} || $ENV{'SERVER_PORT'} == '443') { |
|
220
|
0
|
|
|
|
|
|
$get_protocol = 'https:'; |
|
221
|
|
|
|
|
|
|
} else { |
|
222
|
0
|
|
|
|
|
|
$get_protocol = 'http:'; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Return Result : |
|
226
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
227
|
0
|
|
|
|
|
|
return $get_protocol; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
# End of Subroutine for get protocols. |
|
230
|
|
|
|
|
|
|
# =========================================================================================================== |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# Subroutine for check IF module is exists : |
|
233
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
234
|
|
|
|
|
|
|
sub try_module { |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# Define parameter module : |
|
237
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
238
|
0
|
|
|
0
|
0
|
|
my ($self, $module_name) = @_; |
|
239
|
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
eval("use $module_name"); |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# Check IF eval is true : |
|
243
|
|
|
|
|
|
|
# Jika module belum diload. |
|
244
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
245
|
0
|
0
|
|
|
|
|
if ($@) { |
|
246
|
|
|
|
|
|
|
#print "\$@ = $@\n"; |
|
247
|
0
|
|
|
|
|
|
return(0); |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# Check IF eval is false : |
|
251
|
|
|
|
|
|
|
# Jika module Telah diload. |
|
252
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
253
|
|
|
|
|
|
|
else { |
|
254
|
0
|
|
|
|
|
|
return(1); |
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
# End of Subroutine for check IF module is exists |
|
258
|
|
|
|
|
|
|
# =========================================================================================================== |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Subroutine for define time for Event MySQL : |
|
261
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
262
|
|
|
|
|
|
|
sub time_event_mysql { |
|
263
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
264
|
|
|
|
|
|
|
# Define parameter Subroutine : |
|
265
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
266
|
0
|
|
|
0
|
1
|
|
my ($self, $time_event) = @_; |
|
267
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
268
|
|
|
|
|
|
|
# Define scalar for place result : |
|
269
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
270
|
0
|
|
|
|
|
|
my %data = (); |
|
271
|
0
|
|
|
|
|
|
my $get_num = undef; |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# For $time_event =~ /Y/ : |
|
274
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
275
|
0
|
0
|
|
|
|
|
if ($time_event =~ m/Y/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
277
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' YEAR)'; |
|
278
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
279
|
0
|
|
|
|
|
|
$data{'unit'} = 'YEAR'; |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
# End of For $time_event =~ /Y/. |
|
282
|
|
|
|
|
|
|
# ==================================================================== |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# For $time_event =~ /M/ : |
|
285
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
286
|
|
|
|
|
|
|
elsif ($time_event =~ m/M/) { |
|
287
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
288
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' MONTH)'; |
|
289
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
290
|
0
|
|
|
|
|
|
$data{'unit'} = 'MONTH'; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
# End of for $time_event =~ /M/. |
|
293
|
|
|
|
|
|
|
# ==================================================================== |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# For $time_event =~ /W/ : |
|
296
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
297
|
|
|
|
|
|
|
elsif ($time_event =~ m/W/) { |
|
298
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
299
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' WEEK)'; |
|
300
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
301
|
0
|
|
|
|
|
|
$data{'unit'} = 'WEEK'; |
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
# End of for $time_event =~ /W/. |
|
304
|
|
|
|
|
|
|
# ==================================================================== |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# For $time_event =~ /D/ : |
|
307
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
308
|
|
|
|
|
|
|
elsif ($time_event =~ m/D/) { |
|
309
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
310
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' DAY)'; |
|
311
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
312
|
0
|
|
|
|
|
|
$data{'unit'} = 'DAY'; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
|
|
|
|
|
|
# End of For $time_event =~ /D/. |
|
315
|
|
|
|
|
|
|
# ==================================================================== |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
# For $time_event =~ /H/ : |
|
318
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
319
|
|
|
|
|
|
|
elsif ($time_event =~ m/H/) { |
|
320
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
321
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' HOUR)'; |
|
322
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
323
|
0
|
|
|
|
|
|
$data{'unit'} = 'HOUR'; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
# End of For $time_event =~ /H/. |
|
326
|
|
|
|
|
|
|
# ==================================================================== |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# For $time_event =~ /m/ : |
|
329
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
330
|
|
|
|
|
|
|
elsif ($time_event =~ m/m/) { |
|
331
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
332
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' MINUTE)'; |
|
333
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
334
|
0
|
|
|
|
|
|
$data{'unit'} = 'MINUTE'; |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
# End of For $time_event =~ /m/. |
|
337
|
|
|
|
|
|
|
# ==================================================================== |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# For $time_event =~ /d/ : |
|
340
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
341
|
|
|
|
|
|
|
elsif ($time_event =~ m/d/) { |
|
342
|
0
|
|
|
|
|
|
$get_num = $time_event =~ s/\D//g; |
|
343
|
0
|
|
|
|
|
|
$data{'event'} = '(CURRENT_TIMESTAMP + INTERVAL '.$get_num.' SECOND)'; |
|
344
|
0
|
|
|
|
|
|
$data{'time'} = $time_event; |
|
345
|
0
|
|
|
|
|
|
$data{'unit'} = 'SECOND'; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
# End of For $time_event =~ /d/. |
|
348
|
|
|
|
|
|
|
# ==================================================================== |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
# Default Case : |
|
351
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
352
|
|
|
|
|
|
|
else { |
|
353
|
0
|
|
|
|
|
|
$data{'event'} = 'CURRENT_TIMESTAMP'; |
|
354
|
0
|
|
|
|
|
|
$data{'time'} = ''; |
|
355
|
0
|
|
|
|
|
|
$data{'unit'} = ''; |
|
356
|
|
|
|
|
|
|
} |
|
357
|
|
|
|
|
|
|
# End of case $time_event == /d/. |
|
358
|
|
|
|
|
|
|
# ==================================================================== |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# Return Result : |
|
361
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
362
|
0
|
|
|
|
|
|
return \%data; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
# End of Subroutine for define time for Event MySQL |
|
365
|
|
|
|
|
|
|
# =========================================================================================================== |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
# Subroutine for Define format DATETIME MySQL : |
|
368
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
369
|
|
|
|
|
|
|
sub datetime_mysql { |
|
370
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
371
|
|
|
|
|
|
|
# Define parameter subroutine : |
|
372
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
373
|
0
|
|
|
0
|
0
|
|
my ($self, $timestamp, $timezone) = @_; |
|
374
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
375
|
|
|
|
|
|
|
# Define scalar for place result : |
|
376
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
377
|
0
|
|
|
|
|
|
my $data = undef; |
|
378
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
379
|
|
|
|
|
|
|
# Set DateTime and TimeZone : |
|
380
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
381
|
0
|
|
|
|
|
|
my $dt = DateTime->from_epoch( |
|
382
|
|
|
|
|
|
|
epoch => $timestamp, |
|
383
|
|
|
|
|
|
|
time_zone => $timezone |
|
384
|
|
|
|
|
|
|
); |
|
385
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
386
|
|
|
|
|
|
|
# Get DateTime Format : |
|
387
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
388
|
0
|
|
|
|
|
|
my $date_define = $dt->ymd; |
|
389
|
0
|
|
|
|
|
|
my $time_define = $dt->hms; |
|
390
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
391
|
|
|
|
|
|
|
# Place date reuslt : |
|
392
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
393
|
0
|
|
|
|
|
|
$data = $date_define.' '.$time_define; |
|
394
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
395
|
|
|
|
|
|
|
# Return result : |
|
396
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
397
|
0
|
|
|
|
|
|
return $data; |
|
398
|
|
|
|
|
|
|
} |
|
399
|
|
|
|
|
|
|
# End of Subroutine for Define format DATETIME MySQL |
|
400
|
|
|
|
|
|
|
# =========================================================================================================== |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
# Subroutine for Print data with newline : |
|
403
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
404
|
|
|
|
|
|
|
sub cetak { |
|
405
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
406
|
|
|
|
|
|
|
# Define parameter subroutine : |
|
407
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
408
|
0
|
|
|
0
|
1
|
|
my ($data) = @_; |
|
409
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
410
|
|
|
|
|
|
|
# Print Data : |
|
411
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
412
|
0
|
|
|
|
|
|
print "$data \n"; |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
# End of Subroutine for Print data with newline |
|
415
|
|
|
|
|
|
|
# =========================================================================================================== |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
# Subroutine for Print ref : |
|
418
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
419
|
|
|
|
|
|
|
sub cetak_r { |
|
420
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
421
|
|
|
|
|
|
|
# Check Parameter Subroutine : |
|
422
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
423
|
0
|
0
|
|
0
|
1
|
|
if (keys(@_) eq 1) { |
|
424
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
425
|
|
|
|
|
|
|
# Print Dumper : |
|
426
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
427
|
0
|
|
|
|
|
|
print Dumper $_[0]; |
|
428
|
|
|
|
|
|
|
} |
|
429
|
0
|
0
|
|
|
|
|
if (keys(@_) > 1) { |
|
430
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
431
|
|
|
|
|
|
|
# Print Dumper : |
|
432
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
433
|
0
|
|
|
|
|
|
print Dumper \@_; |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
# End of Subroutine for Print ref. |
|
437
|
|
|
|
|
|
|
# =========================================================================================================== |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
# Subroutine for print ref with pre tag HTML : |
|
440
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
|
441
|
|
|
|
|
|
|
sub cetak_pre { |
|
442
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
443
|
|
|
|
|
|
|
# Check Parameter Subroutine : |
|
444
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
445
|
0
|
0
|
|
0
|
1
|
|
if (keys(@_) eq 1) { |
|
446
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
447
|
|
|
|
|
|
|
# Print Dumper : |
|
448
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
449
|
0
|
|
|
|
|
|
print "<pre>"; |
|
450
|
0
|
|
|
|
|
|
print Dumper $_[0]; |
|
451
|
0
|
|
|
|
|
|
print "</pre>"; |
|
452
|
|
|
|
|
|
|
} |
|
453
|
0
|
0
|
|
|
|
|
if (keys(@_) > 1) { |
|
454
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
455
|
|
|
|
|
|
|
# Print Dumper : |
|
456
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
|
457
|
0
|
|
|
|
|
|
print Dumper \@_; |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
} |
|
460
|
|
|
|
|
|
|
# End of Subroutine for print ref with pre tag HTML |
|
461
|
|
|
|
|
|
|
# =========================================================================================================== |
|
462
|
|
|
|
|
|
|
1; |
|
463
|
|
|
|
|
|
|
__END__ |
|
464
|
|
|
|
|
|
|
# |