뉴스:
페이지: [1]
  프린트  
작성자 게시글: 부족전쟁 접으면서 -_-;;  (Read 116842 times)
항상야근
창병
*
포스트: 2


프로필 보기
« on: 7월 26, 2010, 06:14:00 am »

.. 파일을 올릴려고 했는데 파일은 안올라 가는군요 -_-;;

한동안 잘 쓰던 동줍Class  입니다 ㅎㅎ (참고로 자작 A/S 없음)

쓸줄 아시는분은 셋팅해서 쓰세요 ㅎㅎ

================         bujok.class 파일
<?
class Bujok{

private $id="";
private $pw="";
private $server="";
private $ch;
public $village;
public $proxy=false;


private $userBill = array();

   function Bujok($server){
      $this->server = $server;
      $this->ch = curl_init();



      $this->village = array();
      $this->vInfo = false;
   }




   function Login($id, $pw,$server = false){

      $this->id = $id;
      $this->pw = $pw;
      if($server !== false) $this->server = $server;

      $postData["user"] =$this->id;
      $postData["password"] =$this->pw;
      $postData["clear"] = "true";
      $postData["server"] = $this->server;
      $postData["cookie"] = "";



      if($this->prox) curl_setopt($this->ch, CURLOPT_PROXY, $this->prox);

      curl_setopt($this->ch, CURLOPT_URL, "http://www.bujokjeonjaeng.org/index.php?action=login");
      curl_setopt($this->ch, CURLOPT_HEADER, 1);

      curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($this->ch, CURLOPT_COOKIESESSION, 1);
      curl_setopt($this->ch, CURLOPT_USERAGENT , "Mozilla/5.0 (Windows; U; Windows NT 5.1; ko; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3");
      curl_setopt($this->ch, CURLOPT_REFERER, "http://www.bujokjeonjaeng.org");
      curl_setopt($this->ch, CURLOPT_COOKIEFILE, "/home/naearu/www/lab/bu/cookie/cookiefile");
      curl_setopt($this->ch, CURLOPT_COOKIEJAR,  "/home/naearu/www/lab/bu/cookie/cookiefile");

      curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);

