function zb_AjaxOnlineDataSource() { // Speed debug // $mtime = microtime(); // $mtime = explode(" ",$mtime); // $mtime = $mtime[1] + $mtime[0]; // $starttime = $mtime; global $alter_conf; $query = "SELECT * from `users`"; $query_fio = "SELECT * from `realname`"; $allusers = simple_queryall($query); $allfioz = simple_queryall($query_fio); $fioz = zb_UserGetAllRealnames(); $detect_address = zb_AddressGetFulladdresslist(); $ucount = 0; $deadUsers = array(); //alternate view of online module $addrDelimiter = ''; if (isset($alter_conf['ONLINE_ALTERNATE_VIEW'])) { if ($alter_conf['ONLINE_ALTERNATE_VIEW']) { $addrDelimiter = wf_tag('br'); } } //hide dead users array if ($alter_conf['DEAD_HIDE']) { if (!empty($alter_conf['DEAD_TAGID'])) { $tagDead = vf($alter_conf['DEAD_TAGID'], 3); $query_dead = "SELECT `login`,`tagid` from `tags` WHERE `tagid`='" . $tagDead . "'"; $alldead = simple_queryall($query_dead); if (!empty($alldead)) { foreach ($alldead as $idead => $eachDead) { $deadUsers[$eachDead['login']] = $eachDead['tagid']; } } } } $result = '{'; $result .= ' "aaData": [ '; if (!empty($allusers)) { $totalusers = sizeof($allusers); foreach ($allusers as $io => $eachuser) { $tinet = 0; $ucount++; $cash = $eachuser['Cash']; $credit = $eachuser['Credit']; for ($classcounter = 0; $classcounter <= 9; $classcounter++) { $dc = 'D' . $classcounter . ''; $uc = 'U' . $classcounter . ''; $tinet = $tinet + ($eachuser[$dc] + $eachuser[$uc]); } $act = '<img src=skins/icon_active.gif>' . __('Yes'); //finance check if ($cash < '-' . $credit) { $act = '<img src=skins/icon_inactive.gif>' . __('No'); } //online activity check if ($alter_conf['DN_ONLINE_DETECT']) { $onlineFlag = '"<img src=skins/icon_nostar.gif> ' . __('No') . '",'; if (file_exists(DATA_PATH . 'dn/' . $eachuser['login'])) { $onlineFlag = '"<img src=skins/icon_star.gif> ' . __('Yes') . '",'; } } else { $onlineFlag = ''; } @($clearuseraddress = $detect_address[$eachuser['login']]); $clearuseraddress = trim($clearuseraddress); $clearuseraddress = str_replace("'", '`', $clearuseraddress); $clearuseraddress = mysql_real_escape_string($clearuseraddress); //additional finance links if ($alter_conf['FAST_CASH_LINK']) { $fastcashlink = ' <a href=?module=addcash&username='******'login'] . '#profileending><img src=skins/icon_dollar.gif border=0></a> '; } else { $fastcashlink = ''; } if (!$alter_conf['DEAD_HIDE']) { $result .= ' [ "<a href=?module=traffstats&username='******'login'] . '><img src=skins/icon_stats.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username='******'login'] . '><img src=skins/icon_user.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $addrDelimiter . $clearuseraddress . '", "' . @mysql_real_escape_string(trim($fioz[$eachuser['login']])) . '", "' . $eachuser['IP'] . '", "' . $eachuser['Tariff'] . '", "' . $act . '", ' . $onlineFlag . ' "' . zb_TraffToGb($tinet) . '", "' . round($eachuser['Cash'], 2) . '", "' . round($eachuser['Credit'], 2) . '" ],'; } else { if (!isset($deadUsers[$eachuser['login']])) { $result .= ' [ "<a href=?module=traffstats&username='******'login'] . '><img src=skins/icon_stats.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username='******'login'] . '><img src=skins/icon_user.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $clearuseraddress . '", "' . @mysql_real_escape_string(trim($fioz[$eachuser['login']])) . '", "' . $eachuser['IP'] . '", "' . $eachuser['Tariff'] . '", "' . $act . '", ' . $onlineFlag . ' "' . zb_TraffToGb($tinet) . '", "' . round($eachuser['Cash'], 2) . '", "' . round($eachuser['Credit'], 2) . '" ],'; } } } } $result = substr($result, 0, -1); $result .= ' ] } '; print $result; // $mtime = microtime(); // $mtime = explode(" ",$mtime); // $mtime = $mtime[1] + $mtime[0]; // $endtime = $mtime; // $totaltime = ($endtime - $starttime); // echo "This result generated in ".$totaltime." seconds"; die; }
/** * Renders json data for user list * * @global array $alter_conf * * @return string */ function zb_AjaxOnlineDataSourceSafe() { global $alter_conf; $query = "SELECT * from `users`"; $query_fio = "SELECT * from `realname`"; $allusers = simple_queryall($query); $allfioz = simple_queryall($query_fio); $fioz = zb_UserGetAllRealnames(); $detect_address = zb_AddressGetFulladdresslist(); $ucount = 0; $deadUsers = array(); //alternate view of online module $addrDelimiter = ''; if (isset($alter_conf['ONLINE_ALTERNATE_VIEW'])) { if ($alter_conf['ONLINE_ALTERNATE_VIEW']) { $addrDelimiter = wf_tag('br'); } } //hide dead users array if ($alter_conf['DEAD_HIDE']) { if (!empty($alter_conf['DEAD_TAGID'])) { $tagDead = vf($alter_conf['DEAD_TAGID'], 3); $query_dead = "SELECT `login`,`tagid` from `tags` WHERE `tagid`='" . $tagDead . "'"; $alldead = simple_queryall($query_dead); if (!empty($alldead)) { foreach ($alldead as $idead => $eachDead) { $deadUsers[$eachDead['login']] = $eachDead['tagid']; } } } } $jsonAAData = array(); if (!empty($allusers)) { $totalusers = sizeof($allusers); foreach ($allusers as $io => $eachuser) { $tinet = 0; $ucount++; $cash = $eachuser['Cash']; $credit = $eachuser['Credit']; for ($classcounter = 0; $classcounter <= 9; $classcounter++) { $dc = 'D' . $classcounter . ''; $uc = 'U' . $classcounter . ''; $tinet = $tinet + ($eachuser[$dc] + $eachuser[$uc]); } $act = '<img src=skins/icon_active.gif>' . __('Yes'); //finance check if ($cash < '-' . $credit) { $act = '<img src=skins/icon_inactive.gif>' . __('No'); } //online activity check if ($alter_conf['DN_ONLINE_DETECT']) { $onlineFlag = '<img src=skins/icon_nostar.gif> ' . __('No'); if (file_exists(DATA_PATH . 'dn/' . $eachuser['login'])) { $onlineFlag = '<img src=skins/icon_star.gif> ' . __('Yes'); } } else { $onlineFlag = ''; } @($clearuseraddress = $detect_address[$eachuser['login']]); //additional finance links if ($alter_conf['FAST_CASH_LINK']) { $fastcashlink = ' <a href=?module=addcash&username='******'login'] . '#profileending><img src=skins/icon_dollar.gif border=0></a> '; } else { $fastcashlink = ''; } if (!$alter_conf['DEAD_HIDE']) { $jsonItem = array(); $jsonItem[] = '<a href=?module=traffstats&username='******'login'] . '><img src=skins/icon_stats.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username='******'login'] . '><img src=skins/icon_user.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $addrDelimiter . $clearuseraddress; $jsonItem[] = @$fioz[$eachuser['login']]; $jsonItem[] = $eachuser['IP']; $jsonItem[] = $eachuser['Tariff']; $jsonItem[] = $act; if (!empty($onlineFlag)) { $jsonItem[] = $onlineFlag; } $jsonItem[] = zb_TraffToGb($tinet); $jsonItem[] = "" . round($eachuser['Cash'], 2); $jsonItem[] = "" . round($eachuser['Credit'], 2); $jsonAAData[] = $jsonItem; } else { if (!isset($deadUsers[$eachuser['login']])) { $jsonItem = array(); $jsonItem[] = '<a href=?module=traffstats&username='******'login'] . '><img src=skins/icon_stats.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username='******'login'] . '><img src=skins/icon_user.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $clearuseraddress; $jsonItem[] = @$fioz[$eachuser['login']]; $jsonItem[] = $eachuser['IP']; $jsonItem[] = $eachuser['Tariff']; $jsonItem[] = $act; if (!empty($onlineFlag)) { $jsonItem[] = $onlineFlag; } $jsonItem[] = zb_TraffToGb($tinet); $jsonItem[] = "" . round($eachuser['Cash'], 2); $jsonItem[] = "" . round($eachuser['Credit'], 2); $jsonAAData[] = $jsonItem; } } } } $result = array("aaData" => $jsonAAData); return json_encode($result); }