Показать сообщение отдельно

  #2  
Старый 05.06.2008, 15:21
Isis
Флудер
Регистрация: 20.11.2006
Сообщений: 3,316
Провел на форуме:
16641028

Репутация: 2371


По умолчанию

PHP код:
<?php

    
/**
     * Sms SubGate
     *
     * @author Isis <xeka@xeka.ru>
     * @access private
     * @copyright Isis 28.05.2008
     * @link http://www.vpleer.ru
     * @version 1.0
     */

    /**
     * Set on error_reporting to null
     */
    
error_reporting(0);

    
/**
     * Configuration settings
     *
     * @param string $user value of the account from sms.spb.su
     * @param string $pass value of the account from sms.spb.su
     * @param string $textok value of the text
     * @param boolean $type type of the query send to sms.spb.su
     * @param boolean $ok value of the valid
     */
    
$user        '';
    
$pass        '';
    
$textok        'Vawe sms yspewno otpravleno, spasibo!';
    
$type        1;        # Default, 1 - GET, 2 - POST
    
$ok            0;
    
$errno        '';
    
$errstr        '';
    
$content    '';
    
$error        '';

    
/**
     * Demonstrate values
     */
    
$smsid        $_GET['smsid'];
    
$num        $_GET['num'];
    
$operator    $_GET['operator'];
    
$userid        $_GET['user_id'];
    
$cost        $_GET['cost'];
    
$msg        $_GET['msg'];

    
/**
     * Parsing value to validate\*
     */
    
$parse    explode(" "$msg);
    
$pref    $parse['1'];
    
$phone    $parse['2'];
    
$nick    $parse['3'];
    
$text    str_replace($pref.' '.$phone.' '.$nickNULL$msg);
    
$text    trim(substr($text0160));
    
$query    'user='.$user.'&pass='.$pass.'&phone='.$phone.'&message='.$text.'&from='.$nick;

    
/**
     * Begin
     */
    
if($num && $userid && $cost && $smsid && $operator && $msg)
    {
        
/**
         * Check query from configuration and send
         */
        
if($type == 1)
        {
            
$socket    fsockopen('sms.spb.su'80$errno$errstr5);
            
$header    "GET http://sms.spb.su/sms.cgi?".$query." HTTP/1.1\r\n";
            
$header .= "Host: sms.spb.su\r\n";
            
$header .= "Connection: Close\r\n\r\n";
            
fwrite($socket$header);
            while (!
feof($socket))
            {
                
$content .= fread($socket1);
            }
            
fclose($socket);
        }
        else
        {
            
$socket    fsockopen('sms.spb.su'80$errno$errstr5);
            
$header    "POST http://sms.spb.su/sms.cgi HTTP/1.1\r\n";
            
$header .= "Host: sms.spb.su\r\n";
            
$header .= "User-Agent: SMS SubGate\r\n";
            
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
            
$header .= "Content-Length: ".strlen($query)."\r\n\r\n".$query."\r\n";
            
fwrite($socket$header);
            while (!
feof($socket))
            {
                
$content .= fread($socket,24);
            }
            
fclose($socket);
        }

        
/**
         * Find any errors and continue
         */
        
if(strpos($content'Message successfully sent') !== false)    $ok    1;
        if(
strpos($content'aunthefication failur') !== false)    $error    'Error: aunthefication failure';
        if(
strpos($content'can\'t send this message'$content) !== false)    $error    'Error: can\'t send this message';
        if(
strpos($content'your credit is null') !== false)    $error    'Error: your credit is null';
        if(
strpos($content'unsupported phone number') !== false)    $error    'Error: unsupported phone number';

        
/**
         * Request headers to sms sender
         */
        
if($ok)
        {
            echo 
"smsid:".$smsid."\n";
            echo 
"status:reply\n";
            echo 
"content-type:text/plan\n";
            echo 
"\n";
            echo 
$textok."\n";
        }
        else
        {
            echo 
"smsid:".$smsid."\n";
            echo 
"status:reply\n";
            echo 
"content-type:text/plan\n";
            echo 
"\n";
            echo 
$error."\n";
        }
    }

    
/**
     * The end
     */
?>
Переделаешь чуть-чуть т.к. здесь 2 гейта используются, писал под russianbilling, mpbill