Помогите разобраться

Discussion in 'PHP' started by XPYCT, 22 Feb 2015.

  1. XPYCT

    XPYCT New Member

    Joined:
    6 Apr 2008
    Messages:
    11
    Likes Received:
    0
    Reputations:
    0
    Доброго времени суток друзья!
    Помогите разобраться со скриптом,
    Есть скрипт который показывает имя персонажа, где находиться персонаж в игре, его здоровье. Раньше работал без проблем, все показывало, но в один прекрасный день сайт с игрой поменял хостинг и все приплыли. Взгляните опытным взглядом почему не работает?
    PHP:
    <?php

    error_reporting
    (0);

    $stat_mas  = array("align=\"absmiddle\" class=\"png\"/>", "</span>");
    $login_mas = array("<span class=\"nickname\">", "</span>");
    $pos_mas   = array("Город: ", "</p>");
    $level_mas = array("Боевой уровень: <b>", "</b>");
    $cur_helth_mas = array("id=\"curr_helth_val\">", "</span>");
    $helth_mas = array("class=\"health\">/", "</span>"); 



    function 
    get_page($url, $post_data) {
      
    $curl = curl_init($url);
      
      
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      
      
    curl_setopt($curl, CURLOPT_GET, 1);
      
    //curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      
      
    curl_setopt($curl, CURLOPT_USERAGENT, "Opera/9.64 (Windows NT 6.1; U; ru) Presto/2.1.1");
      
      
    $content = curl_exec($curl);
      
    curl_close($curl);
      return 
    $content;
    }

    function 
    modify_link($str) {
      if (
    strpos($str, "a href=")) {
        
    $tmp = explode('"', $str);
        return 
    $tmp[0].'"'.'http://www.icedland.ru/'.$tmp[1].'"'.$tmp[2];
      }
      return 
    $str;
    }

    function 
    get_value_from_page($cont, $str_beg, $str_end, $offset = 0) {
      
    $pos_begin = strpos($cont, $str_beg);
      
    $pos_end = strpos($cont, $str_end, $pos_begin);
      
    $out = substr($cont, $pos_begin + strlen($str_beg) + $offset, $pos_end - ($pos_begin + strlen($str_beg) + $offset)  );
      
      
      return 
    $out; 
    }

    if ( isset(
    $_GET['set']) ) {
      print 
    "
      <form action='onlineSMG.php' method='post'>
        <textarea name='post'>
        
        </textarea>
        <input type='submit'>
      </form>
      "
    ;
      die;
    }

    if ( isset(
    $_POST['post']) ) {
      
    //print var_dump($_POST); die;
      
    $text = $_POST['post'];
      
    //print $text; die;
      
    $b = 1;
      
    $e = 1;
      
    //$f = fopen('tt', "a+");
      //if (!$f) {
      //  print "not open file";
      //  die;
      //}
        
      
    while ($b and $e) {
        
    $b = strpos($text, "<a href='", $e);
        
    $e = strpos($text, "'>", $b);
        if (
    $b and $e) {
          
    $link = 'http://www.icedland.ru'.substr($text, $b + strlen("<a href='"), $e - ($b + strlen("<a href='"))  );
          
          
    $content = get_page($link, '');
          
    $level = get_value_from_page($content, $level_mas[0], $level_mas[1]);
          if (
    $level >= 30)      
            
    //fwrite($f, $link."\n");
            //file_put_contents('tt', $link."\n");
            
    print $link."<br>";
        }
      }
      
    //fclose($f);
      
    die;
    }


    $urls = file('listSMG.txt');  //'http://www.icedland.ru/humaninfo.php?id=194376';

     

    print "

    <html> 
      <head> 
        <title>Online SMG</title>       
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">
      </head>
    <body>
    <style>
      body {
        font-family: Verdana, Arial Narrow, Arial;
        font-size: 16px;
      }
      
      #red {
        color : red;
      }
      
      a {  
        text-decoration: underline;
        color : blue;
      }
        a:hover {    
          text-decoration: underline;      
        }
      
      #blue {
        color : blue;
      }
      
    </style>
    <table cellspacing='0' cellpadding='5'>
      <tr>
        <th>Login</th>
        <th>Status</th>
        <th>Position</th>
      </tr>
    "
    ;

    for (
    $i = 0; $i < sizeof($urls); $i++) {
      
    $content = get_page($urls[$i], '');

      
    $status = modify_link(get_value_from_page($content, $stat_mas[0], $stat_mas[1]));
      
    $login = modify_link(get_value_from_page($content, $login_mas[0], $login_mas[1]));
      
    $pos = strip_tags(get_value_from_page($content, $pos_mas[0], $pos_mas[1]));
      
    $level = get_value_from_page($content, $level_mas[0], $level_mas[1]);
      
    $cur_helth = get_value_from_page($content, $cur_helth_mas[0], $cur_helth_mas[1]);
      
    $helth = get_value_from_page($content, $helth_mas[0], $helth_mas[1]);
      if (
    $cur_helth >= ($helth * 0.6)) 
        
    $cur = 'blue'; 
      else 
        
    $cur = 'red';
      if ((
    $status == 'Персонаж в игре') or (strpos($status, 'В бою') != FALSE) or ($status == 'В заявке на бой') )  {
        print 
    "
          <tr>
            <td><a href='
    {$urls[$i]}'><span ID='$cur'><b>{$login} [{$level}]</b> [{$cur_helth}/{$helth}]</span></a></td>
            <td><span ID='
    $cur'>{$status}</span></td>
            <td>
    {$pos}</td>
          </tr>
        "
    ;
      }
    }

    print 
    "
    </table>
    </body>
    </html>
    "
    ;







    ?>

    кусочек из файла listsmg
    HTML:
    http://www.icedland.ru/humaninfo.php?id=225643
    http://www.icedland.ru/humaninfo.php?id=20629
    http://www.icedland.ru/humaninfo.php?id=162884
    http://www.icedland.ru/humaninfo.php?id=187787
    http://www.icedland.ru/humaninfo.php?id=95641
    http://www.icedland.ru/humaninfo.php?id=55321
    http://www.icedland.ru/humaninfo.php?id=23181
    http://www.icedland.ru/humaninfo.php?id=45402
    
    Сайт с игрой icedland.ru