function Main() { $this->CheckAdminPrivs('robot'); $config=ConfigHandler::get('robot'); $order_by=$this->Get['order_by']?$this->Get['order_by']:"today_times"; $order_type=$this->Get['order_type']?$this->Get['order_type']:"desc"; $toggle_order_type=$order_type=="desc"?"asc":"desc"; $$order_by="order_".$order_type; include_once(LOGIC_PATH.'robot.logic.php'); $RobotRogic=new RobotLogic(); $turnon_radio=FormHandler::YesNoRadio('config[turnon]',(int)$config['turnon'],'','class="radio"'); if ($config['turnon']) { $sql="SELECT * FROM ".$RobotRogic->tableName; $query=$this->DatabaseHandler->Query($sql,"SKIP_ERROR"); if($query==false && $this->DatabaseHandler->getlastErrorNo()==ERROR_TABLE_NOT_EXIST) { $query=$RobotRogic->createTable($RobotRogic->tableName,$RobotRogic->getFieldList(),$sql); } $robot_list=array(); $name_list=array(); while ($row=$query->GetRow()) { $row['link']=preg_replace("/.*?(((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k):\/\/)|(www\.))([^\[\"'\s\)\(\;]+))|([a-z0-9\_\-.]+@[a-z0-9]+\.[a-z0-9\.]{2,}))*/i","\\1",$row['agent']); if(strpos($row['link'],'@')!==false)$row['link']="mailto:".$row['link']; if($row['link'] && strpos($row['link'],":")===false)$row['link']="http:/"."/".$row['link']; $row['first_visit']=my_date_format($row['first_visit']); $row['last_visit']=my_date_format($row['last_visit']); if($this->ad) { $show_ad=isset($config['list'][$row['name']]['show_ad']) ?(int)$config['list'][$row['name']]['show_ad']: 1; $row['show_ad_radio']=FormHandler::YesNoRadio("config[list][{$row['name']}][show_ad]",$show_ad,'',"class='radio'"); } $row['today_times']=0; $name_list[]=$row['name']; $row['name']=trim($row['name']); $robot_list[$row['name']]=$row; } if(sizeof($name_list)>=0) { $names=$this->DatabaseHandler->BuildIn($name_list,""); include_once LOGIC_PATH.'robot_log.logic.php'; $RobotLogLogic=new RobotLogLogic(""); $sql="SELECT * FROM {$RobotLogLogic->tableName} where `name` in($names) and `date`='{$RobotLogLogic->date}' order by times desc"; $query=$this->DatabaseHandler->Query($sql,"SKIP_ERROR"); if($query==false && $this->DatabaseHandler->getlastErrorNo()==ERROR_TABLE_NOT_EXIST) { $query=$RobotRogic->createTable($RobotLogLogic->tableName,$RobotLogLogic->getFieldList(),$sql); } $today_robot_list=array(); while ($row=$query->GetRow()) { if(isset($robot_list[$row['name']])) $robot_list[$row['name']]['today_times']=$row['times']; } } if(is_array($robot_list) && sizeof($robot_list)>0) { foreach ($robot_list as $key=>$value) { $order_by_list[$key]=$value[$order_by]; } array_multisort($order_by_list,constant(strtoupper("sort_".$order_type)),$robot_list); } if(sizeof($robot_list)>0) { $robot_ip_list=array(); $sql="SELECT ip,name from {$RobotRogic->tableName}_ip order by `ip`"; $query=$this->DatabaseHandler->Query($sql,"SKIP_ERROR"); if($query!=false) { while ($row=$query->GetRow()) { $robot_ip_list[$row['name']][]=$row['ip']; } if(!empty($robot_ip_list)) { foreach ($robot_ip_list as $_robot=>$_ip_list) { if(sizeof($_ip_list)>5) { $ip_list=array(); $ip_list_count=0; foreach ($_ip_list as $_ip) { $ip=substr($_ip,0,strrpos($_ip,".")).".*"; $ip_list[$ip]=$ip; $ip_list_count++; if($ip_list_count>10)break; } $robot_ip_list[$_robot]=$ip_list; } } } } } } include handler('template')->file("@admin/robot"); }
function MasterObject(&$config) { global $rewriteHandler; $config['v'] = SYS_VERSION.SYS_RELEASE; $this->Config=$config; Obj::register('config', $this->Config); $this->Get = &$_GET; $this->Post = &$_POST; $this->Cookie = &$_COOKIE; $this->Session = &$_SESSION; $this->Request = &$_REQUEST; $this->Server = &$_SERVER; $this->Files = &$_FILES; $this->Module = trim($this->Post['mod']?$this->Post['mod']:$this->Get['mod']); $this->Code = trim($this->Post['code']?$this->Post['code']:$this->Get['code']); $this->OPC = trim($this->Post['op']?$this->Post['op']:$this->Get['op']); if ($this->Code == '') { $this->Code = ini('settings.default_code'); } $GLOBALS['iframe'] = ''; require_once LIB_PATH . 'cookie.han.php'; $this->CookieHandler = handler('cookie'); Obj::register('CookieHandler',$this->CookieHandler); if(false == in_array($this->Module, array('downapp', 'wap')) && false === X_IS_AJAX) { if(false != ($get_ignore_jump = get('ignore_jump'))) { $this->CookieHandler->SetVar('ignore_jump', time()); } $ignore_jump = ($get_ignore_jump ? $get_ignore_jump : $this->CookieHandler->GetVar('ignore_jump')); if(false == $ignore_jump && $_SERVER['HTTP_USER_AGENT'] && false != preg_match('~(MicroMessenger|iPhone|Android|Mobile)~i', $_SERVER['HTTP_USER_AGENT'], $match)) { header('Location: index.php?mod=downapp'); } } $__navs = ConfigHandler::get('nav'); foreach ($__navs as $i => $nav) { $curClass = ''; if (strpos($nav['url'], $this->Module)>0 && strpos($nav['url'], $this->Code)>0) { $curClass = 'current'; } elseif (strpos($nav['url'], $this->Module)>0 && $this->Code === false) { $curClass = 'current'; } elseif ($this->Module=='index' && $this->Code=='' && strpos($nav['url'], 'mod')==false && strpos($nav['url'], 'code')==false && substr($nav['url'], 0, 4) != 'http') { $curClass = 'current'; } $__navs[$i]['class'] = $curClass; if ($rewriteHandler) { $__navs[$i]['url'] = $rewriteHandler->formatURL($nav['url']); } } $this->Config['__navs'] = $__navs; $this->TemplateHandler = handler('template'); Obj::register('TemplateHandler',$this->TemplateHandler); $this->DatabaseHandler = dbc(); Obj::register('DatabaseHandler',$this->DatabaseHandler); require_once LIB_PATH . 'member.han.php'; $uid = 0;$password = '';$secques = ''; if($authcode=$this->CookieHandler->GetVar('auth')) { list($password,$secques,$uid)=explode("\t",authcode($authcode,'DECODE')); } $this->MemberHandler= handler('member'); $this->MemberHandler->FetchMember($uid,$password,$secques); $this->Title=$this->MemberHandler->CurrentAction['name']; Obj::register("MemberHandler",$this->MemberHandler); $ipbanned=ConfigHandler::get('access','ipbanned'); if(!empty($ipbanned) && preg_match("~^({$ipbanned})~",$_SERVER['REMOTE_ADDR'])) { $this->Messager("您的IP已经被禁止访问。",null); } unset($ipbanned); if(MEMBER_ID<1 && (int)$this->Config['robot']['turnon']==1) { include_once LOGIC_PATH.'robot.logic.php'; $RobotLogic=new RobotLogic(); define("ROBOT_NAME",$RobotLogic->isRobot()); if(ROBOT_NAME!==false) { if ($this->Config['robot']['list'][ROBOT_NAME]['disallow']) { exit('Access Denied'); } $RobotLogic->statistic(); if(isset($this->Config['robot']['list'][ROBOT_NAME]['show_ad']) && (int)$this->Config['robot']['list'][ROBOT_NAME]['show_ad']==0) { unset($this->Config['ad']); } include_once LOGIC_PATH.'robot_log.logic.php'; $RobotLogLogic=new RobotLogLogic(ROBOT_NAME); $RobotLogLogic->statistic(); unset($RobotLogLogic); } unset($RobotLogic); } unset($this->Config['robot']); define("FORMHASH",substr(md5(substr(time(), 0, -7).$_SERVER['HTTP_HOST'].$this->Config['auth_key'].$_SERVER['HTTP_USER_AGENT']),0,16)); if($_SERVER['REQUEST_METHOD']=="POST" && $this->Module!='callback' && $this->Module!='misc' && $this->Module!='upload' && $this->Module!='address') { if($this->Post["FORMHASH"]!=FORMHASH || strpos($_SERVER["HTTP_REFERER"],$_SERVER["HTTP_HOST"])===false) { X_IS_AJAX || $this->Messager("请求无效",null); } } }