0,((st._hclk+tmp._clk)*100)/(st._hout+tmp._out),100) as tr_kpd,
if (st._hout-tmp._force < 0,100,((st._hout+tmp._out)*100)/(st._huin+tmp._uin)) as my_back,
if (st._hout-tmp._force < 0,1,0) as is_force
,st._huin+tmp._uin as in_
,st._hout+tmp._out as out_
,st._hclk+tmp._clk as clk_
from tm_cj_stats st, tm_cj_tmpst tmp, tm_cj_traders tr
where st.tid=tmp.tid and st.tid=tr.tid
and tr._status='on'
and st.tid > 4
order by in_ desc, out_ desc";
$v_30=mysql_query($v_32) or print mysql_error();
$v_51=mysql_num_rows($v_30);
$v_168=implode('',file('./faces/tpl.top.html'));
for ($v_24=0;$v_24<$v_51;$v_24++) {
$v_169=$v_24+1;
$v_168=str_replace("{TRADER_URL_".$v_169."}",mysql_result($v_30,$v_24,'_url'),$v_168);
$v_168=str_replace("{TRADER_DOMAIN_".$v_169."}",mysql_result($v_30,$v_24,'_domain'),$v_168);
$v_168=str_replace("{TRADER_TITLE_".$v_169."}",mysql_result($v_30,$v_24,'_title'),$v_168);
$v_168=str_replace("{IN_".$v_169."}",mysql_result($v_30,$v_24,'in_'),$v_168);
$v_168=str_replace("{OUT_".$v_169."}",mysql_result($v_30,$v_24,'out_'),$v_168);
}
$v_14=fopen('./thumb/top.txt','w');
fwrite($v_14,$v_168);
fclose($v_14);
}
function &get_thumb($v_170, $v_171=100, $v_139 = '', $v_172 = false) {
$v_21=array();
$v_16=fopen('./thumb/thumb'.$v_139.'.csv','r');
while ($v_23 = fgetcsv ($v_16, 1000, ";")) {
if (count($v_23) > 1) { $v_21[$v_23[1]] = array(trim($v_23[0]), trim(@$v_23[2])); }
}
fclose($v_16);
$v_18=@unserialize(@implode('',@file('./thumb/thumb'.$v_139.'.stats')));
if (!is_array($v_18)) { $v_18=array();}
arsort($v_18,SORT_NUMERIC); reset($v_18);
$v_173=count($v_21);
$v_174=count($v_18);
$v_170=intval(($v_171/100)*$v_170);
if ($v_170 > $v_174) {
$v_170=$v_174;
}
$v_175=$v_171-$v_170;
for ($v_24=0;$v_24<$v_170;$v_24++) {
list($v_19,$v_20)=each($v_18);
$v_176[]=array('thumb'=>$v_19,'url'=>$v_21[$v_19][0], 'desc'=>$v_21[$v_19][1]);
unset($v_21[$v_19]);
}
srand ((float) microtime() * 10000000);
if (count($v_21) < $v_175) { $v_175 = count($v_21); }
$v_177 = array_rand($v_21, $v_175);
while(list($v_19,$v_20) = each($v_177)) {
$v_176[]=array('thumb'=>$v_20,'url'=>$v_21[$v_20][0], 'desc'=>$v_21[$v_20][1]);
}
unset($v_21);
if ($v_172 != false) { shuffle($v_176); }
array_unshift($v_176,'');
return $v_176;
}
function f_72() {
if (true == isset($_SERVER['HTTP_REFERER'])) {
$v_14=@fopen('./sys_log/cj_ref_'.date('Y-m-d').'.csv','a');
if ($v_14) {
fwrite($v_14,"\"".date("H:i:s")."\";\"".$_SERVER['REMOTE_ADDR']."\";\"".$_SERVER['HTTP_REFERER']."\"\n");
fclose($v_14);
}
return true;
} else {
return false;
}
}
function f_73($tid) {
$v_178=array('HTTP_CLIENT_IP','HTTP_FORWARDED','HTTP_FROM','HTTP_VIA','HTTP_X_FORWARDED_FOR','HTTP_PROXY_CONNECTION','HTTP_XROXY_CONNECTION','HTTP_PROXY_AUTHORIZATION','HTTP_FORWARDED','HTTP_USER_AGENT_VIA');
$v_179 = ''; $v_180 = 0;
while(list($v_19,$v_20) = each($v_178)) {
if (isset($_SERVER[$v_20])) {
$v_180=1;
$v_179.=$_SERVER[$v_20].'|';
}
}
$v_30=mysql_query("select _ip from tm_cj_iplog where _ip=".crc32($_SERVER['REMOTE_ADDR'])." and tid=".$tid." limit 1") or die(mysql_error());
if (mysql_num_rows($v_30) > 0) {
$v_32="update low_priority tm_cj_stats set _rin=_rin+1, _hrin=_hrin+1 where tid=".$tid;
}else {
mysql_query("insert into tm_cj_iplog set _ip='".crc32($_SERVER['REMOTE_ADDR'])."', tid='".$tid."', _time='".time()."', _act=1, _proxy=".$v_180.", country_code = '".$_SERVER['GEOIP_COUNTRY_CODE']."'");
$v_32="update low_priority tm_cj_stats set _uin=_uin+1, _rin=_rin+1, _huin=_huin+1, _hrin=_hrin+1 where tid=".$tid;
}
mysql_query($v_32);
}
if (true == isset($_GET['ft'])) {
$v_41 = $_GET['ft'];
} elseif (true == isset($_GET['id'])) {
$v_41 = $_GET['id'];
} elseif (@$_SERVER['QUERY_STRING'] !='') {
$v_41 = $_SERVER['QUERY_STRING'];
} elseif (@$_SERVER['HTTP_REFERER']) {
$v_181 = parse_url($_SERVER['HTTP_REFERER']);
$v_41 = $v_181['host'];
} else {
$v_41 = '';
}
$v_41=str_replace('www.','',$v_41);
$v_41=eregi_replace("[^a-zA-Z_.0123456789-]+",'',$v_41);
if ($v_41=='') { $v_41='bookmark'; }
$v_30=mysql_query("SELECT _time from tm_cj_cron") or die(mysql_error());
$v_182=mysql_result($v_30,0,'_time');
if (date("H",$v_182) != date("H",time())) {
@ignore_user_abort(true);
mysql_query("UPDATE tm_cj_cron SET _time=".time()) or die(mysql_error());
mysql_query("
INSERT INTO tm_cj_hour
SELECT
s.tid,
unix_timestamp() - 3600,
s._huin,
s._hrin,
IF (s._hout > t._force, s._hout - t._force, 0) AS _hout,
s._hclk,
IF (s._hout - t._force > 0, t._force, s._hout) AS _forced
FROM
tm_cj_stats s,
tm_cj_tmpst t
WHERE
s.tid = t.tid
") or die(mysql_error());
mysql_query("UPDATE tm_cj_stats SET _huin=0, _hrin=0, _hout=0, _hclk=0") or die(mysql_error());
mysql_query("DELETE FROM tm_cj_tmpst") or die(mysql_error());
mysql_query("
INSERT INTO tm_cj_tmpst
SELECT
h.tid AS tid,
SUM(h._uin) AS _uin,
SUM(h._rin) AS _rin,
SUM(h._out) AS _out,
SUM(h._clk) AS _clk,
f._force AS _force,
SUM(h._forced) AS _forced
FROM
tm_cj_hour h,
tm_cj_force f
WHERE
h.tid=f.tid AND f._hour = '".date("G")."'
GROUP BY h.tid
ORDER BY h.tid
") or die(mysql_error());
mysql_query("DELETE FROM tm_cj_iplog WHERE _time < unix_timestamp() - 3600*24") or die(mysql_error());
mysql_query("DELETE FROM tm_cj_hour WHERE _time < unix_timestamp()-3600*24") or die(mysql_error());
}
if (USE_TOP == 1) {
$v_183 = intval(@filemtime('thumb/top.txt'));
if (time() - $v_183 > 3600) {
f_71();
}
}
$v_30=mysql_query("select _face, tid from tm_cj_traders where _domain='".$v_41."'") or die(mysql_error());
if (mysql_num_rows($v_30) == 1) {
$v_184=mysql_result($v_30,0,'_face');
if ($v_184=='') {$v_184='default';}
$tid=mysql_result($v_30,0,'tid');
}else {
$tid=1;
$v_41='bookmark';
$v_184='default';
}
if ($tid==1) { f_72(); }
f_73($tid);
if (true == isset($_GET['morda'])) {
$v_184 = trim($_GET['morda']);
}
if (intval(SKIP_FACE) == 0) {
$v_185=intval(@$_COOKIE['faceID'])+1;
if ($v_185 > 1) {
if (file_exists(PATH.'/faces/'.$v_184.$v_185.EXT)) {
setcookie('faceID', $v_185, time()+86400*14);
$v_184=$v_184.$v_185;
}else {
setcookie('faceID', '1', time()+86400*14);
}
}else {
setcookie('faceID', '1', time()+86400*14);
}
setcookie('TM_CJ_TID',$tid,false,'/');
setcookie('TM_CJ_UNIQUE',md5(DB_LOGIN.$_SERVER['REMOTE_ADDR']),false,'/');
Header("Cache-Control: no-cashe, must-revalidate");
Header("Pragma: no-cache");
print "
".HTML_DTD."
";
include_once('./faces/'.$v_184.EXT);
flush();
} else {
print "
".HTML_DTD."
";
}
mysql_close();
?>