      curl_setopt($this->ch, CURLOPT_POST, 1);
      curl_setopt($this->ch, CURLOPT_POSTFIELDS, http_build_query($postData));
      curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 5);


      $ex=curl_exec ($this->ch);
      $ex = str_replace("<span class=\"grey\">.</span>","",$ex);

      preg_match_all("/<a href=\"[^\"]*village=([0-9]+)[^\"]*\">[\n\r\t]*[
                     ]?(.*)[
                     ]?<span id=\"[^\"]*\">(.{1,100})<\/span>\t?<\/a>/",$ex,$out);

      $this->village = $out[1];



      $loginOK = strstr($ex,"game.php?screen=overview");
      if($loginOK !== false){
         return true;
      }else{
         return false;
      }
   }



   function getInfo(){

      $this->vInfo = array();

      curl_setopt($this->ch, CURLOPT_URL, "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$this->village[1]."&screen=overview_villages&mode=prod");
      $ex=curl_exec ($this->ch);

      $ex = str_replace("<span class=\"grey\">.</span>","",$ex);

      preg_match_all("/<a href=\"[^\"]*village=([0-9]+)[^\"]*\">[\n\r\t]*[
                     ]?(.*)[
                     ]?<span id=\"[^\"]*\">(.{1,100})<\/span>\t?<\/a>/",$ex,$out1);
      //print_r($out1);

      preg_match_all("/<td>([0-9]+)<\/td>[\n\r\t]*[
      ]?<td align=\"center\">[
      ]?<img src=\"[^\"]*\" title=\"[^\"]*\" alt=\"\" \/>([0-9]+) [
      ]?<img src=\"[^\"]*\" title=\"[^\"]*\" alt=\"\" \/>([0-9]+) [
      ]?<img src=\"[^\"]*\" title=\"[^\"]*\" alt=\"\" \/>([0-9]+) <\/td>[\n\r\t
      ]*<td>([0-9]+)<\/td>[\n\r\t
      ]*<td><a href=\"[^\"]*\">([0-9\/]+)<\/a><\/td>   <td>([0-9\/]+)<\/td>/",$ex,$out2);
      // 1 = 점수
      // 2 = 목재
      // 3 = 점토
      // 4 = 철
      // 5 = 저장고
      // 6 = 상인
      // 7 = 농가

      //print_r($out2);


      for($i = 0; $i < count($out1[0]); $i++){

         preg_match("/\(([0-9]+)\|([0-9]+)\)/",$out1[3][$i],$poTmp);

         //print_r($poTmp);

         $villNo = $out1[1][$i];
         $this->vInfo[ $villNo ][Name    ] = $out1[3][$i];
         $this->vInfo[ $villNo ][Point   ] = $out2[1][$i];
         $this->vInfo[ $villNo ][Storage ] = $out2[5][$i];
         $this->vInfo[ $villNo ][Place   ] = $out2[6][$i];
         $this->vInfo[ $villNo ][Farm    ] = $out2[7][$i];
         $this->vInfo[ $villNo ][Attack  ] = $out2[1][$i];
         $this->vInfo[ $villNo ][Wood    ] = $out2[2][$i];
         $this->vInfo[ $villNo ][Stone   ] = $out2[3][$i];
         $this->vInfo[ $villNo ][Iron    ] = $out2[4][$i];

         $this->vInfo[ $villNo ][X    ] = $poTmp[1];
         $this->vInfo[ $villNo ][Y    ] = $poTmp[2];
      }

      return $this->vInfo;
   }

   function attack($villNum ,$x,$y,$units){

      $posStr = http_build_query($units);

      $posStr1 .= $posStr;
      $posStr1 .="&x=".$x;
      $posStr1 .="&y=".$y;
      $posStr1 .="&attack=%EA%B3%B5%EA%B2%A9";


      $attackURL =  "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$villNum."&screen=place&try=confirm";
      curl_setopt($this->ch, CURLOPT_URL,$attackURL);
      curl_setopt($this->ch, CURLOPT_REFERER, "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$villNum."&screen=place");
      curl_setopt($this->ch, CURLOPT_POSTFIELDS,$posStr1 );
      $ex=curl_exec ($this->ch);


      if( !preg_match("/<input type=\"hidden\" name=\"action_id\" value=\"([0-9]+)\" \/>/",$ex,$out) ){
         return false;
      }

      $posStr2 .="attack=true";
      $posStr2 .="&x=".$x;
      $posStr2 .="&y=".$y;
      $posStr2 .="&action_id=".$out[1];

      foreach($units as $unit=>$nums){
         $posStr2 .="&".$unit."=".(!$nums?'0':$nums);
      }


      preg_match("/<form action=\"([^\"]+)\" method=\"post\" onsubmit=\"this\.submit\.disabled=true;\">/",$ex,$out);
//      preg_match("/<form action=\"([^\"]+)\" method=\"post\" onSubmit=\"this.submit.disabled=true;\">/",$ex,$out);

      $confURL = "http://".$this->server.".bujokjeonjaeng.org".urldecode($out[1]);

      $confURL = str_replace("&amp;","&",$confURL);

      curl_setopt($this->ch, CURLOPT_URL, $confURL);
      curl_setopt($this->ch, CURLOPT_REFERER, "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$villNum."&screen=place&try=confirm");
      curl_setopt($this->ch, CURLOPT_POSTFIELDS, $posStr2);
      $ex=curl_exec ($this->ch);


      return true;

   }


   function getGrayMine($villNum,$x=0,$y=0){

      if($x ==0 && $y==0){
         $posStr1 = "";
      }else{
         $posStr1 = "x=$x&y=$y";
      }

      $attackURL =  "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$villNum."&screen=map";
      curl_setopt($this->ch, CURLOPT_URL,$attackURL);
      curl_setopt($this->ch, CURLOPT_REFERER, "http://".$this->server.".bujokjeonjaeng.org/game.php?village=".$villNum."&screen=place");
      curl_setopt($this->ch, CURLOPT_POSTFIELDS,$posStr1 );
      $ex=curl_exec ($this->ch);

      $count = preg_match_all("/onmouseover=\"Map.map_popup\(event, '([^']*)', '([^']*)', '([^']*)', [0-9]*, ([^,]*), ([^,]*), '([^']*)', '([^']*)', '([^']*)', ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*)\)\" onmouseout=\"Map.map_kill\(\)\"/",$ex,$out);

//onmouseover="Map.map_popup('103 다들 엉덩이 땀띠 조심해요 (579|498) K45', '/graphic/bonus/iron.png?1', '100% 더 많은 철생산', 6250, 'chaesoya (56.509 점)', '네오에이스 (1.176.278 점)', '', '', '', 100, 6552, '/game.php?village=6552&amp;screen=overview&amp;source=6240&amp;json=', '10-05-02 11:41 ', 'dots/green.png', 'max_loot/0.png', false)" onmouseout="Map.map_kill()">

      $grayMines = array();
      for($i=0;$i<$count ;$i++){

         if($out[4][$i] == 'null'){

            preg_match("/\(([0-9]+)\|([0-9]+)\)/",$out[1][$i],$poTmp);

            $grayMines[] = array(
               'X'=>$poTmp[1],
               'Y'=>$poTmp[2],
               'NAME'=>$out[1][$i]
               );
         }
      }
      return $grayMines;
   }
}
?>

dong_jub.php --  사용예시

<?
include "bujok.class";
$bu = new Bujok("kr6"); // 서버명
if(!$bu->Login("아이디","비밀번호") ){
    echo "로그인 실패!";
    exit;
}

$info = $bu->getInfo();
//공격금지 마을 셋팅
$doNot = array();
// 병력셋팅
$DJunits = array(
"spear"     =>"",
"sword"     =>"",
"axe"       =>"",
"archer"    =>"",
"spy"       =>"1",
"light"     =>"15",
"marcher"   =>"",
"heavy"     =>"",
"ram"       =>"",
"catapult"  =>"",
"knight"    =>"",
"snob"      =>""
);


$villageNum = $bu->village[0];

echo "DongJub Start - $villageNum \n";

$gray1 = $bu->getGrayMine($villageNum,593,504); // 회광리스트업
$gray2 = $bu->getGrayMine($villageNum,593,519); // 회광리스트업
$gray3 = $bu->getGrayMine($villageNum,563,519); // 회광리스트업
$gray4 = $bu->getGrayMine($villageNum,563,504); // 회광리스트업

$grayMines = array_merge($gray1,$gray2,$gray3,$gray4);
shuffle($grayMines);

//$vills=array(6240,6787,6818);
$vills=array(6787,6818);

foreach( $vills as $villageNum){

   shuffle($grayMines);

   echo "DongJub Start - $villageNum \n";
   foreach($grayMines as $num => $grayMine ){
      if( in_array(($grayMine[X]." | ".$grayMine[Y]),$doNot) ){
         continue;
      }
      echo "attack ".$grayMine[X]." | ".$grayMine[Y]."  :   ".$grayMine[NAME]."\n";
      $result = $bu->attack($villageNum ,$grayMine[X],$grayMine[Y],$DJunits);
      if(!$result) break;

      unset( $grayMines[ $num ] );
   }
}
?>


Logged
러시앤캐쉬
창병
*
포스트: 18



프로필 보기
« 리플라이 #1 on: 7월 28, 2010, 05:32:04 pm »

이거원.. 올려주셔도 이용방법을 모르니.. 궁금하고 답답할 따름입니다.
Logged
항상야근
창병
*
포스트: 2


프로필 보기
« 리플라이 #2 on: 8월 01, 2010, 08:45:41 pm »

두개의 파일을 올려드렸는데요.

PHP서버를 가지고 계신분들은 싹 셋팅하셔서 시간마다 호출하게 셋팅을 해 두시면 알아서 동줍을 다닙니다 -_-;; 이제껏 걸어놨었지만 걸린적은 없었네요 ㅎㅎ

Logged
페이지: [1]
  프린트  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Theme AvareMu by Fussilet.com
© 2009-2024 부족 툴즈. All Rights Reserved.