묻고답하기

<style type="text/css">
@import url("white.css");
</style>

<?php
class trafficInfo {
 function xml_info($xml, $domain) {
  $fileArr = explode("\n", $xml);
  $fileCnt = count($fileArr);
  for($i=0; $i<$fileCnt; $i++) {
   if(strpos($fileArr[$i], '<domain-'.$domain.'>') !== false) {
    $get = true;
   }
   if($get) {
    $z[] = preg_replace(";\t*;", "", $fileArr[$i]);$fileArr[$i];
   }
   if(strpos($fileArr[$i], '</domain-'.$domain.'>') !== false) {
    break;
   }
  }
  if($z && is_array($z)) {
   //print_r($z);
   $file = implode("", $z);
   $xmlParser = xml_parser_create();
   xml_parse_into_struct($xmlParser, $file, $vals, $index);
   xml_parser_free($xmlParser);

   $params = array();
   $level = array();
   foreach ($vals as $xmlElem) {
    if ($xmlElem['type'] == 'open') {
     if (array_key_exists('attributes',$xmlElem)) {
      list($level[$xmlElem['level']],$extra) = array_values($xmlElem['attributes']);
     } else {
      $level[$xmlElem['level'+ '+ ']] = $xmlElem['tag'];
     }
    }
    if ($xmlElem['type'] == 'complete') {
     $start_level = 1;
     $php_stmt = '$params';
     while($start_level < $xmlElem['level']) {
      $php_stmt .= '[$level['.$start_level.']]';
      $start_level++;
     }
     $php_stmt .= '[$xmlElem[\'tag\']] = $xmlElem[\'value\'];';
     eval($php_stmt);
    }
   }
  } else {
   exit(" <font color=\"red\">에러 : XML 정보 불러오기 실패</font>\n<br />\n");
  }
  $this->usageTraffic = $this->kb_to_mb(str_replace('KiB', '', $params['DOMAIN-'.strtoupper($domain)]['USAGES']['TOTAL']));
  $this->totalTraffic = $this->kb_to_mb(str_replace('KB', '', $params['DOMAIN-'.strtoupper($domain)]['LIMITS']['TOTAL']));
  $this->percent = round($this->usageTraffic / $this->totalTraffic * 1000) / 1000 * 100;
  return $params;
 }
 function hosting_traffic($html, $domain) {
  $file = explode("\n", $html);
  $flags = 0;
  for($i=0, $fileNum=count($file); $i<$fileNum; $i++) {
   if(strpos($file[$i], $domain) !== false) {
    if($flags < 2) {
     $flags++;
    } else {
     break;
    }
   }
  }
  for($ii=$i+1, $userInfo=$i+11; $ii<$userInfo; $ii++) {
   $file_ .=  $file[$ii]."\n";
  }
  preg_match_all(';<td class="(red|critical|green|yellow)">([^<]+)</td>;', $file_, $match);
  $this->usageTraffic = $match[2][3];
  $this->totalTraffic = $match[2][7];
  $this->percent = round($this->usageTraffic / $this->totalTraffic * 1000) / 1000 * 100;
  return $match;
 }
 function kb_to_mb($kb) {
  return $kb/1000;
 }
 function get_traffic($domain, $accountId, $accountPass, $trafficPath) {
  $fp = fsockopen($domain, 80, $errstr, $errno, 30);
  if($trafficPath != 'traffic' && $trafficPath != 'traffic?xml') {
   exit('정확히 적어주시길 바랍니다.');
  }
  if(!$fp) {
   exit('정확히 적어주시길 바랍니다. ('.$errstr.")");
  } else {
   $data = "GET /".$trafficPath." HTTP/1.0\r\n";
   $data .= "Host: ".$domain."\r\n";
   $data .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n";
   $data .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*\r\n";
   $data .= "Accept-encoding: gzip\r\n";
   $data .= "Accept-language: ko-kr\r\n";
   $data .= "Authorization: BASIC ".base64_encode($accountId.':'.$accountPass)."\r\n\r\n";
   fwrite($fp, $data);
   $inHeaders = true;
   $atStart = true;
   while (!feof($fp)) {
    $line = fgets($fp, 4096);
    if ($atStart) {
     $atStart = false;
     if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
      echo "정보를 정상적으로 받아오지 못했습니다.1(".htmlentities($line).')';
      exit();
     }
     if($m[2] != 200) {
      echo "정보를 정상적으로 받아오지 못했습니다.2(".htmlentities($line).')';
      exit();
     }
     continue;
    }
    if ($inHeaders) {
     if (trim($line) == '') {
      $inHeaders = false;
      continue;
     }
     if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
      continue;
     }
     continue;
    }
    $trafficPage .= $line;
   }
   fclose($fp);
  }
  if($trafficPath == 'traffic') {
   return $this->hosting_traffic($trafficPage, $domain);
  } else if($trafficPath == 'traffic?xml') {
   return $this->xml_info($trafficPage, $domain);
  }
 }
}

