[SCRIPT] SMS Donate

Тема в разделе "Веб скрипты (WEB)", создана пользователем root, 1 окт 2014.

  1. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    254
    Симпатии:
    58
    Баллы:
    11
    Код:
    <?php $mssql_address = "127.0.0.1"; 
    $mssql_login="login"; 
    $mssql_password="password"; 
    $lin2db_dbname = "lin2db"; 
    $lin2world_dbname = "lin2world"; 
    $lin2log_dbname = "lin2log"; 
    
    
    //Cached ъ¤°********************************************************************// 
    $cached_ip="127.0.0.1"; 
    $cached_port="2012"; 
    
    
    /*****************************************************************************/ 
    function writeD($packet, $d) { 
      $b4 = ($d & 0x000000FF); 
      $b3 = ($d & 0x0000FF00) >> 8; 
      $b2 = ($d & 0x00FF0000) >> 16; 
      $b1 = ($d & 0xFF000000) >> 24; 
      $packet = $packet.chr($b4).chr($b3).chr($b2).chr($b1); 
      return $packet; 
    } 
    
    
    /*****************************************************************************/ 
    function writeS($packet, $strs) { 
        for ($i=0; $i<strlen($strs); $i++) { 
          $packet = $packet.$strs[$i].chr(0); 
        } 
      $packet = $packet.chr(0).chr(0); 
    
    
      return $packet; 
    } 
    
    
    function GetCharID ($char_name){ 
    global $lin2world_dbname; 
      mssql_select_db ("$lin2world_dbname");   
      $msql = "select char_id from user_data where char_name='$char_name'"; 
      $result = mssql_query($msql); 
      $row = mssql_fetch_row($result); 
      $char_id = $row[0]; 
      return $char_id; 
    } 
    
    
    function GetCharAdena ($char_id){ 
    global $lin2world_dbname; 
      mssql_select_db ("$lin2world_dbname");   
      $msql = "select amount from user_item where item_type = 57 and char_id = $char_id"; 
      $result = mssql_query($msql); 
      $row = mssql_fetch_row($result); 
      return $row[0]; 
    } 
    
    
    /*****************************************************************************/ 
    function cached($command){ 
    global $cached_ip,$cached_port; 
      $fp=fsockopen("$cached_ip", $cached_port, $errno, $errstr); 
      if(!$fp)return 0; 
      else{ 
        $b2 = (strlen($command)+2) & 0x000000FF; 
        $b1 = ((strlen($command)+2) & 0x0000FF00) >> 8; 
        $command = chr($b2).chr($b1).$command; 
        fwrite($fp, $command); 
        stream_set_timeout($fp, 2); 
        $ans=fgets($fp,8); 
        $answ = "0"; 
        if (ord($ans[3]) == 1) { 
        $answ = "1"; 
        } 
        return "$answ";   
      } 
    } 
    /*****************************************************************************/ 
    function kick_char($char_name){ 
    global $cached_errors; 
      $char_id = GetCharID($char_name); 
      $command = ''; 
      $command = chr (5); 
      $command = writeD($command, $char_id); 
      $command = writeS($command, $char_name); 
      $answ=cached($command); 
      usleep(500000); 
      $answ=cached($command); 
      return $answ; 
    }   
    /*****************************************************************************/ 
    function add_item_to_char($char_name,$item_type,$amount){ 
    global $cached_errors; 
      kick_char($char_name); 
    //dddddddddS 
      $char_id = GetCharID($char_name); 
      $command = ''; 
      $command = chr(55); 
      $command = writeD($command, $char_id); 
      $command = writeD($command, 0); 
      $command = writeD($command, $item_type); 
      $command = writeD($command, $amount); 
      $command = writeD($command, 0); 
      $command = writeD($command, 0); 
      $command = writeD($command, 0); 
      $command = writeD($command, 0); 
      $command = writeD($command, 0); 
      $command = writeS($command, $char_name); 
      $answ=cached($command); 
      return $answ; 
    } 
    
    
    $f=fopen("\logs\sms.log","a+"); 
    fprintf($f, "---------------------------------------------------------------\n"); 
    fprintf($f, "%s: SMS transaction begin\n", date("d.m.Y H:i:s")); 
    if (IsSet($_GET)){ 
    $dest = $_GET['dest']; 
    $opi = $_GET['opi']; 
    $message = urldecode($_GET['message']); 
    $src = $_GET['src']; 
    $transID = $_GET['transid']; 
    $s = explode (" ",$message); 
    $char_id = $s[1]; 
    fprintf($f,"    + MSG: IP = %s, TransID (TID) = %s, Dest = %s,  Src = %s, Opi = %s, char_id = %s, Message = '%s'.\n",$_SERVER['REMOTE_ADDR'], $transID, $dest, $src, $opi, $char_id, $message); 
    // BANNED 
    if ($src == '7910XXXXXXX') { 
      fprintf($f,"    ! ERROR: %s", "Perevod NE prinyat. Svyazhites s administraciei: [email protected]\n"); 
      fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Perevod NE prinyat. Svyazhites s administraciei: [email protected] TID=$transID"); 
    } 
    
    
    if ($char_id == '') { 
      fprintf($f,"    ! ERROR: %s", "CharID missing. Unable to proceed.\n"); 
      fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Ne ukazan identifikator personaja! TID=$transID"); 
    } 
    
    
    $dbconnect = mssql_connect ("127.0.0.1","login","password"); 
    
    
    if (! mssql_select_db ("lin2world", $dbconnect)) 
    { 
       fprintf($f,"    ! ERROR: MSSQL Error = '%s'\n", mssql_error()); 
       fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
       fclose($f); 
       die (" Oshibka bazy dannyh. TID=$transID"); 
    } 
    
    
    /* check limits */ 
    $sql = "select count(reason) as qty, reason from transact 
    where DateDiff(hour,init_time, GETDATE()) < 24 and reason like '%$src' 
    group by reason 
    order by reason 
    "; 
    $res = mssql_query($sql); 
    $row = mssql_fetch_row($res); 
    if ((mssql_num_rows($res) > 0)&&$row[0] >= 30 ) { 
      fprintf($f,"    ! ERROR: 30 SMS per day limit exceeded from #%s!\n", $src); 
      fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Oshibka! Voznagrajdenie NE nachisleno! Vy otoslali uje bolee 30-ti SMS za poslednie 24 chasa! TID=$transID"); 
    } 
    /* check limits ends */ 
    
    
    
    
    
    
    $sql = "select * from user_data where char_id = $char_id"; 
    $res = mssql_query($sql); 
    if (mssql_num_rows($res) == 0 ) { 
      fprintf($f,"    ! ERROR: Wrong CharID (%s) specified. Unable to proceed.\n", $char_id); 
      fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Neverniy identifikator personaja ($char_id). TID=$transID"); 
    } 
    $row = mssql_fetch_row($res); 
    $char_name = $row[0]; 
    
    
    switch ($dest) { 
    case 1601: 
       $reward = 175000; 
       break; 
    case 2222: 
       $reward = 800000; 
       break; 
    default: 
       fprintf($f,"    ! ERROR: Wrong Short SMS number (%s) specified. Unable to proceed.\n", $dest); 
       fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
       fclose($f); 
       die ("Neizvestniy sms nomer. TID=$transID"); 
       break; 
    } 
    $sql = "INSERT INTO [lin2world].[dbo].transact (type, status, char_id, item_type, amount, reason, comment, tid) VALUES (51, 0, $char_id, 57, $reward, 'SMS donation from $src', 'TransID = $transID, operator = $opi, sms#=$dest, message = $message', $transID)".chr(10).chr(13)."select scope_identity()"; 
    $upd = mssql_query($sql); 
    $row = mssql_fetch_row($upd); 
    $tr_record = $row[0]; 
    kick_char($char_name); 
    $old_adena = GetCharAdena($char_id); 
    if (add_item_to_char($char_name, 57, $reward) == "0") 
    { 
      fprintf($f,"    ! ERROR: add_item_to_char failed! Unable to proceed.\n"); 
      fprintf($f,"    ! MSG: Transaction pending. [lin2world].[dbo].[transact].uid = %d (status = 0). Unable to proceed.\n", $tr_record); 
      fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Oshibka obrabotki zaprosa (04). TID=$transID"); 
    } 
      usleep(100); 
    $new_adena = GetCharAdena($char_id); 
    /* 
    if ( $new_adena < $old_adena + $reward ) { 
      fprintf($f,"    ! ERROR: Adena reward verification error. Char adena amount before transaction %d, after = %d (reward = %d). Unable to proceed.\n", $old_adena, $new_adena, $reward); 
      fprintf($f,"    ! MSG: Transaction pending. [lin2world].[dbo].[transact].uid = %d (status = 0). Unable to proceed.\n", $tr_record); 
      fprintf($f,"%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
      fclose($f); 
      die ("Oshibka obrabotki zaprosa (05). TID=$transID"); 
    } 
    */ 
    $sql = "update [lin2world].[dbo].transact set status = 1, close_time = GETDATE() where uid = ".$tr_record; 
    $upd = mssql_query($sql); 
    echo "<SERVER> blagodarit vas za podderjku! Voznagrajdenie v $reward aden perechisleno personaju $char_name."; 
    fprintf($f, "    + MSG: Transaction successfully finished. Char '%s' (%d) is awarded by %s adena.\n", $char_name, $char_id, $reward); 
    fprintf($f, "    + MSG: Transaction closed. [lin2world].[dbo].[transact].uid = %d (status = 1).\n", $tr_record); 
    fprintf($f, "%s: SMS transaction end\n", date("d.m.Y H:i:s")); 
    fclose($f); 
    
    
    } 
    ?>
     
  2. pacman2ebawer

    pacman2ebawer Member User

    Регистрация:
    1 июл 2015
    Сообщения:
    40
    Симпатии:
    2
    Баллы:
    8
    Вбросил скрип а дальше сами разбирайтесь ?:) так не делается. ща попробую инструкцию накатать если у меня получиться.
     
  3. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    254
    Симпатии:
    58
    Баллы:
    11
    Это старый скрипт от 2008 года, информации по применению увы не осталось, зато есть код, грамотные администрации смогут разобраться что к чему.