<?php
require_once(CORE_PATH . 'dateTime.inc'); 
require_once(LIB_PATH . 'Database.inc'); 
require_once(LIB_PATH . 'ApFind.inc'); 
class x_8c extends x_cn { 
var $x_lm = Array( 'USER_LIST' => Array('USER_ID', 'UUID', 'USERNAME', 'FULLNAME', 'EMAIL', 'DESCRIPTION'), 
'ISS_LIST' => Array('ISS_ID', 'ISS_NAME', 'LANG'), 
'PROTO_LIST' => Array('PROTO_ID', 'PROTO_NAME', 'LANG') 
); 
var $x_ln = 0; 
var $x_lo = 0; 
var $x_23 = Array(); 
var $x_lp = 0; 
function x_lq( $x_lr = Array(), 
$x_6v = 0, 
$x_6w = 0, 
$x_ls = 5, 
$x_fh = 5, 
$x_4w = '', 
$x_lt = 300) { 
if (empty($x_lr)) { 
$x_lu = $this->x_lv($x_6v, 
$x_6w, 
false, 
$x_ls, 
$x_4w); 
$x_lu = $x_lu['data']; 
} else { 
$x_lu = $x_lr['data']; 
} 
$x_5c = Array(); 
$x_7p = 0; 
$x_lw = x_6a(); 
$x_lx = x_6a(true); 
foreach ($x_lu as $x_fd => $x_1n) { 
$x_3u = Array(); 
$x_3u['x_6u'] = $x_1n['name']; 
$x_3u['x_fd'] = $x_fd; 
$x_3u['x_ff'] = x_4p($x_1n['value'], $x_4w->x_4r()); 
$x_3u['x_fh'] = $x_fh; 
$x_3u['x_dw'] = Array('data' => Array(), 'other' => Array()); 
$x_3u['x_dx'] = Array(); 
$x_bf = Array(); 
$x_bf = $this->x_ly( $x_fd, 
$x_6v, 
$x_6w, 
$x_fh); 
$x_c2 = 0; 
$x_lz = 0; 
foreach($x_bf as $x_m0) { 
$x_m1 = x_6e( 'all', 
$x_m0['userId'], 
$x_m0['userName'], 
$x_m0['userFullname'], 
true, 
true, 
$x_lt, 
true, 
$x_lw); 
$x_3u['x_dx'][] = Array($x_m1, 
x_4p($x_m0['requestsTotal'], $x_4w->x_4r())); 
if ($x_lz < 6) { 
$x_m2 = x_6e( 'all', 
$x_m0['userId'], 
$x_m0['userName'], 
$x_m0['userFullname'], 
false, false, 0, false, $x_lx); 
$x_3u['x_dw']['data'][] = Array('value' => $x_m0['requestsTotal'], 'name' => $x_m2); 
$x_3u['x_dw']['links'][] = Array('label' => strip_tags($x_m1), 
'requests' => x_4p($x_m0['requestsTotal'], $x_4w->x_4r()), 
'periodStart' => $x_6v, 
'periodEnd' => $x_6w, 
'userId' => $x_m0['userId']); 
$x_c2 = sum64($x_c2, $x_m0['requestsTotal']); 
} 
$x_lz++; 
} 
$x_gv = sub64($x_1n['value'], $x_c2); 
if ($x_gv > 0) { 
$x_3u['x_dw']['other'] = Array('value' => $x_gv, 'name' => x_4a('otherData')); 
$x_3u['x_dw']['links'][] = Array ('label' => '<kerio:text id="otherData" />', 
'requests' => x_4p($x_gv, $x_4w->x_4r())); 
} 
unset($x_bf); 
$x_5c['tableData'][$x_7p] = $x_3u; 
$x_7p++; 
unset($x_3u); 
} 
return $x_5c; 
} 
function x_ly( $x_fd = -1, 
$x_6v = 0, 
$x_6w = 0, 
$x_fh = 5) { 
$x_ct = $this->x_m3($x_6v, $x_6w); 
$x_5c = Array(); 
$x_m4 = Array(); 
if ($x_ct && $x_fd >= 0) { 
switch ($x_ct) { 
case 'D': 
$x_cq = 'select * from GET_ALL_TOP_WEBS_VISITORS_D(' . $x_6v . ', ' . $x_fd . ', ' . $x_fh . ')'; 
$this->x_cc($x_cq); 
$x_5c = $this->x_cs('assoc', 'USER_ID'); 
break; 
case 'AP': 
if (count($this->x_23) != 0) { 
foreach ($this->x_23 as $x_m5) { 
$x_cq = 'select * from GET_ALL_TOP_WEBS_VISITORS_AP(' . $x_m5 . ', ' . $x_fd . ', ' . $x_fh . ')'; 
$this->x_cc($x_cq); 
$x_5c = $this->x_cs('assoc', 'USER_ID'); 
} 
} 
break; 
} 
foreach ($x_5c as $x_1m => $x_1n) { 
$x_5c[$x_1m] = Array( 'userName' => $x_1n['USERNAME'], 
'userId' => $x_1n['USER_ID'], 
'requestsTotal' => $x_1n['REQUESTS'] 
); 
} 
$x_5c = $this->x_m6($x_5c); 
} 
return $x_5c; 
} 
function x_m3($x_6v = 0, $x_6w = 0) { 
$x_ct = 'offer'; 
if (0 == ($x_6w - $x_6v)) { 
$x_cq = 'select min(DAY_NUM), max(DAY_NUM) from WEB_ACCESS_D'; 
$this->x_cc($x_cq); 
$x_m7 = Array(); 
$x_m7 = $this->x_cs('assoc'); 
$x_m7 = $x_m7[0]; 
if ($x_6v < $x_m7['MIN'] || $x_6w > $x_m7['MAX']) { 
$x_ct = 'offer'; 
} else { 
$x_ct = 'D'; 
} 
} else { 
$x_cq = 'select AP_ID from AP_LIST where AP_BEGIN = ' . $x_6v . ' and AP_END =' . $x_6w; 
$this->x_cc($x_cq); 
$x_m7 = Array(); 
$x_m7 = $this->x_cs('assoc'); 
$x_m7 = $x_m7[0]; 
if (empty($x_m7) || sizeof($x_m7) != 1) { 
$x_ct = 'offer'; 
} else { 
$this->x_23 = $x_m7; 
$x_ct = 'AP'; 
} 
} 
return $x_ct; 
} 
function x_lv($x_6v = 0, 
$x_6w = 0, 
$x_a9 = false, 
$x_m8 = 5, 
$x_4w = '') { 
$x_5c = Array(); 
$x_m9 =Array(); 
$x_ma = 0; 
$x_ct = $this->x_m3($x_6v, $x_6w); 
switch ($x_ct) { 
case 'D': 
if ($x_a9 === false){ 
$x_cq = 'select * from GET_ALL_TOP_WEBS_D(' . $x_6v . ', ' . $x_m8 . ')'; 
} else { 
$x_cq = 'select * from GET_USER_TOP_WEBS_D(' . $x_6v . ', ' . intval($x_a9) . ', ' . $x_m8 . ')'; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'WEB_ID'); 
if (!empty($x_as)) { 
$x_m9 = $x_as; 
} 
break; 
case 'AP': 
if (count($this->x_23) != 0) { 
foreach ($this->x_23 as $x_m5) { 
if ($x_a9 === false) { 
$x_cq = 'select * from GET_ALL_TOP_WEBS_AP(' . $x_m5 . ', ' . $x_m8 . ')'; 
} else { 
$x_cq = 'select * from GET_USER_TOP_WEBS_AP(' . $x_m5 . ', ' . intval($x_a9) . ', ' . $x_m8 . ')'; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'WEB_ID'); 
if (!empty($x_as)) { 
$x_m9 = $x_as; 
} 
} 
} 
break; 
case 'offer': 
$x_mb = new x_6y(); 
$x_23 = $x_mb->x_ci($x_6v, 
$x_6w); 
unset($x_mb); 
$x_5c['message'] = $x_23; 
break; 
} 
if (!empty($x_m9)) { 
foreach ($x_m9 as $x_1m => $x_1n) { 
$x_mc = ($x_1n['WEB_NAME'] != '' ? $x_1n['WEB_NAME'] : x_4a('unknown_site') . ' ' . $x_1n['WEB_ID']); 
$x_5c['data'][$x_1m] = Array('name' => $x_mc, 'value' => $x_1n['REQUESTS']); 
$x_5c['links'][] = Array('label' => x_4d($x_mc), 
'requests' => x_4p($x_1n['REQUESTS'], $x_4w->x_4r()), 
'webId' => $x_1m, 
'periodStart' => $x_6v, 
'periodEnd' => $x_6w); 
} 
} else { 
$x_5c['data'] = Array(); 
} 
return $x_5c; 
} 
function x_md($x_a9 = false) { 
$x_5c = Array(); 
if ($x_a9 !== false) { 
$x_fk = $this->x_me(Array('USER_ID', 'USERNAME', 'FULLNAME', 'EMAIL', 'DESCRIPTION', 'UUID'), 
'WHERE USER_ID = \'' . intval($x_a9) . '\'', 
'assoc'); 
$x_fk = $x_fk[0]; 
if ($x_fk != null && is_array($x_fk)) { 
if ($x_fk['FULLNAME'] != '') { 
$x_5c['FULLNAME'] = Array('caption' => '', 'value' => x_4d($x_fk['FULLNAME'])); 
} elseif ($x_fk['USERNAME'] != '') { 
$x_5c['FULLNAME'] = Array('caption' => '', 'value' => x_4d($x_fk['USERNAME'])); 
} elseif (0 == $x_a9) { 
$x_5c['FULLNAME'] = Array('caption' => '', 'value' => x_4a('notLogged_fullname')); 
$x_5c['DESCRIPTION'] = Array('caption' => '', 'value' => x_4a('notLogged_username')); 
} 
if ($x_fk['USERNAME'] != '') { 
$x_5c['USERNAME'] = Array('caption' => '<kerio:text id="lang_username" />: ', 
'value' => x_4d($x_fk['USERNAME'])); 
} 
if ($x_fk['EMAIL'] != '') { 
$x_5c['EMAIL'] = Array('caption' => '<kerio:text id="email" />: ', 'value' => x_4d($x_fk['EMAIL'])); 
} 
if ($x_fk['DESCRIPTION'] != '') { 
$x_5c['DESCRIPTION'] = Array('caption' => '<kerio:text id="description" />: ', 'value' => x_4d($x_fk['DESCRIPTION'])); 
} 
$x_5c['UUID'] = trim($x_fk['UUID']); 
$x_5c['ID'] = trim($x_a9); 
$x_5c['x_lb'] = Array('fullname' => trim($x_fk['FULLNAME']), 'username' => trim($x_fk['USERNAME'])); 
} 
} 
return $x_5c; 
} 
function x_mf($x_4w = 'en') { 
$x_5c = Array(); 
$x_as = $this->x_mg('PROTO_LIST', 
Array('PROTO_ID', 'PROTO_NAME', 'LANG'), 
'', 
$x_4w, 
'PROTO_ID'); 
$x_3u = Array(); 
foreach ($x_as as $x_7d) { 
$x_3u[$x_7d['PROTO_NAME']] = Array($x_7d['PROTO_ID'], 
$x_7d['PROTO_NAME']); 
} 
$x_f7 = array_keys($x_3u); 
$x_7x = kerio("webiface::PhpNonAuth"); 
kerio_sort($x_4w, $x_f7); 
$x_5c[] = Array('0', '-- <kerio:text id="allProtocols" /> --'); 
foreach ($x_f7 as $x_1n => $x_ec) { 
$x_5c[] = $x_3u[$x_ec]; 
} 
return $x_5c; 
} 
function x_mh($x_a9 = false, 
$x_4w = 'en', 
$x_mi = false) { 
$x_mj = Array(); 
$x_5c = Array(); 
if (!$x_mi) { 
$x_mk = Array('USER_ID', 'FULLNAME', 'USERNAME'); 
$x_ml = 'USER_ID'; 
$x_mm = true; 
} else { 
$x_mk = Array('USER_ID', 'UUID', 'FULLNAME', 'USERNAME'); 
$x_ml = 'USER_ID'; 
$x_mm = true; 
} 
$x_mj = $this->x_me($x_mk, 
'ORDER BY FULLNAME, USERNAME', 
'assoc', 
'USER_ID'); 
if (!empty($x_mj)) { 
$x_3u = Array(); 
$x_lw = x_6a(); 
$x_lz = 0; 
foreach ($x_mj as $x_en) { 
$x_m1 = x_6e('all', 
$x_en['USER_ID'], 
$x_en['USERNAME'], 
$x_en['FULLNAME'], 
false, 
false, 
0, true, 
$x_lw); 
if ($x_m1 != '' && $x_en['USER_ID'] != 0) { 
$x_3u[$x_m1 . $x_lz] = Array($x_en[$x_ml], $x_m1); 
} else if (0 == $x_en['USER_ID']){ 
$x_mn = $x_m1; 
} 
$x_lz++; 
} 
$x_mo = array_keys($x_3u); 
$x_7x = kerio("webiface::PhpNonAuth"); 
kerio_sort($x_4w, $x_mo); 
if ($x_mm) { 
$x_3u[$x_mn] = Array(0, $x_mn); 
array_push($x_mo, $x_mn); 
} 
foreach ($x_mo as $x_1n) { 
$x_5c[$x_1n] = $x_3u[$x_1n]; 
} 
if ($x_a9 === false || -1 == $x_a9) { 
$x_3s = Array('-1', ' -- <kerio:text id="please_select_user" /> -- '); 
array_unshift($x_5c, $x_3s); 
} 
} 
return $x_5c; 
} 
function x_mp($x_lr = Array(), 
$x_mq = false, 
$x_6v = 0, 
$x_6w = 0, 
$x_mr = 5, 
$x_a9 = false, 
$x_4w = '') { 
$x_ah = $x_4w->x_4r(); 
$x_5c = Array(); 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
if (!is_array($x_lr) || empty($x_lr)) { 
$x_lr = $this->x_mu($x_6v, 
$x_6w, 
$x_mr, 
$x_a9, 
$x_4w->x_8f()); 
} 
if ($x_lr != false) { 
if (false === $x_mq) { 
$x_mq = $this->x_mv( $x_6v, 
$x_6w, 
$x_a9, 
false, 
$x_ah); 
$x_mq = $x_mq['dataTotal']; 
} else { 
$x_mq = $x_mq['dataTotal']; 
} 
$x_3u = Array(); 
$x_mw = 0; 
foreach ($x_lr['data'] as $x_1n) { 
$x_3u['data'][] = Array('value' => $x_1n['dataTotal'], 'name' => $x_1n['protoName']); 
$x_3u['links'][] = Array( 'label' => $x_1n['protoName'], 
'dataTotal' => x_4p(x_4q($x_1n['dataTotal']), 
$x_ah), 
'protoId' => $x_1n['protoID']); 
$x_mw = sum64($x_mw, $x_1n['dataTotal']); 
} 
$x_mx = sub64($x_mq, $x_mw); 
if ($x_mx > 0) { 
$x_3u['links'][] = Array('label' => '<kerio:text id="otherData" />', 
'dataTotal' => x_4p(x_4q($x_mx), 
$x_ah)); 
$x_5c = Array('data' => $x_3u['data'], 
'other' => Array('value' => $x_mx, 'name' => x_4a('otherData')), 
'links' => $x_3u['links'] 
); 
} else { 
$x_5c = Array('data' => $x_3u['data'], 'other' => Array(), 'links' => $x_3u['links']); 
} 
} 
} 
return $x_5c; 
} 
function x_my($x_5t = Array(), $x_4w = 'en') { 
$x_mz = Array(); 
foreach ($x_5t as $x_a9 => $x_7d) { 
$x_mz[] = 'PROTO_ID = ' . intval($x_a9); 
} 
if (!empty($x_mz)) { 
$x_as = $this->x_mg('PROTO_LIST', 
Array('PROTO_ID', 'PROTO_NAME', 'LANG'), 
'WHERE (' . implode(' OR ', $x_mz) . ')', 
$x_4w, 
'PROTO_ID'); 
reset($x_as); 
foreach ($x_5t as $x_ko => $x_7d) { 
if ($x_as[$x_ko] && $x_as[$x_ko] != '') { 
$x_kp = $x_as[$x_ko]['PROTO_NAME']; 
} else { 
$x_kp = x_4a('unknown_protocol') . ' ' . $x_ko; 
} 
$x_5t[$x_ko]['protoName'] = $x_kp; 
} 
} 
return $x_5t; 
} 
function x_mu( $x_6v = 0, 
$x_6w = 0, 
$x_mr = 5, 
$x_a9 = false, 
$x_4w = 'en') { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
$x_cq = ''; 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	select


										      first ' . intval($x_mr) . ' PROTO_ID as "protoID",


										      SUM(DATA_TOTAL) as "dataTotal"


										from


										    PROTO_D


										where


										     (DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


										group by 1


										order by 2 desc'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	select


											      first ' . intval($x_mr) . ' PROTO_ID as "protoID",


											      SUM(DATA_TOTAL) as "dataTotal"


											from


											    PROTO_W


											where


											     (' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											group by 1


											order by 2 desc'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	select


											      first ' . intval($x_mr) . ' PROTO_M.PROTO_ID as "protoID",


											      SUM(DATA_TOTAL) as "dataTotal"


											from


											    PROTO_M


											where


											     (' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											group by 1


											order by 2 desc'; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_l9['data'] = $this->x_cs('assoc', 'protoID'); 
$x_l9['data'] = $this->x_my($x_l9['data'], $x_4w); 
if (count($x_l9) != 0) { 
return $x_l9; 
} else { 
return false; 
} 
} 
} 
function x_n1( $x_lr = Array(), 
$x_n2 = 0) { 
$x_5c = Array(); 
if (!empty($x_lr['data'])) { 
$x_3u = Array(); 
foreach ($x_lr['data'] as $x_n3 => $x_1n) { 
$x_3u[] = Array('value' => $x_1n['requestsTotal'], 
'name' => $x_1n['issName']); 
} 
$x_5c['data'] = $x_3u; 
$x_5c['links'] = $x_lr['links']; 
} 
return $x_5c; 
} 
function x_n4( $x_lr = Array(), 
$x_6v = 0, 
$x_6w = 0, 
$x_n5 = 5, 
$x_4w = '', 
$x_fh = 5, 
$x_lt = 300) { 
if (empty($x_lr)) { 
$x_lu = $this->x_n6( $x_6v, 
$x_6w, 
$x_n5, 
false, 
$x_4w); 
$x_lu = $x_lu['data']; 
} else { 
$x_lu = $x_lr['data']; 
} 
$x_5c = Array(); 
$x_7p = 0; 
$x_lw = x_6a(); 
$x_lx = x_6a(true); 
foreach ($x_lu as $x_n3 => $x_1n) { 
$x_3u = Array(); 
$x_3u['x_6u'] = $x_1n['issName']; 
$x_3u['x_ff'] = x_4p($x_1n['requestsTotal'], 
$x_4w->x_4r()); 
$x_3u['x_n7'] = x_4p( 
$this->x_n8( 
$x_n3, 
$x_6v, 
$x_6w), 
$x_4w->x_4r()); 
$x_3u['x_fe'] = $x_n3; 
$x_3u['x_fh'] = $x_fh; 
$x_3u['x_dw'] = Array('data' => Array(), 'other' => Array()); 
$x_3u['x_dx'] = Array(); 
$x_bf = Array(); 
$x_bf = $this->x_n9( $x_n3, 
$x_6v, 
$x_6w, 
$x_fh); 
$x_c2 = 0; 
$x_lz = 0; 
foreach($x_bf as $x_m0) { 
$x_m1 = x_6e( 'all', 
$x_m0['userId'], 
$x_m0['userName'], 
$x_m0['userFullname'], 
true, 
true, 
$x_lt, 
true, 
$x_lw); 
if ($x_lz < 6) { 
$x_m2 = x_6e( 'all', 
$x_m0['userId'], 
$x_m0['userName'], 
$x_m0['userFullname'], 
false, false, 0, false, $x_lx); 
$x_3u['x_dw']['data'][] = Array('value' => $x_m0['requestsTotal'], 
'name' => $x_m2); 
$x_3u['x_dw']['links'][] = Array('label' => strip_tags($x_m1), 
'requests' => x_4p($x_m0['requestsTotal'], 
$x_4w->x_4r()), 
'periodStart' => $x_6v, 
'periodEnd' => $x_6w, 
'userId' => $x_m0['userId']); 
$x_c2 = sum64($x_c2, $x_m0['requestsTotal']); 
} 
$x_3u['x_dx'][] = Array($x_m1, 
x_4p($x_m0['requestsTotal'], 
$x_4w->x_4r())); 
$x_lz++; 
} 
$x_gv = sub64($x_1n['requestsTotal'], $x_c2); 
if ($x_gv > 0) { 
$x_3u['x_dw']['other'] = Array('value' => $x_gv, 'name' => x_4a('otherData')); 
$x_3u['x_dw']['links'][] = Array ('label' => '<kerio:text id="otherData" />', 
'requests' => x_4p($x_gv, 
$x_4w->x_4r())); 
} 
unset($x_bf); 
$x_5c['tableData'][$x_7p] = $x_3u; 
$x_7p++; 
unset($x_3u); 
} 
return $x_5c; 
} 
function x_n6( $x_6v = 0, 
$x_6w = 0, 
$x_n5 = 5, 
$x_a9 = false, 
$x_4w = '') { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT


											FIRST ' . $x_n5 . ' ISS_ID as "issId",


											SUM(REQUESTS_TOTAL) as "requestsTotal"


										FROM ISS_D


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


										GROUP BY 1


										PLAN SORT((ISS_D INDEX (PK_ISS_D)))


										ORDER BY 2 DESC'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_n5 . ' ISS_ID as "issId",


												SUM(REQUESTS_TOTAL) as "requestsTotal"


											FROM ISS_W


											WHERE 


												(' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											GROUP BY 1


											PLAN SORT((ISS_W INDEX (PK_ISS_W)))


											ORDER BY 2 DESC'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_n5 . ' ISS_ID as "issId",


												SUM(REQUESTS_TOTAL) as "requestsTotal"


											FROM ISS_M


											WHERE 


												(' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											GROUP BY 1


											PLAN SORT((ISS_M INDEX (PK_ISS_M)))


											ORDER BY 2 DESC'; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'issId'); 
$x_l9 = Array(); 
$x_l9['data'] = $this->x_na($x_as, $x_4w->x_8f()); 
foreach ($x_l9['data'] as $x_7d) { 
$x_l9['links'][] = Array('label' => $x_7d['issName'], 
'requests' => x_4p($x_7d['requestsTotal'], 
$x_4w->x_4r()), 
'categoryId' => $x_7d['issId'], 
'periodStart' => $x_6v, 
'periodEnd' => $x_6w); 
} 
return $x_l9; 
} 
} 
function x_n8( $x_fe = -1, 
$x_6v = 0, 
$x_6w = 0) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms && $x_fe >= 0) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT


  											COUNT( DISTINCT(USER_ID)) as "totalRequesters"


										FROM ISS_D


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											AND ISS_D.ISS_ID = ' . $x_fe; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


      											COUNT( DISTINCT(USER_ID)) as "totalRequesters"


											FROM ISS_W


											WHERE 


												(' . $x_n0 . ')


												AND ISS_ID = ' . $x_fe; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


      											COUNT( DISTINCT(USER_ID)) as "totalRequesters"


											FROM ISS_M


											WHERE 


												(' . $x_n0 . ')


												AND ISS_ID = ' . $x_fe; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_nb = $this->x_cs('assoc'); 
return $x_nb[0]['totalRequesters']; 
} 
} 
function x_n9($x_fe = -1, 
$x_6v = 0, 
$x_6w = 0, 
$x_fh = 5) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms && $x_fe >= 0) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT


											FIRST ' . $x_fh . ' USER_ID as "userId",


											SUM(REQUESTS_TOTAL) as "requestsTotal"


										FROM ISS_D


										WHERE


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											AND ISS_ID = ' . $x_fe . '


										GROUP BY 1


										ORDER BY 2 DESC'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_fh . ' USER_ID as "userId",


												SUM(REQUESTS_TOTAL) as "requestsTotal"


											FROM ISS_W


											WHERE


												(' . $x_n0 . ')


												AND ISS_ID = ' . $x_fe . '


											GROUP BY 1


											ORDER BY 2 DESC'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_fh . ' USER_ID as "userId",


												SUM(REQUESTS_TOTAL) as "requestsTotal"


											FROM ISS_M


											WHERE


												(' . $x_n0 . ')


												AND ISS_ID = ' . $x_fe . '


											GROUP BY 1


											ORDER BY 2 DESC'; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'userId'); 
