Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Wyskskuje blad curl w 33 linijce! dlaczego?
Forum PHP.pl > Forum > PHP
efrem
Teorytycznie skrypt powiniene dzialac ale wyskakuje mi blad w 33 linijce nie wiem dlaczego ?!

  1. <?PHP
  2. header("Content-type: text/html; charset=UTF-8");
  3.  
  4. /**
  5.  * Licencja CC BY-NC-SA
  6.  * <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl" target="_blank">http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl</a>
  7.  * Klasa mbox umożliwiająca wysyłanie wiadomoœci SMS
  8.  * @author Kacper 'kacka' Szurek
  9.  * @mail kacperszurek (poczta w gmail.com)
  10.  * Jeżeli się przydało - napisz
  11.  * Chcesz podziękować, pomóc masz pytanie - napisz
  12.  * Skrypt przechowuje cookie w katalogu /dane/mbox.txt
  13.  *
  14.  */
  15. class mbox
  16. {
  17.    /**
  18.      * Przechowuje identyfikator połączenia curl
  19.      *
  20.      * @var $ch
  21.      */
  22.    protected $_curl;
  23.  
  24.    /**
  25.      * Ułatwienie dostępu do curl
  26.      *
  27.      * @param string $url - adres strony
  28.      * @param array $post - opcjonalnie tablica parametrów
  29.      * @return string - zwraca pobraną treœć
  30.      */
  31.    public function curl($url, $post = null)
  32.    {
  33.    <br />
  34.    $this->_curl = curl_init();
  35.        
  36.        $var = array(
  37.            CURLOPT_URL => $url,
  38.            CURLOPT_COOKIEJAR => dirname(__FILE__).'/dane/mbox.txt',
  39.            CURLOPT_COOKIEFILE => dirname(__FILE__).'/dane/mbox.txt',
  40.            CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
  41.            CURLOPT_RETURNTRANSFER => true,
  42.            CURLOPT_FOLLOWLOCATION => true);
  43.                    
  44.        if ( !is_null($post) ) {
  45.            foreach ($post as $option => $value) {
  46.                $tmp .= $option. '=' .urlencode($value). '&';
  47.            }
  48.            
  49.            $var[CURLOPT_POST] = true;
  50.            $var[CURLOPT_POSTFIELDS] = $tmp;
  51.        }
  52.            
  53.        curl_setopt_array($this->_curl, $var);
  54.        
  55.        $return = curl_exec($this->_curl);
  56.    
  57.        return $return;
  58.        
  59.        curl_close($this->_curl);
  60.    }
  61.  
  62.    /**
  63.      * Funkcja logująca do <span class="searchlite">orange</span>.pl
  64.      *
  65.      * @param string $user - użytkownik
  66.      * @param string $password - hasło
  67.      */
  68.    public function login($user, $password)
  69.    {
  70.        $data = array(
  71.        '_dyncharset' => 'UTF-8',
  72.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' => 'http://www.orange.pl/portal/map/map/signin',
  73.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL=' => '',
  74.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => 'http://www.orange.pl/portal/map/map/pim',
  75.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => '',
  76.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => $user,
  77.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => '',
  78.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => $password,
  79.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => '',
  80.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' => 10,
  81.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' => 10,
  82.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' => '',
  83.        '&_DARGS' => '/gear/static/signInLoginBox.jsp'
  84.        );
  85.        
  86.        $login = $this->curl('http://www.orange.pl/portal/map/map/signin', $data);
  87.        
  88.        if (preg_match('/Podałeœ błędny login lub hasło. SprawdŸ je i wpisz jeszcze raz/', $login))
  89.        {
  90.            file_put_contents('/dane/mbox.txt', '');
  91.            throw new Exception('Błędne dane logowania.');
  92.        }
  93.    }
  94.    
  95.    /**
  96.      * Funkcja wysyłająca sms, sprawdza jego długoœć i poprawnoœć numeru
  97.      *
  98.      * @param int $to - adres odbiorcy
  99.      * @param string $message - treœć wiadomoœci
  100.      */
  101.    public function send($to, $message)
  102.    {
  103.        if (strlen($message) == 0 || strlen($message) > 640)
  104.        {
  105.            throw new Exception('Wiadomoœć musi mieć mniej niż 640 znaków');
  106.        }
  107.        
  108.        $data = array(
  109.        '_dyncharset' => 'UTF-8',
  110.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => 'sms',
  111.        '&_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => '',
  112.        'enabled' => 'false',
  113.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '/portal/map/map/message_box?mbox_view=newsms',
  114.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '',
  115.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' => '/portal/map/map/message_box?mbox_view=messageslist',
  116.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' =>'',
  117.        'smscounter' => 1,
  118.        'counter' => strlen($message),
  119.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $to,
  120.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => '',
  121.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => '',
  122.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
  123.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => '',
  124.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => 'Wyœlij',
  125.        '_DARGS' => '/gear/mapmessagebox/smsform.jsp',
  126.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x' => 10,
  127.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y' => 10
  128.        );
  129.                
  130.        $send = $this->curl('http://www.orange.pl/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp', $data);
  131.        
  132.        if (preg_match('/Niepoprawny numer telefonu/', $send))
  133.        {
  134.            throw new Exception('Podany numer telefonu jest błędny');
  135.        }
  136.        
  137.        if (preg_match('/Wyszukaj wiadomoœci, których/', $send))
  138.        {
  139.            echo 'Wiadomoœć została prawidłowo wysłana.';
  140.        }
  141.    }
  142. }
  143. try {
  144.    if (!isset($_POST['login']))
  145.    {
  146.        echo '<form method="post" action="mbox2.php5">Login:<input type="text" name="login">
  147. Hasło:<input type="password" name="haslo">
  148. Do kogo:<input type="text" name="do">
  149. Wiadomoœć:<textarea name="tresc" rows="10" cols="40"></textarea><input type="submit" name="wyslij" value="Wyœlij"></form>';
  150.    }
  151.    else {
  152.    $a = new mbox();
  153.    $a->login($_POST['login'], $_POST['haslo']);
  154.    $a->send($_POST['do'], $_POST['tresc']);
  155.    }
  156. } catch (Exception $e)
  157. {
  158.    echo $e->getMessage();
  159. }
  160. ?>



