public function ipListAction() { //检查当前页面权限 $sign = '?ctl=config/machine&ac=ip.list'; $this->manager->checkMenuPermission($sign, Widget_Manager::MENU_PURVIEW_SELECT); $CageList = $this->CageList; $DepotId = $this->request->DepotId; $export = $this->request->export ? intval($this->request->export) : 0; $page = $this->request->page ? intval($this->request->page) : 1; $pageSize = $export ? 0 : 20; $DepotList = $this->DepotList; $ServerList = $this->ServerList; $PartnerList = $this->PartnerList; $param = array(); if ($DepotId) { $param['DepotId'] = $DepotId; $CageIdList = Base_Common::getArrList($CageList[$DepotId]); } $MachineList = $this->oMachine->getIpList($CageIdList, ($page - 1) * $pageSize, $pageSize); $MachineArr = $MachineList['MachineDetail']; foreach ($MachineArr as $MachineId => &$MachineInfo) { $MachineInfo['PartnerName'] = $PartnerList[$ServerList[$MachineInfo['ServerId']]['PartnerId']]['name']; $MachineInfo['LocalIP'] = long2ip($MachineInfo['LocalIP']); $MachineInfo['WebIP'] = long2ip($MachineInfo['WebIP']); $MachineInfo['Purpose'] = $MachineInfo['Purpose']; } //翻页 $pageParam = $param + array("export" => 0); $page_url = Base_Common::getUrl('', 'config/machine', 'ip.list', $pageParam) . "&page=~page~"; $page_content = base_common::multi($MachineList['MachineCount'], $page_url, $page, $pagesize, 10, $maxpage = 100, $prevWord = '上一页', $nextWord = '下一页'); //表格导出 $execlParam = $param + array("export" => 1); $export_var = "<a href =" . Base_Common::getUrl('', 'config/machine', 'ip.list', $execlParam) . "><导出表格></a>"; if ($export == 1) { $oExcel = new Third_Excel(); $FileName = 'IP地址信息'; $oExcel->download($FileName)->addSheet('IP地址信息'); //标题栏 $title = array("序列号", "资产编号", "内网IP", "外网IP", "项目", "用途"); $oExcel->addRows(array($title)); foreach ($MachineArr as $MachineCode => $MachineInfot) { //生成单行数据 $t = array(); $t['MachineCode'] = $MachineInfot['MachineCode']; $t['EstateCode'] = $MachineInfot['EstateCode']; $t['LocalIP'] = $MachineInfot['LocalIP']; $t['WebIP'] = $MachineInfot['WebIP']; $t['PartnerName'] = $MachineInfot['PartnerName']; $t['Purpose'] = $MachineInfot['Purpose']; $oExcel->addRows(array($t)); unset($t); } $oExcel->closeSheet()->close(); } include $this->tpl('Config_Machine_ipList'); }
public function machineMapAction() { $sign = "?ctl=config/depot&ac=machine.map"; $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_SELECT); $export = $this->request->export ? intval($this->request->export) : 0; $DepotParame['export'] = 1; $DepotList = $this->oDepot->getAll(); //用于设置默认的页面参数 $DepotIdStr = Base_Common::getArrList($DepotList); $DepotArr = explode(",", $DepotIdStr); //页面参数 $DepotId = $this->request->DepotId ? $this->request->DepotId : $DepotArr[0]; $DepotX = $this->request->X; $DepotXList = $this->getDepotX($DepotId); $DepotName = $DepotList[$DepotId]['name']; if ($DepotId && $DepotX) { $DepotParame['DepotId'] = $DepotId; $DepotParame['X'] = $DepotX; $CageList = $this->oCage->getCageListParams($DepotId, $DepotX); $MachineFields = "MachineId,MachineCode,EstateCode,Position,Size,LocalIP,WebIP,Purpose,Flag"; foreach ($CageList as $CageId => $CageInfo) { $MachineList = $this->oMachine->getMachineByCageId($CageId, $MachineFields); $SizeList = array(); for ($i = 1; $i <= $CageInfo["Size"]; $i++) { $SizeList[$i] = 0; } foreach ($MachineList as $key => $MachineInfo) { $MachineInfo['LocalIP'] = long2ip($MachineInfo['LocalIP']); $MachineInfo['WebIP'] = long2ip($MachineInfo['WebIP']); $SizeList[$MachineInfo['Position']] = $MachineInfo; for ($i = $MachineInfo['Position']; $i <= $MachineInfo['Position'] + $MachineInfo['Size'] - 1; $i++) { if ($i > $MachineInfo['Position']) { unset($SizeList[$i]); } } ksort($SizeList); $CageList[$CageId]['SizeList'] = $SizeList; } } } $imgPath = __APP_ROOT_DIR__ . "admin/html/img/machine/"; //导出表格 $export_var = "<a href =" . Base_Common::getUrl('', 'config/depot', 'machine.map', $DepotParame) . "><导出表格></a>"; if ($export == 1) { /*header("Content-type:application/vnd.ms-excel;charset=UTF-8"); header("Content-Disposition:attachment;filename=test_data.xls"); foreach($CageList as $CageId=> $CageInfo) { echo "<table>"; echo "<tr><td>编号:{$CageInfo['CageCode']}</td></tr>"; echo "<tr><td>电量:{$CageInfo['Current']}A</td></tr>"; echo "<tr><td>实际电量:{$CageInfo['ActualCurrent']}A</td></tr>"; foreach($CageInfo['SizeList'] as $k=> $v) { if($v == 0) { echo "<tr><td></td></tr>"; }else{ if($v['Flag']==1) { echo "<tr><td><img title='内网IP:".$v['LocalIP']." 外网IP:".$v['WebIP']."' src='{$imgPath}server/server".$v['Size'].".png' style='height:".($v['Size']*15)."px' /></td></tr>"; }elseif($v['Flag']==2)//交换机 { echo "<tr><td><img title='内网IP:".$v['MachineCode']."外网IP:".$v['WebIP']."' src='{$imgPath}exchange/exchange".$v['Size'].".png' style='height:".($v['Size']*15)."px' /></td></tr>"; }elseif($v['Flag']==3)//防火墙 { echo "<tr><td><img title='内网IP:".$v['MachineCode']."外网IP:".$v['WebIP']."' src='{$imgPath}router/router".$v['Size'].".png' style='height:".($v['Size']*15)."px' /></td></tr>"; }elseif($v['Flag']==4)//路由器 { echo "<tr><td><img title='内网IP:".$v['MachineCode']."外网IP:".$v['WebIP']."' src='{$imgPath}router/router".$v['Size'].".png' style='height:".($v['Size']*15)."px' /></td></tr>"; } } } echo "</table>"; }*/ /*$FileName='机器列表图'; $oExcel = new Third_Excel(); $oExcel->download($FileName)->addSheet('机器列表图'); include $this->tpl('Config_Depot_MapList3');lll $oExcel->closeSheet()->close(); */ header("Content-type:application/vnd.ms-excel;charset=UTF-8"); header("Content-Disposition:attachment;filename=MachineMap.xls"); include $this->tpl('Config_Depot_MapExecl'); } else { include $this->tpl('Config_Depot_MapList'); } }
/** *使用礼包码 */ public function useProductPackCodeAction() { //基础元素,必须参与验证 $User['UserId'] = abs(intval($this->request->UserId)); $User['ProductPackCode'] = $this->request->ProductPackCode; $User['Time'] = abs(intval($this->request->Time)); $User['ServerId'] = $this->request->ServerId; $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; //URL验证码 $sign = $this->request->sign; //私钥,以后要移开到数据库存储 $p_sign = 'lm'; $sign_to_check = base_common::check_sign($User, $p_sign); //不参与验证的元素 //验证URL是否来自可信的发信方 if ($sign_to_check == $sign) { if ($User['UserId']) { //验证时间戳,时差超过600秒即认为非法 if (abs($User['Time'] - time()) <= 600) { if ($User['ServerId']) { //查询用户 $UserInfo = $this->oUser->GetUserById($User['UserId']); if ($UserInfo['UserId']) { unset($User['ReturnType']); //判断用户所选服务器大区是否存在 $ServerInfo = $this->oServer->getRow($User['ServerId']); if ($ServerInfo['ServerId']) { $oProductPack = new Config_Product_Pack(); $ProductPackCode = $oProductPack->getUserProductPackCode($User['ProductPackCode'], $User['UserId']); if (!$ProductPackCode['ProductPackCode']) { $ProductPackCode = $oProductPack->getProductPackCode($User['ProductPackCode']); } if ($ProductPackCode['ProductPackCode']) { if (($ProductPackCode['AppId'] = $ServerInfo['AppId']) && ($ProductPackCode['PartnerId'] = $ServerInfo['PartnerId'])) { if (!$ProductPackCode['UsedUser']) { $GenInfo = $oProductPack->GetGenPackCodeLogById($ProductPackCode['GenId']); if ($GenInfo['GenId']) { if ($User['Time'] <= $GenInfo['EndTime']) { if ($GenInfo['needBind'] == 2) { $ProductPack = $oProductPack->getRow($ProductPackCode['ProductPackId']); if ($ProductPack['ProductPackId']) { if ($ProductPack['UseCountLimit']) { $GenLog = $oProductPack->getGenLog(0, 0, $ProductPackCode['ProductPackId'], 2, 0, 0, 0); $UseLog = $oProductPack->getUserPackUserLog(0, 0, $UserInfo['UserId'], $ProductPackCode['ProductPackId'], Base_Common::getArrList($GenLog['GenLog']), 0); $Count = count($UseLog); //获取该用户该礼包使用次数 if ($Count >= $ProductPack['UseCountLimit']) { $result = array('return' => 0, 'comment' => "您的该礼包使用次数已经超过上限"); } else { $Use = $oProductPack->usePackCode($ProductPackCode['ProductPackCode'], $ServerInfo['ServerId'], $UserInfo['UserId'], $User['Time']); if ($Use) { $result = array('return' => 1, 'comment' => "礼包已经在发送中,请稍后登陆游戏查收"); } else { $result = array('return' => 2, 'comment' => "礼包发送失败,请稍后重试"); } } } else { $Use = $oProductPack->usePackCode($ProductPackCode['ProductPackCode'], $ServerInfo['ServerId'], $UserInfo['UserId'], $User['Time']); if ($Use) { $result = array('return' => 1, 'comment' => "礼包已经在发送中,请稍后登陆游戏查收"); } else { $result = array('return' => 2, 'comment' => "礼包发送失败,请稍后重试"); } } } else { $result = array('return' => 0, 'comment' => "无此礼包"); } } else { if ($ProductPackCode['AsignUser'] == $UserInfo['UserId']) { $Use = $oProductPack->usePackCode($ProductPackCode['ProductPackCode'], $ServerInfo['ServerId'], $UserInfo['UserId'], $User['Time']); if ($Use) { $result = array('return' => 1, 'comment' => "礼包已经在发送中,请稍后登陆游戏查收"); } else { $result = array('return' => 2, 'comment' => "礼包发送失败,请稍后重试"); } } else { $result = array('return' => 0, 'comment' => "该礼包的指定使用用户不是您"); } } } else { $result = array('return' => 0, 'comment' => "礼包已经过期"); } } else { $result = array('return' => 0, 'comment' => "无此批次"); } } else { if ($ProductPackCode['UsedUser'] == $UserInfo['UserId']) { if ($ProductPackCode['CodeStatus'] == 1) { $ProductPack = $oProductPack->getRow($ProductPackCode['ProductPackId']); if (time() - $ProductPack['UseTimeLag'] >= $ProductPackCode['UsedTime']) { $errorList = $this->oCharacter->getSendErrorList($UserInfo['UserId'], $ProductPackCode['ProductPackCode']); $addLog = 0; $oProduct = new Config_Product_Product(); foreach ($errorList as $key => $errorLog) { $insert = $oProduct->insertIntoProductSendList($ProductPackCode['ProductPackCode'], 'ProductPack', $errorLog['ProductId'], $errorLog['ProductType'], $errorLog['ProductCount'], $errorLog['UserId'], $errorLog['ServerId'], time()); if ($insert) { $addLog++; } } if ($addLog) { $oProductPack->updatePackCode($ProductPackCode['ProductPackCode'], array('UsedTime' => time())); $result = array('return' => 1, 'comment' => $addLog . "个道具重新加入发放队列"); } else { $result = array('return' => 1, 'comment' => "礼包码已于 " . date("Y-m-d H:i:s", $ProductPackCode['UsedTime']) . " 被您使用"); } } else { $result = array('return' => 0, 'comment' => "您的操作过于频繁," . $ProductPack['UseTimeLag'] . "秒内只允许操作一次,请稍后再试"); } } } else { $result = array('return' => 0, 'comment' => "礼包码已于 " . date("Y-m-d H:i:s", $ProductPackCode['UsedTime']) . " 被其他用户使用"); } } } else { $result = array('return' => 0, 'comment' => "您所输入的礼包码不允许在此服务器使用"); } } else { $result = array('return' => 0, 'comment' => "无此礼包码"); } } else { $result = array('return' => 0, 'comment' => "您所选择的服务器不存在"); } } else { $result = array('return' => 2, 'comment' => "无此用户"); } } else { $result = array('return' => 2, 'comment' => "请选择服务器"); } } else { $result = array('return' => 2, 'comment' => "时间有误"); } } else { $result = array('return' => 0, 'comment' => "请选择用户"); } } else { $result = array('return' => 2, 'comment' => "验证失败,请检查URL"); } $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; if ($User['ReturnType'] == 1) { echo json_encode($result); } }