$x_as = $this->x_m6($x_as); 
return $x_as; 
} 
} 
function x_na($x_5t = Array(), $x_4w = 'en') { 
$x_mz = Array(); 
foreach ($x_5t as $x_fe => $x_7d) { 
$x_mz[] = 'ISS_ID = ' . intval($x_fe); 
} 
if (!empty($x_mz)) { 
$x_as = $this->x_nc('ISS_LIST', 
Array('ISS_ID', 'ISS_NAME', 'LANG'), 
'WHERE (' . implode(' OR ', $x_mz) . ')', 
$x_4w, 'ISS_ID'); 
reset($x_as); 
foreach ($x_5t as $x_nd => $x_7d) { 
if ($x_as[$x_nd] && $x_as[$x_nd] != '') { 
$x_ne = $x_as[$x_nd]['ISS_NAME']; 
} else { 
$x_ne = x_4a('unknown_category') . ' ' . $x_nd; 
} 
$x_5t[$x_nd]['issName'] = $x_ne; 
} 
} 
return $x_5t; 
} 
function x_nf ( $x_6v = 0, 
$x_6w = 0, 
$x_ko = 0, 
$x_ah = ',', 
$x_ng = false, 
$x_lt = 450) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
$x_ko = intval($x_ko); 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_nh = 'PROTO_D'; 
break; 
case 'W': 
$x_nh = 'PROTO_W'; 
break; 
case 'M': 
$x_nh = 'PROTO_M'; 
break; 
} 
$x_cq = '	SELECT


									USER_ID as "userId",


									SUM(DATA_TOTAL) as "dataTotal"


								FROM ' . $x_nh . '


								WHERE 


									(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


									 AND PROTO_ID = ' . $x_ko . '


								GROUP BY 1


								ORDER BY 2 DESC'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'userId'); 
return $this->x_ni($x_as, 
$x_ah, 
$x_ng, 
$x_lt, 
false, 
$x_ko); 
} 
} 
function x_nj( $x_6v = 0, 
$x_6w = 0, 
$x_ah = ',', 
$x_ng = false, 
$x_lt = 255) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT


											USER_ID as "userId",


											SUM(DATA_IN) as "dataIn",


											SUM(DATA_OUT) as "dataOut",


											SUM(DATA_TOTAL) as "dataTotal"


										FROM DATAINOUT_D


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


										GROUP BY 1


										PLAN SORT((DATAINOUT_D INDEX (PK_DATAINOUT_D)))


										ORDER BY 4 DESC'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'DATAINOUT_W.AP_ID = ' . implode(' OR DATAINOUT_W.AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												USER_ID as "userId",


												SUM(DATA_IN) as "dataIn",


												SUM(DATA_OUT) as "dataOut",


												SUM(DATA_TOTAL) as "dataTotal"


											from DATAINOUT_W join AP_LIST on AP_LIST.AP_ID = DATAINOUT_W.AP_ID


											WHERE 


												(' . $x_n0 . ')


											GROUP BY 1


											ORDER BY 4 DESC'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'DATAINOUT_M.AP_ID = ' . implode(' OR DATAINOUT_M.AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												USER_ID as "userId",


												SUM(DATA_IN) as "dataIn",


												SUM(DATA_OUT) as "dataOut",


												SUM(DATA_TOTAL) as "dataTotal"


											from DATAINOUT_M join AP_LIST on AP_LIST.AP_ID = DATAINOUT_M.AP_ID


											WHERE 


												(' . $x_n0 . ')


											GROUP BY 1


											ORDER BY 4 DESC'; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'userId'); 
