· 5 years ago · Jan 25, 2020, 10:36 PM
1<?php
2/**
3*
4* @ This file is created by http://DeZender.Net
5* @ deZender (PHP7 Decoder for ionCube Encoder)
6*
7* @ Version : 4.0.9.0
8* @ Author : DeZender
9* @ Release on : 08.08.2019
10* @ Official site : http://DeZender.Net
11*
12*/
13
14class ApplicationController extends Controller
15{
16 final public function license_check($addoncode = '', $from_framework = 0)
17 {
18 $lic_data = '';
19
20 for ($i = 0; $i < VALIDATOR_SERVER_COUNT; $i++) {
21 $validator = ($i == 0 ? 'validator' : 'validator' . $i);
22
23 if ($addoncode != '') {
24 $url = 'http://' . $validator . '.xyzscripts.com/index.php?page=license/validate_addon/' . PRODUCT_CODE . '/' . $addoncode . '/' . $_SERVER['HTTP_HOST'] . '/' . LICENSE_KEY;
25 }
26 else {
27 $url = 'http://' . $validator . '.xyzscripts.com/index.php?page=license/validate/' . PRODUCT_CODE . '/' . $_SERVER['HTTP_HOST'] . '/' . LICENSE_KEY;
28 }
29
30 $lic_data = '';
31 if ((ini_get('allow_url_fopen') == 1) && ($fp_license = fopen($url, 'r'))) {
32 while (!feof($fp_license)) {
33 $lic_data .= fgetc($fp_license);
34 }
35
36 fclose($fp_license);
37 }
38 else if (function_exists('curl_init')) {
39 $ch = curl_init();
40 curl_setopt($ch, CURLOPT_URL, $url);
41 curl_setopt($ch, CURLOPT_HEADER, 0);
42 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
43 $content = curl_exec($ch);
44 curl_close($ch);
45 $lic_data = $content;
46 }
47 else {
48 Main::print_error('Either URL fopen or CURL must be enabled on your server.');
49 exit();
50 }
51
52 if ($lic_data == -1) {
53 $this->set_root_cookie(COOKIE_ADMIN_USERNAME, '', 0);
54 $this->set_root_cookie(COOKIE_ADMIN_PASSWORD, '', 0);
55 $this->set_root_cookie(COOKIE_ADMIN_LOGINID, '', 0);
56 $this->set_root_cookie(COOKIE_ADMIN_TYPE, '', 0);
57
58 if ($from_framework == 0) {
59 Main::print_error('License validation failed. Please verify the key in your configuration file.');
60 exit();
61 }
62 else {
63 return $lic_data;
64 }
65
66 continue;
67 }
68
69 if ($lic_data == 1) {
70 if ($from_framework == 0) {
71 break;
72 }
73 else {
74 return $lic_data;
75 }
76
77 continue;
78 }
79
80 continue;
81 }
82
83 if ($lic_data == '') {
84 return $this->check_license_validation_network_failure();
85 }
86 }
87
88 final public function check_license_validation_network_failure()
89 {
90 $db = DAL::get_instance();
91 $rowdata = $db->execute_query('SELECT id,value FROM ' . TABLE_PREFIX . 'config WHERE name=?', ['report_lnfth']);
92 $rowdatacount = $rowdata->get_num_records();
93 $config_id = 0;
94 $report_lnfth = '';
95
96 if (0 < $rowdatacount) {
97 $rowdatacontent = $rowdata->fetch_assoc();
98 $config_id = $rowdatacontent['id'];
99 $report_lnfth = $rowdatacontent['value'];
100 }
101
102 $secret_key = 'xyzadmarkethash';
103 $failure_time = 0;
104 $hash = '';
105 $dbinsert_flag = 0;
106 $print_error_flag = 0;
107 $current_time = time();
108
109 if ($report_lnfth != '') {
110 $report_array = json_decode($report_lnfth, 1);
111
112 if (isset($report_array['ft'])) {
113 $failure_time = intval($report_array['ft']);
114 }
115
116 if (isset($report_array['h'])) {
117 $hash = $report_array['h'];
118 }
119
120 if (0 < $failure_time) {
121 if (43200 <= $current_time - $failure_time) {
122 $print_error_flag = 1;
123 }
124 }
125 else {
126 $dbinsert_flag = 1;
127 $print_error_flag = 1;
128 }
129
130 if ($print_error_flag == 0) {
131 $created_hash = md5($failure_time . $secret_key);
132
133 if ($hash != $created_hash) {
134 $print_error_flag = 1;
135 }
136 }
137 }
138 else {
139 $dbinsert_flag = 1;
140 $print_error_flag = 1;
141 }
142
143 if ($dbinsert_flag == 1) {
144 $failure_time = $current_time;
145 $new_hash = md5($failure_time . $secret_key);
146 $json_data = '{"ft":' . $failure_time . ',"h":"' . $new_hash . '"}';
147
148 if ($config_id == 0) {
149 $db->execute_query('INSERT INTO `' . TABLE_PREFIX . 'config` (`id`, `name`, `value`) VALUES (?,?,?)', ['', 'report_lnfth', $json_data]);
150 }
151 else {
152 $db->execute_query('UPDATE `' . TABLE_PREFIX . 'config` SET value=? WHERE name=?', [$json_data, 'report_lnfth']);
153 }
154 }
155
156 if ($print_error_flag == 1) {
157 Main::print_error('Unable to validate license. If you are repeatedly getting this error please contact support desk.');
158 exit();
159 }
160 else {
161 return 1;
162 }
163 }
164
165 public function before_execute()
166 {
167 parent::before_execute();
168 $curr_folder = substr(getcwd(), strrpos(getcwd(), DIRECTORY_SEPARATOR) + 1);
169
170 if ($curr_folder != INSTALL_DIR) {
171 date_default_timezone_set(Configuration::get_instance()->read('default_time_zone'));
172 }
173 }
174
175 public function get_fraud_type($type)
176 {
177 if ($type == 1) {
178 $fraud = $this->get_label('repetitive click');
179 }
180 else if ($type == 2) {
181 $fraud = $this->get_label('publisher fraud click');
182 }
183 else if ($type == 3) {
184 $fraud = $this->get_label('invalid ip click');
185 }
186 else if ($type == 4) {
187 $fraud = $this->get_label('invalid geo click');
188 }
189 else if ($type == 5) {
190 $fraud = $this->get_label('proxy click');
191 }
192 else if ($type == 6) {
193 $fraud = $this->get_label('bot click');
194 }
195 else if ($type == 7) {
196 $fraud = $this->get_label('ip limit exceed');
197 }
198
199 return $fraud;
200 }
201
202 public function get_publisher_top_adunits($time_flag = 3, $pid = 0, $display_type = 0)
203 {
204 $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
205 $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
206 $html_addon_enabled = $this->get_addon_status('html_enabled');
207 $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
208 $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
209 $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
210 $result_array = [];
211 $db = DAL::get_instance();
212 $query_string = '';
213 $uidspc_str = '';
214
215 if ($pid == 0) {
216 $query_string = '';
217 $uidspc_str = '';
218 }
219 else {
220 $query_string .= ' s.uid=\'' . $pid . '\' and ';
221 $uidspc_str .= ' and a.pubid=\'' . $pid . '\' ';
222 }
223
224 $impressionstring = '';
225 $datastring = '';
226
227 if ($display_type == 0) {
228 $impressionstring = ' sum(s.pub_profit) ';
229 $datastring = ' AND (display_type=0 OR display_type=4) ';
230 }
231 else if (($display_type == 1) && ($cpm_addon_enabled == 1) && ($html_addon_enabled == 1)) {
232 $impressionstring = ' sum(s.cpm_profit+s.html_profit) ';
233 $datastring = ' AND (display_type=1 OR display_type=4) ';
234 }
235 else if (($display_type == 1) && ($cpm_addon_enabled == 1)) {
236 $impressionstring = ' sum(s.cpm_profit) ';
237 $datastring = ' AND (display_type=1 OR display_type=4) ';
238 }
239 else if (($display_type == 1) && ($html_addon_enabled == 1)) {
240 $impressionstring = ' sum(s.html_profit) ';
241 $datastring = ' AND (display_type=1 OR display_type=4) ';
242 }
243 else if (($display_type == 6) && ($cpa_addon_enabled == 1)) {
244 $impressionstring = ' sum(s.cpa_profit) ';
245 $datastring = ' AND (display_type=6 OR display_type=4) ';
246 }
247 else if (($display_type == 9) && ($pop_addon_enabled == 1)) {
248 $impressionstring = ' sum(s.pop_profit) ';
249 $datastring = ' AND (display_type=9) ';
250 }
251 else if (($display_type == 12) && ($affiliate_addon_enabled == 1)) {
252 $impressionstring = ' sum(s.affiliate_profit) ';
253 $datastring = ' AND (display_type=12) ';
254 }
255 else if (($display_type == 13) && ($cpv_addon_enabled == 1)) {
256 $impressionstring = ' sum(s.cpv_profit) ';
257 $datastring = ' AND (display_type=13) ';
258 }
259
260 $text_ads_enabled = Configuration::get_instance()->read('text-ads_enabled');
261 $adtype_str = '';
262
263 if ($this->get_addon_status('interstitial_enabled') != 1) {
264 $adtype_str .= ' ab.banner_type <>1 ';
265 }
266
267 if ($this->get_addon_status('text-image-ads_enabled') != 1) {
268 if ($adtype_str != '') {
269 $adtype_str .= ' AND ';
270 }
271
272 $adtype_str .= ' ab.banner_type <>3 ';
273 }
274
275 if ($this->get_addon_status('skin-ads_enabled') != 1) {
276 if ($adtype_str != '') {
277 $adtype_str .= ' AND ';
278 }
279
280 $adtype_str .= ' ab.banner_type <>4 ';
281 }
282
283 if ($text_ads_enabled != 1) {
284 if ($adtype_str != '') {
285 $adtype_str .= ' AND ';
286 }
287
288 $adtype_str .= ' ab.type <>1 ';
289 }
290
291 if ($adtype_str != '') {
292 $adtype_str = ' AND ((' . $adtype_str . ') OR ab.banner_type IS NULL) ';
293 }
294
295 if ($time_flag == 1) {
296 $start_time = date('Y', time());
297 $start_time .= date('m', time());
298 $start_time .= date('d', time());
299 $start = $start_time;
300 $table = TABLE_PREFIX . 'statistics_pub_daily';
301 }
302 else if ($time_flag == 2) {
303 $start_time = date('Y', time());
304 $start_time .= date('m', time());
305 $start_time .= date('d', time());
306
307 for ($i = 0; $i < 13; $i++) {
308 $start_time = $this->get_previous_day($start_time);
309 }
310
311 $start = $start_time;
312 $table = TABLE_PREFIX . 'statistics_pub_daily';
313 }
314 else if ($time_flag == 3) {
315 $start_time = date('Y', time());
316 $start_time .= date('m', time());
317 $start_time .= date('d', time());
318
319 for ($i = 0; $i < 29; $i++) {
320 $start_time = $this->get_previous_day($start_time);
321 }
322
323 $start = $start_time;
324 $table = TABLE_PREFIX . 'statistics_pub_daily';
325 }
326 else if ($time_flag == 4) {
327 $start_time = date('Y', time());
328 $start_time .= date('m', time());
329 $start_temp = $start_time;
330
331 for ($i = 0; $i < 11; $i++) {
332 $start_time = $this->get_previous_month($start_time);
333 }
334
335 $start = $start_time;
336 $table = TABLE_PREFIX . 'statistics_pub_monthly';
337 $table1 = TABLE_PREFIX . 'statistics_pub_monthly_temp';
338 }
339 else if ($time_flag == 5) {
340 $start_temp = date('Y', time());
341 $start = 0;
342 $table = TABLE_PREFIX . 'statistics_pub_yearly';
343 $table1 = TABLE_PREFIX . 'statistics_pub_yearly_temp';
344 }
345 if (($time_flag == 1) || ($time_flag == 2) || ($time_flag == 3)) {
346 $row = 'SELECT a.id as aduid,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY ' . $impressionstring . ' DESC LIMIT 0,6';
347 $row_res = $db->execute_query($row, [$start]);
348 }
349 else if (($time_flag == 4) || ($time_flag == 5)) {
350 $row = 'SELECT x.aduid as aduid,x.apubid as apubid,x.aduname as aduname,x.disp as disp FROM' . "\r\n\t\t" . '((SELECT a.id as aduid,' . $impressionstring . ' as impss,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)' . "\r\n\t\t\t\t" . 'UNION (SELECT a.id as aduid,' . $impressionstring . ' as impss,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table1 . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)) as x GROUP BY x.aduid ORDER BY sum(x.impss) DESC LIMIT 0,6';
351 $row_res = $db->execute_query($row, [$start, $start_temp]);
352 }
353
354 $key = 0;
355
356 while ($row_result = $row_res->fetch_assoc()) {
357 $result_array[$key][0] = $row_result['aduid'];
358 $result_array[$key][1] = $row_result['apubid'];
359
360 if (0 < $row_result['apubid']) {
361 $result_array[$key][2] = $this->get_user_name($row_result['apubid']);
362 }
363 else {
364 $result_array[$key][2] = $this->get_label('admin');
365 }
366
367 $result_array[$key][3] = $row_result['aduname'];
368 $result_array[$key][4] = $row_result['disp'];
369 $key = $key + 1;
370 }
371
372 return $result_array;
373 }
374
375 public function get_advertiser_top_ads($time_flag = 3, $uid = 0, $display_type = 0)
376 {
377 $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
378 $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
379 $html_addon_enabled = $this->get_addon_status('html_enabled');
380 $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
381 $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
382 $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
383 $text_ads_enabled = Configuration::get_instance()->read('text-ads_enabled');
384 $result_array = [];
385 $db = DAL::get_instance();
386 $query_string = '';
387 $uidspc_str = '';
388
389 if ($uid == 0) {
390 $query_string = '';
391 $uidspc_str = '';
392 }
393 else {
394 $query_string .= ' s.uid=\'' . $uid . '\' and ';
395 $uidspc_str .= ' and a.uid=\'' . $uid . '\' ';
396 }
397
398 if ($time_flag == 1) {
399 $start_time = date('Y', time());
400 $start_time .= date('m', time());
401 $start_time .= date('d', time());
402 $start = $start_time;
403 $table = TABLE_PREFIX . 'statistics_adv_daily';
404 }
405 else if ($time_flag == 2) {
406 $start_time = date('Y', time());
407 $start_time .= date('m', time());
408 $start_time .= date('d', time());
409
410 for ($i = 0; $i < 13; $i++) {
411 $start_time = $this->get_previous_day($start_time);
412 }
413
414 $start = $start_time;
415 $table = TABLE_PREFIX . 'statistics_adv_daily';
416 }
417 else if ($time_flag == 3) {
418 $start_time = date('Y', time());
419 $start_time .= date('m', time());
420 $start_time .= date('d', time());
421
422 for ($i = 0; $i < 29; $i++) {
423 $start_time = $this->get_previous_day($start_time);
424 }
425
426 $start = $start_time;
427 $table = TABLE_PREFIX . 'statistics_adv_daily';
428 }
429 else if ($time_flag == 4) {
430 $start_time = date('Y', time());
431 $start_time .= date('m', time());
432 $start_temp = $start_time;
433
434 for ($i = 0; $i < 11; $i++) {
435 $start_time = $this->get_previous_month($start_time);
436 }
437
438 $start = $start_time;
439 $table = TABLE_PREFIX . 'statistics_adv_monthly';
440 $table1 = TABLE_PREFIX . 'statistics_adv_monthly_temp';
441 }
442 else if ($time_flag == 5) {
443 $start_temp = date('Y', time());
444 $start = 0;
445 $table = TABLE_PREFIX . 'statistics_adv_yearly';
446 $table1 = TABLE_PREFIX . 'statistics_adv_yearly_temp';
447 }
448
449 $impressionstring = '';
450 $uidstrings = '';
451
452 if ($display_type == 0) {
453 $impressionstring = ' sum(s.money_spent) ';
454 $uidstrings = ' and a.uid<>0 ';
455 }
456 else if (($display_type == 1) && ($cpm_addon_enabled == 1)) {
457 $impressionstring = ' sum(s.cpm_spend) ';
458 $uidstrings = ' and a.uid<>0 ';
459 }
460 else if (($display_type == 2) && ($html_addon_enabled == 1)) {
461 $impressionstring = ' sum(s.html_profit) ';
462 $uidstrings = ' and a.uid=0 AND a.html_default =0 ';
463 }
464 else if (($display_type == 6) && ($cpa_addon_enabled == 1)) {
465 $impressionstring = ' sum(s.cpa_spend) ';
466 $uidstrings = ' and a.uid<>0 ';
467 }
468 else if (($display_type == 9) && ($pop_addon_enabled == 1)) {
469 $impressionstring = ' sum(s.pop_spend) ';
470 $uidstrings = ' and a.uid<>0 ';
471 }
472 else if (($display_type == 12) && ($affiliate_addon_enabled == 1)) {
473 $impressionstring = ' sum(s.affiliate_spend) ';
474 $uidstrings = ' and a.uid<>0 ';
475 }
476 else if (($display_type == 13) && ($cpv_addon_enabled == 1)) {
477 $impressionstring = ' sum(s.cpv_spend) ';
478 $uidstrings = ' and a.uid<>0 ';
479 }
480
481 $adtype_str = '';
482
483 if ($this->get_addon_status('ecommerce-ads_enabled') != 1) {
484 $adtype_str .= ' AND a.type <>7 ';
485 }
486 else {
487 $adtype_str .= ' AND (a.type <>7 OR (a.type =7 AND a.ecommerce_parent >0)) ';
488 }
489
490 if ($this->get_addon_status('text-image-ads_enabled') != 1) {
491 $adtype_str .= ' AND a.type <>11 ';
492 }
493
494 if ($this->get_addon_status('interstitial_enabled') != 1) {
495 $adtype_str .= ' AND a.type <>5 ';
496 }
497
498 if ($cpv_addon_enabled != 1) {
499 $adtype_str .= ' AND a.type <>13 ';
500 }
501
502 if ($this->get_addon_status('skin-ads_enabled') != 1) {
503 $adtype_str .= ' AND a.type <>14 ';
504 }
505
506 if ($text_ads_enabled != 1) {
507 $adtype_str .= ' AND a.type <>1 ';
508 }
509 if (($time_flag == 1) || ($time_flag == 2) || ($time_flag == 3)) {
510 $row = 'SELECT a.id as ad_id,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=? and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY ' . $impressionstring . ' DESC LIMIT 0,6';
511 $row_res = $db->execute_query($row, [$start, 1, $display_type]);
512 }
513 else if (($time_flag == 4) || ($time_flag == 5)) {
514 $row = 'SELECT x.ad_id as ad_id,x.auid as auid,x.aname as aname FROM' . "\r\n\t\t" . '((SELECT a.id as ad_id,' . $impressionstring . ' as impss,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=1 and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)' . "\r\n\t\t\t\t" . 'UNION (SELECT a.id as ad_id,' . $impressionstring . ' as impss,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table1 . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=1 and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)) as x GROUP BY x.ad_id ORDER BY sum(x.impss) DESC LIMIT 0,6';
515 $row_res = $db->execute_query($row, [$start, $display_type, $start_temp, $display_type]);
516 }
517
518 $key = 0;
519
520 while ($row_result = $row_res->fetch_assoc()) {
521 $result_array[$key][0] = $row_result['ad_id'];
522 $result_array[$key][1] = $row_result['auid'];
523 $result_array[$key][2] = $this->get_user_name($row_result['auid']);
524 $result_array[$key][3] = $row_result['aname'];
525 $key = $key + 1;
526 }
527
528 return $result_array;
529 }
530
531 public function get_suggested_value_ad($type, $aid, $bannerid = 0, $pricing = 0, $device = 2)
532 {
533 $increment_value = 0.01;
534 $db = DAL::get_instance();
535 $uid = $this->read_cookie_param(COOKIE_LOGINID);
536 $devicestring = '';
537
538 if ($device != 2) {
539 $devicestring = ' AND (a.device=2 OR a.device=' . $device . ') ';
540 }
541 if (($type == 2) || ($type == 7)) {
542 $typestring = ' AND (a.type=2 OR a.type=7) ';
543 }
544 else {
545 $typestring = ' AND a.type=' . $type . ' ';
546 }
547
548 $ds_places = Configuration::get_instance()->read('decimal_place');
549 $sugest_val = $db->read_single_column('SELECT COALESCE(round(max(default_rate),' . $ds_places . '),0) FROM ' . "\r\n\t\t\t\t" . TABLE_PREFIX . 'ads a ' . "\r\n\t\t\t\t" . 'WHERE a.status=1 ' . "\r\n\t\t\t\t" . 'AND a.id<>? ' . "\r\n\t\t\t\t" . 'AND a.display_type=' . $pricing . "\r\n\t\t\t\t" . $devicestring . "\r\n\t\t\t\t\r\n\t\t\t\t" . $typestring . "\r\n\t\t\t\t" . 'AND a.banner_id=?', [$aid, $bannerid]);
550 $minvalue = $this->get_minrate_by_uid($uid, $pricing);
551
552 if ($minvalue <= $sugest_val) {
553 $value = $sugest_val + $increment_value;
554 }
555 else {
556 $value = $minvalue;
557 }
558
559 return $value;
560 }
561
562 public function get_date_format($type, $year, $month = '', $day = '', $hour = '')
563 {
564 $d = Configuration::get_instance()->read('day_format');
565 $m = Configuration::get_instance()->read('month_format');
566 $y = Configuration::get_instance()->read('year_format');
567 $dp = Configuration::get_instance()->read('day_position');
568 $ds = Configuration::get_instance()->read('day_separator');
569 $hs = Configuration::get_instance()->read('time_separator');
570 $hds = Configuration::get_instance()->read('hour_display_format');
571 $h = Configuration::get_instance()->read('hour_format');
572 $mfor = Configuration::get_instance()->read('minute_format');
573 $sfor = Configuration::get_instance()->read('second_format');
574
575 if ($type == 2) {
576 $time = $year;
577 $cday = date('j', $time);
578 $cday1 = date('d', $time);
579 $cmonth0 = date('n', $time);
580 $cmonth = date('m', $time);
581 $cmonth1 = date('M', $time);
582 $cyear = date('y', $time);
583 $cyear1 = date('Y', $time);
584
585 if ($hds == 12) {
586 if ($h == 'HH') {
587 $chour = date('h', $time);
588 }
589 else {
590 $chour = date('g', $time);
591 }
592 }
593 else if ($hds == 24) {
594 if ($h == 'HH') {
595 $chour = date('H', $time);
596 }
597 else {
598 $chour = date('G', $time);
599 }
600 }
601
602 $cminute = date('i', $time);
603
604 if ($mfor == 'M') {
605 if ($cminute < 10) {
606 $cminute = substr($cminute, -1);
607 }
608 }
609
610 $csecond = date('s', $time);
611
612 if ($sfor == 'S') {
613 if ($csecond < 10) {
614 $csecond = substr($csecond, -1);
615 }
616 }
617
618 $cformat = date('A', $time);
619 $datestring = '';
620
621 if ($d == 'd') {
622 $datestring_day = $cday;
623 }
624 else if ($d == 'D') {
625 $datestring_day = $cday1;
626 }
627
628 if ($m == 'm') {
629 $daystring_month = $cmonth0;
630 }
631 else if ($m == 'M') {
632 $daystring_month = $cmonth;
633 }
634 else if ($m == 'Mon') {
635 $daystring_month = $cmonth1;
636 }
637
638 if ($y == 'y') {
639 $daystring_year = $cyear;
640 }
641 else if ($y == 'Y') {
642 $daystring_year = $cyear1;
643 }
644
645 if ($hds == 12) {
646 $daystring_time = ' ' . $chour . $hs . $cminute . $hs . $csecond . ' ' . $cformat;
647 }
648 else if ($hds == 24) {
649 $daystring_time = ' ' . $chour . $hs . $cminute . $hs . $csecond;
650 }
651
652 if ($dp == 1) {
653 $datestring = $datestring_day . $ds . $daystring_month . $ds . $daystring_year . $daystring_time;
654 }
655 else if ($dp == 2) {
656 $datestring = $daystring_month . $ds . $datestring_day . $ds . $daystring_year . $daystring_time;
657 }
658 else if ($dp == 3) {
659 $datestring = $daystring_year . $ds . $daystring_month . $ds . $datestring_day . $daystring_time;
660 }
661 else if ($dp == 4) {
662 $datestring = $daystring_year . $ds . $datestring_day . $ds . $daystring_month . $daystring_time;
663 }
664
665 return $datestring;
666 }
667
668 if ($type == 1) {
669 $day_str = '';
670 $month_str = '';
671 $hour_str = '';
672
673 if ($hour != '') {
674 $hour_str = ' ' . $hour;
675 }
676
677 if ($day != '') {
678 if ($d == 'd') {
679 $day_first = substr($day, 0, 1);
680
681 if ($day_first == 0) {
682 $day = substr($day, 1, 1);
683 }
684 }
685
686 if ($dp == 3) {
687 $day_str = $day;
688 }
689 else {
690 $day_str = $day . $ds;
691 }
692 }
693
694 if ($month != '') {
695 if ($m == 'm') {
696 $month_first = substr($month, 0, 1);
697
698 if ($month_first == 0) {
699 $month = substr($month, 1, 1);
700 }
701 }
702 else if ($m == 'Mon') {
703 if ($month == '01') {
704 $month = 'Jan';
705 }
706 else if ($month == '02') {
707 $month = 'Feb';
708 }
709 else if ($month == '03') {
710 $month = 'Mar';
711 }
712 else if ($month == '04') {
713 $month = 'Apr';
714 }
715 else if ($month == '05') {
716 $month = 'May';
717 }
718 else if ($month == '06') {
719 $month = 'Jun';
720 }
721 else if ($month == '07') {
722 $month = 'Jul';
723 }
724 else if ($month == '08') {
725 $month = 'Aug';
726 }
727 else if ($month == '09') {
728 $month = 'Sep';
729 }
730 else if ($month == '10') {
731 $month = 'Oct';
732 }
733 else if ($month == '11') {
734 $month = 'Nov';
735 }
736 else if ($month == '12') {
737 $month = 'Dec';
738 }
739 }
740
741 if ($dp == 4) {
742 $month_str = $month;
743 }
744 else {
745 $month_str = $month . $ds;
746 }
747 }
748
749 if ($y == 'y') {
750 $year = substr($year, 2, 2);
751 }
752
753 if ($dp == 1) {
754 $d_format = $day_str . $month_str . $year . $hour_str;
755...................................................................................
756....................................................
757.........................