· 5 years ago · Feb 18, 2020, 07:08 AM
1# SkillonNet Hacked #
2# Did not respond to emails for over 2 weeks #
3# Hereby we are going to leak all source code of all casinos using SkillonNet #
4
5<?
6$benches = array();
7start_bench('TOTAL');
8
9if(!isset($_REQUEST['runcron'])) {
10 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
11}
12if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) && $_SERVER['HTTP_CF_CONNECTING_IP'] != $_SERVER['REMOTE_ADDR']) {
13 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
14}
15
16require_once('/project_new/declares/connect_report_center.php');
17require_once('/project_new/declares/connect_kpax_cms.php');
18require_once('/project_new/declares/connect_rk.php');
19require_once('/project_new/email_routing_service/commonData.php');
20require_once('/project_new/declares/device_detector.php');
21require_once('/project_new/gotodomains.com/funcs.php');
22$cashierUrl = 'https://secure.skilldnsproc.com/servlet/dispatch?dispatch=cashier&token=IQX6M7SGI541KV35J1AA120416023937';
23$globals = array();
24$maintenance = false;
25$logging = true;
26$maintenance_logging = false;
27$maintenance_start = '';
28$maintenance_end = '';
29$exception_users = array();
30$time = time();
31$cache = true;
32$globals['country'] = (isset($_REQUEST['country']) ? $_REQUEST['country'] : '');
33if($maintenance_start != '' && strtotime(date('Y-m-d H:i:s')) >= $maintenance_start && strtotime(date('Y-m-d H:i:s')) <= $maintenance_end)
34 show_maintenance_window('maintenance scheduled from: ' . $maintenance_start . ' to: ' . $maintenance_end);
35elseif($maintenance == true)
36 show_maintenance_window('maintenance manually set');
37
38start_bench('clean input');
39foreach ($_REQUEST as $k=>$v) { $_REQUEST[$k] = pg_escape_string($_REQUEST[$k]);}
40end_bench('clean input');
41
42start_bench('detect device');
43$dd = new Device_Detector;
44$mobile = ($dd->isMobile() ? ' mobile_device' : ' non_mobile_device');
45end_bench('detect device');
46
47start_bench('connect to databases');
48//connect to reports center
49$rc = new DB_connect;
50$rc_connection = $rc->db_connect_reports_center();
51//connect to kpax_cms
52$kc = new DB_connect_cms;
53$kc_connection = $kc->db_connect_kpax_cms();
54$rk = new DB_connect_rk;
55$rk_connection = $rk->db_connect_rk();
56end_bench('connect to databases');
57
58function connectRedis() {
59 $redis = new Redis();
60 $redis->pconnect('127.0.0.1');
61 $redis->select(9);
62
63 return $redis;
64}
65
66$redis = connectRedis();
67
68if(isset($perm_restricted_countries[$globals['country']]))
69 show_maintenance_window('maintenance manually set');
70
71if(isset($_REQUEST['clear_cache'])){
72 start_bench('clearing cache');
73 if(isset($_REQUEST['skin']))
74 $globals['app_name'] = str_replace(array('_T','_t'),'',$_REQUEST['skin']);
75 else
76 $globals['app_name'] = '';
77
78 clear_cache($globals['app_name']);
79
80 end_bench('clearing cache');
81}elseif(isset($_REQUEST['clear_prefix'])){
82 start_bench('clearing cache prefix');
83
84 $globals['app_name'] = str_replace('_T','',$_REQUEST['skin']);
85 clear_appname_cache($globals['app_name']);
86
87 end_bench('clearing cache prefix');
88}else{
89 if(isset($_REQUEST['skin']))
90 $globals['app_name'] = str_replace(array('_T','_t'),'',$_REQUEST['skin']);
91 else
92 $globals['app_name'] = '';
93}
94if($argv[1] == "runcron" || isset($_REQUEST['refetch_data'])){
95 $promotions = get_promotions(true);
96 echo "Promotions cached successfully!\r\n";
97 /* if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'groups')){
98 $user_groups = fetch_user_groups(true,true);
99 echo "User Groups cached successfully!\r\n";
100 } */
101 if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'tournaments')){
102 $tournaments = fetch_tournaments_stats(true);
103 echo "Tournaments Stats cached successfully!\r\n";
104 }
105 if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'translations')){
106 $translations = fetch_translations('all',true);
107 echo "Translations cached successfully!\r\n";
108 }
109 if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'rates')){
110 $exchange_rates = fetch_exchange_rates(true);
111 echo "Exchange Rates cached successfully!\r\n";
112 }
113 if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'brands')){
114 $brands = fetch_brand('all',true);
115 echo "Brands Data cached successfully \r\n";
116 }
117 if(isset($argv[2]) && ($argv[2] == "all" || $argv[2] == 'packages')){
118 $packages = get_packages(true);
119 echo "Packages cached successfully \r\n";
120 }
121 die();
122}elseif(isset($_REQUEST['refetch_promotions'])){
123 $promotions = get_promotions(true);
124 echo 'Promotions cached successfully!' . "\r\n";
125 die();
126}/* elseif(isset($_REQUEST['refetch_groups'])){
127 $user_groups = fetch_user_groups(false,true);
128 echo 'User groups cached successfully!' . "\r\n";
129 //var_dump($user_groups);
130 die();
131} */
132elseif(isset($_REQUEST['refetch_translations'])){
133 $translations = fetch_translations('all',true);
134 echo 'Translations cached successfully!' . "\r\n";
135 //var_dump($translations);
136 die();
137}elseif(isset($_REQUEST['refetch_packages'])){
138 $packages = get_packages(true);
139 echo "Packages cached successfully \r\n";
140 //var_dump($packages);
141 die();
142}elseif(isset($_REQUEST['refetch_brands'])){
143 $brands = fetch_brand('all',true);
144 echo "Brands Data cached successfully \r\n";
145 //var_dump($packages);
146 die();
147}
148if(isset($_REQUEST['skin']) && !isset($_REQUEST['promo_data']) && !isset($_REQUEST['used']) && !isset($_REQUEST['clicked'])){
149 if(isset($_REQUEST['clear_cache'])){
150 unset($_REQUEST['clear_cache']);
151 }
152 $parameters = encryptor('encrypt',$_REQUEST);
153 $cached_index = md5($parameters);
154 if($redis->exists($cached_index))
155 $parameters = $redis->get($cached_index);
156 $redis->set($cached_index,$parameters,21600); //store the request in memory for 6 hours
157 /* file_put_contents('/project_new/promos.playeroffers.com/test_queries.log', date('Y-m-d H:i:s')." :: ---------------------------------------REQUEST-START ----------------------------------------------" . "\n\n", FILE_APPEND|LOCK_EX);
158 file_put_contents('/project_new/promos.playeroffers.com/test_queries.log', date('Y-m-d H:i:s')." ::" . json_encode($_REQUEST) . "\n\n", FILE_APPEND|LOCK_EX);
159 file_put_contents('/project_new/promos.playeroffers.com/test_queries.log', date('Y-m-d H:i:s')." :: ---------------------------------------REQUEST-END ----------------------------------------------" . "\n\n", FILE_APPEND|LOCK_EX); */
160 //if(isset($_REQUEST['test_nikos'])){
161 $globals['brand_data'] = fetch_brand($globals['app_name']);
162 show_preloader($cached_index);
163 die();
164 /* }else{
165 header('location: http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?q=' . $cached_index . '&pa=' . $_REQUEST['cashierUrl']);
166 } */
167}elseif(isset($_REQUEST['q']) && $redis->exists($_REQUEST['q'])&& !isset($_REQUEST['promo_data']) && !isset($_REQUEST['used']) && !isset($_REQUEST['clicked'])){
168
169 start_bench('encoded cached');
170
171 $q_request = $_REQUEST['q'];
172 $_REQUEST = json_decode(encryptor('decrypt',$redis->get($_REQUEST['q'])),TRUE);
173 $_REQUEST['q'] = $q_request;
174 if(isset($_REQUEST['clear_cache'])){
175 unset($_REQUEST['clear_cache']);
176 $redis->set($_REQUEST['q'],$_REQUEST,21600);
177 }
178
179 end_bench('encoded cached');
180}
181start_bench('globals');
182
183$globals['cached_index'] = $_REQUEST['q'];
184$globals['tournaments_stats'] = fetch_tournaments_stats();
185$globals['cashierUrl'] = (isset($_REQUEST['cashierUrl']) ? $_REQUEST['cashierUrl'] : (isset($_REQUEST['pa']) ? $_REQUEST['pa'] : $cashierUrl));
186$globals['lastDepositUrl'] = (isset($_REQUEST['lastDepositUrl']) ? $_REQUEST['lastDepositUrl'] : (isset($_REQUEST['pa']) ? $_REQUEST['pa'] : $cashierUrl));
187if(isset($_REQUEST['skin']) && $_REQUEST['skin'] != '')
188 $globals['app_name'] = str_replace('_T','',$_REQUEST['skin']);
189else{
190 $logged_hit = log_hit('','error_skin');
191 show_maintenance_window('skin_name not passed: ');
192}
193if(isset($_REQUEST['promo_data']) && !isset($_REQUEST['used']) && !isset($_REQUEST['clicked']) && !isset($_REQUEST['purchased'])){
194 $promo_data = explode('-',$_REQUEST['promo_data']);
195 if(strtotime(date('Y-m-d')) == $promo_data[0]){
196 echo json_encode(array('result' => TRUE));
197 }else{
198 echo json_encode(array('result' => FALSE));
199 }
200 die();
201}
202/* if(!isset($_REQUEST['rate']) && !isset($_REQUEST['used']) && !isset($_REQUEST['purchased']) && !isset($_REQUEST['clicked'])){
203} */
204if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] != '')
205 $globals['user_id'] = $_REQUEST['user_id'];
206else{
207 $logged_hit = log_hit('','error_userid');
208 show_maintenance_window('You are not logged in.');
209}
210if(isset($_REQUEST['username']) && $_REQUEST['username'] != ''){
211 $globals['username'] = $_REQUEST['username'];
212}else{
213 $logged_hit = log_hit('','error_username');
214 show_maintenance_window('You are not logged in.');
215}
216
217$globals['user_ip'] = $_SERVER['REMOTE_ADDR'];
218
219if(isset($_REQUEST['custom_date']) && $_REQUEST['custom_date'] != ''/* && $globals['user_ip'] == '213.207.150.18' */)
220 $globals['custom_date'] = date('Y-m-d',strtotime($_REQUEST['custom_date']));
221else
222 unset($globals['custom_date']);
223
224//die("Unauthorized access. Your IP has been logged.");
225
226if(isset($_REQUEST['api_tech_test']) || isset($_REQUEST['no_log']) || isset($_REQUEST['dev']))
227 $logging = false;
228
229$globals['time'] = $time;
230list($cc, $region) = resolveRegionByIP($_SERVER['REMOTE_ADDR']);
231
232if(isset($_REQUEST['rate'])){
233 $rate = $_REQUEST['rate'];
234 $promo_id = $_REQUEST['promo_id'];
235 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
236 $logged = log_user_action($promo_id,'rate',$rate);
237 if(!isset($_REQUEST['dev']) && $_REQUEST['dev'] != 911)
238 $logged_hit = log_hit($promo_id,'rated');
239 echo json_encode(array('success' => $logged));
240 die();
241}elseif(isset($_REQUEST['used'])){
242 $promo_id = $_REQUEST['promo_id'];
243 $promo_data = explode('-',$_REQUEST['promo_data']);
244 $bonus_code = $_REQUEST['label'];
245 if(strtotime(date('Y-m-d')) == $promo_data[0]){
246 $schedule_date = (isset($promo_data[0]) ? date('Y-m-d H:i:s',$promo_data[0]) : '');
247 $schedule_id = (isset($promo_data[1]) ? $promo_data[1] : 0);
248 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
249 $logged = log_user_action($promo_id,'used','t',$schedule_id);
250 if(!isset($_REQUEST['dev']) && $_REQUEST['dev'] != 911)
251 $logged_hit = log_hit($promo_id,'used',$schedule_id,$schedule_date,$bonus_code);
252 echo json_encode(array('success' => $logged));
253 }else{
254 echo json_encode(array('status' => 'expired'));
255 }
256 die();
257}elseif(isset($_REQUEST['clicked'])){
258 $promo_id = $_REQUEST['promo_id'];
259 $promo_data = explode('-',$_REQUEST['promo_data']);
260 $bonus_code = $_REQUEST['label'];
261 if(strtotime(date('Y-m-d')) == $promo_data[0]){
262 $schedule_date = (isset($promo_data[0]) ? date('Y-m-d H:i:s',$promo_data[0]) : '');
263 $schedule_id = (isset($promo_data[1]) ? $promo_data[1] : 0);
264 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
265 $logged = log_user_action($promo_id,'clicked','t',$schedule_id);
266 if(!isset($_REQUEST['dev']) && $_REQUEST['dev'] != 911)
267 $logged_hit = log_hit($promo_id,'clicked',$schedule_id,$schedule_date,$bonus_code);
268 echo json_encode(array('success' => $logged));
269 }else{
270 echo json_encode(array('status' => 'expired'));
271 }
272 die();
273}elseif(isset($_REQUEST['purchased'])){
274 $promo_id = $_REQUEST['promo_id'];
275 $promo_data = explode('-',$_REQUEST['promo_data']);
276 if(strtotime(date('Y-m-d')) == $promo_data[0]){
277 $schedule_date = (isset($promo_data[0]) ? date('Y-m-d H:i:s',$promo_data[0]) : '');
278 $schedule_id = (isset($promo_data[1]) ? $promo_data[1] : 0);
279 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
280 $logged = log_user_action($promo_id,'purchased','t',$schedule_id);
281 $notes = $_REQUEST['purchased'];
282 if(!isset($_REQUEST['dev']))
283 $logged_hit = log_hit($promo_id,'purchased',$schedule_id,$schedule_date,$notes);
284 echo json_encode(array('success' => $logged));
285 }else{
286 echo json_encode(array('status' => 'expired'));
287 }
288 die();
289}
290$globals['pointer_events'] = '';
291if(isset($_REQUEST['history_viewer']))
292 $globals['pointer_events'] = ' disable_actions';
293/* elseif(isset($_REQUEST['like'])){
294 $promo_id = $_REQUEST['promo_id'];
295 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
296 $logged = log_user_action($promo_id,'liked','t');
297 echo json_encode(array('success' => $logged));
298 if(!isset($_REQUEST['dev']) && $_REQUEST['dev'] != 911)
299 $logged_hit = log_hit($promo_id,'liked');
300 die();
301}
302elseif(isset($_REQUEST['share'])){
303 $promo_id = $_REQUEST['promo_id'];
304 $globals['user_ip'] = (isset($_REQUEST['user_ip']) ? $_REQUEST['user_ip'] : $globals['user_ip']);
305 $logged = log_user_action($promo_id,'shared','t');
306 echo json_encode(array('success' => $logged));
307 if(!isset($_REQUEST['dev']) && $_REQUEST['dev'] != 911)
308 $logged_hit = log_hit($promo_id,'shared');
309 die();
310}*/
311
312if(!isset($_REQUEST['lang_id'])){
313 $abbrev_ends = end(explode('.',$globals['app_name']));
314 $globals['lang_id'] = strtoupper($abbrev_ends);
315 $globals['lang'] = (in_array($abbrev_ends,array('de','dk')) ? $abbrev_ends : 'en');
316}else{
317 $globals['lang_id'] = (isset($_REQUEST['lang_id']) ? (isset($languageCodes[ltrim($_REQUEST['lang_id'], '0')]) ? $languageCodes[ltrim($_REQUEST['lang_id'], '0')] : 'EN') : 'EN');
318 $globals['lang'] = strtolower($globals['lang_id']);
319}
320$globals['lang'] = ($globals['lang'] == 'da' ? 'dk' : $globals['lang']);
321$globals['lang'] = ($globals['lang'] == 'jp' ? 'ja' : $globals['lang']);
322$globals['language'] = fetch_language($globals['lang']);
323$globals['translations'] = fetch_translations($globals['lang']);
324$globals['free_spins_packages'] = get_packages();
325$globals['generated_packages'] = '';
326$globals['currencies'] = array('EUR' => '€','USD' => '$','AUD' => '$','CAD' => '$','GBP' => '£','ZAR' => 'R','KR' => 'kr','DKK' => 'kr','RUB' => 'py6','NOK' => 'Kr','SEK' => 'Kr');
327$globals['country'] = (isset($_REQUEST['country']) ? $_REQUEST['country'] : '');
328$globals['acc_type'] = (isset($_REQUEST['acc_type']) ? $_REQUEST['acc_type'] : '');
329$globals['vip_level'] = (isset($_REQUEST['vip_level']) ? (isset($vipLevel[$_REQUEST['vip_level']]) ? $vipLevel[$_REQUEST['vip_level']] : '') : '');
330$globals['acc_flag'] = (isset($_REQUEST['acc_flag']) ? $_REQUEST['acc_flag'] : '');
331$globals['v_man'] = (isset($_REQUEST['v_man']) ? strtolower($_REQUEST['v_man']) : '');
332$globals['dep_avg'] = (isset($_REQUEST['dep_avg']) ? $_REQUEST['dep_avg'] : '');
333$globals['fairplayrate'] = (isset($_REQUEST['fpr']) ? $_REQUEST['fpr'] : '');
334//$globals['fairplayrate'] = (isset($_REQUEST['fprvip']) ? $_REQUEST['fprvip'] : '');
335$globals['total_deposits'] = (isset($_REQUEST['TotalDeposits']) ? $_REQUEST['TotalDeposits'] : '');
336$globals['platform'] = (isset($_REQUEST['platform']) ? ($platformCodes[$_REQUEST['platform']] ? $platformCodes[$_REQUEST['platform']] : $platformCodes[1]) : $platformCodes[1]);
337$globals['hold'] = (isset($_REQUEST['hold']) ? $_REQUEST['hold'] : '');
338$globals['bb_rate'] = (isset($_REQUEST['bbr']) ? $_REQUEST['bbr'] : '');
339$globals['bonus_rate'] = (isset($_REQUEST['bonus_rate']) ? $_REQUEST['bonus_rate'] : '');
340$globals['bonusbalance'] = (isset($_REQUEST['bonusbalance']) ? $_REQUEST['bonusbalance'] : '');
341$globals['dep_count'] = (isset($_REQUEST['dep_count']) ? $_REQUEST['dep_count'] : '');
342$globals['betstodepositrate'] = (isset($_REQUEST['betstodepositrate']) ? $_REQUEST['betstodepositrate'] : '');
343$globals['top_app_type'] = (isset($_REQUEST['top_app_type']) ? $_REQUEST['top_app_type'] : '');
344$globals['ext_id'] = (isset($_REQUEST['ext_id']) ? $_REQUEST['ext_id'] : '');
345$globals['type'] = $_REQUEST['type'];
346$globals['aname'] = (isset($_REQUEST['affiliate']) ? $_REQUEST['affiliate'] : 'NA');
347$globals['vip'] = (isset($_REQUEST['vip']) ? ($_REQUEST['vip'] == 1 ? true : false) : false);
348$globals['temp_user'] = (isset($_REQUEST['temp_user']) ? ($_REQUEST['temp_user'] == 1 ? true : false) : false);
349$globals['avgbet'] = (isset($_REQUEST['AVGBET']) ? $_REQUEST['AVGBET']:0);
350$globals['brand_data'] = fetch_brand($globals['app_name']);
351$globals['langs_array'] = get_languages_url($globals['brand_data']['id']);
352if(is_numeric($_REQUEST['cur']) && isset($currencyCodes[$_REQUEST['cur']])){
353 $globals['currency'] = $currencyCodes[$_REQUEST['cur']];
354 $globals['currency_symbol'] = $globals['currencies'][$globals['currency']];
355}elseif(!is_numeric($_REQUEST['cur']) && isset($currency_symbols[$_REQUEST['cur']])){
356 $globals['currency'] = $_REQUEST['cur'];
357 $globals['currency_symbol'] = $currency_symbols[$_REQUEST['cur']];
358}elseif(!is_numeric($_REQUEST['cur']) && isset($globals['currencies'][$_REQUEST['cur']])){
359 $globals['currency'] = $_REQUEST['cur'];
360 $globals['currency_symbol'] = $globals['currencies'][$_REQUEST['cur']];
361}else{
362 $globals['currency'] = 'EUR';
363 $globals['currency_symbol'] = $globals['currencies'][$globals['currency']];
364}
365
366start_bench('fetch_exchange_rates');
367$globals['curr_exchange_rates'] = fetch_exchange_rates();
368end_bench('fetch_exchange_rates');
369/*** OJO Parameters ***/
370$globals['ojo_level'] = (isset($_REQUEST['ojoLevel']) ? $_REQUEST['ojoLevel'] : '');
371$globals['ojo_level_progress'] = (isset($_REQUEST['ojoLevelProgress']) ? $_REQUEST['ojoLevelProgress'] : '');
372$globals['ojo_level_date'] = '0000-00-00';
373if(isset($_REQUEST['ojoLevelReachedDate']) && $_REQUEST['ojoLevelReachedDate'] != '' && $_REQUEST['ojoLevelReachedDate'] != '1970-01-01')
374 $globals['ojo_level_date'] = $_REQUEST['ojoLevelReachedDate'];
375/*** Dates Parameters ***/
376$globals['last_log'] = '0000-00-00';
377if(isset($_REQUEST['last_log']) && $_REQUEST['last_log'] != '' && $_REQUEST['last_log'] != '1970-01-01')
378 $globals['last_log'] = $_REQUEST['last_log'];
379$globals['last_dep'] = '0000-00-00';
380if(isset($_REQUEST['last_dep']) && $_REQUEST['last_dep'] != '' && $_REQUEST['last_dep'] != '1970-01-01')
381 $globals['last_dep'] = $_REQUEST['last_dep'];
382$globals['first_dep'] = '0000-00-00';
383if(isset($_REQUEST['1st_dep_date']) && $_REQUEST['1st_dep_date'] != '' && $_REQUEST['1st_dep_date'] != '1970-01-01')
384 $globals['first_dep'] = $_REQUEST['1st_dep_date'];
385$globals['last_bet'] = '0000-00-00';
386if(isset($_REQUEST['last_bet']) && $_REQUEST['last_bet'] != '' && $_REQUEST['last_bet'] != '1970-01-01')
387 $globals['last_bet'] = $_REQUEST['last_bet'];
388$globals['last_wd'] = '0000-00-00';
389if(isset($_REQUEST['last_wd_date']) && $_REQUEST['last_wd_date'] != '' && $_REQUEST['last_wd_date'] != '1970-01-01')
390 $globals['last_wd'] = $_REQUEST['last_wd_date'];
391$globals['last_dec'] = '0000-00-00';
392if(isset($_REQUEST['last_dec_date']) && $_REQUEST['last_dec_date'] != '' && $_REQUEST['last_dec_date'] != '1970-01-01')
393 $globals['last_dec'] = $_REQUEST['last_dec_date'];
394$globals['signup_date'] = '0000-00-00';
395if(isset($_REQUEST['signup_date']) && $_REQUEST['signup_date'] != '' && $_REQUEST['signup_date'] != '1970-01-01')
396 $globals['signup_date'] = $_REQUEST['signup_date'];
397$globals['dob'] = '0000-00-00';
398if(isset($_REQUEST['dob']) && $_REQUEST['dob'] != '' && $_REQUEST['dob'] != '1970-01-01')
399 $globals['dob'] = $_REQUEST['dob'];
400/*** Dates Parameters end ***/
401$globals['user_groups'] = array()/* fetch_user_groups(true) */;
402/* if(isset($_REQUEST['nikos'])){
403 $end_time=microtime(true);
404 $after_groups_time = "time_after_groups: ". bcsub($end_time, $script_start_time, 4). "\n";
405 $after_groups_memory = "memory (byte)after_groups: ". memory_get_peak_usage(true). "\n";
406 var_dump($after_groups_time);
407 var_dump($after_groups_memory);
408} */
409$ssl = '';
410if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
411 $ssl = 's';
412
413$globals['free_spins_url_base'] = 'http' . $ssl . '://' . $_SERVER['HTTP_HOST'] . '/bonusAPI.php';
414$globals['free_spins_url_base_data'] = array(
415 'username' => $globals['username'],
416 'user_id' => $globals['user_id'],
417 'country' => $globals['country'],
418 'cur' => $globals['currency'],
419 'skin' => $globals['app_name'],
420 'affiliate' => $globals['aname'],
421 'ext_id' => $globals['ext_id']
422);
423if(isset($language_date_formats[$globals['lang']]) && $language_date_formats[$globals['lang']] != '')
424 $globals['date_formats'] = $language_date_formats[$globals['lang']];
425else
426 $globals['date_formats'] = $language_date_formats['en'];
427if((isset($_REQUEST['bda']) && $_REQUEST['bda'] == '1') || (isset($_REQUEST['hwbda']) && $_REQUEST['hwbda'] == '1')){
428 $globals['bda'] = $_REQUEST['bda'];
429 $globals['hwbda'] = $_REQUEST['hwbda'];
430 $logged_hit = log_hit('','bda or hwbda');
431 show_maintenance_window('Your Daily Picks are currently not available.');
432}
433
434end_bench('globals');
435//addition: . &cmpgn_id=498,499,500&ref=48_test1
436echo build_available_promotions();
437/* if(isset($_REQUEST['nikos'])){
438 $end_time=microtime(true);
439 $after_processing_time = "time_after_processing: ". bcsub($end_time, $script_start_time, 4). "\n";
440 $after_processing_memory = "memory (byte)after_processing: ". memory_get_peak_usage(true). "\n";
441 var_dump($after_processing_time);
442 var_dump($after_processing_memory);
443} */
444end_bench('TOTAL');
445if(isset($_COOKIE['dailyTest'])) {
446 pre($_REQUEST, TRUE);
447 pre($benches, TRUE);
448 die("<br />DONE!");
449}
450
451function build_available_promotions() {
452 global $mobile,$dd,$kc_connection,$rc_connection,$globals,$languageCodes,$accType,$vipLevel,$platformCodes,$currencyCodes,$currency_symbols,$cache;
453
454 start_bench('build_available_promotions');
455 //$available_promotions = array();
456 $promotions_displayed = array();
457 $i;
458 $license_selections = array(
459 'Malta' => "'Malta','All','Malta_Curacao','Malta_Denmark','Malta_Denmark_UK','Malta_Curacao_UK'",
460 'Curacao' => "'Curacao','All','Malta_Curacao','Malta_Curacao_UK'",
461 'UK' => "'UK','All','Malta_Denmark_UK','Malta_Curacao_UK'",
462 'Denmark' => "'Denmark','All','Malta_Denmark','Malta_Denmark_UK'"
463 );
464 $tabs = array(/*'what_to_do' => array(
465 'tab_title' => 'What to do?',
466 'tab_content' => 'what_to_do',
467 ),*/
468 'what_you_get' => array(
469 'tab_title' => 'What you get',
470 'tab_content' => 'what_you_get',
471 ),
472 'token_terms' => array(
473 'tab_title' => 'Terms',
474 'tab_content' => 'token_terms',
475 )/*,
476 'token_restrictive_terms' => array(
477 'tab_title' => 'Restrictive Terms',
478 'tab_content' => 'token_restrictive_terms',
479 ) */
480 );
481 $website_license = $globals['brand_data']['license'];
482 $appAbbrev = $globals['brand_data']['abbrev'];
483 $logo_dir = '';
484 $brand_domain = $globals['brand_data']['domain'];
485 $website_langs = $globals['brand_data']['website_langs'];
486 $websiteDisplayName = $globals['brand_data']['website_sisplay_name'];
487 $resDomain = $globals['brand_data']['resDomain'];
488 $website_id = $globals['brand_data']['website_id'];
489 //$promotions = promotions_per_brand();
490
491 if(isset($_REQUEST['dev']) && (isset($_REQUEST['clear_cache']) || isset($_REQUEST['custom_date'])))
492 $promotions = get_promotions(true);
493 else
494 $promotions = get_promotions();
495 /* if(isset($_GET['nikos'])){
496 $stats_start_time=microtime(true);
497 $before_stats_memory = "memory (byte)before_stats: ". memory_get_peak_usage(true). "\n";
498 var_dump($before_stats_memory);
499 } */
500 $stats = get_stats();
501 //die();
502 $promo_translations = $promotions['promo_translations'];
503 if(!$dd->isMobile())
504 $promotions['promotions_days']['yesterday'][$appAbbrev] = array_merge($promotions['promotions_days']['yesterday'][$appAbbrev],$promotions['promotions_days']['always'][$appAbbrev]);
505 $promotions['promotions_days']['today'][$appAbbrev] = array_merge($promotions['promotions_days']['today'][$appAbbrev],$promotions['promotions_days']['always'][$appAbbrev]);
506 $promotions['promotions_days']['tomorrow'][$appAbbrev] = array_merge($promotions['promotions_days']['tomorrow'][$appAbbrev],$promotions['promotions_days']['always'][$appAbbrev]);
507 $promo_ids = implode(',',array_merge($promotions['promotions_days']['yesterday'][$appAbbrev],$promotions['promotions_days']['today'][$appAbbrev],$promotions['promotions_days']['tomorrow'][$appAbbrev]));
508 if(!isset($_REQUEST['dev']) && isset($_REQUEST['q']))
509 $logged_hit = log_hit($promo_ids);
510 if(!isset($_REQUEST['lang_id'])){
511 $logged_hit = log_hit($promo_ids,'language not specified');
512 }
513 //var_dump($promotions['promotions_days']);
514 //unset($promotions['promotions_days']['always']);
515 //var_dump($promo_ids);
516 $request_data = base64_encode(json_encode($_REQUEST));
517 $header = '<!DOCTYPE html>' .
518 '<html dir="ltr" lang="en-US">' .
519 '<head profile="http://gmpg.org/xfn/11">' .
520 //'<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10">' .
521 '<meta charset="utf-8">' .
522 '<meta http-equiv="X-UA-Compatible" content="IE=edge">' .
523 '<meta name="viewport" content="width=device-width, initial-scale=1">' .
524 '<meta http-equiv="Content-Language" content="en" />' .
525 '<title>' . $globals['app_name'] . '</title>' .
526 '<meta name="Description" content="description" />' .
527 '<meta name="robots" content="index,follow">' .
528 '<meta name="google" content="notranslate" />' .
529 //'<meta name="og:site_name" content="' . $globals['app_name'] . '" />' .
530 //'<meta name="og:url" content="http://' . $globals['langs_array'][$globals['lang']]['promotions_url'] . '" />' .
531 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" />' .
532 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/star-rating.min.css" media="all" rel="stylesheet" type="text/css" />' .
533 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/flipclock.css" media="all" rel="stylesheet" type="text/css" />' .
534 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/slick.css" media="all" rel="stylesheet" type="text/css" />' .
535 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/slick-theme.css" media="all" rel="stylesheet" type="text/css" />' .
536 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.css?'.time().'" media="all" rel="stylesheet" type="text/css" />' .
537 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site_' . $appAbbrev . '.css?'.time().'" media="all" rel="stylesheet" type="text/css" />' .
538 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site_' . $appAbbrev . '.css?'.time().'" media="all" rel="stylesheet" type="text/css" />';
539 if($appAbbrev=='sm'/* in_array($appAbbrev,['sm','sm-uk','sm-dk']) */){
540 $header .= '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular&subset=Latin,Cyrillic">' .
541 '<style type="text/css">' .
542 'body {font-family: Ubuntu, serif!important;}' .
543 '</style>';
544 }else{
545 $header .= '<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=cyrillic,latin" rel="stylesheet" type="text/css">';
546 }
547 $header .= '<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=cyrillic,latin" rel="stylesheet" type="text/css">' .
548 '<!--[if lt IE 9]>' .
549 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/html5shiv.min.js"></script>' .
550 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/respond.min.js"></script>' .
551 '<![endif]-->' .
552 //'<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />' .
553 '<script type="text/javascript">' .
554 "var server_script_url = '" . $_SERVER['PHP_SELF'] . "';" .
555 '</script>' .
556 '</head>' .
557 '<body class="' . $appAbbrev . $mobile . ($globals['lang'] != 'en' ? ' ' . $globals['lang'] : '') . (str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?' dev':'') . '">' .
558 '<div class="loader_element"></div>' .
559 '<div class="loader"><img src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/ajax_loader.gif" /></div>' .
560 '<div class="rating_text" rel="1">' . $globals['translations']['Not for me.'] . '</div>' .
561 '<div class="rating_text" rel="2">' . $globals['translations']['Maybe another time.'] . '</div>' .
562 '<div class="rating_text" rel="3">' . $globals['translations']['Its OK.'] . '</div>' .
563 '<div class="rating_text" rel="4">' . $globals['translations']['Liked it.'] . '</div>' .
564 '<div class="rating_text" rel="5">' . $globals['translations']['Loved it!'] . '</div>' .
565 '<div class="alert_message success" id="success">' .
566 '<div class="header_bar">' .
567 '<span class="alert_message_close glyphicon glyphicon-ok-sign"></span>' . $globals['translations']['Confirmation'] .
568 '</div><br />' .
569 '<strong>' . $globals['translations']['Congratulations'] . '!</strong><br />' .
570 $globals['translations']['You have claimed this offer successfully'] . '<br /><br />' .
571 '<button type="button" class="alert_message_close btn-close">' . $globals['translations']['THANK YOU'] . '</button>' .
572 '</div>' .
573 '<div class="alert_message tournaments" id="tournaments_success">' .
574 '<div class="header_bar">' .
575 '<span class="alert_message_close glyphicon glyphicon-ok-sign"></span>' . $globals['translations']['Confirmation'] .
576 '</div><br />' .
577 '<strong>' . $globals['translations']['Congratulations'] . '!</strong><br />' .
578 $globals['translations']['You have claimed this offer successfully'] . '<br /><br />' .
579 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
580 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
581 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
582 $globals['translations']['TOURNAMENTS'] .
583 '<span class="glyphicon glyphicon-play"></span>' .
584 '</form>' .
585 '</div>' .
586 '<div class="alert_message tournaments" id="tournaments_warning">' .
587 '<div class="header_bar">' .
588 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
589 '</div><br />' .
590 $globals['translations']['You already claimed this offer.'] . '<br /><br />' .
591 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
592 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
593 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
594 $globals['translations']['TOURNAMENTS'] .
595 '<span class="glyphicon glyphicon-play"></span>' .
596 '</form>' .
597 '</div>' .
598 '<div class="alert_message warning" id="warning">' .
599 '<div class="header_bar">' .
600 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
601 '</div><br />' .
602 $globals['translations']['You already claimed this offer.'] . '<br /><br />' .
603 '<button type="button" class="alert_message_close btn-close">CLOSE</button>' .
604 '</div>' .
605 '<div class="alert_message error" id="error">' .
606 '<div class="header_bar">' .
607 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
608 '</div><br />' .
609 $globals['translations']['An error occured while processing your request.'] . '<br /><br />' .
610 '<button type="button" class="alert_message_close btn-close">' . $globals['translations']['CLOSE'] . '</button>' .
611 '</div>' .
612 '<div class="alert_message error" id="purchase_amount_error">' .
613 '<div class="header_bar">' .
614 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
615 '</div><br />' .
616 $globals['translations']['Amount missing or invalid'] . '<br /><br />' .
617 '<button type="button" class="alert_message_close btn-close">' . $globals['translations']['CLOSE'] . '</button>' .
618 '</div>' .
619 '<div class="alert_message error" id="purchase_insuficient_funds_error">' .
620 '<div class="header_bar">' .
621 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
622 '</div><br />' .
623 $globals['translations']['You have insufficient funds.'] . '<br />' .
624 $globals['translations']['Please select a lower amount or deposit.'] . '<br /><br />' .
625 '<button type="button" class="alert_message_close btn-close">' . $globals['translations']['CLOSE'] . '</button>' .
626 '</div>' .
627 '<div class="alert_message warning" id="expired">' .
628 '<div class="header_bar">' .
629 '<span class="alert_message_close glyphicon glyphicon-remove-sign"></span>' . $globals['translations']['ERROR'] .
630 '</div><br />';
631 if($appAbbrev == 'ojo' || $appAbbrev == 'ojo-uk' || $appAbbrev == 'ojo-dk')
632 $header .= $globals['translations']['Unfortunately this promotion has expired.<br />After your kickers reload, check what is available now.'] . '<br /><br />';
633 else
634 $header .= $globals['translations']['Unfortunately this promotion has expired.<br />After your daily picks reload, check what is available now.'] . '<br /><br />';
635 $header .= '<button type="button" class="alert_message_close btn-close">CLOSE</button>' .
636 '</div>' .
637 '<div class="main_container center-block' . $mobile . '">';
638 //$trophy_abbrev = (in_array($appAbbrev,array('test','eu','eu-dk','eu-uk','dg','dg-uk','dg-dk','dg-de')) ? 'white' : $appAbbrev);
639 /* if(in_array($appAbbrev,array('simba','simba-dk','simba-uk')))
640 $trophy_abbrev = 'sg';
641 elseif(in_array($appAbbrev,array('qv','qv-dk','qv-uk')))
642 $trophy_abbrev = 'sg'; */
643 /* $trophy_abbrev = (!in_array($appAbbrev,array('simba','simba-dk','simba-uk')) ? 'white' : 'sg');
644 $trophy_abbrev = (!in_array($appAbbrev,array('qv','qv-dk','qv-uk')) ? 'white' : 'qv'); */
645 $trophy_abbrev = str_replace(array('-dk','-uk','-de'),'',$appAbbrev);
646 $trophy_abbrev = ($trophy_abbrev == 'simba' ? 'sg' : ($trophy_abbrev == 'dg' ? 'white' : $trophy_abbrev));
647 if($dd->isMobile() /* && in_array($appAbbrev,array('test','eu','eu-dk','eu-uk','dg','dg-uk','dg-dk','dg-de','mega-new','mega-uk','mega-dk-new','em')) */){
648 $header .= '<div class="top_header">' .
649 '<div class="logo slogo"><img src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/' . (in_array($appAbbrev,array('dg-de','simba-dk')) ? $appAbbrev : ($appAbbrev == 'test' ? 'eu' : preg_replace('/-.*/','',$appAbbrev))) . (str_replace(array('-uk','-dk'),'',$appAbbrev)=='caf'?'_white':'') . '.png?v='.time().'" /></div>';
650 if($appAbbrev == 'ojo' || $appAbbrev == 'ojo-uk' || $appAbbrev == 'ojo-dk')
651 $header .= ''/* $globals['translations']['KICKERS'] */;
652 else
653 $header .= $globals['translations']['DAILY PICKS'];
654 if(!in_array($globals['brand_data']['abbrev'], ['dg-de','ojo','ojo-uk','ojo-dk'])){
655 $header .= '<div class="tournaments">' .
656 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
657 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
658 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
659 '<img class="trophy" src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/trophy_' . (in_array($appAbbrev,array('simba','simba-uk','simba-dk')) ? 'simba' : 'mobile') . '.png?v=2" />' .
660 '</form>' .
661 '</div>';
662 }
663 if(in_array($globals['brand_data']['abbrev'], ['ojo','ojo-uk','ojo-dk'])){
664 $header .='<span class="home-link' . $globals['pointer_events'] . '">X</span>';
665 }else{
666 $header .='<span class="home-link glyphicon glyphicon-home' . $globals['pointer_events'] . '"></span>';
667 }
668 $header .= '</div>';
669 if($globals['tournaments_stats']['tournaments_showed_today'] > 0 ){
670 if(!in_array($globals['brand_data']['abbrev'], ['dg-de'])){
671 if(in_array($globals['brand_data']['abbrev'], ['ojo','ojo-uk','ojo-dk'])){
672 $header .= '<div class="promo_tab_links">' .
673 '<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>' .
674 '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 btn btn-lg">' .
675 $globals['translations']['KICKERS'] .
676 '</div>' .
677 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"></div>' .
678 '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 btn btn-lg tournaments_action">' .
679 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
680 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
681 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
682 '<div class="action_button_container tournaments">' .
683 $globals['translations']['REEL SPINOFFS'] .
684 '</div>' .
685 '</form>' .
686 '</div>' .
687 '<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>' .
688 '<div class="clearfix"></div>' .
689 '</div>';
690 }else{
691 $header .= '<div class="tournaments tournaments_link">' .
692 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
693 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
694 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
695 '<div class="headlines row">' .
696 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-center trophy_logo">' .
697 '<img class="trophy" src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/trophy_' . (!in_array($appAbbrev,array('simba','simba-dk','simba-uk')) ? 'white' : 'sg') . '.png?v=2" />' .
698 '</div>' .
699 '<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5 tournaments_title">';
700 if($appAbbrev == 'ojo' || $appAbbrev == 'ojo-uk' || $appAbbrev == 'ojo-dk')
701 $header .= $globals['translations']['REEL SPINOFFS'];
702 else
703 $header .= $globals['translations']['TOURNAMENTS'];
704 $header .= '</div>' .
705 '<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 active_users text-center visible_portrait">' .
706 '<span class="glyphicon glyphicon-user">' . $globals['tournaments_stats']['active'] . '</span>' .
707 '</div>' .
708 '<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 active_users text-center visible_landscape">' .
709 '<span>' . $globals['tournaments_stats']['active'] . ' ' . $globals['translations']['Active Players'] . '</span>' .
710 '</div>' .
711 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 action_button_container">' .
712 '<span class="glyphicon glyphicon-play action_button"></span>' .
713 '</div>' .
714 '<div class="clearfix"></div>' .
715 '</div>' .
716 '</form>' .
717 '</div>';
718 }
719 }
720
721 }
722 $header .= '<div class="promotions_container block-center">';
723 }else{
724 $header .= '<a class="close glyphicon glyphicon-share-alt glyphicon-home glyphicon-flipped" href="' . $globals['cashierUrl'] . '"></a>'.
725 '<div class="promotions_container block-center">';
726 if($globals['tournaments_stats']['tournaments_showed_today'] > 0 ){
727 if(!in_array($globals['brand_data']['abbrev'], ['dg-de'])){
728 $header .= '<div class="tournaments">' .
729 '<form id="tournaments_form" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
730 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
731 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
732 '<img class="trophy" src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/trophy_' . $trophy_abbrev . '.png?v=2" />';
733 if($appAbbrev == 'ojo' || $appAbbrev == 'ojo-uk' || $appAbbrev == 'ojo-dk')
734 $header .= $globals['translations']['REEL SPINOFFS'];
735 else
736 $header .= $globals['translations']['TOURNAMENTS'];
737 $header .= '<span class="glyphicon glyphicon-play"></span>' .
738 '</form>' .
739 '</div>';
740 }
741 }
742 }
743 if(!$dd->isMobile()){
744 $header .= '<div class="promos-carousel">';
745 }
746 $footer = ($dd->isMobile() ? '<div class="footer_end clearfix"></div>' : '') .
747 '</div>' .
748 '</div>';
749 $end_doc = display_feeds_modal() .
750 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery-1.9.1.js"></script>' .
751 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/bootstrap.min.js"></script>' .
752 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery.mobile.custom.min.js"></script>' .
753 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/star-rating.min.js"></script>' .
754 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery.countdown.min.js"></script>' .
755 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/slick.min.js"></script>' .
756 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.js?'.time().'"></script>' .
757 '<script type="text/javascript" src="https://addevent.com/libs/atc/1.6.1/atc.min.js" async defer></script>
758 <script type="text/javascript">';
759 if(!$dd->isMobile()){
760 $end_doc .= "$(document).ready(function(){
761 $('.promos-carousel').slick({
762 arrows: true,
763 centerMode: true,
764 centerPadding: '0px',
765 slidesToScroll: 1,
766 infinite: false,
767 initialSlide: $('.initial-promo').index(),
768 slidesToShow: 3,
769 swipeToSlide: true
770 }).on('init',function(slick){
771 $('.promos-carousel').slick('slickGoTo', $('.initial-promo').index());
772 }).on('setPosition', function(slick) {
773 var slidesShown = $('.promos-carousel').slick('slickGetOption', 'slidesToShow');
774 var numberOfSlides = $('.promos-carousel').find('.slick-slide').length;
775 if (slidesShown === numberOfSlides) {
776 $('.promos-carousel').find('.slick-track').css('transform', 'translate3d(0px, 0px, 0px)');
777 }
778 });
779 $('.slick-slide').last().addClass('last-slide');
780 /*$('.slick-track').on('click','.slick-slide',function(e){
781 if(!$(e.target).is('.slick-current')) {
782 return false;
783 }
784 });*/
785 fix_slick_elements();
786 });
787 $(window).load(function(){
788 $('.reminder').show();
789 $('.slick-disabled').on('click',function(){
790 return false;
791 });
792 fix_slick_elements();
793 $('.loader_element').hide();
794 " . 'window.parent.postMessage({ "PA": "stopGenPreloader" }, "*");' .
795 "});
796 $(window).resize(function() {
797 fix_slick_elements();
798 });
799 /*$('.loadGame').not('.disable_actions').on('click',function(e){
800 e.preventDefault();
801 var game = $(this).attr('id');
802 window.parent.postMessage({ 'msgType': 'openGameFromDailyPics', 'itemID': game }, '*');
803 return false;
804 });*/
805 ";
806 }else{
807 $end_doc .= "
808 $(window).load(function(){
809 $('.promotion .promo_title').each(function(index){
810 var line_height = $(this).outerHeight();
811 if(line_height > 32){
812 $(this).css('line-height','20px');
813 }
814 });
815 //var users_line_height = parseInt($('.visible_landscape').css('line-height').replace('px',''));
816 var element_height = $('.visible_landscape span').height();
817 if(element_height > 34){
818 $('.visible_landscape').css('line-height','17px');
819 }
820 $('.reminder').show();
821 fix_slick_elements();
822 $('.loader_element').hide();
823 });
824 $(window).resize(function() {
825 $('.promotion .promo_title').each(function(index){
826 var line_height = $(this).outerHeight();
827 if(line_height > 32){
828 $(this).css('line-height','20px');
829 }
830 });
831 //$('.promos-carousel').slick('resize');
832 //var users_line_height = parseInt($('.visible_landscape').css('line-height').replace('px',''));
833 var element_height = $('.visible_landscape span').height();
834 if(element_height > 34){
835 $('.visible_landscape').css('line-height','17px');
836 }
837 fix_slick_elements();
838 });
839 /*$('.loadMobileGame').not('.disable_actions').on('click',function(e){
840 e.preventDefault();
841 var game = $(this).attr('id');
842 window.parent.postMessage({ 'msgType': 'openGameFromDailyPics', 'itemID': game }, '*');
843 return false;
844 });*/
845 ";
846 }
847 $temp_packages = $globals['free_spins_packages'];
848 foreach($temp_packages as $package_key => $package_values){
849 unset($temp_packages[$package_key]['bonus_id']);
850 $temp_packages[$package_key]['text_'] = $temp_packages[$package_key]['bonus_code'];
851 unset($temp_packages[$package_key]['bonus_code']);
852 }
853 $end_doc .= "function load_game(game,actions){
854 if(actions){
855 window.parent.postMessage({ 'msgType': 'openGameFromDailyPics', 'itemID': game }, '*');
856 }
857 }";
858 $end_doc .= "var packages = " . json_encode($temp_packages) . ";" .
859 '</script>' .
860 '</body>' .
861 '</html>';
862 $output = '';
863 $modals = '';
864 $first_today_promo = true;
865 //echo 'all available promotions: ' . sizeof($promotions['promotions']) . '<br />';
866 /* if(isset($_GET['nikos'])){
867 $end_time=microtime(true);
868 echo "time_before_promos_loop: ", bcsub($end_time, $start_time, 4), "\n";
869 echo "memory (byte)_before_promos_loop: ", memory_get_peak_usage(true), "\n";
870 } */
871 foreach($promotions['promotions_days'] as $promo_day => $promo_ids){
872 if($dd->isMobile && $promo_day == 'yesterday')
873 continue;
874 foreach($promo_ids[$appAbbrev] as $key => $value){
875 /* if(isset($_REQUEST['test_nikos'])){
876 var_dump($promotion['promo_id'].'<br />');
877 } */
878 $view_title = '';
879 $what_you_get = '';
880 $token_terms = '';
881 $token_restrictive_terms = '';
882 $show_promotion = true;
883 /* if(!isset($promotions['promotions_per_brand'][$appAbbrev][$value]))
884 continue; */
885 $promotion = $promotions['promotions'][$value];
886 $day_check = '';
887 if($promo_day != 'today')
888 $day_check = ' -1 day';
889 /* if($promotion['brands'] != '' && ((is_array($promotion['brands']) && !empty($promotion['brands']) && !isset($promotion['brands'][$appAbbrev])) || (!is_array($promotion['brands']) && $appAbbrev != $promotion['brands']))){
890 continue;
891 } */
892 # FIX THE AMPERSAND IN THE ARRAY...
893 if(isset($promotion['restricted_acc_types']) && is_array($promotion['restricted_acc_types'])) {
894 foreach($promotion['restricted_acc_types'] as $tmp => $restricted_acc_types) {
895 $promotion['restricted_acc_types'][str_replace('&', '&', $tmp)] = str_replace('&', '&', $restricted_acc_types);
896 }
897 }
898
899 //~ if(isset($globals['username']) && $globals['username']=='marab198385' && $promotion['promo_id'] == 196) {
900 //~ echo "<pre>".print_r($globals['acc_type'], TRUE)."</pre>";
901 //~ echo "<pre>".print_r($accType, TRUE)."</pre>";
902 //~ echo "<pre>".print_r($accType[$globals['acc_type']], TRUE)."</pre>";
903 //~ var_dump($accType[$globals['acc_type']]);
904 //~ echo "<pre>".print_r($promotion['restricted_acc_types'], TRUE)."</pre>";
905 //~ var_dump($promotion['restricted_acc_types']);
906 //~ echo "<pre>".print_r(isset($promotion['restricted_acc_types'][$accType[$globals['acc_type']]]), TRUE)."</pre>";
907 //~ echo "<pre>".print_r((1 == 1), TRUE)."</pre>";
908 //~ die();
909 //~ }
910 //var_dump($promotion['restricted_acc_types']);
911 //echo $promotion['restricted_acc_types'][$accType[$globals['acc_type']]] . "\r\n";
912 if($globals['acc_type'] != '' && $accType[$globals['acc_type']] != '' && is_array($promotion['restricted_acc_types']) && !empty($promotion['restricted_acc_types']) && isset($promotion['restricted_acc_types'][$accType[$globals['acc_type']]])){
913 continue;
914 }elseif($promotion['restricted_acc_types'] != '' && $accType[$globals['acc_type']] == $promotion['restricted_acc_types']){
915 continue;
916 }
917 if($globals['dep_avg'] != '' && is_array($promotion['dep_avg']) && !empty($promotion['dep_avg']) && !($globals['dep_avg'] >= $promotion['dep_avg'][0] && $globals['dep_avg'] < $promotion['dep_avg'][1])){
918 continue;
919 }elseif($globals['dep_avg'] != '' && $promotion['dep_avg'] != '' && !is_array($promotion['dep_avg']) && !empty($promotion['dep_avg'])){
920 //echo $promotion['promo_id'] . ' - ' . $promotion['dep_avg'] . '<br />';
921 if(strpos($promotion['dep_avg'],'<') !== false && $globals['dep_avg'] >= str_replace('<','',$promotion['dep_avg'])){
922 continue;
923 }elseif(strpos($promotion['dep_avg'],'>') !== false && $globals['dep_avg'] < str_replace('>','',$promotion['dep_avg'])){
924 continue;
925 }elseif(strpos($promotion['dep_avg'],'<') !== false && strpos($promotion['dep_avg'],'>') !== false && $promotion['dep_avg'] != $globals['dep_avg']){
926 continue;
927 }
928 }
929 if($globals['fairplayrate'] != '' && is_array($promotion['fairplayrate']) && !empty($promotion['fairplayrate']) && !($globals['fairplayrate'] >= $promotion['fairplayrate'][0] && $globals['fairplayrate'] < $promotion['fairplayrate'][1])){
930 continue;
931 }elseif($globals['fairplayrate'] != '' && $promotion['fairplayrate'] != '' && !is_array($promotion['fairplayrate']) && !empty($promotion['fairplayrate'])){
932 //echo $promotion['promo_id'] . ' - ' . $promotion['dep_avg'] . '<br />';
933 if(strpos($promotion['fairplayrate'],'<') !== false && number_format($globals['fairplayrate'], 2, '.', '')>= number_format(str_replace('<','',$promotion['fairplayrate']), 2, '.', '')){
934 continue;
935 }elseif(strpos($promotion['fairplayrate'],'>') !== false && number_format($globals['fairplayrate'], 2, '.', '') < number_format(str_replace('>','',$promotion['fairplayrate']), 2, '.', '')){
936 continue;
937 }elseif(strpos($promotion['fairplayrate'],'<') !== false && strpos($promotion['fairplayrate'],'>') !== false && $promotion['fairplayrate'] != $globals['fairplayrate']){
938 continue;
939 }
940 }
941 if(($promotion['restricted_vip_levels'] != '' && (is_array($promotion['restricted_vip_levels']) && !empty($promotion['restricted_vip_levels']) && isset($promotion['restricted_vip_levels'][$globals['vip_level']]))) || ($promotion['restricted_vip_levels'] == $globals['vip_level'] && $globals['vip_level'] != '')){
942 continue;
943 }
944 if($globals['vip_level'] != '' && is_array($promotion['restricted_vip_levels']) && !empty($promotion['restricted_vip_levels']) && isset($promotion['restricted_vip_levels'][$globals['vip_level']])){
945 continue;
946 }
947 if(isset($_REQUEST['custom_date'])){
948 $today_date = date('Y-m-d',strtotime($_REQUEST['custom_date']));
949 $today_ending_date = date('Y-m-d',strtotime($_REQUEST['custom_date'].' 23:59:59'));
950 $today_datetime = date('Y-m-d H:i:s',strtotime($_REQUEST['custom_date'].' 00:00:00'));
951 }
952 else{
953 $today_date = date('Y-m-d');
954 $today_ending_date = date('Y-m-d').' 23:59:59';
955 $today_datetime = date('Y-m-d H:i:s');
956 }
957 if(($globals['first_dep'] == '0000-00-00' && $promotion['first_dep'] != '') || ($globals['first_dep'] != '' && $promotion['first_dep'] != '' && !((is_array($promotion['first_dep']) && !empty($promotion['first_dep']) && strtotime($globals['first_dep'].$day_check) >= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['first_dep'][0].' days'))) && strtotime($globals['first_dep'].$day_check) <= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['first_dep'][1].' days')))) || (strtotime($globals['first_dep'].$day_check) == strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['first_dep'].' days'))))))){
958 continue;
959 }
960 if(($globals['last_dep'] == '0000-00-00' && $promotion['last_dep'] != '') || ($globals['last_dep'] != '' && $promotion['last_dep'] != '' && !((is_array($promotion['last_dep']) && !empty($promotion['last_dep']) && strtotime(date('Y-m-d',strtotime($globals['last_dep'].$day_check))) >= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['last_dep'][0].' days'))) && strtotime(date('Y-m-d',strtotime($globals['last_dep'].$day_check))) <= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['last_dep'][1].' days')))) || (!is_array($promotion['last_dep']) && $promotion['last_dep'] != '' && strtotime(date('Y-m-d',strtotime($globals['last_dep'].$day_check))) == strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['last_dep'].' days'))))))){
961 continue;
962 }
963 if($globals['dep_count'] != '' && $globals['dep_count'] > 0 && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && !($globals['dep_count'] >= $promotion['dep_count'][0] && $globals['dep_count'] < $promotion['dep_count'][1])){
964 //if($globals['dep_count'] != '' && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && $globals['dep_count'] <= $promotion['dep_count'][0] && $globals['dep_count'] >= $promotion['dep_count'][1]){
965 continue;
966 }elseif($globals['dep_count'] != '' && $globals['dep_count'] > 0 && $promotion['dep_count'] != '' && !is_array($promotion['dep_count']) && !empty($promotion['dep_count'])){
967 if(strpos($promotion['dep_count'],'<') !== false && $globals['dep_count'] >= str_replace('<','',$promotion['dep_count'])){
968 continue;
969 }elseif(strpos($promotion['dep_count'],'>') !== false && $globals['dep_count'] < str_replace('>','',$promotion['dep_count'])){
970 continue;
971 }elseif((strpos($promotion['dep_count'],'<') === false && strpos($promotion['dep_count'],'>') === false) && $promotion['dep_count'] != $globals['dep_count']){
972 continue;
973 }/* elseif((strpos($promotion['dep_count'],'<') === false && strpos($promotion['dep_count'],'>') === false) && $promotion['dep_count'] > 0 && $globals['dep_count'] != $promotion['dep_count']){
974 continue;
975 } */
976 }elseif($globals['dep_count'] == 0 && $promotion['dep_count'] > 0){
977 continue;
978 }
979 $dep_count_qualified = true;
980 if($promotion['dep_count_logic'] != '' && is_array($promotion['dep_count_logic']) && !empty($promotion['dep_count_logic'])){
981 $skip_promotion = false;
982 foreach($promotion['dep_count_logic'] as $dclk => $dclk_values){
983 if(!is_array($dclk_values['dep_count_req']) && strpos($dclk_values['dep_count_req'],',') !== false){
984 $dclk_values['dep_count_req'] = explode(',',$dclk_values['dep_count_req']);
985 }
986 $dep_count_qualified = true;
987 if($globals['dep_count'] != '' && $globals['dep_count'] > 0 && is_array($dclk_values['dep_count_req']) && !empty($dclk_values['dep_count_req']) && !($globals['dep_count'] >= $dclk_values['dep_count_req'][0] && $globals['dep_count'] <= $dclk_values['dep_count_req'][1])){
988 $dep_count_qualified = false;
989 continue;
990 }elseif($globals['dep_count'] != '' && $globals['dep_count'] > 0 && $dclk_values['dep_count_req'] != '' && !is_array($dclk_values['dep_count_req']) && !empty($dclk_values['dep_count_req'])){
991 if(strpos($dclk_values['dep_count_req'],'<') !== false && $globals['dep_count'] >= str_replace('<','',$dclk_values['dep_count_req'])){
992 $dep_count_qualified = false;
993 continue;
994 }elseif(strpos($dclk_values['dep_count_req'],'>') !== false && $globals['dep_count'] < str_replace('>','',$dclk_values['dep_count_req'])){
995 $dep_count_qualified = false;
996 continue;
997 }elseif((strpos($dclk_values['dep_count_req'],'<') === false && strpos($dclk_values['dep_count_req'],'>') === false) && $dclk_values['dep_count_req'] != $globals['dep_count']){
998 $dep_count_qualified = false;
999 continue;
1000 }
1001 }elseif($globals['dep_count'] == 0 && $dclk_values['dep_count_req'] > 0){
1002 $dep_count_qualified = false;
1003 continue;
1004 }
1005 if($dep_count_qualified){
1006 if($globals['betstodepositrate'] != '' && $globals['betstodepositrate'] > 0 && is_array($dclk_values['betstodepositrate']) && !empty($dclk_values['betstodepositrate']) && !($globals['betstodepositrate'] >= $dclk_values['betstodepositrate'][0] && $globals['betstodepositrate'] <= $dclk_values['betstodepositrate'][1])){
1007 //if($globals['dep_count'] != '' && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && $globals['dep_count'] <= $promotion['dep_count'][0] && $globals['dep_count'] >= $promotion['dep_count'][1]){
1008 $skip_promotion = true;
1009 break;
1010 }elseif($globals['betstodepositrate'] != '' && $globals['betstodepositrate'] > 0 && $dclk_values['betstodepositrate'] != '' && !is_array($dclk_values['betstodepositrate']) && !empty($dclk_values['betstodepositrate'])){
1011 if(strpos($dclk_values['betstodepositrate'],'<') !== false && number_format($globals['betstodepositrate'], 2, '.', '') >= number_format(str_replace('<','',$dclk_values['betstodepositrate']), 2, '.', '')){
1012 $skip_promotion = true;
1013 break;
1014 }elseif(strpos($dclk_values['betstodepositrate'],'>') !== false && number_format($globals['betstodepositrate'], 2, '.', '') < number_format(str_replace('>','',$dclk_values['betstodepositrate']), 2, '.', '')){
1015 $skip_promotion = true;
1016 break;
1017 }elseif((strpos($dclk_values['betstodepositrate'],'<') === false && strpos($dclk_values['betstodepositrate'],'>') === false) && $dclk_values['betstodepositrate'] != $globals['betstodepositrate']){
1018 $skip_promotion = true;
1019 break;
1020 }
1021 }elseif($globals['betstodepositrate'] == 0 && $dclk_values['betstodepositrate'] > 0){
1022 $skip_promotion = true;
1023 break;
1024 }
1025 }
1026 }
1027 if($skip_promotion){
1028 continue;
1029 }
1030 }else{
1031 if($globals['dep_count'] != '' && $globals['dep_count'] > 0 && is_array($promotion['dep_count_req']) && !empty($promotion['dep_count_req']) && !($globals['dep_count'] >= $promotion['dep_count_req'][0] && $globals['dep_count'] < $promotion['dep_count_req'][1])){
1032 //if($globals['dep_count'] != '' && $globals['dep_count'] > 0 && is_array($promotion['dep_count_req']) && !empty($promotion['dep_count_req']) && !($globals['dep_count'] >= $promotion['dep_count_req'][0] && $globals['dep_count'] < $promotion['dep_count_req'][1])){
1033 //if($globals['dep_count'] != '' && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && $globals['dep_count'] <= $promotion['dep_count'][0] && $globals['dep_count'] >= $promotion['dep_count'][1]){
1034 //continue;
1035 $dep_count_qualified = false;
1036 }elseif($globals['dep_count'] != '' && $globals['dep_count'] > 0 && $promotion['dep_count_req'] != '' && !is_array($promotion['dep_count_req']) && !empty($promotion['dep_count_req'])){
1037 if(strpos($promotion['dep_count_req'],'<') !== false && $globals['dep_count'] >= str_replace('<','',$promotion['dep_count_req'])){
1038 $dep_count_qualified = false;
1039 }elseif(strpos($promotion['dep_count_req'],'>') !== false && $globals['dep_count'] < str_replace('>','',$promotion['dep_count_req'])){
1040 $dep_count_qualified = false;
1041 }elseif((strpos($promotion['dep_count_req'],'<') === false && strpos($promotion['dep_count_req'],'>') === false) && $promotion['dep_count_req'] != $globals['dep_count']){
1042 $dep_count_qualified = false;
1043 }
1044 }elseif($globals['dep_count'] == 0 && $promotion['dep_count_req'] > 0){
1045 $dep_count_qualified = false;
1046 }
1047 if($dep_count_qualified){
1048 if($globals['betstodepositrate'] != '' && $globals['betstodepositrate'] > 0 && is_array($promotion['betstodepositrate']) && !empty($promotion['betstodepositrate']) && !($globals['betstodepositrate'] >= $promotion['betstodepositrate'][0] && $globals['betstodepositrate'] < $promotion['betstodepositrate'][1])){
1049 //if($globals['dep_count'] != '' && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && $globals['dep_count'] <= $promotion['dep_count'][0] && $globals['dep_count'] >= $promotion['dep_count'][1]){
1050 continue;
1051 }elseif($globals['betstodepositrate'] != '' && $globals['betstodepositrate'] > 0 && $promotion['betstodepositrate'] != '' && !is_array($promotion['betstodepositrate']) && !empty($promotion['betstodepositrate'])){
1052 if(strpos($promotion['betstodepositrate'],'<') !== false && number_format($globals['betstodepositrate'], 2, '.', '')>= number_format(str_replace('<','',$promotion['betstodepositrate']), 2, '.', '')){
1053 continue;
1054 }elseif(strpos($promotion['betstodepositrate'],'>') !== false && number_format($globals['betstodepositrate'], 2, '.', '')< number_format(str_replace('>','',$promotion['betstodepositrate']), 2, '.', '')){
1055 continue;
1056 }elseif((strpos($promotion['betstodepositrate'],'<') === false && strpos($promotion['betstodepositrate'],'>') === false) && $promotion['betstodepositrate'] != $globals['betstodepositrate']){
1057 continue;
1058 }
1059 }elseif($globals['betstodepositrate'] == 0 && $promotion['betstodepositrate'] > 0){
1060 continue;
1061 }
1062 }
1063 }
1064 $dep_count_qualified = true;
1065 if($promotion['dep_count_logic_req'] != '' && is_array($promotion['dep_count_logic_req']) && !empty($promotion['dep_count_logic_req'])){
1066 $skip_promotion = false;
1067 foreach($promotion['dep_count_logic_req'] as $dclk => $dclk_values){
1068 # dep_count_req preparation
1069 $dep_count_qualified = parameter_qualified($dclk_values,'dep_count','dep_count_req');
1070 if($dep_count_qualified){
1071 /* if(!parameter_qualified($dclk_values,'bbrate','bonus_rate') && isset($_REQUEST['history_viewer'])){
1072 if($promotion['promo_id'] == 2042)
1073 die('test1');
1074 } */
1075 if(!parameter_qualified($dclk_values,'bonus_rate','bonus_rate') && !parameter_qualified($dclk_values,'bb_rate','bb_rate') && !parameter_qualified($dclk_values,'avgbet','avgbet') && !date_parameter_qualified($dclk_values,'last_wd','last_wd',$day_check)){
1076 $skip_promotion = true;
1077 break;
1078 }
1079 /* # bonus_rate
1080 if(!parameter_qualified($dclk_values,'bonus_rate','bonus_rate')){
1081 $skip_promotion = true;
1082 break;
1083 }
1084 # bb_rate
1085 if(!parameter_qualified($dclk_values,'bb_rate','bb_rate')){
1086 $skip_promotion = true;
1087 break;
1088 }
1089 # avgbet
1090 if(!parameter_qualified($dclk_values,'avgbet','avgbet')){
1091 $skip_promotion = true;
1092 break;
1093 }
1094 # last_wd
1095 if(!date_parameter_qualified($dclk_values,'last_wd','last_wd',$day_check)){
1096 $skip_promotion = true;
1097 break;
1098 } */
1099 }
1100 }
1101 if($skip_promotion){
1102 continue;
1103 }
1104 }
1105 if($globals['total_deposits'] != '' && $globals['total_deposits'] > 0 && is_array($promotion['total_deposits']) && !empty($promotion['total_deposits']) && !($globals['total_deposits'] >= $promotion['total_deposits'][0] && $globals['total_deposits'] < $promotion['total_deposits'][1])){
1106 //if($globals['dep_count'] != '' && is_array($promotion['dep_count']) && !empty($promotion['dep_count']) && $globals['dep_count'] <= $promotion['dep_count'][0] && $globals['dep_count'] >= $promotion['dep_count'][1]){
1107 continue;
1108 }elseif($globals['total_deposits'] != '' && $globals['total_deposits'] > 0 && $promotion['total_deposits'] != '' && !is_array($promotion['total_deposits']) && !empty($promotion['total_deposits'])){
1109 if(strpos($promotion['total_deposits'],'<') !== false && $globals['total_deposits'] >= str_replace('<','',$promotion['total_deposits'])){
1110 continue;
1111 }elseif(strpos($promotion['total_deposits'],'>') !== false && $globals['total_deposits'] < str_replace('>','',$promotion['total_deposits'])){
1112 continue;
1113 }elseif((strpos($promotion['total_deposits'],'<') === false && strpos($promotion['total_deposits'],'>') === false) && $promotion['total_deposits'] != $globals['total_deposits']){
1114 continue;
1115 }/* elseif((strpos($promotion['dep_count'],'<') === false && strpos($promotion['dep_count'],'>') === false) && $promotion['dep_count'] > 0 && $globals['dep_count'] != $promotion['dep_count']){
1116 continue;
1117 } */
1118 }elseif($globals['total_deposits'] == 0 && $promotion['total_deposits'] > 0){
1119 continue;
1120 }
1121 /* avgbet */
1122 $avgbet_le = true;
1123 if(is_array($promotion['avgbet']) && !empty($promotion['avgbet']) && $promotion['avgbet'][0] != '' && $promotion['avgbet'][1] != ''){
1124 if(strpos($promotion['avgbet'][1],'|') !== false && $globals['avgbet'] <= number_format(str_replace('|','',$promotion['avgbet'][1]))){
1125 $avgbet_le = true;
1126 }elseif(strpos($promotion['avgbet'][1],'|') !== false && $globals['avgbet'] > number_format(str_replace('|','',$promotion['avgbet'][1]))){
1127 $avgbet_le = false;
1128 }elseif(strpos($promotion['avgbet'][1],'|') === false && $globals['avgbet'] < number_format($promotion['avgbet'][1])){
1129 $avgbet_le = true;
1130 }elseif(strpos($promotion['avgbet'][1],'|') === false && $globals['avgbet'] >= number_format($promotion['avgbet'][1])){
1131 $avgbet_le = false;
1132 }
1133 }
1134 if(($globals['avgbet'] != '' && is_array($promotion['avgbet']) && !empty($promotion['avgbet']) && !($globals['avgbet'] >= $promotion['avgbet'][0] && $avgbet_le)) && $promotion['avgbet_not']){
1135 # avgbet_not = true (not checked)
1136 continue;
1137 }elseif(($globals['avgbet'] != '' && is_array($promotion['avgbet']) && !empty($promotion['avgbet']) && ($globals['avgbet'] >= $promotion['avgbet'][0] && $avgbet_le)) && !$promotion['avgbet_not']){
1138 # avgbet_not = false (checked)
1139 continue;
1140 }elseif($globals['avgbet'] != '' && $promotion['avgbet'] != '' && !is_array($promotion['avgbet']) && !empty($promotion['avgbet'])){
1141 //if($promotion['promo_id']==61){
1142 //var_dump('avgbet:'.$globals['avgbet'].',avgbet:'.$promotion['avgbet'].',avgbet_not:'.$promotion['avgbet_not'],'avgbet_le:'.$avgbet_le);
1143 //}
1144 if((strpos($promotion['avgbet'],'<') !== false && number_format($globals['avgbet'], 2, '.', '') >= number_format(str_replace('<','',$promotion['avgbet']), 2, '.', '')) && $promotion['avgbet_not']){
1145 # avgbet_not = true (not checked)
1146 continue;
1147 }if((strpos($promotion['avgbet'],'<') !== false && number_format($globals['avgbet'], 2, '.', '') < number_format(str_replace('<','',$promotion['avgbet']), 2, '.', '')) && !$promotion['avgbet_not']){
1148 # avgbet_not = false (checked)
1149 continue;
1150 }elseif((strpos($promotion['avgbet'],'>') !== false && number_format($globals['avgbet'], 2, '.', '') < number_format(str_replace('>','',$promotion['avgbet']), 2, '.', '')) && $promotion['avgbet_not']){
1151 # avgbet_not = true (not checked)
1152 continue;
1153 }elseif((strpos($promotion['avgbet'],'>') !== false && number_format($globals['avgbet'], 2, '.', '') >= number_format(str_replace('>','',$promotion['avgbet']), 2, '.', '')) && !$promotion['avgbet_not']){
1154 # avgbet_not = false (checked)
1155 continue;
1156 }elseif((strpos($promotion['avgbet'],'<') === false && strpos($promotion['avgbet'],'>') === false && $promotion['avgbet'] != $globals['avgbet']) && $promotion['avgbet_not']){
1157 # avgbet_not = true (not checked)
1158 continue;
1159 }elseif((strpos($promotion['avgbet'],'<') === false && strpos($promotion['avgbet'],'>') === false && $promotion['avgbet'] == $globals['avgbet']) && !$promotion['avgbet_not']){
1160 # avgbet_not = false (checked)
1161 continue;
1162 }
1163 }elseif(($globals['avgbet'] == 0 && $promotion['avgbet'] > 0) && $promotion['avgbet_not']){
1164 # avgbet_not = true (not checked)
1165 continue;
1166 }
1167 if($promotion['restricted_countries'] != '' && is_array($promotion['restricted_countries']) && !empty($promotion['restricted_countries']) && isset($promotion['restricted_countries'][$globals['country']])){
1168 continue;
1169 }
1170 if($globals['bonus_rate'] != '' && is_array($promotion['bonus_rate']) && !empty($promotion['bonus_rate']) && !($globals['bonus_rate'] >= $promotion['bonus_rate'][0] && $globals['bonus_rate'] < $promotion['bonus_rate'][1])){
1171 //if($globals['bonus_rate'] != '' && $promotion['bonus_rate'] != '' && ((is_array($promotion['bonus_rate']) && !empty($promotion['bonus_rate']) && $globals['bonus_rate'] <= $promotion['bonus_rate'][0] && $globals['bonus_rate'] >= $promotion['bonus_rate'][1]) || ($globals['bonus_rate'] == $promotion['bonus_rate']))){
1172 continue;
1173 }elseif($globals['bonus_rate'] != '' && $promotion['bonus_rate'] != '' && !is_array($promotion['bonus_rate']) && !empty($promotion['bonus_rate'])){
1174 if(strpos($promotion['bonus_rate'],'<') !== false && $globals['bonus_rate'] > str_replace('<','',$promotion['bonus_rate'])){
1175 continue;
1176 }elseif(strpos($promotion['bonus_rate'],'>') !== false && $globals['bonus_rate'] < str_replace('>','',$promotion['bonus_rate'])){
1177 continue;
1178 }elseif($promotion['bonus_rate'] != $globals['bonus_rate']){
1179 continue;
1180 }
1181 }
1182
1183 if($globals['bonusbalance'] != '' && is_array($promotion['bonusbalance']) && !empty($promotion['bonusbalance']) && !($globals['bonusbalance'] >= $promotion['bonusbalance'][0] && $globals['bonusbalance'] < $promotion['bonusbalance'][1])){
1184 continue;
1185 }elseif($globals['bonusbalance'] != '' && $promotion['bonusbalance'] != '' && !is_array($promotion['bonusbalance']) && !empty($promotion['bonusbalance'])){
1186 if(strpos($promotion['bonusbalance'],'<') !== false && $globals['bonusbalance'] > str_replace('<','',$promotion['bonusbalance'])){
1187 continue;
1188 }elseif(strpos($promotion['bonusbalance'],'>') !== false && $globals['bonusbalance'] < str_replace('>','',$promotion['bonusbalance'])){
1189 continue;
1190 }elseif($promotion['bonusbalance'] != $globals['bonusbalance']){
1191 continue;
1192 }
1193 }
1194
1195 if($globals['hold'] != '' && is_array($promotion['hold']) && !empty($promotion['hold']) && !($globals['hold'] >= $promotion['hold'][0] && $globals['hold'] < $promotion['hold'][1])){
1196 //if($globals['hold'] != '' && is_array($promotion['hold']) && !empty($promotion['hold']) && $globals['hold'] <= $promotion['hold'][0] && $globals['hold'] >= $promotion['hold'][1]){
1197 continue;
1198 }elseif($globals['hold'] != '' && $promotion['hold'] != '' && !is_array($promotion['hold']) && !empty($promotion['hold'])){
1199 if(strpos($promotion['hold'],'<') !== false && $globals['hold'] > str_replace('<','',$promotion['hold'])){
1200 continue;
1201 }elseif(strpos($promotion['hold'],'>') !== false && $globals['hold'] < str_replace('>','',$promotion['hold'])){
1202 continue;
1203 }elseif($promotion['hold'] != $globals['hold']){
1204 continue;
1205 }
1206 }
1207 if($appAbbrev == 'ojo' || $appAbbrev == 'ojo-uk' || $appAbbrev == 'ojo-dk'){
1208 $ojo_level_exist = false;
1209 if((is_array($promotion['ojo_level']) && !empty($promotion['ojo_level'])) || $promotion['ojo_level'] != '')
1210 $ojo_level_exist = true;
1211 if($globals['ojo_level'] != '' && $promotion['ojo_level'] != '' && is_array($promotion['ojo_level']) && !empty($promotion['ojo_level']) && !($globals['ojo_level'] >= $promotion['ojo_level'][0] && $globals['ojo_level'] < $promotion['ojo_level'][1])){
1212 //if($globals['hold'] != '' && is_array($promotion['hold']) && !empty($promotion['hold']) && $globals['hold'] <= $promotion['hold'][0] && $globals['hold'] >= $promotion['hold'][1]){
1213 continue;
1214 }elseif($globals['ojo_level'] != '' && $promotion['ojo_level'] != '' && !is_array($promotion['ojo_level']) && !empty($promotion['ojo_level'])){
1215 if(strpos($promotion['ojo_level'],'<') !== false && $globals['ojo_level'] > str_replace('<','',$promotion['ojo_level'])){
1216 continue;
1217 }elseif(strpos($promotion['ojo_level'],'>') !== false && $globals['ojo_level'] < str_replace('>','',$promotion['ojo_level'])){
1218 continue;
1219 }elseif($promotion['ojo_level'] != $globals['ojo_level']){
1220 continue;
1221 }
1222 }
1223 if($globals['ojo_level_progress'] != '' && $promotion['ojo_level_progress'] != '' && is_array($promotion['ojo_level_progress']) && !empty($promotion['ojo_level_progress']) && !($globals['ojo_level_progress'] >= $promotion['ojo_level_progress'][0] && $globals['ojo_level_progress'] < $promotion['ojo_level_progress'][1])){
1224 //if($globals['hold'] != '' && is_array($promotion['hold']) && !empty($promotion['hold']) && $globals['hold'] <= $promotion['hold'][0] && $globals['hold'] >= $promotion['hold'][1]){
1225 continue;
1226 }elseif($globals['ojo_level_progress'] != '' && $promotion['ojo_level_progress'] != '' && !is_array($promotion['ojo_level_progress']) && !empty($promotion['ojo_level_progress'])){
1227 if(strpos($promotion['ojo_level_progress'],'<') !== false && $globals['ojo_level_progress'] > str_replace('<','',$promotion['ojo_level_progress'])){
1228 continue;
1229 }elseif(strpos($promotion['ojo_level_progress'],'>') !== false && $globals['ojo_level_progress'] < str_replace('>','',$promotion['ojo_level_progress'])){
1230 continue;
1231 }elseif($promotion['ojo_level_progress'] != $globals['ojo_level_progress']){
1232 continue;
1233 }
1234 }
1235 if(($globals['ojo_level_date'] == '0000-00-00' && $promotion['ojo_level_date'] != '') || ($globals['ojo_level_date'] != '' && $promotion['ojo_level_date'] != '' && !((is_array($promotion['ojo_level_date']) && !empty($promotion['ojo_level_date']) && strtotime($globals['ojo_level_date'].$day_check) >= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['ojo_level_date'][0].' days'))) && strtotime($globals['ojo_level_date'].$day_check) <= strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['ojo_level_date'][1].' days'))))) || (strtotime($globals['ojo_level_date'].$day_check) == strtotime(date('Y-m-d',strtotime($today_date.' - '.$promotion['ojo_level_date'].' days')))))){
1236 continue;
1237 }
1238 }
1239 if($promotion['user_groups'] != '' && is_array($promotion['user_groups']) && !empty($promotion['user_groups'])){
1240 $exist_in_group = false;
1241 foreach($promotion['user_groups'] as $user_group => $user_group_value){
1242 $user_id = $globals['user_id'];
1243 $query = pg_query($kc_connection,"select * from players_groups where user_id='$user_id' and title='$user_group'");
1244 if(pg_num_rows($query) > 0){
1245 $exist_in_group = true;
1246 break;
1247 }
1248 }
1249 if(!$exist_in_group){
1250 /* if(isset($_REQUEST['nikos_test'])){
1251 var_dump($promotion['user_groups']);
1252 var_dump($promotion['promo_id']);
1253 } */
1254 continue;
1255 }
1256 }elseif(!is_array($promotion['user_groups']) && $promotion['user_groups'] != ''){
1257 $user_group = $promotion['user_groups'];
1258 $user_id = $globals['user_id'];
1259 $query1 = pg_query($kc_connection,"select * from players_groups where user_id='$user_id' and title='$user_group'");
1260 if(pg_num_rows($query1) > 0){
1261
1262 }else{
1263 /* if(isset($_REQUEST['nikos_test']))
1264 var_dump($user_group.'-'.$promotion['promo_id']); */
1265 continue;
1266 }
1267 }
1268 /* #old user_groups check from loaded cached data (slower and higher memory usage)
1269 * if($promotion['user_groups'] != '' && is_array($promotion['user_groups']) && !empty($promotion['user_groups'])){
1270 $exist_in_group = false;
1271 foreach($globals['user_groups']['per_user_id'][$globals['user_id']] as $user_group => $user_group_value){
1272 if(isset($promotion['user_groups'][$user_group])){
1273 $exist_in_group = true;
1274 break;
1275 }
1276 }
1277 //!isset($globals['user_groups']['per_user_id'][$globals['user_id']][$promotion['user_groups']][$globals['user_id']])
1278 if(!$exist_in_group)
1279 continue;
1280 }elseif($promotion['user_groups'] != '' && !is_array($promotion['user_groups']) && !isset($globals['user_groups'][$promotion['user_groups']][$globals['user_id']])){
1281 continue;
1282 }*/
1283 if($promotion['restricted_user_groups'] != '' && is_array($promotion['restricted_user_groups']) && !empty($promotion['restricted_user_groups'])){
1284 $exist_in_group = false;
1285 foreach($promotion['restricted_user_groups'] as $user_group => $user_group_value){
1286 $user_id = $globals['user_id'];
1287 $query2 = pg_query($kc_connection,"select * from players_groups where user_id='$user_id' and title='$user_group'");
1288 if(pg_num_rows($query2) > 0){
1289 $exist_in_group = true;
1290 /* if(isset($_REQUEST['nikos_test'])){
1291 var_dump($promotion['user_groups']);
1292 var_dump('restricted-'.$promotion['promo_id']);
1293 } */
1294 break;
1295 }
1296 }
1297 if($exist_in_group){
1298 continue;
1299 }
1300 }elseif(!is_array($promotion['restricted_user_groups']) && $promotion['restricted_user_groups'] != ''){
1301 $user_group = $promotion['restricted_user_groups'];
1302 $user_id = $globals['user_id'];
1303 $query3 = pg_query($kc_connection,"select * from players_groups where user_id='$user_id' and title='$user_group'");
1304 if(pg_num_rows($query3) > 0){
1305 /* if(isset($_REQUEST['nikos_test']))
1306 var_dump('restricted-'.$user_group.'-'.$promotion['promo_id']); */
1307 continue;
1308 }
1309 }
1310 /* #old restricted_user_groups check from loaded cached data (slower and higher memory usage)
1311 * if($promotion['restricted_user_groups'] != '' && is_array($promotion['restricted_user_groups']) && !empty($promotion['restricted_user_groups'])){
1312 $exist_in_group = false;
1313 foreach($globals['user_groups']['per_user_id'][$globals['user_id']] as $user_group => $user_group_value){
1314 if(isset($promotion['restricted_user_groups'][$user_group])){
1315 $exist_in_group = true;
1316 break;
1317 }
1318 }
1319 //!isset($globals['user_groups']['per_user_id'][$globals['user_id']][$promotion['user_groups']][$globals['user_id']])
1320 if($exist_in_group)
1321 continue;
1322 }elseif($promotion['restricted_user_groups'] != '' && $globals['user_id'] != '' && isset($globals['user_groups'][$promotion['restricted_user_groups']][$globals['user_id']])){
1323 continue;
1324 } */
1325 if($promotion['user_id'] != '' && $promotion['user_id'] != '' && ((is_array($promotion['user_id']) && !empty($promotion['user_id']) && !isset($promotion['user_id'][$globals['user_id']])) || (!is_array($promotion['user_id']) && $promotion['user_id'] != $globals['user_id']))){
1326 continue;
1327 }
1328 if(isset($globals['temp_user']) && $globals['temp_user'] == true && $promotion['temp_users_visible'] != true){
1329 continue;
1330 }
1331 if(($promotion['restricted_users'] != '' && is_array($promotion['restricted_users']) && !empty($promotion['restricted_users']) && isset($promotion['restricted_users'][$globals['user_id']])) || ($promotion['restricted_users'] == $globals['user_id'] && $globals['user_id'] != '')){
1332 continue;
1333 }
1334 if($promotion['aname'] != '' && $globals['aname'] != '' && ((is_array($promotion['aname']) && !empty($promotion['aname']) && !isset($promotion['aname'][$globals['aname']])) || (!is_array($promotion['aname']) && $promotion['aname'] != $globals['aname']))){
1335 continue;
1336 }
1337 if(($promotion['restricted_anames'] != '' && is_array($promotion['restricted_anames']) && !empty($promotion['anames']) && isset($promotion['restricted_anames'][$globals['aname']])) || ($promotion['restricted_anames'] == $globals['aname'] && $globals['aname'] != '')){
1338 continue;
1339 }
1340 if(($promotion['platforms_restricted'] != '' && is_array($promotion['platforms_restricted']) && !empty($promotion['platforms_restricted']) && isset($promotion['platforms_restricted'][$globals['platform']])) || ($promotion['platforms_restricted'] == $globals['platform'] && $globals['platform'] != '')){
1341 continue;
1342 }
1343 /* if($globals['signup_date'] != '' && $promotion['days_after_signup'] > 0 && strtotime(date('Y-m-d',strtotime($globals['signup_date']))) != strtotime(date('Y-m-d',strtotime('-'.$promotion['days_after_signup']." days")))){
1344 continue;
1345 } */
1346 if($globals['signup_date'] != '0000-00-00' && $promotion['days_after_signup'] != '' && $promotion['days_after_signup'] > 0 && !((is_array($promotion['days_after_signup']) && !empty($promotion['days_after_signup']) && strtotime($globals['signup_date'].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$promotion['days_after_signup'][0].' days'))) && strtotime($globals['signup_date'].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$promotion['days_after_signup'][1].' days')))) && !(strtotime($globals['signup_date'].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$promotion['days_after_signup'].' days')))))){
1347 continue;
1348 }/*
1349 if(isset($_REQUEST['nikos_test']) && $promotion['promo_id'] == 529){
1350 echo $globals['signup_date'] . '<br />' . $promotion['days_after_signup'] . '<br />';
1351 die('test');
1352 } */
1353 if(($globals['last_log'] == '0000-00-00' && $promotion['last_logout'] != '') || ($globals['last_log'] != '' && $promotion['last_log'] != '' && !((is_array($promotion['last_logout']) && !empty($promotion['last_logout']) && strtotime($globals['last_log'].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_logout'][0].' days'))) && strtotime($globals['last_log'].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_logout'][1].' days')))) || (strtotime($globals['last_log'].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$promotion['last_logout'].' days'))))))){
1354 continue;
1355 }
1356 if(($globals['last_bet'] == '0000-00-00' && $promotion['last_bet'] != '') || ($globals['last_bet'] != '' && ((is_array($promotion['last_bet']) && !empty($promotion['last_bet']) && strtotime($globals['last_bet'].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_bet'][0].' days'))) && strtotime($globals['last_bet'].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_bet'][1].' days'))) || (strtotime($globals['last_bet'].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$promotion['last_bet'].' days')))))))){
1357 continue;
1358 }
1359 if(($globals['last_dec'] == '0000-00-00' && $promotion['last_dec'] != '') || ($globals['last_dec'] != '' && is_array($promotion['last_dec']) && !empty($promotion['last_dec']) && !(strtotime($globals['last_dec'].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_dec'][0].' days'))) && strtotime($globals['last_dec'].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_dec'][1].' days')))))){
1360 continue;
1361 }
1362 if(($globals['last_wd'] == '0000-00-00' && $promotion['last_wd'] != '') || ($globals['last_wd'] != '' && $promotion['last_wd'] != '' && !((is_array($promotion['last_wd']) && !empty($promotion['last_wd']) && strtotime($globals['last_wd'].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_wd'][0].' days'))) && strtotime($globals['last_wd'].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$promotion['last_wd'][1].' days'))))) || (strtotime($globals['last_wd'].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$promotion['last_wd'].' days')))))){
1363 continue;
1364 }
1365 if($globals['dob'] != '' && $globals['dob'] != 0 && $promotion['days_before_bday'] != ''){
1366 //$bday_difference = ((strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob']))) - strtotime(date('Y-m-d')))/(60 * 60 * 24));
1367 $bday_entry_diff0 = ' - ';
1368 $bday_entry_diff1 = ' - ';
1369 /* if($promotion['promo_id']==61){
1370 echo $bday_entry_diff .'<br />';
1371 echo strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff))).'<br />';
1372 echo strtotime(date('Y-m-d')).'<br />';
1373 echo date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff)).'<br />';
1374 die();
1375 } */
1376 if(is_array($promotion['days_before_bday'])){
1377 $bday_entry_diff0 = (strpos($promotion['days_before_bday'][0],'-')===false?' - ':' + ').str_replace('-','',$promotion['days_before_bday'][0]).' days';
1378 $bday_entry_diff1 = (strpos($promotion['days_before_bday'][1],'-')===false?' - ':' + ').str_replace('-','',$promotion['days_before_bday'][1]).' days';
1379 $bday_start_promo = strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff0)).' 00:00:00');
1380 $bday_end_promo = strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff1)).' 23:59:59');
1381 if(strtotime($today_datetime) < $bday_start_promo || strtotime($today_datetime) > $bday_end_promo){
1382 continue;
1383 }
1384 /* }elseif(strtotime(date('Y-m-d H:i:s')) >= strpos($promotion['days_before_bday'],'<') !== false && strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff.str_replace('<','',$promotion['days_before_bday']). ' days')).' 00:00:00')){
1385 continue;
1386 }elseif(strtotime(date('Y-m-d H:i:s')) > strpos($promotion['days_before_bday'],'>') !== false && strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff.str_replace('>','',$promotion['days_before_bday']). ' days')).' 00:00:00')){
1387 continue; */
1388 }else{
1389 $bday_entry_diff = (strpos($promotion['days_before_bday'],'-')!== false?' + ':' - ').str_replace('-','',$promotion['days_before_bday'][0]).' days';
1390 if(strtotime($today_date) != strtotime(date('Y').'-'.date('m-d',strtotime($globals['dob'].$bday_entry_diff))))
1391 continue;
1392 }
1393 }
1394 if($globals['acc_flag'] != '' && is_array($promotion['restricted_flags']) && !empty($promotion['restricted_flags']) && isset($promotion['restricted_flags'][$globals['acc_flag']])){
1395 continue;
1396 }
1397 if($globals['v_man'] != '' && is_array($promotion['restricted_vip_managers']) && !empty($promotion['restricted_vip_managers']) && isset($promotion['restricted_vip_managers'][$globals['v_man']])){
1398 continue;
1399 }
1400 if($promotion['top_app_type'] != '' && $promotion['top_app_type'] != '' && ((is_array($promotion['top_app_type']) && !empty($promotion['top_app_type']) && !isset($promotion['top_app_type'][$globals['top_app_type']])) || (!is_array($promotion['top_app_type']) && $globals['top_app_type'] != $promotion['top_app_type']))){
1401 continue;
1402 }
1403 if($globals['bb_rate'] != '' && is_array($promotion['bb_rate']) && $globals['bb_rate'] >= $promotion['bb_rate'][0] && $globals['bb_rate'] < $promotion['bb_rate'][1]){
1404 continue;
1405 }
1406 if($globals['bb_rate'] != '' && !is_array($promotion['bb_rate']) && ((strpos($promotion['bb_rate'],'>') && str_replace('>','',$promotion['bb_rate']) > $globals['bb_rate']) || (strpos($promotion['bb_rate'],'<') && str_replace('<','',$promotion['bb_rate']) < $globals['bb_rate']))){
1407 continue;
1408 }
1409 if(($promo_translations[$promotion['promo_id']]['view_title']['token_'.$globals['lang']] == '' && $promo_translations[$promotion['promo_id']]['view_title']['token_en']== '') || ($promo_translations[$promotion['promo_id']]['what_to_do']['token_'.$globals['lang']] == '' && $promo_translations[$promotion['promo_id']]['what_to_do']['token_en'] == '' && $promo_translations[$promotion['promo_id']]['what_you_get']['token_'.$globals['lang']] == '' && $promo_translations[$promotion['promo_id']]['what_you_get']['token_en'] != '' && $promo_translations[$promotion['promo_id']]['token_terms']['token_'.$globals['lang']] == '' && $promo_translations[$promotion['promo_id']]['token_terms']['token_en'] == '' && $promo_translations[$promotion['promo_id']]['token_rewards']['token_'.$globals['lang']] == '' && $promo_translations[$promotion['promo_id']]['token_rewards']['token_en'] == '')){
1410 continue;
1411 }
1412 /* if(($promotion['view_title']['token_'.$globals['lang']] == '' && $promotion['view_title']['token_en'] == '') || ($promotion['what_to_do']['token_'.$globals['lang']] == '' && $promotion['what_to_do']['token_en'] == '' && $promotion['what_you_get']['token_'.$globals['lang']] == '' && $promotion['what_you_get']['token_en'] != '' && $promotion['token_terms']['token_'.$globals['lang']] == '' && $promotion['token_terms']['token_en'] == '' && $promotion['token_rewards']['token_'.$globals['lang']] == '' && $promotion['token_rewards']['token_en'] == '')){
1413 continue;
1414 } */
1415 if($show_promotion == true){
1416 //$promo_image = 'https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/'.$promotion['promo_id'].'/'.$promotion['promo_id'];
1417 $promo_image = 'https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/promotions/'.$promotion['promo_id'].'/'.$promotion['promo_id'];
1418 $promo_image_temp = '/project_new/promos.playeroffers.com/images/promotions_frame/promotions/'.$promotion['promo_id'].'/'.$promotion['promo_id'];
1419 //outer image
1420 if(file_exists($promo_image_temp.'_out_'.$globals['lang'].'.png'))
1421 $out_promo_image = $promo_image.'_out_'.$globals['lang'].'.png';
1422 elseif(file_exists($promo_image_temp.'_out_'.$globals['lang'].'.png'))
1423 $out_promo_image = $promo_image.'_out_'.$globals['lang'].'.png';
1424 elseif(file_exists($promo_image_temp.'_out_'.'.jpg'))
1425 $out_promo_image = $promo_image.'_out_'.'.jpg';
1426 elseif(file_exists($promo_image_temp.'_out.png'))
1427 $out_promo_image = $promo_image.'_out.png';
1428 elseif(file_exists($promo_image_temp.'_out_en.png'))
1429 $out_promo_image = $promo_image.'_out_en.png';
1430 elseif(file_exists($promo_image_temp.'_out_en.jpg'))
1431 $out_promo_image = $promo_image.'_out_en.jpg';
1432 elseif(file_exists($promo_image_temp.'_'.$globals['lang'].'.jpg'))
1433 $out_promo_image = $promo_image.'_'.$globals['lang'].'.jpg';
1434 elseif(file_exists($promo_image_temp.'_'.$globals['lang'].'.png'))
1435 $out_promo_image = $promo_image.'_'.$globals['lang'].'.png';
1436 elseif(file_exists($promo_image_temp.'_en.png'))
1437 $out_promo_image = $promo_image.'_en.png';
1438 elseif(file_exists($promo_image_temp.'_en.jpg'))
1439 $out_promo_image = $promo_image.'_en.jpg';
1440 elseif(file_exists($promo_image_temp.'_'.'.jpg'))
1441 $out_promo_image = $promo_image.'_'.'.jpg';
1442 elseif(file_exists($promo_image_temp.'.png'))
1443 $out_promo_image = $promo_image.'.png';
1444
1445 $out_promo_image .= '?'.time();
1446
1447 //inner image
1448 if(file_exists($promo_image_temp.'_in_'.$globals['lang'].'.png'))
1449 $inner_promo_image = $promo_image.'_in_'.$globals['lang'].'.png';
1450 elseif(file_exists($promo_image_temp.'_in_'.$globals['lang'].'.png'))
1451 $inner_promo_image = $promo_image.'_in_'.$globals['lang'].'.png';
1452 elseif(file_exists($promo_image_temp.'_in.png'))
1453 $inner_promo_image = $promo_image.'_in.png';
1454 elseif(file_exists($promo_image_temp.'_in_'.'.jpg'))
1455 $inner_promo_image = $promo_image.'_in_'.'.jpg';
1456 elseif(file_exists($promo_image_temp.'_in_en.png'))
1457 $inner_promo_image = $promo_image.'_in_en.png';
1458 elseif(file_exists($promo_image_temp.'_in_en.jpg'))
1459 $inner_promo_image = $promo_image.'_in_en.jpg';
1460 elseif(file_exists($promo_image_temp.'_'.$globals['lang'].'.jpg'))
1461 $inner_promo_image = $promo_image.'_'.$globals['lang'].'.jpg';
1462 elseif(file_exists($promo_image_temp.'_'.$globals['lang'].'.png'))
1463 $inner_promo_image = $promo_image.'_'.$globals['lang'].'.png';
1464 elseif(file_exists($promo_image_temp.'_en.png'))
1465 $inner_promo_image = $promo_image.'_en.png';
1466 elseif(file_exists($promo_image_temp.'_en.jpg'))
1467 $inner_promo_image = $promo_image.'_en.jpg';
1468 elseif(file_exists($promo_image_temp.'.jpg'))
1469 $inner_promo_image = $promo_image.'.jpg';
1470 elseif(file_exists($promo_image_temp.'.png'))
1471 $inner_promo_image = $promo_image.'.png';
1472
1473 $inner_promo_image .= '?'.time();
1474
1475 $promotion_used = ($stats[$value]['used'] != '' ? ($stats[$value]['used'] > 0 ? $stats[$value]['used'] : 17) : 17);
1476 $promotion_rate = ($stats[$value]['rate'] != '' ? ($stats[$value]['rate'] > 0 ? $stats[$value]['rate'] : 4.7) : 4.7);
1477 $token_after_fix = $promotion['promo_id'];
1478 $shortcodes = get_shortcodes();
1479 $promo_translations[$promotion['promo_id']]['view_title'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_translations[$promotion['promo_id']]['view_title']));
1480 $promo_translations[$promotion['promo_id']]['what_you_get'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_translations[$promotion['promo_id']]['what_you_get']));
1481 $promo_translations[$promotion['promo_id']]['token_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_translations[$promotion['promo_id']]['token_terms']));
1482 $promo_translations[$promotion['promo_id']]['token_restrictive_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_translations[$promotion['promo_id']]['token_restrictive_terms']));
1483 $view_title = ($promo_translations[$promotion['promo_id']]['view_title']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['view_title']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['view_title']['token_en']);
1484 $what_you_get = ($promo_translations[$promotion['promo_id']]['what_you_get']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['what_you_get']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['what_you_get']['token_en']);
1485 $token_terms = ($promo_translations[$promotion['promo_id']]['token_terms']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['token_terms']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['token_terms']['token_en']);
1486 $token_restrictive_terms = ($promo_translations[$promotion['promo_id']]['token_restrictive_terms']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['token_restrictive_terms']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['token_restrictive_terms']['token_en']);
1487 $token_availability = ($promo_translations[$promotion['promo_id']]['token_availability']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['token_availability']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['token_availability']['token_en']);
1488 if($promo_day == 'yesterday' && !$dd->isMobile()){
1489 if(!isset($promotions['promotions_days']['today'][$value])){
1490 $output .= '<div class="promotion ' . $promo_day . ' text-center">' .
1491 '<div class="promo_header">' .
1492 ($promotion['extra_class'] != '' ? $globals['translations'][$promotion['extra_class']] : '') .
1493 '</div>' .
1494 '<div class="promo_logo text-center">' .
1495 '<img src="' . $out_promo_image . '" />' .
1496 '</div>' .
1497 '<div class="promo_title">' . html_entity_decode($view_title) . '</div>' .
1498 '<div class="glyphicon glyphicon-user promo_users"><span class="glyph-label">' . $promotion_used . '</span></div>' .
1499 '<div class="glyphicon glyphicon-star promo_rate"><span class="glyph-label">' . $promotion_rate . '</span></div>' .
1500 '<div class="not_available_today text-center">' .
1501 $globals['translations']['Not available today'] .
1502 '</div>' .
1503 '</div>';
1504 }
1505 }elseif($promo_day == 'today'){
1506 if($promotion['tsto']=='')
1507 $promotion['tsto'] = date('Y-m-d 23:59:59');
1508 $promotions_displayed[] = $promotion['promo_id'];
1509 if($first_today_promo == true){
1510 $initial_promo = ' initial-promo';
1511 $first_today_promo = false;
1512 }else
1513 $initial_promo = '';
1514 $today = date('Y-m-d') . ' 23:59:59';
1515 $tsto = date('F d, Y H:i A',strtotime($promotion['tsto'].' +1 day'));
1516 $today_date = date('F d, Y H:i A') . ' UTC';
1517 $differenceInSeconds = strtotime($today) - strtotime(date('Y-m-d H:i:s'));
1518 $custom_classes = '<style type="text/css">' . "\r\n";
1519 if(is_array($promotion['custom_styles']) && !empty($promotion['custom_styles'])){
1520 if(isset($promotion['custom_styles']['promo_background']) && $promotion['custom_styles']['promo_background'] != '')
1521 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container,.promo-' . $promotion['promo_id'] . ' .promotion_container .promotion_contents .restrictive_terms,.promo-' . $promotion['promo_id'] . ' .promotion_container .promotion_terms_container {background-color:' . $promotion['custom_styles']['promo_background'] . '!important;}' . "\r\n";
1522 if(isset($promotion['custom_styles']['promo_text_color']) && $promotion['custom_styles']['promo_text_color'] != '')
1523 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container,.promo-' . $promotion['promo_id'] . ' .promotion_container .promotion_terms_container .promotion_terms_content,.promo-' . $promotion['promo_id'] . ' .promotion_container .header,.promo-' . $promotion['promo_id'] . ' .promotion_container .header .headline_text_container,.promo-' . $promotion['promo_id'] . ' .promotion_container .toggle_content,.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_counter {color:' . $promotion['custom_styles']['promo_text_color'] . '!important;}' . "\r\n";
1524 if(isset($promotion['custom_styles']['footer_color']) && $promotion['custom_styles']['footer_color'] != ''){
1525 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_button_controls {background-color:' . $promotion['custom_styles']['footer_color'] . '!important;color:' . $promotion['custom_styles']['footer_text_color'] . ';}' . "\r\n" .
1526 "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_button_controls:before {border:1px solid ' . $promotion['custom_styles']['footer_color'] . '!important;}' . "\r\n";
1527 }
1528 if(isset($promotion['custom_styles']['footer_text_color']) && $promotion['custom_styles']['footer_text_color'] != '')
1529 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .addeventatc_icon:before,.promo-' . $promotion['promo_id'] . ' .promotion .promo_button_controls .inner_button_controls .button_control.rated .promo_badge_rate,.promo-' . $promotion['promo_id'] . ' .promotion .promo_button_controls .inner_button_controls .button_control.used .promo_used, .promo-' . $promotion['promo_id'] . ' .promotion .promo_button_controls .inner_button_controls .button_control.rate_action {color:' . $promotion['custom_styles']['footer_text_color'] . '!important;}' . "\r\n";
1530 if(isset($promotion['custom_styles']['footer_icons_color']) && $promotion['custom_styles']['footer_icons_color'] != ''){
1531 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_button_controls .inner_button_controls .button_control.rated:before,.promo-' . $promotion['promo_id'] . ' .promotion .promo_button_controls .inner_button_controls .button_control.used:before, .promo-' . $promotion['promo_id'] . ' .promotion .promo_button_controls .inner_button_controls .button_control .rating-container .rating-stars {color:' . $promotion['custom_styles']['footer_icons_color'] . '!important;}' . "\r\n" .
1532 "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_button_controls .inner_button_controls .button_control .rating-container .rating-stars:before {color:' . $promotion['custom_styles']['footer_icons_color'] . '!important;}' . "\r\n";
1533 }
1534 if(isset($promotion['custom_styles']['footer_rating_color']) && $promotion['custom_styles']['footer_rating_color'] != '')
1535 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promo_button_controls .inner_button_controls .button_control .rating-container {color:' . $promotion['custom_styles']['footer_rating_color'] . '!important;}' . "\r\n";
1536 if(isset($promotion['custom_styles']['action_buttons_color']) && $promotion['custom_styles']['action_buttons_color'] != '')
1537 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .btn-default {background-color:' . $promotion['custom_styles']['action_buttons_color'] . '!important;}' . "\r\n";
1538 if(isset($promotion['custom_styles']['action_buttons_text_color']) && $promotion['custom_styles']['action_buttons_text_color'] != '')
1539 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .btn-default {color:' . $promotion['custom_styles']['action_buttons_text_color'] . '!important;}' . "\r\n";
1540 if(isset($promotion['custom_styles']['action_buttons_text_color']) && $promotion['custom_styles']['action_buttons_text_color'] != '')
1541 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .btn-default {color:' . $promotion['custom_styles']['action_buttons_text_color'] . '!important;}' . "\r\n";
1542 if(isset($promotion['custom_styles']['availability_text_color']) && $promotion['custom_styles']['availability_text_color'] != '')
1543 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .sub-headline {color:' . $promotion['custom_styles']['availability_text_color'] . '!important;}' . "\r\n";
1544 }
1545 if(is_array($promotion['custom_classes']) && !empty($promotion['custom_classes'])){
1546 foreach($promotion['custom_classes'] as $custom_class => $style){
1547 $custom_classes .= "\t" . '.promo-' . $promotion['promo_id'] . ' .promotion_container .promotion_contents .' . $style['class_name'] . ' {' . $style['class_type'] . ': ' . $style['color_value'] . '!important;}' . "\r\n";
1548 }
1549 }
1550 $custom_classes .= '</style>' . "\r\n";
1551
1552 if($dd->isMobile()){
1553 $output .= '<div class="row promotion ' . $promo_day . ' text-center' . ($promotion['extra_class'] != '' ? ' highlighted' : '') . $class . $initial_promo . '" rel="promotion-' . $promotion['promo_id'] . '">' .
1554 '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center promo_header" rel="' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1555 '<div class="promo_header_inner">' .
1556 ($promotion['extra_class'] != '' ? $globals['translations'][$promotion['extra_class']] : '') .
1557 '</div>' .
1558 '</div>' .
1559 '<div class="clearfix"></div>' .
1560 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 promotion_logo text-center" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1561 '<img rel="promotion-' . $promotion['promo_id'] . '" src="' . $out_promo_image . '" />' .
1562 '</div>' .
1563 '<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5 promo_title text-left" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1564 html_entity_decode($view_title) .
1565 '</div>' .
1566 '<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 counter_element">' .
1567 $globals['translations']['Ends In'] . '<br />' .
1568 '<div class="clock promo_counter" rel="' . $differenceInSeconds . '" data-countdown="' . $today . '"></div>' .
1569 '</div>' .
1570 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 action_button_container" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1571 '<div class="action_button glyphicon glyphicon-play"></div>' .
1572 '</div>';
1573 }else{
1574 $output .= '<div class="promotion ' . $promo_day . ' text-center' . ($promotion['extra_class'] != '' ? ' highlighted' : '') . $class . $initial_promo . '" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1575 '<div class="promo_header text-center" rel="' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#' . $promotion['promo_id'] . '">' .
1576 '<div class="promo_header_inner inline-block">' .
1577 ($promotion['extra_class'] != '' ? $globals['translations'][$promotion['extra_class']] : '') .
1578 '</div>' .
1579 '</div>' .
1580 '<div class="promo_logo text-center" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' .
1581 '<img rel="promotion-' . $promotion['promo_id'] . '" src="' . $out_promo_image . '" />' .
1582 '</div>' .
1583 '<div class="promo_title" rel="promotion-' . $promotion['promo_id'] . '" data-toggle="modal" data-target="#promotion-' . $promotion['promo_id'] . '">' . html_entity_decode($view_title) . '</div>' .
1584 '<div class="glyphicon glyphicon-user promo_users" rel="promotion-' . $promotion['promo_id'] . '"><span class="glyph-label">' . $promotion_used . '</span></div>' .
1585 '<div class="glyphicon glyphicon-star promo_rate" rel="promotion-' . $promotion['promo_id'] . '"><span class="glyph-label">' . $promotion_rate . '</span></div>';
1586 }
1587 $output .= '</div>';
1588 $tournaments_class = ($promotion['tournaments_redirection'] ? ' tournaments_redirection' : '');
1589 $modals .= '<div class="modal-offer modal fade promo-' . $promotion['promo_id'] . $tournaments_class . '" id="promotion-' . $promotion['promo_id'] . '" data-keyboard="false" data-backdrop="static">' .
1590 '<button type="button" class="close glyphicon glyphicon-share-alt glyphicon-flipped" data-dismiss="modal" aria-hidden="true"></button>
1591 <div class="rating_message" rel="' . $promotion['promo_id'] . '" id="success">' .
1592 '<div class="close cancel glyphicon glyphicon-remove"></div>' .
1593 '<h2>' . $globals['translations']['Rating'] . '</h2>' .
1594 '<div class="rate_glyphs">
1595 <span class="glyphicon glyphicon-star" id="1"></span>
1596 <span class="glyphicon glyphicon-star middle" id="2"></span>
1597 <span class="glyphicon glyphicon-star" id="3"></span>
1598 <span class="glyphicon glyphicon-star middle" id="4"></span>
1599 <span class="glyphicon glyphicon-star" id="5"></span>
1600 </div>' .
1601 '<div class="rating_text_message"></div>' .
1602 '<button type="button" class="rating_message_close btn-close">' . $globals['translations']['Submit'] . '</button>' .
1603 '</div>' .
1604 $custom_classes .
1605 '<textarea class="promo_description" rel="' . $promotion['promo_id'] . '" style="display:none;">' . strip_tags($what_you_get) . '</textarea>
1606 <input type="hidden" class="promo_title" rel="' . $promotion['promo_id'] . '" value="' . $view_title . '" />
1607 <input type="hidden" class="promo_image" rel="' . $promotion['promo_id'] . '" value="' . $globals['langs_array'][$globals['lang']]['language_url'] . $inner_promo_image . '" />
1608 <input type="hidden" class="promo_url" res="' . $promotion['promo_schedule_date'] . '-' . $promotion['schedule_id'] . '" rel="' . $promotion['promo_id'] . '" value="' . $globals['langs_array'][$globals['lang']]['promotions_url'] . '#' . $promotion['code'] . '" />
1609 <input type="hidden" class="user" rel="' . $globals['user_id'] . '" res="' . $globals['username'] . '" value="' . $globals['user_ip'] . '" />
1610 <input type="hidden" class="name" value="' . $_REQUEST['skin'] . '" rel="' . $appAbbrev . '" />
1611 <div class="promotion_container promotion center-block">
1612 <div class="promotion_terms_container" id="promo-terms-' . $promotion['promo_id'] . '">
1613 <div class="toggle_content glyphicon glyphicon-triangle-left" rel="' . $promotion['promo_id'] . '">' . $globals['translations']['Promotion'] . '</div>
1614 <div class="promotion_terms_content">' .
1615 html_entity_decode($token_terms);
1616 if($appAbbrev != 'ojo' && $appAbbrev != 'ojo-uk' && $appAbbrev != 'ojo-dk'){
1617 $modals .= $globals['translations']['generic_daily_picks_terms'];
1618 }
1619 $ending_date = date($globals['date_formats'],($promotion['duration']>1?($promotion['ending_stamp']!=0?$promotion['ending_stamp']:strtotime($today_ending_date)):strtotime($today_ending_date)));
1620
1621 if(in_array($appAbbrev, ['ojo', 'ojo-uk', 'ojo-dk']) && in_array(strtolower($globals['lang']), ['se', 'sv'])){
1622 $availability_element = 'Gäller till:<span class="availability"> ' . $ending_date . '</span>';
1623 }else{
1624 $availability_element = $globals['translations']['Use Until:'] . '<span class="availability"> ' . $ending_date . '</span>';
1625 }
1626
1627 /* if($promotion['promo_id'] == 110)
1628 var_dump($globals['translations'][$promotion['availability']['offer_availability']]); */
1629 if($promotion['availability']['offer_availability'] != '' && $promotion['availability']['offer_availability'] == 'token_availability_'.$promotion['promo_id']){
1630 $availability_element .= ($dd->isMobile() ? '<br />' : ' | ') . $globals['translations']['Available:'] . '<span class="availability"> ';
1631 $availability_element .= html_entity_decode($token_availability);
1632 //$availability_element .= $globals['translations'][$promotion['availability']['offer_availability']];
1633 }elseif($promotion['availability']['offer_availability']!=''){
1634 $availability_text = $globals['translations'][$promotion['availability']['offer_availability']];
1635 $availability_element .= ($dd->isMobile() ? '<br />' : ' | ') . $globals['translations']['Available:'] . '<span class="availability"> ';
1636 $availability_element .= str_replace("*",$promotion['availability']['replacement_number'],html_entity_decode($availability_text));
1637 }
1638 $modals .= '</div>
1639 </div>
1640 <div class="header">
1641 <div class="logo_container text-left"><img src="' . $inner_promo_image . '" /></div>
1642 <div class="toggle_content glyphicon glyphicon-triangle-right active" rel="' . $promotion['promo_id'] . '">' . $globals['translations']['Terms'] . '</div>
1643 <div class="headline_text_container center-block text-center">
1644 ' . html_entity_decode($view_title) . '<br />' .
1645 '<div class="sub-headline highlight">' .
1646 $availability_element . /* $promo_translations[$promotion['promo_id']]['token_availability'.$promotion['promo_id']]['token_'.$globals['lang']] . */
1647 '</div>' . '<br />';
1648 //$promotion['what_you_get']['token_'.$globals['lang']] = html_entity_decode($promotion['what_you_get']['token_'.$globals['lang']]);
1649 //preg_match_all("/#BONUS_([A-Za-z0-9]+)#/", $promotion['what_you_get']['token_'.$globals['lang']], $bonus_codes_found);
1650 //if(isset($_REQUEST['api_tech_test'])){
1651 /* echo '<xmp>';
1652 print_r($bonus_codes_found);
1653 echo '</xmp>'; */
1654 //}
1655 /* foreach($bonus_codes_found[0] as $key => $value){
1656 $action_selected = get_action($promotion,'action_btn',$bonus_codes_found[1][$key]);
1657 $promotion['what_you_get']['token_'.$globals['lang']] = str_replace($value,$action_selected,$promotion['what_you_get']['token_'.$globals['lang']]);
1658 } */
1659
1660 //$promo_strings = str_replace($promo_custom_buttons['buttons'],$promo_custom_buttons['converted'],$promo_strings); // Custom Buttons
1661 //$promotion['what_you_get']['token_'.$globals['lang']] = (isset($promotion['what_you_get']['token_'.$globals['lang']]) ? str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $promotion['what_you_get']['token_'.$globals['lang']]) : ''); // USERNAME
1662 //$promotion['token_restrictive_terms']['token_'.$globals['lang']] = (isset($promotion['token_restrictive_terms']['token_'.$globals['lang']]) ? str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $promotion['token_restrictive_terms']['token_'.$globals['lang']]) : ''); // USERNAME
1663 //$promotion['token_terms']['token_'.$globals['lang']] = (isset($promotion['token_terms']['token_'.$globals['lang']]) ? str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $promotion['token_terms']['token_'.$globals['lang']]) : ''); // USERNAME
1664 $promo_title = ($promotion['view_title']['token_'.$globals['lang']] != '' ? $promo_translations[$promotion['promo_id']]['view_title']['token_'.$globals['lang']] : $promo_translations[$promotion['promo_id']]['view_title']['token_en']);
1665 $what_you_get = str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $what_you_get); // USERNAME
1666 $token_restrictive_terms = str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $token_restrictive_terms); // USERNAME
1667 $token_terms = str_replace(array('#USERNAME','#SKIN_DOMAIN#','#SKIN_NAME#','#EMAIL_SUPPORT#'),array($globals['username'],$globals['brand_data']['domain'],$globals['brand_data']['appName'],'support@'.$globals['brand_data']['domain']), $token_terms); // USERNAME
1668 if(sizeof($promotion['custom_buttons']) > 0){
1669 //fetch and fix custom buttons
1670 $promo_custom_buttons['buttons'] = array();
1671 $promo_custom_buttons['converted'] = array();
1672 foreach($promotion['custom_buttons'] as $cb => $value){
1673 if($promotion['desktop_game'] != 0)
1674 $games['desktop_game'] = $promotion['desktop_game'];
1675 if($promotion['mobile_game'] != 0)
1676 $games['mobile_game'] = $promotion['mobile_game'];
1677 $promotion['custom_buttons'][$cb]['converted'] = get_action($value,'action_btn',$cb,$request_data,$games);
1678 $promo_custom_buttons['buttons'][] = '#' . $cb . '#';
1679 $promo_custom_buttons['converted'][] = $promotion['custom_buttons'][$cb]['converted'];
1680 $globals['generated_packages'] .= generate_package($cb);
1681 }
1682 $what_you_get = str_replace($promo_custom_buttons['buttons'],$promo_custom_buttons['converted'],$what_you_get);
1683 $token_restrictive_terms = str_replace($promo_custom_buttons['buttons'],$promo_custom_buttons['converted'],$token_restrictive_terms);
1684 $token_terms = str_replace($promo_custom_buttons['buttons'],$promo_custom_buttons['converted'],$token_terms);
1685 }
1686 //get the avarage deposit and convert it to the account currency
1687 if($globals['currency'] == 'EUR')
1688 $dep_avg = $globals['dep_avg'];
1689 elseif($globals['currency'] == 'USD')
1690 $dep_avg = ceil(($globals['dep_avg'] * $globals['curr_exchange_rates']['EUR'])/10)*10;
1691 else
1692 $dep_avg = ceil(($globals['dep_avg'] * $globals['curr_exchange_rates']['EUR'])/10)*10*(in_array($globals['currency'],array('NOK','SEK','DKK','ZAR'))?10:1);
1693 //replace shortcode #DEP_AVG# with the average deposit value
1694 $what_you_get = str_replace('#DEP_AVG#', ($dep_avg.$globals['currency']),$what_you_get);
1695 //#DEP_AVG_ shortcodes
1696 preg_match_all("/#DEP_AVG_([A-Za-z0-9]+)#/", $what_you_get, $average_bonus_found);
1697 //var_dump($average_bonus_found);
1698 foreach($average_bonus_found[0] as $key => $value){
1699 //print_r($average_bonus_found);
1700 $min_value = 0;
1701 if(isset($average_bonus_found[1][$key]) && $average_bonus_found[1][$key] != '')
1702 $min_value = $average_bonus_found[1][$key];
1703 $dep_bonus = $dep_avg;
1704 if($dep_bonus < $min_value && $min_value != 0)
1705 $dep_bonus = $min_value;
1706 $dep_bonus .= $globals['currency'];
1707 $what_you_get = str_replace($value,$dep_bonus,$what_you_get);
1708 }
1709 //#DEP_BNS_ shortcodes
1710 preg_match_all("/#DEP_BNS_(?:SUM_)?([A-Za-z0-9]+)(?:_)?([A-Za-z0-9]+)?#/", $what_you_get, $average_bonus_found);
1711 foreach($average_bonus_found[0] as $key => $value){
1712 //print_r($average_bonus_found);
1713 $max_value = 0;
1714 if(isset($average_bonus_found[2][$key]) && $average_bonus_found[2][$key] != '')
1715 $max_value = $average_bonus_found[2][$key];
1716 $dep_bonus = ($dep_avg * ($average_bonus_found[1][$key]/100));
1717 if($dep_bonus > $max_value && $max_value != 0)
1718 $dep_bonus = $max_value;
1719 $dep_bonus .= $globals['currency'];
1720 $what_you_get = str_replace($value,$dep_bonus,$what_you_get);
1721 }
1722
1723 $modals .= '</div>';
1724 //'<div class="clock promo_counter glyphicon glyphicon-time" rel="' . $differenceInSeconds . '" data-countdown="' . $today . '"></div>';
1725 $tabs_contents = '';
1726 $restrictive_terms = '';
1727 if(isset($token_restrictive_terms) && $token_restrictive_terms != ''){
1728 $restrictive_terms = '<div class="restrictive_terms" rel="promotion-' . $promotion['promo_id'] . '">' .
1729 '<span class="close_icon glyphicon glyphicon-remove"></span>' .
1730 $token_restrictive_terms .
1731 '</div>';
1732 }
1733 /* foreach($tabs as $tab => $tab_value){
1734 $tab_content = ''; */
1735 if($what_you_get != '' || $what_you_get != ''/* && $tab_value['tab_content'] != 'restrictive_terms' || $tab_value['tab_content'] == 'token_terms' */){
1736 //$extra_terms = ($tab_value['tab_content'] == 'terms' ? $globals['translations']['generic_daily_picks_terms']['token_'.$globals['lang']] : '');
1737 $tab_content = $what_you_get;
1738 /* if($tab_value['tab_content'] == 'token_terms'){
1739 $tabs_contents .= '<div class="modal fade" id="terms_modal-' . $promotion['promo_id'] . '" tabindex="-1" role="dialog">
1740 <div class="modal-dialog" role="document">
1741 <div class="modal-content">
1742 <div class="modal-header">
1743 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
1744 <h4 class="modal-title" id="myModalLabel">Modal title</h4>
1745 </div>
1746 <div class="modal-body">' .
1747 html_entity_decode($tab_content) .
1748 html_entity_decode($extra_terms) .
1749 '</div>
1750 </div>
1751 </div>
1752 </div>';
1753 }else{ */
1754 $tabs_contents .= '<div class="promotion_contents' . ($restrictive_terms != '' ? ' restrictions ' : ' ') . 'what_you_get">' .
1755 $restrictive_terms .
1756 html_entity_decode($tab_content) .
1757 '</div>';
1758 //}
1759 }
1760 //}
1761 $modals .= '</div>' .
1762 $tabs_contents .
1763 '<div class="promo_button_controls">
1764 <div class="inner_button_controls ' . ($dd->isMobile() ? 'visible-sm' : '') . '">
1765 <div title="Add to Calendar" class="addeventatc button_control" rel="' . $promotion['promo_id'] . '">
1766 <span class="start">' . $promotion['tsfrom'] . '</span>
1767 <span class="end">' . $promotion['tsto'] . '</span>
1768 <span class="title">' . html_entity_decode($promo_translations[$promotion['promo_id']]['view_title']['token_'.$globals['lang']]) . '</span>
1769 <span class="all_day_event">true</span>
1770 <span class="date_format">DD/MM/YYYY</span>
1771 <span class="alarm_reminder">60</span>
1772 <span class="recurring"></span>
1773 </div>' .
1774 '<div class="button_control used glyphicon glyphicon-user text-left">
1775 <div class="promo_used text-center" id="' . $promotion['promo_id'] . '">' . $promotion_used . '</div>
1776 </div>
1777 <div class="button_control rated glyphicon glyphicon-star text-left">
1778 <div class="promo_badge_rate text-center" id="' . $promotion['promo_id'] . '">' . $promotion_rate . '</div>
1779 </div>
1780 <div class="button_control rate_action text-left">
1781 ' . $globals['translations']['Rate Now'] . ':
1782 <input id="rating-' . $promotion['promo_id'] . '" type="number" class="rating" rel="' . $globals['user_id'] . '" res="' . $globals['username'] . '" user_data="' . $globals['user_ip'] . '" data-show-clear="false" data-show-caption="false" data-min="0" data-max="5" data-step="1" data-size="xs" glyphicon="false" data-glyphicon="0">
1783 </div>
1784 </div>';
1785 if($dd->isMobile()){
1786 $modals .= '<div class="inner_button_controls visible-xs">
1787 <div class="auto-center">
1788 <div title="Add to Calendar" class="addeventatc button_control" rel="' . $promotion['promo_id'] . '">
1789 <span class="start">' . $promotion['tsfrom'] . '</span>
1790 <span class="end">' . $promotion['tsto'] . '</span>
1791 <span class="title">' . html_entity_decode($promo_title) . '</span>
1792 <span class="all_day_event">true</span>
1793 <span class="date_format">DD/MM/YYYY</span>
1794 <span class="alarm_reminder">60</span>
1795 <span class="recurring"></span>
1796 </div>' .
1797 '<div class="button_control used glyphicon glyphicon-user text-left">
1798 <div class="promo_used text-center" id="' . $promotion['promo_id'] . '">' . $promotion_used . '</div>
1799 </div>
1800 <div class="button_control rated glyphicon glyphicon-star text-left">
1801 <div class="promo_badge_rate text-center" id="promotion-' . $promotion['promo_id'] . '">' . $promotion_rate . '</div>
1802 </div>
1803 </div>
1804 <div class="auto-center">
1805 <div class="button_control rate_action text-left">
1806 ' . $globals['translations']['Rate Now'] . ':
1807 <input id="rating-' . $promotion['promo_id'] . '" type="number" class="rating" rel="' . $globals['user_id'] . '" res="' . $globals['username'] . '" user_data="' . $globals['user_ip'] . '" data-show-clear="false" data-show-caption="false" data-min="0" data-max="5" data-step="1" data-size="xs" glyphicon="false" data-glyphicon="0">
1808 </div>
1809 </div>
1810 </div>';
1811 }
1812 $modals .= '</div>
1813 </div>
1814 </div>';
1815 }elseif($promo_day == 'tomorrow'){
1816 $tomorrow = date('Y-m-d') . ' 23:59:59';
1817 $differenceInSeconds = strtotime($tomorrow) - strtotime(date('Y-m-d H:i:s'));
1818 if($dd->isMobile()){
1819 $output .= '<div class="row promotion ' . $promo_day . ' text-center' . ($promotion['extra_class'] != '' ? ' highlighted' : '') . $class . $initial_promo . '" rel="promotion-' . $promotion['promo_id'] . '">' .
1820 '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center promo_header" rel="' . $promotion['promo_id'] . '">' .
1821 '<div class="promo_header_inner inline-block">' .
1822 ($promotion['extra_class'] != '' ? $globals['translations'][$promotion['extra_class']] : '') .
1823 '</div>' .
1824 '</div>' .
1825 '<div class="clearfix"></div>' .
1826 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 promotion_logo text-center" rel="promotion-' . $promotion['promo_id'] . '">' .
1827 '<img rel="promotion-' . $promotion['promo_id'] . '" src="' . $out_promo_image . '" />' .
1828 '</div>' .
1829 '<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5 promo_title text-left" rel="promotion-' . $promotion['promo_id'] . '">' .
1830 html_entity_decode($view_title) .
1831 '</div>' .
1832 '<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 counter_element">' .
1833 $globals['translations']['Starts In'] . '<br />' .
1834 '<div class="clock promo_counter" rel="' . $differenceInSeconds . '" data-countdown="' . $tomorrow . '"></div>' .
1835 '</div>' .
1836 '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 action_button_container" rel="promotion-' . $promotion['promo_id'] . '">' .
1837 '<div class="action_button reminder_container">' .
1838 '<div title="' . $globals['translations']['Remind Me'] . '" class="addeventatc button_control" rel="promo-' . $promotion['promo_id'] . '">' .
1839 //'<span class="text_title">' . $globals['translations']['Remind Me'] . '</span>' .
1840 '<span class="start">' . $promotion['tsfrom'] . '</span>
1841 <span class="end">' . $promotion['tsto'] . '</span>
1842 <span class="title">' . html_entity_decode($view_title) . '</span>
1843 <span class="all_day_event">true</span>
1844 <span class="date_format">DD/MM/YYYY</span>
1845 <span class="alarm_reminder">60</span>
1846 <span class="recurring"></span>
1847 <div class="clearfix"></div>
1848 </div>' .
1849 '</div>' .
1850 '</div>' .
1851 '<div class="clearfix"></div>' .
1852 '</div>';
1853 }else{
1854 $output .= '<div class="promotion ' . $promo_day . ' text-center' . $class . '">' .
1855 '<div class="promo_header">' .
1856 ($promotion['extra_class'] != '' ? $globals['translations'][$promotion['extra_class']] : '') .
1857 '</div>' .
1858 '<div class="promo_logo text-center">' .
1859 '<img src="' . $out_promo_image . '" />' .
1860 '</div>' .
1861 '<div class="promo_title">' . html_entity_decode($view_title) . '</div>' .
1862 '<div class="glyphicon glyphicon-user promo_users"><span class="glyph-label">' . 147 . '</span></div>' .
1863 '<div class="glyphicon glyphicon-star promo_rate"><span class="glyph-label">' . ($stats[$value]['rate'] != '' ? ($stats[$value]['rate'] > 0 ? $stats[$value]['rate'] : 4.7) : 4.7) . '</span></div>' .
1864 '<div class="unavailable">' .
1865 $globals['translations']['Available in'] . '<br />' .
1866 '<div class="clock promo_counter glyphicon glyphicon-time" rel="' . $differenceInSeconds . '" data-countdown="' . $tomorrow . '"></div><br />' .
1867 '</div>' .
1868 '<div class="reminder">' .
1869 '<div title="' . $globals['translations']['Remind Me'] . '" class="addeventatc button_control" rel="promo-' . $promotion['promo_id'] . '">
1870 <span class="text_title">' . $globals['translations']['Remind Me'] . '</span>
1871 <span class="start">' . $promotion['tsfrom'] . '</span>
1872 <span class="end">' . $promotion['tsto'] . '</span>
1873 <span class="title">' . html_entity_decode($view_title) . '</span>
1874 <span class="all_day_event">true</span>
1875 <span class="date_format">DD/MM/YYYY</span>
1876 <span class="alarm_reminder">60</span>
1877 <span class="recurring"></span>
1878 <div class="clear"></div>
1879 </div>' .
1880 '</div>' .
1881 '</div>';
1882 }
1883 }
1884 $i++;
1885 }
1886 }
1887 }
1888 /* if(isset($_GET['nikos'])){
1889 $end_time=microtime(true);
1890 echo "time_after_promos_loop: ", bcsub($end_time, $start_time, 4), "\n";
1891 echo "memory (byte)_after_promos_loop: ", memory_get_peak_usage(true), "\n";
1892 } */
1893 $modals .= $globals['generated_packages'];
1894 if(!empty($promotions_displayed) && sizeof($promotions_displayed) > 0 && $logged_hit != false){
1895 $displayed_promos = implode(',',$promotions_displayed);
1896 $query = pg_query($rc_connection,"update d_daily_picks_log set displayed_promotions='$displayed_promos' where entry_id='$logged_hit'");
1897 }
1898
1899 end_bench('build_available_promotions');
1900
1901 return $header . $output . $footer . $modals . $end_doc;
1902}
1903
1904function parameter_qualified($data = [],$parameter = '',$variable = ''){
1905 global $kc_connection,$rc_connection,$globals,$cache;
1906 $inclusive = true;
1907 $not = false;
1908 if($data[$variable]=='undefined')
1909 return false;
1910 //$globals[$parameter] = ($globals[$parameter]=='undefined'?'':$globals[$parameter]);
1911 if(!is_array($data) || $parameter == '' || $variable == '')
1912 return false;
1913 if(strpos($data[$variable],'!') !== false){
1914 $not = true;
1915 $data[$variable] = str_replace('!','',$data[$variable]);
1916 }
1917 $inclusive = false;
1918 if(strpos($data[$variable],'|') !== false){
1919 $inclusive = true;
1920 $data[$variable] = str_replace('|','',$data[$variable]);
1921 }
1922 if(!is_array($data[$variable]) && strpos($data[$variable],',') !== false){
1923 $data[$variable] = explode(',',$data[$variable]);
1924 }
1925 $globals[$parameter] = number_format($globals[$parameter], 2, '.', '');
1926 if($inclusive && $globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable]) && !($globals[$parameter] >= number_format($data[$variable][0], 2, '.', '') && $globals[$parameter] <= number_format($data[$variable][1], 2, '.', '')) && !$not){
1927 //if($pro)
1928 return false;
1929 //continue;
1930 }elseif($inclusive && $globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable]) && $globals[$parameter] >= number_format($data[$variable][0], 2, '.', '') && $globals[$parameter] <= number_format($data[$variable][1], 2, '.', '') && $not){
1931 //if($pro)
1932 return false;
1933 //continue;
1934 }elseif(!$inclusive && $globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable]) && !($globals[$parameter] >= number_format($data[$variable][0], 2, '.', '') && $globals[$parameter] < number_format($data[$variable][1], 2, '.', '')) && !$not){
1935 return false;
1936 //continue;
1937 }elseif(!$inclusive && $globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable]) && $globals[$parameter] >= number_format($data[$variable][0], 2, '.', '') && $globals[$parameter] < number_format($data[$variable][1], 2, '.', '') && $not){
1938 return false;
1939 //continue;
1940 }elseif($globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && !is_array($data[$variable]) && !empty($data[$variable])){
1941 if(strpos($data[$variable],'<') !== false && $globals[$parameter] >= number_format(str_replace('<','',$data[$variable]), 2, '.', '') && !$not){
1942 return false;
1943 //continue;
1944 }elseif(strpos($data[$variable],'>=') !== false && $globals[$parameter] >= number_format(str_replace('>=','',$data[$variable]), 2, '.', '') && $not){
1945 return false;
1946 //continue;
1947 }elseif(strpos($data[$variable],'>=') !== false && $globals[$parameter] < number_format(str_replace('>=','',$data[$variable]), 2, '.', '') && !$not){
1948 return false;
1949 //continue;
1950 }elseif(strpos($data[$variable],'>=') === false && strpos($data[$variable],'>') !== false && $globals[$parameter] <= number_format(str_replace('>','',$data[$variable]), 2, '.', '') && !$not){
1951 return false;
1952 //continue;
1953 }elseif((strpos($data[$variable],'<') === false && strpos($data[$variable],'>') === false) && $data[$variable] != $globals[$parameter] && !$not){
1954 return false;
1955 //continue;
1956 }elseif((strpos($data[$variable],'<') === false && strpos($data[$variable],'>') === false) && $data[$variable] == $globals[$parameter] && $not){
1957 return false;
1958 //continue;
1959 }
1960 }elseif($globals[$parameter] != '' && $data[$variable] != '' && $globals[$parameter] == 0 && $data[$variable] > 0 && !$not){
1961 return false;
1962 //continue;
1963 }
1964 return true;
1965}
1966
1967function date_parameter_qualified($data = [],$parameter = '',$variable = '',$day_check = ''){
1968 global $kc_connection,$rc_connection,$globals,$cache;
1969 $inclusive = false;
1970 $not = false;
1971 if($data[$variable]=='undefined')
1972 return false;
1973 $globals_temp = $globals[$parameter];
1974 //$globals[$parameter] = ($globals[$parameter]=='0000-00-00'?'1970-01-01':$globals[$parameter]);
1975 if(!is_array($data) || $parameter == '' || $variable == '')
1976 return false;
1977 if(strpos($data[$variable],'!') !== false){
1978 $not = true;
1979 $data[$variable] = str_replace('!','',$data[$variable]);
1980 }
1981 $inclusive = false;
1982 if(strpos($data[$variable],'|') !== false){
1983 $inclusive = true;
1984 $data[$variable]= str_replace('|','',$data[$variable]);
1985 }
1986 if(!is_array($data[$variable]) && strpos($data[$variable],',') !== false){
1987 $data[$variable] = explode(',',$data[$variable]);
1988 }
1989 $day_check = ($globals[$parameter]=='0000-00-00'?'':$day_check);
1990 if($inclusive){
1991 if($globals[$parameter] != '' && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable])){
1992 if(!(strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$data[$variable][1].' days'))) && strtotime($globals[$parameter].$day_check) <= strtotime(date('Y-m-d',strtotime('- '.$data[$variable][0].' days')))) && !$not){
1993 return false;
1994 // filter has ,
1995 }
1996 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'<') !== false && strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.str_replace('<','',$data[$variable])))) && !$not){
1997 return false;
1998 // filter has <
1999 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'<') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('<','',$data[$variable])))) && $not){
2000 return false;
2001 // filter has <
2002 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('>=','',$data[$variable])))) && !$not){
2003 return false;
2004 // filter has >=
2005 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') !== false && strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.str_replace('>=','',$data[$variable])))) && $not){
2006 return false;
2007 // filter has >=
2008 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') === false && strpos($data[$variable],'>') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('>','',$data[$variable])))) && !$not){
2009 return false;
2010 // filter has >
2011 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'=') !== false && strtotime($globals[$parameter].$day_check) != strtotime(date('Y-m-d',strtotime('- '.$data[$variable].' days'))) && !$not){
2012 return false;
2013 // filter has =
2014 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'=') !== false && strtotime($globals[$parameter].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$data[$variable].' days'))) && $not){
2015 return false;
2016 // filter has =
2017 }
2018 }else{
2019 if($globals[$parameter] != '' && $data[$variable] != '' && is_array($data[$variable]) && !empty($data[$variable])){
2020 if(!(strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.$data[$variable][1].' days'))) && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.$data[$variable][0].' days')))) && !$not){
2021 return false;
2022 // filter has ,
2023 }
2024 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'<') !== false && strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.str_replace('<','',$data[$variable].' days')))) && !$not){
2025 return false;
2026 // filter has <
2027 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'<') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('<','',$data[$variable].' days')))) && $not){
2028 return false;
2029 // filter has <
2030 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('>=','',$data[$variable].' days')))) && !$not){
2031 return false;
2032 // filter has >=
2033 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') !== false && strtotime($globals[$parameter].$day_check) >= strtotime(date('Y-m-d',strtotime('- '.str_replace('>=','',$data[$variable].' days')))) && $not){
2034 //die($globals[$parameter].','.date('Y-m-d',strtotime('- '.str_replace('>=','',$data[$variable].' days'))));
2035 return false;
2036 // filter has >=
2037 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'>=') === false && strpos($data[$variable],'>') !== false && strtotime($globals[$parameter].$day_check) < strtotime(date('Y-m-d',strtotime('- '.str_replace('>','',$data[$variable].' days')))) && !$not){
2038 return false;
2039 // filter has >
2040 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'=') !== false && strtotime($globals[$parameter].$day_check) != strtotime(date('Y-m-d',strtotime('- '.$data[$variable].' days'))) && !$not){
2041 return false;
2042 // filter has =
2043 }elseif($globals[$parameter] != '' && $data[$variable] != '' && strpos($data[$variable],'=') !== false && strtotime($globals[$parameter].$day_check) == strtotime(date('Y-m-d',strtotime('- '.$data[$variable].' days'))) && $not){
2044 return false;
2045 // filter has =
2046 }
2047 }
2048 /* elseif(!$inclusive && $globals[$parameter] != '' && $globals[$parameter] > 0 && is_array($data[$variable]) && !empty($data[$variable]) && $globals[$parameter] >= $data[$variable][0] && $globals[$parameter] < $data[$variable][1] && $not){
2049 return false;
2050 //continue;
2051 }elseif($globals[$parameter] != '' && $globals[$parameter] > 0 && $data[$variable] != '' && !is_array($data[$variable]) && !empty($data[$variable])){
2052 if(strpos($data[$variable],'<') !== false && $globals[$parameter] >= number_format(str_replace('<','',$data[$variable])) && !$not){
2053 return false;
2054 //continue;
2055 }elseif(strpos($data[$variable],'>') !== false && $globals[$parameter] < number_format(str_replace('>','',$data[$variable])) && !$not){
2056 return false;
2057 //continue;
2058 }elseif((strpos($data[$variable],'<') === false && strpos($data[$variable],'>') === false) && $data[$variable] != $globals[$parameter] && !$not){
2059 return false;
2060 //continue;
2061 }
2062 }elseif($globals[$parameter] == 0 && $data[$variable] > 0 && !$not){
2063 return false;
2064 //continue;
2065 } */
2066 $globals[$parameter] = $globals_temp;
2067 return true;
2068}
2069
2070function get_promotions($force = false) {
2071 global $kc_connection,$rc_connection,$globals,$cache;
2072
2073 start_bench('get_promotions');
2074
2075 $redis = connectRedis();
2076
2077 # DELETE CACHE
2078 // $redis->delete('promotions_per_brand');
2079 // $redis->delete('promotions');
2080 // $redis->delete('promotions_days');
2081 // $redis->delete('cached_timestamp');
2082 $promotions = array();
2083 $promotions_days = array();
2084 $promotions_days['yesterday'] = array();
2085 $promotions_days['today'] = array();
2086 $promotions_days['tomorrow'] = array();
2087 $promotions_days['always'] = array();
2088 $promotions_per_brand = array();
2089 $promo_translations = array();
2090 $promo_ids = '';
2091 $where_specific = '';
2092 if($redis->exists('promotions_per_brand'))
2093 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2094 $cached_day = date('Y-m-d');
2095 if($redis->exists('cached_timestamp')) {
2096 $cached_day = date('Y-m-d', strtotime($redis->get('cached_timestamp')));
2097 }
2098
2099 if($redis->exists('promotions') && strtotime($cached_day) == strtotime(date('Y-m-d')) && $cache == true && $force == false) {
2100 start_bench('get_promotions cached');
2101
2102 $promotions = unserialize($redis->get('promotions'));
2103 $promotions_days = unserialize($redis->get('promotions_days'));
2104 $promo_translations = unserialize($redis->get('promo_translations'));
2105 $promo_ids = implode(',',array_keys($promotions));
2106 if($redis->exists('promotions_per_brand')){
2107 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2108 //var_dump($promotions_per_brand);
2109 //die();
2110 }else{
2111 foreach($promotions as $promo => $value){
2112 if(is_array($promotions[$promo]['brands']) && sizeof($promotions[$promo]['brands']) > 0){
2113 foreach($promotions[$promo]['brands'] as $current_brand => $brand_value){
2114 $promotions_per_brand[$current_brand][$promo] = $value;
2115 }
2116 }elseif($promotions[$promo]['brands'] != ''){
2117 $promotions_per_brand[$promotions[$promo]['brands']][$promo] = $value;
2118 }
2119 }
2120 }
2121 end_bench('get_promotions cached');
2122 }else{
2123 start_bench('get_promotions not cached');
2124 //$shortcodes = get_shortcodes();
2125 if(isset($globals['custom_date'])){
2126 $yesterday_start = date('Y-m-d',strtotime($globals['custom_date'].' - 1 day')).' 00:00:00';
2127 $yesterday_end = date('Y-m-d',strtotime($globals['custom_date'].' - 1 day')).' 23:59:59';
2128 $today_start = date('Y-m-d',strtotime($globals['custom_date'])).' 00:00:00';
2129 $today_end = date('Y-m-d',strtotime($globals['custom_date'])).' 23:59:59';
2130 $tomorrow_start = date('Y-m-d',strtotime($globals['custom_date'].' + 1 day')).' 00:00:00';
2131 $tomorrow_end = date('Y-m-d',strtotime($globals['custom_date'].' + 1 day')).' 23:59:59';
2132 }else{
2133 $yesterday_start = date('Y-m-d',strtotime('- 1 day')).' 00:00:00';
2134 $yesterday_end = date('Y-m-d',strtotime('- 1 day')).' 23:59:59';
2135 $today_start = date('Y-m-d').' 00:00:00';
2136 $today_end = date('Y-m-d').' 23:59:59';
2137 $tomorrow_start = date('Y-m-d',strtotime('+ 1 day')).' 00:00:00';
2138 $tomorrow_end = date('Y-m-d',strtotime('+ 1 day')).' 23:59:59';
2139 }
2140 if($force == true && isset($_REQUEST['dev']) && isset($_REQUEST['promo']) && $_REQUEST['promo'] != ''){
2141 $where_specific = "and daily_picks_promotions.id='{$_REQUEST['promo']}'";
2142 $promotions = unserialize($redis->get('promotions'));
2143 $promotions_days = unserialize($redis->get('promotions_days'));
2144 $promo_translations = unserialize($redis->get('promo_translations'));
2145 $promo_ids = implode(',',array_keys($promotions));
2146 if($redis->exists('promotions_per_brand')){
2147 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2148 //var_dump($promotions_per_brand);
2149 //die();
2150 }else{
2151 foreach($promotions as $promo => $value){
2152 if(is_array($promotions[$promo]['brands']) && sizeof($promotions[$promo]['brands']) > 0){
2153 foreach($promotions[$promo]['brands'] as $current_brand => $brand_value){
2154 $promotions_per_brand[$current_brand][$promo] = $value;
2155 }
2156 }elseif($promotions[$promo]['brands'] != ''){
2157 $promotions_per_brand[$promotions[$promo]['brands']][$promo] = $value;
2158 }
2159 }
2160 }
2161 }
2162 $query_promotions = pg_query($kc_connection,"select
2163 daily_picks_promotions.*,
2164 daily_picks_schedule.ending_stamp,
2165 case
2166 when daily_picks_schedule.id IS NULL then 0
2167 else daily_picks_schedule.id
2168 end as schedule_id,
2169 case
2170 when daily_picks_promotions.all_time=1 then '$today_start'
2171 else daily_picks_schedule.tsfrom
2172 end as promo_schedule_date,
2173 case
2174 when daily_picks_promotions.bday_users='t' then '$today_start'
2175 else daily_picks_schedule.tsfrom
2176 end as tsfrom,
2177 case
2178 when daily_picks_promotions.bday_users='t' then '$today_end'
2179 else daily_picks_schedule.tsto
2180 end as tsto,
2181 case
2182 when daily_picks_promotions.bday_users='t' then 0
2183 else daily_picks_promotions.sorting
2184 end as generic_sorting,
2185 case
2186 when daily_picks_schedule.sorting IS NULL then 0
2187 else daily_picks_schedule.sorting
2188 end as calendar_sorting,
2189 case
2190 when daily_picks_promotions.all_time=1 and bday_users='t' then 'today'
2191 when '$yesterday_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'yesterday'
2192 when '$today_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'today'
2193 when '$tomorrow_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'tomorrow'
2194 else 'always'
2195 end as promo_day
2196 from
2197 daily_picks_promotions left outer join daily_picks_schedule on daily_picks_promotions.id=daily_picks_schedule.promotion_id
2198 where
2199 daily_picks_promotions.active='t'
2200 and
2201 daily_picks_promotions.enabled=1
2202 and (
2203 (daily_picks_schedule.tsfrom>='$yesterday_start' and daily_picks_schedule.tsfrom<='$tomorrow_end' and daily_picks_schedule.tsto>='$yesterday_start' and daily_picks_schedule.tsto<='$tomorrow_end')
2204 or daily_picks_promotions.all_time=1
2205 )
2206 $where_specific
2207 order by
2208 tsto asc,
2209 calendar_sorting desc,
2210 generic_sorting desc"
2211 );
2212 //and (daily_picks_promotions.all_time=1 and daily_picks_schedule between '$today_start' and '$today_end')
2213 if(pg_num_rows($query_promotions) > 0){
2214 while($promotion = pg_fetch_object($query_promotions)){
2215 $promo_ids .= ($promo_ids == '' ? $promotion->id : ','.$promotion->id);
2216 /*$view_title = json_decode(str_replace("\\\\",'\\',$promotion->view_title));
2217 $description = json_decode(str_replace("\\\\",'\\',$promotion->description));
2218 $more = json_decode(str_replace("\\\\",'\\',$promotion->more));
2219 $tac = json_decode(str_replace("\\\\",'\\',$promotion->tac));
2220 $rewards = json_decode(str_replace("\\\\",'\\',$promotion->rewards));*/
2221 $promotions_days[$promotion->promo_day][$promotion->id] = $promotion->id;
2222 $token_after_fix = $promotion->id;
2223 /* $token_strings = pg_query($kc_connection,"select
2224 string_translations.*
2225 from
2226 string_translations
2227 where
2228 token
2229 in('view_title_$token_after_fix','what_to_do_$token_after_fix','what_you_get_$token_after_fix','token_terms_$token_after_fix','token_rewards_$token_after_fix')
2230 and
2231 category='promotions'"
2232 ); */
2233 if($promotion->promo_day == 'today' || !isset($promotions[$promotion->id])){
2234 $token_strings = pg_query($kc_connection,"select
2235 string_translations.*
2236 from
2237 string_translations
2238 where
2239 token
2240 in('view_title_$token_after_fix','what_you_get_$token_after_fix','token_terms_$token_after_fix','token_restrictive_terms_$token_after_fix','token_availability_$token_after_fix')
2241 and
2242 category='promotions'"
2243 );
2244 $promotions[$promotion->id] = array(
2245 'promo_id' => $promotion->id,
2246 'schedule_id' => $promotion->schedule_id,
2247 'promo_schedule_date' => strtotime($promotion->promo_schedule_date),
2248 'title' => $promotion->title,
2249 'code' => $promotion->code,
2250 'user_id' => (strpos($promotion->user_id, ',') !== false ? explode(',',$promotion->user_id) : $promotion->user_id),
2251 'user_groups' => (strpos($promotion->user_groups, ',') !== false ? explode(',',$promotion->user_groups) : $promotion->user_groups),
2252 'restricted_user_groups' => (strpos($promotion->restricted_user_groups, ',') !== false ? explode(',',$promotion->restricted_user_groups) : $promotion->restricted_user_groups),
2253 'aname' => (strpos($promotion->aname, ',') !== false ? explode(',',$promotion->aname) : $promotion->aname),
2254 'platforms_restricted' => (strpos($promotion->platforms_restricted, ',') !== false ? explode(',',$promotion->platforms_restricted) : $promotion->platforms_restricted),
2255 'restricted_vip_levels' => (strpos($promotion->vip_levels_restricted, ',') !== false ? explode(',',$promotion->vip_levels_restricted) : $promotion->vip_levels_restricted),
2256 'restricted_users' => (strpos($promotion->restricted_users, ',') !== false ? explode(',',$promotion->restricted_users) : $promotion->restricted_users),
2257 'restricted_anames' => (strpos($promotion->restricted_anames, ',') !== false ? explode(',',$promotion->restricted_anames) : $promotion->restricted_anames),
2258 'restricted_countries' => json_decode($promotion->restricted_countries),
2259 'restricted_acc_types' => (strpos($promotion->acc_types_restricted, ',') !== false ? explode(',',$promotion->acc_types_restricted) : $promotion->acc_types_restricted),
2260 'restricted_flags' => (strpos($promotion->flags_restricted, ',') !== false ? explode(',',$promotion->flags_restricted) : $promotion->flags_restricted),
2261 'restricted_vip_managers' => (strpos($promotion->vip_managers_restricted, ',') !== false ? explode(',',strtolower($promotion->vip_managers_restricted)) : strtolower($promotion->vip_managers_restricted)),
2262 //'birthday' => $promotion->bday_users,
2263 'days_before_bday' => (strpos($promotion->days_before_bday,',') !== false ? explode(',',html_entity_decode($promotion->days_before_bday)) : html_entity_decode($promotion->days_before_bday)),
2264 'bb_rate' => (strpos($promotion->bb_rate,',') !== false ? explode(',',$promotion->bb_rate) : $promotion->bb_rate),
2265 'bonus_rate' => (strpos($promotion->bonus_rate,',') !== false ? explode(',',html_entity_decode($promotion->bonus_rate)) : html_entity_decode($promotion->bonus_rate)),
2266 'bonusbalance' => (strpos($promotion->bonusbalance,',') !== false ? explode(',',html_entity_decode($promotion->bonusbalance)) : html_entity_decode($promotion->bonusbalance)),
2267 'dep_count' => (strpos($promotion->dep_count,',') !== false ? explode(',',html_entity_decode($promotion->dep_count)) : html_entity_decode($promotion->dep_count)),
2268 'total_deposits' => (strpos($promotion->total_deposits,',') !== false ? explode(',',html_entity_decode($promotion->total_deposits)) : html_entity_decode($promotion->total_deposits)),
2269 'hold' => (strpos($promotion->hold,',') !== false ? explode(',',html_entity_decode($promotion->hold)) : html_entity_decode($promotion->hold)),
2270 'top_app_type' => (strpos($promotion->top_app_type,',') !== false ? explode(',',$promotion->top_app_type) : $promotion->top_app_type),
2271 'last_logout' => (strpos($promotion->last_logout,',') !== false ? explode(',',$promotion->last_logout) : $promotion->last_logout),
2272 'last_dep' => (strpos($promotion->last_dep,',') !== false ? explode(',',$promotion->last_dep) : $promotion->last_dep),
2273 'first_dep' => (strpos($promotion->first_dep,',') !== false ? explode(',',$promotion->first_dep) : $promotion->first_dep),
2274 'last_wd' => (strpos($promotion->last_wd,',') !== false ? explode(',',$promotion->last_wd) : $promotion->last_wd),
2275 'last_dec' => (strpos($promotion->last_dec,',') !== false ? explode(',',$promotion->last_dec) : $promotion->last_dec),
2276 'dep_avg' => (strpos($promotion->dep_avg,',') !== false ? explode(',',html_entity_decode($promotion->dep_avg)) : html_entity_decode($promotion->dep_avg)),
2277 'fairplayrate' => (strpos($promotion->fairplayrate,',') !== false ? explode(',',html_entity_decode($promotion->fairplayrate)) : html_entity_decode($promotion->fairplayrate)),
2278 //'days_after_signup' => $promotion->days_after_signup,
2279 'days_after_signup' => (strpos($promotion->days_after_signup,',') !== false ? explode(',',$promotion->days_after_signup) : $promotion->days_after_signup),
2280 'license' => $promotion->license,
2281 'extra_class' => $promotion->extra_class,
2282 'brands' => json_decode($promotion->brands),
2283 //'view_title' => '',
2284 //'what_to_do' => '',
2285 //'what_you_get' => '',
2286 //'token_terms' => '',
2287 /* 'token_rewards' => '', */
2288 //'token_restrictive_terms' => '',
2289 //'multi_bonus' => $promotion->multi_bonus,
2290 'likes' => $promotion->likes,
2291 'share' => $promotion->share,
2292 //'vip_only' => $promotion->vip_only,
2293 'all_time' => $promotion->all_time,
2294 'button_type' => $promotion->button_type,
2295 'button_action' => $promotion->button_action,
2296 'button_code' => $promotion->button_code,
2297 'custom_buttons' => json_decode($promotion->custom_buttons,true),
2298 'custom_classes' => json_decode($promotion->custom_classes,true),
2299 'custom_styles' => ($promotion->custom_styles != '' ? json_decode($promotion->custom_styles,true) : ''),
2300 'dep_count_logic' => ($promotion->dep_count_logic != ''? json_decode($promotion->dep_count_logic,true):''),
2301 'dep_count_logic_req' => ($promotion->dep_count_logic_req != ''? json_decode($promotion->dep_count_logic_req,true):''),
2302 'availability' => ($promotion->availability != '' ? json_decode($promotion->availability,true) : ''),
2303 'campaign_ids' => $promotion->campaign_ids,
2304 //'expiry_days' => $promotion->expiry_days,
2305 'tsfrom' => $promotion->tsfrom,
2306 'tsto' => $promotion->tsto,
2307 'sorting' => $promotion->sorting,
2308 //'desktop_game' => $promotion->desktop_game,
2309 //'mobile_game' => $promotion->mobile_game,
2310 'tournaments_redirection' => ($promotion->tournaments_redirection == 't' ? true: false),
2311 'ojo_level' => (strpos($promotion->ojo_level,',') !== false? explode(',',html_entity_decode($promotion->ojo_level)) : html_entity_decode($promotion->ojo_level)),
2312 'ojo_level_progress' => (strpos($promotion->ojo_level_progress,',') !== false? explode(',',html_entity_decode($promotion->ojo_level_progress)) : html_entity_decode($promotion->ojo_level_progress)),
2313 'ojo_level_date' => (strpos($promotion->ojo_level_date,',') !== false? explode(',',$promotion->ojo_level_date) : $promotion->ojo_level_date),
2314 'dep_count_req' => (strpos($promotion->dep_count_req,',') !== false? explode(',',html_entity_decode($promotion->dep_count_req)) : html_entity_decode($promotion->dep_count_req)),
2315 'betstodepositrate' => (strpos($promotion->betstodepositrate,',') !== false? explode(',',html_entity_decode($promotion->betstodepositrate)) : html_entity_decode($promotion->betstodepositrate)),
2316 'avgbet' => (strpos($promotion->avgbet,',') !== false? explode(',',html_entity_decode($promotion->avgbet)) : html_entity_decode($promotion->avgbet)),
2317 'avgbet_not' => (strpos($promotion->avgbet,'!')!==false?false:true),
2318 'duration' => $promotion->duration,
2319 'temp_users_visible' => ($promotion->temp_users_visible == 't'?true:false),
2320 'ending_stamp' => $promotion->ending_stamp
2321 );
2322 //$promotions[$promotion->id]['avgbet'] = (strpos($promotion->avgbet,',') !== false ? explode(',',html_entity_decode($promotion->avgbet)) : html_entity_decode($promotion->avgbet));
2323 if(is_array($promotions[$promotion->id]['avgbet'])){
2324 if($promotions[$promotion->id]['avgbet'][0] == '' && isset($promotions[$promotion->id]['avgbet'][2])){
2325 $promotions[$promotion->id]['avgbet'][0] = $promotions[$promotion->id]['avgbet'][1];
2326 $promotions[$promotion->id]['avgbet'][1] = $promotions[$promotion->id]['avgbet'][2];
2327 unset($promotions[$promotion->id]['avgbet'][2]);
2328 }
2329 $promotions[$promotion->id]['avgbet'][0] = str_replace('!','',$promotions[$promotion->id]['avgbet'][0]);
2330 }else{
2331 $promotions[$promotion->id]['avgbet'] = str_replace(array('!','='),'',$promotions[$promotion->id]['avgbet']);
2332 }
2333 if($promotions[$promotion->id]['availability']['offer_availability'] == 'token_availability')
2334 $promotions[$promotion->id]['availability']['offer_availability'] = 'token_availability_'.$promotion->id;
2335 $promotions[$promotion->id]['user_id'] = (is_array($promotions[$promotion->id]['user_id'])?array_combine($promotions[$promotion->id]['user_id'],$promotions[$promotion->id]['user_id']) : $promotions[$promotion->id]['user_id']);
2336 $promotions[$promotion->id]['user_groups'] = (is_array($promotions[$promotion->id]['user_groups'])?array_combine($promotions[$promotion->id]['user_groups'],$promotions[$promotion->id]['user_groups']) : $promotions[$promotion->id]['user_groups']);
2337 $promotions[$promotion->id]['aname'] = (is_array($promotions[$promotion->id]['aname']) ? array_combine($promotions[$promotion->id]['aname'],$promotions[$promotion->id]['aname']) : $promotions[$promotion->id]['aname']);
2338 $promotions[$promotion->id]['platforms_restricted'] = (is_array($promotions[$promotion->id]['platforms_restricted']) ? array_combine($promotions[$promotion->id]['platforms_restricted'],$promotions[$promotion->id]['platforms_restricted']) : $promotions[$promotion->id]['platforms_restricted']);
2339 $promotions[$promotion->id]['restricted_vip_levels'] = (is_array($promotions[$promotion->id]['restricted_vip_levels']) ? array_combine($promotions[$promotion->id]['restricted_vip_levels'],$promotions[$promotion->id]['restricted_vip_levels']) : $promotions[$promotion->id]['restricted_vip_levels']);
2340 $promotions[$promotion->id]['restricted_users'] = (is_array($promotions[$promotion->id]['restricted_users']) ? array_combine($promotions[$promotion->id]['restricted_users'],$promotions[$promotion->id]['restricted_users']) : $promotions[$promotion->id]['restricted_users']);
2341 $promotions[$promotion->id]['restricted_user_groups'] = (is_array($promotions[$promotion->id]['restricted_user_groups'])?array_combine($promotions[$promotion->id]['restricted_user_groups'],$promotions[$promotion->id]['restricted_user_groups']) : $promotions[$promotion->id]['restricted_user_groups']);
2342 $promotions[$promotion->id]['restricted_anames'] = (is_array($promotions[$promotion->id]['restricted_anames']) ? array_combine($promotions[$promotion->id]['restricted_anames'],$promotions[$promotion->id]['restricted_anames']) : $promotions[$promotion->id]['restricted_anames']);
2343 $promotions[$promotion->id]['restricted_countries'] = (is_array($promotions[$promotion->id]['restricted_countries']) ? array_combine($promotions[$promotion->id]['restricted_countries'],$promotions[$promotion->id]['restricted_countries']) : $promotions[$promotion->id]['restricted_countries']);
2344 $promotions[$promotion->id]['restricted_acc_types'] = (is_array($promotions[$promotion->id]['restricted_acc_types']) ? array_combine($promotions[$promotion->id]['restricted_acc_types'],$promotions[$promotion->id]['restricted_acc_types']) : $promotions[$promotion->id]['restricted_acc_types']);
2345 $promotions[$promotion->id]['restricted_flags'] = (is_array($promotions[$promotion->id]['restricted_flags']) ? array_combine($promotions[$promotion->id]['restricted_flags'],$promotions[$promotion->id]['restricted_flags']) : $promotions[$promotion->id]['restricted_flags']);
2346 $promotions[$promotion->id]['restricted_vip_managers'] = (is_array($promotions[$promotion->id]['restricted_vip_managers']) ? array_combine($promotions[$promotion->id]['restricted_vip_managers'],$promotions[$promotion->id]['restricted_vip_managers']) : $promotions[$promotion->id]['restricted_vip_managers']);
2347 $promotions[$promotion->id]['brands'] = (is_array($promotions[$promotion->id]['brands']) ? array_combine($promotions[$promotion->id]['brands'],$promotions[$promotion->id]['brands']) : $promotions[$promotion->id]['brands']);
2348 /* if(isset($_REQUEST['testnikos']))
2349 print_r($promotions[$promotion->id]['custom_buttons']); */
2350 /* foreach($promotions[$promotion->id]['custom_buttons'] as $k => $value){
2351 $promotions[$promotion->id]['custom_buttons'][$k]['converted'] = get_action($value,'action_btn',$k);
2352 $promo_custom_buttons['buttons'][] = '#' . $k . '#';
2353 $promo_custom_buttons['converted'][] = $promotions[$promotion->id]['custom_buttons'][$k]['converted'];
2354 } */
2355 while($promo_strings = pg_fetch_array($token_strings)){
2356 if($promo_strings['token'] == 'view_title_'.$token_after_fix){
2357 //$promotions[$promotion->id]['view_title'] = $promo_strings;
2358 $promo_translations[$promotion->id]['view_title'] = $promo_strings;
2359 # $promotions[$promotion->id]['view_title'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2360 # else if($promo_strings['token'] == 'what_to_do_'.$token_after_fix)
2361 # $promotions[$promotion->id]['what_to_do'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2362 }else if($promo_strings['token'] == 'what_you_get_'.$token_after_fix){
2363 //$promotions[$promotion->id]['what_you_get'] = $promo_strings;
2364 $promo_translations[$promotion->id]['what_you_get'] = $promo_strings;
2365 # $promotions[$promotion->id]['what_you_get'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2366 }else if($promo_strings['token'] == 'token_terms_'.$token_after_fix){
2367 //$promotions[$promotion->id]['token_terms'] = $promo_strings;
2368 $promo_translations[$promotion->id]['token_terms'] = $promo_strings;
2369 # $promotions[$promotion->id]['token_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2370 # else if($promo_strings['token'] == 'token_rewards_'.$token_after_fix)
2371 # $promotions[$promotion->id]['token_rewards'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2372 }else if($promo_strings['token'] == 'token_restrictive_terms_'.$token_after_fix){
2373 //$promotions[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2374 $promo_translations[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2375 # $promotions[$promotion->id]['token_restrictive_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));*/
2376 }else if($promo_strings['token'] == 'token_availability_'.$token_after_fix){
2377 //$promotions[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2378 $promo_translations[$promotion->id]['token_availability'] = $promo_strings;
2379 # $promotions[$promotion->id]['token_restrictive_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));*/
2380 }
2381 }
2382 if(is_array($promotions[$promotion->id]['brands']) && sizeof($promotions[$promotion->id]['brands']) > 0){
2383 foreach($promotions[$promotion->id]['brands'] as $current_brand => $brand_value){
2384 $promotions_days[$promotion->promo_day][$current_brand][$promotion->id] = $promotion->id;
2385 }
2386 foreach($promotions[$promotion->id]['brands'] as $current_brand => $brand_value){
2387 $promotions_per_brand[$current_brand][$promotion->id] = $promotions[$promotion->id];
2388 }
2389 }elseif($promotions[$promotion->id]['brands'] != ''){
2390 $promotions_per_brand[$promotions[$promotion->id]['brands']][$promotion->id] = $promotions[$promotion->id];
2391 $promotions_days[$promotion->promo_day][$promotions[$promotion->id]['brands']][$promotion->id] = $promotion->id;
2392 }
2393 }
2394 }
2395 }
2396
2397 if(!isset($_REQUEST['custom_date']) && !isset($_REQUEST['dev']) && $cache == true) {
2398 $redis->set('promotions_per_brand', serialize($promotions_per_brand), 3600); //cache for 1 hour
2399 $redis->set('promotions', serialize($promotions), 3600); //cache for 1 hour
2400 $redis->set('promotions_days', serialize($promotions_days), 3600); //cache for 1 hour
2401 $redis->set('cached_timestamp', date('Y-m-d H:i:s'), 3600); //cache for 1 hour
2402 $redis->set('promo_translations', serialize($promo_translations), 3600); //cache for 1 hour
2403 }
2404
2405 end_bench('get_promotions not cached');
2406 }
2407
2408 end_bench('get_promotions');
2409
2410 return array('promotions' => $promotions,'promotions_days' => $promotions_days,'promotions_per_brand' => $promotions_per_brand,'promo_translations' => $promo_translations);
2411}
2412
2413function get_promotions_filtered_per_brand($force = false) {
2414 global $kc_connection,$rc_connection,$globals,$cache;
2415 start_bench('get_promotions');
2416 $redis = connectRedis();
2417 # DELETE CACHE
2418 // $redis->delete('promotions_per_brand');
2419 // $redis->delete('promotions');
2420 // $redis->delete('promotions_days');
2421 // $redis->delete('cached_timestamp');
2422 $promotions = array();
2423 $promotions_days = array();
2424 $promotions_days['yesterday'] = array();
2425 $promotions_days['today'] = array();
2426 $promotions_days['tomorrow'] = array();
2427 $promotions_days['always'] = array();
2428 $promotions_per_brand = array();
2429 $promo_translations = array();
2430 $promo_ids = '';
2431 $where_specific = '';
2432 $appAbbrev = $globals['brand_data']['abbrev'];
2433 $filter_per_brand = "and '$appAbbrev'=ANY(replace(replace(daily_picks_promotions.brands,'[','{'),']','}')::text[]) ";
2434 if($redis->exists('promotions_per_brand'))
2435 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2436 $cached_day = date('Y-m-d');
2437 if($redis->exists('cached_timestamp')) {
2438 $cached_day = date('Y-m-d', strtotime($redis->get('cached_timestamp')));
2439 }
2440 if($redis->exists('promotions') && strtotime($cached_day) == strtotime(date('Y-m-d')) && $cache == true && $force == false) {
2441 start_bench('get_promotions cached');
2442 $promotions = unserialize($redis->get('promotions'));
2443 $promotions_days = unserialize($redis->get('promotions_days'));
2444 $promo_translations = unserialize($redis->get('promo_translations'));
2445 $promo_ids = implode(',',array_keys($promotions));
2446 if($redis->exists('promotions_per_brand')){
2447 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2448 //var_dump($promotions_per_brand);
2449 //die();
2450 }else{
2451 foreach($promotions as $promo => $value){
2452 if(is_array($promotions[$promo]['brands']) && sizeof($promotions[$promo]['brands']) > 0){
2453 foreach($promotions[$promo]['brands'] as $current_brand => $brand_value){
2454 $promotions_per_brand[$current_brand][$promo] = $value;
2455 }
2456 }elseif($promotions[$promo]['brands'] != ''){
2457 $promotions_per_brand[$promotions[$promo]['brands']][$promo] = $value;
2458 }
2459 }
2460 }
2461 end_bench('get_promotions cached');
2462 }else{
2463 start_bench('get_promotions not cached');
2464 //$shortcodes = get_shortcodes();
2465 if(isset($globals['custom_date'])){
2466 $yesterday_start = date('Y-m-d',strtotime($globals['custom_date'].' - 1 day')).' 00:00:00';
2467 $yesterday_end = date('Y-m-d',strtotime($globals['custom_date'].' - 1 day')).' 23:59:59';
2468 $today_start = date('Y-m-d',strtotime($globals['custom_date'])).' 00:00:00';
2469 $today_end = date('Y-m-d',strtotime($globals['custom_date'])).' 23:59:59';
2470 $tomorrow_start = date('Y-m-d',strtotime($globals['custom_date'].' + 1 day')).' 00:00:00';
2471 $tomorrow_end = date('Y-m-d',strtotime($globals['custom_date'].' + 1 day')).' 23:59:59';
2472 }else{
2473 $yesterday_start = date('Y-m-d',strtotime('- 1 day')).' 00:00:00';
2474 $yesterday_end = date('Y-m-d',strtotime('- 1 day')).' 23:59:59';
2475 $today_start = date('Y-m-d').' 00:00:00';
2476 $today_end = date('Y-m-d').' 23:59:59';
2477 $tomorrow_start = date('Y-m-d',strtotime('+ 1 day')).' 00:00:00';
2478 $tomorrow_end = date('Y-m-d',strtotime('+ 1 day')).' 23:59:59';
2479 }
2480 if($force == true && isset($_REQUEST['dev']) && isset($_REQUEST['promo']) && $_REQUEST['promo'] != ''){
2481 $where_specific = "and daily_picks_promotions.id='{$_REQUEST['promo']}'";
2482 $promotions = unserialize($redis->get('promotions'));
2483 $promotions_days = unserialize($redis->get('promotions_days'));
2484 $promo_translations = unserialize($redis->get('promo_translations'));
2485 $promo_ids = implode(',',array_keys($promotions));
2486 if($redis->exists('promotions_per_brand')){
2487 $promotions_per_brand = unserialize($redis->get('promotions_per_brand'));
2488 //var_dump($promotions_per_brand);
2489 //die();
2490 }else{
2491 foreach($promotions as $promo => $value){
2492 if(is_array($promotions[$promo]['brands']) && sizeof($promotions[$promo]['brands']) > 0){
2493 foreach($promotions[$promo]['brands'] as $current_brand => $brand_value){
2494 $promotions_per_brand[$current_brand][$promo] = $value;
2495 }
2496 }elseif($promotions[$promo]['brands'] != ''){
2497 $promotions_per_brand[$promotions[$promo]['brands']][$promo] = $value;
2498 }
2499 }
2500 }
2501 }
2502 $query_promotions = pg_query($kc_connection,"select
2503 daily_picks_promotions.*,
2504 daily_picks_schedule.ending_stamp,
2505 case
2506 when daily_picks_schedule.id IS NULL then 0
2507 else daily_picks_schedule.id
2508 end as schedule_id,
2509 case
2510 when daily_picks_promotions.all_time=1 then '$today_start'
2511 else daily_picks_schedule.tsfrom
2512 end as promo_schedule_date,
2513 case
2514 when daily_picks_promotions.bday_users='t' then '$today_start'
2515 else daily_picks_schedule.tsfrom
2516 end as tsfrom,
2517 case
2518 when daily_picks_promotions.bday_users='t' then '$today_end'
2519 else daily_picks_schedule.tsto
2520 end as tsto,
2521 case
2522 when daily_picks_promotions.bday_users='t' then 0
2523 else daily_picks_promotions.sorting
2524 end as generic_sorting,
2525 case
2526 when daily_picks_schedule.sorting IS NULL then 0
2527 else daily_picks_schedule.sorting
2528 end as calendar_sorting,
2529 case
2530 when daily_picks_promotions.all_time=1 and bday_users='t' then 'today'
2531 when '$yesterday_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'yesterday'
2532 when '$today_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'today'
2533 when '$tomorrow_start' between daily_picks_schedule.tsfrom and daily_picks_schedule.tsto then 'tomorrow'
2534 else 'always'
2535 end as promo_day
2536 from
2537 daily_picks_promotions left outer join daily_picks_schedule on daily_picks_promotions.id=daily_picks_schedule.promotion_id
2538 where
2539 daily_picks_promotions.active='t'
2540 and
2541 daily_picks_promotions.enabled=1
2542 and (
2543 (daily_picks_schedule.tsfrom>='$yesterday_start' and daily_picks_schedule.tsfrom<='$tomorrow_end' and daily_picks_schedule.tsto>='$yesterday_start' and daily_picks_schedule.tsto<='$tomorrow_end')
2544 or daily_picks_promotions.all_time=1
2545 )
2546 $filter_per_brand
2547 $where_specific
2548 order by
2549 tsto asc,
2550 calendar_sorting desc,
2551 generic_sorting desc"
2552 );
2553 //and (daily_picks_promotions.all_time=1 and daily_picks_schedule between '$today_start' and '$today_end')
2554 if(pg_num_rows($query_promotions) > 0){
2555 while($promotion = pg_fetch_object($query_promotions)){
2556 $promo_ids .= ($promo_ids == '' ? $promotion->id : ','.$promotion->id);
2557 /*$view_title = json_decode(str_replace("\\\\",'\\',$promotion->view_title));
2558 $description = json_decode(str_replace("\\\\",'\\',$promotion->description));
2559 $more = json_decode(str_replace("\\\\",'\\',$promotion->more));
2560 $tac = json_decode(str_replace("\\\\",'\\',$promotion->tac));
2561 $rewards = json_decode(str_replace("\\\\",'\\',$promotion->rewards));*/
2562 $promotions_days[$promotion->promo_day][$promotion->id] = $promotion->id;
2563 $token_after_fix = $promotion->id;
2564 /* $token_strings = pg_query($kc_connection,"select
2565 string_translations.*
2566 from
2567 string_translations
2568 where
2569 token
2570 in('view_title_$token_after_fix','what_to_do_$token_after_fix','what_you_get_$token_after_fix','token_terms_$token_after_fix','token_rewards_$token_after_fix')
2571 and
2572 category='promotions'"
2573 ); */
2574 if($promotion->promo_day == 'today' || !isset($promotions[$promotion->id])){
2575 $token_strings = pg_query($kc_connection,"select
2576 string_translations.*
2577 from
2578 string_translations
2579 where
2580 token
2581 in('view_title_$token_after_fix','what_you_get_$token_after_fix','token_terms_$token_after_fix','token_restrictive_terms_$token_after_fix','token_availability_$token_after_fix')
2582 and
2583 category='promotions'"
2584 );
2585 $promotions[$promotion->id] = array(
2586 'promo_id' => $promotion->id,
2587 'schedule_id' => $promotion->schedule_id,
2588 'promo_schedule_date' => strtotime($promotion->promo_schedule_date),
2589 'title' => $promotion->title,
2590 'code' => $promotion->code,
2591 'user_id' => (strpos($promotion->user_id, ',') !== false ? explode(',',$promotion->user_id) : $promotion->user_id),
2592 'user_groups' => (strpos($promotion->user_groups, ',') !== false ? explode(',',$promotion->user_groups) : $promotion->user_groups),
2593 'restricted_user_groups' => (strpos($promotion->restricted_user_groups, ',') !== false ? explode(',',$promotion->restricted_user_groups) : $promotion->restricted_user_groups),
2594 'aname' => (strpos($promotion->aname, ',') !== false ? explode(',',$promotion->aname) : $promotion->aname),
2595 'platforms_restricted' => (strpos($promotion->platforms_restricted, ',') !== false ? explode(',',$promotion->platforms_restricted) : $promotion->platforms_restricted),
2596 'restricted_vip_levels' => (strpos($promotion->vip_levels_restricted, ',') !== false ? explode(',',$promotion->vip_levels_restricted) : $promotion->vip_levels_restricted),
2597 'restricted_users' => (strpos($promotion->restricted_users, ',') !== false ? explode(',',$promotion->restricted_users) : $promotion->restricted_users),
2598 'restricted_anames' => (strpos($promotion->restricted_anames, ',') !== false ? explode(',',$promotion->restricted_anames) : $promotion->restricted_anames),
2599 'restricted_countries' => json_decode($promotion->restricted_countries),
2600 'restricted_acc_types' => (strpos($promotion->acc_types_restricted, ',') !== false ? explode(',',html_entity_decode($promotion->acc_types_restricted)) : html_entity_decode($promotion->acc_types_restricted)),
2601 'restricted_flags' => (strpos($promotion->flags_restricted, ',') !== false ? explode(',',$promotion->flags_restricted) : $promotion->flags_restricted),
2602 'restricted_vip_managers' => (strpos($promotion->vip_managers_restricted, ',') !== false ? explode(',',strtolower($promotion->vip_managers_restricted)) : strtolower($promotion->vip_managers_restricted)),
2603 //'birthday' => $promotion->bday_users,
2604 'days_before_bday' => (strpos($promotion->days_before_bday,',') !== false ? explode(',',html_entity_decode($promotion->days_before_bday)) : html_entity_decode($promotion->days_before_bday)),
2605 'bb_rate' => (strpos($promotion->bb_rate,',') !== false ? explode(',',$promotion->bb_rate) : $promotion->bb_rate),
2606 'bonus_rate' => (strpos($promotion->bonus_rate,',') !== false ? explode(',',html_entity_decode($promotion->bonus_rate)) : html_entity_decode($promotion->bonus_rate)),
2607 'bonusbalance' => (strpos($promotion->bonusbalance,',') !== false ? explode(',',html_entity_decode($promotion->bonusbalance)) : html_entity_decode($promotion->bonusbalance)),
2608 'dep_count' => (strpos($promotion->dep_count,',') !== false ? explode(',',html_entity_decode($promotion->dep_count)) : html_entity_decode($promotion->dep_count)),
2609 'total_deposits' => (strpos($promotion->total_deposits,',') !== false ? explode(',',html_entity_decode($promotion->total_deposits)) : html_entity_decode($promotion->total_deposits)),
2610 'hold' => (strpos($promotion->hold,',') !== false ? explode(',',html_entity_decode($promotion->hold)) : html_entity_decode($promotion->hold)),
2611 'top_app_type' => (strpos($promotion->top_app_type,',') !== false ? explode(',',$promotion->top_app_type) : $promotion->top_app_type),
2612 'last_logout' => (strpos($promotion->last_logout,',') !== false ? explode(',',$promotion->last_logout) : $promotion->last_logout),
2613 'last_dep' => (strpos($promotion->last_dep,',') !== false ? explode(',',$promotion->last_dep) : $promotion->last_dep),
2614 'first_dep' => (strpos($promotion->first_dep,',') !== false ? explode(',',$promotion->first_dep) : $promotion->first_dep),
2615 'last_wd' => (strpos($promotion->last_wd,',') !== false ? explode(',',$promotion->last_wd) : $promotion->last_wd),
2616 'last_dec' => (strpos($promotion->last_dec,',') !== false ? explode(',',$promotion->last_dec) : $promotion->last_dec),
2617 'dep_avg' => (strpos($promotion->dep_avg,',') !== false ? explode(',',html_entity_decode($promotion->dep_avg)) : html_entity_decode($promotion->dep_avg)),
2618 'fairplayrate' => (strpos($promotion->fairplayrate,',') !== false ? explode(',',html_entity_decode($promotion->fairplayrate)) : html_entity_decode($promotion->fairplayrate)),
2619 //'days_after_signup' => $promotion->days_after_signup,
2620 'days_after_signup' => (strpos($promotion->days_after_signup,',') !== false ? explode(',',$promotion->days_after_signup) : $promotion->days_after_signup),
2621 'license' => $promotion->license,
2622 'extra_class' => $promotion->extra_class,
2623 'brands' => json_decode($promotion->brands),
2624 //'view_title' => '',
2625 //'what_to_do' => '',
2626 //'what_you_get' => '',
2627 //'token_terms' => '',
2628 /* 'token_rewards' => '', */
2629 //'token_restrictive_terms' => '',
2630 //'multi_bonus' => $promotion->multi_bonus,
2631 'likes' => $promotion->likes,
2632 'share' => $promotion->share,
2633 //'vip_only' => $promotion->vip_only,
2634 'all_time' => $promotion->all_time,
2635 'button_type' => $promotion->button_type,
2636 'button_action' => $promotion->button_action,
2637 'button_code' => $promotion->button_code,
2638 'custom_buttons' => json_decode($promotion->custom_buttons,true),
2639 'custom_classes' => json_decode($promotion->custom_classes,true),
2640 'custom_styles' => ($promotion->custom_styles != '' ? json_decode($promotion->custom_styles,true) : ''),
2641 'dep_count_logic' => ($promotion->dep_count_logic != ''? json_decode($promotion->dep_count_logic,true):''),
2642 'dep_count_logic_req' => ($promotion->dep_count_logic_req != ''? json_decode($promotion->dep_count_logic_req,true):''),
2643 'availability' => ($promotion->availability != '' ? json_decode($promotion->availability,true) : ''),
2644 'campaign_ids' => $promotion->campaign_ids,
2645 //'expiry_days' => $promotion->expiry_days,
2646 'tsfrom' => $promotion->tsfrom,
2647 'tsto' => $promotion->tsto,
2648 'sorting' => $promotion->sorting,
2649 //'desktop_game' => $promotion->desktop_game,
2650 //'mobile_game' => $promotion->mobile_game,
2651 'tournaments_redirection' => ($promotion->tournaments_redirection == 't' ? true: false),
2652 'ojo_level' => (strpos($promotion->ojo_level,',') !== false? explode(',',html_entity_decode($promotion->ojo_level)) : html_entity_decode($promotion->ojo_level)),
2653 'ojo_level_progress' => (strpos($promotion->ojo_level_progress,',') !== false? explode(',',html_entity_decode($promotion->ojo_level_progress)) : html_entity_decode($promotion->ojo_level_progress)),
2654 'ojo_level_date' => (strpos($promotion->ojo_level_date,',') !== false? explode(',',$promotion->ojo_level_date) : $promotion->ojo_level_date),
2655 'dep_count_req' => (strpos($promotion->dep_count_req,',') !== false? explode(',',html_entity_decode($promotion->dep_count_req)) : html_entity_decode($promotion->dep_count_req)),
2656 'betstodepositrate' => (strpos($promotion->betstodepositrate,',') !== false? explode(',',html_entity_decode($promotion->betstodepositrate)) : html_entity_decode($promotion->betstodepositrate)),
2657 'avgbet' => (strpos($promotion->avgbet,',') !== false? explode(',',html_entity_decode($promotion->avgbet)) : html_entity_decode($promotion->avgbet)),
2658 'avgbet_not' => (strpos($promotion->avgbet,'!')!==false?false:true),
2659 'duration' => $promotion->duration,
2660 'temp_users_visible' => ($promotion->temp_users_visible == 't'?true:false),
2661 'ending_stamp' => $promotion->ending_stamp
2662 );
2663 //$promotions[$promotion->id]['avgbet'] = (strpos($promotion->avgbet,',') !== false ? explode(',',html_entity_decode($promotion->avgbet)) : html_entity_decode($promotion->avgbet));
2664 if(is_array($promotions[$promotion->id]['avgbet'])){
2665 if($promotions[$promotion->id]['avgbet'][0] == '' && isset($promotions[$promotion->id]['avgbet'][2])){
2666 $promotions[$promotion->id]['avgbet'][0] = $promotions[$promotion->id]['avgbet'][1];
2667 $promotions[$promotion->id]['avgbet'][1] = $promotions[$promotion->id]['avgbet'][2];
2668 unset($promotions[$promotion->id]['avgbet'][2]);
2669 }
2670 $promotions[$promotion->id]['avgbet'][0] = str_replace('!','',$promotions[$promotion->id]['avgbet'][0]);
2671 }else{
2672 $promotions[$promotion->id]['avgbet'] = str_replace(array('!','='),'',$promotions[$promotion->id]['avgbet']);
2673 }
2674 if($promotions[$promotion->id]['availability']['offer_availability'] == 'token_availability')
2675 $promotions[$promotion->id]['availability']['offer_availability'] = 'token_availability_'.$promotion->id;
2676 $promotions[$promotion->id]['user_id'] = (is_array($promotions[$promotion->id]['user_id'])?array_combine($promotions[$promotion->id]['user_id'],$promotions[$promotion->id]['user_id']) : $promotions[$promotion->id]['user_id']);
2677 $promotions[$promotion->id]['user_groups'] = (is_array($promotions[$promotion->id]['user_groups'])?array_combine($promotions[$promotion->id]['user_groups'],$promotions[$promotion->id]['user_groups']) : $promotions[$promotion->id]['user_groups']);
2678 $promotions[$promotion->id]['aname'] = (is_array($promotions[$promotion->id]['aname']) ? array_combine($promotions[$promotion->id]['aname'],$promotions[$promotion->id]['aname']) : $promotions[$promotion->id]['aname']);
2679 $promotions[$promotion->id]['platforms_restricted'] = (is_array($promotions[$promotion->id]['platforms_restricted']) ? array_combine($promotions[$promotion->id]['platforms_restricted'],$promotions[$promotion->id]['platforms_restricted']) : $promotions[$promotion->id]['platforms_restricted']);
2680 $promotions[$promotion->id]['restricted_vip_levels'] = (is_array($promotions[$promotion->id]['restricted_vip_levels']) ? array_combine($promotions[$promotion->id]['restricted_vip_levels'],$promotions[$promotion->id]['restricted_vip_levels']) : $promotions[$promotion->id]['restricted_vip_levels']);
2681 $promotions[$promotion->id]['restricted_users'] = (is_array($promotions[$promotion->id]['restricted_users']) ? array_combine($promotions[$promotion->id]['restricted_users'],$promotions[$promotion->id]['restricted_users']) : $promotions[$promotion->id]['restricted_users']);
2682 $promotions[$promotion->id]['restricted_user_groups'] = (is_array($promotions[$promotion->id]['restricted_user_groups'])?array_combine($promotions[$promotion->id]['restricted_user_groups'],$promotions[$promotion->id]['restricted_user_groups']) : $promotions[$promotion->id]['restricted_user_groups']);
2683 $promotions[$promotion->id]['restricted_anames'] = (is_array($promotions[$promotion->id]['restricted_anames']) ? array_combine($promotions[$promotion->id]['restricted_anames'],$promotions[$promotion->id]['restricted_anames']) : $promotions[$promotion->id]['restricted_anames']);
2684 $promotions[$promotion->id]['restricted_countries'] = (is_array($promotions[$promotion->id]['restricted_countries']) ? array_combine($promotions[$promotion->id]['restricted_countries'],$promotions[$promotion->id]['restricted_countries']) : $promotions[$promotion->id]['restricted_countries']);
2685 $promotions[$promotion->id]['restricted_acc_types'] = (is_array($promotions[$promotion->id]['restricted_acc_types']) ? array_combine($promotions[$promotion->id]['restricted_acc_types'],$promotions[$promotion->id]['restricted_acc_types']) : $promotions[$promotion->id]['restricted_acc_types']);
2686 $promotions[$promotion->id]['restricted_flags'] = (is_array($promotions[$promotion->id]['restricted_flags']) ? array_combine($promotions[$promotion->id]['restricted_flags'],$promotions[$promotion->id]['restricted_flags']) : $promotions[$promotion->id]['restricted_flags']);
2687 $promotions[$promotion->id]['restricted_vip_managers'] = (is_array($promotions[$promotion->id]['restricted_vip_managers']) ? array_combine($promotions[$promotion->id]['restricted_vip_managers'],$promotions[$promotion->id]['restricted_vip_managers']) : $promotions[$promotion->id]['restricted_vip_managers']);
2688 $promotions[$promotion->id]['brands'] = (is_array($promotions[$promotion->id]['brands']) ? array_combine($promotions[$promotion->id]['brands'],$promotions[$promotion->id]['brands']) : $promotions[$promotion->id]['brands']);
2689 /* if(isset($_REQUEST['testnikos']))
2690 print_r($promotions[$promotion->id]['custom_buttons']); */
2691 /* foreach($promotions[$promotion->id]['custom_buttons'] as $k => $value){
2692 $promotions[$promotion->id]['custom_buttons'][$k]['converted'] = get_action($value,'action_btn',$k);
2693 $promo_custom_buttons['buttons'][] = '#' . $k . '#';
2694 $promo_custom_buttons['converted'][] = $promotions[$promotion->id]['custom_buttons'][$k]['converted'];
2695 } */
2696 while($promo_strings = pg_fetch_array($token_strings)){
2697 if($promo_strings['token'] == 'view_title_'.$token_after_fix){
2698 //$promotions[$promotion->id]['view_title'] = $promo_strings;
2699 $promo_translations[$promotion->id]['view_title'] = $promo_strings;
2700 # $promotions[$promotion->id]['view_title'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2701 # else if($promo_strings['token'] == 'what_to_do_'.$token_after_fix)
2702 # $promotions[$promotion->id]['what_to_do'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2703 }else if($promo_strings['token'] == 'what_you_get_'.$token_after_fix){
2704 //$promotions[$promotion->id]['what_you_get'] = $promo_strings;
2705 $promo_translations[$promotion->id]['what_you_get'] = $promo_strings;
2706 # $promotions[$promotion->id]['what_you_get'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2707 }else if($promo_strings['token'] == 'token_terms_'.$token_after_fix){
2708 //$promotions[$promotion->id]['token_terms'] = $promo_strings;
2709 $promo_translations[$promotion->id]['token_terms'] = $promo_strings;
2710 # $promotions[$promotion->id]['token_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2711 # else if($promo_strings['token'] == 'token_rewards_'.$token_after_fix)
2712 # $promotions[$promotion->id]['token_rewards'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));
2713 }else if($promo_strings['token'] == 'token_restrictive_terms_'.$token_after_fix){
2714 //$promotions[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2715 $promo_translations[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2716 # $promotions[$promotion->id]['token_restrictive_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));*/
2717 }else if($promo_strings['token'] == 'token_availability_'.$token_after_fix){
2718 //$promotions[$promotion->id]['token_restrictive_terms'] = $promo_strings;
2719 $promo_translations[$promotion->id]['token_availability'] = $promo_strings;
2720 # $promotions[$promotion->id]['token_restrictive_terms'] = convert_codes(str_replace($shortcodes['codes'],$shortcodes['content'],$promo_strings));*/
2721 }
2722 }
2723 if(is_array($promotions[$promotion->id]['brands']) && sizeof($promotions[$promotion->id]['brands']) > 0){
2724 foreach($promotions[$promotion->id]['brands'] as $current_brand => $brand_value){
2725 $promotions_days[$promotion->promo_day][$current_brand][$promotion->id] = $promotion->id;
2726 }
2727 foreach($promotions[$promotion->id]['brands'] as $current_brand => $brand_value){
2728 $promotions_per_brand[$current_brand][$promotion->id] = $promotions[$promotion->id];
2729 }
2730 }elseif($promotions[$promotion->id]['brands'] != ''){
2731 $promotions_per_brand[$promotions[$promotion->id]['brands']][$promotion->id] = $promotions[$promotion->id];
2732 $promotions_days[$promotion->promo_day][$promotions[$promotion->id]['brands']][$promotion->id] = $promotion->id;
2733 }
2734 }
2735 }
2736 }
2737 if(!isset($_REQUEST['custom_date']) && !isset($_REQUEST['dev']) && $cache == true) {
2738 $redis->set('promotions_per_brand', serialize($promotions_per_brand), 3600); //cache for 1 hour
2739 $redis->set('promotions', serialize($promotions), 3600); //cache for 1 hour
2740 $redis->set('promotions_days', serialize($promotions_days), 3600); //cache for 1 hour
2741 $redis->set('cached_timestamp', date('Y-m-d H:i:s'), 3600); //cache for 1 hour
2742 $redis->set('promo_translations', serialize($promo_translations), 3600); //cache for 1 hour
2743 }
2744 end_bench('get_promotions not cached');
2745 }
2746 end_bench('get_promotions');
2747 return array('promotions' => $promotions,'promotions_days' => $promotions_days,'promotions_per_brand' => $promotions_per_brand,'promo_translations' => $promo_translations);
2748}
2749
2750function promotions_per_brand() {
2751 global $globals,$cache;
2752
2753 start_bench('promotions_per_brand');
2754 $redis = connectRedis();
2755 $promotions_per_brand = array();
2756 if($redis->exists('promotions_'.$globals['brand_data']['abbrev'])) {
2757 $promotions= unserialize($redis->get('promotions_'.$globals['brand_data']['abbrev']));
2758 }else{
2759 $promotions = get_promotions();
2760 foreach($promotions['promotions'] as $promotion_id => $value){
2761 foreach($value['brands'] as $promo_brand => $brand_values){
2762 $promotions_per_brand['promotions_'.$promo_brand][$promotion_id] = $brand_values;
2763 }
2764 }
2765 if(!empty($promotions_per_brand)){
2766 foreach($promotions_per_brand as $promotion_per_brand => $promos){
2767 if($cache == true && $redis->exists($promotion_per_brand)){
2768 $redis->delete($promotion_per_brand);
2769 $redis->set($promotion_per_brand, serialize($promos), 1800); // CACHE FOR 30 minutes
2770 }else if($cache == true){
2771 $redis->set($promotion_per_brand, serialize($promos), 1800); // CACHE FOR 30 minutes
2772 }
2773 }
2774 }
2775 }
2776 //var_dump($promotions_per_brand);
2777 //die();
2778
2779 end_bench('promotions_per_brand');
2780
2781 return array('promotions' => $promotions_per_brand['promotions_'.$globals['brand_data']['abbrev']],'promotions_days' => $promotions['promotions_days']);
2782}
2783
2784/*require '/project_new/vendor/autoload.php';*/
2785
2786
2787function fetch_user_groups($return = false,$force_refetch = false){
2788 global $globals,$kc_connection,$cache;
2789
2790 start_bench('fetch_user_groups');
2791
2792 $redis = connectRedis();
2793
2794 # DELETE CACHE
2795 // $redis->delete('user_groups');
2796
2797 $user_groups = array();
2798 /* if($redis->exists('user_groups') && !$force_refetch) {
2799 start_bench('fetch_user_groups cached');
2800
2801 $user_groups = unserialize($redis->get('user_groups'));
2802
2803 end_bench('fetch_user_groups cached');
2804 } else {
2805 start_bench('fetch_user_groups not cached');
2806
2807 $query = pg_query($kc_connection,"select * from players_groups where title!='' order by title asc");
2808 if(pg_num_rows($query) > 0){
2809 while($row = pg_fetch_object($query)){
2810 $user_groups[$row->title][$row->user_id] = $row->user_id;
2811 $user_groups['per_user_id'][$row->user_id][$row->title] = $row->title;
2812 }
2813 if($cache == true)
2814 $redis->set('user_groups', serialize($user_groups), 86400); // CACHE FOR 24 HOURS
2815 }
2816
2817 end_bench('fetch_user_groups not cached');
2818 } */
2819
2820 end_bench('fetch_user_groups');
2821
2822 if($return)
2823 return $user_groups;
2824}
2825
2826function get_stats(){
2827 global $rc_connection,$cache;
2828 $stats = array();
2829 $redis = connectRedis();
2830 if($redis->exists('stats') && !$force){
2831 $stats = unserialize($redis->get('stats'));
2832 }
2833 else{
2834 $promotions = get_promotions();
2835 $promo_ids = implode(',',array_keys($promotions['promotions']));
2836 $query_stats = pg_query($rc_connection,"select
2837 distinct promo_id,
2838 COALESCE(sum(CASE WHEN rate IS NOT NULL THEN rate ELSE 0 END), 0) as rate_sum,
2839 (select round((sum(rate)::float/count(*)::float)::numeric,1) from d_client_promotions_stats as calc_rate where calc_rate.promo_id=stats.promo_id and rate IS NOT NULL) as rate,
2840 (select count(*) from d_client_promotions_stats as used_promo where used_promo.promo_id=stats.promo_id and used_promo.used='t') as used,
2841 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.used='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_used,
2842 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users_rated where users_rated.rate IS NOT NULL and users_rated.promo_id=stats.promo_id and users_rated.schedule_id=0),',') as users_rated
2843 from
2844 d_client_promotions_stats as stats
2845 where
2846 promo_id in({$promo_ids})
2847 GROUP BY promo_id");
2848
2849 /* $query_stats = pg_query($rc_connection,"select
2850 distinct promo_id,
2851 (select count(*) from d_client_promotions_stats as rt where rt.promo_id = stats.promo_id) as rated,
2852 (select sum(rate) from d_client_promotions_stats as rate_sum where rate_sum.promo_id=stats.promo_id and rate IS NOT NULL) as rate_sum,
2853 (select round((sum(rate)::float/count(*)::float)::numeric,1) from d_client_promotions_stats as calc_rate where calc_rate.promo_id=stats.promo_id and rate IS NOT NULL) as rate,
2854 (select count(*) from d_client_promotions_stats as likes where likes.promo_id=stats.promo_id and likes.liked='t') as liked,
2855 (select count(*) from d_client_promotions_stats as shares where shares.promo_id=stats.promo_id and shares.shared='t') as shared,
2856 (select count(*) from d_client_promotions_stats as used_promo where used_promo.promo_id=stats.promo_id and used_promo.used='t') as used,
2857 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.used='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_used,
2858 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.liked='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_liked,
2859 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users_rated where users_rated.rate IS NOT NULL and users_rated.promo_id=stats.promo_id and users_rated.schedule_id=0),',') as users_rated
2860 from
2861 d_client_promotions_stats as stats
2862 where
2863 promo_id in({$promo_ids})"); */
2864 if(pg_num_rows($query_stats) > 0){
2865 while($promo_stats = pg_fetch_object($query_stats)){
2866 $stats[$promo_stats->promo_id] = array(
2867 'promo_id' => $promo_stats->promo_id,
2868 //'rated' => $promo_stats->rated,
2869 'rate_sum' => $promo_stats->rate_sum,
2870 'rate' => ($promo_stats->rate == '' ? 4.7 : $promo_stats->rate),
2871 //'liked' => $promo_stats->liked,
2872 //'shared' => $promo_stats->shared,
2873 //'users_liked' => explode(',',$promo_stats->users_liked),
2874 'users_rated' => explode(',',$promo_stats->users_rated),
2875 'used' => $promo_stats->used
2876 );
2877 }
2878 }
2879 if($cache == true)
2880 $redis->set('stats', serialize($stats), 3600); // cache for 24 hours
2881 }
2882 return $stats;
2883}
2884
2885function get_languages_url($website_id) {
2886 global $kc_connection,$globals,$cache;
2887 $set_xcache = false;
2888 $languageArray = array();
2889 $redis = connectRedis();
2890 if($redis->exists($globals['app_name'].'_langs') && !$force){
2891 $website_langs= unserialize($redis->get($globals['app_name'].'_langs'));
2892 if(isset($website_langs[$globals['lang']]))
2893 $languageArray = $website_langs;
2894 else{
2895 $set_xcache = true;
2896 }
2897 }
2898 elseif(isset($globals['brand_data']['website_langs'])){
2899 $website_langs = $globals['brand_data']['website_langs'];
2900 if(is_string($website_langs)) {
2901 $websiteDomain = $globals['brand_data']['website_domain'];
2902 $website_license = end(explode('.',$websiteDomain));
2903 $website_license_text = $globals['brand_data']['website_license'];
2904 $websiteDisplayName = $globals['brand_data']['website_display_name'];
2905 $resDomain = $globals['brand_data']['website_path'];
2906 $website_langsChunks = explode(';', $website_langs);
2907 sort($website_langsChunks);
2908 if(is_array($website_langsChunks)) {
2909 foreach($website_langsChunks as $lang_chunk) {
2910 $langsChunks = explode(':', $lang_chunk);
2911 $subdomain_chunks = explode(".", $langsChunks[1]);
2912 $languageArray[$langsChunks[0]] = array(
2913 'subdomain' => $langsChunks[1],
2914 'download_link' => $langsChunks[2],
2915 'subdomain_chunks' => $subdomain_chunks,
2916 'enabled' => ($langsChunks[3] == 1?TRUE:FALSE),
2917 'promotions_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '') . '/promotions-index.html',
2918 'language_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '')
2919 );
2920 }
2921 }
2922 }
2923 }
2924 else{
2925 $query = pg_query($kc_connection,"SELECT * FROM websites WHERE website_id={$website_id}");
2926 if(pg_num_rows($query) > 0) {
2927 $website = pg_fetch_object($query);
2928 $website_langs = $website->website_langs;
2929 $websiteDomain = $website->website_domain;
2930 $website_license = end(explode('.',$websiteDomain));
2931 $website_license_text = $website->website_license;
2932 $websiteDisplayName = $website->website_display_name;
2933 $resDomain = $website->website_path;
2934 $website_langsChunks = explode(';', $website_langs);
2935 sort($website_langsChunks);
2936 if(is_array($website_langsChunks)) {
2937 foreach($website_langsChunks as $lang_chunk) {
2938 $langsChunks = explode(':', $lang_chunk);
2939 $subdomain_chunks = explode(".", $langsChunks[1]);
2940 $languageArray[$langsChunks[0]] = array(
2941 'subdomain' => $langsChunks[1],
2942 'download_link' => $langsChunks[2],
2943 'subdomain_chunks' => $subdomain_chunks,
2944 'enabled' => ($langsChunks[3] == 1?TRUE:FALSE),
2945 'promotions_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '') . '/promotions-index.html',
2946 'language_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '')
2947 );
2948 }
2949 }
2950 }
2951 if($cache == true)
2952 $redis->set($globals['app_name'].'_langs', serialize($languageArray), 86400); // cache for 24 hours
2953 }
2954 return $languageArray;
2955}
2956
2957function fetch_brand($appName = '',$force = false){
2958 global $kc_connection,$globals,$cache;
2959 $redis = connectRedis();
2960 if($redis->exists('brands') && !$force){
2961 $brands= unserialize($redis->get('brands'));
2962 }
2963 else{
2964 $query = pg_query($kc_connection,"select
2965 brands.*,
2966 websites.website_id,
2967 websites.website_langs,
2968 websites.website_display_name,
2969 websites.website_path
2970 from
2971 brands left outer join websites on brands.domain=websites.website_domain
2972 where
2973 brands.license!='' and brands.app_name!=''
2974 order by
2975 brands.domain asc");
2976 if(pg_num_rows($query) > 0){
2977 $brands = array();
2978 while($website = pg_fetch_object($query)){
2979 $brands[$website->app_name] = array(
2980 'appName' => $website->app_name,
2981 'abbrev' => $website->abbrev,
2982 'domain' => $website->domain,
2983 'license' => $website->license,
2984 'token' => $website->token,
2985 'website_id' => $website->website_id,
2986 'website_langs' => $website->website_langs,
2987 'website_display_name' => $website->website_display_name,
2988 'website_path' => $website->website_path
2989 );
2990 $website_langs = $website->website_langs;
2991 $website_langsChunks = explode(';', $website_langs);
2992 sort($website_langsChunks);
2993 $languageArray = array();
2994 if(is_array($website_langsChunks)) {
2995 foreach($website_langsChunks as $lang_chunk) {
2996 $langsChunks = explode(':', $lang_chunk);
2997 $subdomain_chunks = explode(".", $langsChunks[1]);
2998 $languageArray[$langsChunks[0]] = array(
2999 'subdomain' => $langsChunks[1],
3000 'download_link' => $langsChunks[2],
3001 'subdomain_chunks' => $subdomain_chunks,
3002 'enabled' => ($langsChunks[3] == 1?TRUE:FALSE),
3003 'promotions_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '') . '/promotions-index.html',
3004 'language_url' => $subdomain_chunks[0].'.'.$subdomain_chunks[1].".".$subdomain_chunks[2].(isset($subdomain_chunks[3]) ? ".".$subdomain_chunks[3] : '')
3005 );
3006 }
3007 }
3008 $brands[$website->app_name]['website_langs'] = $languageArray;
3009 }
3010 $brands['TestCasino'] = $brands['EUcasino'];
3011 $brands['TestCasino']['abbrev'] = 'test';
3012 $brands['TestCasino']['AppName'] = 'TestCasino';
3013 if($cache == true)
3014 $redis->set('brands', serialize($brands), 86400); // cache for 24 hours
3015 }
3016 }
3017 if($appName == 'all')
3018 return true;
3019 elseif(isset($brands[$appName]))
3020 return $brands[$appName];
3021 else
3022 show_maintenance_window('skin_name: '.$appName.' not found!');
3023}
3024
3025function fetch_language($lang = 'en',$force = false){
3026 global $kc_connection,$cache;
3027 $langArray = array();
3028 $redis = connectRedis();
3029 if($redis->exists('langArray') && !$force){
3030 $langArray= unserialize($redis->get('langArray'));
3031 }
3032 else{
3033 $query = pg_query($kc_connection,"select * from languages");
3034 if(pg_num_rows($query) > 0){
3035 while($language = pg_fetch_object($query)){
3036 $langArray[$language->language_abbrev] = array(
3037 'abbrev' => $language->language_abbrev,
3038 'slug' => $language->language_slug
3039 );
3040 }
3041 $langArray['bu'] = array('abbrev' => 'bu',
3042 'slug' => 'bulgarian'
3043 );
3044 $langArray['da'] = array('abbrev' => 'da',
3045 'slug' => 'danish'
3046 );
3047 $langArray['gr'] = array('abbrev' => 'gr',
3048 'slug' => 'greek'
3049 );
3050 }
3051 if($cache == true)
3052 $redis->set('langArray', serialize($langArray), 86400); // cache for 24 hours
3053 }
3054 if(isset($langArray[$lang]))
3055 return $langArray[$lang];
3056 else
3057 return $langArray['en'];
3058}
3059
3060function fetch_translations($lang = 'en',$force = false){
3061 global $kc_connection,$cache,$globals;
3062
3063 $redis = connectRedis();
3064
3065 $shortcodes = get_shortcodes();
3066 $translations = array(
3067 'en' => array(
3068 'Your Daily Picks' => '',
3069 'Your Kickers' => '',
3070 'Your Previous Picks' => '',
3071 'Your Next Picks' => '',
3072 'Not available today' => '',
3073 'Cashier' => '',
3074 'Claim Now' => '',
3075 'Claim the Kicker' => '',
3076 'Play Now' => '',
3077 'DG_Play Now' => '',
3078 'Free Spins' => '',
3079 'Register Now' => '',
3080 'DG_Register Now' => '',
3081 'Deposit Now' => '',
3082 'Available for' => '',
3083 'Available in' => '',
3084 'What to do?' => '',
3085 //'What you get' => 'What you get',
3086 'Restrictive Terms' => '',
3087 'Terms' => '',
3088 'Starts in' => '',
3089 'Ends in' => '',
3090 'Staff Pick' => '',
3091 'Exclusive Promotion' => '',
3092 'Hot Promotion' => '',
3093 'Special Promotion' => '',
3094 'Winter Magic' => '',
3095 'Rate Now' => '',
3096 'Rated' => '',
3097 'Used' => '',
3098 'Likes' => '',
3099 'Share' => '',
3100 'Rewards' => '',
3101 'generic_daily_picks_terms' => '',
3102 'Confirmation' => '',
3103 'Congratulations' => '',
3104 'Promotion' => '',
3105 'You have claimed this offer successfully' => '',
3106 'ERROR' => '',
3107 'You already claimed this offer.' => '',
3108 'THANK YOU' => '',
3109 'An error occured while processing your request.' => '',
3110 'CLOSE' => '',
3111 'Submit' => '',
3112 'Rating' => '',
3113 'Not for me.' => '',
3114 'Maybe another time.' => '',
3115 'Its OK.' => '',
3116 'Liked it.' => '',
3117 'Loved it!' => '',
3118 'Remind Me' => '',
3119 'Unfortunately this promotion has expired.<br />After your daily picks reload, check what is available now.' => '',
3120 'Unfortunately this promotion has expired.<br />After your kickers reload, check what is available now.' => '',
3121 'DAILY PICKS' => '',
3122 'KICKERS' => '',
3123 'CLICK HERE' => '',
3124 'TOURNAMENTS' => '',
3125 'Tournaments' => '',
3126 'Go to Tournaments' => '',
3127 'REEL SPINOFFS' => '',
3128 'JOIN NOW' => '',
3129 'Details' => '',
3130 'Starts In' => '',
3131 'Ends In' => '',
3132 'Active Players' => '',
3133 'Your Daily Picks are currently not available.' => '',
3134 'Your Kickers are currently not available.' => '',
3135 'Currently Unavailable' => '',
3136 'Purchase your Spins Package either directly with your balance or with a deposit and then play your spins.' => '',
3137 'Purchase your Spins Package with your balance or by making a deposit.' => '',
3138 'Buy your Spin Packages' => '',
3139 'Details' => '',
3140 'Value per spin' => '',
3141 'Buy Spins' => '',
3142 'Buy with Deposit' => '',
3143 'Buy with balance' => '',
3144 'Buy with Balance' => '',
3145 'Enter an amount' => '',
3146 'Spins' => '',
3147 '+ Extra #5# Spins' => '',
3148 'Game:' => '',
3149 'Discount' => '',
3150 'Save' => '',
3151 'Amount missing or invalid' => '',
3152 'You have insufficient funds.' => '',
3153 'Please select a lower amount or deposit.' => '',
3154 'Return to Games to play your spins.' => '',
3155 'DG_Buy your Spin Packages' => '',
3156 'DG_+ Extra #5# Spins' => '',
3157 'DG_Buy with Balance' => '',
3158 'DG_Buy with Deposit' => '',
3159 'DG_Game:' => '',
3160 'DG_Value per spin:' => '',
3161 'DG_Purchase your Spins Package either directly with your balance or with a deposit and then play your spins.' => '',
3162 'DG_This offer is only valid if seen as an option for your daily picks.' => '',
3163 'DG_We reserve the right to cancel promotions or bonus offers, of any kind at any time, without prior notice. Any such cancellation will not affect an award already redeemed.' => '',
3164 'DG_Spins' => '',
3165 'Claim Ticket' => '',
3166 'Deposit and Claim Ticket' => '',
3167 'Once' => '',
3168 '*x per day' => '',
3169 'See Offer Below' => '',
3170 'Only for 1st Deposit' => '',
3171 'NOW' => '',
3172 'TODAY' => '',
3173 'Unlimited' => '',
3174 'Up to * times' => '',
3175 'Use Until:' => '',
3176 //'Availability:' => '',
3177 'Available:' => ''
3178 )
3179 );
3180
3181 if($redis->exists('translations') && $cache == true && !$force) {
3182 $translations = unserialize($redis->get('translations'));
3183 } else{
3184 $imploded = implode("','",array_keys($translations['en']));
3185 $query = pg_query($kc_connection,"select string_translations.* from string_translations where token in('$imploded')");
3186 if(pg_num_rows($query) > 0){
3187 while($string = pg_fetch_object($query)){
3188 foreach($string as $key => $value){
3189 if(preg_match('/token_/',$key)){
3190 $lang_code = str_replace('token_','',$key);
3191 $value = str_replace($shortcodes['codes'],$shortcodes['content'],$value);
3192 if(isset($translations[$lang_code]))
3193 $translations[$lang_code][$string->token] = ($value == '' ? html_entity_decode($string->token_en) : html_entity_decode($value));
3194 else
3195 $translations[$lang_code] = array($string->token => ($value == '' ? html_entity_decode($string->token_en) : html_entity_decode($value)));
3196 }
3197 }
3198 }
3199
3200 if($cache == true)
3201 $redis->set('translations', serialize($translations), 86400); // cache for 24 hours
3202 }
3203 }
3204
3205 if($lang == 'all' && $force)
3206 return true;
3207
3208 if(isset($translations[$lang])) {
3209 return $translations[$lang];
3210 }else{
3211 return $translations['en'];
3212 }
3213}
3214
3215function fetch_exchange_rates($force = false){
3216 global $rk_connection,$globals,$cache;
3217 $output = array();
3218 $date = date('Y-m-d');
3219 $redis = connectRedis();
3220 if($redis->exists('curr_exchange_rates') && !$force){
3221 $output= unserialize($redis->get('curr_exchange_rates'));
3222 }
3223 else{
3224 $query = pg_query($rk_connection,"select
3225 curr,
3226 rates
3227 from
3228 curr_exhange_rates
3229 where
3230 entry_date='$date'
3231 order by
3232 curr asc");
3233 if(pg_num_rows($query) > 0){
3234 while($rates = pg_fetch_object($query)){
3235 $output[$rates->curr] = $rates->rates;
3236 }
3237 if($cache == true)
3238 $redis->set('curr_exchange_rates', serialize($output), 21600); // cache for 6 hours
3239 }
3240 }
3241 return $output;
3242}
3243
3244function show_maintenance_window($reason,$maintenance_mode = false){
3245 global $globals,$logging,$maintenance_logging,$dd,$cache;
3246 if(isset($globals['bda']) || isset($globals['hwbda']))
3247 $message = $reason;
3248 else
3249 $message = 'Currently Unavailable';
3250 if(!isset($_REQUEST['dev'])){
3251 echo '<!DOCTYPE html>' .
3252 '<html dir="ltr" lang="en-US">' .
3253 '<head profile="http://gmpg.org/xfn/11">' .
3254 '<meta charset="utf-8">' .
3255 '<meta http-equiv="X-UA-Compatible" content="IE=edge">' .
3256 '<meta name="viewport" content="width=device-width, initial-scale=1">' .
3257 '<meta http-equiv="Content-Language" content="en" />' .
3258 '<title>Currently Unavailable</title>' .
3259 '<meta name="Description" content="description" />' .
3260 '<meta name="robots" content="index,follow">' .
3261 '<meta name="google" content="notranslate" />' .
3262 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" />' .
3263 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/star-rating.min.css" media="all" rel="stylesheet" type="text/css" />' .
3264 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/flipclock.css" media="all" rel="stylesheet" type="text/css" />' .
3265 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.css" media="all" rel="stylesheet" type="text/css" />' .
3266 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery-1.9.1.js"></script>' .
3267 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/bootstrap.min.js"></script>' .
3268 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery.mobile.custom.min.js"></script>' .
3269 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.js?'.time().'"></script>' .
3270 '<!--[if lt IE 9]>' .
3271 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/html5shiv.min.js"></script>' .
3272 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/respond.min.js"></script>' .
3273 '<![endif]-->' .
3274 //'<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />' .
3275 '</head>' .
3276 '<body class="maintenance' . ($dd->isMobile() ? ' mobile_device' : '') . '">' .
3277 '<div class="main_container center-block">' .
3278 '<div id="maintenance_mode">' .
3279 ($dd->isMobile() ? '<span class="home-link glyphicon glyphicon-home"></span>' : '<a class="close glyphicon glyphicon-share-alt glyphicon-home glyphicon-flipped" href="' . $globals['cashierUrl'] . '"></a>') .
3280 $message .
3281 '</div>' .
3282 '</div>' .
3283 '</body>' .
3284 '</html>';
3285 $fp = fopen("wrong_requests.txt",'a');
3286 if($fp){
3287 if($maintenance_mode){
3288 $fm = fopen("maintenance_requests.txt");
3289 fwrite($fm,date('Y-m-d H:i:s').' - '.$_SERVER['REMOTE_ADDR'].' : ' . $reason."\n");
3290 fclose($fm);
3291 }
3292 else{
3293 fwrite($fp,date('Y-m-d H:i:s').' - '.$_SERVER['REMOTE_ADDR'].' : ' . $reason . ' - ' . $_SERVER['REQUEST_URI'] . "\n");
3294 }
3295 }
3296 fclose($fp);
3297 die();
3298 }
3299}
3300
3301function show_preloader($cached_index){
3302 global $globals,$dd,$cache;
3303 echo '<!DOCTYPE html>' .
3304 '<html dir="ltr" lang="en-US">' .
3305 '<head profile="http://gmpg.org/xfn/11">' .
3306 '<meta charset="utf-8">' .
3307 '<meta http-equiv="X-UA-Compatible" content="IE=edge">' .
3308 '<meta name="viewport" content="width=device-width, initial-scale=1">' .
3309 '<meta http-equiv="Content-Language" content="en" />' .
3310 '<title>' . $globals['app_name'] . '</title>' .
3311 '<meta name="Description" content="description" />' .
3312 '<meta name="robots" content="index,follow">' .
3313 '<meta name="google" content="notranslate" />' .
3314 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" />' .
3315 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.css" media="all" rel="stylesheet" type="text/css" />' .
3316 '<link href="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/css/site_' . $globals['brand_data']['abbrev']. '.css?'.time().'" media="all" rel="stylesheet" type="text/css" />' .
3317 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery-1.9.1.js"></script>' .
3318 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/bootstrap.min.js"></script>' .
3319 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/jquery.mobile.custom.min.js"></script>' .
3320 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/site'.(str_replace(array('/','.php'),'',$_SERVER['SCRIPT_NAME'])=='api_dev'?'_dev':'').'.js?'.time().'"></script>' .
3321 '<!--[if lt IE 9]>' .
3322 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/html5shiv.min.js"></script>' .
3323 '<script src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/js/respond.min.js"></script>' .
3324 '<![endif]-->' .
3325 //'<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />' .
3326 '<script type="text/javascript">' .
3327 '$(document).ready(function(){' .
3328 "$('.loader').css('height',$(window).height()+'px');" .
3329 'window.location = "http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?q=' . $cached_index . '&pa=' . $_REQUEST['cashierUrl']. '";' .
3330 '});' .
3331 '</script>' .
3332 '<style type="text/css">' .
3333 '.loader {width:100%;background-image:url(/images/ajax-loader.gif);background-position:center center;background-repeat:no-repeat;}' .
3334 '</style>' .
3335 '</head>' .
3336 '<body class="preloader ' . $globals['brand_data']['abbrev'] . ($dd->isMobile() ? ' mobile_device' : '') . '">' .
3337 '<div class="loader"></div>' .
3338 '</body>' .
3339 '</html>';
3340}
3341
3342function convert_codes($data = false){
3343 global $lang,$globals,$currency_symbol,$cache;
3344 $codes = array(
3345 'amounts' => array(
3346 'expression' => "/#AMOUNT_([0-9,\.]+)#/",
3347 'code' => '#AMOUNT_value#',
3348 'end' => '#'
3349 )
3350 );
3351 if($data != false && $data != ''){
3352 foreach($codes as $code => $codeArray){
3353 if(is_array($data) && sizeof($data) > 0){
3354 foreach($data as $data_key => $data_value){
3355 if($data_value != ''){
3356 preg_match_all($codeArray['expression'], $data_value, $values_found);
3357 if($code == 'amounts'){
3358 if(sizeof($values_found) > 0){
3359 foreach($values_found[1] as $key => $value){
3360 $value = str_replace(',','',$value);
3361 $value = (strpos($value,'.') ? number_format($value,2) : (int)$value);
3362 $values_found[1][$key] = $value*(in_array($globals['currency'],array('KR','ZAR','SEK','NOK','DKK')) ? 10 : ($globals['currency'] == 'RUB' ? 70 : 1));
3363 $values_found[1][$key] = (is_float($values_found[1][$key]) ? number_format($values_found[1][$key],2) : $values_found[1][$key]);
3364 $values_found[1][$key] = ((int)$values_found[1][$key] < $values_found[1][$key] ? $values_found[1][$key] : (int)$values_found[1][$key]);
3365 $values_found[1][$key] = (in_array($globals['lang'],array('de','no','se')) ? $values_found[1][$key].$globals['currency_symbol'] : ($globals['currency'] == 'RUB' ? $values_found[1][$key].$globals['currency_symbol'] : $globals['currency_symbol'].$values_found[1][$key]));
3366 }
3367 $data[$data_key] = str_replace($values_found[0],$values_found[1],$data[$data_key]);
3368 }
3369 }
3370 else{
3371 if(isset($codeArray['replace']) && $codeArray['replace'] != '')
3372 $data[$data_key] = str_replace($value,$codeArray['replace']);
3373 }
3374 }
3375 }
3376 }
3377 else{
3378 preg_match_all($codeArray['expression'], $data, $values_found);
3379 if($code == 'amounts'){
3380 if(sizeof($values_found) > 0){
3381 foreach($values_found[1] as $key => $value){
3382 $value = str_replace(',','',$value);
3383 $value = (strpos($value,'.') ? number_format($value,2) : (int)$value);
3384 $values_found[1][$key] = $value*(in_array($globals['currency'],array('KR','ZAR','SEK','NOK','DKK')) ? 10 : ($globals['currency'] == 'RUB' ? 70 : 1));
3385 $values_found[1][$key] = (is_float($values_found[1][$key]) ? number_format($values_found[1][$key],2) : $values_found[1][$key]);
3386 $values_found[1][$key] = (in_array($globals['lang'],array('de','no','se')) ? $values_found[1][$key].$globals['currency_symbol'] : ($globals['currency'] == 'RUB' ? $values_found[1][$key].$globals['currency_symbol'] : $globals['currency_symbol'].$values_found[1][$key]));
3387 }
3388 $data = str_replace($values_found[0],$values_found[1],$data);
3389 }
3390 }
3391 else{
3392 if(isset($codeArray['replace']) && $codeArray['replace'] != '')
3393 $data = str_replace($value,$codeArray['replace']);
3394 }
3395 }
3396 }
3397 }
3398 return $data;
3399}
3400
3401function get_action($promotion,$class = '',$id = '',$request_data,$games = array('desktop_game'=>0,'mobile_game'=>0)){
3402 global $globals,$cache,$dd;
3403 $output = '';
3404 $lastDepositUrl = $globals['lastDepositUrl'];
3405 $cashierUrl = $globals['cashierUrl'];
3406 $free_spins = $globals['free_spins_url'];
3407 $actions = array(
3408 'deposit' => array(
3409 'action' => $globals['cashierUrl']
3410 ),
3411 'deposit_with_code' => array(
3412 'code' => true,
3413 'action' => $globals['cashierUrl']
3414 ),
3415 'deposit_and_register' => array(
3416 'action' => $globals['cashierUrl']
3417 ),
3418 'register' => array(
3419 'action' => $globals['free_spins_url']
3420 ),
3421 'register_with_code' => array(
3422 'code' => true,
3423 'action' => $globals['free_spins_url']
3424 ),
3425 'free_bonus' => array(
3426 'code' => true,
3427 'action' => $globals['free_spins_url']
3428 ),
3429 'free_spins' => array(
3430 'code' => true,
3431 'action' => $globals['free_spins_url']
3432 ),
3433 'tournaments' => array(
3434 'action' => 'https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index='
3435 ),
3436 'game' => array(
3437 'action' => 'https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index='
3438 )
3439 );
3440 $button_types = array(
3441 'claim_now' => 'Claim Now',
3442 'ojo_claim_now' => 'Claim the Kicker',
3443 'deposit_now' => 'Deposit Now',
3444 'register_now' => 'Register Now',
3445 'dg_register_now' => 'DG_Register Now',
3446 'play_now' => 'Play Now',
3447 'freespins' => 'Free Spins',
3448 'tournaments' => 'TOURNAMENTS',
3449 'ojo_tournaments' => 'REEL SPINOFFS',
3450 'tournaments2' => 'Go to Tournaments',
3451 'freespins2' => 'Claim Ticket',
3452 'deposit_now2' => 'Deposit and Claim Ticket'
3453 );
3454 $dg_prefix = (in_array($globals['brand_data']['abbrev'],['dg','dg-uk','dg-dk','dg-de'])?'DG_':'');
3455 $theme = (in_array($globals['brand_data']['abbrev'],array('crk','crk-uk','cauc','ek','mega-new','mega-dk-new','mega-uk')) ? '' : (in_array($globals['brand_data']['abbrev'],array('simba','simba-dk','simba-uk','sm','sm-uk','sm-dk','dg','dg-de','dg-uk','dg-dk')) ? '_gold' : '_red'));
3456 $bonus_code = '';
3457 if($globals['brand_data']['abbrev'] == 'ojo' || $globals['brand_data']['abbrev'] == 'ojo-uk' || $globals['brand_data']['abbrev'] == 'ojo-dk')
3458 if(in_array(strtolower($globals['lang']), ['se', 'sv']) && $promotion['button_type'] == 'deposit_now'){
3459 $button_text = 'Gör insättning nu';
3460 }else{
3461 $button_text = $globals['translations'][$button_types[$promotion['button_type']]];
3462 }
3463 elseif($globals['lang'] == 'de' && isset($globals['translations'][$button_types['dg_'.$promotion['button_type']]]) && in_array($globals['brand_data']['abbrev'],array('dg','dg-uk','dg-dk','dg-de')))
3464 $button_text = $globals['translations'][$button_types['dg_'.$promotion['button_type']]];
3465 elseif($globals['lang'] == 'de' && isset($globals['translations']['DG_'.$button_types[$promotion['button_type']]]) && in_array($globals['brand_data']['abbrev'],array('dg','dg-uk','dg-dk','dg-de')))
3466 $button_text = $globals['translations']['DG_'.$button_types[$promotion['button_type']]];
3467 else
3468 $button_text = $globals['translations'][$button_types[$promotion['button_type']]];
3469 /* echo '<br />';
3470 print_r($promotion['button_action']);
3471 echo '<br />'; */
3472 if(isset($promotion['button_action']) && $promotion['button_action'] == 'free_spins' || $promotion['button_action'] == 'free_bonus' || $promotion['button_action'] == 'register') {
3473 $globals['free_spins_url_base_data']['cmpgn_id'] = ($promotion['button_campaign_id'] != '' ? $promotion['button_campaign_id'] : ($promotion['campaign_ids'] != '' ? $promotion['campaign_ids'] : 0));
3474 $globals['free_spins_url_base_data']['ref'] = $promotion['promo_id'] . '_' . $promotion['button_code'];
3475 $output = '<a class="free_spins_claim btn btn-lg btn-default' . $globals['pointer_events'] . '" res="' . $globals['free_spins_url_base_data']['cmpgn_id'] . '" href="' . $globals['free_spins_url_base'] . '?d=' . encryptor('encrypt', $globals['free_spins_url_base_data']) . '">' . $button_text . '</a>';
3476 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'register_with_code'){
3477 $bonus_code = ($id != '' ? $id : $promotion['button_code']);
3478 $globals['free_spins_url_base_data']['cmpgn_id'] = ($promotion['button_campaign_id'] != '' ? $promotion['button_campaign_id'] : ($promotion['campaign_ids'] != '' ? $promotion['campaign_ids'] : 0));
3479 $globals['free_spins_url_base_data']['ref'] = $promotion['promo_id'] . '_' . $promotion['button_code'];
3480 $output = '<a class="register btn btn-lg btn-default' . $globals['pointer_events'] . '" res="' . $globals['free_spins_url_base_data']['cmpgn_id'] . '-' . $bonus_code . '" rel="' . $globals['free_spins_url_base'] . '?d=' . encryptor('encrypt', $globals['free_spins_url_base_data']) . '" href="' . $actions['deposit']['action'] . '&bonusCode=' . $bonus_code . '">' . $button_text . '</a>';
3481 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'deposit_and_register'){
3482 $bonus_code = ($id != '' ? $id : $promotion['button_code']);
3483 $globals['free_spins_url_base_data']['cmpgn_id'] = ($promotion['button_campaign_id'] != '' ? $promotion['button_campaign_id'] : ($promotion['campaign_ids'] != '' ? $promotion['campaign_ids'] : 0));
3484 $globals['free_spins_url_base_data']['ref'] = $promotion['promo_id'] . '_' . $promotion['button_code'];
3485 $output = '<a class="register btn btn-lg btn-default' . $globals['pointer_events'] . '" res="' . $globals['free_spins_url_base_data']['cmpgn_id'] . '-' . $bonus_code . '" rel="' . $globals['free_spins_url_base'] . '?d=' . encryptor('encrypt', $globals['free_spins_url_base_data']) . '" href="' . $actions['deposit']['action'] . '&bonusCode=' . $bonus_code . '">' . $button_text . '</a>';
3486 /* $output = '<form id="btn_action_form" class="register btn btn-lg btn-default" action="https://' . $_SERVER['HTTP_HOST'] . '/tournaments/?cached_index=' . $globals['cached_index'] . '" method="post">' .
3487 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
3488 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
3489 '<input type="submit" class="action_btn" value="' . $button_text . '" />
3490 </form>'; */
3491
3492 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'deposit'){
3493 $output = '<a class="btn btn-lg btn-default click_action' . $globals['pointer_events'] . '" rel="' . $actions['deposit']['action'] . '">' .
3494 $button_text .
3495 '</a>';
3496 $output = '<form class="btn_action_form click_action" action="' . $actions['deposit']['action'] . '" method="post">' .
3497 '<input type="submit" class="btn btn-lg btn-default' . $globals['pointer_events'] . '" value="' . $button_text . '" />
3498 </form>';
3499 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'deposit_with_code'){
3500 if($id != '' || $promotion['button_code'] != '')
3501 $bonus_code = '&bonusCode=' . ($id != '' ? $id : $promotion['button_code']);
3502 $output = '<a class="btn btn-lg btn-default click_action' . $globals['pointer_events'] . '" rel="' . $actions['deposit_with_code']['action'] . $bonus_code . '">' .
3503 $button_text .
3504 '</a>';
3505 $output = '<form class="btn_action_form click_action' . $globals['pointer_events'] . '" action="' . $actions['deposit_with_code']['action'] . '" method="post">' .
3506 '<input type="hidden" name="bonusCode" value="' . ($id != '' ? $id : $promotion['button_code']) . '" />' .
3507 '<input type="submit" class="btn btn-lg btn-default' . $globals['pointer_events'] . '" value="' . $button_text . '" />
3508 </form>';
3509 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'tournaments' || $promotion['button_action'] == 'tournaments2'){
3510 if($globals['brand_data']['abbrev'] == 'ojo' || $globals['brand_data']['abbrev'] == 'ojo-uk' || $globals['brand_data']['abbrev'] == 'ojo-dk')
3511 $button_text = $globals['translations'][$button_types['ojo_tournaments']];
3512 $output = '<form id="tournaments_form" class="btn btn-lg btn-default' . $globals['pointer_events'] . '" action="' . $actions['tournaments']['action'] . $globals['cached_index'] . '" method="post">' .
3513 '<input type="hidden" name="tournaments" id="tournaments" value="' . $request_data . '" />' .
3514 '<input type="hidden" name="daily_picks_form" id="daily_picks_form" value="1" />' .
3515 '<input type="submit" class="action_btn' . $globals['pointer_events'] . '" value="' . $button_text . '" />
3516 </form>';
3517 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'packages'){
3518 $output = '<a class="btn btn-lg btn-default" href="Javascript:void(0);" data-toggle="modal" data-target="#package' . $id . '">' .
3519 $globals['translations']['Details'] .
3520 '</a>';
3521 /* $bonus_code = '&bonusCode=' . $id;
3522 if($class=='cashier'){
3523 $output = '<a class="btn btn-lg btn-default" href="' . $actions['deposit']['action'] . $bonus_code . '">' .
3524 $button_text .
3525 '</a>';
3526 }else{
3527 $globals['free_spins_url_base_data']['cmpgn_id'] = $package_data['bonus_id'];
3528 $globals['free_spins_url_base_data']['ref'] = $package_data['bonus_code'];
3529 $output = '<a class="btn btn-lg btn-default" href="' . $globals['free_spins_url_base'] . '?d=' . encryptor('encrypt', $globals['free_spins_url_base_data']) . '" data-toggle="modal" data-target="#package' . $id . '">' .
3530 $button_text .
3531 '</a>';
3532 } */
3533 }elseif(isset($promotion['button_action']) && $promotion['button_action'] == 'game'){
3534 if($dd->isMobile()){
3535 $output = '<a class="btn btn-lg btn-default loadMobileGame' . $globals['pointer_events'] . '" href="Javascript:load_game(' . $promotion['games']['mobile_game'][0]. ',' . ($globals['pointer_events']==''?'true':'false') . ');void(0);" id="' . $promotion['games']['mobile_game'][0] . '">' .
3536 $button_text.
3537 '</a>';
3538 }else{
3539 $output = '<a class="btn btn-lg btn-default loadGame' . $globals['pointer_events'] . '" href="Javascript:load_game(' . $promotion['games']['desktop_game'][0]. ',' . ($globals['pointer_events']==''?'true':'false') . ');void(0);" id="' . $promotion['games']['desktop_game'][0]. '">' .
3540 $button_text.
3541 '</a>';
3542 }
3543 /* $bonus_code = '&bonusCode=' . $id;
3544 if($class=='cashier'){
3545 $output = '<a class="btn btn-lg btn-default" href="' . $actions['deposit']['action'] . $bonus_code . '">' .
3546 $button_text .
3547 '</a>';
3548 }else{
3549 $globals['free_spins_url_base_data']['cmpgn_id'] = $package_data['bonus_id'];
3550 $globals['free_spins_url_base_data']['ref'] = $package_data['bonus_code'];
3551 $output = '<a class="btn btn-lg btn-default" href="' . $globals['free_spins_url_base'] . '?d=' . encryptor('encrypt', $globals['free_spins_url_base_data']) . '" data-toggle="modal" data-target="#package' . $id . '">' .
3552 $button_text .
3553 '</a>';
3554 } */
3555 }elseif(isset($promotion['button_action']) && $promotion['button_action'] != '' && $promotion['button_type'] != ''){
3556 if(isset($actions[$promotion['button_action']]['code']) && $actions['deposit']['code'] == true && ($id != '' || $promotion['button_code'] != ''))
3557 $bonus_code = '&bonusCode=' . ($id != '' ? $id : $promotion['button_code']);
3558 $output = '<a class="btn btn-lg btn-default' . $globals['pointer_events'] . '" href="' . $actions['deposit']['action'] . $bonus_code . '">' .
3559 $button_text .
3560 '</a>';
3561 }else{
3562 if($id != '' || $promotion['button_code'] != '')
3563 $bonus_code = '&bonusCode=' . ($id != '' ? $id : $promotion['button_code']);
3564 /* $output = '<a class="btn btn-lg btn-default" href="' . $actions['deposit']['action'] . ($id != '' ? $id : $promotion['button_code']) . '">' .
3565 $button_text .
3566 '</a>'; */
3567 /* if($class == 'package_action')
3568 $button_text = $globals['translations']['Deposit Now']; */
3569 $output = '<form class="btn_action_form click_action" action="' . $actions['deposit']['action'] . '" method="post">' .
3570 '<input type="hidden" name="bonusCode" value="' . ($id != '' ? $id : $promotion['button_code']) . '" />' .
3571 '<input type="submit" class="btn btn-lg btn-default' . $globals['pointer_events'] . '" value="' . $button_text . '" />
3572 </form>';
3573 }
3574 return $output;
3575}
3576
3577function generate_package($package_code){
3578 global $globals,$cache,$mobile;
3579 $output = '';
3580 $ojo = '';
3581 $discount = '';
3582 $discount_amount = '';
3583 $mobile_class = str_replace(' ','',$mobile);
3584 $dg_prefix = '';
3585 if($globals['lang'] == 'de' && in_array($globals['brand_data']['abbrev'],array('dg','dg-uk','dg-dk')))
3586 $dg_prefix = 'DG_';
3587 if(isset($globals['free_spins_packages'][$package_code])){
3588 $package_data = $globals['free_spins_packages'][$package_code];
3589 if(in_array($globals['currency'],array('NOK','SEK','DKK','ZAR')))
3590 $package_data['spin_value'] = $package_data['spin_value'] * 10;
3591 elseif($globals['currency'] == 'RUB')
3592 $package_data['spin_value'] = $package_data['spin_value'] * 70;
3593 $package_url_data = $globals['free_spins_url_base_data'];
3594 if($package_data['type'] == 'dynamic'){
3595 $package_url_data['ref'] = $package_data['bonus_code'];
3596 $package_url_data['cmpgn_id'] = $package_data['bonus_id'];
3597 $purchase_url = $globals['free_spins_url_base'] . '?purchase_type=2&d='.encryptor('encrypt', $package_url_data);
3598 }
3599 $output_header = '<div id="package' . $package_data['code'] . '" class="packages_modal modal fade ' . $mobile_class . '" data-backdrop="static" data-keyboard="false" style="z-index:1000000;">' .
3600 '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>' .
3601 '<div class="packages_modal_header text-center">' .
3602 (isset($globals['translations'][$dg_prefix.'Buy your Spin Packages'])?$globals['translations'][$dg_prefix.'Buy your Spin Packages']:$globals['translations']['Buy your Spin Packages']) .
3603 '</div>' .
3604 '<div class="packages_modal_body">';
3605 /* if(isset($_REQUEST['dev']) || isset($_REQUEST['custom_date']))
3606 $output_header .= '<div class="cover_overlay"></div>'; */
3607 $output_footer = '<div class="row">' .
3608 '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">' .
3609 '<div class="package_action_container">' .
3610 '<a class="package_action btn btn-lg btn-default' . $globals['pointer_events'] . '" rel="' . $purchase_url . '" href="#">' .
3611 //($package_data['type'] == 'dynamic' ? $globals['translations']['Buy with Balance'] : $globals['translations']['Buy Spins']) .
3612 (isset($globals['translations'][$dg_prefix.'Buy with Balance'])?$globals['translations'][$dg_prefix.'Buy with Balance']:$globals['translations']['Buy with Balance']) .
3613 '</a>' .
3614 //($mobile_class == 'mobile_device'?'<br class="clearfix">':'') .
3615 '<form class="btn_action_form click_action' . $globals['pointer_events'] . '" action="' . $globals['cashierUrl'] . '" method="post">' .
3616 '<input type="hidden" name="bonusCode" value="' . $package_data['bonus_code'] . '" />' .
3617 '<input type="submit" class="btn btn-lg btn-default' . $globals['pointer_events'] . '" value="' . (isset($globals['translations'][$dg_prefix.'Buy with Deposit'])?$globals['translations'][$dg_prefix.'Buy with Deposit']:$globals['translations']['Buy with Deposit'])/* ($package_data['type'] == 'dynamic' ? $globals['translations']['Buy with Deposit'] : $globals['translations']['Deposit Now']) */ . '" />
3618 </form>' .
3619 //($mobile_class == 'mobile_device'?'<br class="clearfix">':'') .
3620 '</div>' .
3621 '</div>' .
3622 '</div>' .
3623 '<div class="row">' .
3624 '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center bottom_notes">' .
3625 (isset($globals['translations'][$dg_prefix.'Game:'])?$globals['translations'][$dg_prefix.'Game:']:$globals['translations']['Game:']) . ' ' . $package_data['game_name'] . ' | ' . (isset($globals['translations'][$dg_prefix.'Value per spin'])?$globals['translations'][$dg_prefix.'Value per spin']:$globals['translations']['Value per spin']). ': ' . $globals['currency_symbol'] . $package_data['spin_value'] .
3626 '</div>' .
3627 '</div>' .
3628 '</div>' .
3629 '<div class="packages_modal_footer text-left">';
3630 if($globals['brand_data']['abbrev'] == 'ojo' || $globals['brand_data']['abbrev'] == 'ojo-uk' || $globals['brand_data']['abbrev'] == 'ojo-dk')
3631 $output_footer .= (isset($globals['translations'][$dg_prefix.'Purchase your Spins Package with your balance or by making a deposit.'])?$globals['translations'][$dg_prefix.'Purchase your Spins Package with your balance or by making a deposit.']:$globals['translations']['Purchase your Spins Package with your balance or by making a deposit.']);
3632 else
3633 $output_footer .= (isset($globals['translations'][$dg_prefix.'Purchase your Spins Package either directly with your balance or with a deposit and then play your spins.'])?$globals['translations'][$dg_prefix.'Purchase your Spins Package either directly with your balance or with a deposit and then play your spins.']:$globals['translations']['Purchase your Spins Package either directly with your balance or with a deposit and then play your spins.']);
3634 $output_footer .= '</div>' .
3635 '</div>';
3636 $output .= '<div class="row">' .
3637 '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">' .
3638 '<div class="packages_options_container">' .
3639 '<div class="btn-group" data-toggle="buttons">';
3640 if($globals['brand_data']['abbrev'] == 'ojo' || $globals['brand_data']['abbrev'] == 'ojo-uk' || $globals['brand_data']['abbrev'] == 'ojo-dk')
3641 $ojo = '_ojo';
3642 //package selection options
3643 $active_selection = (($package_data['packages_options']%2)==0?($package_data['packages_options']/2):(ceil($package_data['packages_options']/2)));
3644 for($i=1;$i<=$package_data['packages_options'];$i++){
3645 if(in_array($globals['currency'],array('NOK','SEK','DKK','ZAR'))){
3646 if($package_data['type'] == 'dynamic'){
3647 $package_data['min_value'] = $package_data['min_value'] * 10;
3648 $package_data['max_value'] = $package_data['max_value'] * 10;
3649 }else{
3650 $package_data['cost'][$i] = $package_data['cost'][$i] * 10;
3651 $package_data['discount_amount'][$i] = ($package_data['discount_amount'][$i]!=''? $package_data['discount_amount'][$i] * 10 : '');
3652 }
3653 }elseif($globals['currency'] == 'RUB'){
3654 if($package_data['type'] == 'dynamic'){
3655 $package_data['min_value'] = $package_data['min_value'] * 70;
3656 $package_data['max_value'] = $package_data['max_value'] * 70;
3657 }else{
3658 $package_data['cost'][$i] = $package_data['cost'][$i] * 70;
3659 $package_data['discount_amount'][$i] = ($package_data['discount_amount'][$i]!=''? $package_data['discount_amount'][$i] * 70 : '');
3660 }
3661 }
3662 $package_url_data = $globals['free_spins_url_base_data'];
3663 if($package_data['type'] == 'fixed'){
3664 $package_url_data['cmpgn_id'] = $package_data['bonus_id'][$i];
3665 $package_url_data['ref'] = $package_data['bonus_code'][$i];
3666 }else{
3667 $package_url_data['cmpgn_id'] = $package_data['bonus_id'];
3668 $package_url_data['ref'] = $package_data['bonus_code'];
3669 }
3670 $purchase_url = $globals['free_spins_url_base'] . '?purchase_type=' . ($package_data['type'] == 'fixed' ? 1 : 2) . '&d='.encryptor('encrypt', $package_url_data);
3671 $output .= '<label class="btn btn-primary cost' . $i . ($active_selection==$i?' active':' notActive') . '" id="cost' . $i . '">' .
3672 '<input type="radio" class="' . $globals['pointer_events'] . '" name="cost" rel="' . $purchase_url . '" id="cost' . ($package_data['type'] == 'dynamic' ? ($package_data['min_value'] * $i) : $package_data['cost'][$i]) . '" autocomplete="off" value="' . ($package_data['type'] == 'dynamic' ? ($package_data['min_value'] * $i) : $package_data['cost'][$i]) . '"> ' . $globals['currency_symbol'] . ($package_data['type'] == 'dynamic' ? ($package_data['min_value'] * $i) : $package_data['cost'][$i]) .
3673 '</label>';
3674 }
3675 $output .= '</div>' .
3676 '</div>' .
3677 '</div>' .
3678 '</div>' .
3679 '<div class="row">';
3680 if($package_data['type'] == 'dynamic'){
3681 $min_value = $package_data['min_value'];
3682 $max_value = $package_data['max_value'];
3683 $selected_value = $active_selection*$min_value;
3684 $offset_custom_input = ($mobile_class == 'mobile_device' ? '' : 'col-sm-offset-1 col-md-offset-1 col-lg-offset-1 ');
3685 $output .= '<div class="' . $offset_custom_input . ($package_data['type']=='dynamic'?'col-xs-5':'col-xs-10') . ' col-sm-4 col-md-4 col-lg-4 custom_user_amount">' .
3686 '<label class="custom_player_amount">' . (isset($globals['translations'][$dg_prefix.'Enter an amount'])?$globals['translations'][$dg_prefix.'Enter an amount']:$globals['translations']['Enter an amount']) . ':</label><br />' .
3687 '<div class="custom_amount">' .
3688 '<label class="currency_input_label">' . $globals['currency_symbol'] . '</label><input type="text" class="' . $globals['pointer_events'] . '" id="player_amount" name="player_amount" value="' . $selected_value . '">' .
3689 '</div>' .
3690 '</div>';
3691 $spins = $selected_value;
3692 $package_info = ''/* ($discount != ''?'<span class="discount">' . $discount . '</span>% ' . $globals['translations']['Discount']:'') . ($discount_amount != '' ? ' <span class="save_amount">(' . $globals['translations']['Save'] . ': ' . $globals['currency_symbol'] . '<label class="discount_amount">' . $discount_amount . '</label>)</span>' : '') */;
3693 $offset = '';
3694 }else{
3695 /* $min_value = $package_data['cost'][1];
3696 $max_value = $package_data['cost'][sizeof($package_data['cost'])]; */
3697 $selected_value = $package_data['cost'][$active_selection];
3698 $spins = $package_data['spins'][$active_selection];
3699 $max_value = $package_data['cost'][sizeof($package_data['cost'])];
3700 $discount = ($package_data['discount'][$active_selection]!=''?$package_data['discount'][$active_selection]:'');
3701 $discount_amount = ($package_data['discount_amount'][$active_selection]!=''?$package_data['discount_amount'][$active_selection]:'');
3702 if($package_data['extra_spins'] != '' && isset($package_data['extra_spins'][$active_selection]) && $package_data['extra_spins'][$active_selection] > 0)
3703 $package_info = '<span class="discount">' . str_replace('#5#','<label class="extra_spins">'.$package_data['extra_spins'][$active_selection].'</label>',(isset($globals['translations'][$dg_prefix.'+ Extra #5# Spins'])?$globals['translations'][$dg_prefix.'+ Extra #5# Spins']:$globals['translations']['+ Extra #5# Spins']) . '</span>');
3704 else
3705 $package_info = ($discount != ''?'<span class="discount">' . $discount . '</span>% ' . (isset($globals['translations'][$dg_prefix.'Discount'])?$globals['translations'][$dg_prefix.'Discount']:$globals['translations']['Discount']): '') . ($discount_amount != '' ? ' <span class="save_amount">' . ($discount != ''?'(':'') . (isset($globals['translations'][$dg_prefix.'Save'])?$globals['translations'][$dg_prefix.'Save']:$globals['translations']['Save']) . ': ' . $globals['currency_symbol'] . '<label class="discount_amount">' . $discount_amount . '</label>' . ($discount != ''?')':'') . '</span>' : '');
3706
3707 $offset = 'col-xs-offset-1 col-sm-offset-3 col-md-offset-3 col-lg-offset-3 ';
3708 }
3709 $output .= '<div class="' . $offset . ($package_data['type']=='dynamic'?'col-xs-7':'col-xs-10') . ' col-sm-6 col-md-6 col-lg-6 selected_values_container text-center">' .
3710 '<span class="gift_icon selected_values">' .
3711 '<img src="https://aws-origin.image-tech-storage.com/promos.playeroffers.com/images/promotions_frame/box' . $ojo . '.png">' .
3712 '</span>' .
3713 '<span class="player_amount_value selected_values">' . $spins . '</span> ' . (isset($globals['translations'][$dg_prefix.'Spins'])?$globals['translations'][$dg_prefix.'Spins']:$globals['translations']['Spins']) . '<br>' .
3714 '<div class="progress' . /* ($package_data['type']=='dynamic'?' hide':'') .*/ '">' .
3715 //'<div class="progress-bar" rel="' . $purchase_url . '" role="progressbar" aria-valuenow="' . $selected_value . '" aria-valuemin="' . ($package_data['type'] == 'dynamic' ? $package_data['min_value'] : $package_data['cost'][1]) . '" aria-valuemax="' . $max_value . '" style="width:' . (($selected_value/$max_value)*100) . '%;"></div>' .
3716 $package_info .
3717 '</div>' .
3718 '</div>' .
3719 '</div>';
3720 }else{
3721 return false;
3722 /*
3723 * $url_data = [
3724 'username' => $req['username'],
3725 'user_id' => $req['user_id'],
3726 'country' => $req['country'],
3727 'cur' => $req['currency'],
3728 'skin' => $req['app_name'],
3729 'affiliate' => $req['aname'],
3730 'ext_id' => $req['ext_id'],
3731 'cmpgn_id' => $tournament['free_spins_id'],
3732 'ref' => $tournament['bonus_code']
3733 ];
3734 */
3735 //'/bonusAPI.php?purchase_type=1&purchase_amount='.(int)$package['fixed_cost'].'&d='.$this->encryptor('encrypt', $url_data)
3736 //'/bonusAPI.php?purchase_type=2&d='.$this->encryptor('encrypt', $url_data);
3737 }
3738 return $output_header . $output . $output_footer;
3739}
3740
3741function display_feeds_modal(){
3742 global $globals,$cache;
3743 $output = '';
3744 //define("ENT_XML1", 16);
3745 $bp_feed = file_get_contents('http://playeroffers.com/api.php?type=bonus_policy&sid=' . $globals['brand_data']['token'] . '&lang='.$globals['lang']);
3746 $tnc_feed = file_get_contents('http://playeroffers.com/api.php?type=terms_and_conditions&sid=' . $globals['brand_data']['token'] . '&lang='.$globals['lang']);
3747 /* $xml_bp = simplexml_load_string($bp_feed, 'SimpleXMLElement', LIBXML_NOCDATA);
3748 $xml_tnc = simplexml_load_string($tnc_feed, 'SimpleXMLElement', LIBXML_NOCDATA); */
3749 //$bonus_policy = $xml_bp->P->LINE;
3750 $bonus_policy = $bp_feed;
3751 //$terms_and_conditions = $xml_tnc->P->LINE;
3752 $terms_and_conditions = $tnc_feed;
3753 $output .= '<div id="bonus_policy_modal" class="feeds_modal bonus_policy_modal modal fade" data-keyboard="false" style="z-index:1000000;">' .
3754 '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>' .
3755 //file_get_contents('http://' . $globals['brand_data']['domain'] . '/feed_proxy.php?type=bonus_policy&lang='.$globals['lang']) .
3756 $bonus_policy .
3757 '</div>' .
3758 '<div id="terms_and_conditions_modal" class="feeds_modal terms_and_conditions_modal modal fade" data-keyboard="false" style="z-index:1000000;">' .
3759 '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>' .
3760 //file_get_contents('http://' . $globals['brand_data']['domain'] . '/feed_proxy.php?type=terms_and_conditions&lang='.$globals['lang']) .
3761 $terms_and_conditions .
3762 '</div>';
3763 return $output;
3764}
3765
3766function get_shortcodes($force = false){
3767 global $kc_connection,$cache;
3768 $shortcodes = array();
3769 start_bench('get_shortcodes');
3770 $redis = connectRedis();
3771 if($redis->exists('shortcodes') && !$force){
3772 $shortcodes= unserialize($redis->get('shortcodes'));
3773 }else{
3774 $query = pg_query($kc_connection,"select shortcode,content from promotions_shortcodes");
3775 if(pg_num_rows($query) > 0){
3776 while($shortcode = pg_fetch_object($query)){
3777 $shortcodes['codes'][] = html_entity_decode($shortcode->shortcode);
3778 $shortcodes['content'][] = html_entity_decode($shortcode->content);
3779 }
3780 }
3781 if($cache == true)
3782 $redis->set('shortcodes', serialize($shortcodes), 21600); // cache for 6 hours
3783 }
3784 return $shortcodes;
3785}
3786
3787function get_packages($force = false){
3788 global $kc_connection,$cache;
3789 $packages = array();
3790 start_bench('get_packages');
3791 $redis = connectRedis();
3792 if($redis->exists('free_spins_packages') && !$force){
3793 $packages = unserialize($redis->get('free_spins_packages'));
3794 }else{
3795 $query = pg_query($kc_connection,"select * from free_spins_packages order by entry_id desc");
3796 if(pg_num_rows($query) > 0){
3797 while($package = pg_fetch_object($query)){
3798 $packages[$package->code] = array(
3799 'entry_id' => $package->entry_id,
3800 'code' => $package->code,
3801 'title' => $package->title,
3802 'type' => $package->type,
3803 'min_value' => $package->min_value,
3804 'max_value' => $package->max_value,
3805 'spin_value' => $package->spin_value,
3806 'spins' => $package->spins,
3807 'packages_options' => $package->packages_options,
3808 'game_name' => $package->game_name,
3809 'extra_spins' => $package->extra_spins
3810 );
3811 if($package->type == 'fixed'){
3812 $packages[$package->code]['cost'] = json_decode($package->cost,TRUE);
3813 $packages[$package->code]['bonus_id'] = json_decode($package->bonus_id,TRUE);
3814 $packages[$package->code]['bonus_code'] = json_decode($package->bonus_code,TRUE);
3815 $packages[$package->code]['discount'] = json_decode($package->discount,TRUE);
3816 $packages[$package->code]['discount_amount'] = json_decode($package->discount_amount,TRUE);
3817 $packages[$package->code]['spins'] = json_decode($package->spins,TRUE);
3818 $packages[$package->code]['extra_spins'] = json_decode($package->extra_spins,TRUE);
3819 }else{
3820 $packages[$package->code]['bonus_id'] = $package->bonus_id;
3821 $packages[$package->code]['bonus_code'] = $package->bonus_code;
3822 }
3823 }
3824 }
3825 if($cache == true)
3826 $redis->set('free_spins_packages', serialize($packages), 21600); // cache for 6 hours
3827 }
3828 end_bench('get_packages');
3829 return $packages;
3830}
3831
3832function ValidateDate($date, $format = 'Y-m-d') {
3833 $version = explode('.', phpversion());
3834 if (((int) $version[0] >= 5 && (int) $version[1] >= 2 && (int) $version[2] > 17)) {
3835 $d = DateTime::createFromFormat($format, $date);
3836 } else {
3837 $d = new DateTime(date($format, strtotime($date)));
3838 }
3839 return $d && $d->format($format) == $date;
3840}
3841
3842function logical_result($value){
3843 if(strpos($value,'!') === false)
3844 return true;
3845 else
3846 return false;
3847}
3848
3849function log_user_action($promo_id = 0,$action = '',$value = '',$schedule_id = 0){
3850 global $rc_connection,$globals,$cache;
3851 $output = false;
3852 $redis = connectRedis();
3853 if($action != '' && $promo_id != 0){
3854 $app_name = $globals['app_name'];
3855 $user_id = $globals['user_id'];
3856 $username = $globals['username'];
3857 $ip = $globals['user_ip'];
3858 $exists = true;
3859 $existing_rows = 0;
3860 if($action == 'rate'){
3861 $exists = pg_query($rc_connection,"select * from d_client_promotions_stats where promo_id=$promo_id and appname='$app_name' and user_id='$user_id'");
3862 $existing_rows = pg_num_rows($exists);
3863 }
3864 if($exists && $existing_rows == 0){
3865 $query = pg_query($rc_connection,"insert into d_client_promotions_stats (promo_id,appname,user_id,username,{$action},user_ip" . ($schedule_id != 0 ? ",schedule_id" : "") . ") values($promo_id,'$app_name',$user_id,'$username','$value','$ip'" . ($schedule_id != 0 ? ",'$schedule_id'" : "") . ")");
3866 //file_put_contents('/project_new/promos.playeroffers.com/failed_queries.log', date('Y-m-d H:i:s')." :: insert into d_client_promotions_stats (promo_id,appname,user_id,username,{$action},user_ip" . ($schedule_id != 0 ? ",schedule_id" : "") . ") values($promo_id,'$app_name',$user_id,'$username','$value','$ip'" . ($schedule_id != 0 ? ",'$schedule_id'" : "") . ")" . "\n\n", FILE_APPEND|LOCK_EX);
3867 }else
3868 $query = true;
3869 if($query != false){
3870 $promotion_stats = pg_query($rc_connection,"select
3871 distinct promo_id,
3872 COALESCE(sum(CASE WHEN rate IS NOT NULL THEN rate ELSE 0 END), 0) as rate_sum,
3873 (select count(*) from d_client_promotions_stats as rt where rt.promo_id = stats.promo_id) as rated,
3874 (select round((sum(rate)::float/count(*)::float)::numeric,1) from d_client_promotions_stats as calc_rate where calc_rate.promo_id=stats.promo_id and rate IS NOT NULL) as rate,
3875 (select count(*) from d_client_promotions_stats as used_promo where used_promo.promo_id=stats.promo_id and used_promo.used='t') as used,
3876 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.used='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_used,
3877 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users_rated where users_rated.rate IS NOT NULL and users_rated.promo_id=stats.promo_id and users_rated.schedule_id=0),',') as users_rated
3878 from
3879 d_client_promotions_stats as stats
3880 where
3881 promo_id={$promo_id}
3882 GROUP BY promo_id");
3883 /* "select
3884 distinct promo_id,
3885 COALESCE(sum(CASE WHEN rate IS NOT NULL THEN rate ELSE 0 END), 0) as rate_sum,
3886 (select count(*) from d_client_promotions_stats as rt where rt.promo_id = stats.promo_id) as rated,
3887 (select round((sum(rate)::float/count(*)::float)::numeric,1) from d_client_promotions_stats as calc_rate where calc_rate.promo_id=stats.promo_id and rate IS NOT NULL) as rate,
3888 (select count(*) from d_client_promotions_stats as likes where likes.promo_id=stats.promo_id and likes.liked='t') as liked,
3889 (select count(*) from d_client_promotions_stats as shares where shares.promo_id=stats.promo_id and shares.shared='t') as shared,
3890 (select count(*) from d_client_promotions_stats as used_promo where used_promo.promo_id=stats.promo_id and used_promo.used='t') as used,
3891 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.used='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_used,
3892 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users where users.liked='t' and users.promo_id=stats.promo_id and users.schedule_id=0),',') as users_liked,
3893 array_to_string(ARRAY(select distinct user_id from d_client_promotions_stats as users_rated where users_rated.rate IS NOT NULL and users_rated.promo_id=stats.promo_id and users_rated.schedule_id=0),',') as users_rated
3894 from
3895 d_client_promotions_stats as stats
3896 where
3897 promo_id={$promo_id}
3898 GROUP BY promo_id" */
3899 $promo_stats = pg_fetch_object($promotion_stats);
3900 $stats = get_stats();
3901 unset($stats[$promo_id]);
3902 $stats[$promo_id] = array(
3903 'promo_id' => $promo_stats->promo_id,
3904 'rated' => $promo_stats->rated,
3905 'rate_sum' => $promo_stats->rate_sum,
3906 'rate' => ($promo_stats->rate == '' ? 4.7 : $promo_stats->rate),
3907 //'liked' => $promo_stats->liked,
3908 //'shared' => $promo_stats->shared,
3909 //'users_liked' => explode(',',$promo_stats->users_liked),
3910 'users_rated' => explode(',',$promo_stats->users_rated),
3911 'used' => $promo_stats->used
3912 );
3913 $redis->delete('stats');
3914 $redis->set('stats',serialize($stats),900);
3915 $output = $stats[$promo_id];
3916 }else{
3917 $output['error_stats'] = 'error';//"insert into d_client_promotions_stats (promo_id,appname,user_id,username,{$action},user_ip) values($promo_id,'$app_name ',$user_id,'$username','$value','$ip')";
3918 }
3919 }
3920 return $output;
3921}
3922
3923function log_hit($promo_ids = '',$action = '',$schedule_id = 0,$schedule_date = '',$notes){
3924 global $globals,$rc_connection,$logging,$maintenance_logging,$cache;
3925 $redis = connectRedis();
3926 $skin = (isset($globals['app_name']) ? $globals['app_name'] : '');
3927 $userid = (isset($globals['user_id']) ? $globals['user_id'] : 0);
3928 $username = (isset($globals['username']) ? $globals['username'] : '');
3929 $uri = '';
3930 $purchase_notes = '';
3931 $action = ($action != '' ? $action : 'accessed');
3932 $today = strtotime(date('Y-m-d'));
3933 $promotions = get_promotions();
3934 $promo_title = html_entity_decode($promotions['promo_translations'][$promo_ids]['view_title']['token_en']);
3935 $bonus_code = ($notes!=''?$notes:'');
3936 if(strpos($bonus_code, '-') !== false){
3937 $temp_code = str_replace('-',', Bonus Code: ',$bonus_code);
3938 $bonus_code = 'Bonus Id: ' . $temp_code;
3939 }elseif(strpos($bonus_code, ',') !== false){
3940 $bonus_code = ', Bonus Id: ' . end(explode(',',$bonus_code));
3941 }
3942 if($logging){
3943 if(isset($_REQUEST['q']) && $redis->exists($_REQUEST['q'])){
3944 $uri_parameters = json_decode(encryptor('decrypt',$redis->get($_REQUEST['q'])),TRUE);
3945 $uri = '/api.php?';
3946 foreach($uri_parameters as $key=>$value) { $uri .= $key.'='.$value.'&'; }
3947 }else{
3948 unset($_REQUEST['q']);
3949 $uri = pg_escape_string($_SERVER['REQUEST_URI']);
3950 }
3951 if($action == 'used' && strtotime(date('Y-m-d',strtotime($schedule_date))) != $today && $schedule_id > 0){
3952 # LOG FAKE OR ABUSED REQUESTS
3953 file_put_contents('/project_new/promos.playeroffers.com/abused_requests.log', date('Y-m-d H:i:s').' :: username:'.$globals['username'] . '_userid:' . $globals['user_id'] . '_skin:' . $globals['app_name'] . '_schedule_date:' . $schedule_date.'_schedule_id:'.$schedule_id.'_promo_id:'.$promo_ids."\n\n", FILE_APPEND|LOCK_EX);
3954 alert_admins($schedule_date,$schedule_id,$promo_ids);
3955 //file_put_contents('/project_new/promos.playeroffers.com/queries.log', date('Y-m-d H:i:s').'_'.$globals['username'].'_'.$globals['user_id'].'_'.$schedule_date.'_'.$schedule_id.")\n\n", FILE_APPEND|LOCK_EX);
3956 }
3957 if($action == 'used' && strtotime(date('Y-m-d',strtotime($schedule_date))) != $today && $schedule_id > 0){
3958 # LOG FAKE OR ABUSED REQUESTS
3959 file_put_contents('/project_new/promos.playeroffers.com/abused_requests.log', date('Y-m-d H:i:s').' :: username:'.$globals['username'] . '_userid:' . $globals['user_id'] . '_skin:' . $globals['app_name'] . '_schedule_date:' . $schedule_date.'_schedule_id:'.$schedule_id.'_promo_id:'.$promo_ids."\n\n", FILE_APPEND|LOCK_EX);
3960 alert_admins($schedule_date,$schedule_id,$promo_ids);
3961 //file_put_contents('/project_new/promos.playeroffers.com/queries.log', date('Y-m-d H:i:s').'_'.$globals['username'].'_'.$globals['user_id'].'_'.$schedule_date.'_'.$schedule_id.")\n\n", FILE_APPEND|LOCK_EX);
3962 }
3963 if($action == 'purchased'){
3964 $packages = get_packages();
3965 $alt_notes = explode('-',$notes);
3966 if($packages[$alt_notes[0]]['type'] == 'fixed')
3967 $notes = 'Promo: ' . $promo_title . ', Bonus Code: ' . $packages[$alt_notes[0]]['bonus_code'][$alt_notes[2]] . ', Spins: ' . $packages[$alt_notes[0]]['spins'][$alt_notes[2]] . (isset($packages[$alt_notes[0]]['extra_spins'][$alt_notes[2]])? ', Extra Spins: ' . $packages[$alt_notes[0]]['extra_spins'][$alt_notes[2]]:'') . ', Cost: ' . $packages[$alt_notes[0]]['cost'][$alt_notes[2]];
3968 else
3969 $notes = 'Promo: ' . $promo_title . ', Bonus Code: ' . $packages[$alt_notes[0]]['bonus_code'] . ', Spins: ' . $alt_notes[1] . ', Cost: ' . $alt_notes[1];
3970 //file_put_contents('/project_new/promos.playeroffers.com/failed_queries.log', date('Y-m-d H:i:s')." Purchase Notes:: " . $purchase_notes . ' | ' . $notes . ' | ' . $alt_notes[0] . ' | ' . $alt_notes[1] . ' | ' . " \n\n", FILE_APPEND|LOCK_EX);
3971 }elseif($action!='accessed'){
3972 if(strpos($bonus_code, ',') === false && $bonus_code != '')
3973 $bonus_code = ', Bonus Code: ' . $bonus_code;
3974 $notes = 'Promo: ' . $promo_title . $bonus_code;
3975 }
3976 $query = pg_query($rc_connection,"insert into d_daily_picks_log (action,skin,userid,username,promo_ids,uri" . ($schedule_id != 0 ? ",promo_schedule_id" : "") . ($schedule_date != '' ? ",promo_schedule_date" : "") . ",alt_notes) values('$action','$skin',$userid,'$username','$promo_ids','$uri'" . ($schedule_id != 0 ? ",'$schedule_id'" : "") . ($schedule_date != '' ? ",'$schedule_date'" : '') . ",'$notes') returning entry_id");
3977 if($uri_parameters['username'] == 'KevinC'){
3978 file_put_contents('/project_new/promos.playeroffers.com/queries.log', $query."\n\n", FILE_APPEND|LOCK_EX);
3979 file_put_contents('/project_new/promos.playeroffers.com/queries.log', $_REQUEST['q'].'::'.$uri_parameters."\n\n", FILE_APPEND|LOCK_EX);
3980 }
3981 if($query != false){
3982 //file_put_contents('/project_new/promos.playeroffers.com/queries.log', "insert into d_daily_picks_log (action,skin,userid,username,promo_ids,uri" . ($schedule_id != 0 ? ",promo_schedule_id" : "") . ($schedule_date != '' ? ",promo_schedule_date" : "") . ") values('$action','$skin',$userid,'$username','$promo_ids','$uri'" . ($schedule_id != 0 ? ",'$schedule_id'" : "") . ($schedule_date != '' ? ",'$schedule_date'" : '') . ") returning entry_id\n\n", FILE_APPEND|LOCK_EX);
3983 $record_id = pg_fetch_object($query);
3984 return $record_id->entry_id;
3985 }else{
3986 file_put_contents('/project_new/promos.playeroffers.com/failed_queries.log', date('Y-m-d H:i:s')." :: insert into d_daily_picks_log (action,skin,userid,username,promo_ids,uri" . ($schedule_id != 0 ? ",promo_schedule_id" : "") . ($schedule_date != '' ? ",promo_schedule_date" : "") . ") values('$action','$skin',$userid,'$username','$promo_ids','$uri'" . ($schedule_id != 0 ? ",'$schedule_id'" : "") . ($schedule_date != '' ? ",'$schedule_date'" : '') . ") returning entry_id\n\n", FILE_APPEND|LOCK_EX);
3987 return false;
3988 }
3989 }else{
3990 return false;
3991 }
3992}
3993
3994function alert_admins($schedule_date = '1970-01-01',$schedule_id = 0,$promo_id = 0){
3995 global $globals,$cache;
3996 $headers = 'MIME-Version: 1.0' . "\r\n";
3997 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
3998 $headers .= 'To: IT Department <nikos@kpaxmarketing.com>' . "\r\n";
3999 $headers .= 'From: Daily Picks Alert <tech@kpaxmarketing.com>' . "\r\n";
4000 //$headers .= 'Cc: marketingteam@kpaxmarketing.com' . "\r\n";
4001 $email_message = "Possible fake or abusing promotion claim in daily picks.<br />You can check the setup using below details:<br /><br />";
4002 $email_message .= "Promotion scheduled date: " . date('Y-m-d',strtotime($schedule_date)) . "<br />";
4003 $email_message .= "Date user tried to claim: " . date('Y-m-d') . "<br />";
4004 $email_message .= "Promotion scheduled id (tech knows about this in case needed): " . $schedule_id . "<br />";
4005 $email_message .= "Promotion id (tech knows about this in case needed): " . $promo_id . "<br />";
4006 $email_message .= "User id: " . $globals['user_id'] . "<br />";
4007 $email_message .= "Username: " . $globals['username'] . "<br />";
4008 $email_message .= "Skin: " . $globals['app_name'] . "<br /><br />";
4009 mail('nikos@kpaxmarketing.com', "Fake or Abusing promotion claim in daily picks" . (str_replace('/','',$_SERVER['SCRIPT_NAME']) == 'api_test.php' ? ' TEST' : ''), $email_message, $headers);
4010}
4011
4012function fetch_tournaments_stats($force = false){
4013 global $rc_connection,$cache;
4014 $redis = connectRedis();
4015 $res = ['active' => 0, 'winners' => 0, 'prizes' => 0];
4016 if($redis->exists('tournament_stats1') && !$force){
4017 $res = unserialize($redis->get('tournament_stats1'));
4018 }else{
4019 $today = date("Y-m-d");
4020 $start_month = date("Y-m-d", strtotime('-90 days'));
4021 $end_month = date("Y-m-d");
4022 $query = pg_query($rc_connection, "SELECT COUNT(entry_date) as active
4023 FROM d_leaderboards
4024 WHERE DATE(entry_date) BETWEEN DATE('".$start_month."') AND DATE('".$end_month."')");
4025 $active = pg_fetch_assoc($query);
4026 $res['active'] = number_format($active['active']);
4027 /*------------------------------------------------------*/
4028 $query_winners = pg_query($rc_connection, "SELECT COUNT(paid_out_stamp) as winners
4029 FROM d_leaderboards
4030 WHERE prize > 0 AND DATE(paid_out_stamp) BETWEEN DATE('".$start_month."') AND DATE('".$end_month."')");
4031 $winners = pg_fetch_assoc($query_winners);
4032 $res['winners'] = number_format($winners['winners']);
4033 /*------------------------------------------------------*/
4034 $query_prizes = pg_query($rc_connection, "SELECT COALESCE(sum(prize), 0) as prizes
4035 FROM d_leaderboards
4036 WHERE prize > 0 AND DATE(paid_out_stamp) BETWEEN DATE('".$start_month."') AND DATE('".$end_month."')");
4037 $prizes = pg_fetch_assoc($query_prizes);
4038 $res['prizes'] = number_format($prizes['prizes']);
4039 $redis->set('tournament_stats1', serialize($res), 300); //cache
4040 }
4041 if($redis->exists('tournaments_showed_today') && !$force){
4042 $res['tournaments_showed_today'] = $redis->get('tournaments_showed_today');
4043 }else{
4044 $yesterday = date("Y-m-d",strtotime('-1 days'));
4045 $today = date("Y-m-d");
4046 $tomorrow = date("Y-m-d",strtotime('+1 days'));
4047 $query = pg_query($rc_connection, "SELECT COUNT(id) as active FROM d_tournaments_schedule WHERE start_date between DATE('$yesterday') and DATE('$tomorrow')");
4048 $active = pg_fetch_object($query);
4049 $res['tournaments_showed_today'] = $active->active;
4050 $redis->set('tournaments_showed_today', $active->active, 21600); //cache for 6 hours
4051 }
4052 return $res;
4053}
4054
4055function clear_cache($app_name = ''){
4056
4057 $redis = connectRedis();
4058
4059 $cache = array('license_selections','brands','shortcodes','langArray','translations','promotions','promotions_days','stats','curr_exhange_rates'/* ,'user_groups' */);
4060 foreach($cache as $k => $v) {
4061 $redis->delete($v);
4062 }
4063
4064 if($app_name != '') {
4065 $redis->delete($app_name.'_langs');
4066 }
4067 //echo 'Cache Successfully Cleared!';
4068}
4069
4070function clear_appname_cache($app_name = '') {
4071
4072 $redis = connectRedis();
4073 $redis->delete($app_name);
4074
4075 //echo 'Cleared Cache for ' . $app_name . '<br />';
4076}
4077
4078function encryptor($action, $data) {
4079 $output = false;
4080
4081 $encrypt_method = "AES-256-CBC";
4082 //pls set your unique hashing key
4083 $secret_key = 'a30d83233cf31eae17fa09795cfba423';
4084 $secret_iv = '98cdf76e93238959349cc37ff7edadda';
4085
4086 // hash
4087 $key = hash('sha256', $secret_key);
4088
4089 // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
4090 $iv = substr(hash('sha256', $secret_iv), 0, 16);
4091
4092 //do the encyption given text/string/number
4093 if($action == 'encrypt') {
4094 $string = json_encode($data);
4095
4096 $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
4097 $output = urlencode(base64_encode($output));
4098 }
4099 else if( $action == 'decrypt' ) {
4100 //decrypt the given text/string/number
4101 $output = openssl_decrypt(base64_decode(urldecode($data)), $encrypt_method, $key, 0, $iv);
4102 $string = json_decode($output);
4103 }
4104
4105 return $output;
4106}
4107
4108function fix_purchased_notes(){
4109 //global $rc_connection,$cache;
4110 /* $promotions = get_promotions();
4111 $query = pg_query($rc_connection,"select entry_id,promo_ids,alt_notes from d_daily_picks_log where alt_notes='Promo: ' and action='clicked'");
4112 if($query != false && pg_num_rows($query) > 0){
4113 echo pg_num_rows($query) . ' entries found!<br />';
4114 $entries_fixed = 0;
4115 while($row = pg_fetch_object($query)){
4116 $promo_title = html_entity_decode($promotions['promo_translations'][$row->promo_ids]['view_title']['token_en']);
4117 $alt_notes = $row->alt_notes.$promo_title;
4118 $query2 = pg_query($rc_connection,"update d_daily_picks_log set alt_notes='$alt_notes' where entry_id='{$row->entry_id}'");
4119 $entries_fixed++;
4120 }
4121 }
4122 echo $entries_fixed . ' Fixed!<br />'; */
4123}
4124
4125function pre($data, $fixed=FALSE) {
4126 if(is_array($data)) {
4127 $style = '';
4128 if($fixed) {
4129 $style = 'style="position: fixed; width: 90%; height: 85%; bottom: 0; left: 5%;"';
4130 }
4131 echo "<pre $style>".print_r($data, TRUE)."</pre><br />";
4132 } else {
4133 $style = '';
4134 if($fixed) {
4135 $style = 'style="position: fixed; width: 90%; height: 300px; bottom: 0; left: 5%;"';
4136 }
4137 echo "<span $style>".$data."</span><br />";
4138 }
4139}
4140
4141function start_bench($name) {
4142 global $benches;
4143
4144 $benches[$name]['start'] = microtime(TRUE);
4145}
4146function end_bench($name) {
4147 global $benches;
4148
4149 $benches[$name]['end'] = microtime(TRUE);
4150 $benches[$name]['total'] = $benches[$name]['end'] - $benches[$name]['start'];
4151}
4152
4153?>