return $this->x_ni($x_as, $x_ah, $x_ng, $x_lt); 
} 
} 
function x_ni($x_as = Array(), 
$x_ah = ',', 
$x_ng = false, 
$x_lt = 255, 
$x_nk = true, 
$x_ko = 0) { 
$x_as = $this->x_m6($x_as); 
$x_mw = 0; 
if (0 == $x_ko) { 
$x_nl = $this->x_mv($this->x_ln, $this->x_lo); 
} else { 
$x_nl = $this->x_nm($this->x_ln, $this->x_lo, $x_ko); 
} 
$x_mw = $x_nl['dataTotal']; 
unset($x_nl); 
$x_8j = Array(); 
$x_c2 = 0; 
$x_7p = 0; 
$x_lw = x_6a(); 
foreach($x_as as $x_1n) { 
if (0 == $x_7p) { 
$x_nn = $x_1n['dataTotal']; 
} 
if ($x_mw != 0) { 
$x_9w = x_5s(mul64($x_1n['dataTotal'],100), $x_mw); 
} else { 
$x_9w = 0; 
} 
$x_no = x_5s(mul64($x_1n['dataTotal'], 100), $x_nn); 
$x_m1 = x_6e('all', 
$x_1n['userId'], 
$x_1n['userName'], 
$x_1n['userFullname'], 
true, true, $x_lt, true, $x_lw); 
$x_9t = x_4p(x_4q($x_1n['dataIn']), 
$x_ah); 
$x_9u = x_4p(x_4q($x_1n['dataOut']), 
$x_ah); 
$x_np = x_4p(x_4q($x_1n['dataTotal']), 
$x_ah); 
if (!$x_ng) { 
if ($x_nk) { 
$x_8j[] = Array( $x_m1, 
$x_9t, 
$x_9u, 
$x_np, 
round($x_no, 2), 
round($x_9w, 2)); 
} else { 
$x_8j[] = Array( $x_m1, 
$x_np, 
round($x_no, 2), 
round($x_9w, 2)); 
} 
} else { 
if ($x_nk) { 
$x_8j[] = Array( $x_7p+1, 
$x_m1, 
$x_9t, 
$x_9u, 
$x_np, 
round($x_9w, 2), 
round($x_no, 2)); 
} else { 
$x_8j[] = Array( $x_7p+1, 
$x_m1, 
$x_np, 
round($x_9w, 2), 
round($x_no, 2)); 
} 
} 
$x_7p++; 
} 
return $x_8j; 
} 
function x_nm( $x_6v = 0, 
$x_6w = 0, 
$x_ko = 0) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT 


											SUM(DATA_TOTAL) AS "dataTotal" 


										FROM PROTO_D 


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT 


												SUM(DATA_TOTAL) AS "dataTotal" 


											FROM PROTO_W 


											WHERE 


												(' . $x_n0 . ')'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT 


												SUM(DATA_TOTAL) AS "dataTotal" 


											FROM PROTO_M 


											WHERE 


												(' . $x_n0 . ')'; 
} 
break; 
} 
$x_cq .= ' AND PROTO_ID = ' . $x_ko; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (!empty($x_as[0])) { 
return $x_as[0]; 
} else { 
return Array('dataTotal' => 0); 
} 
} 
} 
function x_nq( $x_lr = Array(), 
$x_mq = false, 
$x_kn = 5, 
$x_6v = 0, 
$x_6w = 0, 
$x_ah = ',') { 
$x_5c = Array(); 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
if (!is_array($x_lr) || empty($x_lr)) { 
$x_lr = $this->x_nr($x_6v, $x_6w, $x_kn, false, $x_ah); 
} 
if (false === $x_mq) { 
$x_mq = $this->x_mv($x_6v, $x_6w, 0, false, $x_ah); 
} 
$x_3u = Array(); 
$x_mw = 0; 
if (!empty($x_lr['data'])) { 
foreach ($x_lr['data'] as $x_69 => $x_1n) { 
$x_3u[] = Array('value' => $x_1n[1], 'name' => $x_lr['links'][$x_69]['user']); 
$x_mw = sum64($x_mw, $x_1n[1]); 
} 
$x_mx = sub64($x_mq, $x_mw); 
if (!empty($x_3u)) { 
$x_5c = Array( 'data' => $x_3u, 
'other' => Array( 'value' => $x_mx, 
'name' => x_4a('otherData')), 
'links' => $x_lr['links'] 
); 
$x_5c['links'][] = Array ('label' => '<kerio:text id="otherData" />', 
'dataTotal' => x_4p(x_4q($x_mx), 
$x_ah)); 
} 
} 
} 
return $x_5c; 
} 
function x_nr($x_6v = 0, 
$x_6w = 0, 
$x_fh = 5, 
$x_ns = true, 
$x_ah = ',', 
$x_lt = 237 
) { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
$x_cq = ''; 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT


											FIRST ' . $x_fh . ' USER_ID as "userId",


											SUM(DATA_TOTAL) as "dataTotal",


											SUM(DATA_IN) as "dataIn",


											SUM(DATA_OUT) as "dataOut"


										FROM DATAINOUT_D


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


										GROUP BY 1


										PLAN SORT((DATAINOUT_D INDEX (PK_DATAINOUT_D)))


										ORDER BY 2 DESC'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_fh . ' USER_ID as "userId",


												SUM(DATA_TOTAL) as "dataTotal",


												SUM(DATA_IN) as "dataIn",


												SUM(DATA_OUT) as "dataOut"


											FROM DATAINOUT_W


											WHERE 


												(' . $x_n0 . ')


											GROUP BY 1


											PLAN SORT((DATAINOUT_W INDEX (PK_DATAINOUT_W)))


											ORDER BY 2 DESC'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


												FIRST ' . $x_fh . ' USER_ID as "userId",


												SUM(DATA_TOTAL) as "dataTotal",


												SUM(DATA_IN) as "dataIn",


												SUM(DATA_OUT) as "dataOut"


											FROM DATAINOUT_M


											WHERE 


												(' . $x_n0 . ')


											GROUP BY 1


											PLAN SORT((DATAINOUT_M INDEX (PK_DATAINOUT_M)))


											ORDER BY 2 DESC'; 
} 
break; 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'userId'); 
$x_as = $this->x_m6($x_as); 
$x_8j = Array(); 
$x_lw = x_6a(); 
$x_lx = x_6a(true); 
foreach($x_as as $x_1n) { 
$x_m1 = x_6e( 'all', 
$x_1n['userId'], 
$x_1n['userName'], 
$x_1n['userFullname'], 
false, 
true, 
$x_lt, 
true, 
$x_lw, 
false); 
$x_m2 = x_6e( 'all', 
$x_1n['userId'], 
$x_1n['userName'], 
$x_1n['userFullname'], 
false, false, 0, false, $x_lx); 
if (true === $x_ns) { 
$x_8j['data'][] = Array( $x_m1, x_4p($x_1n['dataTotal'], 
$x_ah)); 
} else { 
$x_8j['data'][] = Array($x_m1, $x_1n['dataTotal']); 
} 
$x_8j['links'][] = Array('periodStart' => $x_6v, 
'periodEnd' => $x_6w, 
'userId' => $x_1n['userId'], 
'label' => strip_tags($x_m1), 
'user' => strip_tags($x_m2), 
'dataIn' => x_4p(x_4q($x_1n['dataIn']), 
$x_ah), 
'dataOut' => x_4p(x_4q($x_1n['dataOut']), 
$x_ah), 
'dataTotal' => x_4p(x_4q($x_1n['dataTotal']), 
$x_ah) 
); 
} 
return $x_8j; 
} 
} 
function x_m6($x_5t = Array()) { 
$x_mz = Array(); 
foreach ($x_5t as $x_a9 => $x_7d) { 
$x_mz[] = 'USER_ID = ' . intval($x_a9); 
} 
if (!empty($x_mz)) { 
$x_as = $this->x_me(Array('USER_ID', 'FULLNAME', 'USERNAME'), 'WHERE (' . implode(' OR ', $x_mz) . ')', 'assoc', 'USER_ID'); 
reset($x_as); 
foreach ($x_5t as $x_a9 => $x_en) { 
if ($x_as[$x_a9] && $x_as[$x_a9] != '') { 
$x_nt = $x_as[$x_a9]['FULLNAME']; 
$x_28 = $x_as[$x_a9]['USERNAME']; 
} else { 
$x_nt = x_4a('unknown_user') . ' ' . $x_a9; 
$x_28 = x_4a('unknown_user') . ' ' . $x_a9; 
} 
$x_5t[$x_a9]['userFullname'] = $x_nt; 
$x_5t[$x_a9]['userName'] = $x_28; 
} 
} 
return $x_5t; 
} 
function x_nu($x_6v = 0, 
$x_6w = 0, 
$x_a9 = false, 
$x_4w = '') { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
$x_5c = Array(); 
switch ($x_ms) { 
case 'H': 
$x_cq = '	SELECT


									    	sum(DATA_TOTAL) as "dataTotal",


									    	DAY_NUM as "dayNum",


									    	HOUR_NUM as "hourNum",


      										((DAY_NUM * 100) + HOUR_NUM) as "timestamp",


      										sum(DATA_IN) as "dataIn",


      										sum(DATA_OUT) as "dataOut"


										from DATAINOUT_H


										WHERE


										     (DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '										     


										GROUP BY 2, 3


										ORDER BY 2, 3'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'timestamp'); 
if (!empty($x_as)) { 
$x_9r = 0; 
$x_3u = Array(); 
$x_nv = $x_4w->x_nw(); 
for ($x_7p = $this->x_ln; $x_7p <= $this->x_lo; $x_7p++) { 
for ($x_9r = 0; $x_9r < 24; $x_9r++) { 
$x_nx = (($x_7p * 100) + $x_9r); 
$x_3u[$x_nx] = Array(); 
$x_64 = ($x_7p * 24); 
$x_3u[$x_nx]['start'] = gmDate($x_nv, (($x_64 + $x_9r) * (60 * 60))); 
$x_3u[$x_nx]['end'] = gmDate($x_nv, (($x_64 + $x_9r + 1) * (60 * 60))); 
} 
} 
foreach($x_3u as $x_7r => $x_ny) { 
$x_np = ($x_as[$x_7r]['dataTotal'] ? $x_as[$x_7r]['dataTotal'] : 0); 
$x_9t = ($x_as[$x_7r]['dataIn'] ? $x_as[$x_7r]['dataIn'] : 0); 
$x_9u = ($x_as[$x_7r]['dataOut'] ? $x_as[$x_7r]['dataOut'] : 0); 
$x_5c['data'][] = Array( 
'value' => $x_np, 
'name' => $x_ny['start']); 
$x_5c['links'][] = Array( 'dataTotal' => x_4p(x_4q($x_np), 
$x_4w->x_4r()), 
'dataIn' => x_4p(x_4q($x_9t), 
$x_4w->x_4r()), 
'dataOut' => x_4p(x_4q($x_9u), 
$x_4w->x_4r()), 
'label' => $x_ny['start'] . ' - ' . $x_ny['end']); 
} 
} else { 
$x_5c = Array(); 
} 
break; 
case 'D': 
$x_cq = '	SELECT


									    	sum(DATA_TOTAL) as "dataTotal",


									    	DAY_NUM as "dayNum",


      										sum(DATA_IN) as "dataIn",


      										sum(DATA_OUT) as "dataOut"


										from DATAINOUT_D


										WHERE


										     (DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')


											' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


										GROUP BY 2


										ORDER BY 2'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'dayNum'); 
if (!empty($x_as)) { 
$x_9r = 0; 
$x_3u = Array(); 
for ($x_7p = $this->x_ln; $x_7p <= $this->x_lo; $x_7p++) { 
$x_3u[$x_7p] = $x_7p; 
} 
$x_7n = 'j'; 
foreach($x_3u as $x_7u) { 
$x_np = ($x_as[$x_7u]['dataTotal'] ? $x_as[$x_7u]['dataTotal'] : 0); 
$x_9t = ($x_as[$x_7u]['dataIn'] ? $x_as[$x_7u]['dataIn'] : 0); 
$x_9u = ($x_as[$x_7u]['dataOut'] ? $x_as[$x_7u]['dataOut'] : 0); 
$x_5c['data'][] = Array('value' => $x_np, 
'name' => kp_getDate($x_7u, $x_7n)); 
$x_5c['links'][] = Array( 'periodStart' => $x_7u, 
'periodEnd' => $x_7u, 
'userId' => intval($x_a9), 
'dataIn' => x_4p(x_4q($x_9t), 
$x_4w->x_4r()), 
'dataOut' => x_4p(x_4q($x_9u), 
$x_4w->x_4r()), 
'dataTotal' => x_4p(x_4q($x_np), 
$x_4w->x_4r()), 
'label' => kp_getDate($x_7u, 
$x_4w->x_34()) 
); 
} 
} else { 
$x_5c = Array(); 
} 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'DATAINOUT_W.AP_ID = ' . implode(' OR DATAINOUT_W.AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


										    	sum(DATA_TOTAL) as "dataTotal",


												DATAINOUT_W.AP_ID as "apId",


												AP_BEGIN as "apBegin",


												AP_END as "apEnd",


      											sum(DATA_IN) as "dataIn",


      											sum(DATA_OUT) as "dataOut"


											from DATAINOUT_W join AP_LIST on AP_LIST.AP_ID = DATAINOUT_W.AP_ID


											WHERE


											     (' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											GROUP BY 2, 3, 4


											ORDER BY 3'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (!empty($x_as)) { 
if ($x_as[0]['apBegin'] > $x_6v) { 
$x_nz = $x_as[0]['apBegin'] - 1; 
$x_o0 = 0; 
$x_3u = Array(); 
$x_7p = 1; 
do { 
$x_o0 = $x_nz - 6; 
$x_3u = Array('dataTotal' => 0, 'apBegin' => $x_o0, 'apEnd' => $x_nz); 
array_unshift($x_as, $x_3u); 
$x_nz = $x_o0 - 1; 
$x_7p++; 
} while ($x_o0 >= $x_6v && $x_7p <= 260); 
} 
$x_o1 = count($x_as) - 1; 
if ($x_as[$x_o1]['apEnd'] < $x_6w) { 
$x_o0 = $x_as[$x_o1]['apEnd'] + 1; 
$x_nz = 0; 
$x_3u = Array(); 
$x_7p = 1; 
do { 
$x_nz = $x_o0 + 6; 
$x_3u = Array('dataTotal' => 0, 'apBegin' => $x_o0, 'apEnd' => $x_nz); 
array_push($x_as, $x_3u); 
$x_o0 = $x_nz + 1; 
$x_7p++; 
} while ($x_nz <= $x_6w && $x_7p <= 260); 
} 
foreach($x_as as $x_7u) { 
$x_5c['data'][] = Array('value' => $x_7u['dataTotal'], 
'name' => kp_getDate($x_7u['apBegin'], $x_4w->x_d5(), true)); 
$x_5c['links'][] = Array( 'periodStart' => $x_7u['apBegin'], 
'periodEnd' => $x_7u['apEnd'], 
'userId' => intval($x_a9), 
'dataTotal' => x_4p(x_4q($x_7u['dataTotal']), 
$x_4w->x_4r()), 
'dataIn' => x_4p(x_4q($x_7u['dataIn']), 
$x_4w->x_4r()), 
'dataOut' => x_4p(x_4q($x_7u['dataOut']), 
$x_4w->x_4r()), 
'label' => kp_getDate($x_7u['apBegin'], $x_4w->x_34()) 
. ' - ' . kp_getDate($x_7u['apEnd'], $x_4w->x_34())); 
} 
} else { 
$x_5c = Array(); 
} 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'DATAINOUT_M.AP_ID = ' . implode(' OR DATAINOUT_M.AP_ID = ', $this->x_23); 
$x_cq = '	SELECT


										    	sum(DATA_TOTAL) as "dataTotal",


												DATAINOUT_M.AP_ID as "apId",


												AP_BEGIN as "apBegin",


												AP_END as "apEnd",


      											sum(DATA_IN) as "dataIn",


      											sum(DATA_OUT) as "dataOut"


											from DATAINOUT_M join AP_LIST on AP_LIST.AP_ID = DATAINOUT_M.AP_ID


											WHERE


											     (' . $x_n0 . ')


												' . ($x_a9 === false ? '' : ' AND USER_ID = ' . intval($x_a9)) . '


											GROUP BY 2, 3, 4


											ORDER BY 3'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (!empty($x_as)) { 
if ($x_as[0]['apBegin'] > $x_6v) { 
$x_o2 = kp_getDate($x_as[0]['apBegin'], 'j'); 
if (1 == $x_o2) { 
$x_o3 = 0; 
} else { 
$x_o3 = $x_o2; 
} 
$x_7v = kp_getDate($x_as[0]['apBegin'], 'n'); 
$x_7w = kp_getDate($x_as[0]['apBegin'], 'Y'); 
$x_o0 = kp_getDay(mktime(12, 0, 0, 
$x_7v - 1, 
$x_o2, 
$x_7w 
) 
); 
$x_3u = Array(); 
$x_7p = 1; 
do { 
$x_nz = kp_getDay(mktime(12, 0, 0, 
$x_7v, 
(0 == $x_o3 ? $x_o3 : $x_o3 -1 ), 
$x_7w 
) 
); 
$x_3u = Array('dataTotal' => 0, 'apBegin' => $x_o0, 'apEnd' => $x_nz); 
array_unshift($x_as, $x_3u); 
$x_7w = kp_getDate($x_o0, 'Y'); 
$x_7v = $x_7v - 1; 
if ($x_7v < 1) { 
$x_7v = 12; 
} 
$x_o0 = kp_getDay(mktime(12, 0, 0, 
$x_7v - 1, 
$x_o2, 
$x_7w 
) 
); 
$x_7p++; 
} while ($x_o0 >= $x_6v && $x_7p <= 62); 
} 
$x_o1 = count($x_as)-1; 
if ($x_as[$x_o1]['apEnd'] < $x_6w) { 
$x_o2 = kp_getDate($x_as[$x_o1]['apStart'], 'j'); 
if (1 == $x_o2) { 
$x_o3 = 0; 
} else { 
$x_o3 = $x_o2; 
} 
$x_7v = kp_getDate($x_as[$x_o1]['apBegin'], 'n') + 1; 
$x_7w = kp_getDate($x_as[$x_o1]['apBegin'], 'Y'); 
if ($x_7v > 12) { 
$x_7v = 1; 
$x_7w++; 
} 
$x_o0 = kp_getDay(mktime(1, 1, 1, 
$x_7v, 
$x_o2, 
$x_7w 
) 
); 
$x_3u = Array(); 
$x_7p = 1; 
do { 
$x_nz = kp_getDay(mktime(0, 0, 0, 
$x_7v + 1, 
(0 == $x_o3 ? $x_o3 : $x_o3 + 1 ), 
$x_7w 
) 
); 
$x_3u = Array('dataTotal' => 0, 'apBegin' => $x_o0, 'apEnd' => $x_nz); 
array_push($x_as, $x_3u); 
$x_7w = kp_getDate($x_nz, 'Y'); 
$x_7v = $x_7v + 1; 
if ($x_7v > 12) { 
$x_7v = 1; 
$x_7w++; 
} 
$x_o0 = kp_getDay(mktime(1, 1, 1, 
$x_7v, 
$x_o2, 
$x_7w 
) 
); 
$x_7p++; 
} while ($x_nz <= $x_6w && $x_7p <= 62); 
} 
foreach($x_as as $x_7u) { 
$x_5c['data'][] = Array('value' => $x_7u['dataTotal'], 
'name' => kp_getDate($x_7u['apBegin'], $x_4w->x_d5(), true)); 
$x_5c['links'][] = Array( 'periodStart' => $x_7u['apBegin'], 
'periodEnd' => $x_7u['apEnd'], 
'userId' => intval($x_a9), 
'dataTotal' => x_4p(x_4q($x_7u['dataTotal']), 
$x_4w->x_4r()), 
'dataIn' => x_4p(x_4q($x_7u['dataIn']), 
$x_4w->x_4r()), 
'dataOut' => x_4p(x_4q($x_7u['dataOut']), 
$x_4w->x_4r()), 
'label' => kp_getDate($x_7u['apBegin'], 
$x_4w->x_34()) 
. ' - ' . kp_getDate($x_7u['apEnd'], 
$x_4w->x_34())); 
} 
} else { 
$x_5c = Array(); 
} 
} 
break; 
} 
} 
return ($x_5c); 
} 
function x_mv( $x_6v = 0, 
$x_6w = 0, 
$x_a9 = false, 
$x_ns = false, 
$x_ah = '') { 
$x_ms = $this->x_mt($x_6v, $x_6w); 
if ($x_ms) { 
switch ($x_ms) { 
case 'H': 
case 'D': 
$x_cq = '	SELECT 


											SUM(DATA_IN) AS "dataIn", 


											SUM(DATA_OUT) AS "dataOut", 


											SUM(DATA_TOTAL) AS "dataTotal" 


										FROM DATAINOUT_D 


										WHERE 


											(DAY_NUM >= ' . $this->x_ln . ' AND DAY_NUM <= ' . $this->x_lo . ')'; 
break; 
case 'W': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT 


												SUM(DATA_IN) AS "dataIn", 


												SUM(DATA_OUT) AS "dataOut", 


												SUM(DATA_TOTAL) AS "dataTotal" 


											FROM DATAINOUT_W 


											WHERE 


												(' . $x_n0 . ')'; 
} 
break; 
case 'M': 
if (count($this->x_23) != 0) { 
$x_n0 = 'AP_ID = ' . implode(' OR AP_ID = ', $this->x_23); 
$x_cq = '	SELECT 


												SUM(DATA_IN) AS "dataIn", 


												SUM(DATA_OUT) AS "dataOut", 


												SUM(DATA_TOTAL) AS "dataTotal" 


											FROM DATAINOUT_M 


											WHERE 


												(' . $x_n0 . ')'; 
} 
break; 
} 
if ($x_a9 !== false) { 
$x_cq .= ' AND USER_ID = ' . intval($x_a9); 
} 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (true === $x_ns && !empty($x_as[0])) { 
foreach ($x_as[0] as $x_69 => $x_1n) { 
$x_as[0][$x_69] = x_4p(x_4q($x_1n), $x_ah); 
} 
} 
if (!empty($x_as[0])) { 
return $x_as[0]; 
} else { 
return Array('dataIn' => 0, 'dataOut' => 0, 'dataTotal' => 0); 
} 
} 
} 
function x_mt($x_6v = 0, $x_6w = 0) { 
if (0 == $x_6v || 0 == $x_6w) { 
return false; 
} else { 
$x_bt = $x_6w - $x_6v; 
$x_bt += 1; 
if ($x_bt >= 0 && $x_bt <= 2) { 
$this->x_lp = $x_bt; 
$this->x_ln = $x_6v; 
$this->x_lo = $x_6w; 
return 'H'; 
} elseif ($x_bt >= 3 && $x_bt <= 34) { 
$this->x_lp = $x_bt; 
$this->x_ln = $x_6v; 
$this->x_lo = $x_6w; 
return 'D'; 
} elseif ($x_bt >= 35 && $x_bt <= 179) { 
$this->x_lp = $x_bt; 
$x_mb = new x_6y(); 
$x_23 = Array(); 
$x_23 = $x_mb->x_dd($x_6v, $x_6w, 'W'); 
$this->x_23 = $x_23; 
return 'W'; 
} elseif ($x_bt >= 180 && $x_bt <= 1800) { 
$this->x_lp = $x_bt; 
$x_mb = new x_6y(); 
$x_cr = Array(); 
$x_cr = $x_mb->x_dd($x_6v, $x_6w, 'M'); 
$this->x_23 = $x_cr; 
return 'M'; 
} else { 
return false; 
} 
} 
} 
function x_nc($x_o4 = '', $x_mk = Array(), $x_mz = '', $x_4w = 'en', $x_dp = false) { 
$x_mk = $this->x_o5($x_o4, $x_mk); 
if(!empty($x_mk)) { 
$x_o6 = 'LANG=\'' . $this->x_5t($x_4w) . '\''; 
if ($x_4w != 'en') { 
$x_o6 = '(' . $x_o6 . ' OR LANG=\'en\')'; 
} 
$x_mk[] = 'ISS_ID || LANG as LANG_STAMP'; 
$x_cq = 'SELECT ' 
. implode(', ', $x_mk) 
. ' FROM ' . $x_o4 . ' ' 
. ($x_mz != '' ? $x_mz : '') 
. ($x_mz != '' ? ' AND ' : ' WHERE ') . $x_o6; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'LANG_STAMP'); 
$x_5c = Array(); 
if (count($x_as) != 0) { 
foreach ($x_as as $data) { 
if (!isset($x_5c[$data['ISS_ID']])) { 
$x_5c[$data['ISS_ID']] = Array('ISS_ID' => $data['ISS_ID'], 
'ISS_NAME' => $data['ISS_NAME'], 
'LANG' => $data['LANG'] 
); 
} else if ($x_4w == trim($data['LANG'])){ 
$x_5c[$data['ISS_ID']] = Array('ISS_ID' => $data['ISS_ID'], 
'ISS_NAME' => $data['ISS_NAME'], 
'LANG' => $data['LANG'] 
); 
} 
} 
} 
return $x_5c; 
} else { 
return false; 
} 
} 
function x_mg( $x_o4 = '', 
$x_mk = Array(), 
$x_mz = '', 
$x_4w = 'en', 
$x_dp = false) { 
$x_mk = $this->x_o5($x_o4, $x_mk); 
if(!empty($x_mk)) { 
$x_o6 = 'LANG=\'' . $this->x_5t($x_4w) . '\''; 
if ($x_4w != 'en') { 
$x_o6 = '(' . $x_o6 . ' OR LANG=\'en\')'; 
} 
$x_mk[] = 'PROTO_ID || LANG as LANG_STAMP'; 
$x_cq = 'SELECT ' 
. implode(', ', $x_mk) 
. ' FROM ' . $x_o4 . ' ' 
. ($x_mz != '' ? $x_mz : '') 
. ($x_mz != '' ? ' AND ' : ' WHERE ') . $x_o6; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc', 'LANG_STAMP'); 
$x_5c = Array(); 
if (count($x_as) != 0) { 
foreach ($x_as as $data) { 
if (!isset($x_5c[$data['PROTO_ID']])) { 
$x_5c[$data['PROTO_ID']] = Array('PROTO_ID' => $data['PROTO_ID'], 
'PROTO_NAME' => $data['PROTO_NAME'], 
'LANG' => $data['LANG'] 
); 
} else if ($x_4w == trim($data['LANG'])){ 
$x_5c[$data['PROTO_ID']] = Array('PROTO_ID' => $data['PROTO_ID'], 
'PROTO_NAME' => $data['PROTO_NAME'], 
'LANG' => $data['LANG'] 
); 
} 
} 
} 
return $x_5c; 
} else { 
return false; 
} 
} 
function x_me($x_mk = Array(), 
$x_o7 = '', 
$x_g2 = 'index', 
$x_dp = false) { 
$x_mk = $this->x_o5('USER_LIST', $x_mk); 
if(!empty($x_mk)) { 
$x_cq = 'SELECT ' . implode(', ', $x_mk) . ' FROM USER_LIST' . ($x_o7 != '' ? ' ' . $x_o7 : '') . ';'; 
$this->x_cc($x_cq); 
return $this->x_cs($x_g2, $x_dp); 
} else { 
return false; 
} 
} 
function x_o5($x_o4 = '', $x_mk) { 
if (empty($x_mk) || !is_array($x_mk)) { 
$x_mk = $this->x_lm[$x_o4]; 
} else { 
$x_3u = Array(); 
foreach($x_mk as $x_o8) { 
if (in_array($x_o8, $this->x_lm[$x_o4])) { 
$x_3u[] = $x_o8; 
} 
} 
$x_mk = $x_3u; 
} 
return $x_mk; 
} 
function x_5t($x_51 = '') { 
return addslashes($x_51); 
} 
function getDbValue($x_ec = '') { 
$x_5c = ''; 
if ($x_ec != '') { 
$x_cq = 'SELECT VAR_VALUE FROM MISC WHERE VAR_NAME=\'' . $x_ec . '\''; 
$this->x_cc($x_cq); 
$x_5c = $this->x_cs('index'); 
$x_5c = $x_5c[0][0]; 
} 
return $x_5c; 
} 
function x_cd($x_4w = '') { 
$x_cq = 'SELECT ISS_ID, ISS_NAME FROM ISS_LIST WHERE LANG=\'' . $x_4w . '\''; 
$this->x_cc($x_cq); 
$x_5c = $this->x_cs('assoc', 'ISS_ID'); 
return $x_5c; 
} 
} 
?>