Poradzcie cos:-)
okitoki
bo <br /> który jest w lini 31/32 nie jest poleceniem PHP

Kod
<?PHP
header("Content-type: text/html; charset=UTF-8");

/**
* Licencja CC BY-NC-SA
* <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl" target="_blank">http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl</a>
* Klasa mbox umożliwiająca wysyłanie wiadomoœci SMS
* @author Kacper 'kacka' Szurek
* @mail kacperszurek (poczta w gmail.com)
* Jeżeli się przydało - napisz
* Chcesz podziękować, pomóc masz pytanie - napisz
* Skrypt przechowuje cookie w katalogu /dane/mbox.txt
*
*/
class mbox
{
   /**
    * Przechowuje identyfikator połączenia curl
    *
    * @var $ch
    */
   protected $_curl;

   /**
    * Ułatwienie dostępu do curl
    *
    * @param string $url - adres strony
    * @param array $post - opcjonalnie tablica parametrów
    * @return string - zwraca pobraną treœć
    */
   public function curl($url, $post = null)
   {
  
   $this->_curl = curl_init();
      
       $var = array(
           CURLOPT_URL => $url,
           CURLOPT_COOKIEJAR => dirname(__FILE__).'/dane/mbox.txt',
           CURLOPT_COOKIEFILE => dirname(__FILE__).'/dane/mbox.txt',
           CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
           CURLOPT_RETURNTRANSFER => true,
           CURLOPT_FOLLOWLOCATION => true);
                  
       if ( !is_null($post) ) {
           foreach ($post as $option => $value) {
               $tmp .= $option. '=' .urlencode($value). '&';
           }
          
           $var[CURLOPT_POST] = true;
           $var[CURLOPT_POSTFIELDS] = $tmp;
       }
          
       curl_setopt_array($this->_curl, $var);
      
       $return = curl_exec($this->_curl);
  
       return $return;
      
       curl_close($this->_curl);
   }