$domain = 'lamborghini.mireene.com'; // 도메인(ex : mireene.com)
$accountId = 'lamborghini'; // 계정아이디
$accountPass = '+ '********'; // 계정암호
$trafficPath = 'traffic'; // 일반서버의 경우 traffic, cent서버는 traffic?xml

$traffic = new trafficInfo();
$trafficInfo = $traffic->get_traffic($domain, $accountId, $accountPass, $trafficPath);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 트래픽 정보보기 </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Mireene" />
<meta name="keywords" content="traffic" />
<meta name="description" content="traffic" />
</head>

<body>

 
  <div class="HG_trafficViewer">
    <h2 class="title"><span>트래픽 사용량</span></h2>
        <div class="description">Traffic = <?php echo $traffic->percent; ?>% (<?php echo $traffic->usageTraffic; ?>MB / <?php echo $traffic->totalTraffic; ?>MB)</div>
        <div class="graph">
            <div class="used" style="width:<?php echo $traffic->percent; ?>%;"></div>
            <div class="rest" style="width:<?php echo 100 - $traffic->percent; ?>%;"></div>
            <div class="clear"></div>
        </div>

</div>

</body>
</html>

 

 

 

http://www.xpressengine.com/17123904

 **********************************여기 글에 있는거 보고했어요~

http://lamborghini.mireene.com/xe/traffic/traffic.php

이렇게 뜨는 이유좀 알려주세요;;

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
또별 비정상적인 방법으로 회원가입 문의 [1] 2010.04.21 by 백성찬
양병주 메뉴 설정 문제 문의 드립니다. [3] file 2010.04.21 by 하연울
김희연637 급합니다!!! 글쓰기 버튼이 사라졌습니다 file  
Milano 달력이 맞지 않게 나올때는 어떻게 해야할까요? [2] file 2010.04.21 by 현원
H754 이미지 업로드시 alt 값 [1] 2010.04.21 by 앙띠2
찰나의빛 존재하지 않는 사용자 아이디입니다. 뭘까요??????? [1] 2010.04.21 by NEARSTORY
zenqu 게시판 확장변수 타이틀 굵게 안되게 하는방법 아시는분 [1] file 2010.04.21 by 앙띠2
윈스컴 간단한 덧글은 어떻게 바꾸나요? [1] 2010.04.21 by 앙띠2
찰나의빛 config.user.inc.php 파일은 설치 후 직접 만들어야 하나요? [1] 2010.04.21 by 앙띠2
^^ 컴포넌트 Code Highlighter 사용법 좀 알려주세요 [8] 2020.03.15 by Euney
이정남623 게시판 스킨 XE Official Skin 검색부분이 리스트와 겹칩니다. [2] file 2010.04.21 by 이정남623
kuroseki_黑跡 레이아웃에서 로그인 위젯이 깨집니다. file  
말라랑칼물렁컹이 본문 내 이미지 조절 애드온이 IE8 및 FF등 에서 작동하지 않습니다.  
로진 코드가 꼬인것 같습니다  
퍼플덕 openid 로그인 안되는 되요?  
otonacool 한 서버에 두개의 XE를 설치할 수 없나요? [1] 2010.04.21 by 현원
즈즈. 제어판-환경설정(setting)이 저장해도 반영이 안됩니다. [3] file 2010.04.21 by 즈즈.
쌀국수 모듈을 설치했더니 오류가 나네요..;;  
흰둥럽럽 회원검색 모듈 이런거있나요??.. file  
흰둥럽럽 포인트제도 형식에 대해서 잘아시는분..ㅋ  
흰둥럽럽 이런 모듈은 돈내야되나요? [1] 2010.04.21 by 현원
무비클립 레이아웃 description 외국어 관련질문 드려요  
비밀얌 오늘 가입회원이 123명이네요..헐..??? [2] 2010.04.21 by 쥬시쿨
공부해야지 호스팅 업체의 Root 권한으로 업데이트 이후.. 유저 권한은?? [1] 2010.04.21 by 휘즈
무실 XE 게시판에 글을 올리면 어디에 저장이 되는지요? [1] 2010.04.21 by 현원
우리아기 캐시파일 재생성및 세션정리 해도 적용이 안되는경우..ㅠ.ㅠ [3] 2010.04.21 by 현원
혼자267 시간에 따라 바뀌는 그림을 만드는 방법 [1] 2010.04.21 by 앙띠2
닉네임  admin으로 로그인할려는데 아이디,비밀번호 치고 로그인버튼을 누르면 왼쪽상단에 서버에연결중입니다. 떠야하는데 안뜨고 로그인이안되요;;  
강함이 xe 처음 설치하려고 하는데요. [1] 2010.04.21 by 앙띠2
케이이치 외부페이지에서 위젯을 넣었는데요 [2] 2010.04.22 by 현원