   /**
    * Funkcja logująca do <span class="searchlite">orange</span>.pl
    *
    * @param string $user - użytkownik
    * @param string $password - hasło
    */
   public function login($user, $password)
   {
       $data = array(
       '_dyncharset' => 'UTF-8',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' => 'http://www.orange.pl/portal/map/map/signin',
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL=' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => 'http://www.orange.pl/portal/map/map/pim',
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => $user,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => $password,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' => 10,
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' => 10,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' => '',
       '&_DARGS' => '/gear/static/signInLoginBox.jsp'
       );
      
       $login = $this->curl('http://www.orange.pl/portal/map/map/signin', $data);
      
       if (preg_match('/Podałeœ błędny login lub hasło. SprawdŸ je i wpisz jeszcze raz/', $login))
       {
           file_put_contents('/dane/mbox.txt', '');
           throw new Exception('Błędne dane logowania.');
       }
   }
  
   /**
    * Funkcja wysyłająca sms, sprawdza jego długoœć i poprawnoœć numeru
    *
    * @param int $to - adres odbiorcy
    * @param string $message - treœć wiadomoœci
    */
   public function send($to, $message)
   {
       if (strlen($message) == 0 || strlen($message) > 640)
       {
           throw new Exception('Wiadomoœć musi mieć mniej niż 640 znaków');
       }
      
       $data = array(
       '_dyncharset' => 'UTF-8',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => 'sms',
       '&_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => '',
       'enabled' => 'false',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '/portal/map/map/message_box?mbox_view=newsms',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' => '/portal/map/map/message_box?mbox_view=messageslist',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' =>'',
       'smscounter' => 1,
       'counter' => strlen($message),
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $to,
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => '',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => 'Wyœlij',
       '_DARGS' => '/gear/mapmessagebox/smsform.jsp',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x' => 10,
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y' => 10
       );
              
       $send = $this->curl('http://www.orange.pl/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp', $data);
      
       if (preg_match('/Niepoprawny numer telefonu/', $send))
       {
           throw new Exception('Podany numer telefonu jest błędny');
       }
      
       if (preg_match('/Wyszukaj wiadomoœci, których/', $send))
       {
           echo 'Wiadomoœć została prawidłowo wysłana.';
       }
   }
}
try {
   if (!isset($_POST['login']))
   {
       echo '<form method="post" action="mbox2.php5">Login:<input type="text" name="login">
Hasło:<input type="password" name="haslo">
Do kogo:<input type="text" name="do">
Wiadomoœć:<textarea name="tresc" rows="10" cols="40"></textarea><input type="submit" name="wyslij" value="Wyœlij"></form>';
   }
   else {
   $a = new mbox();
   $a->login($_POST['login'], $_POST['haslo']);
   $a->send($_POST['do'], $_POST['tresc']);
   }
} catch (Exception $e)
{
   echo $e->getMessage();
}
?>


widzę że jest to skrypt do logowanej bramki SMS w orange smile.gif
efrem
tak to bra,ka sms w orange ;]


niestety po usunieciu <br> nadal nie chce dzialac w tym miejscu.

nie wiem dlaczego widzi blad w $this->_curl = curl_init();
okitoki
a masz na serwerze curl?, zobacz to

Kod
<?PHP
header("Content-type: text/html; charset=UTF-8");

/**
* Licencja CC BY-NC-SA
* <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl" target="_blank">http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl</a>
* Klasa mbox umożliwiająca wysyłanie wiadomoœci SMS
* @author Kacper 'kacka' Szurek
* @mail kacperszurek (poczta w gmail.com)
* Jeżeli się przydało - napisz
* Chcesz podziękować, pomóc masz pytanie - napisz
* Skrypt przechowuje cookie w katalogu /dane/mbox.txt
*
*/
class mbox
{
   /**
    * Przechowuje identyfikator połączenia curl
    *
    * @var $ch
    */
   protected $_curl;

   /**
    * Ułatwienie dostępu do curl
    *
    * @param string $url - adres strony
    * @param array $post - opcjonalnie tablica parametrów
    * @return string - zwraca pobraną treœć
    */
   public function curl($url, $post = null)
   {
   if(!function_exists(curl_init))
     die('cURL nie zosal zainstalowany');
   $this->_curl = curl_init();
      
       $var = array(
           CURLOPT_URL => $url,
           CURLOPT_COOKIEJAR => dirname(__FILE__).'/dane/mbox.txt',
           CURLOPT_COOKIEFILE => dirname(__FILE__).'/dane/mbox.txt',
           CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
           CURLOPT_RETURNTRANSFER => true,
           CURLOPT_FOLLOWLOCATION => true);
                  
       if ( !is_null($post) ) {
           foreach ($post as $option => $value) {
               $tmp .= $option. '=' .urlencode($value). '&';
           }
          
           $var[CURLOPT_POST] = true;
           $var[CURLOPT_POSTFIELDS] = $tmp;
       }
          
       curl_setopt_array($this->_curl, $var);
      
       $return = curl_exec($this->_curl);
  
       return $return;
      
       curl_close($this->_curl);
   }

   /**
    * Funkcja logująca do <span class="searchlite">orange</span>.pl
    *
    * @param string $user - użytkownik
    * @param string $password - hasło
    */
   public function login($user, $password)
   {
       $data = array(
       '_dyncharset' => 'UTF-8',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' => 'http://www.orange.pl/portal/map/map/signin',
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL=' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => 'http://www.orange.pl/portal/map/map/pim',
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => $user,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => $password,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => '',
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' => 10,
       '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' => 10,
       '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' => '',
       '&_DARGS' => '/gear/static/signInLoginBox.jsp'
       );
      
       $login = $this->curl('http://www.orange.pl/portal/map/map/signin', $data);
      
       if (preg_match('/Podałeœ błędny login lub hasło. SprawdŸ je i wpisz jeszcze raz/', $login))
       {
           file_put_contents('/dane/mbox.txt', '');
           throw new Exception('Błędne dane logowania.');
       }
   }
  
   /**
    * Funkcja wysyłająca sms, sprawdza jego długoœć i poprawnoœć numeru
    *
    * @param int $to - adres odbiorcy
    * @param string $message - treœć wiadomoœci
    */
   public function send($to, $message)
   {
       if (strlen($message) == 0 || strlen($message) > 640)
       {
           throw new Exception('Wiadomoœć musi mieć mniej niż 640 znaków');
       }
      
       $data = array(
       '_dyncharset' => 'UTF-8',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => 'sms',
       '&_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => '',
       'enabled' => 'false',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '/portal/map/map/message_box?mbox_view=newsms',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' => '/portal/map/map/message_box?mbox_view=messageslist',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' =>'',
       'smscounter' => 1,
       'counter' => strlen($message),
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $to,
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => '',
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
       '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => '',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => 'Wyœlij',
       '_DARGS' => '/gear/mapmessagebox/smsform.jsp',
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x' => 10,
       '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y' => 10
       );
              
       $send = $this->curl('http://www.orange.pl/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp', $data);
      
       if (preg_match('/Niepoprawny numer telefonu/', $send))
       {
           throw new Exception('Podany numer telefonu jest błędny');
       }
      
       if (preg_match('/Wyszukaj wiadomoœci, których/', $send))
       {
           echo 'Wiadomoœć została prawidłowo wysłana.';
       }
   }
}
try {
   if (!isset($_POST['login']))
   {
       echo '<form method="post" action="mbox2.php5">Login:<input type="text" name="login">
Hasło:<input type="password" name="haslo">
Do kogo:<input type="text" name="do">
Wiadomoœć:<textarea name="tresc" rows="10" cols="40"></textarea><input type="submit" name="wyslij" value="Wyœlij"></form>';
   }
   else {
   $a = new mbox();
   $a->login($_POST['login'], $_POST['haslo']);
   $a->send($_POST['do'], $_POST['tresc']);
   }
} catch (Exception $e)
{
   echo $e->getMessage();
}
?>
To jest wersja lo-fi głównej zawarto¶ci. Aby zobaczyć pełn± wersję z większ± zawarto¶ci±, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.